create-pnpm-cli 0.0.7 → 0.0.9

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.
Files changed (86) hide show
  1. package/package.json +1 -1
  2. package/template/webpack-typescript-react/.env.development +1 -0
  3. package/template/webpack-typescript-react/.env.production +1 -0
  4. package/template/webpack-typescript-react/.eslintrc.js +36 -0
  5. package/template/webpack-typescript-react/babel.config.js +38 -0
  6. package/template/webpack-typescript-react/package.json +63 -0
  7. package/template/webpack-typescript-react/postcss.config.js +13 -0
  8. package/template/webpack-typescript-react/prettier.config.js +8 -0
  9. package/template/webpack-typescript-react/public/img/img1.jpg +0 -0
  10. package/template/webpack-typescript-react/public/img/img10.jpg +0 -0
  11. package/template/webpack-typescript-react/public/img/img11.jpg +0 -0
  12. package/template/webpack-typescript-react/public/img/img12.jpg +0 -0
  13. package/template/webpack-typescript-react/public/img/img13.jpg +0 -0
  14. package/template/webpack-typescript-react/public/img/img14.jpg +0 -0
  15. package/template/webpack-typescript-react/public/img/img15.jpg +0 -0
  16. package/template/webpack-typescript-react/public/img/img16.jpg +0 -0
  17. package/template/webpack-typescript-react/public/img/img17.jpg +0 -0
  18. package/template/webpack-typescript-react/public/img/img18.jpg +0 -0
  19. package/template/webpack-typescript-react/public/img/img19.jpg +0 -0
  20. package/template/webpack-typescript-react/public/img/img2.jpg +0 -0
  21. package/template/webpack-typescript-react/public/img/img20.jpg +0 -0
  22. package/template/webpack-typescript-react/public/img/img21.jpg +0 -0
  23. package/template/webpack-typescript-react/public/img/img22.jpg +0 -0
  24. package/template/webpack-typescript-react/public/img/img23.jpg +0 -0
  25. package/template/webpack-typescript-react/public/img/img24.jpg +0 -0
  26. package/template/webpack-typescript-react/public/img/img25.jpg +0 -0
  27. package/template/webpack-typescript-react/public/img/img26.jpg +0 -0
  28. package/template/webpack-typescript-react/public/img/img27.jpg +0 -0
  29. package/template/webpack-typescript-react/public/img/img28.jpg +0 -0
  30. package/template/webpack-typescript-react/public/img/img29.jpg +0 -0
  31. package/template/webpack-typescript-react/public/img/img3.jpg +0 -0
  32. package/template/webpack-typescript-react/public/img/img30.jpg +0 -0
  33. package/template/webpack-typescript-react/public/img/img31.jpg +0 -0
  34. package/template/webpack-typescript-react/public/img/img32.jpg +0 -0
  35. package/template/webpack-typescript-react/public/img/img33.jpg +0 -0
  36. package/template/webpack-typescript-react/public/img/img34.jpg +0 -0
  37. package/template/webpack-typescript-react/public/img/img35.jpg +0 -0
  38. package/template/webpack-typescript-react/public/img/img36.jpg +0 -0
  39. package/template/webpack-typescript-react/public/img/img37.jpg +0 -0
  40. package/template/webpack-typescript-react/public/img/img38.jpg +0 -0
  41. package/template/webpack-typescript-react/public/img/img4.jpg +0 -0
  42. package/template/webpack-typescript-react/public/img/img5.jpg +0 -0
  43. package/template/webpack-typescript-react/public/img/img6.jpg +0 -0
  44. package/template/webpack-typescript-react/public/img/img7.jpg +0 -0
  45. package/template/webpack-typescript-react/public/img/img8.jpg +0 -0
  46. package/template/webpack-typescript-react/public/img/img9.jpg +0 -0
  47. package/template/webpack-typescript-react/scripts/data.js +60 -0
  48. package/template/webpack-typescript-react/src/config/data.ts +197 -0
  49. package/template/webpack-typescript-react/src/config/index.ts +1 -0
  50. package/template/webpack-typescript-react/src/hooks/useImagesViewer.ts +80 -0
  51. package/template/webpack-typescript-react/src/hooks/useWindowWidth.ts +24 -0
  52. package/template/webpack-typescript-react/src/index.tsx +19 -0
  53. package/template/webpack-typescript-react/src/layouts/MainLayout.tsx +9 -0
  54. package/template/webpack-typescript-react/src/layouts/index.ts +1 -0
  55. package/template/webpack-typescript-react/src/pages/home.tsx +17 -0
  56. package/template/webpack-typescript-react/src/pages/image.tsx +24 -0
  57. package/template/webpack-typescript-react/src/pages/masonry.tsx +92 -0
  58. package/template/webpack-typescript-react/src/pages/scroll-view.tsx +36 -0
  59. package/template/webpack-typescript-react/src/pages/virtual-list.tsx +27 -0
  60. package/template/webpack-typescript-react/src/routes/config.tsx +39 -0
  61. package/template/webpack-typescript-react/src/styles/global.css +6 -0
  62. package/template/webpack-typescript-react/src/templates/index.html +12 -0
  63. package/template/webpack-typescript-react/src/types/index.d.ts +4 -0
  64. package/template/webpack-typescript-react/src/utils/index.ts +17 -0
  65. package/template/webpack-typescript-react/tailwind.config.js +8 -0
  66. package/template/webpack-typescript-react/tsconfig.json +21 -0
  67. package/template/webpack-typescript-react/webpack.config.ts +94 -0
  68. package/template/zeropress/README.md +11 -0
  69. package/template/zeropress/docs/1./347/254/224/350/256/260/1./347/254/254/344/270/200/345/244/251/1./346/226/207/347/253/240.md +3 -0
  70. package/template/zeropress/docs/1./347/254/224/350/256/260/2./347/254/254/344/272/214/345/244/251/1./346/226/207/347/253/240.md +3 -0
  71. package/template/zeropress/docs/index.mdx +3 -0
  72. package/template/zeropress/package.json +21 -0
  73. package/template/zeropress/public/logo.jpg +0 -0
  74. package/template/zeropress/tsconfig.json +5 -0
  75. package/template/zeropress/zeropress.config.ts +22 -0
  76. package/template/todo-react-typescript/tsconfig.json +0 -12
  77. /package/template/{pnpm-typescript-monorepo → pnpm-monorepo-typescript}/README.md +0 -0
  78. /package/template/{pnpm-typescript-monorepo → pnpm-monorepo-typescript}/apps/examples/package.json +0 -0
  79. /package/template/{pnpm-typescript-monorepo → pnpm-monorepo-typescript}/apps/examples/tsconfig.json +0 -0
  80. /package/template/{pnpm-typescript-monorepo → pnpm-monorepo-typescript}/package.json +0 -0
  81. /package/template/{pnpm-typescript-monorepo → pnpm-monorepo-typescript}/packages/name/bin/index.js +0 -0
  82. /package/template/{pnpm-typescript-monorepo → pnpm-monorepo-typescript}/packages/name/package.json +0 -0
  83. /package/template/{pnpm-typescript-monorepo → pnpm-monorepo-typescript}/packages/name/tsconfig.json +0 -0
  84. /package/template/{pnpm-typescript-monorepo → pnpm-monorepo-typescript}/pnpm-workspace.yaml +0 -0
  85. /package/template/{pnpm-typescript-monorepo → pnpm-monorepo-typescript}/prettier.config.cjs +0 -0
  86. /package/template/{todo-react-typescript → webpack-typescript-react}/README.md +0 -0
