Commit 23388ad9 authored by haiyoucuv's avatar haiyoucuv

内置工具包built-in

埋点
parent cdd98fc5
...@@ -8,6 +8,6 @@ ...@@ -8,6 +8,6 @@
</head> </head>
<body> <body>
<div id="root"></div> <div id="root"></div>
<script type="module" src="/src/main.tsx"></script> <script type="module" src="/src/index.tsx"></script>
</body> </body>
</html> </html>
{ {
"name": "@grace/built-in", "name": "@grace/built-in",
"private": true, "private": true,
"version": "0.0.1", "version": "0.0.0",
"type": "module", "type": "module",
"scripts": { "scripts": {
"dev": "vite", "dev": "vite",
......
...@@ -12,7 +12,7 @@ export default defineConfig(({ mode }): UserConfig => { ...@@ -12,7 +12,7 @@ export default defineConfig(({ mode }): UserConfig => {
build: { build: {
sourcemap: isDev, sourcemap: isDev,
lib: { lib: {
entry: "./src/main.tsx", entry: "./src/index.tsx",
name: 'builtIn', name: 'builtIn',
fileName: 'index', fileName: 'index',
}, },
...@@ -29,7 +29,7 @@ export default defineConfig(({ mode }): UserConfig => { ...@@ -29,7 +29,7 @@ export default defineConfig(({ mode }): UserConfig => {
}, },
plugins: [ plugins: [
react(), react(),
dts({ rollupTypes: true, tsconfigPath: './tsconfig.app.json' }) dts({ tsconfigPath: './tsconfig.app.json' })
], ],
css: { css: {
preprocessorOptions: { preprocessorOptions: {
......
...@@ -8,6 +8,6 @@ ...@@ -8,6 +8,6 @@
</head> </head>
<body> <body>
<div id="root"></div> <div id="root"></div>
<script type="module" src="/src/main.tsx"></script> <script type="module" src="/src/index.tsx"></script>
</body> </body>
</html> </html>
{ {
"name": "@grace/svgaplayer", "name": "@grace/svgaplayer",
"private": true, "private": true,
"version": "0.0.1", "version": "0.0.0",
"type": "module", "type": "module",
"scripts": { "scripts": {
"dev": "vite", "dev": "vite",
...@@ -15,5 +15,9 @@ ...@@ -15,5 +15,9 @@
"types": "dist/index.d.ts", "types": "dist/index.d.ts",
"dependencies": { "dependencies": {
"svga": "^2.1.1" "svga": "^2.1.1"
},
"peerDependencies": {
"react": ">=16.9.0",
"react-dom": ">=16.9.0"
} }
} }
export * from './components/SvgaPlayer' export * from './components/SvgaPlayer'
export * from './utils/loader' export * from './utils/loader'
\ No newline at end of file
{ {
"compilerOptions": {
"composite": false
},
"files": [], "files": [],
"references": [ "references": [
{ "path": "./tsconfig.app.json" }, { "path": "./tsconfig.app.json" },
......
...@@ -12,7 +12,7 @@ export default defineConfig(({ mode }): UserConfig => { ...@@ -12,7 +12,7 @@ export default defineConfig(({ mode }): UserConfig => {
build: { build: {
sourcemap: isDev, sourcemap: isDev,
lib: { lib: {
entry: "./src/main.tsx", entry: "./src/index.tsx",
name: 'SvgaPlayer', name: 'SvgaPlayer',
fileName: 'index', fileName: 'index',
}, },
...@@ -31,7 +31,7 @@ export default defineConfig(({ mode }): UserConfig => { ...@@ -31,7 +31,7 @@ export default defineConfig(({ mode }): UserConfig => {
}, },
plugins: [ plugins: [
react(), react(),
dts({ rollupTypes: true, tsconfigPath: './tsconfig.app.json' }) dts({ tsconfigPath: './tsconfig.app.json' })
], ],
css: { css: {
preprocessorOptions: { preprocessorOptions: {
......
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
lerna-debug.log*
node_modules
dist
dist-ssr
*.local
# Editor directories and files
.vscode/*
!.vscode/extensions.json
.idea
.DS_Store
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?
import js from '@eslint/js'
import globals from 'globals'
import reactHooks from 'eslint-plugin-react-hooks'
import reactRefresh from 'eslint-plugin-react-refresh'
import tseslint from 'typescript-eslint'
export default tseslint.config(
{ ignores: ['dist'] },
{
extends: [js.configs.recommended, ...tseslint.configs.recommended],
files: ['**/*.{ts,tsx}'],
languageOptions: {
ecmaVersion: 2020,
globals: globals.browser,
},
plugins: {
'react-hooks': reactHooks,
'react-refresh': reactRefresh,
},
rules: {
...reactHooks.configs.recommended.rules,
'react-refresh/only-export-components': [
'warn',
{ allowConstantExport: true },
],
},
},
)
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Vite + React + TS</title>
</head>
<body>
<div id="root"></div>
<script type="module" src="/src/index.tsx"></script>
</body>
</html>
{
"name": "@grace/ui",
"private": true,
"version": "0.0.0",
"type": "module",
"scripts": {
"dev": "vite",
"build:watch": "tsc -b && vite build -w --mode development",
"build": "tsc -b && vite build",
"lint": "eslint .",
"preview": "vite preview"
},
"main": "dist/index.cjs",
"module": "dist/index.js",
"types": "dist/index.d.ts",
"dependencies": {
"svga": "^2.1.1"
}
}
import React, { HTMLAttributes, CSSProperties, MouseEventHandler, ReactElement, useState } from "react";
export interface IBaseButtonProps {
className?: string;
}
type MergedHTMLAttributes = Omit<
HTMLAttributes<HTMLDivElement>,
'onPause'
>;
interface IButtonProps extends IBaseButtonProps, MergedHTMLAttributes {
}
/**
* @return ReactElement
* @constructor
* @param props
*/
export const Button = (props: IButtonProps): ReactElement => {
const {
children,
className,
onClick = () => void 0,
style = {}
} = props;
const [scale, setScale] = useState("unset");
const onTouchStart = () => {
setScale("scale(0.9,0.9)");
};
const onTouchEnd = () => {
setScale("unset");
};
const onTouchCancel = onTouchEnd;
return <div
className={className}
onTouchStart={onTouchStart}
onTouchEnd={onTouchEnd}
onTouchCancel={onTouchCancel}
onClick={onClick}
style={{
transitionDuration: "0.5s",
transform: scale,
...style,
}}
>
{children}
</div>;
};
/// <reference types="vite/client" />
{
"compilerOptions": {
"target": "ES2020",
"useDefineForClassFields": true,
"lib": ["ES2020", "DOM", "DOM.Iterable"],
"module": "ESNext",
"skipLibCheck": true,
/* Bundler mode */
"moduleResolution": "Bundler",
"allowImportingTsExtensions": true,
"isolatedModules": true,
"moduleDetection": "force",
"noEmit": true,
"jsx": "react-jsx",
/* Linting */
"strict": false,
"noUnusedLocals": false,
"noUnusedParameters": false,
"noFallthroughCasesInSwitch": true,
"declaration": true,
"sourceMap": true,
},
"include": ["src"]
}
{
"files": [],
"references": [
{ "path": "./tsconfig.app.json" },
{ "path": "./tsconfig.node.json" }
]
}
{
"compilerOptions": {
"target": "ES2022",
"lib": [
"ES2023",
"dom"
],
"module": "ESNext",
"skipLibCheck": true,
/* Bundler mode */
"moduleResolution": "Bundler",
"allowImportingTsExtensions": true,
"isolatedModules": true,
"moduleDetection": "force",
"noEmit": true,
/* Linting */
"strict": false,
"noUnusedLocals": true,
"noUnusedParameters": true,
"noFallthroughCasesInSwitch": true
},
"include": ["vite.config.ts"]
}
import { defineConfig, UserConfig } from 'vite'
import react from '@vitejs/plugin-react'
import dts from 'vite-plugin-dts';
// https://vite.dev/config/
export default defineConfig(({ mode }): UserConfig => {
const isDev = mode == "development";
return {
build: {
sourcemap: isDev,
lib: {
entry: "./src/index.tsx",
name: 'UI',
fileName: 'index',
},
cssTarget: 'chrome61',
rollupOptions: {
// 确保外部化处理那些你不想打包进库的依赖
external: ['react', 'react-dom', "react/jsx-runtime"],
output: {
// 在 UMD 构建模式下为这些外部化的依赖提供一个全局变量
globals: {
React: 'react',
"react-dom": 'react-dom',
},
},
},
},
plugins: [
react(),
dts({ rollupTypes: true, tsconfigPath: './tsconfig.app.json' })
],
css: {
preprocessorOptions: {
less: {
javascriptEnabled: true,
},
},
modules: {
localsConvention: 'camelCase'
}
}
}
})
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
"@csstools/normalize.css": "^12.1.1", "@csstools/normalize.css": "^12.1.1",
"@grace/built-in": "workspace:^", "@grace/built-in": "workspace:^",
"@grace/svgaplayer": "workspace:^", "@grace/svgaplayer": "workspace:^",
"@spark/ui": "^2.1.28", "@grace/ui": "workspace:^",
"@types/node": "^22.7.6", "@types/node": "^22.7.6",
"axios": "^1.7.7", "axios": "^1.7.7",
"chalk": "^5.3.0", "chalk": "^5.3.0",
......
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment