valyrian.js 8.1.8 → 8.1.10
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/dist/index.js +138 -65
- package/dist/index.js.map +3 -3
- package/dist/index.min.js +1 -1
- package/dist/index.min.js.map +1 -1
- package/dist/index.mjs +138 -65
- package/dist/index.mjs.map +3 -3
- package/dist/lib/index.d.ts +2 -2
- package/dist/lib/index.d.ts.map +1 -1
- package/dist/lib/pulses/index.d.ts.map +1 -1
- package/dist/lib/suspense/index.d.ts +2 -1
- package/dist/lib/suspense/index.d.ts.map +1 -1
- package/dist/pulses/index.js +30 -17
- package/dist/pulses/index.js.map +2 -2
- package/dist/pulses/index.min.js +1 -1
- package/dist/pulses/index.min.js.map +1 -1
- package/dist/pulses/index.mjs +30 -17
- package/dist/pulses/index.mjs.map +2 -2
- package/dist/suspense/index.js +76 -25
- package/dist/suspense/index.js.map +2 -2
- package/dist/suspense/index.min.js +1 -1
- package/dist/suspense/index.min.js.map +1 -1
- package/dist/suspense/index.mjs +84 -26
- package/dist/suspense/index.mjs.map +2 -2
- package/lib/index.ts +158 -74
- package/lib/pulses/index.ts +37 -19
- package/lib/suspense/index.ts +125 -36
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -131,15 +131,30 @@ var reservedProps = /* @__PURE__ */ new Set([
|
|
|
131
131
|
"v-model",
|
|
132
132
|
"v-create",
|
|
133
133
|
"v-update",
|
|
134
|
-
"v-cleanup"
|
|
134
|
+
"v-cleanup",
|
|
135
|
+
"v-remove"
|
|
135
136
|
]);
|
|
137
|
+
var SUBTREE_LC = Symbol.for("valyrian.subtreeLifecycle");
|
|
138
|
+
function markSubtreeLifecycle(dom) {
|
|
139
|
+
let node = dom;
|
|
140
|
+
while (node && node.nodeType === 1 && !node[SUBTREE_LC]) {
|
|
141
|
+
node[SUBTREE_LC] = true;
|
|
142
|
+
node = node.parentElement;
|
|
143
|
+
}
|
|
144
|
+
}
|
|
136
145
|
function addCallbackToSet(callback, setType, vnode) {
|
|
137
146
|
vnode[setType] = vnode[setType] || /* @__PURE__ */ new Set();
|
|
147
|
+
if (vnode.dom) {
|
|
148
|
+
markSubtreeLifecycle(vnode.dom);
|
|
149
|
+
}
|
|
138
150
|
vnode[setType].add(() => {
|
|
139
151
|
const cleanup = callback();
|
|
140
152
|
if (typeof cleanup === "function") {
|
|
141
153
|
vnode["oncleanup" /* onCleanup */] = vnode["oncleanup" /* onCleanup */] || /* @__PURE__ */ new Set();
|
|
142
154
|
vnode["oncleanup" /* onCleanup */].add(cleanup);
|
|
155
|
+
if (vnode.dom) {
|
|
156
|
+
markSubtreeLifecycle(vnode.dom);
|
|
157
|
+
}
|
|
143
158
|
}
|
|
144
159
|
});
|
|
145
160
|
}
|
|
@@ -194,51 +209,77 @@ var callSet = (set) => {
|
|
|
194
209
|
}
|
|
195
210
|
set.clear();
|
|
196
211
|
};
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
212
|
+
function collectVnodesPostOrder(dom, out) {
|
|
213
|
+
const childNodes = dom.childNodes;
|
|
214
|
+
for (let i = 0; i < childNodes.length; i++) {
|
|
215
|
+
const child = childNodes[i];
|
|
216
|
+
if (!child || child.nodeType !== 1) {
|
|
217
|
+
continue;
|
|
201
218
|
}
|
|
202
|
-
|
|
203
|
-
|
|
219
|
+
collectVnodesPostOrder(child, out);
|
|
220
|
+
}
|
|
221
|
+
const vnode = dom.vnode;
|
|
222
|
+
if (vnode) {
|
|
223
|
+
out.push(vnode);
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
function strictCleanupBeforeRemove(dom) {
|
|
227
|
+
const vnodes = [];
|
|
228
|
+
collectVnodesPostOrder(dom, vnodes);
|
|
229
|
+
for (let i = 0; i < vnodes.length; i++) {
|
|
230
|
+
callSet(vnodes[i].oncleanup);
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
function strictOnRemoveAfterDetach(dom) {
|
|
234
|
+
const vnodes = [];
|
|
235
|
+
collectVnodesPostOrder(dom, vnodes);
|
|
236
|
+
for (let i = 0; i < vnodes.length; i++) {
|
|
237
|
+
callSet(vnodes[i].onremove);
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
function strictRemoveNode(dom) {
|
|
241
|
+
if (!dom || dom.nodeType !== 1) {
|
|
242
|
+
return;
|
|
243
|
+
}
|
|
244
|
+
if (!dom[SUBTREE_LC]) {
|
|
245
|
+
dom.remove();
|
|
246
|
+
return;
|
|
247
|
+
}
|
|
248
|
+
strictCleanupBeforeRemove(dom);
|
|
249
|
+
dom.remove();
|
|
250
|
+
strictOnRemoveAfterDetach(dom);
|
|
251
|
+
}
|
|
252
|
+
function strictReplaceChild(parent, newNode, oldNode) {
|
|
253
|
+
if (oldNode && oldNode.nodeType === 1 && oldNode[SUBTREE_LC]) {
|
|
254
|
+
strictCleanupBeforeRemove(oldNode);
|
|
255
|
+
}
|
|
256
|
+
parent.replaceChild(newNode, oldNode);
|
|
257
|
+
if (oldNode && oldNode.nodeType === 1 && oldNode[SUBTREE_LC]) {
|
|
258
|
+
strictOnRemoveAfterDetach(oldNode);
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
var directives = {
|
|
262
|
+
"v-create": (callback, vnode, oldProps) => {
|
|
204
263
|
if (oldProps) {
|
|
205
|
-
|
|
264
|
+
return;
|
|
206
265
|
}
|
|
266
|
+
addCallbackToSet(() => callback(vnode), "oncreate" /* onCreate */, vnode);
|
|
207
267
|
},
|
|
208
|
-
"v-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
while (parentVnode) {
|
|
212
|
-
parentVnode.onremove = parentVnode.onremove || /* @__PURE__ */ new Set();
|
|
213
|
-
addCallbackToSet(
|
|
214
|
-
() => {
|
|
215
|
-
if (!childVnode.dom.vnode || currentChildVnode.dom.parentNode) {
|
|
216
|
-
return;
|
|
217
|
-
}
|
|
218
|
-
callback(childVnode);
|
|
219
|
-
childVnode.dom.vnode = null;
|
|
220
|
-
},
|
|
221
|
-
"onremove" /* onRemove */,
|
|
222
|
-
parentVnode
|
|
223
|
-
);
|
|
224
|
-
if (!parentVnode.dom.parentElement) {
|
|
225
|
-
break;
|
|
226
|
-
}
|
|
227
|
-
currentChildVnode = parentVnode;
|
|
228
|
-
parentVnode = parentVnode.dom.parentElement.vnode;
|
|
268
|
+
"v-update": (callback, vnode, oldProps) => {
|
|
269
|
+
if (!oldProps) {
|
|
270
|
+
return;
|
|
229
271
|
}
|
|
272
|
+
addCallbackToSet(() => callback(vnode, oldProps), "onupdate" /* onUpdate */, vnode);
|
|
230
273
|
},
|
|
231
274
|
"v-cleanup": (callback, vnode) => {
|
|
232
|
-
|
|
275
|
+
vnode.oncleanup = vnode.oncleanup || /* @__PURE__ */ new Set();
|
|
276
|
+
vnode.oncleanup.add(() => callback(vnode));
|
|
277
|
+
markSubtreeLifecycle(vnode.dom);
|
|
233
278
|
},
|
|
234
|
-
"v-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
parentNode.replaceChild(document.createTextNode(""), vnode.dom);
|
|
239
|
-
}
|
|
240
|
-
return false;
|
|
241
|
-
}
|
|
279
|
+
"v-remove": (callback, vnode) => {
|
|
280
|
+
vnode.onremove = vnode.onremove || /* @__PURE__ */ new Set();
|
|
281
|
+
vnode.onremove.add(() => callback(vnode));
|
|
282
|
+
markSubtreeLifecycle(vnode.dom);
|
|
242
283
|
},
|
|
243
284
|
"v-show": (value, vnode) => {
|
|
244
285
|
const bool = Boolean(value);
|
|
@@ -411,7 +452,11 @@ function eventListener(e) {
|
|
|
411
452
|
while (dom) {
|
|
412
453
|
const oldVnode = dom.vnode;
|
|
413
454
|
if (oldVnode && oldVnode.props[name]) {
|
|
414
|
-
|
|
455
|
+
try {
|
|
456
|
+
oldVnode.props[name](e, oldVnode);
|
|
457
|
+
} finally {
|
|
458
|
+
current.event = null;
|
|
459
|
+
}
|
|
415
460
|
if (!e.defaultPrevented) {
|
|
416
461
|
update();
|
|
417
462
|
}
|
|
@@ -477,66 +522,79 @@ function createElement(tag, isSVG) {
|
|
|
477
522
|
return isSVG ? document.createElementNS("http://www.w3.org/2000/svg", tag) : document.createElement(tag);
|
|
478
523
|
}
|
|
479
524
|
function flatTree(newVnode) {
|
|
480
|
-
let
|
|
481
|
-
|
|
525
|
+
let children = [];
|
|
526
|
+
const newChildren = newVnode.children;
|
|
527
|
+
newVnode.hasKeys = false;
|
|
482
528
|
if ("v-for" in newVnode.props === false) {
|
|
483
|
-
|
|
529
|
+
for (let l = newChildren.length - 1; l >= 0; l--) {
|
|
530
|
+
children.push(newChildren[l]);
|
|
531
|
+
}
|
|
484
532
|
} else {
|
|
485
533
|
children = [];
|
|
486
534
|
const set = newVnode.props["v-for"];
|
|
487
|
-
const l = set.length;
|
|
488
535
|
const callback = newVnode.children[0];
|
|
489
536
|
if (typeof callback !== "function") {
|
|
490
537
|
console.warn("v-for directive must have a callback function as children");
|
|
491
538
|
return children;
|
|
492
539
|
}
|
|
493
|
-
|
|
494
|
-
|
|
540
|
+
const tmp = [];
|
|
541
|
+
for (let i = 0; i < set.length; i++) {
|
|
542
|
+
tmp.push(callback(set[i], i));
|
|
543
|
+
}
|
|
544
|
+
for (let i = tmp.length - 1; i >= 0; i--) {
|
|
545
|
+
children.push(tmp[i]);
|
|
495
546
|
}
|
|
496
547
|
}
|
|
497
548
|
newVnode.oldChildComponents = newVnode.childComponents;
|
|
498
549
|
if (newVnode.childComponents) {
|
|
499
550
|
newVnode.childComponents = /* @__PURE__ */ new Set();
|
|
500
551
|
}
|
|
501
|
-
|
|
502
|
-
|
|
552
|
+
const out = [];
|
|
553
|
+
while (children.length) {
|
|
554
|
+
const newChild = children.pop();
|
|
503
555
|
if (newChild == null) {
|
|
504
|
-
children.splice(i, 1);
|
|
505
556
|
continue;
|
|
506
557
|
}
|
|
507
558
|
if (Array.isArray(newChild)) {
|
|
508
|
-
|
|
559
|
+
for (let l = newChild.length - 1; l >= 0; l--) {
|
|
560
|
+
children.push(newChild[l]);
|
|
561
|
+
}
|
|
509
562
|
continue;
|
|
510
563
|
}
|
|
511
564
|
if (newChild instanceof Vnode) {
|
|
512
565
|
newChild.props = newChild.props || {};
|
|
566
|
+
if ("v-if" in newChild.props && !Boolean(newChild.props["v-if"])) {
|
|
567
|
+
continue;
|
|
568
|
+
}
|
|
513
569
|
newChild.isSVG = newVnode.isSVG || newChild.tag === "svg";
|
|
514
570
|
if (typeof newChild.tag !== "string") {
|
|
515
571
|
const component = current.component = newChild.tag;
|
|
516
572
|
newVnode.childComponents = newVnode.childComponents || /* @__PURE__ */ new Set();
|
|
517
573
|
newVnode.childComponents.add(component);
|
|
518
|
-
children
|
|
519
|
-
newChild.props,
|
|
520
|
-
newChild.children
|
|
574
|
+
children.push(
|
|
575
|
+
(isPOJOComponent(component) ? component.view : component).bind(component)(newChild.props, newChild.children)
|
|
521
576
|
);
|
|
522
577
|
continue;
|
|
523
578
|
}
|
|
524
579
|
newVnode.hasKeys = newVnode.hasKeys || "key" in newChild.props;
|
|
580
|
+
out.push(newChild);
|
|
581
|
+
continue;
|
|
525
582
|
}
|
|
526
|
-
|
|
583
|
+
out.push(newChild);
|
|
527
584
|
}
|
|
528
|
-
return
|
|
585
|
+
return out;
|
|
529
586
|
}
|
|
530
587
|
function processNewChild(newChild, parentVnode, oldDom) {
|
|
531
588
|
if (oldDom) {
|
|
532
589
|
newChild.dom = createElement(newChild.tag, newChild.isSVG);
|
|
533
|
-
parentVnode.dom
|
|
590
|
+
strictReplaceChild(parentVnode.dom, newChild.dom, oldDom);
|
|
534
591
|
} else {
|
|
535
592
|
newChild.dom = parentVnode.dom.appendChild(createElement(newChild.tag, newChild.isSVG));
|
|
536
593
|
}
|
|
537
594
|
updateAttributes(newChild);
|
|
538
595
|
if ("v-text" in newChild.props) {
|
|
539
596
|
newChild.dom.textContent = newChild.props["v-text"];
|
|
597
|
+
callSet(newChild.oncreate);
|
|
540
598
|
return;
|
|
541
599
|
}
|
|
542
600
|
current.oldVnode = null;
|
|
@@ -544,6 +602,7 @@ function processNewChild(newChild, parentVnode, oldDom) {
|
|
|
544
602
|
const children = flatTree(newChild);
|
|
545
603
|
if (children.length === 0) {
|
|
546
604
|
newChild.dom.textContent = "";
|
|
605
|
+
callSet(newChild.oncreate);
|
|
547
606
|
return;
|
|
548
607
|
}
|
|
549
608
|
for (let i = 0, l = children.length; i < l; i++) {
|
|
@@ -553,6 +612,7 @@ function processNewChild(newChild, parentVnode, oldDom) {
|
|
|
553
612
|
}
|
|
554
613
|
processNewChild(children[i], newChild);
|
|
555
614
|
}
|
|
615
|
+
callSet(newChild.oncreate);
|
|
556
616
|
}
|
|
557
617
|
function patch(newVnode, oldVnode) {
|
|
558
618
|
current.oldVnode = oldVnode;
|
|
@@ -561,8 +621,18 @@ function patch(newVnode, oldVnode) {
|
|
|
561
621
|
const dom = newVnode.dom;
|
|
562
622
|
if (children.length === 0) {
|
|
563
623
|
if (dom.childNodes.length) {
|
|
564
|
-
|
|
624
|
+
const childNodes2 = Array.from(dom.childNodes);
|
|
625
|
+
for (let i = childNodes2.length - 1; i >= 0; i--) {
|
|
626
|
+
const n = childNodes2[i];
|
|
627
|
+
if (n && n.nodeType === 1) {
|
|
628
|
+
strictRemoveNode(n);
|
|
629
|
+
} else {
|
|
630
|
+
n?.remove?.();
|
|
631
|
+
}
|
|
632
|
+
}
|
|
565
633
|
}
|
|
634
|
+
callSet(newVnode.oncreate);
|
|
635
|
+
callSet(newVnode.onupdate);
|
|
566
636
|
return;
|
|
567
637
|
}
|
|
568
638
|
const childNodes = dom.childNodes;
|
|
@@ -577,7 +647,7 @@ function patch(newVnode, oldVnode) {
|
|
|
577
647
|
}
|
|
578
648
|
processNewChild(newChild, newVnode);
|
|
579
649
|
}
|
|
580
|
-
|
|
650
|
+
callSet(newVnode.oncreate);
|
|
581
651
|
return;
|
|
582
652
|
}
|
|
583
653
|
let oldTree = childNodes;
|
|
@@ -600,7 +670,7 @@ function patch(newVnode, oldVnode) {
|
|
|
600
670
|
continue;
|
|
601
671
|
}
|
|
602
672
|
if (oldChild2.nodeType !== 3) {
|
|
603
|
-
dom
|
|
673
|
+
strictReplaceChild(dom, document.createTextNode(newChild), oldChild2);
|
|
604
674
|
continue;
|
|
605
675
|
}
|
|
606
676
|
if (oldChild2.nodeValue != newChild) {
|
|
@@ -627,7 +697,7 @@ function patch(newVnode, oldVnode) {
|
|
|
627
697
|
}
|
|
628
698
|
const oldProps = childNodes[i + 1]?.vnode?.props;
|
|
629
699
|
if (oldProps && "key" in oldProps === false && oldProps["v-keep"] === newChild.props["v-keep"]) {
|
|
630
|
-
oldChild
|
|
700
|
+
strictRemoveNode(oldChild);
|
|
631
701
|
oldTree.splice(i, 1);
|
|
632
702
|
continue;
|
|
633
703
|
}
|
|
@@ -641,10 +711,14 @@ function patch(newVnode, oldVnode) {
|
|
|
641
711
|
}
|
|
642
712
|
callSet(oldChildVnode?.oncleanup);
|
|
643
713
|
patch(newChild, oldChildVnode || null);
|
|
644
|
-
callSet(oldChildVnode?.onremove);
|
|
645
714
|
}
|
|
646
715
|
for (let i = childNodes.length, l = children.length; i > l; i--) {
|
|
647
|
-
childNodes[i - 1]
|
|
716
|
+
const toRemove = childNodes[i - 1];
|
|
717
|
+
if (toRemove && toRemove.nodeType === 1) {
|
|
718
|
+
strictRemoveNode(toRemove);
|
|
719
|
+
} else {
|
|
720
|
+
toRemove?.remove();
|
|
721
|
+
}
|
|
648
722
|
}
|
|
649
723
|
callSet(newVnode.oncreate);
|
|
650
724
|
callSet(newVnode.onupdate);
|
|
@@ -686,11 +760,10 @@ function unmount() {
|
|
|
686
760
|
if (mainVnode) {
|
|
687
761
|
mainComponent = v(() => null, {});
|
|
688
762
|
const result = update();
|
|
689
|
-
for (const name
|
|
690
|
-
mainVnode.dom.removeEventListener(name.slice(2)
|
|
691
|
-
Reflect.deleteProperty(eventListenerNames, name);
|
|
763
|
+
for (const name of eventListenerNames) {
|
|
764
|
+
mainVnode.dom.removeEventListener(name.slice(2), eventListener);
|
|
692
765
|
}
|
|
693
|
-
|
|
766
|
+
eventListenerNames.clear();
|
|
694
767
|
mainComponent = null;
|
|
695
768
|
mainVnode = null;
|
|
696
769
|
isMounted = false;
|
package/dist/index.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../lib/index.ts"],
|
|
4
|
-
"sourcesContent": ["/* eslint-disable */\ndeclare global {\n var document: Document;\n namespace JSX {\n interface IntrinsicElements extends DefaultRecord {}\n type Element = ReturnType<\n typeof v | ((...args: any) => string | number | null | undefined | boolean | Promise<any>)\n >;\n type ComponentReturnType = string | number | null | undefined | boolean | Element | Element[];\n }\n}\n\ninterface DefaultRecord extends Record<string | number | symbol, any> {}\n\nexport interface Properties extends DefaultRecord {\n key?: string | number;\n}\n\nexport interface DomElement extends Element, DefaultRecord {}\n\nexport interface Component extends DefaultRecord {\n (props: Properties, children: any[]): Vnode | any;\n}\n\nexport interface POJOComponent extends DefaultRecord {\n view: Component;\n}\n\nexport type ValyrianComponent = Component | POJOComponent;\n\nexport interface VnodeComponentInterface extends Vnode {\n tag: ValyrianComponent;\n}\n\nexport interface Children extends Array<Vnode | VnodeComponentInterface | ValyrianComponent | any> {}\n\nexport interface Directive {\n (value: any, vnode: VnodeWithDom, oldProps?: Properties): false | void | any;\n}\n\nexport const isNodeJs = Boolean(typeof process !== \"undefined\" && process.versions && process.versions.node);\n\nexport class Vnode {\n constructor(\n public tag: string | Component | POJOComponent,\n public props: null | Properties,\n public children: Children,\n public dom?: DomElement,\n public isSVG?: boolean,\n public oldChildComponents?: Set<ValyrianComponent>,\n public childComponents?: Set<ValyrianComponent>,\n public hasKeys?: boolean,\n public oncreate?: Set<Function>,\n public oncleanup?: Set<Function>,\n public onupdate?: Set<Function>,\n public onremove?: Set<Function>\n ) {}\n}\n\nexport interface VnodeWithDom extends Vnode {\n tag: string;\n dom: DomElement;\n props: Properties;\n}\n\nexport const isPOJOComponent = (component: unknown): component is POJOComponent =>\n Boolean(component && typeof component === \"object\" && \"view\" in component);\n\nexport const isComponent = (component: unknown): component is Component =>\n Boolean(typeof component === \"function\" || isPOJOComponent(component));\nexport const isVnode = (object?: unknown): object is Vnode => object instanceof Vnode;\n\nexport const isVnodeComponent = (object?: unknown): object is VnodeComponentInterface => {\n return isVnode(object) && isComponent(object.tag);\n};\n\nexport function v(tagOrComponent: string | ValyrianComponent, props: Properties | null, ...children: Children) {\n return new Vnode(tagOrComponent, props, children);\n}\n\nv.fragment = (_: Properties, ...children: Children) => children;\n\nexport function hidrateDomToVnode(dom: any): VnodeWithDom | void {\n if (dom.nodeType === 3) {\n return dom.nodeValue;\n }\n\n if (dom.nodeType === 1) {\n const tag = dom.nodeName.toLowerCase();\n const props = {} as Properties;\n const children = [] as Children;\n\n for (let i = 0, l = dom.childNodes.length; i < l; i++) {\n const childDom = dom.childNodes[i];\n if (childDom.nodeType === 3) {\n children.push(childDom.nodeValue);\n } else if (childDom.nodeType === 1) {\n const childVnode = hidrateDomToVnode(childDom);\n children.push(childVnode);\n }\n }\n\n const attributes = dom.attributes;\n for (let i = 0, l = attributes.length; i < l; i++) {\n const attr = attributes[i];\n props[attr.nodeName] = attr.nodeValue;\n }\n\n const vnode = new Vnode(tag, props, children);\n vnode.dom = dom;\n dom.vnode = vnode;\n vnode.isSVG = tag === \"svg\";\n return vnode as VnodeWithDom;\n }\n}\n\nexport function trust(htmlString: string) {\n const div = document.createElement(\"div\");\n div.innerHTML = htmlString.trim();\n return Array.from(div.childNodes).map(hidrateDomToVnode);\n}\n\nlet mainComponent: VnodeComponentInterface | null = null;\nlet mainVnode: VnodeWithDom | null = null;\nlet isMounted = false;\n\nexport const current = {\n oldVnode: null as Vnode | null,\n vnode: null as Vnode | null,\n component: null as ValyrianComponent | null,\n event: null as Event | null\n};\n\nexport const reservedProps = new Set<string>([\n \"key\",\n \"state\",\n \"v-keep\",\n \"v-text\",\n \"v-if\",\n \"v-for\",\n \"v-show\",\n \"v-class\",\n \"v-html\",\n \"v-model\",\n \"v-create\",\n \"v-update\",\n \"v-cleanup\"\n]);\n\nenum SetType {\n onCreate = \"oncreate\",\n onUpdate = \"onupdate\",\n onCleanup = \"oncleanup\",\n onRemove = \"onremove\"\n}\n\nfunction addCallbackToSet(callback: Function, setType: SetType, vnode: VnodeWithDom) {\n vnode[setType] = vnode[setType] || new Set();\n vnode[setType].add(() => {\n const cleanup = callback();\n if (typeof cleanup === \"function\") {\n vnode[SetType.onCleanup] = vnode[SetType.onCleanup] || new Set();\n vnode[SetType.onCleanup].add(cleanup);\n }\n });\n}\n\nfunction validateIsCalledInsideComponent() {\n if (!current.vnode) {\n throw new Error(\"This function must be called inside a component\");\n }\n}\n\nexport const onCreate = (callback: Function) => {\n validateIsCalledInsideComponent();\n const parentVnode = current.vnode as VnodeWithDom;\n const component = current.component as ValyrianComponent;\n const hasComponentAsOldChild = parentVnode.oldChildComponents && parentVnode.oldChildComponents.has(component);\n\n if (!hasComponentAsOldChild) {\n addCallbackToSet(callback, SetType.onCreate, parentVnode);\n }\n};\nexport const onUpdate = (callback: Function) => {\n validateIsCalledInsideComponent();\n const parentVnode = current.vnode as VnodeWithDom;\n const component = current.component as ValyrianComponent;\n const hasComponentAsChild = parentVnode.childComponents && parentVnode.childComponents.has(component);\n if (hasComponentAsChild) {\n addCallbackToSet(callback, SetType.onUpdate, current.vnode as VnodeWithDom);\n }\n};\nexport const onCleanup = (callback: Function) => {\n validateIsCalledInsideComponent();\n addCallbackToSet(callback, SetType.onCleanup, current.vnode as VnodeWithDom);\n};\nexport const onRemove = (callback: Function) => {\n validateIsCalledInsideComponent();\n\n const parentVnode = current.vnode as VnodeWithDom;\n const component = current.component as ValyrianComponent;\n let removed = false;\n\n function removeCallback() {\n const hasComponentAsChild = parentVnode.childComponents && parentVnode.childComponents.has(component);\n\n if (hasComponentAsChild || removed) {\n return;\n }\n\n removed = true;\n callback();\n }\n\n addCallbackToSet(removeCallback, SetType.onRemove, current.vnode as VnodeWithDom);\n};\nconst callSet = (set?: Set<Function> | null) => {\n if (!set) {\n return;\n }\n for (const callback of set) {\n callback();\n }\n set.clear();\n};\n\nexport const directives: Record<string, Directive> = {\n \"v-create\": (callback, childVnode, oldProps) => {\n if (!oldProps) {\n addCallbackToSet(() => callback(childVnode), SetType.onCreate, current.vnode as VnodeWithDom);\n }\n },\n\n \"v-update\": (callback, childVnode, oldProps) => {\n if (oldProps) {\n addCallbackToSet(() => callback(childVnode, oldProps), SetType.onUpdate, current.vnode as VnodeWithDom);\n }\n },\n\n \"v-remove\": (callback, childVnode) => {\n let parentVnode = current.vnode as VnodeWithDom;\n let currentChildVnode = childVnode as VnodeWithDom;\n while (parentVnode) {\n parentVnode.onremove = parentVnode.onremove || new Set();\n addCallbackToSet(\n () => {\n if (!childVnode.dom.vnode || currentChildVnode.dom.parentNode) {\n return;\n }\n callback(childVnode);\n childVnode.dom.vnode = null;\n },\n SetType.onRemove,\n parentVnode\n );\n\n if (!parentVnode.dom.parentElement) {\n break;\n }\n currentChildVnode = parentVnode;\n parentVnode = (parentVnode.dom.parentElement as DomElement).vnode as VnodeWithDom;\n }\n },\n\n \"v-cleanup\": (callback, vnode) => {\n addCallbackToSet(() => callback(vnode), SetType.onCleanup, current.vnode as VnodeWithDom);\n },\n\n \"v-if\": (value, vnode) => {\n if (!Boolean(value)) {\n const parentNode = vnode.dom?.parentNode;\n if (parentNode) {\n parentNode.replaceChild(document.createTextNode(\"\"), vnode.dom);\n }\n\n return false;\n }\n },\n\n \"v-show\": (value, vnode) => {\n const bool = Boolean(value);\n (\n vnode.dom as unknown as {\n style: { display: string };\n }\n ).style.display = bool ? \"\" : \"none\";\n },\n\n \"v-html\": (value, vnode) => {\n vnode.children = trust(value as string);\n },\n\n // The \"v-model\" directive binds the value of an input element to a model property\n \"v-model\": (model, vnode) => {\n // eslint-disable-next-line prefer-const\n if (\"name\" in vnode.props === false) {\n return;\n }\n\n let value;\n const property = vnode.props.name;\n let event = \"oninput\";\n\n // This function updates the model property when the input element's value changes\n let handler = (e: Event) => (model[property] = (e.target as DomElement & Record<string, any>).value);\n if (vnode.tag === \"input\") {\n // Depending on the type of input element, use a different handler function\n switch (vnode.props.type) {\n case \"checkbox\": {\n if (Array.isArray(model[property])) {\n // If the model property is an array, add or remove the value from the array when the checkbox is checked or unchecked\n handler = (e: Event) => {\n const val = (e.target as DomElement & Record<string, any>).value;\n const idx = model[property].indexOf(val);\n if (idx === -1) {\n model[property].push(val);\n } else {\n model[property].splice(idx, 1);\n }\n };\n // If the value is in the array, set the checkbox to be checked\n value = model[property].indexOf(vnode.dom.value) !== -1;\n } else if (\"value\" in vnode.props) {\n // If the input element has a \"value\" attribute, use it to determine the checked state\n handler = () => {\n if (model[property] === vnode.props.value) {\n model[property] = null;\n } else {\n model[property] = vnode.props.value;\n }\n };\n value = model[property] === vnode.props.value;\n } else {\n // If there is no \"value\" attribute, use a boolean value for the model property\n handler = () => (model[property] = !model[property]);\n value = model[property];\n }\n // Set the \"checked\" attribute on the input element\n // eslint-disable-next-line no-use-before-define\n setAttribute(\"checked\", value, vnode);\n break;\n }\n case \"radio\": {\n // If the element is a radio button, set the \"checked\" attribute based on the value of the model property\n // eslint-disable-next-line no-use-before-define\n setAttribute(\"checked\", model[property] === vnode.dom.value, vnode);\n break;\n }\n default: {\n // For all other input types, set the \"value\" attribute based on the value of the model property\n // eslint-disable-next-line no-use-before-define\n setAttribute(\"value\", model[property], vnode);\n }\n }\n } else if (vnode.tag === \"select\") {\n // If the element is a select element, use the \"click\" event by default\n event = \"onclick\";\n if (vnode.props.multiple) {\n // If the select element allows multiple selections, update the model property with an array of selected values\n handler = (e: Event & Record<string, any>) => {\n const val = (e.target as DomElement & Record<string, any>).value;\n if (e.ctrlKey) {\n // If the Ctrl key is pressed, add or remove the value from the array\n const idx = model[property].indexOf(val);\n if (idx === -1) {\n model[property].push(val);\n } else {\n model[property].splice(idx, 1);\n }\n } else {\n // If the Ctrl key is not pressed, set the model property to an array with the selected value\n model[property].splice(0, model[property].length);\n model[property].push(val);\n }\n };\n // Set the \"selected\" attribute on the options based on whether they are in the model property array\n vnode.children.forEach((child: VnodeWithDom) => {\n if (child.tag === \"option\") {\n const value = \"value\" in child.props ? child.props.value : child.children.join(\"\").trim();\n child.props.selected = model[property].indexOf(value) !== -1;\n }\n });\n } else {\n // If the select element does not allow multiple selections, set the \"selected\" attribute on the options based on the value of the model property\n vnode.children.forEach((child: VnodeWithDom) => {\n if (child.tag === \"option\") {\n const value = \"value\" in child.props ? child.props.value : child.children.join(\"\").trim();\n child.props.selected = value === model[property];\n }\n });\n }\n } else if (vnode.tag === \"textarea\") {\n // Set the textarea's content to the value of the model property\n vnode.children = [model[property]];\n }\n\n // We assume that the prev handler if any will not be changed by the user across patchs\n const prevHandler = vnode.props[event];\n\n // Set the event handler on the element\n // eslint-disable-next-line no-use-before-define\n setAttribute(\n event,\n (e: Event) => {\n handler(e);\n\n // If the previous handler is defined, call it after the model has been updated\n if (prevHandler) {\n prevHandler(e);\n }\n },\n vnode\n );\n },\n\n \"v-class\": (value, vnode) => {\n if (typeof value === \"string\") {\n vnode.dom.className = value;\n } else if (Array.isArray(value)) {\n vnode.dom.className = value.join(\" \");\n } else if (typeof value === \"object\") {\n const classList = vnode.dom.classList;\n for (const name in value) {\n const val = typeof value[name] === \"function\" ? (value[name] as Function)() : value[name];\n classList.toggle(name, val);\n }\n }\n },\n\n // Frequent used properties\n class(value, vnode) {\n if (vnode.dom.className !== value) {\n if (vnode.isSVG) {\n vnode.dom.setAttribute(\"class\", value);\n return;\n }\n vnode.dom.className = value;\n }\n },\n\n className(value, vnode) {\n directives.class(value, vnode);\n },\n\n id: (value, vnode) => {\n if (vnode.dom.id !== value) {\n if (vnode.isSVG) {\n vnode.dom.setAttribute(\"id\", value);\n return;\n }\n vnode.dom.id = value;\n }\n },\n\n style: (value, vnode) => {\n if (typeof value === \"string\") {\n if (vnode.isSVG) {\n vnode.dom.setAttribute(\"style\", value);\n return;\n }\n vnode.dom.style = value;\n } else if (typeof value === \"object\") {\n if (vnode.isSVG) {\n vnode.dom.setAttribute(\"style\", \"\");\n } else {\n vnode.dom.style = \"\";\n }\n const domStyle = vnode.dom.style;\n for (const name in value) {\n domStyle[name] = value[name];\n }\n }\n }\n};\n\nexport function directive(name: string, directive: Directive) {\n const directiveName = `v-${name}`;\n directives[directiveName] = directive;\n reservedProps.add(directiveName);\n}\n\nexport function setPropNameReserved(name: string) {\n reservedProps.add(name);\n}\n\nconst eventListenerNames = new Set<string>();\n\nfunction eventListener(e: Event) {\n current.event = e;\n let dom = e.target as DomElement;\n const name = `on${e.type}`;\n\n while (dom) {\n const oldVnode = dom.vnode as VnodeWithDom;\n if (oldVnode && oldVnode.props[name]) {\n oldVnode.props[name](e, oldVnode);\n\n if (!e.defaultPrevented) {\n // eslint-disable-next-line no-use-before-define\n update();\n }\n return;\n }\n dom = dom.parentNode as DomElement;\n }\n\n current.event = null;\n}\n\nfunction sharedSetAttribute(name: string, value: any, newVnode: VnodeWithDom): void | boolean {\n const newVnodeDom = newVnode.dom;\n if (typeof value === \"function\") {\n if (!eventListenerNames.has(name)) {\n // We attach the delegated event listener to the main vnode dom element, which is the root of the component\n (mainVnode as VnodeWithDom).dom.addEventListener(name.slice(2), eventListener);\n eventListenerNames.add(name);\n }\n return;\n }\n\n if (!newVnode.isSVG && name in newVnodeDom) {\n newVnodeDom[name] = value;\n return;\n }\n\n if (value === false) {\n newVnodeDom.removeAttribute(name);\n } else {\n newVnodeDom.setAttribute(name, value);\n }\n}\n\nexport function setAttribute(name: string, value: any, newVnode: VnodeWithDom): void {\n if (!reservedProps.has(name)) {\n newVnode.props[name] = value;\n sharedSetAttribute(name, value, newVnode);\n }\n}\n\nexport function updateAttributes(newVnode: VnodeWithDom, oldVnode?: VnodeWithDom): void {\n const vnodeDom = newVnode.dom;\n const vnodeProps = newVnode.props;\n vnodeDom.vnode = newVnode;\n\n if (oldVnode) {\n for (const name in oldVnode.props) {\n if (name in vnodeProps === false && !eventListenerNames.has(name) && !reservedProps.has(name)) {\n if (!newVnode.isSVG && name in vnodeDom) {\n vnodeDom[name] = null;\n } else {\n vnodeDom.removeAttribute(name);\n }\n }\n }\n }\n\n for (const name in vnodeProps) {\n if (directives[name]) {\n if (directives[name](vnodeProps[name], newVnode, oldVnode?.props) === false) {\n break;\n }\n continue;\n }\n\n if (!reservedProps.has(name)) {\n sharedSetAttribute(name, vnodeProps[name], newVnode);\n }\n }\n}\n\nexport function createElement(tag: string, isSVG: boolean): DomElement {\n return isSVG\n ? document.createElementNS(\"http://www.w3.org/2000/svg\", tag)\n : (document.createElement(tag) as DomElement);\n}\n\nfunction flatTree(newVnode: VnodeWithDom) {\n let i = 0;\n let children: Children;\n\n if (\"v-for\" in newVnode.props === false) {\n children = [...newVnode.children];\n } else {\n children = [];\n const set = newVnode.props[\"v-for\"];\n const l = set.length;\n const callback = newVnode.children[0];\n\n if (typeof callback !== \"function\") {\n console.warn(\"v-for directive must have a callback function as children\");\n return children;\n }\n\n for (let i = 0; i < l; i++) {\n children[i] = callback(set[i], i);\n }\n }\n\n newVnode.oldChildComponents = newVnode.childComponents;\n if (newVnode.childComponents) {\n newVnode.childComponents = new Set();\n }\n\n while (i < children.length) {\n const newChild = children[i];\n\n if (newChild == null) {\n children.splice(i, 1);\n continue;\n }\n\n if (Array.isArray(newChild)) {\n children.splice(i, 1, ...newChild);\n continue;\n }\n\n if (newChild instanceof Vnode) {\n newChild.props = newChild.props || {};\n newChild.isSVG = newVnode.isSVG || newChild.tag === \"svg\";\n\n if (typeof newChild.tag !== \"string\") {\n const component = (current.component = newChild.tag);\n newVnode.childComponents = newVnode.childComponents || new Set();\n newVnode.childComponents.add(component);\n\n children[i] = (isPOJOComponent(component) ? component.view : component).bind(component)(\n newChild.props,\n newChild.children\n );\n\n continue;\n }\n\n newVnode.hasKeys = newVnode.hasKeys || \"key\" in newChild.props;\n }\n\n i++;\n }\n\n return children;\n}\n\nfunction processNewChild(newChild: VnodeWithDom, parentVnode: VnodeWithDom, oldDom?: DomElement) {\n if (oldDom) {\n newChild.dom = createElement(newChild.tag, newChild.isSVG as boolean);\n parentVnode.dom.replaceChild(newChild.dom, oldDom);\n } else {\n newChild.dom = parentVnode.dom.appendChild(createElement(newChild.tag, newChild.isSVG as boolean));\n }\n updateAttributes(newChild);\n if (\"v-text\" in newChild.props) {\n newChild.dom.textContent = newChild.props[\"v-text\"];\n return;\n }\n\n current.oldVnode = null;\n current.vnode = newChild;\n\n const children = flatTree(newChild);\n if (children.length === 0) {\n newChild.dom.textContent = \"\";\n return;\n }\n\n for (let i = 0, l = children.length; i < l; i++) {\n if (children[i] instanceof Vnode === false) {\n newChild.dom.appendChild(document.createTextNode(children[i]));\n continue;\n }\n processNewChild(children[i] as VnodeWithDom, newChild);\n }\n}\n\n// eslint-disable-next-line complexity\nfunction patch(newVnode: VnodeWithDom, oldVnode: VnodeWithDom | null): void {\n current.oldVnode = oldVnode;\n current.vnode = newVnode;\n const children = flatTree(newVnode);\n const dom = newVnode.dom;\n\n if (children.length === 0) {\n if (dom.childNodes.length) {\n dom.textContent = \"\";\n }\n // There are no children so we don't need to call the oncreate and onupdate callbacks\n return;\n }\n\n const childNodes = dom.childNodes as unknown as DomElement[];\n const oldChildrenLength = childNodes.length;\n const childrenLength = children.length;\n if (oldChildrenLength === 0) {\n for (let i = 0; i < childrenLength; i++) {\n const newChild = children[i] as VnodeWithDom;\n if (newChild instanceof Vnode === false) {\n dom.appendChild(document.createTextNode(newChild));\n continue;\n }\n processNewChild(newChild, newVnode);\n }\n // The oncreate callback must be called after the children are created\n newVnode.oncreate && callSet(newVnode.oncreate);\n return;\n }\n\n let oldTree = childNodes as unknown as DomElement[];\n const oldKeyedList: Record<string, number> = {};\n\n if (newVnode.hasKeys) {\n const newOldTree = [];\n for (let i = 0, l = oldTree.length; i < l; i++) {\n newOldTree[i] = oldTree[i];\n const oldVnode = oldTree[i].vnode as VnodeWithDom;\n oldKeyedList[!oldVnode || \"key\" in oldVnode.props === false ? i : (oldVnode.props.key as string)] = i;\n }\n oldTree = newOldTree;\n }\n\n for (let i = 0, l = children.length; i < l; i++) {\n const newChild = children[i] as VnodeWithDom;\n\n if (newChild instanceof Vnode === false) {\n const oldChild = oldTree[i];\n if (!oldChild) {\n dom.appendChild(document.createTextNode(newChild));\n continue;\n }\n\n if (oldChild.nodeType !== 3) {\n dom.replaceChild(document.createTextNode(newChild), oldChild);\n continue;\n }\n\n // eslint-disable-next-line eqeqeq\n if (oldChild.nodeValue != newChild) {\n oldChild.nodeValue = newChild;\n }\n continue;\n }\n\n const oldChild = oldTree[newVnode.hasKeys ? oldKeyedList[(newChild.props.key as any) || i] : i] as DomElement;\n\n if (!oldChild || newChild.tag !== oldChild.nodeName.toLowerCase()) {\n processNewChild(newChild, newVnode, childNodes[i] as DomElement);\n continue;\n }\n\n newChild.dom = oldChild;\n const currentChild = childNodes[i];\n const oldChildVnode = oldChild.vnode as VnodeWithDom;\n if (!currentChild) {\n dom.appendChild(oldChild);\n } else if (currentChild !== oldChild) {\n dom.replaceChild(oldChild, currentChild);\n }\n\n if (\"v-keep\" in newChild.props && oldChildVnode) {\n if (oldChildVnode.props[\"v-keep\"] === newChild.props[\"v-keep\"]) {\n continue;\n }\n\n const oldProps = childNodes[i + 1]?.vnode?.props;\n if (oldProps && \"key\" in oldProps === false && oldProps[\"v-keep\"] === newChild.props[\"v-keep\"]) {\n oldChild.remove();\n oldTree.splice(i, 1);\n continue;\n }\n }\n\n updateAttributes(newChild as VnodeWithDom, oldChildVnode);\n\n if (\"v-text\" in newChild.props) {\n // eslint-disable-next-line eqeqeq\n if (oldChild.textContent != newChild.props[\"v-text\"]) {\n oldChild.textContent = newChild.props[\"v-text\"];\n }\n continue;\n }\n\n // Call the cleanup for the old child vnode before the patch\n callSet(oldChildVnode?.oncleanup);\n // eslint-disable-next-line no-use-before-define\n patch(newChild as VnodeWithDom, oldChildVnode || null);\n // Call the remove for the old child vnode after the patch\n callSet(oldChildVnode?.onremove);\n }\n\n for (let i = childNodes.length, l = children.length; i > l; i--) {\n childNodes[i - 1].remove();\n }\n\n // In here we could have new children or/and patched children\n // So we need to call the oncreate and onupdate callbacks\n callSet(newVnode.oncreate);\n callSet(newVnode.onupdate);\n}\n\nexport function updateVnode(vnode: VnodeWithDom, shouldCleanup = true): string | void {\n vnode.props = vnode.props || {};\n if (shouldCleanup) {\n // The clean up must be from the old vnode\n // and in here the vnode is the old one\n // so, we need to call the cleanup before the patch\n // inside the patch the clean up will be called only for the old children\n callSet(vnode.oncleanup);\n }\n // Clone the old on remove set to call it after the patch\n const oldOnRemoveSet = vnode.onremove ? new Set(vnode.onremove) : null;\n current.vnode = vnode;\n patch(vnode, shouldCleanup ? vnode : null);\n // Call the old on remove set\n callSet(oldOnRemoveSet);\n isMounted = true;\n current.oldVnode = null;\n current.vnode = null;\n current.component = null;\n}\n\nexport function update(): string {\n if (mainVnode) {\n mainVnode.children = [mainComponent];\n // If the updateVnode method is called from outside the main lib (e.g. from a directive)\n // it always be considered as mounted, so the cleanup will be called before the patch\n // But in here, we need to pass the shouldCleanup as false if the app is not mounted\n updateVnode(mainVnode as VnodeWithDom, isMounted);\n if (isNodeJs) {\n return mainVnode.dom.innerHTML;\n }\n }\n return \"\";\n}\n\nlet debouncedUpdateTimeout: any;\nconst debouncedUpdateMethod = isNodeJs ? update : () => requestAnimationFrame(update);\n\nexport function debouncedUpdate(timeout = 42) {\n if (current.event) {\n current.event.preventDefault();\n }\n clearTimeout(debouncedUpdateTimeout);\n debouncedUpdateTimeout = setTimeout(debouncedUpdateMethod, timeout);\n}\n\nexport function unmount() {\n if (mainVnode) {\n mainComponent = v(() => null, {}) as VnodeComponentInterface;\n const result = update();\n for (const name in eventListenerNames) {\n mainVnode.dom.removeEventListener(name.slice(2).toLowerCase(), eventListener);\n Reflect.deleteProperty(eventListenerNames, name);\n }\n\n callSet(mainVnode.onremove);\n\n mainComponent = null;\n mainVnode = null;\n isMounted = false;\n current.vnode = null;\n current.component = null;\n current.event = null;\n return result;\n }\n\n return \"\";\n}\n\nexport function mount(dom: string | DomElement, component: ValyrianComponent | VnodeComponentInterface | any) {\n const container =\n typeof dom === \"string\" ? (isNodeJs ? createElement(dom, dom === \"svg\") : document.querySelector(dom)) : dom;\n\n if (isComponent(component)) {\n mainComponent = v(component, {}, []) as VnodeComponentInterface;\n } else if (isVnodeComponent(component)) {\n mainComponent = component;\n } else {\n mainComponent = v(() => component, {}, []) as VnodeComponentInterface;\n }\n\n mainVnode = hidrateDomToVnode(container) as VnodeWithDom;\n return update();\n}\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAwCO,IAAM,WAAW,QAAQ,OAAO,YAAY,eAAe,QAAQ,YAAY,QAAQ,SAAS,IAAI;AAEpG,IAAM,QAAN,MAAY;AAAA,EACjB,YACS,KACA,OACA,UACA,KACA,OACA,oBACA,iBACA,SACA,UACA,WACA,UACA,UACP;AAZO;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAAA,EACN;AACL;AAQO,IAAM,kBAAkB,CAAC,cAC9B,QAAQ,aAAa,OAAO,cAAc,YAAY,UAAU,SAAS;AAEpE,IAAM,cAAc,CAAC,cAC1B,QAAQ,OAAO,cAAc,cAAc,gBAAgB,SAAS,CAAC;AAChE,IAAM,UAAU,CAAC,WAAsC,kBAAkB;AAEzE,IAAM,mBAAmB,CAAC,WAAwD;AACvF,SAAO,QAAQ,MAAM,KAAK,YAAY,OAAO,GAAG;AAClD;AAEO,SAAS,EAAE,gBAA4C,UAA6B,UAAoB;AAC7G,SAAO,IAAI,MAAM,gBAAgB,OAAO,QAAQ;AAClD;AAEA,EAAE,WAAW,CAAC,MAAkB,aAAu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,WAAW,CAAC,GAAG,CAAC,CAAC;AAAA,EACrC,WAAW,iBAAiB,SAAS,GAAG;AACtC,oBAAgB;AAAA,EAClB,OAAO;AACL,oBAAgB,EAAE,MAAM,WAAW,CAAC,GAAG,CAAC,CAAC;AAAA,EAC3C;AAEA,cAAY,kBAAkB,SAAS;AACvC,SAAO,OAAO;AAChB;",
|
|
6
|
-
"names": ["value", "directive", "
|
|
4
|
+
"sourcesContent": ["/* eslint-disable */\ndeclare global {\n var document: Document;\n namespace JSX {\n interface IntrinsicElements extends DefaultRecord {}\n type Element = ReturnType<\n typeof v | ((...args: any) => string | number | null | undefined | boolean | Promise<any>)\n >;\n type ComponentReturnType = string | number | null | undefined | boolean | Element | Element[];\n }\n}\n\ninterface DefaultRecord extends Record<string | number | symbol, any> {}\n\nexport interface Properties extends DefaultRecord {\n key?: string | number;\n}\n\nexport interface DomElement extends Element, DefaultRecord {}\n\nexport interface Component extends DefaultRecord {\n (props: Properties, children: any[]): Vnode | any;\n}\n\nexport interface POJOComponent extends DefaultRecord {\n view: Component;\n}\n\nexport type ValyrianComponent = Component | POJOComponent;\n\nexport interface VnodeComponentInterface extends Vnode {\n tag: ValyrianComponent;\n}\n\nexport interface Children extends Array<Vnode | VnodeComponentInterface | ValyrianComponent | any> {}\n\nexport interface Directive {\n (value: any, vnode: VnodeWithDom, oldProps?: Properties): false | void | any;\n}\n\nexport const isNodeJs = Boolean(typeof process !== \"undefined\" && process.versions && process.versions.node);\n\nexport class Vnode {\n constructor(\n public tag: string | Component | POJOComponent,\n public props: null | Properties,\n public children: Children,\n public dom?: DomElement,\n public isSVG?: boolean,\n public oldChildComponents?: Set<ValyrianComponent>,\n public childComponents?: Set<ValyrianComponent>,\n public hasKeys?: boolean,\n public oncreate?: Set<Function>,\n public oncleanup?: Set<Function>,\n public onupdate?: Set<Function>,\n public onremove?: Set<Function>\n ) {}\n}\n\nexport interface VnodeWithDom extends Vnode {\n tag: string;\n dom: DomElement;\n props: Properties;\n}\n\nexport const isPOJOComponent = (component: unknown): component is POJOComponent =>\n Boolean(component && typeof component === \"object\" && \"view\" in component);\n\nexport const isComponent = (component: unknown): component is Component =>\n Boolean(typeof component === \"function\" || isPOJOComponent(component));\nexport const isVnode = (object?: unknown): object is Vnode => object instanceof Vnode;\n\nexport const isVnodeComponent = (object?: unknown): object is VnodeComponentInterface => {\n return isVnode(object) && isComponent(object.tag);\n};\n\nexport function v(tagOrComponent: string | ValyrianComponent, props: Properties | null, ...children: Children) {\n return new Vnode(tagOrComponent, props, children);\n}\n\nv.fragment = (_: Properties, ...children: Children) => children;\n\nexport function hidrateDomToVnode(dom: any): VnodeWithDom | string | null | void {\n if (dom.nodeType === 3) {\n return dom.nodeValue;\n }\n\n if (dom.nodeType === 1) {\n const tag = dom.nodeName.toLowerCase();\n const props = {} as Properties;\n const children = [] as Children;\n\n for (let i = 0, l = dom.childNodes.length; i < l; i++) {\n const childDom = dom.childNodes[i];\n if (childDom.nodeType === 3) {\n children.push(childDom.nodeValue);\n } else if (childDom.nodeType === 1) {\n const childVnode = hidrateDomToVnode(childDom);\n children.push(childVnode);\n }\n }\n\n const attributes = dom.attributes;\n for (let i = 0, l = attributes.length; i < l; i++) {\n const attr = attributes[i];\n props[attr.nodeName] = attr.nodeValue;\n }\n\n const vnode = new Vnode(tag, props, children);\n vnode.dom = dom;\n dom.vnode = vnode;\n vnode.isSVG = tag === \"svg\";\n return vnode as VnodeWithDom;\n }\n}\n\nexport function trust(htmlString: string) {\n const div = document.createElement(\"div\");\n div.innerHTML = htmlString.trim();\n return Array.from(div.childNodes).map(hidrateDomToVnode);\n}\n\nlet mainComponent: VnodeComponentInterface | null = null;\nlet mainVnode: VnodeWithDom | null = null;\nlet isMounted = false;\n\nexport const current = {\n oldVnode: null as Vnode | null,\n vnode: null as Vnode | null,\n component: null as ValyrianComponent | null,\n event: null as Event | null\n};\n\nexport const reservedProps = new Set<string>([\n \"key\",\n \"state\",\n \"v-keep\",\n \"v-text\",\n \"v-if\",\n \"v-for\",\n \"v-show\",\n \"v-class\",\n \"v-html\",\n \"v-model\",\n \"v-create\",\n \"v-update\",\n \"v-cleanup\",\n \"v-remove\"\n]);\n\nenum SetType {\n onCreate = \"oncreate\",\n onUpdate = \"onupdate\",\n onCleanup = \"oncleanup\",\n onRemove = \"onremove\"\n}\n\nconst SUBTREE_LC = Symbol.for(\"valyrian.subtreeLifecycle\");\n\nfunction markSubtreeLifecycle(dom: DomElement) {\n let node: any = dom;\n while (node && node.nodeType === 1 && !node[SUBTREE_LC]) {\n node[SUBTREE_LC] = true;\n node = node.parentElement;\n }\n}\n\nfunction addCallbackToSet(callback: Function, setType: SetType, vnode: VnodeWithDom) {\n vnode[setType] = vnode[setType] || new Set();\n\n if (vnode.dom) {\n markSubtreeLifecycle(vnode.dom);\n }\n\n vnode[setType].add(() => {\n const cleanup = callback();\n if (typeof cleanup === \"function\") {\n vnode[SetType.onCleanup] = vnode[SetType.onCleanup] || new Set();\n vnode[SetType.onCleanup].add(cleanup);\n\n if (vnode.dom) {\n markSubtreeLifecycle(vnode.dom);\n }\n }\n });\n}\n\nfunction validateIsCalledInsideComponent() {\n if (!current.vnode) {\n throw new Error(\"This function must be called inside a component\");\n }\n}\n\nexport const onCreate = (callback: Function) => {\n validateIsCalledInsideComponent();\n const parentVnode = current.vnode as VnodeWithDom;\n const component = current.component as ValyrianComponent;\n const hasComponentAsOldChild = parentVnode.oldChildComponents && parentVnode.oldChildComponents.has(component);\n\n if (!hasComponentAsOldChild) {\n addCallbackToSet(callback, SetType.onCreate, parentVnode);\n }\n};\nexport const onUpdate = (callback: Function) => {\n validateIsCalledInsideComponent();\n const parentVnode = current.vnode as VnodeWithDom;\n const component = current.component as ValyrianComponent;\n const hasComponentAsChild = parentVnode.childComponents && parentVnode.childComponents.has(component);\n if (hasComponentAsChild) {\n addCallbackToSet(callback, SetType.onUpdate, current.vnode as VnodeWithDom);\n }\n};\nexport const onCleanup = (callback: Function) => {\n validateIsCalledInsideComponent();\n addCallbackToSet(callback, SetType.onCleanup, current.vnode as VnodeWithDom);\n};\nexport const onRemove = (callback: Function) => {\n validateIsCalledInsideComponent();\n\n const parentVnode = current.vnode as VnodeWithDom;\n const component = current.component as ValyrianComponent;\n let removed = false;\n\n function removeCallback() {\n const hasComponentAsChild = parentVnode.childComponents && parentVnode.childComponents.has(component);\n\n if (hasComponentAsChild || removed) {\n return;\n }\n\n removed = true;\n callback();\n }\n\n addCallbackToSet(removeCallback, SetType.onRemove, current.vnode as VnodeWithDom);\n};\nconst callSet = (set?: Set<Function> | null) => {\n if (!set) {\n return;\n }\n for (const callback of set) {\n callback();\n }\n set.clear();\n};\n\nfunction collectVnodesPostOrder(dom: DomElement, out: VnodeWithDom[]) {\n const childNodes = dom.childNodes as unknown as DomElement[];\n for (let i = 0; i < childNodes.length; i++) {\n const child = childNodes[i];\n if (!child || child.nodeType !== 1) {\n continue;\n }\n collectVnodesPostOrder(child, out);\n }\n const vnode = dom.vnode as VnodeWithDom;\n if (vnode) {\n out.push(vnode);\n }\n}\n\nfunction strictCleanupBeforeRemove(dom: DomElement) {\n const vnodes: VnodeWithDom[] = [];\n collectVnodesPostOrder(dom, vnodes);\n for (let i = 0; i < vnodes.length; i++) {\n callSet(vnodes[i].oncleanup);\n }\n}\n\nfunction strictOnRemoveAfterDetach(dom: DomElement) {\n const vnodes: VnodeWithDom[] = [];\n collectVnodesPostOrder(dom, vnodes);\n for (let i = 0; i < vnodes.length; i++) {\n callSet(vnodes[i].onremove);\n }\n}\n\nfunction strictRemoveNode(dom: DomElement) {\n if (!dom || dom.nodeType !== 1) {\n return;\n }\n\n if (!(dom as any)[SUBTREE_LC]) {\n dom.remove();\n return;\n }\n\n // before detach\n strictCleanupBeforeRemove(dom);\n // detach\n dom.remove();\n // after detach\n strictOnRemoveAfterDetach(dom);\n}\n\nfunction strictReplaceChild(parent: DomElement, newNode: Node, oldNode: DomElement) {\n if (oldNode && oldNode.nodeType === 1 && (oldNode as any)[SUBTREE_LC]) {\n strictCleanupBeforeRemove(oldNode);\n }\n parent.replaceChild(newNode, oldNode);\n if (oldNode && oldNode.nodeType === 1 && (oldNode as any)[SUBTREE_LC]) {\n strictOnRemoveAfterDetach(oldNode);\n }\n}\n\nexport const directives: Record<string, Directive> = {\n \"v-create\": (callback, vnode, oldProps) => {\n if (oldProps) {\n return;\n }\n\n addCallbackToSet(() => callback(vnode), SetType.onCreate, vnode);\n },\n\n \"v-update\": (callback, vnode, oldProps) => {\n if (!oldProps) {\n return;\n }\n addCallbackToSet(() => callback(vnode, oldProps), SetType.onUpdate, vnode);\n },\n\n \"v-cleanup\": (callback, vnode) => {\n vnode.oncleanup = vnode.oncleanup || new Set();\n vnode.oncleanup.add(() => callback(vnode));\n markSubtreeLifecycle(vnode.dom);\n },\n\n \"v-remove\": (callback, vnode) => {\n vnode.onremove = vnode.onremove || new Set();\n vnode.onremove.add(() => callback(vnode));\n markSubtreeLifecycle(vnode.dom);\n },\n\n \"v-show\": (value, vnode) => {\n const bool = Boolean(value);\n (\n vnode.dom as unknown as {\n style: { display: string };\n }\n ).style.display = bool ? \"\" : \"none\";\n },\n\n \"v-html\": (value, vnode) => {\n vnode.children = trust(value as string);\n },\n\n // The \"v-model\" directive binds the value of an input element to a model property\n \"v-model\": (model, vnode) => {\n // eslint-disable-next-line prefer-const\n if (\"name\" in vnode.props === false) {\n return;\n }\n\n let value;\n const property = vnode.props.name;\n let event = \"oninput\";\n\n // This function updates the model property when the input element's value changes\n let handler = (e: Event) => (model[property] = (e.target as DomElement & Record<string, any>).value);\n if (vnode.tag === \"input\") {\n // Depending on the type of input element, use a different handler function\n switch (vnode.props.type) {\n case \"checkbox\": {\n if (Array.isArray(model[property])) {\n // If the model property is an array, add or remove the value from the array when the checkbox is checked or unchecked\n handler = (e: Event) => {\n const val = (e.target as DomElement & Record<string, any>).value;\n const idx = model[property].indexOf(val);\n if (idx === -1) {\n model[property].push(val);\n } else {\n model[property].splice(idx, 1);\n }\n };\n // If the value is in the array, set the checkbox to be checked\n value = model[property].indexOf(vnode.dom.value) !== -1;\n } else if (\"value\" in vnode.props) {\n // If the input element has a \"value\" attribute, use it to determine the checked state\n handler = () => {\n if (model[property] === vnode.props.value) {\n model[property] = null;\n } else {\n model[property] = vnode.props.value;\n }\n };\n value = model[property] === vnode.props.value;\n } else {\n // If there is no \"value\" attribute, use a boolean value for the model property\n handler = () => (model[property] = !model[property]);\n value = model[property];\n }\n // Set the \"checked\" attribute on the input element\n // eslint-disable-next-line no-use-before-define\n setAttribute(\"checked\", value, vnode);\n break;\n }\n case \"radio\": {\n // If the element is a radio button, set the \"checked\" attribute based on the value of the model property\n // eslint-disable-next-line no-use-before-define\n setAttribute(\"checked\", model[property] === vnode.dom.value, vnode);\n break;\n }\n default: {\n // For all other input types, set the \"value\" attribute based on the value of the model property\n // eslint-disable-next-line no-use-before-define\n setAttribute(\"value\", model[property], vnode);\n }\n }\n } else if (vnode.tag === \"select\") {\n // If the element is a select element, use the \"click\" event by default\n event = \"onclick\";\n if (vnode.props.multiple) {\n // If the select element allows multiple selections, update the model property with an array of selected values\n handler = (e: Event & Record<string, any>) => {\n const val = (e.target as DomElement & Record<string, any>).value;\n if (e.ctrlKey) {\n // If the Ctrl key is pressed, add or remove the value from the array\n const idx = model[property].indexOf(val);\n if (idx === -1) {\n model[property].push(val);\n } else {\n model[property].splice(idx, 1);\n }\n } else {\n // If the Ctrl key is not pressed, set the model property to an array with the selected value\n model[property].splice(0, model[property].length);\n model[property].push(val);\n }\n };\n // Set the \"selected\" attribute on the options based on whether they are in the model property array\n vnode.children.forEach((child: VnodeWithDom) => {\n if (child.tag === \"option\") {\n const value = \"value\" in child.props ? child.props.value : child.children.join(\"\").trim();\n child.props.selected = model[property].indexOf(value) !== -1;\n }\n });\n } else {\n // If the select element does not allow multiple selections, set the \"selected\" attribute on the options based on the value of the model property\n vnode.children.forEach((child: VnodeWithDom) => {\n if (child.tag === \"option\") {\n const value = \"value\" in child.props ? child.props.value : child.children.join(\"\").trim();\n child.props.selected = value === model[property];\n }\n });\n }\n } else if (vnode.tag === \"textarea\") {\n // Set the textarea's content to the value of the model property\n vnode.children = [model[property]];\n }\n\n // We assume that the prev handler if any will not be changed by the user across patchs\n const prevHandler = vnode.props[event];\n\n // Set the event handler on the element\n // eslint-disable-next-line no-use-before-define\n setAttribute(\n event,\n (e: Event) => {\n handler(e);\n\n // If the previous handler is defined, call it after the model has been updated\n if (prevHandler) {\n prevHandler(e);\n }\n },\n vnode\n );\n },\n\n \"v-class\": (value, vnode) => {\n if (typeof value === \"string\") {\n vnode.dom.className = value;\n } else if (Array.isArray(value)) {\n vnode.dom.className = value.join(\" \");\n } else if (typeof value === \"object\") {\n const classList = vnode.dom.classList;\n for (const name in value) {\n const val = typeof value[name] === \"function\" ? (value[name] as Function)() : value[name];\n classList.toggle(name, val);\n }\n }\n },\n\n // Frequent used properties\n class(value, vnode) {\n if (vnode.dom.className !== value) {\n if (vnode.isSVG) {\n vnode.dom.setAttribute(\"class\", value);\n return;\n }\n vnode.dom.className = value;\n }\n },\n\n className(value, vnode) {\n directives.class(value, vnode);\n },\n\n id: (value, vnode) => {\n if (vnode.dom.id !== value) {\n if (vnode.isSVG) {\n vnode.dom.setAttribute(\"id\", value);\n return;\n }\n vnode.dom.id = value;\n }\n },\n\n style: (value, vnode) => {\n if (typeof value === \"string\") {\n if (vnode.isSVG) {\n vnode.dom.setAttribute(\"style\", value);\n return;\n }\n vnode.dom.style = value;\n } else if (typeof value === \"object\") {\n if (vnode.isSVG) {\n vnode.dom.setAttribute(\"style\", \"\");\n } else {\n vnode.dom.style = \"\";\n }\n const domStyle = vnode.dom.style;\n for (const name in value) {\n domStyle[name] = value[name];\n }\n }\n }\n};\n\nexport function directive(name: string, directive: Directive) {\n const directiveName = `v-${name}`;\n directives[directiveName] = directive;\n reservedProps.add(directiveName);\n}\n\nexport function setPropNameReserved(name: string) {\n reservedProps.add(name);\n}\n\nconst eventListenerNames = new Set<string>();\n\nfunction eventListener(e: Event) {\n current.event = e;\n let dom = e.target as DomElement;\n const name = `on${e.type}`;\n\n while (dom) {\n const oldVnode = dom.vnode as VnodeWithDom;\n if (oldVnode && oldVnode.props[name]) {\n try {\n oldVnode.props[name](e, oldVnode);\n } finally {\n current.event = null;\n }\n\n if (!e.defaultPrevented) {\n // eslint-disable-next-line no-use-before-define\n update();\n }\n return;\n }\n dom = dom.parentNode as DomElement;\n }\n\n current.event = null;\n}\n\nfunction sharedSetAttribute(name: string, value: any, newVnode: VnodeWithDom): void | boolean {\n const newVnodeDom = newVnode.dom;\n if (typeof value === \"function\") {\n if (!eventListenerNames.has(name)) {\n // We attach the delegated event listener to the main vnode dom element, which is the root of the component\n (mainVnode as VnodeWithDom).dom.addEventListener(name.slice(2), eventListener);\n eventListenerNames.add(name);\n }\n return;\n }\n\n if (!newVnode.isSVG && name in newVnodeDom) {\n newVnodeDom[name] = value;\n return;\n }\n\n if (value === false) {\n newVnodeDom.removeAttribute(name);\n } else {\n newVnodeDom.setAttribute(name, value);\n }\n}\n\nexport function setAttribute(name: string, value: any, newVnode: VnodeWithDom): void {\n if (!reservedProps.has(name)) {\n newVnode.props[name] = value;\n sharedSetAttribute(name, value, newVnode);\n }\n}\n\nexport function updateAttributes(newVnode: VnodeWithDom, oldVnode?: VnodeWithDom): void {\n const vnodeDom = newVnode.dom;\n const vnodeProps = newVnode.props;\n vnodeDom.vnode = newVnode;\n\n if (oldVnode) {\n for (const name in oldVnode.props) {\n if (name in vnodeProps === false && !eventListenerNames.has(name) && !reservedProps.has(name)) {\n if (!newVnode.isSVG && name in vnodeDom) {\n vnodeDom[name] = null;\n } else {\n vnodeDom.removeAttribute(name);\n }\n }\n }\n }\n\n for (const name in vnodeProps) {\n if (directives[name]) {\n if (directives[name](vnodeProps[name], newVnode, oldVnode?.props) === false) {\n break;\n }\n continue;\n }\n\n if (!reservedProps.has(name)) {\n sharedSetAttribute(name, vnodeProps[name], newVnode);\n }\n }\n}\n\nexport function createElement(tag: string, isSVG: boolean): DomElement {\n return isSVG\n ? document.createElementNS(\"http://www.w3.org/2000/svg\", tag)\n : (document.createElement(tag) as DomElement);\n}\n\nfunction flatTree(newVnode: VnodeWithDom) {\n let children: Children = [];\n const newChildren = newVnode.children;\n newVnode.hasKeys = false;\n\n if (\"v-for\" in newVnode.props === false) {\n for (let l = newChildren.length - 1; l >= 0; l--) {\n children.push(newChildren[l]);\n }\n } else {\n children = [];\n const set = newVnode.props[\"v-for\"];\n const callback = newVnode.children[0];\n\n if (typeof callback !== \"function\") {\n console.warn(\"v-for directive must have a callback function as children\");\n return children;\n }\n\n // This is done to preserve the correct call order of the children\n const tmp: any[] = [];\n for (let i = 0; i < set.length; i++) {\n tmp.push(callback(set[i], i));\n }\n for (let i = tmp.length - 1; i >= 0; i--) {\n children.push(tmp[i]);\n }\n }\n\n newVnode.oldChildComponents = newVnode.childComponents;\n if (newVnode.childComponents) {\n newVnode.childComponents = new Set();\n }\n\n const out: Children = [];\n\n while (children.length) {\n const newChild = children.pop();\n\n if (newChild == null) {\n continue;\n }\n\n if (Array.isArray(newChild)) {\n for (let l = newChild.length - 1; l >= 0; l--) {\n children.push(newChild[l]);\n }\n continue;\n }\n\n if (newChild instanceof Vnode) {\n newChild.props = newChild.props || {};\n\n if (\"v-if\" in newChild.props && !Boolean(newChild.props[\"v-if\"])) {\n continue;\n }\n\n newChild.isSVG = newVnode.isSVG || newChild.tag === \"svg\";\n\n if (typeof newChild.tag !== \"string\") {\n const component = (current.component = newChild.tag);\n newVnode.childComponents = newVnode.childComponents || new Set();\n newVnode.childComponents.add(component);\n\n children.push(\n (isPOJOComponent(component) ? component.view : component).bind(component)(newChild.props, newChild.children)\n );\n\n continue;\n }\n\n newVnode.hasKeys = newVnode.hasKeys || \"key\" in newChild.props;\n out.push(newChild);\n continue;\n }\n\n out.push(newChild);\n }\n\n return out;\n}\n\nfunction processNewChild(newChild: VnodeWithDom, parentVnode: VnodeWithDom, oldDom?: DomElement) {\n if (oldDom) {\n newChild.dom = createElement(newChild.tag, newChild.isSVG as boolean);\n strictReplaceChild(parentVnode.dom, newChild.dom, oldDom);\n } else {\n newChild.dom = parentVnode.dom.appendChild(createElement(newChild.tag, newChild.isSVG as boolean));\n }\n updateAttributes(newChild);\n if (\"v-text\" in newChild.props) {\n newChild.dom.textContent = newChild.props[\"v-text\"];\n callSet(newChild.oncreate);\n return;\n }\n\n current.oldVnode = null;\n current.vnode = newChild;\n\n const children = flatTree(newChild);\n if (children.length === 0) {\n newChild.dom.textContent = \"\";\n callSet(newChild.oncreate);\n return;\n }\n\n for (let i = 0, l = children.length; i < l; i++) {\n if (children[i] instanceof Vnode === false) {\n newChild.dom.appendChild(document.createTextNode(children[i]));\n continue;\n }\n processNewChild(children[i] as VnodeWithDom, newChild);\n }\n callSet(newChild.oncreate);\n}\n\n// eslint-disable-next-line complexity\nfunction patch(newVnode: VnodeWithDom, oldVnode: VnodeWithDom | null): void {\n current.oldVnode = oldVnode;\n current.vnode = newVnode;\n const children = flatTree(newVnode);\n const dom = newVnode.dom;\n\n if (children.length === 0) {\n if (dom.childNodes.length) {\n const childNodes = Array.from(dom.childNodes) as any[];\n for (let i = childNodes.length - 1; i >= 0; i--) {\n const n = childNodes[i];\n if (n && n.nodeType === 1) {\n strictRemoveNode(n);\n } else {\n n?.remove?.();\n }\n }\n }\n callSet(newVnode.oncreate);\n callSet(newVnode.onupdate);\n return;\n }\n\n const childNodes = dom.childNodes as unknown as DomElement[];\n const oldChildrenLength = childNodes.length;\n const childrenLength = children.length;\n if (oldChildrenLength === 0) {\n for (let i = 0; i < childrenLength; i++) {\n const newChild = children[i] as VnodeWithDom;\n if (newChild instanceof Vnode === false) {\n dom.appendChild(document.createTextNode(newChild));\n continue;\n }\n processNewChild(newChild, newVnode);\n }\n callSet(newVnode.oncreate);\n return;\n }\n\n let oldTree = childNodes as unknown as DomElement[];\n const oldKeyedList: Record<string, number> = {};\n\n if (newVnode.hasKeys) {\n const newOldTree = [];\n for (let i = 0, l = oldTree.length; i < l; i++) {\n newOldTree[i] = oldTree[i];\n const oldVnode = oldTree[i].vnode as VnodeWithDom;\n oldKeyedList[!oldVnode || \"key\" in oldVnode.props === false ? i : (oldVnode.props.key as string)] = i;\n }\n oldTree = newOldTree;\n }\n\n for (let i = 0, l = children.length; i < l; i++) {\n const newChild = children[i] as VnodeWithDom;\n\n if (newChild instanceof Vnode === false) {\n const oldChild = oldTree[i];\n if (!oldChild) {\n dom.appendChild(document.createTextNode(newChild));\n continue;\n }\n\n if (oldChild.nodeType !== 3) {\n strictReplaceChild(dom, document.createTextNode(newChild), oldChild);\n continue;\n }\n\n // eslint-disable-next-line eqeqeq\n if (oldChild.nodeValue != newChild) {\n oldChild.nodeValue = newChild;\n }\n continue;\n }\n\n const oldChild = oldTree[newVnode.hasKeys ? oldKeyedList[(newChild.props.key as any) || i] : i] as DomElement;\n\n if (!oldChild || newChild.tag !== oldChild.nodeName.toLowerCase()) {\n processNewChild(newChild, newVnode, childNodes[i] as DomElement);\n continue;\n }\n\n newChild.dom = oldChild;\n const currentChild = childNodes[i];\n const oldChildVnode = oldChild.vnode as VnodeWithDom;\n if (!currentChild) {\n dom.appendChild(oldChild);\n } else if (currentChild !== oldChild) {\n dom.replaceChild(oldChild, currentChild);\n }\n\n if (\"v-keep\" in newChild.props && oldChildVnode) {\n if (oldChildVnode.props[\"v-keep\"] === newChild.props[\"v-keep\"]) {\n continue;\n }\n\n const oldProps = childNodes[i + 1]?.vnode?.props;\n if (oldProps && \"key\" in oldProps === false && oldProps[\"v-keep\"] === newChild.props[\"v-keep\"]) {\n strictRemoveNode(oldChild);\n oldTree.splice(i, 1);\n continue;\n }\n }\n\n updateAttributes(newChild as VnodeWithDom, oldChildVnode);\n\n if (\"v-text\" in newChild.props) {\n // eslint-disable-next-line eqeqeq\n if (oldChild.textContent != newChild.props[\"v-text\"]) {\n oldChild.textContent = newChild.props[\"v-text\"];\n }\n continue;\n }\n\n callSet(oldChildVnode?.oncleanup);\n // eslint-disable-next-line no-use-before-define\n patch(newChild as VnodeWithDom, oldChildVnode || null);\n }\n\n for (let i = childNodes.length, l = children.length; i > l; i--) {\n const toRemove = childNodes[i - 1];\n if (toRemove && toRemove.nodeType === 1) {\n strictRemoveNode(toRemove);\n } else {\n toRemove?.remove();\n }\n }\n\n // In here we could have new children or/and patched children\n // So we need to call the oncreate and onupdate callbacks\n callSet(newVnode.oncreate);\n callSet(newVnode.onupdate);\n}\n\nexport function updateVnode(vnode: VnodeWithDom, shouldCleanup = true): string | void {\n vnode.props = vnode.props || {};\n if (shouldCleanup) {\n // The clean up must be from the old vnode\n // and in here the vnode is the old one\n // so, we need to call the cleanup before the patch\n // inside the patch the clean up will be called only for the old children\n callSet(vnode.oncleanup);\n }\n // Clone the old on remove set to call it after the patch\n const oldOnRemoveSet = vnode.onremove ? new Set(vnode.onremove) : null;\n current.vnode = vnode;\n patch(vnode, shouldCleanup ? vnode : null);\n callSet(oldOnRemoveSet);\n isMounted = true;\n current.oldVnode = null;\n current.vnode = null;\n current.component = null;\n}\n\nexport function update(): string {\n if (mainVnode) {\n mainVnode.children = [mainComponent];\n // If the updateVnode method is called from outside the main lib (e.g. from a directive)\n // it always be considered as mounted, so the cleanup will be called before the patch\n // But in here, we need to pass the shouldCleanup as false if the app is not mounted\n updateVnode(mainVnode as VnodeWithDom, isMounted);\n if (isNodeJs) {\n return mainVnode.dom.innerHTML;\n }\n }\n return \"\";\n}\n\nlet debouncedUpdateTimeout: any;\nconst debouncedUpdateMethod = isNodeJs ? update : () => requestAnimationFrame(update);\n\nexport function debouncedUpdate(timeout = 42) {\n if (current.event) {\n current.event.preventDefault();\n }\n clearTimeout(debouncedUpdateTimeout);\n debouncedUpdateTimeout = setTimeout(debouncedUpdateMethod, timeout);\n}\n\nexport function unmount() {\n if (mainVnode) {\n mainComponent = v(() => null, {}) as VnodeComponentInterface;\n const result = update();\n for (const name of eventListenerNames) {\n mainVnode.dom.removeEventListener(name.slice(2), eventListener);\n }\n eventListenerNames.clear();\n\n mainComponent = null;\n mainVnode = null;\n isMounted = false;\n current.vnode = null;\n current.component = null;\n current.event = null;\n return result;\n }\n\n return \"\";\n}\n\nexport function mount(dom: string | DomElement, component: ValyrianComponent | VnodeComponentInterface | any) {\n const container =\n typeof dom === \"string\" ? (isNodeJs ? createElement(dom, dom === \"svg\") : document.querySelector(dom)) : dom;\n\n if (isComponent(component)) {\n mainComponent = v(component, {}, []) as VnodeComponentInterface;\n } else if (isVnodeComponent(component)) {\n mainComponent = component;\n } else {\n mainComponent = v(() => component, {}, []) as VnodeComponentInterface;\n }\n\n mainVnode = hidrateDomToVnode(container) as VnodeWithDom;\n return update();\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAwCO,IAAM,WAAW,QAAQ,OAAO,YAAY,eAAe,QAAQ,YAAY,QAAQ,SAAS,IAAI;AAEpG,IAAM,QAAN,MAAY;AAAA,EACjB,YACS,KACA,OACA,UACA,KACA,OACA,oBACA,iBACA,SACA,UACA,WACA,UACA,UACP;AAZO;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAAA,EACN;AACL;AAQO,IAAM,kBAAkB,CAAC,cAC9B,QAAQ,aAAa,OAAO,cAAc,YAAY,UAAU,SAAS;AAEpE,IAAM,cAAc,CAAC,cAC1B,QAAQ,OAAO,cAAc,cAAc,gBAAgB,SAAS,CAAC;AAChE,IAAM,UAAU,CAAC,WAAsC,kBAAkB;AAEzE,IAAM,mBAAmB,CAAC,WAAwD;AACvF,SAAO,QAAQ,MAAM,KAAK,YAAY,OAAO,GAAG;AAClD;AAEO,SAAS,EAAE,gBAA4C,UAA6B,UAAoB;AAC7G,SAAO,IAAI,MAAM,gBAAgB,OAAO,QAAQ;AAClD;AA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AU,IAAI;AAC5C,MAAI,QAAQ,OAAO;AACjB,YAAQ,MAAM,eAAe;AAAA,EAC/B;AACA,eAAa,sBAAsB;AACnC,2BAAyB,WAAW,uBAAuB,OAAO;AACpE;AAEO,SAAS,UAAU;AACxB,MAAI,WAAW;AACb,oBAAgB,EAAE,MAAM,MAAM,CAAC,CAAC;AAChC,UAAM,SAAS,OAAO;AACtB,eAAW,QAAQ,oBAAoB;AACrC,gBAAU,IAAI,oBAAoB,KAAK,MAAM,CAAC,GAAG,aAAa;AAAA,IAChE;AACA,uBAAmB,MAAM;AAEzB,oBAAgB;AAChB,gBAAY;AACZ,gBAAY;AACZ,YAAQ,QAAQ;AAChB,YAAQ,YAAY;AACpB,YAAQ,QAAQ;AAChB,WAAO;AAAA,EACT;AAEA,SAAO;AACT;AAEO,SAAS,MAAM,KAA0B,WAA8D;AAC5G,QAAM,YACJ,OAAO,QAAQ,WAAY,WAAW,cAAc,KAAK,QAAQ,KAAK,IAAI,SAAS,cAAc,GAAG,IAAK;AAE3G,MAAI,YAAY,SAAS,GAAG;AAC1B,oBAAgB,EAAE,WAAW,CAAC,GAAG,CAAC,CAAC;AAAA,EACrC,WAAW,iBAAiB,SAAS,GAAG;AACtC,oBAAgB;AAAA,EAClB,OAAO;AACL,oBAAgB,EAAE,MAAM,WAAW,CAAC,GAAG,CAAC,CAAC;AAAA,EAC3C;AAEA,cAAY,kBAAkB,SAAS;AACvC,SAAO,OAAO;AAChB;",
|
|
6
|
+
"names": ["value", "directive", "childNodes", "oldVnode", "oldChild"]
|
|
7
7
|
}
|
package/dist/index.min.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(()=>{var e=Boolean("undefined"!=typeof process&&process.versions&&process.versions.node),n=class{constructor(e,n,o,t,s,i,r,l,d,
|
|
1
|
+
(()=>{var e=Boolean("undefined"!=typeof process&&process.versions&&process.versions.node),n=class{constructor(e,n,o,t,s,i,r,l,c,d,p,a){this.tag=e,this.props=n,this.children=o,this.dom=t,this.isSVG=s,this.oldChildComponents=i,this.childComponents=r,this.hasKeys=l,this.oncreate=c,this.oncleanup=d,this.onupdate=p,this.onremove=a}},o=e=>Boolean(e&&"object"==typeof e&&"view"in e),t=e=>Boolean("function"==typeof e||o(e)),s=e=>e instanceof n,i=e=>s(e)&&t(e.tag);function r(e,o,...t){return new n(e,o,t)}function l(e){if(3===e.nodeType)return e.nodeValue;if(1===e.nodeType){const o=e.nodeName.toLowerCase(),t={},s=[];for(let n=0,o=e.childNodes.length;n<o;n++){const o=e.childNodes[n];if(3===o.nodeType)s.push(o.nodeValue);else if(1===o.nodeType){const e=l(o);s.push(e)}}const i=e.attributes;for(let e=0,n=i.length;e<n;e++){const n=i[e];t[n.nodeName]=n.nodeValue}const r=new n(o,t,s);return r.dom=e,e.vnode=r,r.isSVG="svg"===o,r}}function c(e){const n=document.createElement("div");return n.innerHTML=e.trim(),Array.from(n.childNodes).map(l)}r.fragment=(e,...n)=>n;var d=null,p=null,a=!1,u={oldVnode:null,vnode:null,component:null,event:null},f=new Set(["key","state","v-keep","v-text","v-if","v-for","v-show","v-class","v-html","v-model","v-create","v-update","v-cleanup","v-remove"]),m=Symbol.for("valyrian.subtreeLifecycle");function v(e){let n=e;for(;n&&1===n.nodeType&&!n[m];)n[m]=!0,n=n.parentElement}function h(e,n,o){o[n]=o[n]||new Set,o.dom&&v(o.dom),o[n].add(()=>{const n=e();"function"==typeof n&&(o.oncleanup=o.oncleanup||new Set,o.oncleanup.add(n),o.dom&&v(o.dom))})}function y(){if(!u.vnode)throw new Error("This function must be called inside a component")}var g=e=>{if(e){for(const n of e)n();e.clear()}};function C(e,n){const o=e.childNodes;for(let e=0;e<o.length;e++){const t=o[e];t&&1===t.nodeType&&C(t,n)}const t=e.vnode;t&&n.push(t)}function V(e){const n=[];C(e,n);for(let e=0;e<n.length;e++)g(n[e].oncleanup)}function w(e){const n=[];C(e,n);for(let e=0;e<n.length;e++)g(n[e].onremove)}function S(e){e&&1===e.nodeType&&(e[m]?(V(e),e.remove(),w(e)):e.remove())}function b(e,n,o){o&&1===o.nodeType&&o[m]&&V(o),e.replaceChild(n,o),o&&1===o.nodeType&&o[m]&&w(o)}var N={"v-create":(e,n,o)=>{o||h(()=>e(n),"oncreate",n)},"v-update":(e,n,o)=>{o&&h(()=>e(n,o),"onupdate",n)},"v-cleanup":(e,n)=>{n.oncleanup=n.oncleanup||new Set,n.oncleanup.add(()=>e(n)),v(n.dom)},"v-remove":(e,n)=>{n.onremove=n.onremove||new Set,n.onremove.add(()=>e(n)),v(n.dom)},"v-show":(e,n)=>{const o=Boolean(e);n.dom.style.display=o?"":"none"},"v-html":(e,n)=>{n.children=c(e)},"v-model":(e,n)=>{if("name"in n.props==!1)return;let o;const t=n.props.name;let s="oninput",i=n=>e[t]=n.target.value;if("input"===n.tag)switch(n.props.type){case"checkbox":Array.isArray(e[t])?(i=n=>{const o=n.target.value,s=e[t].indexOf(o);-1===s?e[t].push(o):e[t].splice(s,1)},o=-1!==e[t].indexOf(n.dom.value)):"value"in n.props?(i=()=>{e[t]===n.props.value?e[t]=null:e[t]=n.props.value},o=e[t]===n.props.value):(i=()=>e[t]=!e[t],o=e[t]),G("checked",o,n);break;case"radio":G("checked",e[t]===n.dom.value,n);break;default:G("value",e[t],n)}else"select"===n.tag?(s="onclick",n.props.multiple?(i=n=>{const o=n.target.value;if(n.ctrlKey){const n=e[t].indexOf(o);-1===n?e[t].push(o):e[t].splice(n,1)}else e[t].splice(0,e[t].length),e[t].push(o)},n.children.forEach(n=>{if("option"===n.tag){const o="value"in n.props?n.props.value:n.children.join("").trim();n.props.selected=-1!==e[t].indexOf(o)}})):n.children.forEach(n=>{if("option"===n.tag){const o="value"in n.props?n.props.value:n.children.join("").trim();n.props.selected=o===e[t]}})):"textarea"===n.tag&&(n.children=[e[t]]);const r=n.props[s];G(s,e=>{i(e),r&&r(e)},n)},"v-class":(e,n)=>{if("string"==typeof e)n.dom.className=e;else if(Array.isArray(e))n.dom.className=e.join(" ");else if("object"==typeof e){const o=n.dom.classList;for(const n in e){const t="function"==typeof e[n]?e[n]():e[n];o.toggle(n,t)}}},class(e,n){if(n.dom.className!==e){if(n.isSVG)return void n.dom.setAttribute("class",e);n.dom.className=e}},className(e,n){N.class(e,n)},id:(e,n)=>{if(n.dom.id!==e){if(n.isSVG)return void n.dom.setAttribute("id",e);n.dom.id=e}},style:(e,n)=>{if("string"==typeof e){if(n.isSVG)return void n.dom.setAttribute("style",e);n.dom.style=e}else if("object"==typeof e){n.isSVG?n.dom.setAttribute("style",""):n.dom.style="";const o=n.dom.style;for(const n in e)o[n]=e[n]}}};var T,x=new Set;function k(e){u.event=e;let n=e.target;const o=`on${e.type}`;for(;n;){const t=n.vnode;if(t&&t.props[o]){try{t.props[o](e,t)}finally{u.event=null}return void(e.defaultPrevented||P())}n=n.parentNode}u.event=null}function A(e,n,o){const t=o.dom;"function"!=typeof n?o.isSVG||!(e in t)?!1===n?t.removeAttribute(e):t.setAttribute(e,n):t[e]=n:x.has(e)||(p.dom.addEventListener(e.slice(2),k),x.add(e))}function G(e,n,o){f.has(e)||(o.props[e]=n,A(e,n,o))}function E(e,n){const o=e.dom,t=e.props;if(o.vnode=e,n)for(const s in n.props)s in t!=!1||x.has(s)||f.has(s)||(!e.isSVG&&s in o?o[s]=null:o.removeAttribute(s));for(const o in t)if(N[o]){if(!1===N[o](t[o],e,n?.props))break}else f.has(o)||A(o,t[o],e)}function L(e,n){return n?document.createElementNS("http://www.w3.org/2000/svg",e):document.createElement(e)}function K(e){let t=[];const s=e.children;if(e.hasKeys=!1,"v-for"in e.props==!1)for(let e=s.length-1;e>=0;e--)t.push(s[e]);else{t=[];const n=e.props["v-for"],o=e.children[0];if("function"!=typeof o)return console.warn("v-for directive must have a callback function as children"),t;const s=[];for(let e=0;e<n.length;e++)s.push(o(n[e],e));for(let e=s.length-1;e>=0;e--)t.push(s[e])}e.oldChildComponents=e.childComponents,e.childComponents&&(e.childComponents=new Set);const i=[];for(;t.length;){const s=t.pop();if(null!=s)if(Array.isArray(s))for(let e=s.length-1;e>=0;e--)t.push(s[e]);else if(s instanceof n){if(s.props=s.props||{},"v-if"in s.props&&!Boolean(s.props["v-if"]))continue;if(s.isSVG=e.isSVG||"svg"===s.tag,"string"!=typeof s.tag){const n=u.component=s.tag;e.childComponents=e.childComponents||new Set,e.childComponents.add(n),t.push((o(n)?n.view:n).bind(n)(s.props,s.children));continue}e.hasKeys=e.hasKeys||"key"in s.props,i.push(s)}else i.push(s)}return i}function j(e,o,t){if(t?(e.dom=L(e.tag,e.isSVG),b(o.dom,e.dom,t)):e.dom=o.dom.appendChild(L(e.tag,e.isSVG)),E(e),"v-text"in e.props)return e.dom.textContent=e.props["v-text"],void g(e.oncreate);u.oldVnode=null,u.vnode=e;const s=K(e);if(0===s.length)return e.dom.textContent="",void g(e.oncreate);for(let o=0,t=s.length;o<t;o++)s[o]instanceof n!=!1?j(s[o],e):e.dom.appendChild(document.createTextNode(s[o]));g(e.oncreate)}function O(e,o){u.oldVnode=o,u.vnode=e;const t=K(e),s=e.dom;if(0===t.length){if(s.childNodes.length){const e=Array.from(s.childNodes);for(let n=e.length-1;n>=0;n--){const o=e[n];o&&1===o.nodeType?S(o):o?.remove?.()}}return g(e.oncreate),void g(e.onupdate)}const i=s.childNodes,r=i.length,l=t.length;if(0===r){for(let o=0;o<l;o++){const i=t[o];i instanceof n!=!1?j(i,e):s.appendChild(document.createTextNode(i))}return void g(e.oncreate)}let c=i;const d={};if(e.hasKeys){const e=[];for(let n=0,o=c.length;n<o;n++){e[n]=c[n];const o=c[n].vnode;d[o&&"key"in o.props!=!1?o.props.key:n]=n}c=e}for(let o=0,r=t.length;o<r;o++){const r=t[o];if(r instanceof n==!1){const e=c[o];if(!e){s.appendChild(document.createTextNode(r));continue}if(3!==e.nodeType){b(s,document.createTextNode(r),e);continue}e.nodeValue!=r&&(e.nodeValue=r);continue}const l=c[e.hasKeys?d[r.props.key||o]:o];if(!l||r.tag!==l.nodeName.toLowerCase()){j(r,e,i[o]);continue}r.dom=l;const p=i[o],a=l.vnode;if(p?p!==l&&s.replaceChild(l,p):s.appendChild(l),"v-keep"in r.props&&a){if(a.props["v-keep"]===r.props["v-keep"])continue;const e=i[o+1]?.vnode?.props;if(e&&"key"in e==!1&&e["v-keep"]===r.props["v-keep"]){S(l),c.splice(o,1);continue}}E(r,a),"v-text"in r.props?l.textContent!=r.props["v-text"]&&(l.textContent=r.props["v-text"]):(g(a?.oncleanup),O(r,a||null))}for(let e=i.length,n=t.length;e>n;e--){const n=i[e-1];n&&1===n.nodeType?S(n):n?.remove()}g(e.oncreate),g(e.onupdate)}function B(e,n=!0){e.props=e.props||{},n&&g(e.oncleanup);const o=e.onremove?new Set(e.onremove):null;u.vnode=e,O(e,n?e:null),g(o),a=!0,u.oldVnode=null,u.vnode=null,u.component=null}function P(){return p&&(p.children=[d],B(p,a),e)?p.dom.innerHTML:""}var q=e?P:()=>requestAnimationFrame(P);var D={Vnode:n,createElement:L,current:u,debouncedUpdate:function(e=42){u.event&&u.event.preventDefault(),clearTimeout(T),T=setTimeout(q,e)},directive:function(e,n){const o=`v-${e}`;N[o]=n,f.add(o)},directives:N,hidrateDomToVnode:l,isComponent:t,isNodeJs:e,isPOJOComponent:o,isVnode:s,isVnodeComponent:i,mount:function(n,o){const s="string"==typeof n?e?L(n,"svg"===n):document.querySelector(n):n;return d=t(o)?r(o,{},[]):i(o)?o:r(()=>o,{},[]),p=l(s),P()},onCleanup:e=>{y(),h(e,"oncleanup",u.vnode)},onCreate:e=>{y();const n=u.vnode,o=u.component;n.oldChildComponents&&n.oldChildComponents.has(o)||h(e,"oncreate",n)},onRemove:e=>{y();const n=u.vnode,o=u.component;let t=!1;h(function(){n.childComponents&&n.childComponents.has(o)||t||(t=!0,e())},"onremove",u.vnode)},onUpdate:e=>{y();const n=u.vnode,o=u.component;n.childComponents&&n.childComponents.has(o)&&h(e,"onupdate",u.vnode)},reservedProps:f,setAttribute:G,setPropNameReserved:function(e){f.add(e)},trust:c,unmount:function(){if(p){d=r(()=>null,{});const e=P();for(const e of x)p.dom.removeEventListener(e.slice(2),k);return x.clear(),d=null,p=null,a=!1,u.vnode=null,u.component=null,u.event=null,e}return""},update:P,updateAttributes:E,updateVnode:B,v:r};"undefined"!=typeof module?module.exports=D:self.Valyrian=D})();//# sourceMappingURL=index.min.js.map
|