Skip to content

Commit 9a9dc90

Browse files
authored
chore: use vite build system (#70)
BREAKING CHANGE: change dist files and remove umd build
1 parent 7866bb5 commit 9a9dc90

Some content is hidden

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

56 files changed

+7386
-8381
lines changed

.commitlintrc.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
extends:
2-
- '@commitlint/config-conventional'
2+
- '@commitlint/config-conventional'

.eslintrc.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
extends:
2+
- react-app
3+
- react-app/jest

.github/workflows/node-ci.yml

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,19 @@ jobs:
77
runs-on: ubuntu-latest
88

99
steps:
10-
- uses: actions/checkout@v2
10+
- uses: actions/checkout@v3
11+
- uses: pnpm/action-setup@v2
12+
with:
13+
version: 7
1114
- name: Use Node.js
12-
uses: actions/setup-node@v1
15+
uses: actions/setup-node@v3
1316
with:
14-
node-version: '12.x'
15-
- run: yarn
16-
- run: yarn lint
17-
- run: yarn format:check
18-
- run: yarn test --coverage --verbose
19-
- run: yarn build
17+
node-version: 16
18+
cache: 'pnpm'
19+
- run: pnpm install --frozen-lockfile
20+
- run: pnpm run lint
21+
- run: pnpm run format:check
22+
- run: pnpm run build
23+
- run: pnpm run test
2024
- run: git diff --exit-code --name-only
21-
- uses: codecov/codecov-action@v1
25+
- uses: codecov/codecov-action@v2

.github/workflows/node-publish.yml

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,16 @@ jobs:
66
build:
77
runs-on: ubuntu-latest
88
steps:
9-
- uses: actions/checkout@v2
10-
# Setup .npmrc file to publish to npm
11-
- uses: actions/setup-node@v2
9+
- uses: actions/checkout@v3
10+
- uses: pnpm/action-setup@v2
1211
with:
13-
node-version: '12.x'
14-
registry-url: 'https://registry.npmjs.org'
15-
- run: yarn
16-
- run: npm publish
12+
version: 7
13+
- name: Use Node.js
14+
uses: actions/setup-node@v3
15+
with:
16+
node-version: 16
17+
cache: 'pnpm'
18+
- run: pnpm install --frozen-lockfile
19+
- run: pnpm publish
1720
env:
1821
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

.gitignore

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
node_modules
2-
/dist/
3-
/lib/
4-
/es/
5-
/bin/
6-
/coverage/
7-
/.cache/
2+
.DS_Store
3+
dist
4+
dist-ssr
5+
*.local
6+
.cache
7+
coverage
88
/tsdoc-metadata.json
9+
.pnpm-debug.log

.husky/commit-msg

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/usr/bin/env sh
2+
. "$(dirname -- "$0")/_/husky.sh"
3+
4+
pnpm exec commitlint --edit ${1}

.husky/pre-commit

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/usr/bin/env sh
2+
. "$(dirname -- "$0")/_/husky.sh"
3+
4+
pnpm run pre-commit

.huskyrc.yml

Lines changed: 0 additions & 3 deletions
This file was deleted.

.libtonrc.yml

Lines changed: 0 additions & 6 deletions
This file was deleted.

.lintstagedrc.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
'**/*.{js,jsx,ts,tsx,json,css,scss,md}':
2-
- 'libton-script format'
1+
'**/*.{js,jsx,ts,tsx,json,yml,css,scss,md}':
2+
- 'prettier --write'

.prettierignore

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
1-
/dist/
2-
/lib/
3-
/es/
4-
/bin/
5-
/coverage/
6-
/.cache/
1+
dist/
2+
.cache/
3+
coverage/
74
/tsdoc-metadata.json

.prettierrc

Lines changed: 0 additions & 4 deletions
This file was deleted.

.prettierrc.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
trailingComma: 'all'
2+
singleQuote: true

api-extractor.json

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
{
2+
"$schema": "https://developer.microsoft.com/json-schemas/api-extractor/v7/api-extractor.schema.json",
3+
4+
"mainEntryPointFilePath": "<projectFolder>/.cache/dts/index.d.ts",
5+
6+
"apiReport": {
7+
"enabled": false
8+
},
9+
"docModel": {
10+
"enabled": false
11+
},
12+
13+
"dtsRollup": {
14+
"enabled": true,
15+
"untrimmedFilePath": "<projectFolder>/index.d.ts"
16+
},
17+
18+
"messages": {
19+
"compilerMessageReporting": {
20+
"default": {
21+
"logLevel": "warning"
22+
}
23+
},
24+
25+
"extractorMessageReporting": {
26+
"ae-forgotten-export": {
27+
"logLevel": "none"
28+
},
29+
"ae-missing-release-tag": {
30+
"logLevel": "none"
31+
},
32+
"default": {
33+
"logLevel": "warning"
34+
}
35+
},
36+
37+
"tsdocMessageReporting": {
38+
"default": {
39+
"logLevel": "warning"
40+
}
41+
}
42+
}
43+
}

index.d.ts

Lines changed: 31 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -12,18 +12,22 @@ declare type CB<T> = (t: T) => void;
1212

1313
declare type CovarianceGuard<T> = [T, unknown];
1414

15-
export declare function createSelector<V, Fns = {}>(
15+
export declare function createSelector<V, Fns extends {} = {}>(
1616
options: WritableSelectorOptions<V>,
1717
): Wire<V, Fns>;
1818

19-
export declare function createSelector<V, Fns = {}>(
19+
export declare function createSelector<V, Fns extends {} = {}>(
2020
options: ReadOnlySelectorOptions<V>,
2121
): ReadonlyWire<V, Fns>;
2222

23-
export declare function createWire<V, Fns = {}>(initialValue: V): Wire<V, Fns>;
23+
export declare function createWire<V, Fns extends {} = {}>(
24+
initialValue: V,
25+
): Wire<V, Fns>;
2426

2527
export declare type Defined<T> = T extends undefined ? never : T;
2628

29+
declare type Fn = (...args: any) => any;
30+
2731
export declare interface FnsWire<Fns extends {}> extends FnsWireGuard<Fns> {
2832
fn: <K extends KeyOfMethods<Fns>>(name: K, value: Fns[K]) => () => void;
2933
fns: Methods<Fns>;
@@ -65,7 +69,7 @@ export declare type Interceptor<Value> = (
6569
/**
6670
* isDefined check if the value is undefined or not.
6771
* it helps with typescript generic types.
68-
* @param value
72+
* @param value -
6973
*/
7074
export declare const isDefined: <V>(
7175
value: V | undefined,
@@ -78,7 +82,7 @@ declare type KeyOfMethods<T> = NonNever<keyof Methods<T>>;
7882
export declare type LinkIds = Array<string | LinkIds>;
7983

8084
declare type MethodKeys<T> = {
81-
[P in keyof T]: T[P] extends Function ? P : never;
85+
[P in keyof T]: T[P] extends Fn ? P : never;
8286
}[keyof T];
8387

8488
declare type Methods<T> = Pick<T, MethodKeys<T>>;
@@ -99,7 +103,7 @@ export declare interface ReadonlyStateWire<V>
99103
getValue(): V;
100104
/**
101105
* subscribe for value change
102-
* @param callback
106+
* @param callback -
103107
* @returns unsubscribe function
104108
*/
105109
subscribe(callback: (value: Defined<V>) => void): () => void;
@@ -109,8 +113,10 @@ declare interface ReadonlyStateWireGuard<V> {
109113
' state-wire': CovarianceGuard<V>;
110114
}
111115

112-
export declare type ReadonlyWire<V, Fns = {}> = ReadonlyStateWire<V> &
113-
FnsWire<Fns>;
116+
export declare type ReadonlyWire<
117+
V,
118+
Fns extends {} = {},
119+
> = ReadonlyStateWire<V> & FnsWire<Fns>;
114120

115121
declare type SetWireValue = <V>(wire: StateWire<V>, value: Defined<V>) => void;
116122

@@ -122,12 +128,12 @@ export declare interface StateWire<V> extends StateWireGuard<V>, WireId {
122128
getValue(): V;
123129
/**
124130
* set value
125-
* @param value
131+
* @param value -
126132
*/
127133
setValue(value: Defined<V>): void;
128134
/**
129135
* subscribe for value change
130-
* @param callback
136+
* @param callback -
131137
* @returns unsubscribe function
132138
*/
133139
subscribe(callback: (value: Defined<V>) => void): () => void;
@@ -147,26 +153,26 @@ declare type StrictMethodsGuard<Fns> = {
147153
*
148154
* subscribe for function calls
149155
*
150-
* @param wire
156+
* @param wire -
151157
* @param name - name of `fns` function
152158
* @param fn - memoized callback function
153159
*
154160
* @example
155-
```ts
161+
```ts
156162
// subscribe for `sample` function call
157163
useFn(
158164
wire,
159165
'sample',
160166
useCallback(value => {
161-
console.log(value);
162-
}, []),
167+
console.log(value);
168+
}, []),
163169
);
164170
165171
// call `sample` function
166172
wire.fns.sample(5);
167-
```
173+
```
168174
*/
169-
export declare function useFn<Fns, K extends KeyOfMethods<Fns>>(
175+
export declare function useFn<Fns extends {}, K extends KeyOfMethods<Fns>>(
170176
wire: FnsWire<Fns> | null | undefined,
171177
name: K,
172178
fn: Fns[K],
@@ -203,12 +209,12 @@ export declare function useInterceptor<W extends StateWire<any>>(
203209
interceptor: Interceptor<WireState<W>>,
204210
): W;
205211

206-
export declare function useSelector<V, Fns = {}>(
212+
export declare function useSelector<V, Fns extends {} = {}>(
207213
options: WritableSelectorOptions<V>,
208214
deps?: DependencyList,
209215
): Wire<V, Fns>;
210216

211-
export declare function useSelector<V, Fns = {}>(
217+
export declare function useSelector<V, Fns extends {} = {}>(
212218
options: ReadOnlySelectorOptions<V>,
213219
deps?: DependencyList,
214220
): ReadonlyWire<V, Fns>;
@@ -218,21 +224,21 @@ export declare function useSubscribe<V>(
218224
callback: (value: Defined<V>) => void,
219225
): void;
220226

221-
export declare function useWire<V, Fns = {}>(
227+
export declare function useWire<V, Fns extends {} = {}>(
222228
upLink: Wire<V, Fns>,
223229
): Wire<V, Fns>;
224230

225-
export declare function useWire<V, Fns = {}>(
231+
export declare function useWire<V, Fns extends {} = {}>(
226232
upLink: Wire<V | undefined, Fns> | null | undefined,
227233
initialValue: InitializerOrValue<V>,
228234
): Wire<V, Fns>;
229235

230-
export declare function useWire<V, Fns = {}>(
236+
export declare function useWire<V, Fns extends {} = {}>(
231237
upLink: Wire<V, Fns> | null | undefined,
232238
initialValue: InitializerOrValue<V>,
233239
): Wire<V, Fns>;
234240

235-
export declare function useWire<V, Fns = {}>(
241+
export declare function useWire<V, Fns extends {} = {}>(
236242
upLink: Wire<V, Fns> | null | undefined,
237243
initialValue?: InitializerOrValue<V | undefined>,
238244
): Wire<V | undefined, Fns>;
@@ -282,7 +288,7 @@ export declare function useWireValue<W extends ReadonlyStateWire<any>>(
282288

283289
declare type valueAndAction<V> = [V, Dispatch<SetStateAction<Defined<V>>>];
284290

285-
export declare type Wire<V, Fns = {}> = StateWire<V> & FnsWire<Fns>;
291+
export declare type Wire<V, Fns extends {} = {}> = StateWire<V> & FnsWire<Fns>;
286292

287293
export declare type WireFns<W extends FnsWire<any>> = W extends FnsWire<
288294
infer Fns
@@ -301,9 +307,8 @@ export declare interface WireId {
301307
_getLinkIds(): LinkIds;
302308
}
303309

304-
export declare type WireState<
305-
W extends ReadonlyStateWire<any>
306-
> = W extends ReadonlyStateWire<infer V> ? V : never;
310+
export declare type WireState<W extends ReadonlyStateWire<any>> =
311+
W extends ReadonlyStateWire<infer V> ? V : never;
307312

308313
export declare interface WritableSelectorOptions<V> {
309314
get: (options: { get: GetWireValue }) => V;

0 commit comments

Comments
 (0)