Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(www): React 19 support #39

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
8 changes: 7 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,5 +53,11 @@
"prettier-plugin-tailwindcss": "^0.6.8",
"turbo": "^2.0.12"
},
"packageManager": "[email protected]"
"packageManager": "[email protected]",
"pnpm": {
"overrides": {
"@types/react": "npm:[email protected]",
"@types/react-dom": "npm:[email protected]"
}
}
}
3,006 changes: 1,499 additions & 1,507 deletions pnpm-lock.yaml

Large diffs are not rendered by default.

12 changes: 6 additions & 6 deletions www/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,14 @@
"geist": "^1.2.2",
"hast-util-to-string": "^3.0.1",
"lucide-react": "^0.311.0",
"next": "14.2.14",
"next": "15.0.0-rc.1",
"next-mdx-remote": "^4.4.1",
"next-themes": "^0.2.1",
"npm-to-yarn": "^3.0.0",
"react": "18.3.1",
"react": "19.0.0-rc-cd22717c-20241013",
"react-aria": "^3.33.0",
"react-aria-components": "^1.2.1",
"react-dom": "18.3.1",
"react-dom": "19.0.0-rc-cd22717c-20241013",
"react-resizable-panels": "^2.0.19",
"react-stately": "^3.31.0",
"remark-gfm": "^4.0.0",
Expand All @@ -68,8 +68,8 @@
"@types/estree": "^1.0.6",
"@types/mdast": "^4.0.4",
"@types/node": "^18.17.0",
"@types/react": "^18.2.37",
"@types/react-dom": "^18.2.15",
"@types/react": "npm:[email protected]",
"@types/react-dom": "npm:[email protected]",
"autoprefixer": "^10.4.14",
"postcss": "^8.4.31",
"rimraf": "^6.0.1",
Expand All @@ -79,4 +79,4 @@
"typescript": "^5",
"vfile": "^6.0.3"
}
}
}
136 changes: 68 additions & 68 deletions www/scripts/build-demos.ts
Original file line number Diff line number Diff line change
@@ -1,68 +1,68 @@
import { existsSync, promises as fs } from "node:fs";
import path from "path";
import { rimraf } from "rimraf";
import { styles } from "@/registry/styles";
import { demos } from "@/__demos__/registry";

async function buildDemos() {
let index = `// This file is autogenerated by scripts/build-registry.ts
// Do not edit this file directly.
import * as React from "react"

export const Index: Record<string, any> = {
`;

// core demos
index += ` core: {`;
for (const style of styles) {
index += ` "${style.name}": {`;

for (const item of demos) {
const resolveFiles = item.files?.map(
(file) => `registry/ui/${style.name}/${file}`
);
if (!resolveFiles) {
continue;
}
const type = "core";
let componentPath = `@/registry/ui/${style.name}/${type}/${item.name}`;
if (item.files) {
const files = item.files.map((file) =>
typeof file === "string"
? { type: "registry:page", path: file }
: file
);
if (files?.length) {
componentPath = `@/registry/ui/${style.name}/${files[0].path}`;
}
}
index += `
"${item.name}": {
name: "${item.name}",
files: [${resolveFiles.map((file) => `"${file}"`)}],
component: React.lazy(() => import("${componentPath.replace(
".tsx",
""
)}")),
},`;
}

index += `
},`;
}
index += `
},`;

index += `
}
`;

const targetPath = path.join(process.cwd(), "src", "__demos__");
if (!existsSync(targetPath)) {
await fs.mkdir(targetPath, { recursive: true });
}
rimraf.sync(path.join(targetPath, "index.tsx"));
await fs.writeFile(path.join(targetPath, "index.tsx"), index, "utf8");
}

