feat: manually mirror opencoze's code from bytedance

Change-Id: I09a73aadda978ad9511264a756b2ce51f5761adf
This commit is contained in:
fanlv
2025-07-20 17:36:12 +08:00
commit 890153324f
14811 changed files with 1923430 additions and 0 deletions

View File

@@ -0,0 +1,5 @@
const { defineConfig } = require('@coze-arch/stylelint-config');
module.exports = defineConfig({
extends: [],
});

View File

@@ -0,0 +1,6 @@
# [🦀️ Rsbuild](https://rsbuild.dev/zh/guide/start/index) & React App
Web项目初始化模板已包含功能
* react + react-router
* slardar
* less(module), [tailwindcss](https://tailwindcss.com/docs)
* vitest

View File

@@ -0,0 +1,17 @@
{
"$schema": "https://developer.microsoft.com/json-schemas/rush/v5/rush-project.schema.json",
"operationSettings": [
{
"operationName": "build",
"outputFolderNames": ["output"]
},
{
"operationName": "test:cov",
"outputFolderNames": ["coverage"]
},
{
"operationName": "ts-check",
"outputFolderNames": ["dist"]
}
]
}

View File

@@ -0,0 +1,6 @@
const { defineConfig } = require('@coze-arch/eslint-config');
module.exports = defineConfig({
preset: 'web',
packageRoot: __dirname,
});

View File

@@ -0,0 +1,12 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>{{ packageName }}</title>
</head>
<body>
<div id="root"></div>
</body>
</html>

View File

@@ -0,0 +1,12 @@
import type { IConfig } from '../../autoinstallers/plugins/node_modules/rush-init-project-plugin';
import SelectTeamPlugin from '../_plugins/SelectTeamPlugin';
import SetDefaultAuthorPlugin from '../_plugins/SetDefaultAuthorPlugin';
const config: IConfig = {
plugins: [new SetDefaultAuthorPlugin(), new SelectTeamPlugin()],
defaultProjectConfiguration: {
tags:['level-4']
}
};
export default config;

View File

@@ -0,0 +1,45 @@
{
"name": "{{ packageName }}",
"version": "0.0.1",
"private": true,
"description": "{{ description }}",
"keywords": [],
"license": "Apache-2.0",
"author": "{{ authorName }}",
"maintainers": [],
"sideEffects": false,
"scripts": {
"build": "rsbuild build",
"dev": "rsbuild dev",
"lint": "eslint ./ --cache --quiet",
"preview": "rsbuild preview",
"test": "vitest --run --passWithNoTests",
"test:cov": "vitest --run --passWithNoTests --coverage"
},
"dependencies": {
"@coze-arch/logger": "workspace:*",
"react": "~18.2.0",
"react-dom": "~18.2.0",
"react-error-boundary": "^4.0.9",
"react-router-dom": "^6.11.1",
"zustand": "^4.4.7"
},
"devDependencies": {
"@coze-arch/eslint-config": "workspace:*",
"@coze-arch/ts-config": "workspace:*",
"@coze-arch/vitest-config": "workspace:*",
"@coze-arch/stylelint-config": "workspace:*",
"@rsbuild/core": "^0.2.18",
"@rsbuild/plugin-react": "^0.2.18",
"@slardar/web": "1.7.0",
"@types/react": "18.2.37",
"@types/react-dom": "18.2.15",
"@vitest/coverage-v8": "~3.0.5",
"autoprefixer": "^10.4.16",
"postcss": "^8.4.32",
"postcss-loader": "^7.3.3",
"tailwindcss": "~3.3.3",
"vitest": "~3.0.5"
}
}

View File

@@ -0,0 +1,15 @@
import tailwindcss from 'tailwindcss';
import { pluginReact } from '@rsbuild/plugin-react';
import { defineConfig } from '@rsbuild/core';
export default defineConfig({
plugins: [pluginReact()],
html: {
template: './index.html',
},
tools: {
postcss(config) {
config.postcssOptions?.plugins?.push(tailwindcss);
},
},
});

View File

@@ -0,0 +1,24 @@
#!/usr/bin/env bash
set -ex
# Switch cwd to the project folder
cd $(dirname "$0")
# Import the utilities functions
source ../../scripts/scm_base.sh
# Clean up the build directory
rm -rf dist
rm -rf "${ROOT_DIR}"/output
# Prepare
prepare_environment
# Install the dependencies
install_project_deps
build_project
mkdir -p ${ROOT_DIR}/output
cp -r ./dist/* ${ROOT_DIR}/output/

View File

@@ -0,0 +1,44 @@
/*
* Copyright 2025 coze-dev Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { RouterProvider, createBrowserRouter } from 'react-router-dom';
import { useEffect } from 'react';
import slardar from '@slardar/web';
import { reporter } from '@coze-arch/logger';
import { Page1 } from './pages/page1';
import { MainPage } from './pages/main';
const router = createBrowserRouter([
{
path: '/',
children: [
{ path: 'page1', element: <Page1 /> },
{ path: '', element: <MainPage /> },
{ path: '*', element: <div>404</div> },
],
},
]);
export function App() {
useEffect(() => {
reporter.info({ message: 'Ok fine' });
reporter.init(slardar);
}, []);
return <RouterProvider router={router} />;
}

View File

@@ -0,0 +1,8 @@
<svg width="100%" height="100%" viewBox="-10.5 -9.45 21 18.9" fill="#357da1" xmlns="http://www.w3.org/2000/svg">
<circle cx="0" cy="0" r="2" fill="#357da1"></circle>
<g stroke="#357da1" stroke-width="1" fill="none">
<ellipse rx="10" ry="4.5"></ellipse>
<ellipse rx="10" ry="4.5" transform="rotate(60)"></ellipse>
<ellipse rx="10" ry="4.5" transform="rotate(120)"></ellipse>
</g>
</svg>

After

Width:  |  Height:  |  Size: 404 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.5 KiB

View File

@@ -0,0 +1 @@
/// <reference types="@rsbuild/core/types" />

View File

@@ -0,0 +1,8 @@
@tailwind base;
@tailwind components;
@tailwind utilities;
#root {
width: 100%;
height: 100%;
}

View File

@@ -0,0 +1,24 @@
/*
* Copyright 2025 coze-dev Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { createRoot } from 'react-dom/client';
import { App } from './app';
import './index.css';
const root = createRoot(document.getElementById('root'));
root.render(<App />);

View File

@@ -0,0 +1,4 @@
.container {
padding-top: 36px;
text-align: center;
}

View File

@@ -0,0 +1,68 @@
/*
* Copyright 2025 coze-dev Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { Link } from 'react-router-dom';
import { useState } from 'react';
import rsbuildLogo from '@/assets/rsbuild.png';
import reactLogo from '@/assets/react.svg';
import s from './index.module.less';
export function MainPage() {
const [count, setCount] = useState(0);
return (
<div className={s.container}>
<div className="flex items-center justify-center mb-12">
<a href="https://www.rsbuild.dev" target="_blank" rel="noreferrer">
<img
src={rsbuildLogo}
className="h-16 p-1.5 mr-12"
alt="Rsbuild logo"
/>
</a>
<a href="https://reactjs.org" target="_blank" rel="noreferrer">
<img
src={reactLogo}
className="h-16 p-1.5 animate-[spin_20s_linear_infinite]"
alt="React logo"
/>
</a>
</div>
<h1 className="text-3xl">Rsbuild + React</h1>
<div className="p-4">
<button
type="button"
className="p-2 mb-4 bg-blue-500 rounded-md text-slate-50"
onClick={() => setCount(c => c + 1)}
>
count is {count}
</button>
<p>
Edit <code className="text-sm font-mono">src/App.tsx</code> and save
to test HMR
</p>
</div>
<Link to="page1" className="font-light underline text-blue-600">
page1
</Link>
<p className="mt-8 text-gray-400 font-light">
Click on the Rsbuild and React logos to learn more
</p>
</div>
);
}

View File

@@ -0,0 +1,19 @@
/*
* Copyright 2025 coze-dev Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export function Page1() {
return <div>page1</div>;
}

View File

@@ -0,0 +1,5 @@
import type { Config } from 'tailwindcss';
export default {
content: ['./src/**/*.{js,jsx,ts,tsx}'],
} satisfies Config;

