vite-plugin-vanjs 0.1.24 → 0.1.25
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/client/index.mjs +14 -7
- package/meta/global.d.ts +4 -1
- package/package.json +8 -8
- package/router/helpers.mjs +16 -13
package/client/index.mjs
CHANGED
|
@@ -108,18 +108,24 @@ export function elementsMatch(el1, el2, deep) {
|
|
|
108
108
|
return false;
|
|
109
109
|
}
|
|
110
110
|
|
|
111
|
-
|
|
112
|
-
|
|
111
|
+
// Filter empty text nodes — SSR omits them, client creates Text("")
|
|
112
|
+
// from function children returning ""
|
|
113
|
+
const cn1 = Array.from(el1.childNodes).filter((n) =>
|
|
114
|
+
n.nodeType !== 3 || /* istanbul ignore next */ n.textContent !== ""
|
|
115
|
+
);
|
|
116
|
+
const cn2 = Array.from(el2.childNodes).filter((n) =>
|
|
117
|
+
n.nodeType !== 3 || /* istanbul ignore next */ n.textContent !== ""
|
|
118
|
+
);
|
|
113
119
|
|
|
114
120
|
// istanbul ignore else
|
|
115
|
-
if (
|
|
121
|
+
if (cn1.length !== cn2.length) {
|
|
116
122
|
return false;
|
|
117
123
|
}
|
|
118
124
|
|
|
119
125
|
// Only recurse if necessary (has childNodes with data-hk)
|
|
120
|
-
const hasHydratedChildren =
|
|
121
|
-
child instanceof HTMLElement &&
|
|
122
|
-
|
|
126
|
+
const hasHydratedChildren = cn1.some((child) =>
|
|
127
|
+
child instanceof HTMLElement &&
|
|
128
|
+
(child.hasAttribute("data-hk") || child.querySelector("[data-hk]"))
|
|
123
129
|
);
|
|
124
130
|
|
|
125
131
|
// istanbul ignore next
|
|
@@ -130,7 +136,7 @@ export function elementsMatch(el1, el2, deep) {
|
|
|
130
136
|
// Only recurse if opted in
|
|
131
137
|
// istanbul ignore next
|
|
132
138
|
return deep
|
|
133
|
-
?
|
|
139
|
+
? cn1.every((child, idx) => elementsMatch(child, cn2[idx]))
|
|
134
140
|
: true;
|
|
135
141
|
}
|
|
136
142
|
|
|
@@ -279,4 +285,5 @@ export const hydrate = (target, content) => {
|
|
|
279
285
|
target.replaceChildren(...parsed);
|
|
280
286
|
}
|
|
281
287
|
}
|
|
288
|
+
return target;
|
|
282
289
|
};
|
package/meta/global.d.ts
CHANGED
|
@@ -40,7 +40,10 @@ declare module "@vanjs/meta" {
|
|
|
40
40
|
) => null;
|
|
41
41
|
|
|
42
42
|
export const Meta: (
|
|
43
|
-
props: PropsWithKnownKeys<HTMLMetaElement> & {
|
|
43
|
+
props: PropsWithKnownKeys<HTMLMetaElement> & {
|
|
44
|
+
charset?: string & "utf-8";
|
|
45
|
+
property?: string;
|
|
46
|
+
},
|
|
44
47
|
) => null;
|
|
45
48
|
|
|
46
49
|
export const Style: (
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vite-plugin-vanjs",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.25",
|
|
4
4
|
"author": "thednp",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"description": "An async first mini meta-framework for VanJS powered by Vite",
|
|
@@ -88,14 +88,14 @@
|
|
|
88
88
|
"vanjs-ext": "^0.6.3"
|
|
89
89
|
},
|
|
90
90
|
"devDependencies": {
|
|
91
|
-
"@types/node": "^25.
|
|
92
|
-
"@vitest/browser": "^4.1.
|
|
93
|
-
"@vitest/coverage-istanbul": "^4.1.
|
|
94
|
-
"@vitest/ui": "^4.1.
|
|
95
|
-
"happy-dom": "^20.
|
|
91
|
+
"@types/node": "^25.9.3",
|
|
92
|
+
"@vitest/browser": "^4.1.8",
|
|
93
|
+
"@vitest/coverage-istanbul": "^4.1.8",
|
|
94
|
+
"@vitest/ui": "^4.1.8",
|
|
95
|
+
"happy-dom": "^20.10.3",
|
|
96
96
|
"typescript": "6.0.3",
|
|
97
|
-
"vite": "^8.0.
|
|
98
|
-
"vitest": "^4.1.
|
|
97
|
+
"vite": "^8.0.16",
|
|
98
|
+
"vitest": "^4.1.8"
|
|
99
99
|
},
|
|
100
100
|
"engines": {
|
|
101
101
|
"node": ">=20",
|
package/router/helpers.mjs
CHANGED
|
@@ -151,19 +151,22 @@ export const executeModule = async (route, wrapper, ssr) => {
|
|
|
151
151
|
if (routerState.loading === true) return;
|
|
152
152
|
// 0. Set Loading State
|
|
153
153
|
routerState.loading = true;
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
154
|
+
try {
|
|
155
|
+
// 1. Resolve the module first (to get route lifecycle hooks)
|
|
156
|
+
const module = await route.component();
|
|
157
|
+
// 2. Execute lifecycle (a complete route includes all props)
|
|
158
|
+
await executeLifecycle(Object.assign(route, module.route));
|
|
159
|
+
// 3. Resolve children
|
|
160
|
+
const children = resolveChildren(module);
|
|
161
|
+
// 4. Update <head> in the client
|
|
162
|
+
if (!isServer) updateHead();
|
|
163
|
+
// 6. Update / replace children in wrapper
|
|
164
|
+
if (ssr) return van.add(wrapper, ...children);
|
|
165
|
+
else wrapper.replaceChildren(...children);
|
|
166
|
+
} finally {
|
|
167
|
+
// 5. Set Loading State
|
|
168
|
+
routerState.loading = false;
|
|
169
|
+
}
|
|
167
170
|
};
|
|
168
171
|
|
|
169
172
|
/**
|