Skip to content

Commit fe8756b

Browse files
committed
refactor!: refactor the project
1 parent c295d29 commit fe8756b

File tree

328 files changed

+7484
-7278
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

328 files changed

+7484
-7278
lines changed

.eslintrc.json

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -101,14 +101,7 @@
101101
},
102102
{
103103
"files": ["*.tsx", "*.jsx"],
104-
"rules": {
105-
"react-hooks/exhaustive-deps": [
106-
"warn",
107-
{
108-
"additionalHooks": "(useIsomorphicLayoutEffect)"
109-
}
110-
]
111-
}
104+
"rules": {}
112105
},
113106
{
114107
"files": ["**/*.md/*.ts", "**/*.md/*.tsx"],

.github/workflows/main.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ jobs:
1414
- uses: nrwl/nx-set-shas@v2
1515
- uses: actions/setup-node@v2
1616
with:
17-
node-version: '16.13'
17+
node-version: '16'
1818
cache: 'yarn'
1919
- run: yarn install --frozen-lockfile
2020
- run: yarn lint:affected
@@ -28,7 +28,7 @@ jobs:
2828
- uses: nrwl/nx-set-shas@v2
2929
- uses: actions/setup-node@v2
3030
with:
31-
node-version: '16.13'
31+
node-version: '16'
3232
cache: 'yarn'
3333
- run: yarn install --frozen-lockfile
3434
- run: yarn test:affected
@@ -42,7 +42,7 @@ jobs:
4242
- uses: nrwl/nx-set-shas@v2
4343
- uses: actions/setup-node@v2
4444
with:
45-
node-version: '16.13'
45+
node-version: '16'
4646
cache: 'yarn'
4747
- run: yarn install --frozen-lockfile
4848
- run: yarn nx build site --configuration=production --skip-nx-cache
@@ -63,7 +63,7 @@ jobs:
6363
- uses: nrwl/nx-set-shas@v2
6464
- uses: actions/setup-node@v2
6565
with:
66-
node-version: '16.13'
66+
node-version: '16'
6767
cache: 'yarn'
6868
- run: yarn install --frozen-lockfile
6969
- run: yarn nx build platform --configuration=production --skip-nx-cache

.github/workflows/pull-request.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ jobs:
1515
- uses: nrwl/nx-set-shas@v2
1616
- uses: actions/setup-node@v2
1717
with:
18-
node-version: '16.13'
18+
node-version: '16'
1919
cache: 'yarn'
2020
- run: yarn install --frozen-lockfile
2121
- run: yarn lint:affected
@@ -30,7 +30,7 @@ jobs:
3030
- uses: nrwl/nx-set-shas@v2
3131
- uses: actions/setup-node@v2
3232
with:
33-
node-version: '16.13'
33+
node-version: '16'
3434
cache: 'yarn'
3535
- run: yarn install --frozen-lockfile
3636
- run: yarn test:affected
@@ -88,7 +88,7 @@ jobs:
8888
fetch-depth: 0
8989
- uses: actions/setup-node@v2
9090
with:
91-
node-version: '16.13'
91+
node-version: '16'
9292
cache: 'yarn'
9393
- run: yarn install --frozen-lockfile
9494
- run: yarn nx build site --configuration=production --skip-nx-cache

.nvmrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
16.13
1+
16

.vscode/recommended-settings.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"typescript.tsdk": "./node_modules/typescript/lib",
2+
"typescript.tsdk": "node_modules/typescript/lib",
33
"eslint.format.enable": true,
44
"stylelint.validate": ["css", "scss", "html", "markdown"],
55
"editor.defaultFormatter": "esbenp.prettier-vscode",

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,12 @@
5757
"axios": "^0.27.2",
5858
"axios-mock-adapter": "^1.21.2",
5959
"babel-jest": "^27.5.1",
60+
"bootstrap": "^5.2.2",
6061
"codesandbox": "^2.2.3",
6162
"colors": "^1.4.0",
6263
"core-js": "^3.25.2",
6364
"dayjs": "^1.11.5",
65+
"echarts": "^5.3.3",
6466
"eslint": "^8.23.1",
6567
"eslint-config-prettier": "^8.5.0",
6668
"eslint-plugin-import": "^2.26.0",

packages/hooks/.eslintrc.json

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,14 @@
44
"overrides": [
55
{
66
"files": ["*.ts", "*.tsx", "*.js", "*.jsx"],
7-
"rules": {}
7+
"rules": {
8+
"react-hooks/exhaustive-deps": [
9+
"warn",
10+
{
11+
"additionalHooks": "(useIsomorphicLayoutEffect)"
12+
}
13+
]
14+
}
815
},
916
{
1017
"files": ["*.ts", "*.tsx"],
Lines changed: 12 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import type { ImmerHook } from './useImmer';
22

3-
import { freeze, produce } from 'immer';
3+
import { freeze } from 'immer';
44

5-
import { useForceUpdate } from './useForceUpdate';
5+
import { useImmer } from './useImmer';
66
import { useUnmount } from './useUnmount';
77

88
export function createGlobalState<S>(): () => ImmerHook<S | undefined>;
@@ -11,31 +11,25 @@ export function createGlobalState<S>(initialValue?: S): () => ImmerHook<S | unde
1111
const store = {
1212
state: freeze(typeof initialValue === 'function' ? initialValue() : initialValue, true),
1313
setState(updater: any) {
14-
const prev = store.state;
15-
if (typeof updater === 'function') {
16-
store.state = produce(store.state, updater);
17-
} else {
18-
store.state = freeze(updater);
19-
}
20-
if (!Object.is(store.state, prev)) {
21-
for (const update of store.updates) {
22-
update();
23-
}
14+
for (const update of store.updates) {
15+
update(updater);
2416
}
2517
},
26-
updates: new Set<() => void>(),
18+
updates: new Set<(...args: any[]) => any>(),
2719
};
2820

2921
return () => {
30-
const forceUpdate = useForceUpdate();
31-
if (!store.updates.has(forceUpdate)) {
32-
store.updates.add(forceUpdate);
22+
const [state, setState] = useImmer(store.state);
23+
store.state = state;
24+
25+
if (!store.updates.has(setState)) {
26+
store.updates.add(setState);
3327
}
3428

3529
useUnmount(() => {
36-
store.updates.delete(forceUpdate);
30+
store.updates.delete(setState);
3731
});
3832

39-
return [store.state, store.setState];
33+
return [state, store.setState];
4034
};
4135
}

packages/hooks/src/index.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,15 @@
1+
export { useStorage } from './storage';
12
export { createGlobalState } from './createGlobalState';
23
export { useAsync } from './useAsync';
3-
export { useBreakpoints } from './useBreakpoints';
44
export { useEvent } from './useEvent';
55
export { useEventCallback } from './useEventCallback';
6-
export { useElement } from './useElement';
7-
export { useEventListener } from './useEventListener';
8-
export { useEventNotify } from './useEventNotify';
96
export { useForceUpdate } from './useForceUpdate';
107
export { useForkRef } from './useForkRef';
8+
export { useId } from './useId';
119
export { useImmer } from './useImmer';
1210
export { useLockScroll } from './useLockScroll';
1311
export { useIsomorphicLayoutEffect } from './useIsomorphicLayoutEffect';
14-
export { useLocalStorage } from './useLocalStorage';
1512
export { useMount } from './useMount';
13+
export { useRefExtra } from './useRefExtra';
1614
export { useResize } from './useResize';
1715
export { useUnmount } from './useUnmount';
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
export * from './useStorage';
2+
3+
export * from './parser';
4+
5+
export * from './storage';
6+
export * from './localStorage';

0 commit comments

Comments
 (0)