valyrian.js 7.2.11 → 8.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +6 -6
- package/dist/flux-store/index.d.ts +32 -0
- package/dist/flux-store/index.d.ts.map +1 -0
- package/dist/flux-store/index.js +258 -0
- package/dist/flux-store/index.js.map +7 -0
- package/dist/flux-store/index.min.js +1 -0
- package/dist/flux-store/index.min.js.map +1 -0
- package/dist/flux-store/index.mjs +237 -0
- package/dist/flux-store/index.mjs.map +7 -0
- package/dist/hooks/index.d.ts.map +1 -1
- package/dist/hooks/index.js +42 -75
- package/dist/hooks/index.js.map +2 -2
- package/dist/hooks/index.min.js +1 -0
- package/dist/hooks/index.min.js.map +1 -0
- package/dist/hooks/index.mjs +43 -76
- package/dist/hooks/index.mjs.map +2 -2
- package/dist/index.d.ts +52 -54
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +397 -328
- 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 +397 -328
- package/dist/index.mjs.map +3 -3
- package/dist/native-store/index.d.ts +14 -0
- package/dist/native-store/index.d.ts.map +1 -0
- package/dist/native-store/index.js +103 -0
- package/dist/native-store/index.js.map +7 -0
- package/dist/native-store/index.min.js +1 -0
- package/dist/native-store/index.min.js.map +1 -0
- package/dist/native-store/index.mjs +82 -0
- package/dist/native-store/index.mjs.map +7 -0
- package/dist/node/index.d.ts.map +1 -1
- package/dist/node/index.js +223 -86
- package/dist/node/index.js.map +4 -4
- package/dist/node/index.mjs +223 -86
- package/dist/node/index.mjs.map +4 -4
- package/dist/node/node.sw.js +152 -0
- package/dist/node/utils/inline.d.ts.map +1 -1
- package/dist/node/utils/node.sw.js +152 -0
- package/dist/node/utils/session-storage.d.ts +22 -0
- package/dist/node/utils/session-storage.d.ts.map +1 -0
- package/dist/node/utils/sw.d.ts.map +1 -1
- package/dist/node/utils/tree-adapter.d.ts +9 -0
- package/dist/node/utils/tree-adapter.d.ts.map +1 -1
- package/dist/pulse-store/index.d.ts +13 -0
- package/dist/pulse-store/index.d.ts.map +1 -0
- package/dist/pulse-store/index.js +143 -0
- package/dist/pulse-store/index.js.map +7 -0
- package/dist/pulse-store/index.min.js +1 -0
- package/dist/pulse-store/index.min.js.map +1 -0
- package/dist/pulse-store/index.mjs +122 -0
- package/dist/pulse-store/index.mjs.map +7 -0
- package/dist/request/index.d.ts.map +1 -1
- package/dist/request/index.js +68 -89
- package/dist/request/index.js.map +2 -2
- package/dist/request/index.min.js +1 -0
- package/dist/request/index.min.js.map +1 -0
- package/dist/request/index.mjs +68 -89
- package/dist/request/index.mjs.map +2 -2
- package/dist/router/index.d.ts +32 -31
- package/dist/router/index.d.ts.map +1 -1
- package/dist/router/index.js +256 -104
- package/dist/router/index.js.map +3 -3
- package/dist/router/index.min.js +1 -0
- package/dist/router/index.min.js.map +1 -0
- package/dist/router/index.mjs +256 -104
- package/dist/router/index.mjs.map +3 -3
- package/dist/signals/index.d.ts +6 -0
- package/dist/signals/index.d.ts.map +1 -0
- package/dist/signals/index.js +92 -0
- package/dist/signals/index.js.map +7 -0
- package/dist/signals/index.min.js +1 -0
- package/dist/signals/index.min.js.map +1 -0
- package/dist/signals/index.mjs +71 -0
- package/dist/signals/index.mjs.map +7 -0
- package/dist/suspense/index.d.ts +6 -0
- package/dist/suspense/index.d.ts.map +1 -0
- package/dist/suspense/index.js +67 -0
- package/dist/suspense/index.js.map +7 -0
- package/dist/suspense/index.min.js +1 -0
- package/dist/suspense/index.min.js.map +1 -0
- package/dist/suspense/index.mjs +46 -0
- package/dist/suspense/index.mjs.map +7 -0
- package/dist/sw/index.min.js +1 -0
- package/dist/sw/index.min.js.map +1 -0
- package/dist/translate/index.d.ts +19 -0
- package/dist/translate/index.d.ts.map +1 -0
- package/dist/translate/index.js +150 -0
- package/dist/translate/index.js.map +7 -0
- package/dist/translate/index.min.js +1 -0
- package/dist/translate/index.min.js.map +1 -0
- package/dist/translate/index.mjs +129 -0
- package/dist/translate/index.mjs.map +7 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/utils/deep-freeze.d.ts +3 -0
- package/dist/utils/deep-freeze.d.ts.map +1 -0
- package/dist/utils/getter-setter.d.ts +3 -0
- package/dist/utils/getter-setter.d.ts.map +1 -0
- package/dist/utils/has-changed.d.ts +2 -0
- package/dist/utils/has-changed.d.ts.map +1 -0
- package/dist/utils/index.d.ts +4 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/index.js +138 -0
- package/dist/utils/index.js.map +7 -0
- package/dist/utils/index.min.js +1 -0
- package/dist/utils/index.min.js.map +1 -0
- package/dist/utils/index.mjs +115 -0
- package/dist/utils/index.mjs.map +7 -0
- package/lib/flux-store/index.ts +301 -0
- package/lib/hooks/index.ts +52 -101
- package/lib/index.ts +479 -719
- package/lib/native-store/index.ts +106 -0
- package/lib/node/index.ts +5 -3
- package/lib/node/utils/icons.ts +5 -5
- package/lib/node/utils/inline.ts +17 -17
- package/lib/node/utils/node.sw.js +152 -0
- package/lib/node/utils/session-storage.ts +117 -0
- package/lib/node/utils/sw.ts +35 -11
- package/lib/node/utils/tree-adapter.ts +99 -52
- package/lib/pulse-store/index.ts +181 -0
- package/lib/request/index.ts +86 -116
- package/lib/router/index.ts +358 -170
- package/lib/signals/index.ts +98 -0
- package/lib/suspense/index.ts +57 -0
- package/lib/translate/index.ts +156 -0
- package/lib/utils/deep-freeze.ts +54 -0
- package/lib/utils/getter-setter.ts +40 -0
- package/lib/utils/has-changed.ts +43 -0
- package/lib/utils/index.ts +3 -0
- package/package.json +38 -50
- package/tsconfig.json +1 -1
- package/dist/dataset/index.d.ts +0 -24
- package/dist/dataset/index.d.ts.map +0 -1
- package/dist/dataset/index.js +0 -178
- package/dist/dataset/index.js.map +0 -7
- package/dist/dataset/index.mjs +0 -157
- package/dist/dataset/index.mjs.map +0 -7
- package/dist/node/node.sw.tpl +0 -133
- package/dist/node/utils/node.sw.tpl +0 -133
- package/dist/proxy-signal/index.d.ts +0 -23
- package/dist/proxy-signal/index.d.ts.map +0 -1
- package/dist/proxy-signal/index.js +0 -138
- package/dist/proxy-signal/index.js.map +0 -7
- package/dist/proxy-signal/index.mjs +0 -117
- package/dist/proxy-signal/index.mjs.map +0 -7
- package/dist/signal/index.d.ts +0 -20
- package/dist/signal/index.d.ts.map +0 -1
- package/dist/signal/index.js +0 -95
- package/dist/signal/index.js.map +0 -7
- package/dist/signal/index.mjs +0 -74
- package/dist/signal/index.mjs.map +0 -7
- package/dist/store/index.d.ts +0 -16
- package/dist/store/index.d.ts.map +0 -1
- package/dist/store/index.js +0 -93
- package/dist/store/index.js.map +0 -7
- package/dist/store/index.mjs +0 -72
- package/dist/store/index.mjs.map +0 -7
- package/lib/dataset/index.ts +0 -193
- package/lib/index.d.ts +0 -0
- package/lib/interfaces.ts.bak +0 -141
- package/lib/node/utils/node.sw.tpl +0 -133
- package/lib/proxy-signal/index.ts +0 -187
- package/lib/signal/index.ts +0 -161
- package/lib/store/index.ts +0 -101
package/dist/index.js
CHANGED
|
@@ -21,13 +21,15 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
21
21
|
var lib_exports = {};
|
|
22
22
|
__export(lib_exports, {
|
|
23
23
|
Vnode: () => Vnode,
|
|
24
|
-
|
|
24
|
+
createElement: () => createElement,
|
|
25
25
|
current: () => current,
|
|
26
|
+
debouncedUpdate: () => debouncedUpdate,
|
|
26
27
|
directive: () => directive,
|
|
27
28
|
directives: () => directives,
|
|
28
|
-
|
|
29
|
+
hidrateDomToVnode: () => hidrateDomToVnode,
|
|
29
30
|
isComponent: () => isComponent,
|
|
30
31
|
isNodeJs: () => isNodeJs,
|
|
32
|
+
isPOJOComponent: () => isPOJOComponent,
|
|
31
33
|
isVnode: () => isVnode,
|
|
32
34
|
isVnodeComponent: () => isVnodeComponent,
|
|
33
35
|
mount: () => mount,
|
|
@@ -35,9 +37,9 @@ __export(lib_exports, {
|
|
|
35
37
|
onMount: () => onMount,
|
|
36
38
|
onUnmount: () => onUnmount,
|
|
37
39
|
onUpdate: () => onUpdate,
|
|
38
|
-
patch: () => patch,
|
|
39
40
|
reservedProps: () => reservedProps,
|
|
40
41
|
setAttribute: () => setAttribute,
|
|
42
|
+
setPropNameReserved: () => setPropNameReserved,
|
|
41
43
|
trust: () => trust,
|
|
42
44
|
unmount: () => unmount,
|
|
43
45
|
update: () => update,
|
|
@@ -46,176 +48,129 @@ __export(lib_exports, {
|
|
|
46
48
|
v: () => v
|
|
47
49
|
});
|
|
48
50
|
module.exports = __toCommonJS(lib_exports);
|
|
49
|
-
var textTag = "#text";
|
|
50
51
|
var isNodeJs = Boolean(typeof process !== "undefined" && process.versions && process.versions.node);
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
}
|
|
59
|
-
function isComponent(component) {
|
|
60
|
-
return Boolean(
|
|
61
|
-
component && (typeof component === "function" || typeof component === "object" && "view" in component)
|
|
62
|
-
);
|
|
63
|
-
}
|
|
64
|
-
var isVnode = (object) => {
|
|
65
|
-
return object instanceof Vnode;
|
|
52
|
+
var Vnode = class {
|
|
53
|
+
constructor(tag, props, children, dom, isSVG) {
|
|
54
|
+
this.tag = tag;
|
|
55
|
+
this.props = props;
|
|
56
|
+
this.children = children;
|
|
57
|
+
this.dom = dom;
|
|
58
|
+
this.isSVG = isSVG;
|
|
59
|
+
}
|
|
66
60
|
};
|
|
61
|
+
var isPOJOComponent = (component) => Boolean(component && typeof component === "object" && "view" in component);
|
|
62
|
+
var isComponent = (component) => Boolean(typeof component === "function" || isPOJOComponent(component));
|
|
63
|
+
var isVnode = (object) => object instanceof Vnode;
|
|
67
64
|
var isVnodeComponent = (object) => {
|
|
68
65
|
return isVnode(object) && isComponent(object.tag);
|
|
69
66
|
};
|
|
70
|
-
function
|
|
67
|
+
function v(tagOrComponent, props, ...children) {
|
|
68
|
+
return new Vnode(tagOrComponent, props, children);
|
|
69
|
+
}
|
|
70
|
+
v.fragment = (_, ...children) => children;
|
|
71
|
+
function hidrateDomToVnode(dom) {
|
|
71
72
|
if (dom.nodeType === 3) {
|
|
72
|
-
|
|
73
|
-
vnode2.dom = dom;
|
|
74
|
-
return vnode2;
|
|
73
|
+
return dom.nodeValue;
|
|
75
74
|
}
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
75
|
+
if (dom.nodeType === 1) {
|
|
76
|
+
const tag = dom.nodeName.toLowerCase();
|
|
77
|
+
const props = {};
|
|
78
|
+
const children = [];
|
|
79
|
+
for (let i = 0, l = dom.childNodes.length; i < l; i++) {
|
|
80
|
+
const childDom = dom.childNodes[i];
|
|
81
|
+
if (childDom.nodeType === 3) {
|
|
82
|
+
children.push(childDom.nodeValue);
|
|
83
|
+
} else if (childDom.nodeType === 1) {
|
|
84
|
+
const childVnode = hidrateDomToVnode(childDom);
|
|
85
|
+
children.push(childVnode);
|
|
86
|
+
}
|
|
81
87
|
}
|
|
88
|
+
const attributes = dom.attributes;
|
|
89
|
+
for (let i = 0, l = attributes.length; i < l; i++) {
|
|
90
|
+
const attr = attributes[i];
|
|
91
|
+
props[attr.nodeName] = attr.nodeValue;
|
|
92
|
+
}
|
|
93
|
+
const vnode = new Vnode(tag, props, children);
|
|
94
|
+
vnode.dom = dom;
|
|
95
|
+
vnode.isSVG = tag === "svg";
|
|
96
|
+
return vnode;
|
|
82
97
|
}
|
|
83
|
-
let props = {};
|
|
84
|
-
for (let i = 0, l = dom.attributes.length; i < l; i++) {
|
|
85
|
-
let attr = dom.attributes[i];
|
|
86
|
-
props[attr.nodeName] = attr.nodeValue;
|
|
87
|
-
}
|
|
88
|
-
let vnode = new Vnode(dom.tagName.toLowerCase(), props, children);
|
|
89
|
-
vnode.dom = dom;
|
|
90
|
-
return vnode;
|
|
91
98
|
}
|
|
92
99
|
function trust(htmlString) {
|
|
93
|
-
|
|
100
|
+
const div = document.createElement("div");
|
|
94
101
|
div.innerHTML = htmlString.trim();
|
|
95
|
-
return
|
|
102
|
+
return Array.from(div.childNodes).map(hidrateDomToVnode);
|
|
96
103
|
}
|
|
97
104
|
var mainComponent = null;
|
|
98
105
|
var mainVnode = null;
|
|
99
106
|
var isMounted = false;
|
|
100
107
|
var current = {
|
|
101
108
|
vnode: null,
|
|
102
|
-
oldVnode: null,
|
|
103
109
|
component: null,
|
|
104
110
|
event: null
|
|
105
111
|
};
|
|
106
|
-
var reservedProps =
|
|
107
|
-
key
|
|
108
|
-
state
|
|
109
|
-
"v-keep"
|
|
110
|
-
|
|
111
|
-
"v-if"
|
|
112
|
-
"v-
|
|
113
|
-
"v-
|
|
114
|
-
"v-
|
|
115
|
-
"v-
|
|
116
|
-
"v-
|
|
117
|
-
"v-
|
|
118
|
-
"v-
|
|
119
|
-
"v-
|
|
120
|
-
|
|
121
|
-
};
|
|
112
|
+
var reservedProps = /* @__PURE__ */ new Set([
|
|
113
|
+
"key",
|
|
114
|
+
"state",
|
|
115
|
+
"v-keep",
|
|
116
|
+
"v-text",
|
|
117
|
+
"v-if",
|
|
118
|
+
"v-for",
|
|
119
|
+
"v-show",
|
|
120
|
+
"v-class",
|
|
121
|
+
"v-html",
|
|
122
|
+
"v-model",
|
|
123
|
+
"v-create",
|
|
124
|
+
"v-update",
|
|
125
|
+
"v-cleanup"
|
|
126
|
+
]);
|
|
122
127
|
var onCleanupSet = /* @__PURE__ */ new Set();
|
|
123
128
|
var onMountSet = /* @__PURE__ */ new Set();
|
|
124
129
|
var onUpdateSet = /* @__PURE__ */ new Set();
|
|
125
130
|
var onUnmountSet = /* @__PURE__ */ new Set();
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
onUpdateSet.add(callback);
|
|
133
|
-
}
|
|
134
|
-
function onCleanup(callback) {
|
|
135
|
-
onCleanupSet.add(callback);
|
|
136
|
-
}
|
|
137
|
-
function onUnmount(callback) {
|
|
138
|
-
if (!isMounted) {
|
|
139
|
-
onUnmountSet.add(callback);
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
function callSet(set) {
|
|
143
|
-
for (let callback of set) {
|
|
131
|
+
var onMount = (callback) => !isMounted && onMountSet.add(callback);
|
|
132
|
+
var onUpdate = (callback) => onUpdateSet.add(callback);
|
|
133
|
+
var onCleanup = (callback) => onCleanupSet.add(callback);
|
|
134
|
+
var onUnmount = (callback) => !isMounted && onUnmountSet.add(callback);
|
|
135
|
+
var callSet = (set) => {
|
|
136
|
+
for (const callback of set) {
|
|
144
137
|
callback();
|
|
145
138
|
}
|
|
146
139
|
set.clear();
|
|
147
|
-
}
|
|
148
|
-
var eventListenerNames = {};
|
|
149
|
-
function eventListener(e) {
|
|
150
|
-
current.event = e;
|
|
151
|
-
let dom = e.target;
|
|
152
|
-
let name = `v-on${e.type}`;
|
|
153
|
-
while (dom) {
|
|
154
|
-
if (dom[name]) {
|
|
155
|
-
dom[name](e, dom);
|
|
156
|
-
if (!e.defaultPrevented) {
|
|
157
|
-
update();
|
|
158
|
-
}
|
|
159
|
-
return;
|
|
160
|
-
}
|
|
161
|
-
dom = dom.parentNode;
|
|
162
|
-
}
|
|
163
|
-
current.event = null;
|
|
164
|
-
}
|
|
165
|
-
var hideDirective = (test) => (bool, vnode, oldnode) => {
|
|
166
|
-
let value = test ? bool : !bool;
|
|
167
|
-
if (value) {
|
|
168
|
-
let newdom = document.createTextNode("");
|
|
169
|
-
if (oldnode && oldnode.dom && oldnode.dom.parentNode) {
|
|
170
|
-
oldnode.dom.parentNode.replaceChild(newdom, oldnode.dom);
|
|
171
|
-
}
|
|
172
|
-
vnode.tag = "#text";
|
|
173
|
-
vnode.children = [];
|
|
174
|
-
vnode.props = {};
|
|
175
|
-
vnode.dom = newdom;
|
|
176
|
-
return false;
|
|
177
|
-
}
|
|
178
140
|
};
|
|
179
141
|
var directives = {
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
for (let i = 0, l = set.length; i < l; i++) {
|
|
189
|
-
newChildren.push(callback(set[i], i));
|
|
190
|
-
}
|
|
191
|
-
vnode.children = newChildren;
|
|
142
|
+
"v-if": (value, vnode) => {
|
|
143
|
+
if (!Boolean(value)) {
|
|
144
|
+
const parentNode = vnode.dom?.parentNode;
|
|
145
|
+
if (parentNode) {
|
|
146
|
+
parentNode.replaceChild(document.createTextNode(""), vnode.dom);
|
|
147
|
+
}
|
|
148
|
+
return false;
|
|
149
|
+
}
|
|
192
150
|
},
|
|
193
|
-
|
|
194
|
-
|
|
151
|
+
"v-show": (value, vnode) => {
|
|
152
|
+
const bool = Boolean(value);
|
|
195
153
|
vnode.dom.style.display = bool ? "" : "none";
|
|
196
154
|
},
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
for (let name in classes) {
|
|
200
|
-
vnode.dom.classList.toggle(name, classes[name]);
|
|
201
|
-
}
|
|
202
|
-
},
|
|
203
|
-
// The "v-html" directive sets the inner HTML of an element to the given HTML string
|
|
204
|
-
"v-html": (html, vnode) => {
|
|
205
|
-
vnode.children = [trust(html)];
|
|
155
|
+
"v-html": (value, vnode) => {
|
|
156
|
+
vnode.children = trust(value);
|
|
206
157
|
},
|
|
207
158
|
// The "v-model" directive binds the value of an input element to a model property
|
|
208
|
-
"v-model": (
|
|
159
|
+
"v-model": (model, vnode) => {
|
|
160
|
+
if ("name" in vnode.props === false) {
|
|
161
|
+
return;
|
|
162
|
+
}
|
|
209
163
|
let value;
|
|
164
|
+
const property = vnode.props.name;
|
|
165
|
+
let event = "oninput";
|
|
210
166
|
let handler = (e) => model[property] = e.target.value;
|
|
211
167
|
if (vnode.tag === "input") {
|
|
212
|
-
event = event || "oninput";
|
|
213
168
|
switch (vnode.props.type) {
|
|
214
169
|
case "checkbox": {
|
|
215
170
|
if (Array.isArray(model[property])) {
|
|
216
171
|
handler = (e) => {
|
|
217
|
-
|
|
218
|
-
|
|
172
|
+
const val = e.target.value;
|
|
173
|
+
const idx = model[property].indexOf(val);
|
|
219
174
|
if (idx === -1) {
|
|
220
175
|
model[property].push(val);
|
|
221
176
|
} else {
|
|
@@ -248,12 +203,12 @@ var directives = {
|
|
|
248
203
|
}
|
|
249
204
|
}
|
|
250
205
|
} else if (vnode.tag === "select") {
|
|
251
|
-
event =
|
|
206
|
+
event = "onclick";
|
|
252
207
|
if (vnode.props.multiple) {
|
|
253
208
|
handler = (e) => {
|
|
254
|
-
|
|
209
|
+
const val = e.target.value;
|
|
255
210
|
if (e.ctrlKey) {
|
|
256
|
-
|
|
211
|
+
const idx = model[property].indexOf(val);
|
|
257
212
|
if (idx === -1) {
|
|
258
213
|
model[property].push(val);
|
|
259
214
|
} else {
|
|
@@ -266,23 +221,22 @@ var directives = {
|
|
|
266
221
|
};
|
|
267
222
|
vnode.children.forEach((child) => {
|
|
268
223
|
if (child.tag === "option") {
|
|
269
|
-
|
|
224
|
+
const value2 = "value" in child.props ? child.props.value : child.children.join("").trim();
|
|
270
225
|
child.props.selected = model[property].indexOf(value2) !== -1;
|
|
271
226
|
}
|
|
272
227
|
});
|
|
273
228
|
} else {
|
|
274
229
|
vnode.children.forEach((child) => {
|
|
275
230
|
if (child.tag === "option") {
|
|
276
|
-
|
|
231
|
+
const value2 = "value" in child.props ? child.props.value : child.children.join("").trim();
|
|
277
232
|
child.props.selected = value2 === model[property];
|
|
278
233
|
}
|
|
279
234
|
});
|
|
280
235
|
}
|
|
281
236
|
} else if (vnode.tag === "textarea") {
|
|
282
|
-
event = event || "oninput";
|
|
283
237
|
vnode.children = [model[property]];
|
|
284
238
|
}
|
|
285
|
-
|
|
239
|
+
const prevHandler = vnode.props[event];
|
|
286
240
|
sharedSetAttribute(
|
|
287
241
|
event,
|
|
288
242
|
(e) => {
|
|
@@ -291,266 +245,383 @@ var directives = {
|
|
|
291
245
|
prevHandler(e);
|
|
292
246
|
}
|
|
293
247
|
},
|
|
294
|
-
vnode
|
|
295
|
-
oldVnode
|
|
248
|
+
vnode
|
|
296
249
|
);
|
|
297
250
|
},
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
// eslint-disable-next-line no-unused-vars
|
|
302
|
-
"v-create": (callback, vnode, oldVnode) => {
|
|
303
|
-
if (!oldVnode) {
|
|
304
|
-
let cleanup = callback(vnode);
|
|
251
|
+
"v-create": (callback, vnode, oldProps) => {
|
|
252
|
+
if (!oldProps) {
|
|
253
|
+
const cleanup = callback(vnode);
|
|
305
254
|
if (typeof cleanup === "function") {
|
|
306
255
|
onCleanup(cleanup);
|
|
307
256
|
}
|
|
308
257
|
}
|
|
309
258
|
},
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
"v-update": (callback, vnode, oldVnode) => {
|
|
314
|
-
if (oldVnode) {
|
|
315
|
-
let cleanup = callback(vnode, oldVnode);
|
|
259
|
+
"v-update": (callback, vnode, oldProps) => {
|
|
260
|
+
if (oldProps) {
|
|
261
|
+
const cleanup = callback(vnode, oldProps);
|
|
316
262
|
if (typeof cleanup === "function") {
|
|
317
263
|
onCleanup(cleanup);
|
|
318
264
|
}
|
|
319
265
|
}
|
|
320
266
|
},
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
"v-
|
|
325
|
-
|
|
267
|
+
"v-cleanup": (callback, vnode) => {
|
|
268
|
+
onCleanup(() => callback(vnode));
|
|
269
|
+
},
|
|
270
|
+
"v-class": (value, vnode) => {
|
|
271
|
+
if (typeof value === "string") {
|
|
272
|
+
vnode.dom.className = value;
|
|
273
|
+
} else if (Array.isArray(value)) {
|
|
274
|
+
vnode.dom.className = value.join(" ");
|
|
275
|
+
} else if (typeof value === "object") {
|
|
276
|
+
const classList = vnode.dom.classList;
|
|
277
|
+
for (const name in value) {
|
|
278
|
+
const val = typeof value[name] === "function" ? value[name]() : value[name];
|
|
279
|
+
classList.toggle(name, val);
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
},
|
|
283
|
+
// Frequent used properties
|
|
284
|
+
class(value, vnode) {
|
|
285
|
+
if (vnode.dom.className !== value) {
|
|
286
|
+
vnode.dom.className = value;
|
|
287
|
+
}
|
|
288
|
+
},
|
|
289
|
+
className(value, vnode) {
|
|
290
|
+
directives.class(value, vnode, null);
|
|
291
|
+
},
|
|
292
|
+
id: (value, vnode) => {
|
|
293
|
+
vnode.dom.id = value;
|
|
294
|
+
},
|
|
295
|
+
style: (value, vnode) => {
|
|
296
|
+
if (typeof value === "string") {
|
|
297
|
+
vnode.dom.style = value;
|
|
298
|
+
} else if (typeof value === "object") {
|
|
299
|
+
vnode.dom.style = "";
|
|
300
|
+
const domStyle = vnode.dom.style;
|
|
301
|
+
for (const name in value) {
|
|
302
|
+
domStyle[name] = value[name];
|
|
303
|
+
}
|
|
304
|
+
}
|
|
326
305
|
}
|
|
327
306
|
};
|
|
328
307
|
function directive(name, directive2) {
|
|
329
|
-
|
|
308
|
+
const directiveName = `v-${name}`;
|
|
330
309
|
directives[directiveName] = directive2;
|
|
331
|
-
reservedProps
|
|
310
|
+
reservedProps.add(directiveName);
|
|
311
|
+
}
|
|
312
|
+
function setPropNameReserved(name) {
|
|
313
|
+
reservedProps.add(name);
|
|
314
|
+
}
|
|
315
|
+
var eventListenerNames = /* @__PURE__ */ new Set();
|
|
316
|
+
function eventListener(e) {
|
|
317
|
+
current.event = e;
|
|
318
|
+
let dom = e.target;
|
|
319
|
+
const name = `on${e.type}`;
|
|
320
|
+
while (dom) {
|
|
321
|
+
const oldProps = dom.props;
|
|
322
|
+
if (oldProps && oldProps[name]) {
|
|
323
|
+
oldProps[name](e, dom);
|
|
324
|
+
if (!e.defaultPrevented) {
|
|
325
|
+
update();
|
|
326
|
+
}
|
|
327
|
+
return;
|
|
328
|
+
}
|
|
329
|
+
dom = dom.parentNode;
|
|
330
|
+
}
|
|
331
|
+
current.event = null;
|
|
332
332
|
}
|
|
333
|
-
function sharedSetAttribute(name, value, newVnode
|
|
333
|
+
function sharedSetAttribute(name, value, newVnode) {
|
|
334
|
+
const newVnodeDom = newVnode.dom;
|
|
334
335
|
if (typeof value === "function") {
|
|
335
|
-
if (name
|
|
336
|
+
if (!eventListenerNames.has(name)) {
|
|
336
337
|
mainVnode.dom.addEventListener(name.slice(2), eventListener);
|
|
337
|
-
eventListenerNames
|
|
338
|
+
eventListenerNames.add(name);
|
|
338
339
|
}
|
|
339
|
-
newVnode.dom[`v-${name}`] = value;
|
|
340
340
|
return;
|
|
341
341
|
}
|
|
342
|
-
if (name in
|
|
343
|
-
|
|
344
|
-
newVnode.dom[name] = value;
|
|
345
|
-
}
|
|
342
|
+
if (name in newVnodeDom) {
|
|
343
|
+
newVnodeDom[name] = value;
|
|
346
344
|
return;
|
|
347
345
|
}
|
|
348
|
-
if (
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
newVnode.dom.setAttribute(name, value);
|
|
353
|
-
}
|
|
346
|
+
if (value === false) {
|
|
347
|
+
newVnodeDom.removeAttribute(name);
|
|
348
|
+
} else {
|
|
349
|
+
newVnodeDom.setAttribute(name, value);
|
|
354
350
|
}
|
|
355
351
|
}
|
|
356
|
-
function setAttribute(name, value, newVnode
|
|
357
|
-
if (name
|
|
358
|
-
|
|
352
|
+
function setAttribute(name, value, newVnode) {
|
|
353
|
+
if (!reservedProps.has(name)) {
|
|
354
|
+
newVnode.props[name] = value;
|
|
355
|
+
sharedSetAttribute(name, value, newVnode);
|
|
359
356
|
}
|
|
360
|
-
newVnode.props[name] = value;
|
|
361
|
-
sharedSetAttribute(name, value, newVnode, oldVnode);
|
|
362
357
|
}
|
|
363
|
-
function updateAttributes(newVnode,
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
358
|
+
function updateAttributes(newVnode, oldProps) {
|
|
359
|
+
const vnodeDom = newVnode.dom;
|
|
360
|
+
const vnodeProps = newVnode.props;
|
|
361
|
+
if (oldProps) {
|
|
362
|
+
for (const name in oldProps) {
|
|
363
|
+
if (name in vnodeProps === false && !eventListenerNames.has(name) && !reservedProps.has(name)) {
|
|
364
|
+
if (name in vnodeDom) {
|
|
365
|
+
vnodeDom[name] = null;
|
|
369
366
|
} else {
|
|
370
|
-
|
|
367
|
+
vnodeDom.removeAttribute(name);
|
|
371
368
|
}
|
|
372
369
|
}
|
|
373
370
|
}
|
|
374
371
|
}
|
|
375
|
-
for (
|
|
376
|
-
if (name
|
|
377
|
-
if (
|
|
372
|
+
for (const name in vnodeProps) {
|
|
373
|
+
if (directives[name]) {
|
|
374
|
+
if (directives[name](vnodeProps[name], newVnode, oldProps) === false) {
|
|
378
375
|
break;
|
|
379
376
|
}
|
|
380
377
|
continue;
|
|
381
378
|
}
|
|
382
|
-
|
|
379
|
+
if (!reservedProps.has(name)) {
|
|
380
|
+
sharedSetAttribute(name, vnodeProps[name], newVnode);
|
|
381
|
+
}
|
|
383
382
|
}
|
|
384
383
|
}
|
|
385
|
-
function
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
384
|
+
function createElement(tag, isSVG) {
|
|
385
|
+
return isSVG ? document.createElementNS("http://www.w3.org/2000/svg", tag) : document.createElement(tag);
|
|
386
|
+
}
|
|
387
|
+
function flatTree(newVnode) {
|
|
388
|
+
current.vnode = newVnode;
|
|
389
|
+
if ("v-for" in newVnode.props) {
|
|
390
|
+
const children2 = [];
|
|
391
|
+
const set = newVnode.props["v-for"];
|
|
392
|
+
const l = set.length;
|
|
393
|
+
const callback = newVnode.children[0];
|
|
394
|
+
for (let i2 = 0; i2 < l; i2++) {
|
|
395
|
+
const newChild = callback(set[i2], i2);
|
|
396
|
+
if (newChild instanceof Vnode) {
|
|
397
|
+
newChild.props = newChild.props || {};
|
|
398
|
+
newChild.isSVG = newVnode.isSVG || newChild.tag === "svg";
|
|
399
|
+
}
|
|
400
|
+
children2[i2] = newChild;
|
|
401
|
+
}
|
|
402
|
+
return children2;
|
|
389
403
|
}
|
|
390
|
-
let
|
|
391
|
-
|
|
392
|
-
let
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
}
|
|
399
|
-
let newKeyedList = {};
|
|
400
|
-
for (let i = 0; i < newTreeLength; i++) {
|
|
401
|
-
newKeyedList[newTree[i].props.key] = i;
|
|
402
|
-
}
|
|
403
|
-
for (let i = 0; i < newTreeLength; i++) {
|
|
404
|
-
let newChild = newTree[i];
|
|
405
|
-
let oldChild = oldTree[oldKeyedList[newChild.props.key]];
|
|
406
|
-
let shouldPatch = true;
|
|
407
|
-
if (oldChild) {
|
|
408
|
-
newChild.dom = oldChild.dom;
|
|
409
|
-
if ("v-keep" in newChild.props && newChild.props["v-keep"] === oldChild.props["v-keep"]) {
|
|
410
|
-
newChild.children = oldChild.children;
|
|
411
|
-
shouldPatch = false;
|
|
412
|
-
} else {
|
|
413
|
-
updateAttributes(newChild, oldChild);
|
|
414
|
-
}
|
|
415
|
-
} else {
|
|
416
|
-
newChild.dom = createDomElement(newChild.tag, newChild.isSVG);
|
|
417
|
-
updateAttributes(newChild);
|
|
404
|
+
let i = 0;
|
|
405
|
+
const originalChildren = newVnode.children;
|
|
406
|
+
let children = originalChildren;
|
|
407
|
+
while (i < children.length) {
|
|
408
|
+
const newChild = children[i];
|
|
409
|
+
if (newChild == null) {
|
|
410
|
+
if (children === originalChildren) {
|
|
411
|
+
children = [...originalChildren];
|
|
418
412
|
}
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
413
|
+
children.splice(i, 1);
|
|
414
|
+
continue;
|
|
415
|
+
}
|
|
416
|
+
if (Array.isArray(newChild)) {
|
|
417
|
+
if (children === originalChildren) {
|
|
418
|
+
children = [...originalChildren];
|
|
423
419
|
}
|
|
424
|
-
|
|
420
|
+
children.splice(i, 1, ...newChild);
|
|
421
|
+
continue;
|
|
425
422
|
}
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
423
|
+
if (newChild instanceof Vnode) {
|
|
424
|
+
newChild.props = newChild.props || {};
|
|
425
|
+
newChild.isSVG = newVnode.isSVG || newChild.tag === "svg";
|
|
426
|
+
if (typeof newChild.tag !== "string") {
|
|
427
|
+
if (children === originalChildren) {
|
|
428
|
+
children = [...originalChildren];
|
|
429
|
+
}
|
|
430
|
+
const component = current.component = newChild.tag;
|
|
431
|
+
children[i] = (isPOJOComponent(component) ? component.view : component).bind(component)(
|
|
432
|
+
newChild.props,
|
|
433
|
+
newChild.children
|
|
434
|
+
);
|
|
435
|
+
continue;
|
|
429
436
|
}
|
|
430
437
|
}
|
|
438
|
+
i++;
|
|
439
|
+
}
|
|
440
|
+
return children;
|
|
441
|
+
}
|
|
442
|
+
function createNewElement(newChild, newVnode, oldChild) {
|
|
443
|
+
const dom = createElement(newChild.tag, newChild.isSVG);
|
|
444
|
+
if (oldChild) {
|
|
445
|
+
newVnode.dom.replaceChild(dom, oldChild);
|
|
446
|
+
} else {
|
|
447
|
+
newVnode.dom.appendChild(dom);
|
|
448
|
+
}
|
|
449
|
+
newChild.dom = dom;
|
|
450
|
+
updateAttributes(newChild, null);
|
|
451
|
+
newChild.dom.props = newChild.props;
|
|
452
|
+
if ("v-text" in newChild.props) {
|
|
453
|
+
newChild.dom.textContent = newChild.props["v-text"];
|
|
431
454
|
return;
|
|
432
455
|
}
|
|
433
|
-
|
|
434
|
-
|
|
456
|
+
const children = flatTree(newChild);
|
|
457
|
+
if (children.length === 0) {
|
|
458
|
+
newChild.dom.textContent = "";
|
|
435
459
|
return;
|
|
436
460
|
}
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
let newChild = newTree[i];
|
|
441
|
-
if (newChild instanceof Vnode) {
|
|
442
|
-
if (typeof newChild.tag !== "string") {
|
|
443
|
-
current.component = newChild.tag;
|
|
444
|
-
newTree.splice(
|
|
445
|
-
i--,
|
|
446
|
-
1,
|
|
447
|
-
("view" in newChild.tag ? newChild.tag.view.bind(newChild.tag) : newChild.tag.bind(newChild.tag))(
|
|
448
|
-
newChild.props,
|
|
449
|
-
...newChild.children
|
|
450
|
-
)
|
|
451
|
-
);
|
|
452
|
-
}
|
|
461
|
+
for (let i = 0, l = children.length; i < l; i++) {
|
|
462
|
+
if (children[i] instanceof Vnode === false) {
|
|
463
|
+
newChild.dom.appendChild(document.createTextNode(children[i]));
|
|
453
464
|
continue;
|
|
454
465
|
}
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
466
|
+
createNewElement(children[i], newChild, null);
|
|
467
|
+
}
|
|
468
|
+
}
|
|
469
|
+
function patchKeyed(newVnode, children) {
|
|
470
|
+
const oldTree = [...Array.from(newVnode.dom.childNodes)];
|
|
471
|
+
const childNodes = newVnode.dom.childNodes;
|
|
472
|
+
const oldKeyedList = {};
|
|
473
|
+
const newKeyedList = {};
|
|
474
|
+
for (let i = 0, l = oldTree.length; i < l; i++) {
|
|
475
|
+
const oldProps = oldTree[i].props;
|
|
476
|
+
if (oldProps) {
|
|
477
|
+
oldKeyedList[oldProps.key] = i;
|
|
458
478
|
}
|
|
459
|
-
if (
|
|
460
|
-
|
|
461
|
-
continue;
|
|
479
|
+
if (i < children.length && children[i] instanceof Vnode) {
|
|
480
|
+
newKeyedList[children[i].props.key] = i;
|
|
462
481
|
}
|
|
463
|
-
newTree[i] = new Vnode(textTag, {}, [newChild]);
|
|
464
482
|
}
|
|
465
|
-
for (let i = 0; i <
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
483
|
+
for (let i = 0, l = children.length; i < l; i++) {
|
|
484
|
+
const newChild = children[i];
|
|
485
|
+
const oldChild = oldTree[oldKeyedList[newChild.props.key]];
|
|
486
|
+
if (!oldChild) {
|
|
487
|
+
createNewElement(newChild, newVnode, childNodes[i]);
|
|
488
|
+
continue;
|
|
489
|
+
}
|
|
490
|
+
newChild.dom = oldChild;
|
|
491
|
+
const currentChild = childNodes[i];
|
|
492
|
+
if (!currentChild) {
|
|
493
|
+
newVnode.dom.appendChild(oldChild);
|
|
494
|
+
} else if (currentChild !== oldChild) {
|
|
495
|
+
newVnode.dom.replaceChild(oldChild, currentChild);
|
|
496
|
+
}
|
|
497
|
+
if ("v-keep" in newChild.props === false || oldChild.props["v-keep"] !== newChild.props["v-keep"]) {
|
|
498
|
+
updateAttributes(newChild, oldChild.props);
|
|
499
|
+
oldChild.props = newChild.props;
|
|
500
|
+
if ("v-text" in newChild.props) {
|
|
501
|
+
if (oldChild.textContent != newChild.props["v-text"]) {
|
|
502
|
+
oldChild.textContent = newChild.props["v-text"];
|
|
503
|
+
}
|
|
471
504
|
continue;
|
|
472
505
|
}
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
506
|
+
patch(newChild);
|
|
507
|
+
}
|
|
508
|
+
}
|
|
509
|
+
for (let i = children.length, l = childNodes.length; i < l; i++) {
|
|
510
|
+
childNodes[i]?.remove();
|
|
511
|
+
}
|
|
512
|
+
}
|
|
513
|
+
function patch(newVnode) {
|
|
514
|
+
const children = flatTree(newVnode);
|
|
515
|
+
const dom = newVnode.dom;
|
|
516
|
+
if (children.length === 0) {
|
|
517
|
+
if (dom.childNodes.length) {
|
|
518
|
+
dom.textContent = "";
|
|
519
|
+
}
|
|
520
|
+
return;
|
|
521
|
+
}
|
|
522
|
+
const oldDomChildren = dom.childNodes;
|
|
523
|
+
const oldChildrenLength = oldDomChildren.length;
|
|
524
|
+
if (oldChildrenLength > 0) {
|
|
525
|
+
const firstOldProps = oldDomChildren[0].props;
|
|
526
|
+
const firstVnode = children[0];
|
|
527
|
+
if (firstOldProps && firstVnode instanceof Vnode && "key" in firstVnode.props && "key" in firstOldProps) {
|
|
528
|
+
patchKeyed(newVnode, children);
|
|
529
|
+
return;
|
|
530
|
+
}
|
|
531
|
+
}
|
|
532
|
+
const childrenLength = children.length;
|
|
533
|
+
if (oldChildrenLength === 0) {
|
|
534
|
+
for (let i = 0; i < childrenLength; i++) {
|
|
535
|
+
if (children[i] instanceof Vnode === false) {
|
|
536
|
+
dom.appendChild(document.createTextNode(children[i]));
|
|
477
537
|
continue;
|
|
478
538
|
}
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
539
|
+
createNewElement(children[i], newVnode, null);
|
|
540
|
+
}
|
|
541
|
+
return;
|
|
542
|
+
}
|
|
543
|
+
for (let i = 0; i < childrenLength; i++) {
|
|
544
|
+
const newChild = children[i];
|
|
545
|
+
const isText = newChild instanceof Vnode === false;
|
|
546
|
+
const oldChild = oldDomChildren[i];
|
|
547
|
+
if (!oldChild) {
|
|
548
|
+
if (isText) {
|
|
549
|
+
newVnode.dom.appendChild(document.createTextNode(newChild));
|
|
550
|
+
continue;
|
|
482
551
|
}
|
|
552
|
+
createNewElement(newChild, newVnode, null);
|
|
483
553
|
continue;
|
|
484
554
|
}
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
555
|
+
if (isText) {
|
|
556
|
+
if (oldChild.nodeType !== 3) {
|
|
557
|
+
newVnode.dom.replaceChild(document.createTextNode(newChild), oldChild);
|
|
558
|
+
continue;
|
|
559
|
+
}
|
|
560
|
+
if (oldChild.nodeValue != newChild) {
|
|
561
|
+
oldChild.nodeValue = newChild;
|
|
562
|
+
}
|
|
491
563
|
continue;
|
|
492
564
|
}
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
565
|
+
if ("v-keep" in newChild.props) {
|
|
566
|
+
if (oldChild.props && oldChild.props["v-keep"] === newChild.props["v-keep"]) {
|
|
567
|
+
continue;
|
|
568
|
+
}
|
|
569
|
+
const nextOldChild = oldDomChildren[i + 1];
|
|
570
|
+
if (nextOldChild && nextOldChild.props && nextOldChild.props["v-keep"] === newChild.props["v-keep"]) {
|
|
571
|
+
oldChild.remove();
|
|
572
|
+
continue;
|
|
573
|
+
}
|
|
574
|
+
}
|
|
575
|
+
if (newChild.tag !== oldChild.nodeName.toLowerCase()) {
|
|
576
|
+
createNewElement(newChild, newVnode, oldChild);
|
|
499
577
|
continue;
|
|
500
578
|
}
|
|
501
|
-
newChild.dom = oldChild
|
|
502
|
-
|
|
503
|
-
|
|
579
|
+
newChild.dom = oldChild;
|
|
580
|
+
updateAttributes(newChild, oldChild.props || null);
|
|
581
|
+
oldChild.props = newChild.props;
|
|
582
|
+
if ("v-text" in newChild.props) {
|
|
583
|
+
if (newChild.dom.textContent != newChild.props["v-text"]) {
|
|
584
|
+
newChild.dom.textContent = newChild.props["v-text"];
|
|
585
|
+
}
|
|
504
586
|
continue;
|
|
505
587
|
}
|
|
506
|
-
|
|
507
|
-
patch(newChild, oldChild);
|
|
588
|
+
patch(newChild);
|
|
508
589
|
}
|
|
509
|
-
for (let i =
|
|
510
|
-
|
|
590
|
+
for (let i = childrenLength, l = oldDomChildren.length; i < l; i++) {
|
|
591
|
+
oldDomChildren[i]?.remove();
|
|
511
592
|
}
|
|
512
593
|
}
|
|
594
|
+
function updateVnode(vnode) {
|
|
595
|
+
callSet(onCleanupSet);
|
|
596
|
+
vnode.props = vnode.props || {};
|
|
597
|
+
patch(vnode);
|
|
598
|
+
callSet(isMounted ? onUpdateSet : onMountSet);
|
|
599
|
+
isMounted = true;
|
|
600
|
+
current.vnode = null;
|
|
601
|
+
current.component = null;
|
|
602
|
+
}
|
|
513
603
|
function update() {
|
|
514
604
|
if (mainVnode) {
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
mainVnode = new Vnode(oldMainVnode.tag, oldMainVnode.props, [mainComponent]);
|
|
518
|
-
mainVnode.dom = oldMainVnode.dom;
|
|
519
|
-
mainVnode.isSVG = oldMainVnode.isSVG;
|
|
520
|
-
patch(mainVnode, oldMainVnode);
|
|
521
|
-
callSet(isMounted ? onUpdateSet : onMountSet);
|
|
522
|
-
isMounted = true;
|
|
523
|
-
current.vnode = null;
|
|
524
|
-
current.oldVnode = null;
|
|
525
|
-
current.component = null;
|
|
605
|
+
mainVnode.children = [mainComponent];
|
|
606
|
+
updateVnode(mainVnode);
|
|
526
607
|
if (isNodeJs) {
|
|
527
608
|
return mainVnode.dom.innerHTML;
|
|
528
609
|
}
|
|
529
610
|
}
|
|
530
611
|
}
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
oldVnode.dom = vnode.dom;
|
|
538
|
-
oldVnode.isSVG = vnode.isSVG;
|
|
539
|
-
callSet(isMounted ? onUpdateSet : onMountSet);
|
|
540
|
-
isMounted = true;
|
|
541
|
-
current.vnode = null;
|
|
542
|
-
current.oldVnode = null;
|
|
543
|
-
current.component = null;
|
|
544
|
-
if (isNodeJs) {
|
|
545
|
-
return vnode.dom.innerHTML;
|
|
546
|
-
}
|
|
612
|
+
var debouncedUpdateTimeout;
|
|
613
|
+
var clearDebouncedUpdateMethod = isNodeJs ? clearTimeout : cancelAnimationFrame;
|
|
614
|
+
var setDebouncedUpdateMethod = isNodeJs ? () => setTimeout(update, 5) : () => requestAnimationFrame(update);
|
|
615
|
+
function debouncedUpdate() {
|
|
616
|
+
clearDebouncedUpdateMethod(debouncedUpdateTimeout);
|
|
617
|
+
debouncedUpdateTimeout = setDebouncedUpdateMethod();
|
|
547
618
|
}
|
|
548
619
|
function unmount() {
|
|
549
620
|
if (mainVnode) {
|
|
550
|
-
mainComponent =
|
|
551
|
-
|
|
621
|
+
mainComponent = v(() => null, {});
|
|
622
|
+
const result = update();
|
|
552
623
|
callSet(onUnmountSet);
|
|
553
|
-
for (
|
|
624
|
+
for (const name in eventListenerNames) {
|
|
554
625
|
mainVnode.dom.removeEventListener(name.slice(2).toLowerCase(), eventListener);
|
|
555
626
|
Reflect.deleteProperty(eventListenerNames, name);
|
|
556
627
|
}
|
|
@@ -558,22 +629,20 @@ function unmount() {
|
|
|
558
629
|
mainVnode = null;
|
|
559
630
|
isMounted = false;
|
|
560
631
|
current.vnode = null;
|
|
561
|
-
current.oldVnode = null;
|
|
562
632
|
current.component = null;
|
|
633
|
+
current.event = null;
|
|
563
634
|
return result;
|
|
564
635
|
}
|
|
565
636
|
}
|
|
566
637
|
function mount(dom, component) {
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
638
|
+
const container = typeof dom === "string" ? isNodeJs ? createElement(dom, dom === "svg") : document.querySelector(dom) : dom;
|
|
639
|
+
if (isComponent(component)) {
|
|
640
|
+
mainComponent = v(component, {}, []);
|
|
641
|
+
} else if (isVnodeComponent(component)) {
|
|
642
|
+
mainComponent = component;
|
|
643
|
+
} else {
|
|
644
|
+
mainComponent = v(() => component, {}, []);
|
|
571
645
|
}
|
|
572
|
-
|
|
573
|
-
mainVnode = domToVnode(container);
|
|
646
|
+
mainVnode = hidrateDomToVnode(container);
|
|
574
647
|
return update();
|
|
575
648
|
}
|
|
576
|
-
var v = (tagOrComponent, props = {}, ...children) => {
|
|
577
|
-
return new Vnode(tagOrComponent, props || {}, children);
|
|
578
|
-
};
|
|
579
|
-
v.fragment = (_, ...children) => children;
|