@ryupold/vode 1.1.1 → 1.1.3
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 +33 -26
- package/dist/vode.js +38 -70
- package/dist/vode.min.js +1 -1
- package/dist/vode.min.mjs +1 -1
- package/dist/vode.mjs +40 -73
- package/index.ts +1 -2
- package/package.json +1 -1
- package/src/vode.ts +42 -40
- package/tsconfig.json +0 -1
- package/src/html.ts +0 -37
package/README.md
CHANGED
|
@@ -144,7 +144,7 @@ Imagine this HTML:
|
|
|
144
144
|
<div class="card-image">
|
|
145
145
|
<figure class="image is-4by3">
|
|
146
146
|
<img
|
|
147
|
-
src="
|
|
147
|
+
src="placeholders/1280x960.png"
|
|
148
148
|
alt="Placeholder image"
|
|
149
149
|
/>
|
|
150
150
|
</figure>
|
|
@@ -154,7 +154,7 @@ Imagine this HTML:
|
|
|
154
154
|
<div class="media-left">
|
|
155
155
|
<figure class="image is-48x48">
|
|
156
156
|
<img
|
|
157
|
-
src="
|
|
157
|
+
src="placeholders/96x96.png"
|
|
158
158
|
alt="Placeholder image"
|
|
159
159
|
/>
|
|
160
160
|
</figure>
|
|
@@ -166,8 +166,7 @@ Imagine this HTML:
|
|
|
166
166
|
</div>
|
|
167
167
|
|
|
168
168
|
<div class="content">
|
|
169
|
-
Lorem ipsum dolor sit amet, consectetur adipiscing elit.
|
|
170
|
-
iaculis mauris. <a>@bulmaio</a>. <a href="#">#css</a>
|
|
169
|
+
Lorem ipsum dolor sit amet, consectetur adipiscing elit. <a href="?post=vode">vode</a>. <a href="#">#css</a>
|
|
171
170
|
<a href="#">#responsive</a>
|
|
172
171
|
<br />
|
|
173
172
|
<time datetime="2025-09-24">10:09 PM - 24 Sep 2025</time>
|
|
@@ -179,36 +178,36 @@ Imagine this HTML:
|
|
|
179
178
|
expressed as **"vode"** it would look like this:
|
|
180
179
|
|
|
181
180
|
```ts
|
|
182
|
-
[DIV, { class:
|
|
183
|
-
[DIV, { class:
|
|
184
|
-
[FIGURE, { class:
|
|
181
|
+
[DIV, { class: 'card' },
|
|
182
|
+
[DIV, { class: 'card-image' },
|
|
183
|
+
[FIGURE, { class: 'image is-4by3' },
|
|
185
184
|
[IMG, {
|
|
186
|
-
src:
|
|
187
|
-
alt:
|
|
185
|
+
src: 'placeholders/1280x960.png',
|
|
186
|
+
alt: 'Placeholder image'
|
|
188
187
|
}]
|
|
189
188
|
]
|
|
190
189
|
],
|
|
191
|
-
[DIV, { class:
|
|
192
|
-
[DIV, { class:
|
|
193
|
-
[DIV, { class:
|
|
194
|
-
[FIGURE, { class:
|
|
190
|
+
[DIV, { class: 'card-content' },
|
|
191
|
+
[DIV, { class: 'media' },
|
|
192
|
+
[DIV, { class: 'media-left' },
|
|
193
|
+
[FIGURE, { class: 'image is-48x48' },
|
|
195
194
|
[IMG, {
|
|
196
|
-
src:
|
|
197
|
-
alt:
|
|
195
|
+
src: 'placeholders/96x96.png',
|
|
196
|
+
alt: 'Placeholder image'
|
|
198
197
|
}]
|
|
199
198
|
]
|
|
200
199
|
],
|
|
201
|
-
[DIV, { class:
|
|
202
|
-
[P, { class:
|
|
203
|
-
[P, { class:
|
|
200
|
+
[DIV, { class: 'media-content' },
|
|
201
|
+
[P, { class: 'title is-4' }, 'John Smith'],
|
|
202
|
+
[P, { class: 'subtitle is-6' }, '@johnsmith']
|
|
204
203
|
]
|
|
205
204
|
],
|
|
206
|
-
[DIV, { class:
|
|
207
|
-
|
|
208
|
-
[A,
|
|
209
|
-
[A, { href:
|
|
205
|
+
[DIV, { class: 'content' },
|
|
206
|
+
'Lorem ipsum dolor sit amet, consectetur adipiscing elit. ',
|
|
207
|
+
[A, {href: '?post=vode'}, 'vode'], '. ', [A, { href: '#' }, '#css'],
|
|
208
|
+
[A, { href: '#' }, '#responsive'],
|
|
210
209
|
[BR],
|
|
211
|
-
[TIME, { datetime:
|
|
210
|
+
[TIME, { datetime: '2025-09-24' }, '10:09 PM - 24 Sep 2025']
|
|
212
211
|
]
|
|
213
212
|
]
|
|
214
213
|
]
|
|
@@ -317,10 +316,10 @@ const patch = app(containerNode, state, (s) => CompFooBar(s));
|
|
|
317
316
|
```
|
|
318
317
|
It will analyse the current structure of the given `containerNode` and adjust its structure in the first render. When render-patches are applied to the `patch` function or via yield/return of events, the `containerNode` is updated to match the vode structure 1:1.
|
|
319
318
|
|
|
320
|
-
####
|
|
319
|
+
#### isolated state
|
|
321
320
|
You can have multiple isolated vode app instances on a page, each with its own state and render function. The returned patch function from `app` can be used to synchronize the state between them.
|
|
322
321
|
|
|
323
|
-
####
|
|
322
|
+
#### isolated app
|
|
324
323
|
It is possible to nest vode-apps inside vode-apps, but the library is not opionated on how you do that. One can imagine this type of component:
|
|
325
324
|
|
|
326
325
|
```ts
|
|
@@ -396,6 +395,14 @@ s.patch(null);
|
|
|
396
395
|
|
|
397
396
|
// setting a property in a patch to undefined deletes it from the state object
|
|
398
397
|
s.patch({ pointing: undefined });
|
|
398
|
+
|
|
399
|
+
//❌ it is discouraged to patch inside the render step 💩
|
|
400
|
+
const ComponentEwww = (s) => {
|
|
401
|
+
if(!s.isLoading)
|
|
402
|
+
s.patch(() => startLoading());
|
|
403
|
+
|
|
404
|
+
return [DIV, s.loading ? [PROGRESS] : s.title];
|
|
405
|
+
}
|
|
399
406
|
```
|
|
400
407
|
|
|
401
408
|
### memoization
|
|
@@ -426,7 +433,7 @@ const CompMemoFooBar = (s) => [DIV, { class: "container" },
|
|
|
426
433
|
|
|
427
434
|
### Direct access to DOM elements
|
|
428
435
|
|
|
429
|
-
Additionally to the standard HTML attributes, you can define 2 special event attributes: `onMount(State, Element)` and `onUnmount(State, Element)` in the vode props. These are called when the element is created or removed during rendering. They receive the `State` as the first argument and the DOM element as the second argument. Like the other events they can be patches too.
|
|
436
|
+
Additionally to the standard HTML attributes, you can define 2 special event attributes: `onMount(State, Element)` and `onUnmount(State, Element)` in the vode props. These are called when the element is created or removed during rendering. They receive the `State` as the first argument and the DOM element as the second argument. Like the other events they can be patches too.
|
|
430
437
|
|
|
431
438
|
## Contributing
|
|
432
439
|
|
package/dist/vode.js
CHANGED
|
@@ -227,7 +227,7 @@ var V = (() => {
|
|
|
227
227
|
childrenStart: () => childrenStart,
|
|
228
228
|
createPatch: () => createPatch,
|
|
229
229
|
createState: () => createState,
|
|
230
|
-
|
|
230
|
+
hydrate: () => hydrate,
|
|
231
231
|
memo: () => memo,
|
|
232
232
|
mergeClass: () => mergeClass,
|
|
233
233
|
props: () => props,
|
|
@@ -311,8 +311,9 @@ var V = (() => {
|
|
|
311
311
|
_vode.q = null;
|
|
312
312
|
const vom = dom(_vode.state);
|
|
313
313
|
_vode.vode = render(_vode.state, _vode.patch, container.parentElement, 0, _vode.vode, vom);
|
|
314
|
-
if (container.tagName !== vom[0].toUpperCase()) {
|
|
314
|
+
if (container.tagName.toUpperCase() !== vom[0].toUpperCase()) {
|
|
315
315
|
container = _vode.vode.node;
|
|
316
|
+
container._vode = _vode;
|
|
316
317
|
}
|
|
317
318
|
} finally {
|
|
318
319
|
_vode.isRendering = false;
|
|
@@ -342,6 +343,41 @@ var V = (() => {
|
|
|
342
343
|
}
|
|
343
344
|
return _vode.patch;
|
|
344
345
|
}
|
|
346
|
+
function hydrate(element) {
|
|
347
|
+
if (element?.nodeType === Node.TEXT_NODE) {
|
|
348
|
+
if (element.nodeValue?.trim() !== "")
|
|
349
|
+
return element;
|
|
350
|
+
return void 0;
|
|
351
|
+
} else if (element.nodeType === Node.COMMENT_NODE) {
|
|
352
|
+
return void 0;
|
|
353
|
+
} else if (element.nodeType === Node.ELEMENT_NODE) {
|
|
354
|
+
const tag2 = element.tagName.toLowerCase();
|
|
355
|
+
const root = [tag2];
|
|
356
|
+
root.node = element;
|
|
357
|
+
if (element?.hasAttributes()) {
|
|
358
|
+
const props2 = {};
|
|
359
|
+
const attr = element.attributes;
|
|
360
|
+
for (let a of attr) {
|
|
361
|
+
props2[a.name] = a.value;
|
|
362
|
+
}
|
|
363
|
+
root.push(props2);
|
|
364
|
+
}
|
|
365
|
+
if (element.hasChildNodes()) {
|
|
366
|
+
const remove = [];
|
|
367
|
+
for (let child2 of element.childNodes) {
|
|
368
|
+
const wet = child2 && hydrate(child2);
|
|
369
|
+
if (wet) root.push(wet);
|
|
370
|
+
else if (child2) remove.push(child2);
|
|
371
|
+
}
|
|
372
|
+
for (let child2 of remove) {
|
|
373
|
+
child2.remove();
|
|
374
|
+
}
|
|
375
|
+
}
|
|
376
|
+
return root;
|
|
377
|
+
} else {
|
|
378
|
+
return void 0;
|
|
379
|
+
}
|
|
380
|
+
}
|
|
345
381
|
function memo(compare, componentOrProps) {
|
|
346
382
|
componentOrProps.__memo = compare;
|
|
347
383
|
return componentOrProps;
|
|
@@ -451,41 +487,6 @@ var V = (() => {
|
|
|
451
487
|
}
|
|
452
488
|
return target;
|
|
453
489
|
}
|
|
454
|
-
function hydrate(element) {
|
|
455
|
-
if (element?.nodeType === Node.TEXT_NODE) {
|
|
456
|
-
if (element.nodeValue?.trim() !== "")
|
|
457
|
-
return element;
|
|
458
|
-
return void 0;
|
|
459
|
-
} else if (element.nodeType === Node.COMMENT_NODE) {
|
|
460
|
-
return void 0;
|
|
461
|
-
} else if (element.nodeType === Node.ELEMENT_NODE) {
|
|
462
|
-
const tag2 = element.tagName.toLowerCase();
|
|
463
|
-
const root = [tag2];
|
|
464
|
-
root.node = element;
|
|
465
|
-
if (element?.hasAttributes()) {
|
|
466
|
-
const props2 = {};
|
|
467
|
-
const attr = element.attributes;
|
|
468
|
-
for (let a of attr) {
|
|
469
|
-
props2[a.name] = a.value;
|
|
470
|
-
}
|
|
471
|
-
root.push(props2);
|
|
472
|
-
}
|
|
473
|
-
if (element.hasChildNodes()) {
|
|
474
|
-
const remove = [];
|
|
475
|
-
for (let child2 of element.childNodes) {
|
|
476
|
-
const wet = child2 && hydrate(child2);
|
|
477
|
-
if (wet) root.push(wet);
|
|
478
|
-
else if (child2) remove.push(child2);
|
|
479
|
-
}
|
|
480
|
-
for (let child2 of remove) {
|
|
481
|
-
child2.remove();
|
|
482
|
-
}
|
|
483
|
-
}
|
|
484
|
-
return root;
|
|
485
|
-
} else {
|
|
486
|
-
return void 0;
|
|
487
|
-
}
|
|
488
|
-
}
|
|
489
490
|
function render(state, patch, parent, childIndex, oldVode, newVode, svg) {
|
|
490
491
|
newVode = remember(state, newVode, oldVode);
|
|
491
492
|
const isNoVode = !newVode || typeof newVode === "number" || typeof newVode === "boolean";
|
|
@@ -939,38 +940,5 @@ var V = (() => {
|
|
|
939
940
|
var MUNDER = "munder";
|
|
940
941
|
var MUNDEROVER = "munderover";
|
|
941
942
|
var SEMANTICS = "semantics";
|
|
942
|
-
|
|
943
|
-
// src/html.ts
|
|
944
|
-
function htmlToVode(html) {
|
|
945
|
-
const div = document.createElement("div");
|
|
946
|
-
div.innerHTML = html.trim();
|
|
947
|
-
const vodes = [];
|
|
948
|
-
for (const child2 of div.childNodes) {
|
|
949
|
-
const v = elementToVode(child2);
|
|
950
|
-
if (v != null) vodes.push(v);
|
|
951
|
-
}
|
|
952
|
-
return vodes;
|
|
953
|
-
}
|
|
954
|
-
function elementToVode(element) {
|
|
955
|
-
if (element.nodeType === Node.TEXT_NODE) {
|
|
956
|
-
return element.textContent;
|
|
957
|
-
}
|
|
958
|
-
if (element.nodeType !== Node.ELEMENT_NODE) {
|
|
959
|
-
return void 0;
|
|
960
|
-
}
|
|
961
|
-
const vode2 = [element.tagName.toLowerCase()];
|
|
962
|
-
if (element.hasAttributes()) {
|
|
963
|
-
const props2 = {};
|
|
964
|
-
for (const att of element.attributes) {
|
|
965
|
-
props2[att.name] = att.value;
|
|
966
|
-
}
|
|
967
|
-
vode2.push(props2);
|
|
968
|
-
}
|
|
969
|
-
for (const child2 of element.childNodes) {
|
|
970
|
-
const v = elementToVode(child2);
|
|
971
|
-
if (v && (typeof v !== "string" || v.length > 0)) vode2.push(v);
|
|
972
|
-
}
|
|
973
|
-
return vode2;
|
|
974
|
-
}
|
|
975
943
|
return __toCommonJS(index_exports);
|
|
976
944
|
})();
|
package/dist/vode.min.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var V=(()=>{var M=Object.defineProperty;var V=Object.getOwnPropertyDescriptor;var G=Object.getOwnPropertyNames;var k=Object.prototype.hasOwnProperty;var H=(t,o)=>{for(var r in o)M(t,r,{get:o[r],enumerable:!0})},U=(t,o,r,s)=>{if(o&&typeof o=="object"||typeof o=="function")for(let e of G(o))!k.call(t,e)&&e!==r&&M(t,e,{get:()=>o[e],enumerable:!(s=V(o,e))||s.enumerable});return t};var j=t=>U(M({},"__esModule",{value:!0}),t);var Hn={};H(Hn,{A:()=>Z,ABBR:()=>w,ADDRESS:()=>tt,ANIMATE:()=>to,ANIMATEMOTION:()=>eo,ANIMATETRANSFORM:()=>oo,ANNOTATION:()=>an,ANNOTATION_XML:()=>cn,AREA:()=>et,ARTICLE:()=>ot,ASIDE:()=>nt,AUDIO:()=>rt,B:()=>st,BASE:()=>at,BDI:()=>ct,BDO:()=>it,BLOCKQUOTE:()=>pt,BODY:()=>Tt,BR:()=>ft,BUTTON:()=>lt,CANVAS:()=>dt,CAPTION:()=>St,CIRCLE:()=>no,CITE:()=>gt,CLIPPATH:()=>ro,CODE:()=>ut,COL:()=>xt,COLGROUP:()=>yt,DATA:()=>Et,DATALIST:()=>mt,DD:()=>ht,DEFS:()=>so,DEL:()=>At,DESC:()=>ao,DETAILS:()=>Pt,DFN:()=>Nt,DIALOG:()=>Ct,DIV:()=>Mt,DL:()=>Ot,DT:()=>Rt,ELLIPSE:()=>co,EM:()=>Lt,EMBED:()=>bt,FEBLEND:()=>io,FECOLORMATRIX:()=>po,FECOMPONENTTRANSFER:()=>To,FECOMPOSITE:()=>fo,FECONVOLVEMATRIX:()=>lo,FEDIFFUSELIGHTING:()=>So,FEDISPLACEMENTMAP:()=>go,FEDISTANTLIGHT:()=>uo,FEDROPSHADOW:()=>xo,FEFLOOD:()=>yo,FEFUNCA:()=>Eo,FEFUNCB:()=>mo,FEFUNCG:()=>ho,FEFUNCR:()=>Ao,FEGAUSSIANBLUR:()=>Po,FEIMAGE:()=>No,FEMERGE:()=>Co,FEMERGENODE:()=>Mo,FEMORPHOLOGY:()=>Oo,FEOFFSET:()=>Ro,FEPOINTLIGHT:()=>Lo,FESPECULARLIGHTING:()=>bo,FESPOTLIGHT:()=>Do,FETILE:()=>Io,FETURBULENCE:()=>vo,FIELDSET:()=>Dt,FIGCAPTION:()=>It,FIGURE:()=>vt,FILTER:()=>Fo,FOOTER:()=>Ft,FOREIGNOBJECT:()=>Vo,FORM:()=>Vt,G:()=>Go,H1:()=>Gt,H2:()=>kt,H3:()=>Ht,H4:()=>Ut,H5:()=>jt,H6:()=>Bt,HEAD:()=>_t,HEADER:()=>Kt,HGROUP:()=>Xt,HR:()=>qt,HTML:()=>Yt,I:()=>Wt,IFRAME:()=>$t,IMAGE:()=>ko,IMG:()=>Jt,INPUT:()=>Qt,INS:()=>zt,KBD:()=>Zt,LABEL:()=>wt,LEGEND:()=>te,LI:()=>ee,LINE:()=>Ho,LINEARGRADIENT:()=>Uo,LINK:()=>oe,MACTION:()=>pn,MAIN:()=>ne,MAP:()=>re,MARK:()=>se,MARKER:()=>jo,MASK:()=>Bo,MATH:()=>Tn,MENU:()=>ae,MERROR:()=>fn,META:()=>ce,METADATA:()=>_o,METER:()=>ie,MFRAC:()=>ln,MI:()=>dn,MMULTISCRIPTS:()=>Sn,MN:()=>gn,MO:()=>un,MOVER:()=>xn,MPADDED:()=>yn,MPATH:()=>Ko,MPHANTOM:()=>En,MPRESCRIPTS:()=>mn,MROOT:()=>hn,MROW:()=>An,MS:()=>Pn,MSPACE:()=>Nn,MSQRT:()=>Cn,MSTYLE:()=>Mn,MSUB:()=>On,MSUBSUP:()=>Rn,MSUP:()=>Ln,MTABLE:()=>bn,MTD:()=>Dn,MTEXT:()=>In,MTR:()=>vn,MUNDER:()=>Fn,MUNDEROVER:()=>Vn,NAV:()=>pe,NOSCRIPT:()=>Te,OBJECT:()=>fe,OL:()=>le,OPTGROUP:()=>de,OPTION:()=>Se,OUTPUT:()=>ge,P:()=>ue,PATH:()=>Xo,PATTERN:()=>qo,PICTURE:()=>xe,POLYGON:()=>Yo,POLYLINE:()=>Wo,PRE:()=>ye,PROGRESS:()=>Ee,Q:()=>me,RADIALGRADIENT:()=>$o,RECT:()=>Jo,RP:()=>he,RT:()=>Ae,RUBY:()=>Pe,S:()=>Ne,SAMP:()=>Ce,SCRIPT:()=>Me,SECTION:()=>Oe,SELECT:()=>Re,SEMANTICS:()=>Gn,SET:()=>Qo,SLOT:()=>Le,SMALL:()=>be,SOURCE:()=>De,SPAN:()=>Ie,STOP:()=>zo,STRONG:()=>ve,STYLE:()=>Fe,SUB:()=>Ve,SUMMARY:()=>Ge,SUP:()=>ke,SVG:()=>Zo,SWITCH:()=>wo,SYMBOL:()=>tn,TABLE:()=>He,TBODY:()=>Ue,TD:()=>je,TEMPLATE:()=>Be,TEXT:()=>en,TEXTAREA:()=>_e,TEXTPATH:()=>on,TFOOT:()=>Ke,TH:()=>Xe,THEAD:()=>qe,TIME:()=>Ye,TITLE:()=>We,TR:()=>$e,TRACK:()=>Je,TSPAN:()=>nn,U:()=>Qe,UL:()=>ze,USE:()=>rn,VIDEO:()=>Ze,VIEW:()=>sn,WBR:()=>we,app:()=>_,child:()=>J,childCount:()=>$,children:()=>A,childrenStart:()=>N,createPatch:()=>q,createState:()=>X,htmlToVode:()=>kn,memo:()=>K,mergeClass:()=>W,props:()=>S,tag:()=>Y,vode:()=>B});function B(t,o,...r){if(!t)throw new Error("tag must be a string or vode");return Array.isArray(t)?t:o?[t,o,...r]:[t,...r]}function _(t,o,r,...s){if(!t?.parentElement)throw new Error("container must be a valid HTMLElement inside the <html></html> document");if(!o||typeof o!="object")throw new Error("given state must be an object");if(typeof r!="function")throw new Error("dom must be a function that returns a vode");let e={};e.stats={lastRenderTime:0,renderCount:0,liveEffectCount:0,patchCount:0,renderPatchCount:0},Object.defineProperty(o,"patch",{enumerable:!1,configurable:!0,writable:!1,value:async a=>{if(!(!a||typeof a!="function"&&typeof a!="object"))if(e.stats.patchCount++,a?.next){let i=a;e.stats.liveEffectCount++;try{let l=await i.next();for(;l.done===!1;){e.stats.liveEffectCount++;try{e.patch(l.value),l=await i.next()}finally{e.stats.liveEffectCount--}}e.patch(l.value)}finally{e.stats.liveEffectCount--}}else if(a.then){e.stats.liveEffectCount++;try{let i=await a;e.patch(i)}finally{e.stats.liveEffectCount--}}else Array.isArray(a)?typeof a[0]=="function"?a.length>1?e.patch(a[0](e.state,...a.slice(1))):e.patch(a[0](e.state)):e.stats.patchCount--:typeof a=="function"?e.patch(a(e.state)):(e.stats.renderPatchCount++,e.q=x(e.q||{},a,!1),e.isRendering||e.render())}}),Object.defineProperty(e,"render",{enumerable:!1,configurable:!0,writable:!1,value:()=>requestAnimationFrame(()=>{if(e.isRendering||!e.q)return;e.isRendering=!0;let a=Date.now();try{e.state=x(e.state,e.q,!0),e.q=null;let i=r(e.state);e.vode=P(e.state,e.patch,t.parentElement,0,e.vode,i),t.tagName!==i[0].toUpperCase()&&(t=e.vode.node)}finally{e.isRendering=!1,e.stats.renderCount++,e.stats.lastRenderTime=Date.now()-a,e.q&&e.render()}})}),e.patch=o.patch,e.state=o,e.q=null;let n=t;n._vode=e,e.vode=P(o,e.patch,t.parentElement,Array.from(t.parentElement.children).indexOf(t),D(t),r(o));for(let a of s)e.patch(a);return e.patch}function K(t,o){return o.__memo=t,o}function X(t){return t}function q(t){return t}function Y(t){return t?Array.isArray(t)?t[0]:typeof t=="string"||t.nodeType===Node.TEXT_NODE?"#text":void 0:void 0}function S(t){if(Array.isArray(t)&&t.length>1&&t[1]&&!Array.isArray(t[1])&&typeof t[1]=="object"&&t[1].nodeType!==Node.TEXT_NODE)return t[1]}function W(t,o){if(!t)return o;if(!o)return t;if(typeof t=="string"&&typeof o=="string"){let r=t.split(" "),s=o.split(" "),e=new Set([...r,...s]);return Array.from(e).join(" ").trim()}else if(typeof t=="string"&&Array.isArray(o)){let r=new Set([...o,...t.split(" ")]);return Array.from(r).join(" ").trim()}else if(Array.isArray(t)&&typeof o=="string"){let r=new Set([...t,...o.split(" ")]);return Array.from(r).join(" ").trim()}else if(Array.isArray(t)&&Array.isArray(o)){let r=new Set([...t,...o]);return Array.from(r).join(" ").trim()}else{if(typeof t=="string"&&typeof o=="object")return{[t]:!0,...o};if(typeof t=="object"&&typeof o=="string")return{...t,[o]:!0};if(typeof t=="object"&&typeof o=="object")return{...t,...o};if(typeof t=="object"&&Array.isArray(o)){let r={...t};for(let s of o)r[s]=!0;return r}else if(Array.isArray(t)&&typeof o=="object"){let r={};for(let s of t)r[s]=!0;for(let s of Object.keys(o))r[s]=o[s];return r}}throw new Error(`cannot merge classes of ${t} (${typeof t}) and ${o} (${typeof o})`)}function A(t){let o=N(t);return o>0?t.slice(o):null}function $(t){return t.length-N(t)}function J(t,o){return t[o+N(t)]}function N(t){return S(t)?2:1}function x(t,o,r){if(!o)return t;for(let s in o){let e=o[s];if(e&&typeof e=="object"){let n=t[s];n?Array.isArray(e)?t[s]=[...e]:e instanceof Date&&n!==e?t[s]=new Date(e):Array.isArray(n)?t[s]=x({},e,r):typeof n=="object"?x(t[s],e,r):t[s]=x({},e,r):Array.isArray(e)?t[s]=[...e]:e instanceof Date?t[s]=new Date(e):t[s]=x({},e,r)}else e===void 0&&r?delete t[s]:t[s]=e}return t}function D(t){if(t?.nodeType===Node.TEXT_NODE)return t.nodeValue?.trim()!==""?t:void 0;if(t.nodeType===Node.COMMENT_NODE)return;if(t.nodeType===Node.ELEMENT_NODE){let r=[t.tagName.toLowerCase()];if(r.node=t,t?.hasAttributes()){let s={},e=t.attributes;for(let n of e)s[n.name]=n.value;r.push(s)}if(t.hasChildNodes()){let s=[];for(let e of t.childNodes){let n=e&&D(e);n?r.push(n):e&&s.push(e)}for(let e of s)e.remove()}return r}else return}function P(t,o,r,s,e,n,a){n=O(t,n,e);let i=!n||typeof n=="number"||typeof n=="boolean";if(n===e||!e&&i)return e;let l=e?.nodeType===Node.TEXT_NODE,p=l?e:e?.node;if(i){p?.onUnmount&&o(p.onUnmount(p)),p?.remove();return}let E=!i&&z(n),m=!i&&Q(n),C=!!n&&typeof n!="string"&&!!(n?.node||n?.nodeType===Node.TEXT_NODE);if(!E&&!m&&!C&&!e)throw new Error("Invalid vode: "+typeof n+" "+JSON.stringify(n));if(C&&E?n=n.wholeText:C&&m&&(n=[...n]),l&&E)return p.nodeValue!==n&&(p.nodeValue=n),e;if(E&&(!p||!l)){let T=document.createTextNode(n);return p?(p.onUnmount&&o(p.onUnmount(p)),p.replaceWith(T)):r.childNodes[s]?r.insertBefore(T,r.childNodes[s]):r.appendChild(T),T}if(m&&(!p||l||e[0]!==n[0])){a=a||n[0]==="svg";let T=a?document.createElementNS("http://www.w3.org/2000/svg",n[0]):document.createElement(n[0]);n.node=T;let y=n;1 in y&&(y[1]=O(t,y[1],void 0));let g=S(n);R(o,T,void 0,g,a),p?(p.onUnmount&&o(p.onUnmount(p)),p.replaceWith(T)):r.childNodes[s]?r.insertBefore(T,r.childNodes[s]):r.appendChild(T);let d=A(n);if(d)for(let f=0;f<d.length;f++){let c=d[f],u=P(t,o,T,f,void 0,c,a);n[g?f+2:f+1]=u}return T.onMount&&o(T.onMount(T)),n}if(!l&&m&&e[0]===n[0]){a=a||n[0]==="svg",n.node=p;let T=n,y=e,g=!1;if(T[1]?.__memo){let c=T[1];if(T[1]=O(t,T[1],y[1]),c!==T[1]){let u=S(n);R(o,p,S(e),u,a),g=!!u}}else{let c=S(n);R(o,p,S(e),c,a),g=!!c}let d=A(n),f=A(e);if(d){for(let c=0;c<d.length;c++){let u=d[c],F=f&&f[c],b=P(t,o,p,c,F,u,a);b&&(n[g?c+2:c+1]=b)}for(let c=d.length;f&&c<f.length;c++)f[c]?.node?f[c].node.remove():f[c]?.nodeType===Node.TEXT_NODE&&f[c].remove()}for(let c=d?.length||0;c<f?.length;c++)f[c]?.node?f[c].node.remove():f[c]?.nodeType===Node.TEXT_NODE&&f[c].remove();return n}}function Q(t){return Array.isArray(t)&&t.length>0&&typeof t[0]=="string"}function z(t){return typeof t=="string"||t?.nodeType===Node.TEXT_NODE}function O(t,o,r){if(typeof o!="function")return o;let s=o?.__memo,e=r?.__memo;if(Array.isArray(s)&&Array.isArray(e)&&s.length===e.length){let a=!0;for(let i=0;i<s.length;i++)if(s[i]!==e[i]){a=!1;break}if(a)return r}let n=I(o,t);return typeof n=="object"&&(n.__memo=o?.__memo),n}function I(t,o){return typeof t=="function"?I(t(o),o):t}function R(t,o,r,s,e){if(!(!s&&!r)){if(r)for(let n in r){let a=r[n],i=s?.[n];a!==i&&(s?s[n]=h(t,o,n,a,i,e):h(t,o,n,a,void 0,e))}if(s&&r){for(let n in s)if(!(n in r)){let a=s[n];s[n]=h(t,o,n,void 0,a,e)}}else if(s)for(let n in s){let a=s[n];s[n]=h(t,o,n,void 0,a,e)}}}function h(t,o,r,s,e,n){if(r==="style")if(!e)o.style.cssText="";else if(s)for(let a in{...s,...e})!s||e[a]!==s[a]?o.style[a]=e[a]:s[a]&&!e[a]&&(o.style[a]=void 0);else for(let a in e)o.style[a]=e[a];else if(r==="class")if(n)if(e){let a=L(e);o.classList.value=a}else o.classList.value="";else if(e){let a=L(e);o.className=a}else o.className="";else if(r[0]==="o"&&r[1]==="n")if(e){let a=null;if(typeof e=="function"){let i=e;a=l=>t([i,l])}else if(Array.isArray(e)){let i=e,l=e[0];i.length>1?a=()=>t([l,...i.slice(1)]):a=p=>t([l,p])}else typeof e=="object"&&(a=()=>t(e));o[r]=a}else o[r]=null;else e!=null&&e!==!1?o.setAttribute(r,e):o.removeAttribute(r);return e}function L(t){return typeof t=="string"?t:Array.isArray(t)?t.map(L).join(" "):typeof t=="object"?Object.keys(t).filter(o=>t[o]).join(" "):""}var Z="a",w="abbr",tt="address",et="area",ot="article",nt="aside",rt="audio",st="b",at="base",ct="bdi",it="bdo",pt="blockquote",Tt="body",ft="br",lt="button",dt="canvas",St="caption",gt="cite",ut="code",xt="col",yt="colgroup",Et="data",mt="datalist",ht="dd",At="del",Pt="details",Nt="dfn",Ct="dialog",Mt="div",Ot="dl",Rt="dt",Lt="em",bt="embed",Dt="fieldset",It="figcaption",vt="figure",Ft="footer",Vt="form",Gt="h1",kt="h2",Ht="h3",Ut="h4",jt="h5",Bt="h6",_t="head",Kt="header",Xt="hgroup",qt="hr",Yt="html",Wt="i",$t="iframe",Jt="img",Qt="input",zt="ins",Zt="kbd",wt="label",te="legend",ee="li",oe="link",ne="main",re="map",se="mark",ae="menu",ce="meta",ie="meter",pe="nav",Te="noscript",fe="object",le="ol",de="optgroup",Se="option",ge="output",ue="p",xe="picture",ye="pre",Ee="progress",me="q",he="rp",Ae="rt",Pe="ruby",Ne="s",Ce="samp",Me="script",Oe="section",Re="select",Le="slot",be="small",De="source",Ie="span",ve="strong",Fe="style",Ve="sub",Ge="summary",ke="sup",He="table",Ue="tbody",je="td",Be="template",_e="textarea",Ke="tfoot",Xe="th",qe="thead",Ye="time",We="title",$e="tr",Je="track",Qe="u",ze="ul",Ze="video",we="wbr",to="animate",eo="animateMotion",oo="animateTransform",no="circle",ro="clipPath",so="defs",ao="desc",co="ellipse",io="feBlend",po="feColorMatrix",To="feComponentTransfer",fo="feComposite",lo="feConvolveMatrix",So="feDiffuseLighting",go="feDisplacementMap",uo="feDistantLight",xo="feDropShadow",yo="feFlood",Eo="feFuncA",mo="feFuncB",ho="feFuncG",Ao="feFuncR",Po="feGaussianBlur",No="feImage",Co="feMerge",Mo="feMergeNode",Oo="feMorphology",Ro="feOffset",Lo="fePointLight",bo="feSpecularLighting",Do="feSpotLight",Io="feTile",vo="feTurbulence",Fo="filter",Vo="foreignObject",Go="g",ko="image",Ho="line",Uo="linearGradient",jo="marker",Bo="mask",_o="metadata",Ko="mpath",Xo="path",qo="pattern",Yo="polygon",Wo="polyline",$o="radialGradient",Jo="rect",Qo="set",zo="stop",Zo="svg",wo="switch",tn="symbol",en="text",on="textPath",nn="tspan",rn="use",sn="view",an="annotation",cn="annotation-xml",pn="maction",Tn="math",fn="merror",ln="mfrac",dn="mi",Sn="mmultiscripts",gn="mn",un="mo",xn="mover",yn="mpadded",En="mphantom",mn="mprescripts",hn="mroot",An="mrow",Pn="ms",Nn="mspace",Cn="msqrt",Mn="mstyle",On="msub",Rn="msubsup",Ln="msup",bn="mtable",Dn="mtd",In="mtext",vn="mtr",Fn="munder",Vn="munderover",Gn="semantics";function kn(t){let o=document.createElement("div");o.innerHTML=t.trim();let r=[];for(let s of o.childNodes){let e=v(s);e!=null&&r.push(e)}return r}function v(t){if(t.nodeType===Node.TEXT_NODE)return t.textContent;if(t.nodeType!==Node.ELEMENT_NODE)return;let o=[t.tagName.toLowerCase()];if(t.hasAttributes()){let r={};for(let s of t.attributes)r[s.name]=s.value;o.push(r)}for(let r of t.childNodes){let s=v(r);s&&(typeof s!="string"||s.length>0)&&o.push(s)}return o}return j(Hn);})();
|
|
1
|
+
"use strict";var V=(()=>{var N=Object.defineProperty;var v=Object.getOwnPropertyDescriptor;var G=Object.getOwnPropertyNames;var V=Object.prototype.hasOwnProperty;var k=(t,o)=>{for(var r in o)N(t,r,{get:o[r],enumerable:!0})},H=(t,o,r,a)=>{if(o&&typeof o=="object"||typeof o=="function")for(let e of G(o))!V.call(t,e)&&e!==r&&N(t,e,{get:()=>o[e],enumerable:!(a=v(o,e))||a.enumerable});return t};var U=t=>H(N({},"__esModule",{value:!0}),t);var Vn={};k(Vn,{A:()=>z,ABBR:()=>Z,ADDRESS:()=>w,ANIMATE:()=>we,ANIMATEMOTION:()=>to,ANIMATETRANSFORM:()=>eo,ANNOTATION:()=>sn,ANNOTATION_XML:()=>an,AREA:()=>tt,ARTICLE:()=>et,ASIDE:()=>ot,AUDIO:()=>nt,B:()=>rt,BASE:()=>st,BDI:()=>at,BDO:()=>ct,BLOCKQUOTE:()=>it,BODY:()=>pt,BR:()=>Tt,BUTTON:()=>ft,CANVAS:()=>lt,CAPTION:()=>St,CIRCLE:()=>oo,CITE:()=>dt,CLIPPATH:()=>no,CODE:()=>gt,COL:()=>xt,COLGROUP:()=>ut,DATA:()=>yt,DATALIST:()=>Et,DD:()=>mt,DEFS:()=>ro,DEL:()=>ht,DESC:()=>so,DETAILS:()=>At,DFN:()=>Pt,DIALOG:()=>Ct,DIV:()=>Mt,DL:()=>Nt,DT:()=>Ot,ELLIPSE:()=>ao,EM:()=>Rt,EMBED:()=>Lt,FEBLEND:()=>co,FECOLORMATRIX:()=>io,FECOMPONENTTRANSFER:()=>po,FECOMPOSITE:()=>To,FECONVOLVEMATRIX:()=>fo,FEDIFFUSELIGHTING:()=>lo,FEDISPLACEMENTMAP:()=>So,FEDISTANTLIGHT:()=>go,FEDROPSHADOW:()=>xo,FEFLOOD:()=>uo,FEFUNCA:()=>yo,FEFUNCB:()=>Eo,FEFUNCG:()=>mo,FEFUNCR:()=>ho,FEGAUSSIANBLUR:()=>Ao,FEIMAGE:()=>Po,FEMERGE:()=>Co,FEMERGENODE:()=>Mo,FEMORPHOLOGY:()=>No,FEOFFSET:()=>Oo,FEPOINTLIGHT:()=>Ro,FESPECULARLIGHTING:()=>Lo,FESPOTLIGHT:()=>bo,FETILE:()=>Do,FETURBULENCE:()=>Io,FIELDSET:()=>bt,FIGCAPTION:()=>Dt,FIGURE:()=>It,FILTER:()=>Fo,FOOTER:()=>Ft,FOREIGNOBJECT:()=>vo,FORM:()=>vt,G:()=>Go,H1:()=>Gt,H2:()=>Vt,H3:()=>kt,H4:()=>Ht,H5:()=>Ut,H6:()=>Bt,HEAD:()=>jt,HEADER:()=>_t,HGROUP:()=>Kt,HR:()=>Xt,HTML:()=>qt,I:()=>Yt,IFRAME:()=>Wt,IMAGE:()=>Vo,IMG:()=>$t,INPUT:()=>Jt,INS:()=>Qt,KBD:()=>zt,LABEL:()=>Zt,LEGEND:()=>wt,LI:()=>te,LINE:()=>ko,LINEARGRADIENT:()=>Ho,LINK:()=>ee,MACTION:()=>cn,MAIN:()=>oe,MAP:()=>ne,MARK:()=>re,MARKER:()=>Uo,MASK:()=>Bo,MATH:()=>pn,MENU:()=>se,MERROR:()=>Tn,META:()=>ae,METADATA:()=>jo,METER:()=>ce,MFRAC:()=>fn,MI:()=>ln,MMULTISCRIPTS:()=>Sn,MN:()=>dn,MO:()=>gn,MOVER:()=>xn,MPADDED:()=>un,MPATH:()=>_o,MPHANTOM:()=>yn,MPRESCRIPTS:()=>En,MROOT:()=>mn,MROW:()=>hn,MS:()=>An,MSPACE:()=>Pn,MSQRT:()=>Cn,MSTYLE:()=>Mn,MSUB:()=>Nn,MSUBSUP:()=>On,MSUP:()=>Rn,MTABLE:()=>Ln,MTD:()=>bn,MTEXT:()=>Dn,MTR:()=>In,MUNDER:()=>Fn,MUNDEROVER:()=>vn,NAV:()=>ie,NOSCRIPT:()=>pe,OBJECT:()=>Te,OL:()=>fe,OPTGROUP:()=>le,OPTION:()=>Se,OUTPUT:()=>de,P:()=>ge,PATH:()=>Ko,PATTERN:()=>Xo,PICTURE:()=>xe,POLYGON:()=>qo,POLYLINE:()=>Yo,PRE:()=>ue,PROGRESS:()=>ye,Q:()=>Ee,RADIALGRADIENT:()=>Wo,RECT:()=>$o,RP:()=>me,RT:()=>he,RUBY:()=>Ae,S:()=>Pe,SAMP:()=>Ce,SCRIPT:()=>Me,SECTION:()=>Ne,SELECT:()=>Oe,SEMANTICS:()=>Gn,SET:()=>Jo,SLOT:()=>Re,SMALL:()=>Le,SOURCE:()=>be,SPAN:()=>De,STOP:()=>Qo,STRONG:()=>Ie,STYLE:()=>Fe,SUB:()=>ve,SUMMARY:()=>Ge,SUP:()=>Ve,SVG:()=>zo,SWITCH:()=>Zo,SYMBOL:()=>wo,TABLE:()=>ke,TBODY:()=>He,TD:()=>Ue,TEMPLATE:()=>Be,TEXT:()=>tn,TEXTAREA:()=>je,TEXTPATH:()=>en,TFOOT:()=>_e,TH:()=>Ke,THEAD:()=>Xe,TIME:()=>qe,TITLE:()=>Ye,TR:()=>We,TRACK:()=>$e,TSPAN:()=>on,U:()=>Je,UL:()=>Qe,USE:()=>nn,VIDEO:()=>ze,VIEW:()=>rn,WBR:()=>Ze,app:()=>j,child:()=>$,childCount:()=>W,children:()=>A,childrenStart:()=>C,createPatch:()=>X,createState:()=>K,hydrate:()=>b,memo:()=>_,mergeClass:()=>Y,props:()=>d,tag:()=>q,vode:()=>B});function B(t,o,...r){if(!t)throw new Error("tag must be a string or vode");return Array.isArray(t)?t:o?[t,o,...r]:[t,...r]}function j(t,o,r,...a){if(!t?.parentElement)throw new Error("container must be a valid HTMLElement inside the <html></html> document");if(!o||typeof o!="object")throw new Error("given state must be an object");if(typeof r!="function")throw new Error("dom must be a function that returns a vode");let e={};e.stats={lastRenderTime:0,renderCount:0,liveEffectCount:0,patchCount:0,renderPatchCount:0},Object.defineProperty(o,"patch",{enumerable:!1,configurable:!0,writable:!1,value:async s=>{if(!(!s||typeof s!="function"&&typeof s!="object"))if(e.stats.patchCount++,s?.next){let i=s;e.stats.liveEffectCount++;try{let l=await i.next();for(;l.done===!1;){e.stats.liveEffectCount++;try{e.patch(l.value),l=await i.next()}finally{e.stats.liveEffectCount--}}e.patch(l.value)}finally{e.stats.liveEffectCount--}}else if(s.then){e.stats.liveEffectCount++;try{let i=await s;e.patch(i)}finally{e.stats.liveEffectCount--}}else Array.isArray(s)?typeof s[0]=="function"?s.length>1?e.patch(s[0](e.state,...s.slice(1))):e.patch(s[0](e.state)):e.stats.patchCount--:typeof s=="function"?e.patch(s(e.state)):(e.stats.renderPatchCount++,e.q=u(e.q||{},s,!1),e.isRendering||e.render())}}),Object.defineProperty(e,"render",{enumerable:!1,configurable:!0,writable:!1,value:()=>requestAnimationFrame(()=>{if(e.isRendering||!e.q)return;e.isRendering=!0;let s=Date.now();try{e.state=u(e.state,e.q,!0),e.q=null;let i=r(e.state);e.vode=P(e.state,e.patch,t.parentElement,0,e.vode,i),t.tagName.toUpperCase()!==i[0].toUpperCase()&&(t=e.vode.node,t._vode=e)}finally{e.isRendering=!1,e.stats.renderCount++,e.stats.lastRenderTime=Date.now()-s,e.q&&e.render()}})}),e.patch=o.patch,e.state=o,e.q=null;let n=t;n._vode=e,e.vode=P(o,e.patch,t.parentElement,Array.from(t.parentElement.children).indexOf(t),b(t),r(o));for(let s of a)e.patch(s);return e.patch}function b(t){if(t?.nodeType===Node.TEXT_NODE)return t.nodeValue?.trim()!==""?t:void 0;if(t.nodeType===Node.COMMENT_NODE)return;if(t.nodeType===Node.ELEMENT_NODE){let r=[t.tagName.toLowerCase()];if(r.node=t,t?.hasAttributes()){let a={},e=t.attributes;for(let n of e)a[n.name]=n.value;r.push(a)}if(t.hasChildNodes()){let a=[];for(let e of t.childNodes){let n=e&&b(e);n?r.push(n):e&&a.push(e)}for(let e of a)e.remove()}return r}else return}function _(t,o){return o.__memo=t,o}function K(t){return t}function X(t){return t}function q(t){return t?Array.isArray(t)?t[0]:typeof t=="string"||t.nodeType===Node.TEXT_NODE?"#text":void 0:void 0}function d(t){if(Array.isArray(t)&&t.length>1&&t[1]&&!Array.isArray(t[1])&&typeof t[1]=="object"&&t[1].nodeType!==Node.TEXT_NODE)return t[1]}function Y(t,o){if(!t)return o;if(!o)return t;if(typeof t=="string"&&typeof o=="string"){let r=t.split(" "),a=o.split(" "),e=new Set([...r,...a]);return Array.from(e).join(" ").trim()}else if(typeof t=="string"&&Array.isArray(o)){let r=new Set([...o,...t.split(" ")]);return Array.from(r).join(" ").trim()}else if(Array.isArray(t)&&typeof o=="string"){let r=new Set([...t,...o.split(" ")]);return Array.from(r).join(" ").trim()}else if(Array.isArray(t)&&Array.isArray(o)){let r=new Set([...t,...o]);return Array.from(r).join(" ").trim()}else{if(typeof t=="string"&&typeof o=="object")return{[t]:!0,...o};if(typeof t=="object"&&typeof o=="string")return{...t,[o]:!0};if(typeof t=="object"&&typeof o=="object")return{...t,...o};if(typeof t=="object"&&Array.isArray(o)){let r={...t};for(let a of o)r[a]=!0;return r}else if(Array.isArray(t)&&typeof o=="object"){let r={};for(let a of t)r[a]=!0;for(let a of Object.keys(o))r[a]=o[a];return r}}throw new Error(`cannot merge classes of ${t} (${typeof t}) and ${o} (${typeof o})`)}function A(t){let o=C(t);return o>0?t.slice(o):null}function W(t){return t.length-C(t)}function $(t,o){return t[o+C(t)]}function C(t){return d(t)?2:1}function u(t,o,r){if(!o)return t;for(let a in o){let e=o[a];if(e&&typeof e=="object"){let n=t[a];n?Array.isArray(e)?t[a]=[...e]:e instanceof Date&&n!==e?t[a]=new Date(e):Array.isArray(n)?t[a]=u({},e,r):typeof n=="object"?u(t[a],e,r):t[a]=u({},e,r):Array.isArray(e)?t[a]=[...e]:e instanceof Date?t[a]=new Date(e):t[a]=u({},e,r)}else e===void 0&&r?delete t[a]:t[a]=e}return t}function P(t,o,r,a,e,n,s){n=O(t,n,e);let i=!n||typeof n=="number"||typeof n=="boolean";if(n===e||!e&&i)return e;let l=e?.nodeType===Node.TEXT_NODE,p=l?e:e?.node;if(i){p?.onUnmount&&o(p.onUnmount(p)),p?.remove();return}let E=!i&&Q(n),m=!i&&J(n),M=!!n&&typeof n!="string"&&!!(n?.node||n?.nodeType===Node.TEXT_NODE);if(!E&&!m&&!M&&!e)throw new Error("Invalid vode: "+typeof n+" "+JSON.stringify(n));if(M&&E?n=n.wholeText:M&&m&&(n=[...n]),l&&E)return p.nodeValue!==n&&(p.nodeValue=n),e;if(E&&(!p||!l)){let T=document.createTextNode(n);return p?(p.onUnmount&&o(p.onUnmount(p)),p.replaceWith(T)):r.childNodes[a]?r.insertBefore(T,r.childNodes[a]):r.appendChild(T),T}if(m&&(!p||l||e[0]!==n[0])){s=s||n[0]==="svg";let T=s?document.createElementNS("http://www.w3.org/2000/svg",n[0]):document.createElement(n[0]);n.node=T;let y=n;1 in y&&(y[1]=O(t,y[1],void 0));let g=d(n);R(o,T,void 0,g,s),p?(p.onUnmount&&o(p.onUnmount(p)),p.replaceWith(T)):r.childNodes[a]?r.insertBefore(T,r.childNodes[a]):r.appendChild(T);let S=A(n);if(S)for(let f=0;f<S.length;f++){let c=S[f],x=P(t,o,T,f,void 0,c,s);n[g?f+2:f+1]=x}return T.onMount&&o(T.onMount(T)),n}if(!l&&m&&e[0]===n[0]){s=s||n[0]==="svg",n.node=p;let T=n,y=e,g=!1;if(T[1]?.__memo){let c=T[1];if(T[1]=O(t,T[1],y[1]),c!==T[1]){let x=d(n);R(o,p,d(e),x,s),g=!!x}}else{let c=d(n);R(o,p,d(e),c,s),g=!!c}let S=A(n),f=A(e);if(S){for(let c=0;c<S.length;c++){let x=S[c],F=f&&f[c],D=P(t,o,p,c,F,x,s);D&&(n[g?c+2:c+1]=D)}for(let c=S.length;f&&c<f.length;c++)f[c]?.node?f[c].node.remove():f[c]?.nodeType===Node.TEXT_NODE&&f[c].remove()}for(let c=S?.length||0;c<f?.length;c++)f[c]?.node?f[c].node.remove():f[c]?.nodeType===Node.TEXT_NODE&&f[c].remove();return n}}function J(t){return Array.isArray(t)&&t.length>0&&typeof t[0]=="string"}function Q(t){return typeof t=="string"||t?.nodeType===Node.TEXT_NODE}function O(t,o,r){if(typeof o!="function")return o;let a=o?.__memo,e=r?.__memo;if(Array.isArray(a)&&Array.isArray(e)&&a.length===e.length){let s=!0;for(let i=0;i<a.length;i++)if(a[i]!==e[i]){s=!1;break}if(s)return r}let n=I(o,t);return typeof n=="object"&&(n.__memo=o?.__memo),n}function I(t,o){return typeof t=="function"?I(t(o),o):t}function R(t,o,r,a,e){if(!(!a&&!r)){if(r)for(let n in r){let s=r[n],i=a?.[n];s!==i&&(a?a[n]=h(t,o,n,s,i,e):h(t,o,n,s,void 0,e))}if(a&&r){for(let n in a)if(!(n in r)){let s=a[n];a[n]=h(t,o,n,void 0,s,e)}}else if(a)for(let n in a){let s=a[n];a[n]=h(t,o,n,void 0,s,e)}}}function h(t,o,r,a,e,n){if(r==="style")if(!e)o.style.cssText="";else if(a)for(let s in{...a,...e})!a||e[s]!==a[s]?o.style[s]=e[s]:a[s]&&!e[s]&&(o.style[s]=void 0);else for(let s in e)o.style[s]=e[s];else if(r==="class")if(n)if(e){let s=L(e);o.classList.value=s}else o.classList.value="";else if(e){let s=L(e);o.className=s}else o.className="";else if(r[0]==="o"&&r[1]==="n")if(e){let s=null;if(typeof e=="function"){let i=e;s=l=>t([i,l])}else if(Array.isArray(e)){let i=e,l=e[0];i.length>1?s=()=>t([l,...i.slice(1)]):s=p=>t([l,p])}else typeof e=="object"&&(s=()=>t(e));o[r]=s}else o[r]=null;else e!=null&&e!==!1?o.setAttribute(r,e):o.removeAttribute(r);return e}function L(t){return typeof t=="string"?t:Array.isArray(t)?t.map(L).join(" "):typeof t=="object"?Object.keys(t).filter(o=>t[o]).join(" "):""}var z="a",Z="abbr",w="address",tt="area",et="article",ot="aside",nt="audio",rt="b",st="base",at="bdi",ct="bdo",it="blockquote",pt="body",Tt="br",ft="button",lt="canvas",St="caption",dt="cite",gt="code",xt="col",ut="colgroup",yt="data",Et="datalist",mt="dd",ht="del",At="details",Pt="dfn",Ct="dialog",Mt="div",Nt="dl",Ot="dt",Rt="em",Lt="embed",bt="fieldset",Dt="figcaption",It="figure",Ft="footer",vt="form",Gt="h1",Vt="h2",kt="h3",Ht="h4",Ut="h5",Bt="h6",jt="head",_t="header",Kt="hgroup",Xt="hr",qt="html",Yt="i",Wt="iframe",$t="img",Jt="input",Qt="ins",zt="kbd",Zt="label",wt="legend",te="li",ee="link",oe="main",ne="map",re="mark",se="menu",ae="meta",ce="meter",ie="nav",pe="noscript",Te="object",fe="ol",le="optgroup",Se="option",de="output",ge="p",xe="picture",ue="pre",ye="progress",Ee="q",me="rp",he="rt",Ae="ruby",Pe="s",Ce="samp",Me="script",Ne="section",Oe="select",Re="slot",Le="small",be="source",De="span",Ie="strong",Fe="style",ve="sub",Ge="summary",Ve="sup",ke="table",He="tbody",Ue="td",Be="template",je="textarea",_e="tfoot",Ke="th",Xe="thead",qe="time",Ye="title",We="tr",$e="track",Je="u",Qe="ul",ze="video",Ze="wbr",we="animate",to="animateMotion",eo="animateTransform",oo="circle",no="clipPath",ro="defs",so="desc",ao="ellipse",co="feBlend",io="feColorMatrix",po="feComponentTransfer",To="feComposite",fo="feConvolveMatrix",lo="feDiffuseLighting",So="feDisplacementMap",go="feDistantLight",xo="feDropShadow",uo="feFlood",yo="feFuncA",Eo="feFuncB",mo="feFuncG",ho="feFuncR",Ao="feGaussianBlur",Po="feImage",Co="feMerge",Mo="feMergeNode",No="feMorphology",Oo="feOffset",Ro="fePointLight",Lo="feSpecularLighting",bo="feSpotLight",Do="feTile",Io="feTurbulence",Fo="filter",vo="foreignObject",Go="g",Vo="image",ko="line",Ho="linearGradient",Uo="marker",Bo="mask",jo="metadata",_o="mpath",Ko="path",Xo="pattern",qo="polygon",Yo="polyline",Wo="radialGradient",$o="rect",Jo="set",Qo="stop",zo="svg",Zo="switch",wo="symbol",tn="text",en="textPath",on="tspan",nn="use",rn="view",sn="annotation",an="annotation-xml",cn="maction",pn="math",Tn="merror",fn="mfrac",ln="mi",Sn="mmultiscripts",dn="mn",gn="mo",xn="mover",un="mpadded",yn="mphantom",En="mprescripts",mn="mroot",hn="mrow",An="ms",Pn="mspace",Cn="msqrt",Mn="mstyle",Nn="msub",On="msubsup",Rn="msup",Ln="mtable",bn="mtd",Dn="mtext",In="mtr",Fn="munder",vn="munderover",Gn="semantics";return U(Vn);})();
|
package/dist/vode.min.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
function g(f,L,...j){if(!f)throw Error("tag must be a string or vode");if(Array.isArray(f))return f;else if(L)return[f,L,...j];else return[f,...j]}function h(f,L,j,...q){if(!f?.parentElement)throw Error("container must be a valid HTMLElement inside the <html></html> document");if(!L||typeof L!=="object")throw Error("given state must be an object");if(typeof j!=="function")throw Error("dom must be a function that returns a vode");let E={};E.stats={lastRenderTime:0,renderCount:0,liveEffectCount:0,patchCount:0,renderPatchCount:0},Object.defineProperty(L,"patch",{enumerable:!1,configurable:!0,writable:!1,value:async(z)=>{if(!z||typeof z!=="function"&&typeof z!=="object")return;if(E.stats.patchCount++,z?.next){let F=z;E.stats.liveEffectCount++;try{let U=await F.next();while(U.done===!1){E.stats.liveEffectCount++;try{E.patch(U.value),U=await F.next()}finally{E.stats.liveEffectCount--}}E.patch(U.value)}finally{E.stats.liveEffectCount--}}else if(z.then){E.stats.liveEffectCount++;try{let F=await z;E.patch(F)}finally{E.stats.liveEffectCount--}}else if(Array.isArray(z))if(typeof z[0]==="function")if(z.length>1)E.patch(z[0](E.state,...z.slice(1)));else E.patch(z[0](E.state));else E.stats.patchCount--;else if(typeof z==="function")E.patch(z(E.state));else if(E.stats.renderPatchCount++,E.q=A(E.q||{},z,!1),!E.isRendering)E.render()}}),Object.defineProperty(E,"render",{enumerable:!1,configurable:!0,writable:!1,value:()=>requestAnimationFrame(()=>{if(E.isRendering||!E.q)return;E.isRendering=!0;let z=Date.now();try{E.state=A(E.state,E.q,!0),E.q=null;let F=j(E.state);if(E.vode=H(E.state,E.patch,f.parentElement,0,E.vode,F),f.tagName!==F[0].toUpperCase())f=E.vode.node}finally{if(E.isRendering=!1,E.stats.renderCount++,E.stats.lastRenderTime=Date.now()-z,E.q)E.render()}})}),E.patch=L.patch,E.state=L,E.q=null;let X=f;X._vode=E,E.vode=H(L,E.patch,f.parentElement,Array.from(f.parentElement.children).indexOf(f),y(f),j(L));for(let z of q)E.patch(z);return E.patch}function u(f,L){return L.__memo=f,L}function c(f){return f}function v(f){return f}function i(f){return f?Array.isArray(f)?f[0]:typeof f==="string"||f.nodeType===Node.TEXT_NODE?"#text":void 0:void 0}function $(f){if(Array.isArray(f)&&f.length>1&&f[1]&&!Array.isArray(f[1])){if(typeof f[1]==="object"&&f[1].nodeType!==Node.TEXT_NODE)return f[1]}return}function V(f,L){if(!f)return L;if(!L)return f;if(typeof f==="string"&&typeof L==="string"){let j=f.split(" "),q=L.split(" "),E=new Set([...j,...q]);return Array.from(E).join(" ").trim()}else if(typeof f==="string"&&Array.isArray(L)){let j=new Set([...L,...f.split(" ")]);return Array.from(j).join(" ").trim()}else if(Array.isArray(f)&&typeof L==="string"){let j=new Set([...f,...L.split(" ")]);return Array.from(j).join(" ").trim()}else if(Array.isArray(f)&&Array.isArray(L)){let j=new Set([...f,...L]);return Array.from(j).join(" ").trim()}else if(typeof f==="string"&&typeof L==="object")return{[f]:!0,...L};else if(typeof f==="object"&&typeof L==="string")return{...f,[L]:!0};else if(typeof f==="object"&&typeof L==="object")return{...f,...L};else if(typeof f==="object"&&Array.isArray(L)){let j={...f};for(let q of L)j[q]=!0;return j}else if(Array.isArray(f)&&typeof L==="object"){let j={};for(let q of f)j[q]=!0;for(let q of Object.keys(L))j[q]=L[q];return j}throw Error(`cannot merge classes of ${f} (${typeof f}) and ${L} (${typeof L})`)}function D(f){let L=x(f);if(L>0)return f.slice(L);return null}function p(f){return f.length-x(f)}function w(f,L){return f[L+x(f)]}function x(f){return $(f)?2:1}function A(f,L,j){if(!L)return f;for(let q in L){let E=L[q];if(E&&typeof E==="object"){let X=f[q];if(X)if(Array.isArray(E))f[q]=[...E];else if(E instanceof Date&&X!==E)f[q]=new Date(E);else if(Array.isArray(X))f[q]=A({},E,j);else if(typeof X==="object")A(f[q],E,j);else f[q]=A({},E,j);else if(Array.isArray(E))f[q]=[...E];else if(E instanceof Date)f[q]=new Date(E);else f[q]=A({},E,j)}else if(E===void 0&&j)delete f[q];else f[q]=E}return f}function y(f){if(f?.nodeType===Node.TEXT_NODE){if(f.nodeValue?.trim()!=="")return f;return}else if(f.nodeType===Node.COMMENT_NODE)return;else if(f.nodeType===Node.ELEMENT_NODE){let j=[f.tagName.toLowerCase()];if(j.node=f,f?.hasAttributes()){let q={},E=f.attributes;for(let X of E)q[X.name]=X.value;j.push(q)}if(f.hasChildNodes()){let q=[];for(let E of f.childNodes){let X=E&&y(E);if(X)j.push(X);else if(E)q.push(E)}for(let E of q)E.remove()}return j}else return}function H(f,L,j,q,E,X,z){X=I(f,X,E);let F=!X||typeof X==="number"||typeof X==="boolean";if(X===E||!E&&F)return E;let U=E?.nodeType===Node.TEXT_NODE,G=U?E:E?.node;if(F){G?.onUnmount&&L(G.onUnmount(G)),G?.remove();return}let T=!F&&P(X),R=!F&&m(X),M=!!X&&typeof X!=="string"&&!!(X?.node||X?.nodeType===Node.TEXT_NODE);if(!T&&!R&&!M&&!E)throw Error("Invalid vode: "+typeof X+" "+JSON.stringify(X));else if(M&&T)X=X.wholeText;else if(M&&R)X=[...X];if(U&&T){if(G.nodeValue!==X)G.nodeValue=X;return E}if(T&&(!G||!U)){let J=document.createTextNode(X);if(G)G.onUnmount&&L(G.onUnmount(G)),G.replaceWith(J);else if(j.childNodes[q])j.insertBefore(J,j.childNodes[q]);else j.appendChild(J);return J}if(R&&(!G||U||E[0]!==X[0])){z=z||X[0]==="svg";let J=z?document.createElementNS("http://www.w3.org/2000/svg",X[0]):document.createElement(X[0]);X.node=J;let O=X;if(1 in O)O[1]=I(f,O[1],void 0);let Y=$(X);if(K(L,J,void 0,Y,z),G)G.onUnmount&&L(G.onUnmount(G)),G.replaceWith(J);else if(j.childNodes[q])j.insertBefore(J,j.childNodes[q]);else j.appendChild(J);let W=D(X);if(W)for(let Q=0;Q<W.length;Q++){let B=W[Q],Z=H(f,L,J,Q,void 0,B,z);X[Y?Q+2:Q+1]=Z}return J.onMount&&L(J.onMount(J)),X}if(!U&&R&&E[0]===X[0]){z=z||X[0]==="svg",X.node=G;let J=X,O=E,Y=!1;if(J[1]?.__memo){let B=J[1];if(J[1]=I(f,J[1],O[1]),B!==J[1]){let Z=$(X);K(L,G,$(E),Z,z),Y=!!Z}}else{let B=$(X);K(L,G,$(E),B,z),Y=!!B}let W=D(X),Q=D(E);if(W){for(let B=0;B<W.length;B++){let Z=W[B],k=Q&&Q[B],N=H(f,L,G,B,k,Z,z);if(N)X[Y?B+2:B+1]=N}for(let B=W.length;Q&&B<Q.length;B++)if(Q[B]?.node)Q[B].node.remove();else if(Q[B]?.nodeType===Node.TEXT_NODE)Q[B].remove()}for(let B=W?.length||0;B<Q?.length;B++)if(Q[B]?.node)Q[B].node.remove();else if(Q[B]?.nodeType===Node.TEXT_NODE)Q[B].remove();return X}return}function m(f){return Array.isArray(f)&&f.length>0&&typeof f[0]==="string"}function P(f){return typeof f==="string"||f?.nodeType===Node.TEXT_NODE}function I(f,L,j){if(typeof L!=="function")return L;let q=L?.__memo,E=j?.__memo;if(Array.isArray(q)&&Array.isArray(E)&&q.length===E.length){let z=!0;for(let F=0;F<q.length;F++)if(q[F]!==E[F]){z=!1;break}if(z)return j}let X=_(L,f);if(typeof X==="object")X.__memo=L?.__memo;return X}function _(f,L){if(typeof f==="function")return _(f(L),L);else return f}function K(f,L,j,q,E){if(!q&&!j)return;if(j)for(let X in j){let z=j[X],F=q?.[X];if(z!==F)if(q)q[X]=C(f,L,X,z,F,E);else C(f,L,X,z,void 0,E)}if(q&&j){for(let X in q)if(!(X in j)){let z=q[X];q[X]=C(f,L,X,void 0,z,E)}}else if(q)for(let X in q){let z=q[X];q[X]=C(f,L,X,void 0,z,E)}}function C(f,L,j,q,E,X){if(j==="style")if(!E)L.style.cssText="";else if(q){for(let z in{...q,...E})if(!q||E[z]!==q[z])L.style[z]=E[z];else if(q[z]&&!E[z])L.style[z]=void 0}else for(let z in E)L.style[z]=E[z];else if(j==="class")if(X)if(E){let z=S(E);L.classList.value=z}else L.classList.value="";else if(E){let z=S(E);L.className=z}else L.className="";else if(j[0]==="o"&&j[1]==="n")if(E){let z=null;if(typeof E==="function"){let F=E;z=(U)=>f([F,U])}else if(Array.isArray(E)){let F=E,U=E[0];if(F.length>1)z=()=>f([U,...F.slice(1)]);else z=(G)=>f([U,G])}else if(typeof E==="object")z=()=>f(E);L[j]=z}else L[j]=null;else if(E!==null&&E!==void 0&&E!==!1)L.setAttribute(j,E);else L.removeAttribute(j);return E}function S(f){if(typeof f==="string")return f;else if(Array.isArray(f))return f.map(S).join(" ");else if(typeof f==="object")return Object.keys(f).filter((L)=>f[L]).join(" ");else return""}var r="a",l="abbr",t="address",n="area",a="article",d="aside",o="audio",e="b",ff="base",Ef="bdi",Lf="bdo",Xf="blockquote",jf="body",qf="br",zf="button",Bf="canvas",Ff="caption",Gf="cite",Jf="code",Qf="col",Uf="colgroup",Wf="data",Yf="datalist",Zf="dd",$f="del",Af="details",Of="dfn",Tf="dialog",Rf="div",Cf="dl",Hf="dt",Mf="em",Df="embed",If="fieldset",Kf="figcaption",Sf="figure",xf="footer",Nf="form",yf="h1",_f="h2",bf="h3",kf="h4",mf="h5",Pf="h6",gf="head",hf="header",uf="hgroup",cf="hr",vf="html",Vf="i",pf="iframe",wf="img",sf="input",rf="ins",lf="kbd",tf="label",nf="legend",af="li",df="link",of="main",ef="map",fE="mark",EE="menu",LE="meta",XE="meter",jE="nav",qE="noscript",zE="object",BE="ol",FE="optgroup",GE="option",JE="output",QE="p",UE="picture",WE="pre",YE="progress",ZE="q",$E="rp",AE="rt",OE="ruby",TE="s",RE="samp",CE="script",HE="section",ME="select",DE="slot",IE="small",KE="source",SE="span",xE="strong",NE="style",yE="sub",_E="summary",bE="sup",kE="table",mE="tbody",PE="td",gE="template",hE="textarea",uE="tfoot",cE="th",vE="thead",iE="time",VE="title",pE="tr",wE="track",sE="u",rE="ul",lE="video",tE="wbr",nE="animate",aE="animateMotion",dE="animateTransform",oE="circle",eE="clipPath",fL="defs",EL="desc",LL="ellipse",XL="feBlend",jL="feColorMatrix",qL="feComponentTransfer",zL="feComposite",BL="feConvolveMatrix",FL="feDiffuseLighting",GL="feDisplacementMap",JL="feDistantLight",QL="feDropShadow",UL="feFlood",WL="feFuncA",YL="feFuncB",ZL="feFuncG",$L="feFuncR",AL="feGaussianBlur",OL="feImage",TL="feMerge",RL="feMergeNode",CL="feMorphology",HL="feOffset",ML="fePointLight",DL="feSpecularLighting",IL="feSpotLight",KL="feTile",SL="feTurbulence",xL="filter",NL="foreignObject",yL="g",_L="image",bL="line",kL="linearGradient",mL="marker",PL="mask",gL="metadata",hL="mpath",uL="path",cL="pattern",vL="polygon",iL="polyline",VL="radialGradient",pL="rect",wL="set",sL="stop",rL="svg",lL="switch",tL="symbol",nL="text",aL="textPath",dL="tspan",oL="use",eL="view",fX="annotation",EX="annotation-xml",LX="maction",XX="math",jX="merror",qX="mfrac",zX="mi",BX="mmultiscripts",FX="mn",GX="mo",JX="mover",QX="mpadded",UX="mphantom",WX="mprescripts",YX="mroot",ZX="mrow",$X="ms",AX="mspace",OX="msqrt",TX="mstyle",RX="msub",CX="msubsup",HX="msup",MX="mtable",DX="mtd",IX="mtext",KX="mtr",SX="munder",xX="munderover",NX="semantics";function _X(f){let L=document.createElement("div");L.innerHTML=f.trim();let j=[];for(let q of L.childNodes){let E=b(q);if(E!=null)j.push(E)}return j}function b(f){if(f.nodeType===Node.TEXT_NODE)return f.textContent;if(f.nodeType!==Node.ELEMENT_NODE)return;let L=[f.tagName.toLowerCase()];if(f.hasAttributes()){let j={};for(let q of f.attributes)j[q.name]=q.value;L.push(j)}for(let j of f.childNodes){let q=b(j);if(q&&(typeof q!=="string"||q.length>0))L.push(q)}return L}export{g as vode,i as tag,$ as props,V as mergeClass,u as memo,_X as htmlToVode,c as createState,v as createPatch,x as childrenStart,D as children,p as childCount,w as child,h as app,tE as WBR,eL as VIEW,lE as VIDEO,oL as USE,rE as UL,sE as U,dL as TSPAN,wE as TRACK,pE as TR,VE as TITLE,iE as TIME,vE as THEAD,cE as TH,uE as TFOOT,aL as TEXTPATH,hE as TEXTAREA,nL as TEXT,gE as TEMPLATE,PE as TD,mE as TBODY,kE as TABLE,tL as SYMBOL,lL as SWITCH,rL as SVG,bE as SUP,_E as SUMMARY,yE as SUB,NE as STYLE,xE as STRONG,sL as STOP,SE as SPAN,KE as SOURCE,IE as SMALL,DE as SLOT,wL as SET,NX as SEMANTICS,ME as SELECT,HE as SECTION,CE as SCRIPT,RE as SAMP,TE as S,OE as RUBY,AE as RT,$E as RP,pL as RECT,VL as RADIALGRADIENT,ZE as Q,YE as PROGRESS,WE as PRE,iL as POLYLINE,vL as POLYGON,UE as PICTURE,cL as PATTERN,uL as PATH,QE as P,JE as OUTPUT,GE as OPTION,FE as OPTGROUP,BE as OL,zE as OBJECT,qE as NOSCRIPT,jE as NAV,xX as MUNDEROVER,SX as MUNDER,KX as MTR,IX as MTEXT,DX as MTD,MX as MTABLE,HX as MSUP,CX as MSUBSUP,RX as MSUB,TX as MSTYLE,OX as MSQRT,AX as MSPACE,$X as MS,ZX as MROW,YX as MROOT,WX as MPRESCRIPTS,UX as MPHANTOM,hL as MPATH,QX as MPADDED,JX as MOVER,GX as MO,FX as MN,BX as MMULTISCRIPTS,zX as MI,qX as MFRAC,XE as METER,gL as METADATA,LE as META,jX as MERROR,EE as MENU,XX as MATH,PL as MASK,mL as MARKER,fE as MARK,ef as MAP,of as MAIN,LX as MACTION,df as LINK,kL as LINEARGRADIENT,bL as LINE,af as LI,nf as LEGEND,tf as LABEL,lf as KBD,rf as INS,sf as INPUT,wf as IMG,_L as IMAGE,pf as IFRAME,Vf as I,vf as HTML,cf as HR,uf as HGROUP,hf as HEADER,gf as HEAD,Pf as H6,mf as H5,kf as H4,bf as H3,_f as H2,yf as H1,yL as G,Nf as FORM,NL as FOREIGNOBJECT,xf as FOOTER,xL as FILTER,Sf as FIGURE,Kf as FIGCAPTION,If as FIELDSET,SL as FETURBULENCE,KL as FETILE,IL as FESPOTLIGHT,DL as FESPECULARLIGHTING,ML as FEPOINTLIGHT,HL as FEOFFSET,CL as FEMORPHOLOGY,RL as FEMERGENODE,TL as FEMERGE,OL as FEIMAGE,AL as FEGAUSSIANBLUR,$L as FEFUNCR,ZL as FEFUNCG,YL as FEFUNCB,WL as FEFUNCA,UL as FEFLOOD,QL as FEDROPSHADOW,JL as FEDISTANTLIGHT,GL as FEDISPLACEMENTMAP,FL as FEDIFFUSELIGHTING,BL as FECONVOLVEMATRIX,zL as FECOMPOSITE,qL as FECOMPONENTTRANSFER,jL as FECOLORMATRIX,XL as FEBLEND,Df as EMBED,Mf as EM,LL as ELLIPSE,Hf as DT,Cf as DL,Rf as DIV,Tf as DIALOG,Of as DFN,Af as DETAILS,EL as DESC,$f as DEL,fL as DEFS,Zf as DD,Yf as DATALIST,Wf as DATA,Uf as COLGROUP,Qf as COL,Jf as CODE,eE as CLIPPATH,Gf as CITE,oE as CIRCLE,Ff as CAPTION,Bf as CANVAS,zf as BUTTON,qf as BR,jf as BODY,Xf as BLOCKQUOTE,Lf as BDO,Ef as BDI,ff as BASE,e as B,o as AUDIO,d as ASIDE,a as ARTICLE,n as AREA,EX as ANNOTATION_XML,fX as ANNOTATION,dE as ANIMATETRANSFORM,aE as ANIMATEMOTION,nE as ANIMATE,t as ADDRESS,l as ABBR,r as A};
|
|
1
|
+
function P(f,z,...F){if(!f)throw Error("tag must be a string or vode");if(Array.isArray(f))return f;else if(z)return[f,z,...F];else return[f,...F]}function g(f,z,F,...G){if(!f?.parentElement)throw Error("container must be a valid HTMLElement inside the <html></html> document");if(!z||typeof z!=="object")throw Error("given state must be an object");if(typeof F!=="function")throw Error("dom must be a function that returns a vode");let q={};q.stats={lastRenderTime:0,renderCount:0,liveEffectCount:0,patchCount:0,renderPatchCount:0},Object.defineProperty(z,"patch",{enumerable:!1,configurable:!0,writable:!1,value:async(E)=>{if(!E||typeof E!=="function"&&typeof E!=="object")return;if(q.stats.patchCount++,E?.next){let Q=E;q.stats.liveEffectCount++;try{let Y=await Q.next();while(Y.done===!1){q.stats.liveEffectCount++;try{q.patch(Y.value),Y=await Q.next()}finally{q.stats.liveEffectCount--}}q.patch(Y.value)}finally{q.stats.liveEffectCount--}}else if(E.then){q.stats.liveEffectCount++;try{let Q=await E;q.patch(Q)}finally{q.stats.liveEffectCount--}}else if(Array.isArray(E))if(typeof E[0]==="function")if(E.length>1)q.patch(E[0](q.state,...E.slice(1)));else q.patch(E[0](q.state));else q.stats.patchCount--;else if(typeof E==="function")q.patch(E(q.state));else if(q.stats.renderPatchCount++,q.q=A(q.q||{},E,!1),!q.isRendering)q.render()}}),Object.defineProperty(q,"render",{enumerable:!1,configurable:!0,writable:!1,value:()=>requestAnimationFrame(()=>{if(q.isRendering||!q.q)return;q.isRendering=!0;let E=Date.now();try{q.state=A(q.state,q.q,!0),q.q=null;let Q=F(q.state);if(q.vode=M(q.state,q.patch,f.parentElement,0,q.vode,Q),f.tagName.toUpperCase()!==Q[0].toUpperCase())f=q.vode.node,f._vode=q}finally{if(q.isRendering=!1,q.stats.renderCount++,q.stats.lastRenderTime=Date.now()-E,q.q)q.render()}})}),q.patch=z.patch,q.state=z,q.q=null;let B=f;B._vode=q,q.vode=M(z,q.patch,f.parentElement,Array.from(f.parentElement.children).indexOf(f),k(f),F(z));for(let E of G)q.patch(E);return q.patch}function k(f){if(f?.nodeType===Node.TEXT_NODE){if(f.nodeValue?.trim()!=="")return f;return}else if(f.nodeType===Node.COMMENT_NODE)return;else if(f.nodeType===Node.ELEMENT_NODE){let F=[f.tagName.toLowerCase()];if(F.node=f,f?.hasAttributes()){let G={},q=f.attributes;for(let B of q)G[B.name]=B.value;F.push(G)}if(f.hasChildNodes()){let G=[];for(let q of f.childNodes){let B=q&&k(q);if(B)F.push(B);else if(q)G.push(q)}for(let q of G)q.remove()}return F}else return}function h(f,z){return z.__memo=f,z}function u(f){return f}function v(f){return f}function c(f){return f?Array.isArray(f)?f[0]:typeof f==="string"||f.nodeType===Node.TEXT_NODE?"#text":void 0:void 0}function L(f){if(Array.isArray(f)&&f.length>1&&f[1]&&!Array.isArray(f[1])){if(typeof f[1]==="object"&&f[1].nodeType!==Node.TEXT_NODE)return f[1]}return}function V(f,z){if(!f)return z;if(!z)return f;if(typeof f==="string"&&typeof z==="string"){let F=f.split(" "),G=z.split(" "),q=new Set([...F,...G]);return Array.from(q).join(" ").trim()}else if(typeof f==="string"&&Array.isArray(z)){let F=new Set([...z,...f.split(" ")]);return Array.from(F).join(" ").trim()}else if(Array.isArray(f)&&typeof z==="string"){let F=new Set([...f,...z.split(" ")]);return Array.from(F).join(" ").trim()}else if(Array.isArray(f)&&Array.isArray(z)){let F=new Set([...f,...z]);return Array.from(F).join(" ").trim()}else if(typeof f==="string"&&typeof z==="object")return{[f]:!0,...z};else if(typeof f==="object"&&typeof z==="string")return{...f,[z]:!0};else if(typeof f==="object"&&typeof z==="object")return{...f,...z};else if(typeof f==="object"&&Array.isArray(z)){let F={...f};for(let G of z)F[G]=!0;return F}else if(Array.isArray(f)&&typeof z==="object"){let F={};for(let G of f)F[G]=!0;for(let G of Object.keys(z))F[G]=z[G];return F}throw Error(`cannot merge classes of ${f} (${typeof f}) and ${z} (${typeof z})`)}function T(f){let z=x(f);if(z>0)return f.slice(z);return null}function i(f){return f.length-x(f)}function p(f,z){return f[z+x(f)]}function x(f){return L(f)?2:1}function A(f,z,F){if(!z)return f;for(let G in z){let q=z[G];if(q&&typeof q==="object"){let B=f[G];if(B)if(Array.isArray(q))f[G]=[...q];else if(q instanceof Date&&B!==q)f[G]=new Date(q);else if(Array.isArray(B))f[G]=A({},q,F);else if(typeof B==="object")A(f[G],q,F);else f[G]=A({},q,F);else if(Array.isArray(q))f[G]=[...q];else if(q instanceof Date)f[G]=new Date(q);else f[G]=A({},q,F)}else if(q===void 0&&F)delete f[G];else f[G]=q}return f}function M(f,z,F,G,q,B,E){B=I(f,B,q);let Q=!B||typeof B==="number"||typeof B==="boolean";if(B===q||!q&&Q)return q;let Y=q?.nodeType===Node.TEXT_NODE,U=Y?q:q?.node;if(Q){U?.onUnmount&&z(U.onUnmount(U)),U?.remove();return}let O=!Q&&m(B),H=!Q&&y(B),D=!!B&&typeof B!=="string"&&!!(B?.node||B?.nodeType===Node.TEXT_NODE);if(!O&&!H&&!D&&!q)throw Error("Invalid vode: "+typeof B+" "+JSON.stringify(B));else if(D&&O)B=B.wholeText;else if(D&&H)B=[...B];if(Y&&O){if(U.nodeValue!==B)U.nodeValue=B;return q}if(O&&(!U||!Y)){let W=document.createTextNode(B);if(U)U.onUnmount&&z(U.onUnmount(U)),U.replaceWith(W);else if(F.childNodes[G])F.insertBefore(W,F.childNodes[G]);else F.appendChild(W);return W}if(H&&(!U||Y||q[0]!==B[0])){E=E||B[0]==="svg";let W=E?document.createElementNS("http://www.w3.org/2000/svg",B[0]):document.createElement(B[0]);B.node=W;let R=B;if(1 in R)R[1]=I(f,R[1],void 0);let $=L(B);if(K(z,W,void 0,$,E),U)U.onUnmount&&z(U.onUnmount(U)),U.replaceWith(W);else if(F.childNodes[G])F.insertBefore(W,F.childNodes[G]);else F.appendChild(W);let Z=T(B);if(Z)for(let X=0;X<Z.length;X++){let J=Z[X],j=M(f,z,W,X,void 0,J,E);B[$?X+2:X+1]=j}return W.onMount&&z(W.onMount(W)),B}if(!Y&&H&&q[0]===B[0]){E=E||B[0]==="svg",B.node=U;let W=B,R=q,$=!1;if(W[1]?.__memo){let J=W[1];if(W[1]=I(f,W[1],R[1]),J!==W[1]){let j=L(B);K(z,U,L(q),j,E),$=!!j}}else{let J=L(B);K(z,U,L(q),J,E),$=!!J}let Z=T(B),X=T(q);if(Z){for(let J=0;J<Z.length;J++){let j=Z[J],b=X&&X[J],N=M(f,z,U,J,b,j,E);if(N)B[$?J+2:J+1]=N}for(let J=Z.length;X&&J<X.length;J++)if(X[J]?.node)X[J].node.remove();else if(X[J]?.nodeType===Node.TEXT_NODE)X[J].remove()}for(let J=Z?.length||0;J<X?.length;J++)if(X[J]?.node)X[J].node.remove();else if(X[J]?.nodeType===Node.TEXT_NODE)X[J].remove();return B}return}function y(f){return Array.isArray(f)&&f.length>0&&typeof f[0]==="string"}function m(f){return typeof f==="string"||f?.nodeType===Node.TEXT_NODE}function I(f,z,F){if(typeof z!=="function")return z;let G=z?.__memo,q=F?.__memo;if(Array.isArray(G)&&Array.isArray(q)&&G.length===q.length){let E=!0;for(let Q=0;Q<G.length;Q++)if(G[Q]!==q[Q]){E=!1;break}if(E)return F}let B=_(z,f);if(typeof B==="object")B.__memo=z?.__memo;return B}function _(f,z){if(typeof f==="function")return _(f(z),z);else return f}function K(f,z,F,G,q){if(!G&&!F)return;if(F)for(let B in F){let E=F[B],Q=G?.[B];if(E!==Q)if(G)G[B]=C(f,z,B,E,Q,q);else C(f,z,B,E,void 0,q)}if(G&&F){for(let B in G)if(!(B in F)){let E=G[B];G[B]=C(f,z,B,void 0,E,q)}}else if(G)for(let B in G){let E=G[B];G[B]=C(f,z,B,void 0,E,q)}}function C(f,z,F,G,q,B){if(F==="style")if(!q)z.style.cssText="";else if(G){for(let E in{...G,...q})if(!G||q[E]!==G[E])z.style[E]=q[E];else if(G[E]&&!q[E])z.style[E]=void 0}else for(let E in q)z.style[E]=q[E];else if(F==="class")if(B)if(q){let E=S(q);z.classList.value=E}else z.classList.value="";else if(q){let E=S(q);z.className=E}else z.className="";else if(F[0]==="o"&&F[1]==="n")if(q){let E=null;if(typeof q==="function"){let Q=q;E=(Y)=>f([Q,Y])}else if(Array.isArray(q)){let Q=q,Y=q[0];if(Q.length>1)E=()=>f([Y,...Q.slice(1)]);else E=(U)=>f([Y,U])}else if(typeof q==="object")E=()=>f(q);z[F]=E}else z[F]=null;else if(q!==null&&q!==void 0&&q!==!1)z.setAttribute(F,q);else z.removeAttribute(F);return q}function S(f){if(typeof f==="string")return f;else if(Array.isArray(f))return f.map(S).join(" ");else if(typeof f==="object")return Object.keys(f).filter((z)=>f[z]).join(" ");else return""}var s="a",r="abbr",l="address",t="area",n="article",a="aside",d="audio",o="b",e="base",ff="bdi",qf="bdo",zf="blockquote",Bf="body",Ef="br",Ff="button",Gf="canvas",Jf="caption",Qf="cite",Uf="code",Wf="col",Xf="colgroup",Yf="data",Zf="datalist",$f="dd",jf="del",Lf="details",Af="dfn",Rf="dialog",Of="div",Hf="dl",Cf="dt",Mf="em",Df="embed",Tf="fieldset",If="figcaption",Kf="figure",Sf="footer",xf="form",Nf="h1",kf="h2",_f="h3",bf="h4",yf="h5",mf="h6",Pf="head",gf="header",hf="hgroup",uf="hr",vf="html",cf="i",Vf="iframe",pf="img",wf="input",sf="ins",rf="kbd",lf="label",tf="legend",nf="li",af="link",df="main",of="map",ef="mark",fq="menu",qq="meta",zq="meter",Bq="nav",Eq="noscript",Fq="object",Gq="ol",Jq="optgroup",Qq="option",Uq="output",Wq="p",Xq="picture",Yq="pre",Zq="progress",$q="q",jq="rp",Lq="rt",Aq="ruby",Rq="s",Oq="samp",Hq="script",Cq="section",Mq="select",Dq="slot",Tq="small",Iq="source",Kq="span",Sq="strong",xq="style",Nq="sub",kq="summary",_q="sup",bq="table",yq="tbody",mq="td",Pq="template",gq="textarea",hq="tfoot",uq="th",vq="thead",cq="time",Vq="title",iq="tr",pq="track",wq="u",sq="ul",rq="video",lq="wbr",tq="animate",nq="animateMotion",aq="animateTransform",dq="circle",oq="clipPath",eq="defs",fz="desc",qz="ellipse",zz="feBlend",Bz="feColorMatrix",Ez="feComponentTransfer",Fz="feComposite",Gz="feConvolveMatrix",Jz="feDiffuseLighting",Qz="feDisplacementMap",Uz="feDistantLight",Wz="feDropShadow",Xz="feFlood",Yz="feFuncA",Zz="feFuncB",$z="feFuncG",jz="feFuncR",Lz="feGaussianBlur",Az="feImage",Rz="feMerge",Oz="feMergeNode",Hz="feMorphology",Cz="feOffset",Mz="fePointLight",Dz="feSpecularLighting",Tz="feSpotLight",Iz="feTile",Kz="feTurbulence",Sz="filter",xz="foreignObject",Nz="g",kz="image",_z="line",bz="linearGradient",yz="marker",mz="mask",Pz="metadata",gz="mpath",hz="path",uz="pattern",vz="polygon",cz="polyline",Vz="radialGradient",iz="rect",pz="set",wz="stop",sz="svg",rz="switch",lz="symbol",tz="text",nz="textPath",az="tspan",dz="use",oz="view",ez="annotation",fB="annotation-xml",qB="maction",zB="math",BB="merror",EB="mfrac",FB="mi",GB="mmultiscripts",JB="mn",QB="mo",UB="mover",WB="mpadded",XB="mphantom",YB="mprescripts",ZB="mroot",$B="mrow",jB="ms",LB="mspace",AB="msqrt",RB="mstyle",OB="msub",HB="msubsup",CB="msup",MB="mtable",DB="mtd",TB="mtext",IB="mtr",KB="munder",SB="munderover",xB="semantics";export{P as vode,c as tag,L as props,V as mergeClass,h as memo,k as hydrate,u as createState,v as createPatch,x as childrenStart,T as children,i as childCount,p as child,g as app,lq as WBR,oz as VIEW,rq as VIDEO,dz as USE,sq as UL,wq as U,az as TSPAN,pq as TRACK,iq as TR,Vq as TITLE,cq as TIME,vq as THEAD,uq as TH,hq as TFOOT,nz as TEXTPATH,gq as TEXTAREA,tz as TEXT,Pq as TEMPLATE,mq as TD,yq as TBODY,bq as TABLE,lz as SYMBOL,rz as SWITCH,sz as SVG,_q as SUP,kq as SUMMARY,Nq as SUB,xq as STYLE,Sq as STRONG,wz as STOP,Kq as SPAN,Iq as SOURCE,Tq as SMALL,Dq as SLOT,pz as SET,xB as SEMANTICS,Mq as SELECT,Cq as SECTION,Hq as SCRIPT,Oq as SAMP,Rq as S,Aq as RUBY,Lq as RT,jq as RP,iz as RECT,Vz as RADIALGRADIENT,$q as Q,Zq as PROGRESS,Yq as PRE,cz as POLYLINE,vz as POLYGON,Xq as PICTURE,uz as PATTERN,hz as PATH,Wq as P,Uq as OUTPUT,Qq as OPTION,Jq as OPTGROUP,Gq as OL,Fq as OBJECT,Eq as NOSCRIPT,Bq as NAV,SB as MUNDEROVER,KB as MUNDER,IB as MTR,TB as MTEXT,DB as MTD,MB as MTABLE,CB as MSUP,HB as MSUBSUP,OB as MSUB,RB as MSTYLE,AB as MSQRT,LB as MSPACE,jB as MS,$B as MROW,ZB as MROOT,YB as MPRESCRIPTS,XB as MPHANTOM,gz as MPATH,WB as MPADDED,UB as MOVER,QB as MO,JB as MN,GB as MMULTISCRIPTS,FB as MI,EB as MFRAC,zq as METER,Pz as METADATA,qq as META,BB as MERROR,fq as MENU,zB as MATH,mz as MASK,yz as MARKER,ef as MARK,of as MAP,df as MAIN,qB as MACTION,af as LINK,bz as LINEARGRADIENT,_z as LINE,nf as LI,tf as LEGEND,lf as LABEL,rf as KBD,sf as INS,wf as INPUT,pf as IMG,kz as IMAGE,Vf as IFRAME,cf as I,vf as HTML,uf as HR,hf as HGROUP,gf as HEADER,Pf as HEAD,mf as H6,yf as H5,bf as H4,_f as H3,kf as H2,Nf as H1,Nz as G,xf as FORM,xz as FOREIGNOBJECT,Sf as FOOTER,Sz as FILTER,Kf as FIGURE,If as FIGCAPTION,Tf as FIELDSET,Kz as FETURBULENCE,Iz as FETILE,Tz as FESPOTLIGHT,Dz as FESPECULARLIGHTING,Mz as FEPOINTLIGHT,Cz as FEOFFSET,Hz as FEMORPHOLOGY,Oz as FEMERGENODE,Rz as FEMERGE,Az as FEIMAGE,Lz as FEGAUSSIANBLUR,jz as FEFUNCR,$z as FEFUNCG,Zz as FEFUNCB,Yz as FEFUNCA,Xz as FEFLOOD,Wz as FEDROPSHADOW,Uz as FEDISTANTLIGHT,Qz as FEDISPLACEMENTMAP,Jz as FEDIFFUSELIGHTING,Gz as FECONVOLVEMATRIX,Fz as FECOMPOSITE,Ez as FECOMPONENTTRANSFER,Bz as FECOLORMATRIX,zz as FEBLEND,Df as EMBED,Mf as EM,qz as ELLIPSE,Cf as DT,Hf as DL,Of as DIV,Rf as DIALOG,Af as DFN,Lf as DETAILS,fz as DESC,jf as DEL,eq as DEFS,$f as DD,Zf as DATALIST,Yf as DATA,Xf as COLGROUP,Wf as COL,Uf as CODE,oq as CLIPPATH,Qf as CITE,dq as CIRCLE,Jf as CAPTION,Gf as CANVAS,Ff as BUTTON,Ef as BR,Bf as BODY,zf as BLOCKQUOTE,qf as BDO,ff as BDI,e as BASE,o as B,d as AUDIO,a as ASIDE,n as ARTICLE,t as AREA,fB as ANNOTATION_XML,ez as ANNOTATION,aq as ANIMATETRANSFORM,nq as ANIMATEMOTION,tq as ANIMATE,l as ADDRESS,r as ABBR,s as A};
|
package/dist/vode.mjs
CHANGED
|
@@ -85,8 +85,9 @@ function app(container, state, dom, ...initialPatches) {
|
|
|
85
85
|
_vode.q = null;
|
|
86
86
|
const vom = dom(_vode.state);
|
|
87
87
|
_vode.vode = render(_vode.state, _vode.patch, container.parentElement, 0, _vode.vode, vom);
|
|
88
|
-
if (container.tagName !== vom[0].toUpperCase()) {
|
|
88
|
+
if (container.tagName.toUpperCase() !== vom[0].toUpperCase()) {
|
|
89
89
|
container = _vode.vode.node;
|
|
90
|
+
container._vode = _vode;
|
|
90
91
|
}
|
|
91
92
|
} finally {
|
|
92
93
|
_vode.isRendering = false;
|
|
@@ -109,6 +110,43 @@ function app(container, state, dom, ...initialPatches) {
|
|
|
109
110
|
}
|
|
110
111
|
return _vode.patch;
|
|
111
112
|
}
|
|
113
|
+
function hydrate(element) {
|
|
114
|
+
if (element?.nodeType === Node.TEXT_NODE) {
|
|
115
|
+
if (element.nodeValue?.trim() !== "")
|
|
116
|
+
return element;
|
|
117
|
+
return;
|
|
118
|
+
} else if (element.nodeType === Node.COMMENT_NODE) {
|
|
119
|
+
return;
|
|
120
|
+
} else if (element.nodeType === Node.ELEMENT_NODE) {
|
|
121
|
+
const tag = element.tagName.toLowerCase();
|
|
122
|
+
const root = [tag];
|
|
123
|
+
root.node = element;
|
|
124
|
+
if (element?.hasAttributes()) {
|
|
125
|
+
const props = {};
|
|
126
|
+
const attr = element.attributes;
|
|
127
|
+
for (let a of attr) {
|
|
128
|
+
props[a.name] = a.value;
|
|
129
|
+
}
|
|
130
|
+
root.push(props);
|
|
131
|
+
}
|
|
132
|
+
if (element.hasChildNodes()) {
|
|
133
|
+
const remove = [];
|
|
134
|
+
for (let child of element.childNodes) {
|
|
135
|
+
const wet = child && hydrate(child);
|
|
136
|
+
if (wet)
|
|
137
|
+
root.push(wet);
|
|
138
|
+
else if (child)
|
|
139
|
+
remove.push(child);
|
|
140
|
+
}
|
|
141
|
+
for (let child of remove) {
|
|
142
|
+
child.remove();
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
return root;
|
|
146
|
+
} else {
|
|
147
|
+
return;
|
|
148
|
+
}
|
|
149
|
+
}
|
|
112
150
|
function memo(compare, componentOrProps) {
|
|
113
151
|
componentOrProps.__memo = compare;
|
|
114
152
|
return componentOrProps;
|
|
@@ -224,43 +262,6 @@ function mergeState(target, source, allowDeletion) {
|
|
|
224
262
|
}
|
|
225
263
|
return target;
|
|
226
264
|
}
|
|
227
|
-
function hydrate(element) {
|
|
228
|
-
if (element?.nodeType === Node.TEXT_NODE) {
|
|
229
|
-
if (element.nodeValue?.trim() !== "")
|
|
230
|
-
return element;
|
|
231
|
-
return;
|
|
232
|
-
} else if (element.nodeType === Node.COMMENT_NODE) {
|
|
233
|
-
return;
|
|
234
|
-
} else if (element.nodeType === Node.ELEMENT_NODE) {
|
|
235
|
-
const tag2 = element.tagName.toLowerCase();
|
|
236
|
-
const root = [tag2];
|
|
237
|
-
root.node = element;
|
|
238
|
-
if (element?.hasAttributes()) {
|
|
239
|
-
const props2 = {};
|
|
240
|
-
const attr = element.attributes;
|
|
241
|
-
for (let a of attr) {
|
|
242
|
-
props2[a.name] = a.value;
|
|
243
|
-
}
|
|
244
|
-
root.push(props2);
|
|
245
|
-
}
|
|
246
|
-
if (element.hasChildNodes()) {
|
|
247
|
-
const remove = [];
|
|
248
|
-
for (let child2 of element.childNodes) {
|
|
249
|
-
const wet = child2 && hydrate(child2);
|
|
250
|
-
if (wet)
|
|
251
|
-
root.push(wet);
|
|
252
|
-
else if (child2)
|
|
253
|
-
remove.push(child2);
|
|
254
|
-
}
|
|
255
|
-
for (let child2 of remove) {
|
|
256
|
-
child2.remove();
|
|
257
|
-
}
|
|
258
|
-
}
|
|
259
|
-
return root;
|
|
260
|
-
} else {
|
|
261
|
-
return;
|
|
262
|
-
}
|
|
263
|
-
}
|
|
264
265
|
function render(state, patch, parent, childIndex, oldVode, newVode, svg) {
|
|
265
266
|
newVode = remember(state, newVode, oldVode);
|
|
266
267
|
const isNoVode = !newVode || typeof newVode === "number" || typeof newVode === "boolean";
|
|
@@ -717,47 +718,13 @@ var MTR = "mtr";
|
|
|
717
718
|
var MUNDER = "munder";
|
|
718
719
|
var MUNDEROVER = "munderover";
|
|
719
720
|
var SEMANTICS = "semantics";
|
|
720
|
-
// src/html.ts
|
|
721
|
-
function htmlToVode(html) {
|
|
722
|
-
const div = document.createElement("div");
|
|
723
|
-
div.innerHTML = html.trim();
|
|
724
|
-
const vodes = [];
|
|
725
|
-
for (const child2 of div.childNodes) {
|
|
726
|
-
const v = elementToVode(child2);
|
|
727
|
-
if (v != null)
|
|
728
|
-
vodes.push(v);
|
|
729
|
-
}
|
|
730
|
-
return vodes;
|
|
731
|
-
}
|
|
732
|
-
function elementToVode(element) {
|
|
733
|
-
if (element.nodeType === Node.TEXT_NODE) {
|
|
734
|
-
return element.textContent;
|
|
735
|
-
}
|
|
736
|
-
if (element.nodeType !== Node.ELEMENT_NODE) {
|
|
737
|
-
return;
|
|
738
|
-
}
|
|
739
|
-
const vode2 = [element.tagName.toLowerCase()];
|
|
740
|
-
if (element.hasAttributes()) {
|
|
741
|
-
const props2 = {};
|
|
742
|
-
for (const att of element.attributes) {
|
|
743
|
-
props2[att.name] = att.value;
|
|
744
|
-
}
|
|
745
|
-
vode2.push(props2);
|
|
746
|
-
}
|
|
747
|
-
for (const child2 of element.childNodes) {
|
|
748
|
-
const v = elementToVode(child2);
|
|
749
|
-
if (v && (typeof v !== "string" || v.length > 0))
|
|
750
|
-
vode2.push(v);
|
|
751
|
-
}
|
|
752
|
-
return vode2;
|
|
753
|
-
}
|
|
754
721
|
export {
|
|
755
722
|
vode,
|
|
756
723
|
tag,
|
|
757
724
|
props,
|
|
758
725
|
mergeClass,
|
|
759
726
|
memo,
|
|
760
|
-
|
|
727
|
+
hydrate,
|
|
761
728
|
createState,
|
|
762
729
|
createPatch,
|
|
763
730
|
childrenStart,
|
package/index.ts
CHANGED
package/package.json
CHANGED
package/src/vode.ts
CHANGED
|
@@ -182,8 +182,9 @@ export function app<S extends object | unknown>(container: Element, state: Omit<
|
|
|
182
182
|
_vode.q = null;
|
|
183
183
|
const vom = dom(_vode.state);
|
|
184
184
|
_vode.vode = render(_vode.state, _vode.patch, container.parentElement as Element, 0, _vode.vode, vom)!;
|
|
185
|
-
if ((<ContainerNode<S>>container).tagName !== (vom[0] as Tag).toUpperCase()) { //the tag name was changed during render -> update reference to vode-app-root
|
|
185
|
+
if ((<ContainerNode<S>>container).tagName.toUpperCase() !== (vom[0] as Tag).toUpperCase()) { //the tag name was changed during render -> update reference to vode-app-root
|
|
186
186
|
container = _vode.vode.node as Element;
|
|
187
|
+
(<ContainerNode<S>>container)._vode = _vode
|
|
187
188
|
}
|
|
188
189
|
} finally {
|
|
189
190
|
_vode.isRendering = false;
|
|
@@ -219,6 +220,46 @@ export function app<S extends object | unknown>(container: Element, state: Omit<
|
|
|
219
220
|
return _vode.patch;
|
|
220
221
|
}
|
|
221
222
|
|
|
223
|
+
/** return vode representation of given DOM node */
|
|
224
|
+
export function hydrate<S = unknown>(element: Element | Text): AttachedVode<S> | undefined {
|
|
225
|
+
if ((element as Text)?.nodeType === Node.TEXT_NODE) {
|
|
226
|
+
if ((element as Text).nodeValue?.trim() !== "")
|
|
227
|
+
return element as Text;
|
|
228
|
+
return undefined; //ignore (mostly html whitespace)
|
|
229
|
+
}
|
|
230
|
+
else if (element.nodeType === Node.COMMENT_NODE) {
|
|
231
|
+
return undefined; //ignore (not interesting)
|
|
232
|
+
}
|
|
233
|
+
else if (element.nodeType === Node.ELEMENT_NODE) {
|
|
234
|
+
const tag: Tag = (<Element>element).tagName.toLowerCase();
|
|
235
|
+
const root: Vode<S> = [tag];
|
|
236
|
+
|
|
237
|
+
(<AttachedVode<S>>root).node = element;
|
|
238
|
+
if ((element as HTMLElement)?.hasAttributes()) {
|
|
239
|
+
const props: Props<S> = {};
|
|
240
|
+
const attr = (<HTMLElement>element).attributes;
|
|
241
|
+
for (let a of attr) {
|
|
242
|
+
props[a.name] = a.value;
|
|
243
|
+
}
|
|
244
|
+
(<Vode<S>>root).push(props as any);
|
|
245
|
+
}
|
|
246
|
+
if (element.hasChildNodes()) {
|
|
247
|
+
const remove: ChildNode[] = [];
|
|
248
|
+
for (let child of element.childNodes) {
|
|
249
|
+
const wet = child && hydrate<S>(child as Element | Text)! as ChildVode<S>;
|
|
250
|
+
if (wet) root.push(wet as any);
|
|
251
|
+
else if (child) remove.push(child);
|
|
252
|
+
}
|
|
253
|
+
for (let child of remove) {
|
|
254
|
+
child.remove();
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
return <AttachedVode<S>>root;
|
|
258
|
+
} else {
|
|
259
|
+
return undefined;
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
|
|
222
263
|
/** memoizes the resulting component or props by comparing element by element (===) with the
|
|
223
264
|
* `compare` of the previous render. otherwise skips the render step (not calling `componentOrProps`)*/
|
|
224
265
|
export function memo<S>(compare: any[], componentOrProps: Component<S> | ((s: S) => Props<S>)): typeof componentOrProps extends ((s: S) => Props<S>) ? ((s: S) => Props<S>) : Component<S> {
|
|
@@ -365,45 +406,6 @@ function mergeState(target: any, source: any, allowDeletion: boolean) {
|
|
|
365
406
|
return target;
|
|
366
407
|
};
|
|
367
408
|
|
|
368
|
-
function hydrate<S = unknown>(element: Element | Text): AttachedVode<S> | undefined {
|
|
369
|
-
if ((element as Text)?.nodeType === Node.TEXT_NODE) {
|
|
370
|
-
if ((element as Text).nodeValue?.trim() !== "")
|
|
371
|
-
return element as Text;
|
|
372
|
-
return undefined; //ignore (mostly html whitespace)
|
|
373
|
-
}
|
|
374
|
-
else if (element.nodeType === Node.COMMENT_NODE) {
|
|
375
|
-
return undefined; //ignore (not interesting)
|
|
376
|
-
}
|
|
377
|
-
else if (element.nodeType === Node.ELEMENT_NODE) {
|
|
378
|
-
const tag: Tag = (<Element>element).tagName.toLowerCase();
|
|
379
|
-
const root: Vode<S> = [tag];
|
|
380
|
-
|
|
381
|
-
(<AttachedVode<S>>root).node = element;
|
|
382
|
-
if ((element as HTMLElement)?.hasAttributes()) {
|
|
383
|
-
const props: Props<S> = {};
|
|
384
|
-
const attr = (<HTMLElement>element).attributes;
|
|
385
|
-
for (let a of attr) {
|
|
386
|
-
props[a.name] = a.value;
|
|
387
|
-
}
|
|
388
|
-
(<Vode<S>>root).push(props as any);
|
|
389
|
-
}
|
|
390
|
-
if (element.hasChildNodes()) {
|
|
391
|
-
const remove: ChildNode[] = [];
|
|
392
|
-
for (let child of element.childNodes) {
|
|
393
|
-
const wet = child && hydrate<S>(child as Element | Text)! as ChildVode<S>;
|
|
394
|
-
if (wet) root.push(wet as any);
|
|
395
|
-
else if (child) remove.push(child);
|
|
396
|
-
}
|
|
397
|
-
for (let child of remove) {
|
|
398
|
-
child.remove();
|
|
399
|
-
}
|
|
400
|
-
}
|
|
401
|
-
return <AttachedVode<S>>root;
|
|
402
|
-
} else {
|
|
403
|
-
return undefined;
|
|
404
|
-
}
|
|
405
|
-
}
|
|
406
|
-
|
|
407
409
|
function render<S>(state: S, patch: Dispatch<S>, parent: Element, childIndex: number, oldVode: AttachedVode<S> | undefined, newVode: ChildVode<S>, svg?: boolean): AttachedVode<S> | undefined {
|
|
408
410
|
// unwrap component if it is memoized
|
|
409
411
|
newVode = remember(state, newVode, oldVode) as ChildVode<S>;
|
package/tsconfig.json
CHANGED
package/src/html.ts
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import { Props, Vode } from "./vode.js";
|
|
2
|
-
|
|
3
|
-
export function htmlToVode<S extends object | unknown>(html: string): (Vode<S> | string)[] {
|
|
4
|
-
const div = document.createElement('div');
|
|
5
|
-
div.innerHTML = html.trim();
|
|
6
|
-
|
|
7
|
-
const vodes: (Vode<S> | string)[] = [];
|
|
8
|
-
for (const child of div.childNodes) {
|
|
9
|
-
const v = elementToVode<S>(<Element>child);
|
|
10
|
-
if (v != null) vodes.push(v);
|
|
11
|
-
}
|
|
12
|
-
return vodes;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
function elementToVode<S>(element: Element): Vode<S> | string | undefined | null {
|
|
16
|
-
if (element.nodeType === Node.TEXT_NODE) {
|
|
17
|
-
return element.textContent;
|
|
18
|
-
}
|
|
19
|
-
if (element.nodeType !== Node.ELEMENT_NODE) {
|
|
20
|
-
return undefined;
|
|
21
|
-
}
|
|
22
|
-
const vode = <Vode<S>>[element.tagName.toLowerCase()];
|
|
23
|
-
|
|
24
|
-
if (element.hasAttributes()) {
|
|
25
|
-
const props = <Props<S>>{};
|
|
26
|
-
for (const att of element.attributes) {
|
|
27
|
-
props[att.name] = att.value;
|
|
28
|
-
}
|
|
29
|
-
(<any[]>vode).push(props);
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
for (const child of element.childNodes) {
|
|
33
|
-
const v = elementToVode(<Element>child);
|
|
34
|
-
if (v && (typeof v !== "string" || v.length > 0)) (<any[]>vode).push(v);
|
|
35
|
-
}
|
|
36
|
-
return vode;
|
|
37
|
-
}
|