Skip to content

Commit

Permalink
Merge branch 'alibaba:master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
askwuxue authored Jul 11, 2024
2 parents d222cbf + b2f1218 commit b4dae71
Show file tree
Hide file tree
Showing 141 changed files with 3,398 additions and 2,741 deletions.
1 change: 0 additions & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ module.exports = {
'@typescript-eslint/ban-ts-ignore': 'off',
'@typescript-eslint/no-object-literal-type-assertion': 'off',
'@typescript-eslint/no-parameter-properties': 'off',
'consistent-return': 'off',
'import/no-useless-path-segments': 'off',
'no-unused-expressions': 'off',
'react-hooks/rules-of-hooks': 'error',
Expand Down
4 changes: 1 addition & 3 deletions .github/workflows/node-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,13 @@ jobs:

- name: Install pnpm
uses: pnpm/action-setup@v2.2.4
with:
version: 7

- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}

- name: pnpm run intall, build
- name: pnpm run install, build
run: |
pnpm run init
env:
Expand Down
6 changes: 2 additions & 4 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,11 @@ jobs:

- name: Install pnpm
uses: pnpm/action-setup@v2.2.4
with:
version: 7

- name: Get pnpm store directory
id: pnpm-cache
run: |
echo "::set-output name=pnpm_cache_dir::$(pnpm store path)"
echo "pnpm_cache_dir=$(pnpm store path)" >> "$GITHUB_OUTPUT"
- name: Setup pnpm cache
uses: actions/cache@v3
Expand All @@ -37,7 +35,7 @@ jobs:
with:
node-version: ${{ matrix.node-version }}

- name: pnpm run intall, build
- name: pnpm run install, build
run: |
pnpm run init
Expand Down
2 changes: 1 addition & 1 deletion .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

npm run pretty
npm run pretty
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2020 ahooks
Copyright (c) 2019-present ahooks

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ $ npm install --save ahooks
$ yarn add ahooks
# or
$ pnpm add ahooks
# or
$ bun add ahooks
```

## 🔨 Usage
Expand Down Expand Up @@ -77,7 +79,7 @@ Thanks to all the contributors:

## 👥 Discuss

<img src="https://user-images.githubusercontent.com/60802048/201606568-9ce53e3f-2e1c-4dc3-869f-fb3cf6196904.JPG" width="200" style='display:inline'/><img src="https://user-images.githubusercontent.com/60802048/201606896-31abd486-cc3e-4cc4-beea-1b244a4c5595.JPG" width="200" style='display:inline'/><img src="https://user-images.githubusercontent.com/60802048/201606953-c33f3f52-eb91-42bc-8da7-1e941e823144.JPG" width="200" style='display:inline'/>
<img src="https://github.com/alibaba/hooks/assets/49217418/ba636378-1dff-4754-bfe6-46923417cd3b" width="200" style='display:inline' /><img src="https://github.com/alibaba/hooks/assets/49217418/93a169ce-f9d1-4a66-a829-9f16e790ee28" width="200" style='display:inline' /><img src="https://github.com/alibaba/hooks/assets/49217418/d30d80c7-eb16-4522-acab-f2d48513464a" width="200" style='display:inline' />

[1]: https://www.npmjs.com/package/ahooks
[2]: https://npmjs.org/package/ahooks
Expand Down
4 changes: 3 additions & 1 deletion README.zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ $ npm install --save ahooks
$ yarn add ahooks
# or
$ pnpm add ahooks
# or
$ bun add ahooks
```

## 🔨 使用
Expand Down Expand Up @@ -77,7 +79,7 @@ $ pnpm start

## 👥 交流讨论

<img src="https://user-images.githubusercontent.com/12526493/163084546-ed7a18a8-f05b-484e-a32c-049a05c350fd.JPG" width="200" style='display:inline'/><img src="https://user-images.githubusercontent.com/12526493/163084577-bab53c55-610e-4efe-96c7-eb0dd076c100.JPG" width="200" style='display:inline'/><img src="https://user-images.githubusercontent.com/12526493/163084584-bfb789fe-b5f4-4cd6-b4a5-2444bd67c1a5.JPG" width="200" style='display:inline'/>
<img src="https://github.com/alibaba/hooks/assets/49217418/ba636378-1dff-4754-bfe6-46923417cd3b" width="200" style='display:inline' /><img src="https://github.com/alibaba/hooks/assets/49217418/93a169ce-f9d1-4a66-a829-9f16e790ee28" width="200" style='display:inline' /><img src="https://github.com/alibaba/hooks/assets/49217418/d30d80c7-eb16-4522-acab-f2d48513464a" width="200" style='display:inline' />

