revine 0.9.1 → 1.0.2
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/dist/client.d.ts +8 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +4 -0
- package/dist/commands/createProject.d.ts.map +1 -1
- package/dist/commands/createProject.js +44 -3
- package/dist/components/Link.d.ts +8 -0
- package/dist/components/Link.d.ts.map +1 -0
- package/dist/components/Link.js +5 -0
- package/dist/components/NavLink.d.ts +8 -0
- package/dist/components/NavLink.d.ts.map +1 -0
- package/dist/components/NavLink.js +5 -0
- package/dist/index.js +33 -26
- package/dist/runtime/bundler/defaults/vite.d.ts +6 -0
- package/dist/runtime/bundler/defaults/vite.d.ts.map +1 -1
- package/dist/runtime/bundler/defaults/vite.js +8 -2
- package/dist/runtime/bundler/revinePlugin.d.ts +0 -7
- package/dist/runtime/bundler/revinePlugin.d.ts.map +1 -1
- package/dist/runtime/bundler/revinePlugin.js +70 -27
- package/dist/runtime/bundler/viteLoggerPlugin.d.ts.map +1 -1
- package/dist/runtime/bundler/viteLoggerPlugin.js +2 -2
- package/dist/runtime/defineConfig.d.ts +6 -0
- package/dist/runtime/defineConfig.d.ts.map +1 -0
- package/dist/runtime/defineConfig.js +3 -0
- package/dist/runtime/routing.d.ts +2 -0
- package/dist/runtime/routing.d.ts.map +1 -0
- package/dist/runtime/routing.js +1 -0
- package/dist/runtime/types.d.ts +5 -0
- package/dist/runtime/types.d.ts.map +1 -0
- package/dist/runtime/types.js +1 -0
- package/dist/setup/dependencies.d.ts.map +1 -1
- package/dist/setup/dependencies.js +1 -8
- package/package.json +7 -21
- package/src/client.ts +14 -0
- package/src/commands/createProject.ts +55 -9
- package/src/components/Link.tsx +18 -0
- package/src/components/NavLink.tsx +18 -0
- package/src/index.ts +41 -31
- package/src/runtime/bundler/defaults/vite.ts +8 -2
- package/src/runtime/bundler/revinePlugin.ts +71 -28
- package/src/runtime/bundler/viteLoggerPlugin.ts +4 -3
- package/src/runtime/defineConfig.ts +9 -0
- package/src/runtime/routing.ts +4 -0
- package/src/runtime/types.ts +5 -0
- package/src/setup/dependencies.ts +1 -9
- package/template/package.json +1 -2
- package/template/revine.config.ts +4 -2
- package/template/src/pages/index.tsx +18 -16
- package/template/src/root.tsx +2 -2
- package/tsconfig.json +4 -2
- package/dist/runtime/routing/fileBased.d.ts +0 -2
- package/dist/runtime/routing/fileBased.d.ts.map +0 -1
- package/dist/runtime/routing/fileBased.js +0 -29
- package/src/runtime/routing/fileBased.tsx +0 -46
package/README.md
CHANGED
|
@@ -58,7 +58,7 @@ src/pages/blog/[slug].tsx → /blog/:slug
|
|
|
58
58
|
### Clone repository
|
|
59
59
|
|
|
60
60
|
```bash
|
|
61
|
-
git clone https://github.com/your-username/revine.git
|
|
61
|
+
git clone [https://github.com/your-username/revine.git](https://github.com/rachit-bharadwaj/revine)
|
|
62
62
|
```
|
|
63
63
|
|
|
64
64
|
### Install dependencies
|
package/dist/client.d.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export { Outlet, RouterProvider, useLocation, useNavigate, useParams, useSearchParams } from "react-router-dom";
|
|
2
|
+
export type { NavLinkProps } from "./components/NavLink.js";
|
|
3
|
+
export { Link } from "./components/Link.js";
|
|
4
|
+
export { NavLink } from "./components/NavLink.js";
|
|
5
|
+
export { defineConfig } from "./runtime/defineConfig.js";
|
|
6
|
+
export type { LayoutProps } from "./runtime/types.js";
|
|
7
|
+
export type { LinkProps } from "./components/Link.js";
|
|
8
|
+
//# sourceMappingURL=client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,MAAM,EACN,cAAc,EACd,WAAW,EACX,WAAW,EACX,SAAS,EACT,eAAe,EAChB,MAAM,kBAAkB,CAAC;AAC1B,YAAY,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAC5D,OAAO,EAAE,IAAI,EAAE,MAAM,sBAAsB,CAAC;AAC5C,OAAO,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AAClD,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AACzD,YAAY,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACtD,YAAY,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC"}
|
package/dist/client.js
ADDED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createProject.d.ts","sourceRoot":"","sources":["../../src/commands/createProject.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"createProject.d.ts","sourceRoot":"","sources":["../../src/commands/createProject.ts"],"names":[],"mappings":"AAsDA,wBAAsB,aAAa,CACjC,WAAW,EAAE,MAAM,EACnB,OAAO,EAAE;IAAE,KAAK,CAAC,EAAE,OAAO,CAAA;CAAE,iBA6E7B"}
|
|
@@ -10,6 +10,45 @@ import { copyTemplate } from "../utils/file.js";
|
|
|
10
10
|
import { logError, logInfo } from "../utils/logger.js";
|
|
11
11
|
const __filename = fileURLToPath(import.meta.url);
|
|
12
12
|
const __dirname = path.dirname(__filename);
|
|
13
|
+
const GITIGNORE_CONTENT = `# Dependencies
|
|
14
|
+
node_modules/
|
|
15
|
+
dist/
|
|
16
|
+
dist-ssr/
|
|
17
|
+
|
|
18
|
+
# Vite cache
|
|
19
|
+
.vite/
|
|
20
|
+
*.local
|
|
21
|
+
|
|
22
|
+
# Environment files
|
|
23
|
+
.env
|
|
24
|
+
.env.local
|
|
25
|
+
.env.development.local
|
|
26
|
+
.env.test.local
|
|
27
|
+
.env.production.local
|
|
28
|
+
|
|
29
|
+
# Logs
|
|
30
|
+
npm-debug.log*
|
|
31
|
+
yarn-debug.log*
|
|
32
|
+
yarn-error.log*
|
|
33
|
+
|
|
34
|
+
# Editor/IDE
|
|
35
|
+
.vscode/
|
|
36
|
+
.idea/
|
|
37
|
+
*.swp
|
|
38
|
+
*.swo
|
|
39
|
+
|
|
40
|
+
# OS metadata
|
|
41
|
+
.DS_Store
|
|
42
|
+
Thumbs.db
|
|
43
|
+
|
|
44
|
+
# TypeScript build info
|
|
45
|
+
*.tsbuildinfo
|
|
46
|
+
|
|
47
|
+
# Optional
|
|
48
|
+
.cache/
|
|
49
|
+
.tmp/
|
|
50
|
+
.sass-cache/
|
|
51
|
+
`;
|
|
13
52
|
export async function createProject(projectName, options) {
|
|
14
53
|
// Calculate directories. This uses "../../template" for your template folder.
|
|
15
54
|
const templateDir = path.join(__dirname, "../../template");
|
|
@@ -21,6 +60,8 @@ export async function createProject(projectName, options) {
|
|
|
21
60
|
await fs.ensureDir(projectDir);
|
|
22
61
|
// This copies everything, including hidden directories like .revine
|
|
23
62
|
await copyTemplate(templateDir, projectDir, options.force);
|
|
63
|
+
// Explicitly write .gitignore because npm strips it from published tarballs
|
|
64
|
+
await fs.writeFile(path.join(projectDir, ".gitignore"), GITIGNORE_CONTENT);
|
|
24
65
|
// Derive final project name
|
|
25
66
|
const finalProjectName = isCurrentDir
|
|
26
67
|
? path.basename(projectDir)
|
|
@@ -28,12 +69,12 @@ export async function createProject(projectName, options) {
|
|
|
28
69
|
// Check if package.json exists after template copy
|
|
29
70
|
const packageJsonPath = path.join(projectDir, "package.json");
|
|
30
71
|
// Create basic package.json if it doesn't exist
|
|
31
|
-
if (!await fs.pathExists(packageJsonPath)) {
|
|
72
|
+
if (!(await fs.pathExists(packageJsonPath))) {
|
|
32
73
|
const basicPackageJson = {
|
|
33
74
|
name: finalProjectName,
|
|
34
75
|
version: "0.1.0",
|
|
35
76
|
private: true,
|
|
36
|
-
type: "module"
|
|
77
|
+
type: "module",
|
|
37
78
|
};
|
|
38
79
|
await fs.writeJSON(packageJsonPath, basicPackageJson, { spaces: 2 });
|
|
39
80
|
}
|
|
@@ -42,7 +83,7 @@ export async function createProject(projectName, options) {
|
|
|
42
83
|
await updatePackageJson(packageJsonPath, finalProjectName, { useTailwind });
|
|
43
84
|
// Check if README exists, create it if it doesn't
|
|
44
85
|
const readmePath = path.join(projectDir, "README.md");
|
|
45
|
-
if (!await fs.pathExists(readmePath)) {
|
|
86
|
+
if (!(await fs.pathExists(readmePath))) {
|
|
46
87
|
await fs.writeFile(readmePath, `# ${finalProjectName}\n\nCreated with Revine`);
|
|
47
88
|
}
|
|
48
89
|
// Update README with the project name
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { ReactNode } from "react";
|
|
2
|
+
import { type LinkProps as RouterLinkProps } from "react-router-dom";
|
|
3
|
+
export interface LinkProps extends Omit<RouterLinkProps, "to"> {
|
|
4
|
+
href: string;
|
|
5
|
+
children?: ReactNode;
|
|
6
|
+
}
|
|
7
|
+
export declare function Link({ href, children, ...rest }: LinkProps): import("react/jsx-runtime").JSX.Element;
|
|
8
|
+
//# sourceMappingURL=Link.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Link.d.ts","sourceRoot":"","sources":["../../src/components/Link.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AACvC,OAAO,EAEL,KAAK,SAAS,IAAI,eAAe,EAClC,MAAM,kBAAkB,CAAC;AAE1B,MAAM,WAAW,SAAU,SAAQ,IAAI,CAAC,eAAe,EAAE,IAAI,CAAC;IAC5D,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,CAAC,EAAE,SAAS,CAAC;CACtB;AAED,wBAAgB,IAAI,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,GAAG,IAAI,EAAE,EAAE,SAAS,2CAM1D"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { ReactNode } from "react";
|
|
2
|
+
import { type NavLinkProps as RouterNavLinkProps } from "react-router-dom";
|
|
3
|
+
export interface NavLinkProps extends Omit<RouterNavLinkProps, "to"> {
|
|
4
|
+
href: string;
|
|
5
|
+
children?: ReactNode;
|
|
6
|
+
}
|
|
7
|
+
export declare function NavLink({ href, children, ...rest }: NavLinkProps): import("react/jsx-runtime").JSX.Element;
|
|
8
|
+
//# sourceMappingURL=NavLink.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"NavLink.d.ts","sourceRoot":"","sources":["../../src/components/NavLink.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AACvC,OAAO,EAEL,KAAK,YAAY,IAAI,kBAAkB,EACxC,MAAM,kBAAkB,CAAC;AAE1B,MAAM,WAAW,YAAa,SAAQ,IAAI,CAAC,kBAAkB,EAAE,IAAI,CAAC;IAClE,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,CAAC,EAAE,SAAS,CAAC;CACtB;AAED,wBAAgB,OAAO,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,GAAG,IAAI,EAAE,EAAE,YAAY,2CAMhE"}
|
package/dist/index.js
CHANGED
|
@@ -1,48 +1,55 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { Command } from "commander";
|
|
3
|
-
import {
|
|
4
|
-
import { spawn } from "child_process";
|
|
3
|
+
import { readFileSync } from "fs";
|
|
5
4
|
import path from "path";
|
|
6
5
|
import { fileURLToPath } from "url";
|
|
6
|
+
import { createProject } from "./commands/createProject.js";
|
|
7
7
|
const __filename = fileURLToPath(import.meta.url);
|
|
8
8
|
const __dirname = path.dirname(__filename);
|
|
9
|
+
const pkgPath = path.resolve(__dirname, "../package.json");
|
|
10
|
+
const pkg = JSON.parse(readFileSync(pkgPath, "utf-8"));
|
|
9
11
|
const program = new Command();
|
|
10
|
-
// Main command handler for direct project creation
|
|
11
12
|
const handleProjectCreation = async (projectName, options) => {
|
|
12
13
|
await createProject(projectName, options);
|
|
13
14
|
};
|
|
14
|
-
|
|
15
|
-
const runViteCommand = (command) => {
|
|
16
|
-
// Path to the compiled vite.config.js in dist
|
|
15
|
+
const runViteCommand = async (command) => {
|
|
17
16
|
const configPath = path.resolve(__dirname, "runtime/bundler/vite.config.js");
|
|
18
|
-
|
|
17
|
+
// Set the config path as env variable — vite reads VITE_CONFIG_FILE
|
|
18
|
+
process.env.VITE_CONFIG_PATH = configPath;
|
|
19
|
+
// Dynamically import vite's programmatic API
|
|
20
|
+
const vitePath = path.resolve(process.cwd(), "node_modules/vite/dist/node/index.js");
|
|
21
|
+
const vite = await import(vitePath);
|
|
22
|
+
// Load the revine config
|
|
23
|
+
const { generateRevineViteConfig } = await import(path.resolve(__dirname, "runtime/bundler/generateConfig.js"));
|
|
24
|
+
const config = await generateRevineViteConfig();
|
|
19
25
|
if (command === "dev") {
|
|
20
|
-
|
|
21
|
-
|
|
26
|
+
const server = await vite.createServer({
|
|
27
|
+
...config,
|
|
28
|
+
configFile: false, // we pass config directly, no file needed
|
|
29
|
+
});
|
|
30
|
+
await server.listen();
|
|
31
|
+
server.printUrls();
|
|
22
32
|
}
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
};
|
|
28
|
-
// Main command handler for direct project creation with command check
|
|
29
|
-
const handleRootAction = async (projectName, options) => {
|
|
30
|
-
const knownCommands = ["create", "dev", "build", "preview"];
|
|
31
|
-
if (projectName && !knownCommands.includes(projectName)) {
|
|
32
|
-
await handleProjectCreation(projectName, options);
|
|
33
|
+
else if (command === "build") {
|
|
34
|
+
await vite.build({
|
|
35
|
+
...config,
|
|
36
|
+
configFile: false,
|
|
37
|
+
});
|
|
33
38
|
}
|
|
34
|
-
else if (
|
|
35
|
-
|
|
39
|
+
else if (command === "preview") {
|
|
40
|
+
const server = await vite.preview({
|
|
41
|
+
...config,
|
|
42
|
+
configFile: false,
|
|
43
|
+
});
|
|
44
|
+
server.printUrls();
|
|
36
45
|
}
|
|
37
46
|
};
|
|
38
|
-
// Root command
|
|
47
|
+
// Root command — handles: npx revine <project-name>
|
|
39
48
|
program
|
|
40
|
-
.version(
|
|
49
|
+
.version(pkg.version)
|
|
41
50
|
.argument("[project-name/command]")
|
|
42
51
|
.option("-f, --force", "Force creation in non-empty directory")
|
|
43
52
|
.action(async (arg, options) => {
|
|
44
|
-
// If it's a known command, Commander will handle it in the subcommand action.
|
|
45
|
-
// We only handle it here if it's NOT a known command.
|
|
46
53
|
const knownCommands = ["create", "dev", "build", "preview"];
|
|
47
54
|
if (arg && !knownCommands.includes(arg)) {
|
|
48
55
|
await handleProjectCreation(arg, options);
|
|
@@ -51,7 +58,7 @@ program
|
|
|
51
58
|
program.help();
|
|
52
59
|
}
|
|
53
60
|
});
|
|
54
|
-
//
|
|
61
|
+
// npx revine create <project-name>
|
|
55
62
|
program
|
|
56
63
|
.command("create")
|
|
57
64
|
.argument("<project-name>")
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vite.d.ts","sourceRoot":"","sources":["../../../../src/runtime/bundler/defaults/vite.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,iBAAiB
|
|
1
|
+
{"version":3,"file":"vite.d.ts","sourceRoot":"","sources":["../../../../src/runtime/bundler/defaults/vite.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;;;;;;;CAmB7B,CAAC"}
|
|
@@ -1,17 +1,23 @@
|
|
|
1
1
|
import react from "@vitejs/plugin-react";
|
|
2
|
-
import { revineLoggerPlugin } from "../viteLoggerPlugin.js";
|
|
3
2
|
import { revinePlugin } from "../revinePlugin.js";
|
|
3
|
+
import { revineLoggerPlugin } from "../viteLoggerPlugin.js";
|
|
4
4
|
export const defaultViteConfig = {
|
|
5
5
|
plugins: [react(), revinePlugin(), revineLoggerPlugin()],
|
|
6
6
|
logLevel: "silent",
|
|
7
7
|
server: {
|
|
8
8
|
clearScreen: false,
|
|
9
|
-
open:
|
|
9
|
+
open: false,
|
|
10
10
|
port: 3000,
|
|
11
11
|
host: true,
|
|
12
12
|
},
|
|
13
13
|
build: {
|
|
14
14
|
outDir: "build",
|
|
15
15
|
emptyOutDir: true,
|
|
16
|
+
rollupOptions: {
|
|
17
|
+
external: ["revine"],
|
|
18
|
+
},
|
|
19
|
+
},
|
|
20
|
+
optimizeDeps: {
|
|
21
|
+
exclude: ["revine"],
|
|
16
22
|
},
|
|
17
23
|
};
|
|
@@ -1,9 +1,2 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The Revine Vite plugin.
|
|
3
|
-
*
|
|
4
|
-
* Provides a virtual module for `revine/routing` so that:
|
|
5
|
-
* - `import.meta.glob` is resolved by Vite in the *project* context (not node_modules)
|
|
6
|
-
* - React runtime is resolved from the project's own node_modules
|
|
7
|
-
*/
|
|
8
1
|
export declare function revinePlugin(): any;
|
|
9
2
|
//# sourceMappingURL=revinePlugin.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"revinePlugin.d.ts","sourceRoot":"","sources":["../../../src/runtime/bundler/revinePlugin.ts"],"names":[],"mappings":"AAEA
|
|
1
|
+
{"version":3,"file":"revinePlugin.d.ts","sourceRoot":"","sources":["../../../src/runtime/bundler/revinePlugin.ts"],"names":[],"mappings":"AAEA,wBAAgB,YAAY,IAAI,GAAG,CA+GlC"}
|
|
@@ -1,58 +1,101 @@
|
|
|
1
1
|
const VIRTUAL_ROUTING_ID = "\0revine:routing";
|
|
2
|
-
/**
|
|
3
|
-
* The Revine Vite plugin.
|
|
4
|
-
*
|
|
5
|
-
* Provides a virtual module for `revine/routing` so that:
|
|
6
|
-
* - `import.meta.glob` is resolved by Vite in the *project* context (not node_modules)
|
|
7
|
-
* - React runtime is resolved from the project's own node_modules
|
|
8
|
-
*/
|
|
9
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
10
2
|
export function revinePlugin() {
|
|
11
3
|
return {
|
|
12
4
|
name: "revine",
|
|
5
|
+
enforce: "pre",
|
|
13
6
|
resolveId(id) {
|
|
14
7
|
if (id === "revine/routing") {
|
|
15
8
|
return VIRTUAL_ROUTING_ID;
|
|
16
9
|
}
|
|
17
10
|
},
|
|
18
|
-
// Return the routing source as a virtual module.
|
|
19
|
-
// Because it's virtual (not inside node_modules), Vite processes
|
|
20
|
-
// import.meta.glob and all imports normally in the project context.
|
|
21
11
|
load(id) {
|
|
22
12
|
if (id === VIRTUAL_ROUTING_ID) {
|
|
23
13
|
return `
|
|
24
14
|
import { createBrowserRouter } from "react-router-dom";
|
|
25
15
|
import { lazy, Suspense, createElement } from "react";
|
|
26
16
|
|
|
27
|
-
// Eagerly load NotFound from the project's src directory.
|
|
28
17
|
const notFoundModules = import.meta.glob("/src/NotFound.tsx", { eager: true });
|
|
29
18
|
const NotFoundComponent = Object.values(notFoundModules)[0]?.default;
|
|
30
19
|
|
|
31
|
-
// Lazily load all page components under /src/pages.
|
|
32
20
|
const pages = import.meta.glob("/src/pages/**/*.tsx");
|
|
21
|
+
const layoutModules = import.meta.glob("/src/pages/**/layout.tsx", { eager: true });
|
|
22
|
+
const loadingModules = import.meta.glob("/src/pages/**/loading.tsx", { eager: true });
|
|
33
23
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
24
|
+
function getLayoutsForPath(filePath) {
|
|
25
|
+
const parts = filePath.split("/");
|
|
26
|
+
parts.pop();
|
|
27
|
+
const layouts = [];
|
|
28
|
+
const accumulated = [];
|
|
29
|
+
for (const part of parts) {
|
|
30
|
+
accumulated.push(part);
|
|
31
|
+
const key = accumulated.join("/") + "/layout.tsx";
|
|
32
|
+
if (layoutModules[key] && layoutModules[key].default) {
|
|
33
|
+
layouts.push(layoutModules[key].default);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
return layouts;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
function getLoadingForPath(filePath) {
|
|
40
|
+
const parts = filePath.split("/");
|
|
41
|
+
parts.pop();
|
|
42
|
+
while (parts.length >= 2) {
|
|
43
|
+
const key = parts.join("/") + "/loading.tsx";
|
|
44
|
+
if (loadingModules[key] && loadingModules[key].default) {
|
|
45
|
+
return loadingModules[key].default;
|
|
46
|
+
}
|
|
47
|
+
parts.pop();
|
|
48
|
+
}
|
|
49
|
+
return null;
|
|
50
|
+
}
|
|
41
51
|
|
|
42
|
-
|
|
52
|
+
function wrapWithLayouts(element, layouts) {
|
|
53
|
+
return layouts.reduceRight((wrapped, Layout) => {
|
|
54
|
+
return createElement(Layout, null, wrapped);
|
|
55
|
+
}, element);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
function toRoutePath(filePath) {
|
|
59
|
+
let p = filePath;
|
|
60
|
+
p = p.replace(/[\\\\]/g, "/");
|
|
61
|
+
p = p.replace(/.*[/]pages[/]/, "");
|
|
62
|
+
p = p.replace(/[.]tsx$/i, "");
|
|
63
|
+
p = p.replace(/[/]index$/, "");
|
|
64
|
+
p = p.replace(/[(][^)]+[)][/]/g, "");
|
|
65
|
+
p = p.replace(/[[]([\\w]+)[\\]]/g, ":$1");
|
|
66
|
+
if (p === "index" || p === "") return "/";
|
|
67
|
+
return "/" + p;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
const pageEntries = Object.entries(pages).filter(([filePath]) => {
|
|
71
|
+
if (filePath.endsWith("/layout.tsx")) return false;
|
|
72
|
+
if (filePath.endsWith("/loading.tsx")) return false;
|
|
73
|
+
const segments = filePath.split("/");
|
|
74
|
+
return !segments.some((s) => s.startsWith("_"));
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
const routes = pageEntries.map(([filePath, component]) => {
|
|
78
|
+
const routePath = toRoutePath(filePath);
|
|
43
79
|
const Component = lazy(component);
|
|
80
|
+
const layouts = getLayoutsForPath(filePath);
|
|
81
|
+
const Loading = getLoadingForPath(filePath);
|
|
82
|
+
|
|
83
|
+
const fallback = Loading
|
|
84
|
+
? createElement(Loading)
|
|
85
|
+
: createElement("div", null, "Loading\\u2026");
|
|
86
|
+
|
|
87
|
+
const pageElement = createElement(
|
|
88
|
+
Suspense,
|
|
89
|
+
{ fallback },
|
|
90
|
+
createElement(Component)
|
|
91
|
+
);
|
|
44
92
|
|
|
45
93
|
return {
|
|
46
94
|
path: routePath,
|
|
47
|
-
element:
|
|
48
|
-
Suspense,
|
|
49
|
-
{ fallback: createElement("div", null, "Loading\u2026") },
|
|
50
|
-
createElement(Component)
|
|
51
|
-
),
|
|
95
|
+
element: layouts.length > 0 ? wrapWithLayouts(pageElement, layouts) : pageElement,
|
|
52
96
|
};
|
|
53
97
|
});
|
|
54
98
|
|
|
55
|
-
// 404 fallback
|
|
56
99
|
routes.push({
|
|
57
100
|
path: "*",
|
|
58
101
|
element: NotFoundComponent
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"viteLoggerPlugin.d.ts","sourceRoot":"","sources":["../../../src/runtime/bundler/viteLoggerPlugin.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"viteLoggerPlugin.d.ts","sourceRoot":"","sources":["../../../src/runtime/bundler/viteLoggerPlugin.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAiB,MAAM,MAAM,CAAC;AAElD,wBAAgB,kBAAkB,IAAI,MAAM,CA8B3C"}
|
|
@@ -7,13 +7,13 @@ export function revineLoggerPlugin() {
|
|
|
7
7
|
configureServer(server) {
|
|
8
8
|
server.httpServer?.once("listening", () => {
|
|
9
9
|
const protocol = server.config.server.https ? "https" : "http";
|
|
10
|
-
const
|
|
10
|
+
const localUrl = server.resolvedUrls?.local[0] || `http://localhost:3000`;
|
|
11
11
|
const { network = [] } = server.resolvedUrls ?? {};
|
|
12
12
|
// Use the 'indigo' instance in place of 'chalk.cyan'
|
|
13
13
|
console.log(indigo("─────────────────────────────────────────────"));
|
|
14
14
|
console.log(indigo.bold("🚀 Revine Dev Server is now running!"));
|
|
15
15
|
console.log(indigo("─────────────────────────────────────────────"));
|
|
16
|
-
console.log(indigo(`Local: ${chalk.green(
|
|
16
|
+
console.log(indigo(`Local: ${chalk.green(localUrl)}`));
|
|
17
17
|
if (network.length) {
|
|
18
18
|
network.forEach((url) => {
|
|
19
19
|
console.log(indigo(`Network: ${chalk.green(url)}`));
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"defineConfig.d.ts","sourceRoot":"","sources":["../../src/runtime/defineConfig.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,MAAM,CAAC;AAEvC,MAAM,WAAW,YAAY;IAC3B,IAAI,CAAC,EAAE,UAAU,CAAC;CACnB;AAED,wBAAgB,YAAY,CAAC,MAAM,EAAE,YAAY,GAAG,YAAY,CAE/D"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"routing.d.ts","sourceRoot":"","sources":["../../src/runtime/routing.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/runtime/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAEvC,MAAM,WAAW,WAAW;IAC1B,QAAQ,EAAE,SAAS,CAAC;CACrB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dependencies.d.ts","sourceRoot":"","sources":["../../src/setup/dependencies.ts"],"names":[],"mappings":"AAGA,wBAAsB,mBAAmB,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,
|
|
1
|
+
{"version":3,"file":"dependencies.d.ts","sourceRoot":"","sources":["../../src/setup/dependencies.ts"],"names":[],"mappings":"AAGA,wBAAsB,mBAAmB,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAc3E"}
|
|
@@ -6,18 +6,11 @@ export async function installDependencies(projectDir) {
|
|
|
6
6
|
const installResult = spawnSync(npmCmd, ["install"], {
|
|
7
7
|
stdio: "inherit",
|
|
8
8
|
cwd: projectDir,
|
|
9
|
-
shell:
|
|
9
|
+
shell: false,
|
|
10
10
|
});
|
|
11
11
|
if (installResult.error || installResult.status !== 0) {
|
|
12
12
|
logError("Error installing dependencies:", installResult.error);
|
|
13
13
|
logInfo("Try running manually: npm install");
|
|
14
14
|
process.exit(1);
|
|
15
15
|
}
|
|
16
|
-
// Step 2: Link local revine if available (replaces npm version with local build)
|
|
17
|
-
// This is a no-op if revine hasn't been globally linked via `npm link` in the revine repo.
|
|
18
|
-
spawnSync(npmCmd, ["link", "revine"], {
|
|
19
|
-
stdio: "pipe", // suppress output — silently skip if not linked
|
|
20
|
-
cwd: projectDir,
|
|
21
|
-
shell: true,
|
|
22
|
-
});
|
|
23
16
|
}
|
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "revine",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "1.0.2",
|
|
4
4
|
"description": "A react framework, but better.",
|
|
5
|
-
"license": "
|
|
5
|
+
"license": "MIT",
|
|
6
6
|
"author": "Rachit Bharadwaj",
|
|
7
7
|
"type": "module",
|
|
8
8
|
"main": "dist/index.js",
|
|
@@ -11,28 +11,15 @@
|
|
|
11
11
|
},
|
|
12
12
|
"exports": {
|
|
13
13
|
".": {
|
|
14
|
-
"import": "./dist/
|
|
15
|
-
"types": "./dist/
|
|
14
|
+
"import": "./dist/client.js",
|
|
15
|
+
"types": "./dist/client.d.ts"
|
|
16
16
|
},
|
|
17
17
|
"./routing": {
|
|
18
|
-
"import": "./dist/runtime/routing
|
|
19
|
-
"types": "./dist/runtime/routing
|
|
20
|
-
},
|
|
21
|
-
"./bundler/*": {
|
|
22
|
-
"import": "./dist/runtime/bundler/*.js",
|
|
23
|
-
"types": "./dist/runtime/bundler/*.d.ts"
|
|
24
|
-
}
|
|
25
|
-
},
|
|
26
|
-
"typesVersions": {
|
|
27
|
-
"*": {
|
|
28
|
-
"routing": [
|
|
29
|
-
"./dist/runtime/routing/fileBased.d.ts"
|
|
30
|
-
],
|
|
31
|
-
"bundler/*": [
|
|
32
|
-
"./dist/runtime/bundler/*.d.ts"
|
|
33
|
-
]
|
|
18
|
+
"import": "./dist/runtime/routing.js",
|
|
19
|
+
"types": "./dist/runtime/routing.d.ts"
|
|
34
20
|
}
|
|
35
21
|
},
|
|
22
|
+
"typesVersions": {},
|
|
36
23
|
"scripts": {
|
|
37
24
|
"build": "tsc",
|
|
38
25
|
"dev": "tsc -w",
|
|
@@ -42,7 +29,6 @@
|
|
|
42
29
|
"@vitejs/plugin-react": "^4.2.1",
|
|
43
30
|
"chalk": "^5.4.1",
|
|
44
31
|
"commander": "^13.1.0",
|
|
45
|
-
"cross-spawn": "^7.0.6",
|
|
46
32
|
"fs-extra": "^11.3.0",
|
|
47
33
|
"inquirer": "^12.4.1",
|
|
48
34
|
"lodash-es": "^4.17.21",
|
package/src/client.ts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export {
|
|
2
|
+
Outlet,
|
|
3
|
+
RouterProvider,
|
|
4
|
+
useLocation,
|
|
5
|
+
useNavigate,
|
|
6
|
+
useParams,
|
|
7
|
+
useSearchParams
|
|
8
|
+
} from "react-router-dom";
|
|
9
|
+
export type { NavLinkProps } from "./components/NavLink.js";
|
|
10
|
+
export { Link } from "./components/Link.js";
|
|
11
|
+
export { NavLink } from "./components/NavLink.js";
|
|
12
|
+
export { defineConfig } from "./runtime/defineConfig.js";
|
|
13
|
+
export type { LayoutProps } from "./runtime/types.js";
|
|
14
|
+
export type { LinkProps } from "./components/Link.js";
|