buildDemos();
import { existsSync, promises as fs } from "node:fs";
import path from "path";
import { rimraf } from "rimraf";
import { styles } from "@/registry/styles";
import { demos } from "@/__demos__/registry";
async function buildDemos() {
let index = `// This file is autogenerated by scripts/build-registry.ts
// Do not edit this file directly.
import * as React from "react"
export const Index: Record<string, any> = {
`;
// core demos
index += ` core: {`;
for (const style of styles) {
index += ` "${style.name}": {`;
for (const item of demos) {
const resolveFiles = item.files?.map(
(file) => `registry/ui/${style.name}/${file}`
);
if (!resolveFiles) {
continue;
}
const type = "core";
let componentPath = `@/registry/ui/${style.name}/${type}/${item.name}`;
if (item.files) {
const files = item.files.map((file) =>
typeof file === "string"
? { type: "registry:page", path: file }
: file
);
if (files?.length) {
componentPath = `@/registry/ui/${style.name}/${files[0].path}`;
}
}
index += `
"${item.name}": {
name: "${item.name}",
files: [${resolveFiles.map((file) => `"${file}"`)}],
component: React.lazy(() => import("${componentPath.replace(
".tsx",
""
)}")),
},`;
}
index += `
},`;
}
index += `
},`;
index += `
}
`;
const targetPath = path.join(process.cwd(), "src", "__demos__");
if (!existsSync(targetPath)) {
await fs.mkdir(targetPath, { recursive: true });
}
rimraf.sync(path.join(targetPath, "index.tsx"));
await fs.writeFile(path.join(targetPath, "index.tsx"), index, "utf8");
}
buildDemos();
128 changes: 64 additions & 64 deletions www/scripts/build-registry-demos.ts
Original file line number Diff line number Diff line change
@@ -1,64 +1,64 @@
import { existsSync, readdirSync, promises as fs } from "node:fs";
import path from "path";
import { rimraf } from "rimraf";

async function buildRegistryDemos() {
let index = `
type RegistryDemoItem = {
name: string;
files: string[];
};

type RegistryDemos = RegistryDemoItem[];

const buildDemos = (component: string, demos: string[]): RegistryDemos => {
return demos.map((demo) => {
return {
name: \`\${component}-\${demo}\`,
files: [\`core/\${component}/demos/\${demo}.tsx\`],
};
});
};

export const demos: RegistryDemos = [
`;

const components = readdirSync(
path.join(process.cwd(), "src/registry/ui/default/core")
);
for (const component of components) {
if (
!existsSync(
path.join(
process.cwd(),
"src/registry/ui/default/core",
component,
"demos"
)
)
) {
continue;
}
const demos = readdirSync(
path.join(
process.cwd(),
"src/registry/ui/default/core",
component,
"demos"
)
);
index += ` ...buildDemos("${component}", [${demos.map(
(demo) => `"${demo.replace(".tsx", "")}"`
)}]),\n`;
}
index += `]
`;
rimraf.sync(path.join(process.cwd(), "src/__demos__/registry.ts"));
await fs.writeFile(
path.join(process.cwd(), "src/__demos__/registry.ts"),
index
);
console.log("✅ Done!");
}

buildRegistryDemos();
import { existsSync, readdirSync, promises as fs } from "node:fs";
import path from "path";
import { rimraf } from "rimraf";
async function buildRegistryDemos() {
let index = `
type RegistryDemoItem = {
name: string;
files: string[];
};
type RegistryDemos = RegistryDemoItem[];
const buildDemos = (component: string, demos: string[]): RegistryDemos => {
return demos.map((demo) => {
return {
name: \`\${component}-\${demo}\`,
files: [\`core/\${component}/demos/\${demo}.tsx\`],
};
});
};
export const demos: RegistryDemos = [
`;
const components = readdirSync(
path.join(process.cwd(), "src/registry/ui/default/core")
);
for (const component of components) {
if (
!existsSync(
path.join(
process.cwd(),
"src/registry/ui/default/core",
component,
"demos"
)
)
) {
continue;
}
const demos = readdirSync(
path.join(
process.cwd(),
"src/registry/ui/default/core",
component,
"demos"
)
);
index += ` ...buildDemos("${component}", [${demos.map(
(demo) => `"${demo.replace(".tsx", "")}"`
)}]),\n`;
}
index += `]
`;
rimraf.sync(path.join(process.cwd(), "src/__demos__/registry.ts"));
await fs.writeFile(
path.join(process.cwd(), "src/__demos__/registry.ts"),
index
);
console.log("✅ Done!");
}
buildRegistryDemos();
Loading