View File

@@ -0,0 +1,15 @@
{
"extends": "@coze-arch/ts-config/tsconfig.web.json",
"$schema": "https://json.schemastore.org/tsconfig",
"compilerOptions": {
"outDir": "dist",
"rootDir": "src",
"jsx": "react-jsx",
"lib": ["DOM", "ESNext"],
"module": "ESNext",
"target": "ES2020",
"moduleResolution": "bundler"
},
"include": ["src"],
"exclude": ["node_modules", "dist"]
}

View File

@@ -0,0 +1,15 @@
{
"$schema": "https://json.schemastore.org/tsconfig",
"exclude": ["**/*"],
"compilerOptions": {
"composite": true
},
"references": [
{
"path": "./tsconfig.build.json"
},
{
"path": "./tsconfig.misc.json"
}
]
}

View File

@@ -0,0 +1,25 @@
{
"extends": "@coze-arch/ts-config/tsconfig.web.json",
"$schema": "https://json.schemastore.org/tsconfig",
"compilerOptions": {
"rootDir": "./",
"outDir": "./dist",
"jsx": "react-jsx",
"lib": ["DOM", "ESNext"],
"module": "ESNext",
"target": "ES2020",
"moduleResolution": "bundler"
},
"include": [
"__tests__",
"vitest.config.ts",
"tailwind.config.ts",
"rsbuild.config.ts"
],
"exclude": ["./dist"],
"references": [
{
"path": "./tsconfig.build.json"
}
]
}

View File

@@ -0,0 +1,6 @@
import { defineConfig } from '@coze-arch/vitest-config';
export default defineConfig({
dirname: __dirname,
preset: 'web',
});