-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 3421692
Showing
228 changed files
with
36,783 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# Changesets | ||
|
||
Hello and welcome! This folder has been automatically generated by `@changesets/cli`, a build tool that works | ||
with multi-package repos, or single-package repos to help you version and publish your code. You can | ||
find the full documentation for it [in our repository](https://github.com/changesets/changesets) | ||
|
||
We have a quick list of common questions to get you started engaging with this project in | ||
[our documentation](https://github.com/changesets/changesets/blob/main/docs/common-questions.md) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{ | ||
"$schema": "https://unpkg.com/@changesets/[email protected]/schema.json", | ||
"changelog": "@changesets/cli/changelog", | ||
"commit": false, | ||
"fixed": [], | ||
"linked": [], | ||
"access": "restricted", | ||
"baseBranch": "main", | ||
"updateInternalDependencies": "patch", | ||
"ignore": [] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
indent_size = 2 | ||
indent_style = space |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
.yarn | ||
.env* | ||
*.env | ||
**/node_modules/** | ||
.DS_Store | ||
*.tsbuildinfo | ||
|
||
dist | ||
.turbo | ||
|
||
logs | ||
*.log | ||
npm-debug.log* | ||
yarn-debug.log* | ||
yarn-error.log* | ||
lerna-debug.log* | ||
.pnpm-debug.log* | ||
|
||
# Rush temporary files | ||
common/deploy/ | ||
common/temp/ | ||
common/autoinstallers/*/.npmrc | ||
**/.rush/temp/ | ||
*.lock | ||
*.log | ||
*.chunks.jsonl |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# refly-lib | ||
|
||
Supporting libraries for Refly. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
{ | ||
"name": "refly-lib", | ||
"private": true, | ||
"engines": { | ||
"pnpm": ">=8" | ||
}, | ||
"scripts": { | ||
"commit": "cz", | ||
"dev": "turbo run dev", | ||
"build": "turbo run build", | ||
"clean": "turbo run clean", | ||
"lint:ci": "turbo run lint:ci", | ||
"lint": "turbo run lint", | ||
"test": "pnpm -r --if-present test", | ||
"test:unit": "pnpm -r --if-present test:unit", | ||
"test:integration": "pnpm -r --if-present test:integration", | ||
"prepare": "husky" | ||
}, | ||
"devDependencies": { | ||
"@biomejs/biome": "^1.9.0", | ||
"@changesets/cli": "^2.27.8", | ||
"@types/node": "20.14.8", | ||
"commitizen": "^4.2.4", | ||
"cz-conventional-changelog": "^3.3.0", | ||
"husky": "^9.1.6", | ||
"lint-staged": "^15.2.10", | ||
"rimraf": "^5.0.10", | ||
"turbo": "^2.1.2", | ||
"typescript": "5.3.3", | ||
"vitest": "^2.1.0" | ||
}, | ||
"packageManager": "[email protected]", | ||
"config": { | ||
"commitizen": { | ||
"path": "cz-conventional-changelog" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
/lib | ||
/types |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
## 1.0.5 | ||
|
||
`2022-01-21` | ||
|
||
### 💎 Optimization | ||
|
||
- Improve icons' loading speed |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
## 1.0.5 | ||
|
||
`2022-01-21` | ||
|
||
### 💎 功能优化 | ||
|
||
- 提升图标的加载速度 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
# @arco-plugins/vite-react | ||
|
||
## Feature | ||
|
||
1. `Style lazy load` | ||
2. `Theme import` | ||
3. `Icon replacement` | ||
|
||
> `Style lazy load` doesn't work during development for better experience. | ||
## Install | ||
|
||
```bash | ||
npm i @arco-plugins/vite-react -D | ||
``` | ||
|
||
## Usage | ||
|
||
```js | ||
// vite.config.js | ||
|
||
import { vitePluginForArco } from '@arco-plugins/vite-react' | ||
|
||
export default { | ||
... | ||
plugins: [ | ||
vitePluginForArco(options), | ||
], | ||
} | ||
``` | ||
|
||
```tsx | ||
// react | ||
import { Button } from '@arco-design/web-react'; | ||
|
||
export default () => ( | ||
<div> | ||
<Button type="secondary">Cancel</Button> | ||
<Button type="primary">Submit</Button> | ||
</div> | ||
); | ||
``` | ||
|
||
## Options | ||
|
||
The plugin supports the following parameters: | ||
|
||
| Params | Type | Default Value | Description | | ||
| :--------------: | :----------------: | :-----------: | :------------------------ | | ||
| **`theme`** | `{String}` | `''` | Theme package name | | ||
| **`iconBox`** | `{String}` | `''` | Icon library package name | | ||
| **`modifyVars`** | `{Object}` | `{}` | Less variables | | ||
| **`style`** | `{'css'\|Boolean}` | `true` | Style import method | | ||
|**`varsInjectScope`**|`{(string\|RegExp)[]}`|`[]`| Scope of injection of less variables (modifyVars and the theme package's variables) | | ||
|
||
**Style import methods ** | ||
|
||
`style: true` will import less file | ||
|
||
```js | ||
import '@arco-design/web-react/Affix/style'; | ||
``` | ||
|
||
`style: 'css'` will import css file | ||
|
||
```js | ||
import '@arco-design/web-react/Affix/style/css'; | ||
``` | ||
|
||
`style: false` will not import any style file |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
# @arco-plugins/vite-react | ||
|
||
## 特性 | ||
|
||
1. `样式按需加载` | ||
2. `主题引入` | ||
3. `图标替换` | ||
|
||
> 为了开发体验,开发环境下样式为全量引入 | ||
## 安装 | ||
|
||
```bash | ||
npm i @arco-plugins/vite-react -D | ||
``` | ||
|
||
## 用法 | ||
|
||
```js | ||
// vite.config.js | ||
|
||
import { vitePluginForArco } from '@arco-plugins/vite-react' | ||
|
||
export default { | ||
... | ||
plugins: [ | ||
vitePluginForArco(options), | ||
], | ||
} | ||
``` | ||
|
||
```tsx | ||
// react | ||
import { Button } from '@arco-design/web-react'; | ||
|
||
export default () => ( | ||
<div> | ||
<Button type="secondary">Cancel</Button> | ||
<Button type="primary">Submit</Button> | ||
</div> | ||
); | ||
``` | ||
|
||
## 参数 | ||
|
||
插件支持以下参数: | ||
|
||
| 参数名 | 类型 | 默认值 | 描述 | | ||
| :--------------: | :----------------: | :----: | :----------- | | ||
| **`theme`** | `{String}` | `''` | 主题包名 | | ||
| **`iconBox`** | `{String}` | `''` | 图标库包名 | | ||
| **`modifyVars`** | `{Object}` | `{}` | Less 变量 | | ||
| **`style`** | `{'css'\|Boolean}` | `true` | 样式引入方式 | | ||
|**`varsInjectScope`**|`string[]`|`[]`| less 变量(modifyVars 和主题包的变量)注入的范围 | | ||
|
||
**样式引入方式 ** | ||
|
||
`style: true` 将引入 less 文件 | ||
|
||
```js | ||
import '@arco-design/web-react/Affix/style'; | ||
``` | ||
|
||
`style: 'css'` 将引入 css 文件 | ||
|
||
```js | ||
import '@arco-design/web-react/Affix/style/css'; | ||
``` | ||
|
||
`style: false` 不引入样式 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
{ | ||
"name": "@refly/plugin-vite-encoding", | ||
"version": "1.3.3", | ||
"description": "For Vite build, load Arco Design styles on demand", | ||
"main": "lib/index.js", | ||
"types": "types/index.d.ts", | ||
"files": [ | ||
"lib", | ||
"types" | ||
], | ||
"repository": { | ||
"type": "git", | ||
"url": "[email protected]:arco-design/arco-plugins.git", | ||
"directory": "packages/plugin-vite-react" | ||
}, | ||
"keywords": [ | ||
"arco", | ||
"arco-design", | ||
"arco-plugin", | ||
"plugin", | ||
"vite" | ||
], | ||
"scripts": { | ||
"prebuild": "rm -fr lib types", | ||
"build": "npx tsc" | ||
}, | ||
"author": "arco-design", | ||
"license": "MIT", | ||
"dependencies": { | ||
"@babel/generator": "^7.12.11", | ||
"@babel/helper-module-imports": "^7.12.5", | ||
"@babel/parser": "^7.12.11", | ||
"@babel/traverse": "^7.12.12", | ||
"@babel/types": "^7.12.12", | ||
"rollup": "~4.18.0" | ||
}, | ||
"devDependencies": { | ||
"vite": "^2.6.14", | ||
"esbuild": "^0.13.2" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import pluginViteEncoding from './plugin-vite-encoding'; | ||
|
||
export default pluginViteEncoding; | ||
|
||
export { pluginViteEncoding }; |
46 changes: 46 additions & 0 deletions
46
packages/plugin-vite-encoding/src/plugin-vite-encoding/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import type { Plugin } from 'vite'; | ||
import type { OutputChunk, OutputAsset } from 'rollup'; | ||
|
||
const pkg = require('../../package.json'); | ||
|
||
export function toUtf8(str: string) { | ||
return str | ||
.split('') | ||
.map((ch) => (ch.charCodeAt(0) <= 0x7f ? ch : '\\u' + ('0000' + ch.charCodeAt(0).toString(16)).slice(-4))) | ||
.join(''); | ||
} | ||
|
||
interface PluginOption { | ||
filePatterns?: (string | RegExp)[]; // File to transform | ||
} | ||
|
||
export default function vitePluginEncoding(options: PluginOption): Plugin { | ||
return { | ||
name: pkg.name, | ||
|
||
generateBundle(_, bundle) { | ||
for (const file in bundle) { | ||
const chunk = bundle[file] as OutputAsset | OutputChunk; | ||
|
||
let shouldTransform = false; | ||
|
||
for (const pattern of options.filePatterns) { | ||
if (file.match(new RegExp(pattern))) { | ||
shouldTransform = true; | ||
} | ||
} | ||
|
||
if (!shouldTransform) { | ||
continue; | ||
} | ||
|
||
// 如果是 JavaScript 文件 | ||
if (chunk.type === 'chunk' && chunk?.code && /\.js$/.test(file)) { | ||
// 将内容转换为 UTF-8 编码 | ||
const utf8Content = toUtf8(chunk.code as string); | ||
chunk.code = utf8Content; | ||
} | ||
} | ||
}, | ||
}; | ||
} |
2 changes: 2 additions & 0 deletions
2
packages/plugin-vite-encoding/src/plugin-vite-encoding/typings.d.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
declare module '*.json'; | ||
declare module '@babel/helper-module-imports'; |
Oops, something went wrong.