vite-plugin-vanjs 0.1.9 → 0.1.11

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 CHANGED
@@ -5,15 +5,15 @@
5
5
  [![NPM Version](https://img.shields.io/npm/v/vite-plugin-vanjs.svg)](https://www.npmjs.com/package/vite-plugin-vanjs)
6
6
  [![NPM Downloads](https://img.shields.io/npm/dm/vite-plugin-vanjs.svg)](http://npm-stat.com/charts.html?package=vite-plugin-vanjs)
7
7
  [![typescript version](https://img.shields.io/badge/typescript-5.6.2-brightgreen)](https://www.typescriptlang.org/)
8
- [![vanjs-core version](https://img.shields.io/badge/vanjs--core-1.5.5-brightgreen)](https://github.com/vanjs-org/van)
8
+ [![vanjs-core version](https://img.shields.io/badge/vanjs--core-1.6.0-brightgreen)](https://github.com/vanjs-org/van)
9
9
  [![mini-van-plate version](https://img.shields.io/badge/mini--van--plate-0.6.3-brightgreen)](https://github.com/vanjs-org/mini-van-plate)
10
- [![vitest version](https://img.shields.io/badge/vitest-3.1.3-brightgreen)](https://www.vitest.dev/)
11
- [![vite version](https://img.shields.io/badge/vite-6.3.5-brightgreen)](https://vite.dev)
10
+ [![vitest version](https://img.shields.io/badge/vitest-3.2.4-brightgreen)](https://www.vitest.dev/)
11
+ [![vite version](https://img.shields.io/badge/vite-6.4.1-brightgreen)](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;
15
15
  * ***@vanjs/meta*** - allows you to create metadata for your pages as well as load additional assets with ease;
16
- * ***@vanjs/jsx*** - enables JSX transformation;
16
+ * ***@vanjs/jsx*** - enables JSX transformation with automatic namespace resolution;
17
17
  * ***@vanjs/setup*** - enables loading VanJS modules isomorphically;
18
18
  * ***@vanjs/server*** - provides various tools for Server Side Rendering (SSR);
19
19
  * ***@vanjs/client*** - provides various tools for Client Side Rendering (CSR).
@@ -6,7 +6,7 @@ declare module "@vanjs/client" {
6
6
  } from "mini-van-plate/van-plate";
7
7
 
8
8
  /**
9
- * Sets the attribute value of the given name of the given element.
9
+ * Sets the attribute value of the given name to a given target element.
10
10
  *
11
11
  * @param element the target element
12
12
  * @param key the attribute name
@@ -18,6 +18,22 @@ declare module "@vanjs/client" {
18
18
  value: boolean | string | number | null | undefined,
19
19
  ) => void;
20
20
 
21
+ /**
22
+ * Sets the attribute value of the given name and a given namespace
23
+ * to a given target element.
24
+ *
25
+ * @param namespace the attribute/element namespace
26
+ * @param element the target element
27
+ * @param key the attribute name
28
+ * @param value the attribute value
29
+ */
30
+ export const setAttributeNS: (
31
+ namespace: string | null,
32
+ element: Element,
33
+ name: string,
34
+ value: boolean | string | number | null | undefined,
35
+ ) => void;
36
+
21
37
  /**
22
38
  * Normalize the style value and convert it to a string
23
39
  *
package/client/index.mjs CHANGED
@@ -15,6 +15,64 @@ export const setAttribute = (element, key, value) => {
15
15
  }
16
16
  };
17
17
 
18
+ /**
19
+ * Sets or removes an attribute with the specified or inferred namespace on an element.
20
+ *
21
+ * @param {string|null} ns - The namespace URI (e.g., 'http://www.w3.org/2000/svg') or null to infer from element.
22
+ * @param {Element} element - The DOM element to modify.
23
+ * @param {string} key - The attribute name (e.g., 'stroke-width', 'xlink:href').
24
+ * @param {string|boolean|null|undefined} value - The attribute value; falsy values remove the attribute.
25
+ */
26
+ export const setAttributeNS = (ns, element, key, value) => {
27
+ // Infer namespace from element if ns is null
28
+ const elementNS = ns || element.namespaceURI ||
29
+ /* istanbul ignore next - this is a required fallback */ null;
30
+
31
+ // Map attributes to specific namespaces
32
+ const attrNamespaces = {
33
+ "xlink:": "http://www.w3.org/1999/xlink", // XLink attributes (e.g., xlink:href)
34
+ "xml:": "http://www.w3.org/XML/1998/namespace", // XML attributes (e.g., xml:lang)
35
+ "xsi:": "http://www.w3.org/2001/XMLSchema-instance", // XML Schema Instance (e.g., xsi:schemaLocation)
36
+ };
37
+
38
+ // Determine attribute namespace
39
+ let attrNS = elementNS;
40
+ for (const [prefix, uri] of Object.entries(attrNamespaces)) {
41
+ if (key.startsWith(prefix)) {
42
+ attrNS = uri;
43
+ break;
44
+ }
45
+ }
46
+
47
+ if (value == null || value === false || value === "" || value === undefined) {
48
+ // Remove attribute
49
+ try {
50
+ // istanbul ignore else - case may not be covered by happy-dom?
51
+ if (attrNS && attrNS !== "null") {
52
+ // Strip prefix (e.g., xlink:href -> href)
53
+ element.removeAttributeNS(attrNS, key.replace(/^[^:]+:/, ""));
54
+ } else {
55
+ // istanbul ignore next - case may not be covered by happy-dom?
56
+ element.removeAttribute(key);
57
+ // istanbul ignore next - case may not be covered by happy-dom?
58
+ element.removeAttribute(key.replace(/^[^:]+:/, ""));
59
+ }
60
+ } catch (_e) {
61
+ // Silent fail: attribute may not exist
62
+ }
63
+ } else {
64
+ // Set attribute
65
+ const attr = value === true ? key.replace(/^[^:]+:/, "") : String(value);
66
+ try {
67
+ element.setAttributeNS(attrNS, key, attr);
68
+ } catch (_e) {
69
+ // Fallback to non-namespaced set
70
+ // istanbul ignore next - case may not be covered by happy-dom?
71
+ element.setAttribute(key, attr);
72
+ }
73
+ }
74
+ };
75
+
18
76
  /**
19
77
  * @param {import("csstype").Properties | string} style
20
78
  * @returns {string}
package/client/types.d.ts CHANGED
@@ -2,7 +2,7 @@
2
2
  import * as CSS from "csstype";
3
3
 
4
4
  /**
5
- * Sets the attribute value of the given name of the given element.
5
+ * Sets the attribute value of a given name of a given element.
6
6
  *
7
7
  * @param element the target element
8
8
  * @param key the attribute name
@@ -14,6 +14,22 @@ export const setAttribute: (
14
14
  value: boolean | string | number | null | undefined,
15
15
  ) => void;
16
16
 
17
+ /**
18
+ * Sets a namespaced attribute value of a given namespace, name and a given element.
19
+ * Fallback to regular setAttribute automatically.
20
+ *
21
+ * @param namespace the namespace string
22
+ * @param element the target element
23
+ * @param key the attribute name
24
+ * @param value the attribute value
25
+ */
26
+ export const setAttributeNS: (
27
+ namespace: string,
28
+ element: Element,
29
+ name: string,
30
+ value: boolean | string | number | null | undefined,
31
+ ) => void;
32
+
17
33
  /**
18
34
  * Normalize the style value and convert it to a string
19
35
  *
package/jsx/fragment.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import type { JSX } from "./jsx";
1
+ import type { JSX } from "./jsx.d.ts";
2
2
 
3
3
  export type FragmentProps = {
4
4
  children?: JSX.Element;
package/jsx/jsx.d.ts CHANGED
@@ -1,7 +1,12 @@
1
1
  // deno-lint-ignore-file no-empty-interface ban-types
2
2
 
3
3
  import * as csstype from "csstype";
4
- import type { Primitive, State, StateView } from "vanjs-core";
4
+ import type {
5
+ Primitive,
6
+ PropValueOrDerived,
7
+ State,
8
+ StateView,
9
+ } from "vanjs-core";
5
10
  import { Element as VElement } from "mini-van-plate/van-plate";
6
11
 
7
12
  /**
@@ -21,7 +26,7 @@ export type VanNode =
21
26
  | null
22
27
  | undefined;
23
28
 
24
- export type { Fragment } from "./fragment";
29
+ export type { Fragment } from "./fragment.d.ts";
25
30
 
26
31
  export as namespace JSX;
27
32
  export = JSX;
@@ -32,8 +37,6 @@ declare global {
32
37
  }
33
38
 
34
39
  declare namespace JSX {
35
- // type FunctionMaybe<T = unknown> = { (): T } | T;
36
- // type Element = VanNode;
37
40
  type FunctionMaybe<T = unknown> = (() => T) | StateView<T> | T | undefined;
38
41
  type Element =
39
42
  | State<Primitive | null | undefined>
@@ -41,8 +44,6 @@ declare namespace JSX {
41
44
  | DOMElement
42
45
  | HTMLElement
43
46
  | ArrayElement
44
- // | TagComponent<any>
45
- // | Component
46
47
  | FunctionElement
47
48
  | (string & {})
48
49
  | Primitive
@@ -142,8 +143,7 @@ declare namespace JSX {
142
143
  extends
143
144
  CustomAttributes<T>,
144
145
  CustomEventHandlersCamelCase<T>,
145
- CustomEventHandlersLowerCase<T>,
146
- CustomEventHandlersNamespaced<T> {
146
+ CustomEventHandlersLowerCase<T> {
147
147
  children?: Element;
148
148
  innerHTML?: string;
149
149
  innerText?: string | number;
@@ -2341,6 +2341,213 @@ declare namespace JSX {
2341
2341
  use: UseSVGAttributes<SVGUseElement>;
2342
2342
  view: ViewSVGAttributes<SVGViewElement>;
2343
2343
  }
2344
+ /** @type {MathMLElementTagNameMap} */
2345
+ interface MathMLElementTags {
2346
+ math: MathMLMathAttributes<MathMLElement>;
2347
+ mi: MathMLAnnotationAttributes<MathMLElement>;
2348
+ mn: MathMLAnnotationAttributes<MathMLElement>;
2349
+ mo: MathMLOperatorAttributes<MathMLElement>;
2350
+ ms: MathMLAnnotationAttributes<MathMLElement>;
2351
+ mtext: MathMLAnnotationAttributes<MathMLElement>;
2352
+ mspace: MathMLMspaceAttributes<MathMLElement>;
2353
+ mrow: MathMLRowAttributes<MathMLElement>;
2354
+ mfrac: MathMLFracAttributes<MathMLElement>;
2355
+ msqrt: MathMLRowAttributes<MathMLElement>;
2356
+ mroot: MathMLRowAttributes<MathMLElement>;
2357
+ mstyle: MathMLStyleAttributes<MathMLElement>;
2358
+ merror: MathMLRowAttributes<MathMLElement>;
2359
+ mpadded: MathMLPaddedAttributes<MathMLElement>;
2360
+ mphantom: MathMLRowAttributes<MathMLElement>;
2361
+ mfenced: MathMLFencedAttributes<MathMLElement>;
2362
+ mtable: MathMLTableAttributes<MathMLElement>;
2363
+ mtr: MathMLTableRowAttributes<MathMLElement>;
2364
+ mtd: MathMLTableCellAttributes<MathMLElement>;
2365
+ msub: MathMLScriptAttributes<MathMLElement>;
2366
+ msup: MathMLScriptAttributes<MathMLElement>;
2367
+ msubsup: MathMLScriptAttributes<MathMLElement>;
2368
+ mmultiscripts: MathMLMultiscriptsAttributes<MathMLElement>;
2369
+ mover: MathMLScriptAttributes<MathMLElement>;
2370
+ munder: MathMLScriptAttributes<MathMLElement>;
2371
+ munderover: MathMLScriptAttributes<MathMLElement>;
2372
+ semantics: MathMLSemanticsAttributes<MathMLElement>;
2373
+ annotation: MathMLAnnotationElementAttributes<MathMLElement>;
2374
+ "annotation-xml": MathMLAnnotationElementAttributes<MathMLElement>;
2375
+ }
2376
+
2377
+ /** MathML-specific attribute interfaces */
2378
+ interface MathMLAttributes<T> extends AriaAttributes, DOMAttributes<T> {
2379
+ class?: FunctionMaybe<string>;
2380
+ id?: FunctionMaybe<string>;
2381
+ style?: FunctionMaybe<CSSProperties | string>;
2382
+ dir?: FunctionMaybe<"ltr" | "rtl">;
2383
+ mathvariant?: FunctionMaybe<
2384
+ | "normal"
2385
+ | "bold"
2386
+ | "italic"
2387
+ | "bold-italic"
2388
+ | "double-struck"
2389
+ | "bold-fraktur"
2390
+ | "script"
2391
+ | "bold-script"
2392
+ | "fraktur"
2393
+ | "sans-serif"
2394
+ | "bold-sans-serif"
2395
+ | "sans-serif-italic"
2396
+ | "sans-serif-bold-italic"
2397
+ | "monospace"
2398
+ | "initial"
2399
+ | "tailed"
2400
+ | "looped"
2401
+ | "stretched"
2402
+ >;
2403
+ }
2404
+
2405
+ interface MathMLMathAttributes<T> extends MathMLAttributes<T> {
2406
+ display?: FunctionMaybe<"block" | "inline">;
2407
+ alttext?: FunctionMaybe<string>;
2408
+ altimg?: FunctionMaybe<string>;
2409
+ "altimg-width"?: FunctionMaybe<string>;
2410
+ "altimg-height"?: FunctionMaybe<string>;
2411
+ "altimg-valign"?: FunctionMaybe<string>;
2412
+ mathbackground?: FunctionMaybe<string>;
2413
+ mathcolor?: FunctionMaybe<string>;
2414
+ mathsize?: FunctionMaybe<string>;
2415
+ }
2416
+
2417
+ interface MathMLAnnotationAttributes<T> extends MathMLAttributes<T> {
2418
+ mathbackground?: FunctionMaybe<string>;
2419
+ mathcolor?: FunctionMaybe<string>;
2420
+ }
2421
+
2422
+ interface MathMLOperatorAttributes<T> extends MathMLAnnotationAttributes<T> {
2423
+ form?: FunctionMaybe<"prefix" | "infix" | "postfix">;
2424
+ fence?: FunctionMaybe<"true" | "false">;
2425
+ separator?: FunctionMaybe<"true" | "false">;
2426
+ lspace?: FunctionMaybe<string>;
2427
+ rspace?: FunctionMaybe<string>;
2428
+ stretchy?: FunctionMaybe<"true" | "false">;
2429
+ symmetric?: FunctionMaybe<"true" | "false">;
2430
+ maxsize?: FunctionMaybe<string>;
2431
+ minsize?: FunctionMaybe<string>;
2432
+ largeop?: FunctionMaybe<"true" | "false">;
2433
+ movablelimits?: FunctionMaybe<"true" | "false">;
2434
+ accent?: FunctionMaybe<"true" | "false">;
2435
+ }
2436
+
2437
+ interface MathMLMspaceAttributes<T> extends MathMLAnnotationAttributes<T> {
2438
+ width?: FunctionMaybe<string>;
2439
+ height?: FunctionMaybe<string>;
2440
+ depth?: FunctionMaybe<string>;
2441
+ }
2442
+
2443
+ interface MathMLRowAttributes<T> extends MathMLAnnotationAttributes<T> {}
2444
+
2445
+ interface MathMLFracAttributes<T> extends MathMLAnnotationAttributes<T> {
2446
+ linethickness?: FunctionMaybe<string>;
2447
+ numalign?: FunctionMaybe<"left" | "center" | "right">;
2448
+ denomalign?: FunctionMaybe<"left" | "center" | "right">;
2449
+ bevelled?: FunctionMaybe<"true" | "false">;
2450
+ }
2451
+
2452
+ interface MathMLStyleAttributes<T> extends MathMLAnnotationAttributes<T> {
2453
+ mathbackground?: FunctionMaybe<string>;
2454
+ mathcolor?: FunctionMaybe<string>;
2455
+ mathsize?: FunctionMaybe<string>;
2456
+ mathdepth?: FunctionMaybe<string>;
2457
+ }
2458
+
2459
+ interface MathMLPaddedAttributes<T> extends MathMLAnnotationAttributes<T> {
2460
+ width?: FunctionMaybe<string>;
2461
+ height?: FunctionMaybe<string>;
2462
+ depth?: FunctionMaybe<string>;
2463
+ lspace?: FunctionMaybe<string>;
2464
+ voffset?: FunctionMaybe<string>;
2465
+ }
2466
+
2467
+ interface MathMLFencedAttributes<T> extends MathMLAnnotationAttributes<T> {
2468
+ open?: FunctionMaybe<string>;
2469
+ close?: FunctionMaybe<string>;
2470
+ separators?: FunctionMaybe<string>;
2471
+ }
2472
+
2473
+ interface MathMLTableAttributes<T> extends MathMLAnnotationAttributes<T> {
2474
+ align?: FunctionMaybe<
2475
+ | "axis"
2476
+ | "baseline"
2477
+ | "center"
2478
+ | "top"
2479
+ | "bottom"
2480
+ | string
2481
+ >;
2482
+ rowalign?: FunctionMaybe<
2483
+ "top" | "bottom" | "center" | "baseline" | "axis"
2484
+ >;
2485
+ columnalign?: FunctionMaybe<
2486
+ "left" | "center" | "right"
2487
+ >;
2488
+ columnlines?: FunctionMaybe<
2489
+ "none" | "solid" | "dashed"
2490
+ >;
2491
+ rowlines?: FunctionMaybe<
2492
+ "none" | "solid" | "dashed"
2493
+ >;
2494
+ frame?: FunctionMaybe<
2495
+ "none" | "solid" | "dashed"
2496
+ >;
2497
+ framespacing?: FunctionMaybe<string>;
2498
+ equalrows?: FunctionMaybe<"true" | "false">;
2499
+ equalcolumns?: FunctionMaybe<"true" | "false">;
2500
+ displaystyle?: FunctionMaybe<"true" | "false">;
2501
+ side?: FunctionMaybe<"left" | "right" | "leftoverlap" | "rightoverlap">;
2502
+ minlabelspacing?: FunctionMaybe<string>;
2503
+ width?: FunctionMaybe<string>;
2504
+ }
2505
+
2506
+ interface MathMLTableRowAttributes<T> extends MathMLAnnotationAttributes<T> {
2507
+ rowalign?: FunctionMaybe<
2508
+ "top" | "bottom" | "center" | "baseline" | "axis"
2509
+ >;
2510
+ columnalign?: FunctionMaybe<
2511
+ "left" | "center" | "right"
2512
+ >;
2513
+ }
2514
+
2515
+ interface MathMLTableCellAttributes<T> extends MathMLAnnotationAttributes<T> {
2516
+ rowspan?: FunctionMaybe<number | string>;
2517
+ columnspan?: FunctionMaybe<number | string>;
2518
+ rowalign?: FunctionMaybe<
2519
+ "top" | "bottom" | "center" | "baseline" | "axis"
2520
+ >;
2521
+ columnalign?: FunctionMaybe<
2522
+ "left" | "center" | "right"
2523
+ >;
2524
+ }
2525
+
2526
+ interface MathMLScriptAttributes<T> extends MathMLAnnotationAttributes<T> {
2527
+ subscriptshift?: FunctionMaybe<string>;
2528
+ superscriptshift?: FunctionMaybe<string>;
2529
+ }
2530
+
2531
+ interface MathMLMultiscriptsAttributes<T>
2532
+ extends MathMLAnnotationAttributes<T> {
2533
+ subscriptshift?: FunctionMaybe<string>;
2534
+ superscriptshift?: FunctionMaybe<string>;
2535
+ }
2536
+
2537
+ interface MathMLSemanticsAttributes<T> extends MathMLAnnotationAttributes<T> {
2538
+ encoding?: FunctionMaybe<string>;
2539
+ src?: FunctionMaybe<string>;
2540
+ }
2541
+
2542
+ interface MathMLAnnotationElementAttributes<T>
2543
+ extends MathMLAnnotationAttributes<T> {
2544
+ encoding?: FunctionMaybe<string>;
2545
+ src?: FunctionMaybe<string>;
2546
+ }
2344
2547
  interface IntrinsicElements
2345
- extends HTMLElementTags, HTMLElementDeprecatedTags, SVGElementTags {}
2548
+ extends
2549
+ HTMLElementTags,
2550
+ HTMLElementDeprecatedTags,
2551
+ SVGElementTags,
2552
+ MathMLElementTags {}
2346
2553
  }
package/jsx/jsx.mjs CHANGED
@@ -1,22 +1,32 @@
1
+ /// <reference types="./jsx.d.ts" />
2
+
1
3
  import van from "vanjs-core";
2
4
  import isServer from "../setup/isServer.mjs";
3
- import { setAttribute, styleToString } from "../client/index.mjs";
5
+ import { setAttributeNS, styleToString } from "../client/index.mjs";
6
+ import { namespaceElements } from "./ns.mjs";
4
7
 
8
+ /**
9
+ * Compiles JSX to VanJS elements with automatic namespace resolution.
10
+ *
11
+ * @param {string|Function} jsxTag - The tag name (e.g., 'svg') or component function.
12
+ * @param {Object} props - Props including children, ref, style, and attributes.
13
+ * @returns {Element|null} The compiled VanJS element or null for invalid tags.
14
+ */
5
15
  export const jsx = (jsxTag, { children, ref, style, ...rest }) => {
6
- // filter props with undefined values
16
+ // Filter props with undefined values
7
17
  const props = Object.fromEntries(
8
18
  Object.entries(rest).filter(([_, val]) => val !== undefined),
9
19
  );
10
20
 
11
21
  if (typeof jsxTag === "string") {
12
- const newElement = van.tags[jsxTag](props, children);
22
+ const ns = namespaceElements[jsxTag];
23
+ const newElement = (ns ? van.tags(ns) : van.tags)[jsxTag](props, children);
13
24
 
25
+ // Handle style reactively
14
26
  van.derive(() => {
15
- /* istanbul ignore else */
16
27
  if (style) {
17
28
  const styleProp = typeof style === "function" ? style() : style;
18
29
  const styleValue = styleToString(styleProp);
19
-
20
30
  if (isServer) {
21
31
  newElement.propsStr += ` style="${styleValue}"`;
22
32
  } else {
@@ -25,13 +35,18 @@ export const jsx = (jsxTag, { children, ref, style, ...rest }) => {
25
35
  }
26
36
  });
27
37
 
28
- // on server it's good enough to return here
29
- if (isServer) return newElement;
38
+ // On server, apply props as string
39
+ if (isServer) {
40
+ return newElement;
41
+ }
30
42
 
31
- // on the client, we sure do need to set the attributes
43
+ // On client, apply attributes reactively
32
44
  for (const [k, value] of Object.entries(props)) {
45
+ // Use element's namespace for attributes
46
+ const attrNamespace = k === "xmlns" ? null : newElement.namespaceURI;
47
+
33
48
  if (typeof value === "function" && !k.startsWith("on")) {
34
- van.derive(() => setAttribute(newElement, k, value()));
49
+ van.derive(() => setAttributeNS(attrNamespace, newElement, k, value()));
35
50
  continue;
36
51
  }
37
52
 
@@ -41,11 +56,13 @@ export const jsx = (jsxTag, { children, ref, style, ...rest }) => {
41
56
  }
42
57
 
43
58
  if (typeof value === "object" && "val" in value) {
44
- van.derive(() => setAttribute(newElement, k, value.val));
59
+ van.derive(() =>
60
+ setAttributeNS(attrNamespace, newElement, k, value.val)
61
+ );
45
62
  continue;
46
63
  }
47
64
 
48
- setAttribute(newElement, k, value);
65
+ setAttributeNS(attrNamespace, newElement, k, value);
49
66
  }
50
67
 
51
68
  if (ref) ref.val = { current: newElement };
package/jsx/ns.mjs ADDED
@@ -0,0 +1,138 @@
1
+ // in the browser we have the Document API, is it possible to
2
+ export const namespaceElementsMap = {
3
+ "http://www.w3.org/1999/xhtml": [
4
+ // tags common with SVG
5
+ "a",
6
+ "style",
7
+ "title",
8
+ // "abbr", "address", "area", "article", "aside", "audio", "b", "base", "bdi", "bdo",
9
+ // "blockquote", "body", "br", "button", "canvas", "caption", "cite", "code", "col", "colgroup",
10
+ // "data", "datalist", "dd", "del", "details", "dfn", "dialog", "div", "dl", "dt", "em", "embed",
11
+ // "fieldset", "figcaption", "figure", "footer", "form", "h1", "h2", "h3", "h4", "h5", "h6",
12
+ // "head", "header", "hgroup", "hr", "html", "i", "iframe", "img", "input", "ins", "kbd",
13
+ // "label", "legend", "li", "link", "main", "map", "mark", "menu", "meta", "meter", "nav",
14
+ // "noscript", "object", "ol", "optgroup", "option", "output", "p", "param", "picture", "pre",
15
+ // "progress", "q", "rp", "rt", "ruby", "s", "samp", "script", "section", "select", "slot",
16
+ // "small", "source", "span", "strong",
17
+ // "sub", "summary", "sup", "table", "tbody",
18
+ // "td", "template", "textarea", "tfoot", "th", "thead", "time",
19
+ // "tr", "track", "u",
20
+ // "ul", "var", "video", "wbr"
21
+ ],
22
+ "http://www.w3.org/2000/svg": [
23
+ "svg",
24
+ "a",
25
+ "animate",
26
+ "animateMotion",
27
+ "animateTransform",
28
+ "circle",
29
+ "clipPath",
30
+ "defs",
31
+ "desc",
32
+ "ellipse",
33
+ "feBlend",
34
+ "feColorMatrix",
35
+ "feComponentTransfer",
36
+ "feComposite",
37
+ "feConvolveMatrix",
38
+ "feDiffuseLighting",
39
+ "feDisplacementMap",
40
+ "feDistantLight",
41
+ "feDropShadow",
42
+ "feFlood",
43
+ "feFuncA",
44
+ "feFuncB",
45
+ "feFuncG",
46
+ "feFuncR",
47
+ "feGaussianBlur",
48
+ "feImage",
49
+ "feMerge",
50
+ "feMergeNode",
51
+ "feMorphology",
52
+ "feOffset",
53
+ "fePointLight",
54
+ "feSpecularLighting",
55
+ "feSpotLight",
56
+ "feTile",
57
+ "feTurbulence",
58
+ "filter",
59
+ "foreignObject",
60
+ "g",
61
+ "image",
62
+ "line",
63
+ "linearGradient",
64
+ "marker",
65
+ "mask",
66
+ "metadata",
67
+ "mpath",
68
+ "path",
69
+ "pattern",
70
+ "polygon",
71
+ "polyline",
72
+ "radialGradient",
73
+ "rect",
74
+ "set",
75
+ "stop",
76
+ "style",
77
+ "switch",
78
+ "symbol",
79
+ "text",
80
+ "textPath",
81
+ "title",
82
+ "tspan",
83
+ "use",
84
+ "view",
85
+ ],
86
+ "http://www.w3.org/1998/Math/MathML": [
87
+ "math",
88
+ "maction",
89
+ "maligngroup",
90
+ "malignmark",
91
+ "menclose",
92
+ "merror",
93
+ "mfenced",
94
+ "mfrac",
95
+ "mglyph",
96
+ "mi",
97
+ "mlabeledtr",
98
+ "mmultiscripts",
99
+ "mn",
100
+ "mo",
101
+ "mover",
102
+ "mpadded",
103
+ "mphantom",
104
+ "mprescripts",
105
+ "mroot",
106
+ "mrow",
107
+ "ms",
108
+ "mspace",
109
+ "msqrt",
110
+ "mstyle",
111
+ "msub",
112
+ "msubsup",
113
+ "msup",
114
+ "mtable",
115
+ "mtd",
116
+ "mtext",
117
+ "mtr",
118
+ "munder",
119
+ "munderover",
120
+ "semantics",
121
+ "annotation",
122
+ "annotation-xml",
123
+ ],
124
+ };
125
+
126
+ /**
127
+ * Create reverse lookup for namespace elements
128
+ * @type {Record<string, string>}
129
+ */
130
+ export const namespaceElements = Object.entries(namespaceElementsMap).reduce(
131
+ (acc, [namespace, elements]) => {
132
+ elements.forEach((element) => {
133
+ if (!(element in acc)) acc[element] = namespace;
134
+ });
135
+ return acc;
136
+ },
137
+ {},
138
+ );
package/jsx/types.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  /// <reference path="global.d.ts" />
2
- import type { Fragment } from "./fragment";
2
+ import type { Fragment } from "./fragment.d.ts";
3
3
 
4
4
  declare function jsx(
5
5
  type: unknown,
@@ -12,5 +12,5 @@ declare function jsx(
12
12
  [key: string]: unknown;
13
13
  })[];
14
14
 
15
- export type { JSX } from "./jsx";
15
+ export type { JSX } from "./jsx.d.ts";
16
16
  export { Fragment, jsx, jsx as jsxDEV, jsx as jsxs };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vite-plugin-vanjs",
3
- "version": "0.1.9",
3
+ "version": "0.1.11",
4
4
  "author": "thednp",
5
5
  "license": "MIT",
6
6
  "description": "A mini meta-framework for VanJS powered by Vite",
@@ -81,22 +81,21 @@
81
81
  "vanjs-ext": "*"
82
82
  },
83
83
  "dependencies": {
84
- "csstype": "^3.1.3",
84
+ "csstype": "^3.2.3",
85
85
  "mini-van-plate": "^0.6.3",
86
- "vanjs-core": "^1.5.5",
87
- "vanjs-ext": "^0.6.2"
86
+ "vanjs-core": "^1.6.0",
87
+ "vanjs-ext": "^0.6.3"
88
88
  },
89
89
  "devDependencies": {
90
- "@types/node": "^22.15.12",
91
- "@vitest/browser": "^3.1.3",
92
- "@vitest/coverage-istanbul": "^3.1.3",
93
- "@vitest/ui": "^3.1.3",
90
+ "@types/node": "^22.19.15",
91
+ "@vitest/browser": "^3.2.4",
92
+ "@vitest/coverage-istanbul": "^3.2.4",
93
+ "@vitest/ui": "^3.2.4",
94
94
  "happy-dom": "^16.8.1",
95
95
  "typescript": "5.6.2",
96
- "vite": "^6.3.5",
97
- "vitest": "^3.1.3"
96
+ "vite": "^6.4.1",
97
+ "vitest": "^3.2.4"
98
98
  },
99
- "packageManager": "pnpm@8.6.12",
100
99
  "engines": {
101
100
  "node": ">=20",
102
101
  "pnpm": ">=8.6.0"
@@ -104,7 +103,6 @@
104
103
  "scripts": {
105
104
  "test": "vitest --config vitest.config.ts",
106
105
  "test-ui": "vitest --config vitest.config.ts --ui=true",
107
- "badges": "npx -p dependency-version-badge update-badge vanjs-core mini-van-plate typescript vitest vite",
108
106
  "format": "deno fmt plugin meta router setup client server jsx",
109
107
  "lint": "pnpm lint:ts && pnpm check:ts",
110
108
  "lint:ts": "deno lint plugin meta router setup client server jsx",
package/plugin/types.d.ts CHANGED
@@ -1,11 +1,10 @@
1
1
  // plugin/types.ts
2
- export * from "../jsx/types";
3
- export * from "../setup/types";
4
- export * from "../router/types";
5
- export * from "../meta/types";
6
- export * from "../server/types";
7
- export * from "../client/types";
8
- export * from "../parser/types";
2
+ export * from "../jsx/types.d.ts";
3
+ export * from "../setup/types.d.ts";
4
+ export * from "../router/types.d.ts";
5
+ export * from "../meta/types.d.ts";
6
+ export * from "../server/types.d.ts";
7
+ export * from "../client/types.d.ts";
9
8
  import type { PluginOption } from "vite";
10
9
 
11
10
  export type VanJSPluginOptions = {
@@ -14,7 +13,7 @@ export type VanJSPluginOptions = {
14
13
  };
15
14
 
16
15
  export declare const VitePluginVanJS: (
17
- config?: VitePluginVanJS,
16
+ config?: VanJSPluginOptions,
18
17
  ) => PluginOption<VanJSPluginOptions>;
19
18
 
20
19
  export default VitePluginVanJS;
package/router/types.d.ts CHANGED
@@ -12,7 +12,7 @@ import type {
12
12
  PropValueOrDerived,
13
13
  State,
14
14
  } from "vanjs-core";
15
- import { LayoutFile } from "../plugin/types";
15
+ import { LayoutFile } from "../plugin/types.d.ts";
16
16
 
17
17
  // type VanElement = VElement | Exclude<Primitive, boolean | undefined>;
18
18
  // type DOMElement = globalThis.Element;