@vixt/react 0.12.2 → 0.13.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.
@@ -1,8 +1,8 @@
1
1
  // @ts-nocheck
2
- import routes from '~react-pages'
3
2
  import { BrowserRouter, useRoutes } from 'react-router'
4
3
  import appConfig from 'virtual:vixt:app-config'
5
4
  import { setupLayouts } from 'virtual:vixt:setup-layouts'
5
+ import routes from '~react-pages'
6
6
 
7
7
  function App() {
8
8
  const routesWithLayouts = setupLayouts(routes)
@@ -1,6 +1,5 @@
1
1
  import { defineVitePlugin } from "@vixt/core";
2
2
  import { parse } from "node:path";
3
- import { cwd } from "node:process";
4
3
  import fg from "fast-glob";
5
4
  import AutoImport from "unplugin-auto-import/vite";
6
5
  import { pascalCase } from "unplugin-vue-components";
@@ -23,7 +22,6 @@ var components_default = defineVitePlugin((options) => {
23
22
  const files = fg.sync(dirs.map((c) => `${c}/**/*.(t|j)sx`), {
24
23
  ignore: ["node_modules", ".git"],
25
24
  onlyFiles: true,
26
- cwd: cwd(),
27
25
  absolute: true
28
26
  });
29
27
  const imports = {};
@@ -14,6 +14,7 @@ var preset_react_default = defineVixtModule({
14
14
  react: {},
15
15
  pages: {
16
16
  dirs: pages,
17
+ importPath: "absolute",
17
18
  extendRoute
18
19
  },
19
20
  layouts: {
@@ -1,5 +1,8 @@
1
- import { ReactRoute } from "vite-plugin-pages";
1
+ import { CustomBlock, ParsedJSX, ReactRoute } from "vite-plugin-pages";
2
2
  //#region src/node/modules/route-block.d.ts
3
+ declare function parseJSX(code: string): ParsedJSX[];
4
+ declare function parseYamlComment(code: ParsedJSX[], path: string): CustomBlock;
5
+ declare function getRouteBlock(path: string): CustomBlock | undefined;
3
6
  declare function extendRoute(route: ReactRoute): {
4
7
  children?: ReactRoute[];
5
8
  rawRoute?: string | undefined;
@@ -9,4 +12,4 @@ declare function extendRoute(route: ReactRoute): {
9
12
  index?: boolean | undefined;
10
13
  } | undefined;
11
14
  //#endregion
12
- export { extendRoute };
15
+ export { extendRoute, getRouteBlock, parseJSX, parseYamlComment };
@@ -1,7 +1,5 @@
1
1
  import fs from "fs-extra";
2
- import { cwd } from "node:process";
3
2
  import extractComments from "extract-comments";
4
- import path from "pathe";
5
3
  import { parse } from "yaml";
6
4
  //#region src/node/modules/route-block.ts
7
5
  const routeJSXReg = /^\s+(route)\s+/gm;
@@ -24,21 +22,17 @@ function parseYamlComment(code, path) {
24
22
  }, {});
25
23
  }
26
24
  function getRouteBlock(path) {
27
- return parseYamlComment(parseJSX(fs.readFileSync(path, "utf-8")), path);
28
- }
29
- function resolveCodePath(element) {
30
- if (fs.existsSync(element)) return element;
31
- const relativePath = path.join(cwd(), element);
32
- if (fs.existsSync(relativePath)) return relativePath;
33
- return element;
25
+ const parsedJSX = parseJSX(fs.readFileSync(path, "utf-8"));
26
+ if (!parsedJSX.length) return;
27
+ return parseYamlComment(parsedJSX, path);
34
28
  }
35
29
  function extendRoute(route) {
36
30
  if (!route.element) return;
37
- const block = getRouteBlock(resolveCodePath(route.element));
31
+ const block = getRouteBlock(route.element);
38
32
  return {
39
33
  ...route,
40
34
  ...block
41
35
  };
42
36
  }
43
37
  //#endregion
44
- export { extendRoute };
38
+ export { extendRoute, getRouteBlock, parseJSX, parseYamlComment };
@@ -1,5 +1,10 @@
1
+ import { Vixt } from "@vixt/core";
1
2
  //#region src/node/modules/virtual-root-component.d.ts
3
+ declare function resolveRootComponent(vixt: Vixt): {
4
+ path: string;
5
+ code: string;
6
+ };
2
7
  declare function isEmptyCode(code?: string): boolean;
3
8
  declare const _default: import("@vixt/core").VixtModule<import("@vixt/core").ModuleOptions>;
4
9
  //#endregion
5
- export { _default as default, isEmptyCode };
10
+ export { _default as default, isEmptyCode, resolveRootComponent };
@@ -47,4 +47,4 @@ var virtual_root_component_default = defineVixtModule({
47
47
  }
48
48
  });
49
49
  //#endregion
50
- export { virtual_root_component_default as default, isEmptyCode };
50
+ export { virtual_root_component_default as default, isEmptyCode, resolveRootComponent };
package/package.json CHANGED
@@ -1,19 +1,24 @@
1
1
  {
2
2
  "name": "@vixt/react",
3
- "type": "module",
4
- "version": "0.12.2",
5
- "author": "SoulLyoko<https://github.com/SoulLyoko>",
6
- "license": "MIT",
3
+ "version": "0.13.0",
4
+ "keywords": [
5
+ "react",
6
+ "vite",
7
+ "vixt"
8
+ ],
7
9
  "homepage": "https://soullyoko.github.io/vixt/",
10
+ "license": "MIT",
11
+ "author": "SoulLyoko<https://github.com/SoulLyoko>",
8
12
  "repository": {
9
13
  "type": "git",
10
14
  "url": "https://github.com/SoulLyoko/vixt.git"
11
15
  },
12
- "keywords": [
13
- "vixt",
14
- "vite",
15
- "react"
16
+ "files": [
17
+ "dist"
16
18
  ],
19
+ "type": "module",
20
+ "main": "./dist/node/index.mjs",
21
+ "types": "./dist/types/index.d.ts",
17
22
  "exports": {
18
23
  ".": "./dist/node/index.mjs",
19
24
  "./client/App": "./src/client/App.tsx",
@@ -21,30 +26,25 @@
21
26
  "./types": "./dist/types/index.d.ts",
22
27
  "./package.json": "./package.json"
23
28
  },
24
- "main": "./dist/node/index.mjs",
25
- "types": "./dist/types/index.d.ts",
26
- "files": [
27
- "dist"
28
- ],
29
29
  "dependencies": {
30
- "@types/react": "^19.2.17",
31
- "@types/react-dom": "^19.2.3",
32
- "@vitejs/plugin-react": "^6.0.3",
30
+ "@types/react": "^19.2.18",
31
+ "@types/react-dom": "^19.2.5",
32
+ "@vitejs/plugin-react": "^6.1.0",
33
+ "@vixt/core": "0.13.0",
33
34
  "defu": "^6.1.7",
34
35
  "extract-comments": "^1.1.0",
35
36
  "fast-glob": "^3.3.3",
36
- "fs-extra": "^11.3.6",
37
+ "fs-extra": "^11.4.0",
37
38
  "mlly": "^1.8.2",
38
39
  "pathe": "^2.0.3",
39
- "react": "^19.2.7",
40
- "react-dom": "^19.2.7",
41
- "react-router": "^8.2.0",
42
- "unplugin-auto-import": "^21.0.0",
40
+ "react": "^19.2.8",
41
+ "react-dom": "^19.2.8",
42
+ "react-router": "^8.3.0",
43
+ "unplugin-auto-import": "^21.1.0",
43
44
  "unplugin-vue-components": "28.0.0",
44
- "vite": "^8.1.5",
45
+ "vite": "^8.2.2",
45
46
  "vite-plugin-pages": "^0.33.3",
46
47
  "vite-plugin-vue-layouts": "^0.11.0",
47
- "yaml": "^2.9.0",
48
- "@vixt/core": "0.12.2"
48
+ "yaml": "^2.9.0"
49
49
  }
50
50
  }