@@ -0,0 +1,9 @@
1
+ import { Outlet } from 'react-router-dom'
2
+
3
+ export const MainLayout = () => {
4
+ return (
5
+ <div className="">
6
+ <Outlet></Outlet>
7
+ </div>
8
+ )
9
+ }
@@ -0,0 +1 @@
1
+ export * from './MainLayout'
@@ -0,0 +1,17 @@
1
+ import { routesConfig } from '@/routes/config'
2
+ import { Link } from 'react-router-dom'
3
+
4
+ export default function HomePage() {
5
+ return (
6
+ <div className="flex flex-col">
7
+ {routesConfig[0].children?.map(
8
+ (route) =>
9
+ route.path !== '/' && (
10
+ <Link key={route.path} to={route.path || '/'}>
11
+ {route.path?.slice(1)}
12
+ </Link>
13
+ ),
14
+ )}
15
+ </div>
16
+ )
17
+ }
@@ -0,0 +1,24 @@
1
+ import { dataConfig } from '@/config'
2
+ import { getImageData } from '@/utils'
3
+ import { Image } from 'high-order-ui'
4
+
5
+ export default function ImagePage() {
6
+ const img = dataConfig[0].imgs[0]
7
+ const { width, height, blurhash } = getImageData(img)
8
+
9
+ return (
10
+ <>
11
+ hash占位
12
+ <Image
13
+ width={width}
14
+ height={height}
15
+ blurhash={blurhash}
16
+ src={img}
17
+ ></Image>
18
+ 图片占位
19
+ <Image width={width} height={height} src={img}>
20
+ <div className="w-full h-full bg-gradient-to-r from-purple-500 to-pink-500"></div>
21
+ </Image>
22
+ </>
23
+ )
24
+ }
@@ -0,0 +1,92 @@
1
+ import { DataType, dataConfig } from '@/config'
2
+ import { useImagesViewer } from '@/hooks/useImagesViewer'
3
+ import { useWindowWidth } from '@/hooks/useWindowWidth'
4
+ import { getImageData } from '@/utils'
5
+ import { Image, Masonry } from 'high-order-ui'
6
+ import { FunctionComponent, HtmlHTMLAttributes, memo, useState } from 'react'
7
+
8
+ const initialData = dataConfig.map((i) => {
9
+ const { height, width } = getImageData(i.imgs[0])
10
+
11
+ return {
12
+ data: i,
13
+ itemHeight: ((height ?? 0) / (width ?? 0)) * 100, // 需求精准排列时再计算文字高度
14
+ }
15
+ })
16
+
17
+ export default function MasonryPage() {
18
+ const [data, setData] = useState(initialData)
19
+
20
+ // TODO 使用ResizeObserver api
21
+ const windowWidth = useWindowWidth()
22
+
23
+ const getColumn = (
24
+ windowWidth: number,
25
+ response: [number, number, number],
26
+ ) => {
27
+ if (windowWidth < response[0]) {
28
+ return 2
29
+ } else if (windowWidth < response[1]) {
30
+ return 3
31
+ } else if (windowWidth < response[2]) {
32
+ return 4
33
+ } else {
34
+ return 5
35
+ }
36
+ }
37
+
38
+ return (
39
+ <Masonry
40
+ className="p-[20px] h-screen"
41
+ scrollCallbackRange={700}
42
+ onScrollToFooter={() => {
43
+ setData((pre) => [...pre, ...initialData])
44
+ }}
45
+ items={data}
46
+ renderItem={(item) => (
47
+ <Card key={item._id} className="mb-[15px]" value={item}></Card>
48
+ )}
49
+ columnCount={getColumn(windowWidth, [400, 800, 1200])}
50
+ columnSpace={14}
51
+ ></Masonry>
52
+ )
53
+ }
54
+
55
+ // ---
56
+
57
+ type CardProps = HtmlHTMLAttributes<HTMLDivElement> & {
58
+ value: DataType
59
+ }
60
+
61
+ const Card: FunctionComponent<CardProps> = memo(({ value, ...rest }) => {
62
+ const { height, width, blurhash } = getImageData(value.imgs[0])
63
+
64
+ const { view } = useImagesViewer({
65
+ max: 10,
66
+ options: {
67
+ title: false,
68
+ toggleOnDblclick: false,
69
+ slideOnTouch: false,
70
+ },
71
+ })
72
+
73
+ return (
74
+ <div {...rest}>
75
+ <Image
76
+ onClick={() => {
77
+ view(value.imgs)
78
+ }}
79
+ className="w-full rounded-[16px] mb-[10px] overflow-hidden"
80
+ src={value.imgs[0]}
81
+ alt="封面图"
82
+ width={width}
83
+ height={height}
84
+ blurhash={blurhash}
85
+ ></Image>
86
+
87
+ <span className="text-[#333333] text-[14px] leading-[20px] font-normal">
88
+ {value.name}
89
+ </span>
90
+ </div>
91
+ )
92
+ })
@@ -0,0 +1,36 @@
1
+ import { ScrollView } from 'high-order-ui'
2
+
3
+ export default function ScrollViewPage() {
4
+ return (
5
+ <>
6
+ ↑↓
7
+ <ScrollView
8
+ className="w-full h-[200px]"
9
+ isSmooth
10
+ scrollToPosition={1000}
11
+ onScrollToFooter={() => {
12
+ alert('footer')
13
+ }}
14
+ onScrollToHeader={() => {
15
+ alert('header')
16
+ }}
17
+ >
18
+ <div className="border-4 border-dashed w-full h-[5000px] bg-gradient-to-b from-cyan-500 to-blue-500"></div>
19
+ </ScrollView>
20
+ ←→
21
+ <ScrollView
22
+ scrollDirection="horizontal"
23
+ scrollToPosition={1000}
24
+ onScrollToFooter={() => {
25
+ alert('footer')
26
+ }}
27
+ onScrollToHeader={() => {
28
+ alert('header')
29
+ }}
30
+ className="w-full h-[200px]"
31
+ >
32
+ <div className="border-4 border-dashed w-[5000px] h-full bg-gradient-to-r from-purple-500 to-pink-500"></div>
33
+ </ScrollView>
34
+ </>
35
+ )
36
+ }
@@ -0,0 +1,27 @@
1
+ import { dataConfig } from '@/config'
2
+ import { VirtualList } from 'high-order-ui'
3
+
4
+ export default function VirtualListPage() {
5
+ return (
6
+ <VirtualList
7
+ className="h-screen"
8
+ onScrollToFooter={() => {
9
+ alert('footer')
10
+ }}
11
+ onScrollToHeader={() => {
12
+ alert('header')
13
+ }}
14
+ items={dataConfig.map((item, index) => ({
15
+ data: item,
16
+ itemHeight: 40 + index * 3,
17
+ }))}
18
+ renderItem={(item) => {
19
+ return (
20
+ <div key={item._id} className="border-b border-black h-full">
21
+ {item.name}
22
+ </div>
23
+ )
24
+ }}
25
+ ></VirtualList>
26
+ )
27
+ }
@@ -0,0 +1,39 @@
1
+ import { MainLayout } from '@/layouts'
2
+ import { lazy } from 'react'
3
+ import { RouteObject } from 'react-router-dom'
4
+
5
+ // 使用普通lazy写法 https://github.com/remix-run/react-router/tree/main/examples/lazy-loading,虽然用了RouterProvider,但是RouterProvider写法比较杂乱且有类型风险,暂时不采用https://github.com/remix-run/react-router/issues/10475
6
+ const HomePage = lazy(() => import('@/pages/home'))
7
+ const ImagePage = lazy(() => import('@/pages/image'))
8
+ const MasonryPage = lazy(() => import('@/pages/masonry'))
9
+ const ScrollViewPage = lazy(() => import('@/pages/scroll-view'))
10
+ const VirtualListPage = lazy(() => import('@/pages/virtual-list'))
11
+
12
+ export const routesConfig: RouteObject[] = [
13
+ {
14
+ path: '/',
15
+ element: <MainLayout></MainLayout>,
16
+ children: [
17
+ {
18
+ path: '/',
19
+ element: <HomePage></HomePage>,
20
+ },
21
+ {
22
+ path: '/masonry',
23
+ element: <MasonryPage></MasonryPage>,
24
+ },
25
+ {
26
+ path: '/scroll-view',
27
+ element: <ScrollViewPage></ScrollViewPage>,
28
+ },
29
+ {
30
+ path: '/image',
31
+ element: <ImagePage></ImagePage>,
32
+ },
33
+ {
34
+ path: '/virtual-list',
35
+ element: <VirtualListPage></VirtualListPage>,
36
+ },
37
+ ],
38
+ },
39
+ ]
@@ -0,0 +1,6 @@
1
+ @tailwind base;
2
+ @tailwind components;
3
+ @tailwind utilities;
4
+
5
+ body {
6
+ }
@@ -0,0 +1,12 @@
1
+ <!doctype html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="UTF-8" />
5
+ <meta http-equiv="X-UA-Compatible" content="IE=edge" />
6
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />
7
+ <title>examples</title>
8
+ </head>
9
+ <body>
10
+ <div id="root"></div>
11
+ </body>
12
+ </html>
@@ -0,0 +1,4 @@
1
+ declare module '*.jpg' {
2
+ const value: string
3
+ export = value
4
+ }
@@ -0,0 +1,17 @@
1
+ import queryString from 'query-string'
2
+
3
+ export const isBrowser = !!(
4
+ typeof window !== 'undefined' &&
5
+ window.document &&
6
+ window.document.createElement
7
+ )
8
+
9
+ export const getImageData = (str: string) => {
10
+ const { query } = queryString.parseUrl(str, { decode: false })
11
+
12
+ return {
13
+ width: parseInt(query.width as string),
14
+ height: parseInt(query.height as string),
15
+ blurhash: decodeURIComponent(query.blurhash as string),
16
+ }
17
+ }
@@ -0,0 +1,8 @@
1
+ /** @type {import('tailwindcss').Config} */
2
+ module.exports = {
3
+ content: ['./src/**/*.{tsx,ts,jsx,js}'],
4
+ theme: {
5
+ extend: {},
6
+ },
7
+ plugins: [],
8
+ }
@@ -0,0 +1,21 @@
1
+ {
2
+ /* ts-node为webpack提供webpack.config.ts的打包产物webpack.config.js https://webpack.js.org/configuration/configuration-languages/*/
3
+ "ts-node": {
4
+ "compilerOptions": {
5
+ "module": "CommonJS"
6
+ }
7
+ },
8
+ "compilerOptions": {
9
+ "strict": true,
10
+ "skipLibCheck": true,
11
+ "jsx": "react-jsx",
12
+ "target": "ESNext",
13
+ "moduleResolution": "Node",
14
+ "resolveJsonModule": true,
15
+ "esModuleInterop": true,
16
+ "baseUrl": ".",
17
+ "paths": {
18
+ "@/*": ["./src/*"]
19
+ }
20
+ }
21
+ }
@@ -0,0 +1,94 @@
1
+ import ReactRefreshWebpackPlugin from '@pmmmwh/react-refresh-webpack-plugin'
2
+ import BlurhashWebpackPlugin from 'blurhash-webpack-plugin'
3
+ import { config } from 'dotenv'
4
+ import HtmlWebpackPlugin from 'html-webpack-plugin'
5
+ import MiniCssExtractPlugin from 'mini-css-extract-plugin'
6
+ import path from 'path'
7
+ import TsconfigPathsPlugin from 'tsconfig-paths-webpack-plugin'
8
+ import { DefinePlugin } from 'webpack'
9
+ import { WebpackConfiguration } from 'webpack-dev-server'
10
+
11
+ const isDevelopment = process.env.NODE_ENV !== 'production'
12
+
13
+ const env = config({
14
+ path: path.join(__dirname, `./.env.${process.env.NODE_ENV}`),
15
+ })
16
+
17
+ if (env.error) {
18
+ console.error('环境变量读取失败')
19
+ process.exit(1)
20
+ }
21
+
22
+ // 用WebpackConfiguration是因为配置中配置了devServer
23
+ const webpackConfig: WebpackConfiguration = {
24
+ mode: isDevelopment ? 'development' : 'production',
25
+ entry: path.join(__dirname, './src/index.tsx'),
26
+ output: {
27
+ path: path.join(__dirname, './dist'),
28
+ filename: '[name].[contenthash:8].js',
29
+ chunkFilename: '[id].[contenthash:8].js',
30
+ clean: true,
31
+ hashFunction: 'xxhash64',
32
+ },
33
+ resolve: {
34
+ extensions: ['.js', '.mjs', '.cjs', '.jsx', '.ts', '.tsx'],
35
+ plugins: [new TsconfigPathsPlugin()],
36
+ },
37
+
38
+ optimization: {
39
+ // 最小化 __webpack_require__.u 内容改变的影响,分离webpack runtime文件
40
+ runtimeChunk: {
41
+ name: 'runtime',
42
+ },
43
+ // 分包
44
+ splitChunks: {
45
+ chunks: 'all',
46
+ },
47
+ },
48
+ module: {
49
+ rules: [
50
+ {
51
+ test: /\.css$/,
52
+ use: [
53
+ isDevelopment ? 'style-loader' : MiniCssExtractPlugin.loader,
54
+ 'css-loader',
55
+ 'postcss-loader',
56
+ ],
57
+ },
58
+ {
59
+ test: /\.(jsx?|mjs|cjs|tsx?)$/,
60
+ exclude: /node_modules/,
61
+ include: path.join(__dirname, 'src'),
62
+ use: ['babel-loader', 'thread-loader'],
63
+ },
64
+ {
65
+ test: /\.(png|jpe?g|gif|svg|webp)$/,
66
+ type: 'asset/resource',
67
+ },
68
+ ],
69
+ },
70
+ plugins: [
71
+ new DefinePlugin({ 'process.env': JSON.stringify(env.parsed) }),
72
+ new HtmlWebpackPlugin({
73
+ template: path.join(__dirname, './src/templates/index.html'),
74
+ }),
75
+ new MiniCssExtractPlugin({
76
+ filename: '[name].[contenthash:8].css',
77
+ }),
78
+ isDevelopment && new ReactRefreshWebpackPlugin(),
79
+ new BlurhashWebpackPlugin(),
80
+ ].filter(Boolean),
81
+ devServer: {
82
+ static: {
83
+ directory: path.join(__dirname, './public'), //托管静态资源public文件夹
84
+ },
85
+ port: 9001,
86
+ compress: false,
87
+ headers: {
88
+ 'Access-Control-Allow-Origin': '*',
89
+ },
90
+ historyApiFallback: true,
91
+ },
92
+ }
93
+
94
+ export default webpackConfig
@@ -0,0 +1,11 @@
1
+ # zeropress模板
2
+
3
+ 在docs文件夹中直接新建文件夹
4
+
5
+ 第一层为nav,第二层为sidebar,第三层为md文件
6
+
7
+ 支持全中文路径
8
+
9
+ 使用1或者1.自动排序
10
+
11
+ 预览暂时使用npm run serve
@@ -0,0 +1,3 @@
1
+ ---
2
+ pageType: home
3
+ ---
@@ -0,0 +1,21 @@
1
+ {
2
+ "name": "zeropress",
3
+ "description": "",
4
+ "scripts": {
5
+ "build": "zeropress build",
6
+ "serve": "npm run build && serve ./dist"
7
+ },
8
+ "keywords": [],
9
+ "author": "",
10
+ "license": "ISC",
11
+ "dependencies": {
12
+ "react": "^18.2.0",
13
+ "react-dom": "^18.2.0"
14
+ },
15
+ "devDependencies": {
16
+ "@types/react": "^18.2.43",
17
+ "@types/react-dom": "^18.2.17",
18
+ "zeropress": "^0.0.24",
19
+ "serve": "^14.2.1"
20
+ }
21
+ }
@@ -0,0 +1,5 @@
1
+ {
2
+ "compilerOptions": {
3
+ "jsx": "react-jsx",
4
+ },
5
+ }
@@ -0,0 +1,22 @@
1
+ import { UserConfig } from 'zeropress'
2
+
3
+ const config: UserConfig = {
4
+ themeConfig: {
5
+ nav: [
6
+ {
7
+ img: '/logo.jpg',
8
+ link: '/',
9
+ position: 'left',
10
+ },
11
+ {
12
+ dark: true,
13
+ },
14
+ {
15
+ logo: 'github',
16
+ link: 'https://github.com/houhongxu/hhxpress',
17
+ },
18
+ ],
19
+ },
20
+ }
21
+
22
+ export default config
@@ -1,12 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- "strict": true,
4
- "skipLibCheck": true,
5
- "noEmit": true,
6
- "module": "ESNext",
7
- "target": "ESNext",
8
- "resolveJsonModule": true,
9
- "moduleResolution": "node",
10
- "esModuleInterop": true
11
- }
12
- }