[1]: https://www.npmjs.com/package/ahooks
[2]: https://npmjs.org/package/ahooks
Expand Down
29 changes: 19 additions & 10 deletions config/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ export default {
type: 'none',
exclude: [],
},
// https://github.com/alibaba/hooks/issues/2155
extraBabelIncludes: ['filter-obj'],
extraBabelPlugins: [
[
'babel-plugin-import',
Expand Down Expand Up @@ -180,20 +182,27 @@ export default {
scripts: [
'https://s4.cnzz.com/z_stat.php?id=1278992092&web_id=1278992092',
`
const insertVersion = function(){
const insertVersion = function() {
const logo = document.querySelector('.__dumi-default-navbar-logo');
if (!logo) return;
const dom = document.createElement('span');
dom.id = 'logo-version';
dom.innerHTML = '${packages.version}';
const logo = document.querySelector('.__dumi-default-navbar-logo');
if(logo){
logo.parentNode.insertBefore(dom, logo.nextSibling);
}else{
setTimeout(()=>{
insertVersion();
}, 1000)
logo.parentNode.insertBefore(dom, logo.nextSibling);
};
const observer = new MutationObserver((mutationsList, observer) => {
for (const mutation of mutationsList) {
if (mutation.type === 'childList') {
const logoVersion = document.querySelector('#logo-version');
if (logoVersion) {
observer.disconnect();
} else {
insertVersion();
}
}
}
}
insertVersion();
});
observer.observe(document.body, { childList: true, subtree: true });
`,
],
};
2 changes: 2 additions & 0 deletions docs/guide/index.en-US.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ $ npm install --save ahooks
$ yarn add ahooks
# or
$ pnpm add ahooks
# or
$ bun add ahooks
```

## Usage
Expand Down
2 changes: 2 additions & 0 deletions docs/guide/index.zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ $ npm install --save ahooks
$ yarn add ahooks
# or
$ pnpm add ahooks
# or
$ bun add ahooks
```

## 使用
Expand Down
2 changes: 1 addition & 1 deletion docs/guide/upgrade.en-US.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ useRequest has been rewritten:
- Removed `pagination` related options, it is recommended to use `usePagination` or `useAntdTable` to achieve paging ability.
- Removed `loadMore` related options, it is recommended to use `useInfiniteScroll` to achieve unlimited loading ability.
- Removed `fetchKey`, that is, deleted concurrent request.
- Removed `formatResult`, `initialData`, and `thrownError`.
- Removed `formatResult`, `initialData`, and `throwOnError`.
- The request library is no longer integrated by default, and `service` no longer supports string or object.
- Added `runAsync` and `refreshAsync`, the original `run` no longer returns Promise.
- Added error retry ability.
Expand Down
2 changes: 1 addition & 1 deletion docs/guide/upgrade.zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ useRequest 完全进行了重写:
- 删除了 `pagination` 相关属性,建议使用 `usePagination``useAntdTable` 来实现分页能力。
- 删除了 `loadMore` 相关属性,建议使用 `useInfiniteScroll` 来实现无限加载能力。
- 删除了 `fetchKey`,也就是删除了并行能力。
- 删除了 `formatResult``initialData``thrownError`
- 删除了 `formatResult``initialData``throwOnError`
- 不再默认集成请求库,`service` 不再支持字符或对象。
- 新增了 `runAsync``refreshAsync`,原来的 `run` 不再返回 Promise。
- 新增了错误重试能力。
Expand Down
4 changes: 3 additions & 1 deletion docs/index.en-US.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ $ npm install --save ahooks
$ yarn add ahooks
# or
$ pnpm add ahooks
# or
$ bun add ahooks
```

## 🔨 Usage
Expand Down Expand Up @@ -71,7 +73,7 @@ Thanks to all the contributors:

## 👥 Discuss

<img src="https://user-images.githubusercontent.com/60802048/201606568-9ce53e3f-2e1c-4dc3-869f-fb3cf6196904.JPG" width="200" style='display:inline'/><img src="https://user-images.githubusercontent.com/60802048/201606896-31abd486-cc3e-4cc4-beea-1b244a4c5595.JPG" width="200" style='display:inline'/><img src="https://user-images.githubusercontent.com/60802048/201606953-c33f3f52-eb91-42bc-8da7-1e941e823144.JPG" width="200" style='display:inline'/>
<img src="https://github.com/alibaba/hooks/assets/49217418/ba636378-1dff-4754-bfe6-46923417cd3b" width="200" style='display:inline' /><img src="https://github.com/alibaba/hooks/assets/49217418/93a169ce-f9d1-4a66-a829-9f16e790ee28" width="200" style='display:inline' /><img src="https://github.com/alibaba/hooks/assets/49217418/d30d80c7-eb16-4522-acab-f2d48513464a" width="200" style='display:inline' />

[1]: https://www.npmjs.com/package/ahooks
[2]: https://npmjs.org/package/ahooks
Expand Down
6 changes: 5 additions & 1 deletion docs/index.zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ footer: Open-source MIT Licensed | Copyright © 2019-present<br />Powered by [du
$ npm install --save ahooks
# or
$ yarn add ahooks
# or
$ pnpm add ahooks
# or
$ bun add ahooks
```

## 🔨 使用
Expand Down Expand Up @@ -69,7 +73,7 @@ $ pnpm start

## 👥 交流讨论

<img src="https://user-images.githubusercontent.com/60802048/201606568-9ce53e3f-2e1c-4dc3-869f-fb3cf6196904.JPG" width="200" style='display:inline'/><img src="https://user-images.githubusercontent.com/60802048/201606896-31abd486-cc3e-4cc4-beea-1b244a4c5595.JPG" width="200" style='display:inline'/><img src="https://user-images.githubusercontent.com/60802048/201606953-c33f3f52-eb91-42bc-8da7-1e941e823144.JPG" width="200" style='display:inline'/>
<img src="https://github.com/alibaba/hooks/assets/49217418/ba636378-1dff-4754-bfe6-46923417cd3b" width="200" style='display:inline' /><img src="https://github.com/alibaba/hooks/assets/49217418/93a169ce-f9d1-4a66-a829-9f16e790ee28" width="200" style='display:inline' /><img src="https://github.com/alibaba/hooks/assets/49217418/d30d80c7-eb16-4522-acab-f2d48513464a" width="200" style='display:inline' />

[1]: https://www.npmjs.com/package/ahooks
[2]: https://npmjs.org/package/ahooks
Expand Down
2 changes: 1 addition & 1 deletion example/basic/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
"@types/react-dom": "^17.0.0",
"@umijs/test": "^3.4.20",
"lint-staged": "^10.0.7",
"prettier": "^2.2.0",
"prettier": "^3.2.2",
"react": "17.x",
"react-dom": "17.x",
"typescript": "^5.1.3",
Expand Down
14 changes: 10 additions & 4 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
/** esm modules to transform */
const esmModules = [
// `query-string` and its related dependencies
'query-string',
'decode-uri-component',
'split-on-first',
'filter-obj',
];

module.exports = {
preset: 'ts-jest/presets/js-with-ts',
testEnvironment: 'jsdom',
Expand All @@ -18,8 +27,5 @@ module.exports = {
'!**/lib/**',
'!**/dist/**',
],
transformIgnorePatterns: ['^.+\\.js$'],
moduleNameMapper: {
'lodash-es': 'lodash',
},
transformIgnorePatterns: [`node_modules/(?!(?:.pnpm/)?(${esmModules.join('|')}))`],
};
33 changes: 14 additions & 19 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
{
"name": "ahooks",
"private": true,
"packageManager": "pnpm@7.33.6",
"engines": {
"pnpm": ">=7 <8"
},
"repository": {
"type": "git",
"url": "git+https://github.com/alibaba/hooks.git"
Expand All @@ -18,7 +22,7 @@
"pretty": "pretty-quick --staged",
"build:doc": "dumi build",
"pub:doc-surge": "surge ./dist --domain ahooks.js.org",
"pub:doc-gitee": "cd ./dist && rm -rf .git && touch .spa && touch .nojekyll && git init && git remote add origin git@gitee.com:ahooks/ahooks.git && git add -A && git commit -m \"publish docs\" && git push origin master -f && echo https://gitee.com/ahooks/ahooks/pages",
"pub:doc-gitee": "cd ./dist && rm -rf .git && touch .spa && touch .nojekyll && git init && git remote add origin git@gitee.com:ahooks/ahooks.git && git add -A && git commit -m \"publish docs\" && git push origin main -f && echo https://gitee.com/ahooks/ahooks/pages",
"pub:doc": "pnpm run build:doc && pnpm run pub:doc-surge && pnpm run pub:doc-gitee",
"pub": "pnpm run build && pnpm -r --filter=./packages/* publish",
"pub:beta": "pnpm run build && pnpm -r --filter=./packages/* publish --tag beta",
Expand All @@ -27,7 +31,7 @@
"test:strict": "cross-env REACT_MODE=strict jest"
},
"devDependencies": {
"@ant-design/icons": "^5.0.1",
"@ant-design/icons": "^5.3.0",
"@babel/cli": "^7.10.1",
"@babel/core": "^7.10.2",
"@babel/plugin-transform-runtime": "^7.19.6",
Expand All @@ -36,24 +40,17 @@
"@testing-library/jest-dom": "^5.16.5",
"@testing-library/react": "^13.4.0",
"@types/jest": "^29.4.0",
"@types/lodash.debounce": "^4.0.6",
"@types/lodash.isequal": "^4.5.5",
"@types/lodash.throttle": "^4.1.6",
"@types/mockjs": "^1.0.7",
"@types/react-router": "^5.1.19",
"@umijs/fabric": "^2.1.0",
"@umijs/plugin-sass": "^1.1.1",
"antd": "^5.2.1",
"babel-loader": "^8.1.0",
"antd": "^5.14.2",
"babel-plugin-import": "^1.12.0",
"babel-plugin-transform-async-to-promises": "^0.8.15",
"coveralls": "^3.1.1",
"cross-env": "^7.0.3",
"del": "^5.1.0",
"dumi": "^1.1.48",
"enzyme": "^3.10.0",
"eslint": "^7.2.0",
"eslint-plugin-react-hooks": "^4.0.8",
"eslint": "^8.56.0",
"eslint-plugin-react-hooks": "^4.6.0",
"fast-glob": "^3.2.11",
"fs-extra": "^10.0.1",
"gray-matter": "^4.0.3",
Expand All @@ -63,23 +60,21 @@
"husky": "^8.0.0",
"jest": "^29.4.1",
"jest-environment-jsdom": "^29.4.1",
"jest-fetch-mock": "^3.0.3",
"jest-localstorage-mock": "^2.4.18",
"mockjs": "^1.1.0",
"prettier": "^2.0.5",
"pretty-quick": "^3.1.3",
"prettier": "^3.2.5",
"pretty-quick": "^4.0.0",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-drag-listview": "^0.1.6",
"react-router": "^6.4.2",
"react-shadow": "^19.0.3",
"rimraf": "^3.0.2",
"surge": "^0.21.3",
"ts-jest": "^29.0.5",
"ts-jest": "^29.1.1",
"typescript": "^5.1.3",
"umi-request": "^1.2.18",
"webpack": "^4.43.0",
"webpack-cli": "^3.3.10",
"webpack": "^5.90.3",
"webpack-cli": "^5.1.4",
"webpack-merge": "^4.2.2"
},
"commitlint": {
Expand Down
12 changes: 5 additions & 7 deletions packages/hooks/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ahooks",
"version": "3.7.8",
"version": "3.8.0",
"description": "react hooks library",
"keywords": [
"ahooks",
Expand Down Expand Up @@ -34,12 +34,11 @@
],
"dependencies": {
"@babel/runtime": "^7.21.0",
"@types/js-cookie": "^2.x.x",
"ahooks-v3-count": "^1.0.0",
"dayjs": "^1.9.1",
"intersection-observer": "^0.12.0",
"js-cookie": "^2.x.x",
"lodash-es": "^4.17.21",
"lodash": "^4.17.21",
"react-fast-compare": "^3.2.2",
"resize-observer-polyfill": "^1.5.1",
"screenfull": "^5.0.0",
"tslib": "^2.4.1"
Expand All @@ -50,11 +49,10 @@
"devDependencies": {
"@alifd/next": "^1.20.6",
"@ant-design/icons": "^5.0.1",
"@types/enzyme": "^3.10.5",
"@types/js-cookie": "^2.x.x",
"@types/lodash": "^4.14.202",
"antd": "^5.2.1",
"enzyme-adapter-react-16": "^1.15.4",
"jest-websocket-mock": "^2.1.0",
"mock-socket": "^9.0.3",
"mockjs": "^1.1.0",
"react-drag-listview": "^0.1.6",
"react-json-view": "^1.21.3"
Expand Down
2 changes: 1 addition & 1 deletion packages/hooks/src/createDeepCompareEffect/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ export const createDeepCompareEffect: CreateUpdateEffect = (hook) => (effect, de
const signalRef = useRef<number>(0);

if (deps === undefined || !depsEqual(deps, ref.current)) {
ref.current = deps;
signalRef.current += 1;
}
ref.current = deps;

hook(effect, [signalRef.current]);
};
Loading

0 comments on commit b4dae71

Please sign in to comment.