vite-plugin-vanjs 0.1.4 → 0.1.5
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 +1 -1
- package/client/index.mjs +6 -1
- package/package.json +2 -2
- package/setup/vanX-ssr.mjs +23 -5
- package/setup/vanX.mjs +2 -5
package/README.md
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
[](https://github.com/vanjs-org/van)
|
|
9
9
|
[](https://github.com/vanjs-org/mini-van-plate)
|
|
10
10
|
[](https://www.vitest.dev/)
|
|
11
|
-
[](https://vite.dev)
|
|
12
12
|
|
|
13
13
|
A mini meta-framework for [VanJS](https://vanjs.org/) developed around the awesome [vite](https://vite.dev) and tested with [vitest](https://vitest.dev). The plugin comes with a set of modules to streamline your workflow:
|
|
14
14
|
* ***@vanjs/router*** - one of the most important part of an application which allows you to split code and lazy load page like components with ease, handles both Client Side Rendering (SSR) and Server Side Rendering (CSR) and makes it really easy to work with;
|
package/client/index.mjs
CHANGED
|
@@ -106,13 +106,18 @@ function createHydrationContext() {
|
|
|
106
106
|
return parent;
|
|
107
107
|
}
|
|
108
108
|
|
|
109
|
-
/** @type {(oldDom: HTMLElement, newDom: HTMLElement) => HTMLElement} */
|
|
109
|
+
/** @type {(oldDom: HTMLElement, newDom: HTMLElement | HTMLElement[]) => HTMLElement} */
|
|
110
110
|
function diffAndHydrate(oldDom, newDom) {
|
|
111
111
|
// SPA mode
|
|
112
112
|
// istanbul ignore else
|
|
113
113
|
if (!oldDom.children.length && !elementsMatch(oldDom, newDom)) {
|
|
114
114
|
return oldDom.replaceChildren(...unwrap(newDom).children);
|
|
115
115
|
}
|
|
116
|
+
// istanbul ignore else
|
|
117
|
+
if (newDom instanceof Array) {
|
|
118
|
+
oldDom.replaceChildren(...unwrap(newDom).children);
|
|
119
|
+
return;
|
|
120
|
+
}
|
|
116
121
|
|
|
117
122
|
// SSR Mode
|
|
118
123
|
/** @type {Set<HTMLElement>} */
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vite-plugin-vanjs",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.5",
|
|
4
4
|
"author": "thednp",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"description": "A mini meta-framework for VanJS powered by Vite",
|
|
@@ -93,7 +93,7 @@
|
|
|
93
93
|
"@vitest/ui": "^3.1.2",
|
|
94
94
|
"happy-dom": "^16.8.1",
|
|
95
95
|
"typescript": "5.6.2",
|
|
96
|
-
"vite": "^6.3.
|
|
96
|
+
"vite": "^6.3.4",
|
|
97
97
|
"vitest": "^3.1.2"
|
|
98
98
|
},
|
|
99
99
|
"packageManager": "pnpm@8.6.12",
|
package/setup/vanX-ssr.mjs
CHANGED
|
@@ -1,12 +1,30 @@
|
|
|
1
1
|
import { dummyVanX, registerEnv } from "mini-van-plate/shared";
|
|
2
2
|
|
|
3
|
+
const {
|
|
4
|
+
calc,
|
|
5
|
+
compact,
|
|
6
|
+
list,
|
|
7
|
+
noreactive,
|
|
8
|
+
raw,
|
|
9
|
+
reactive,
|
|
10
|
+
replace,
|
|
11
|
+
stateFields,
|
|
12
|
+
} = dummyVanX;
|
|
13
|
+
|
|
3
14
|
const vanX = {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
15
|
+
calc,
|
|
16
|
+
compact,
|
|
17
|
+
list,
|
|
18
|
+
noreactive,
|
|
19
|
+
raw,
|
|
20
|
+
reactive,
|
|
21
|
+
replace,
|
|
22
|
+
stateFields,
|
|
8
23
|
};
|
|
9
24
|
|
|
10
25
|
registerEnv({ vanX });
|
|
11
26
|
|
|
12
|
-
export
|
|
27
|
+
export { calc, compact, list, noreactive, raw, reactive, replace, stateFields };
|
|
28
|
+
|
|
29
|
+
export { vanX as default };
|
|
30
|
+
export {};
|
package/setup/vanX.mjs
CHANGED
|
@@ -20,14 +20,11 @@ const vanX = {
|
|
|
20
20
|
list,
|
|
21
21
|
replace,
|
|
22
22
|
compact,
|
|
23
|
-
// Define default as part of the initial object
|
|
24
|
-
get default() {
|
|
25
|
-
return vanX;
|
|
26
|
-
},
|
|
27
23
|
};
|
|
28
24
|
|
|
29
25
|
// Export named exports
|
|
30
26
|
export { calc, compact, list, noreactive, raw, reactive, replace, stateFields };
|
|
31
27
|
|
|
32
28
|
// Export as default
|
|
33
|
-
export default
|
|
29
|
+
export { vanX as default };
|
|
30
|
+
export {};
|