@vixt/react 0.11.2 → 0.12.1
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/dist/node/index.mjs +5 -11
- package/dist/node/modules/components.mjs +38 -1
- package/dist/node/modules/preset-react.mjs +38 -1
- package/dist/node/modules/route-block.mjs +11 -5
- package/dist/node/modules/virtual-root-component.mjs +6 -7
- package/package.json +10 -6
- package/dist/node/chunk-DnnnRqeS.mjs +0 -26
- package/dist/node/components-Dsb3rw2n.mjs +0 -10795
- package/dist/node/detect-acorn-CKsvmz2e.mjs +0 -370
- package/dist/node/dist-CoEoJGXV.mjs +0 -6999
- package/dist/node/lib-BJ7U9lm_.mjs +0 -1930
- package/dist/node/preset-react-BTKKeG54.mjs +0 -65
package/dist/node/index.mjs
CHANGED
|
@@ -1,13 +1,11 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { t as require_lib } from "./lib-BJ7U9lm_.mjs";
|
|
3
|
-
import { c as resolvePathSync } from "./dist-CoEoJGXV.mjs";
|
|
4
|
-
import { t as preset_react_default } from "./preset-react-BTKKeG54.mjs";
|
|
1
|
+
import preset_react_default from "./modules/preset-react.mjs";
|
|
5
2
|
import virtual_root_component_default from "./modules/virtual-root-component.mjs";
|
|
6
3
|
import virtual_setup_layouts_default from "./modules/virtual-setup-layouts.mjs";
|
|
7
4
|
import { createVixtPlugin } from "@vixt/core";
|
|
5
|
+
import fs from "fs-extra";
|
|
6
|
+
import { resolvePathSync } from "mlly";
|
|
8
7
|
//#region src/node/index.ts
|
|
9
8
|
/** @module react */
|
|
10
|
-
var import_lib = /* @__PURE__ */ __toESM(require_lib(), 1);
|
|
11
9
|
/** @hidden */
|
|
12
10
|
var node_default = createVixtPlugin({ defaults: {
|
|
13
11
|
modules: [
|
|
@@ -17,17 +15,13 @@ var node_default = createVixtPlugin({ defaults: {
|
|
|
17
15
|
],
|
|
18
16
|
app: {
|
|
19
17
|
entryFile: "main.tsx",
|
|
20
|
-
entryCode:
|
|
18
|
+
entryCode: fs.readFileSync(resolvePathSync("@vixt/react/client/entry"), "utf-8"),
|
|
21
19
|
head: { meta: [{ charset: "utf-8" }, {
|
|
22
20
|
name: "viewport",
|
|
23
21
|
content: "width=device-width, initial-scale=1.0"
|
|
24
22
|
}] }
|
|
25
23
|
},
|
|
26
|
-
imports: { imports: [
|
|
27
|
-
"react",
|
|
28
|
-
"react-router",
|
|
29
|
-
"ahooks"
|
|
30
|
-
] },
|
|
24
|
+
imports: { imports: ["react", "react-router"] },
|
|
31
25
|
typescript: { tsConfig: { compilerOptions: {
|
|
32
26
|
jsxImportSource: "react",
|
|
33
27
|
types: ["@vixt/react/types", "vite-plugin-pages/client-react"]
|
|
@@ -1,2 +1,39 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { defineVitePlugin } from "@vixt/core";
|
|
2
|
+
import { parse } from "node:path";
|
|
3
|
+
import { cwd } from "node:process";
|
|
4
|
+
import fg from "fast-glob";
|
|
5
|
+
import AutoImport from "unplugin-auto-import/vite";
|
|
6
|
+
import { pascalCase } from "unplugin-vue-components";
|
|
7
|
+
//#region src/node/modules/components.ts
|
|
8
|
+
function getNameFromFilePath(filePath, dirs) {
|
|
9
|
+
const parsedFilePath = parse(filePath);
|
|
10
|
+
let strippedPath = "";
|
|
11
|
+
for (const dir of dirs) if (parsedFilePath.dir.startsWith(dir)) {
|
|
12
|
+
strippedPath = parsedFilePath.dir.slice(dir.length);
|
|
13
|
+
break;
|
|
14
|
+
}
|
|
15
|
+
const folders = strippedPath.slice(1).split("/").filter(Boolean);
|
|
16
|
+
let filename = parsedFilePath.name;
|
|
17
|
+
if (filename === "index") filename = "";
|
|
18
|
+
filename = [...folders, filename].filter(Boolean).join("-");
|
|
19
|
+
return filename;
|
|
20
|
+
}
|
|
21
|
+
var components_default = defineVitePlugin((options) => {
|
|
22
|
+
const { dirs = ["src/components"], dts = "components.d.ts" } = options ?? {};
|
|
23
|
+
const files = fg.sync(dirs.map((c) => `${c}/**/*.(t|j)sx`), {
|
|
24
|
+
ignore: ["node_modules", ".git"],
|
|
25
|
+
onlyFiles: true,
|
|
26
|
+
cwd: cwd(),
|
|
27
|
+
absolute: true
|
|
28
|
+
});
|
|
29
|
+
const imports = {};
|
|
30
|
+
files.forEach((componentPath) => {
|
|
31
|
+
imports[componentPath] = [["default", pascalCase(getNameFromFilePath(componentPath, dirs))]];
|
|
32
|
+
});
|
|
33
|
+
return AutoImport({
|
|
34
|
+
imports,
|
|
35
|
+
dts
|
|
36
|
+
});
|
|
37
|
+
});
|
|
38
|
+
//#endregion
|
|
2
39
|
export { components_default as default };
|
|
@@ -1,2 +1,39 @@
|
|
|
1
|
-
import
|
|
1
|
+
import components_default from "./components.mjs";
|
|
2
|
+
import { extendRoute } from "./route-block.mjs";
|
|
3
|
+
import { defineVixtModule, resolveLayersDirs } from "@vixt/core";
|
|
4
|
+
import React from "@vitejs/plugin-react";
|
|
5
|
+
import defu from "defu";
|
|
6
|
+
import Pages from "vite-plugin-pages";
|
|
7
|
+
import Layouts from "vite-plugin-vue-layouts";
|
|
8
|
+
var preset_react_default = defineVixtModule({
|
|
9
|
+
meta: { name: "vixt:preset-react" },
|
|
10
|
+
setup(_, vixt) {
|
|
11
|
+
const { components = [], layouts = [], pages = [] } = resolveLayersDirs([...vixt._layers].reverse());
|
|
12
|
+
const { buildTypesDir } = vixt.options;
|
|
13
|
+
const defaultOptions = {
|
|
14
|
+
react: {},
|
|
15
|
+
pages: {
|
|
16
|
+
dirs: pages,
|
|
17
|
+
extendRoute
|
|
18
|
+
},
|
|
19
|
+
layouts: {
|
|
20
|
+
layoutsDirs: layouts,
|
|
21
|
+
pagesDirs: pages,
|
|
22
|
+
extensions: ["jsx", "tsx"],
|
|
23
|
+
importMode: () => "sync"
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
const options = vixt.options = defu(vixt.options, defaultOptions);
|
|
27
|
+
return [
|
|
28
|
+
React(options.react),
|
|
29
|
+
Pages(options.pages),
|
|
30
|
+
Layouts(options.layouts),
|
|
31
|
+
components_default({
|
|
32
|
+
dirs: components,
|
|
33
|
+
dts: `${buildTypesDir}/components.d.ts`
|
|
34
|
+
})
|
|
35
|
+
];
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
//#endregion
|
|
2
39
|
export { preset_react_default as default };
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
1
|
+
import fs from "fs-extra";
|
|
2
|
+
import { cwd } from "node:process";
|
|
3
3
|
import extractComments from "extract-comments";
|
|
4
|
+
import path from "pathe";
|
|
4
5
|
import { parse } from "yaml";
|
|
5
6
|
//#region src/node/modules/route-block.ts
|
|
6
|
-
var import_lib = /* @__PURE__ */ __toESM(require_lib(), 1);
|
|
7
7
|
const routeJSXReg = /^\s+(route)\s+/gm;
|
|
8
8
|
function parseJSX(code) {
|
|
9
9
|
return extractComments(code).slice(0, 1).filter((comment) => routeJSXReg.test(comment.value) && comment.value.includes(":") && comment.loc.start.line === 1);
|
|
@@ -24,11 +24,17 @@ function parseYamlComment(code, path) {
|
|
|
24
24
|
}, {});
|
|
25
25
|
}
|
|
26
26
|
function getRouteBlock(path) {
|
|
27
|
-
return parseYamlComment(parseJSX(
|
|
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;
|
|
28
34
|
}
|
|
29
35
|
function extendRoute(route) {
|
|
30
36
|
if (!route.element) return;
|
|
31
|
-
const block = getRouteBlock(
|
|
37
|
+
const block = getRouteBlock(resolveCodePath(route.element));
|
|
32
38
|
return {
|
|
33
39
|
...route,
|
|
34
40
|
...block
|
|
@@ -1,14 +1,13 @@
|
|
|
1
|
-
import { r as __toESM } from "../chunk-DnnnRqeS.mjs";
|
|
2
|
-
import { t as require_lib } from "../lib-BJ7U9lm_.mjs";
|
|
3
|
-
import { c as resolvePathSync, l as posix } from "../dist-CoEoJGXV.mjs";
|
|
4
1
|
import { defineVixtModule } from "@vixt/core";
|
|
2
|
+
import fs from "fs-extra";
|
|
3
|
+
import { resolvePathSync } from "mlly";
|
|
4
|
+
import path from "pathe";
|
|
5
5
|
import { parseAst } from "vite";
|
|
6
6
|
//#region src/node/modules/virtual-root-component.ts
|
|
7
|
-
var import_lib = /* @__PURE__ */ __toESM(require_lib(), 1);
|
|
8
7
|
function resolveRootComponent(vixt) {
|
|
9
8
|
for (const layer of vixt._layers) {
|
|
10
|
-
const layerRootComponentPath =
|
|
11
|
-
const layerRootComponentCode =
|
|
9
|
+
const layerRootComponentPath = path.resolve(layer.config.srcDir, "App.tsx");
|
|
10
|
+
const layerRootComponentCode = fs.existsSync(layerRootComponentPath) && fs.readFileSync(layerRootComponentPath, "utf-8") || "";
|
|
12
11
|
if (!isEmptyCode(layerRootComponentCode)) return {
|
|
13
12
|
path: layerRootComponentPath,
|
|
14
13
|
code: layerRootComponentCode
|
|
@@ -17,7 +16,7 @@ function resolveRootComponent(vixt) {
|
|
|
17
16
|
const defaultRootComponentPath = resolvePathSync("@vixt/react/client/App");
|
|
18
17
|
return {
|
|
19
18
|
path: defaultRootComponentPath,
|
|
20
|
-
code:
|
|
19
|
+
code: fs.readFileSync(defaultRootComponentPath, "utf-8")
|
|
21
20
|
};
|
|
22
21
|
}
|
|
23
22
|
function isEmptyCode(code) {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vixt/react",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.12.1",
|
|
5
5
|
"author": "SoulLyoko<https://github.com/SoulLyoko>",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"homepage": "https://soullyoko.github.io/vixt/",
|
|
@@ -29,18 +29,22 @@
|
|
|
29
29
|
"dependencies": {
|
|
30
30
|
"@types/react": "^19.2.17",
|
|
31
31
|
"@types/react-dom": "^19.2.3",
|
|
32
|
-
"@vitejs/plugin-react": "^6.0.
|
|
33
|
-
"
|
|
32
|
+
"@vitejs/plugin-react": "^6.0.3",
|
|
33
|
+
"defu": "^6.1.7",
|
|
34
34
|
"extract-comments": "^1.1.0",
|
|
35
35
|
"fast-glob": "^3.3.3",
|
|
36
|
+
"fs-extra": "^11.3.6",
|
|
37
|
+
"mlly": "^1.8.2",
|
|
38
|
+
"pathe": "^2.0.3",
|
|
36
39
|
"react": "^19.2.7",
|
|
37
40
|
"react-dom": "^19.2.7",
|
|
38
|
-
"react-router": "^
|
|
39
|
-
"
|
|
41
|
+
"react-router": "^8.1.0",
|
|
42
|
+
"unplugin-auto-import": "^21.0.0",
|
|
40
43
|
"unplugin-vue-components": "28.0.0",
|
|
44
|
+
"vite": "^8.1.2",
|
|
41
45
|
"vite-plugin-pages": "^0.33.3",
|
|
42
46
|
"vite-plugin-vue-layouts": "^0.11.0",
|
|
43
47
|
"yaml": "^2.9.0",
|
|
44
|
-
"@vixt/core": "0.
|
|
48
|
+
"@vixt/core": "0.12.1"
|
|
45
49
|
}
|
|
46
50
|
}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { createRequire } from "node:module";
|
|
2
|
-
//#region \0rolldown/runtime.js
|
|
3
|
-
var __create = Object.create;
|
|
4
|
-
var __defProp = Object.defineProperty;
|
|
5
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
8
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
|
-
var __commonJSMin = (cb, mod) => () => (mod || (cb((mod = { exports: {} }).exports, mod), cb = null), mod.exports);
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
12
|
-
key = keys[i];
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
14
|
-
get: ((k) => from[k]).bind(null, key),
|
|
15
|
-
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
16
|
-
});
|
|
17
|
-
}
|
|
18
|
-
return to;
|
|
19
|
-
};
|
|
20
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
21
|
-
value: mod,
|
|
22
|
-
enumerable: true
|
|
23
|
-
}) : target, mod));
|
|
24
|
-
var __require = /* @__PURE__ */ createRequire(import.meta.url);
|
|
25
|
-
//#endregion
|
|
26
|
-
export { __require as n, __toESM as r, __commonJSMin as t };
|