Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
/keaPublic

Commit396252d

Browse files
authored
Kea 3.0 (#147)
* 3.0 experiment* rewrite core as functions* move 3.0 build steps in place* one step closer to new syntax* add key, path, props* new build* capture key builder* convert reducers test* tweak some tests* clean up many tests* fix function paths* remove proptypes* caniuse* refactor wrappercontext* clean up tests* listeners to core* build heap,* wrapper context tests* path and key like before* two more tests* fix more tests* new wrap component* props update with new props after each build* context defaults* small cleanup* small cleanup* don't allow circular builds* 3.0.0-alpha.0* export the right stuff* refactor selector creation, add errors* fix type tests* reducer types* listener refactor* fix listeners* improve core* 3.0.0-alpha.1* no peer dep on itself* rename getStore to createStore to indicate destructive actions* export a few more types* 3.0.0-alpha.2* extend with builders* 3.0.0-alpha.3* v3* run more plugins faster with more energy today* move out of src* 3.0.0-alpha.4* true logictype for when there are actions* bring back reducerOptions* 3.0.0-alpha.5* plugin types* fix key for old style logic* 3.0.0-alpha.6* can also be '0'* custom isEquals* fix old urls* upgrade to react 18, end up in a place where tests don't work* add useSelector, pause subscriptions when rendering* 3.0.0-alpha.7* use useSyncExternalStore shim* 3.0.0-alpha.8* no transition around these callbacks* 3.0.0-alpha.9* no more <Provider>* tests work again, but fail* fix hook tests* fix more tests* document strict mode* rename pause* add more sync dependencies* 3.0.0-alpha.10* add tsconfig, hopefully aiding IDE navigation* require at least 17* test subscriptions order* wrap useActions in transactions* add pause as well* 3.0.0-alpha.11* remove duplicate test* inline redux* 3.0.0-alpha.12* remove forked redux, use an enhancer instead* 3.0.0-alpha.13* fix test* 3.0.0-alpha.14* improve comment* clean up some JS* connect logic directly* actions are just true or function* remove useKea* add test for withPause* improve error* fix tests* slightly better connect type* comments* merge props* remove provider from tests* simplify imports* reserve some more keywords from plugins* simplify* 3.0.0-beta.0* fix listener builder types* some playground/test logics* stricter types when not importing other actions for reducesr* 3.0.0-beta.1* fix props order* 3.0.0-beta.2* better way to do props* propsChanged* export batchChanges* 3.0.0-beta.3* fix test* fix event tests* work with arrays* 3.0.0-beta.4* batch propsChanged changes to run them outside react's render loop* 3.0.0-beta.5* support actions in reducers that haven't been defined* 3.0.0-beta.6* verify the same for listeners* newsletter link
1 parent3c0b70e commit396252d

File tree

96 files changed

+10496
-13938
lines changed

Some content is hidden

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

96 files changed

+10496
-13938
lines changed

‎.babelrc‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
"@babel/preset-typescript"
1212
],
1313
"plugins": [
14-
"transform-babel-env-inline",
1514
"@babel/plugin-syntax-dynamic-import",
1615
"@babel/plugin-syntax-import-meta",
1716
["@babel/plugin-proposal-class-properties", {"loose":true }],
@@ -55,7 +54,6 @@
5554
"@babel/preset-react"
5655
],
5756
"plugins": [
58-
"transform-babel-env-inline",
5957
"@babel/plugin-syntax-dynamic-import",
6058
"@babel/plugin-syntax-import-meta",
6159
["@babel/plugin-proposal-class-properties", {"loose":true }],

‎.eslintrc.js‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,6 @@ module.exports = {
1010
rules:{
1111
'@typescript-eslint/no-unused-vars':'off',
1212
'@typescript-eslint/explicit-function-return-type':'off',
13+
'@typescript-eslint/no-empty-function':'off',
1314
},
1415
}

‎CHANGELOG.md‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ const logic = kea({
155155

156156
##2.4.0 - 2021-05-02
157157

158-
-**Possibly Breaking:** Changed the[default path](https://kea.js.org/docs/guide/debugging#logic-path) for logic
158+
-**Possibly Breaking:** Changed the[default path](https://v2.keajs.org/docs/guide/debugging#logic-path) for logic
159159
without a`path` (or when not using the kea babel plugin) from`kea.inline` to`kea.logic`. If you have ever hardcoded
160160
`"kea.inline"` anywhere, perhaps in tests, this will cause a bit of headache. If you need it set at`kea.inline`, use
161161
`resetContext({ defaultPath: ['kea', 'inline'] })`.
@@ -215,7 +215,7 @@ const logic = kea({
215215

216216
##2.2.0 - 2020-09-08
217217

218-
-[TypeScript support](https://kea.js.org/docs/guide/typescript)!
218+
-[TypeScript support](https://v2.keajs.org/docs/guide/typescript)!
219219
- Fix bug with the store being created twice.[#111](https://github.com/keajs/kea/issues/111)
220220
- No other breaking changes.
221221

@@ -249,7 +249,7 @@ described below. Read the announcement blog post to get more context: https://ke
249249

250250
There's also a new babel plugin you might want to check out:https://github.com/keajs/babel-plugin-kea
251251

252-
Finally, Kea 2.0 comes with brand new docs on[https://kea.js.org](https://kea.js.org).
252+
Finally, Kea 2.0 comes with brand new docs on[https://v2.keajs.org](https://v2.keajs.org).
253253
(Old docs for[1.0](https://kea-v1.netlify.app/guide/installation) and[0.28](https://5d7a15398fdb1e00073ed27f--kea-v1.netlify.app/))
254254

255255
###Breaking change
@@ -318,7 +318,7 @@ There are too many changes to list here. See [this document](https://github.com/
318318

319319
- Kea now supports plugins!
320320
- The previous saga functionality has moved to[kea-saga](https://github.com/keajs/kea-saga). Please install it to continue using sagas!
321-
- There's a new function,[`getStore`](https://kea.js.org/api/store), which greatly simplifies configuring your store, especially when importing plugins.
321+
- There's a new function,[`getStore`](https://v0.keajs.org/api/store), which greatly simplifies configuring your store, especially when importing plugins.
322322

323323
###Removed deprecations
324324

‎README.md‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,12 @@
66

77
![Kea Logo](https://keajs.org/img/logo.svg)
88

9-
#Kea v2
9+
#Kea v3
10+
11+
**🗞🚨🗞🚨 Subscribe to the[Kea Newsletter](https://keajs.ck.page/80aecebec7) to keep up to date with latest news! 🗞🚨🗞🚨**
12+
13+
[Read the documentation](https://keajs.org/)
1014

11-
Open the[documentation](https://keajs.org/) and read from there.
1215

1316
##Thank you to our backers!
1417

‎docs/CHANGES-1.0.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -796,7 +796,7 @@ These are in incubation for now and will be released soon. Either with 1.0 or so
796796
797797
#### kea-next
798798
799-
Next.js will be an officially first class citizen with Kea 1.0. I'm porting the [https://kea.js.org/](kea.js.org) website over to it. See [this repository](https://github.com/keajs/kea-next-test/) and its issue for the current status.
799+
Next.js will be an officially first class citizen with Kea 1.0. I'm porting the [https://v1.keajs.org/](kea.js.org) website over to it. See [this repository](https://github.com/keajs/kea-next-test/) and its issue for the current status.
800800
801801
#### kea-listeners
802802

‎package.json‎

Lines changed: 22 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name":"kea",
3-
"version":"2.6.0",
3+
"version":"3.0.0-beta.6",
44
"description":"Smart front-end architecture",
55
"author":"Marius Andra",
66
"license":"MIT",
@@ -34,17 +34,17 @@
3434
"test:types:watch":"npm run type-check -- --watch"
3535
},
3636
"files": [
37-
"es",
3837
"lib",
3938
"src",
4039
"README.md",
41-
"LICENSE.md"
40+
"LICENSE.md",
41+
"tsconfig.json"
4242
],
4343
"jest": {
4444
"testMatch": [
4545
"<rootDir>/test/jest/*"
4646
],
47-
"testEnvironment":"node",
47+
"testEnvironment":"jsdom",
4848
"setupFilesAfterEnv": [
4949
"<rootDir>/jest-setup.js"
5050
]
@@ -91,17 +91,16 @@
9191
"@rollup/plugin-babel":"^5.3.0",
9292
"@rollup/plugin-commonjs":"^19.0.0",
9393
"@rollup/plugin-node-resolve":"^13.0.0",
94-
"@testing-library/jest-dom":"^5.14.1",
95-
"@testing-library/react":"^12.0.0",
96-
"@types/jest":"^24.0.25",
97-
"@types/react":"^17.0.13",
98-
"@types/react-redux":"^7.1.16",
94+
"@testing-library/jest-dom":"^5.16.4",
95+
"@testing-library/react":"^13.1.1",
96+
"@types/jest":"^27.4.1",
97+
"@types/react":"^18.0.6",
98+
"@types/react-redux":"^7.1.24",
9999
"@typescript-eslint/eslint-plugin":"^4.28.2",
100100
"@typescript-eslint/parser":"^4.28.2",
101101
"babel-core":"^7.0.0-bridge.0",
102102
"babel-eslint":"^10.1.0",
103-
"babel-jest":"^24.7.1",
104-
"babel-plugin-transform-babel-env-inline":"^0.0.1",
103+
"babel-jest":"^28.0.0",
105104
"cross-env":"^7.0.3",
106105
"eslint":"^7.30.0",
107106
"eslint-config-prettier":"^8.3.0",
@@ -110,23 +109,25 @@
110109
"eslint-plugin-prettier":"^3.4.0",
111110
"eslint-plugin-promise":"^5.1.0",
112111
"eslint-plugin-react":"^7.24.0",
113-
"jest":"^24.7.1",
112+
"jest":"^28.0.0",
113+
"jest-environment-jsdom":"^28.0.0",
114114
"jest-environment-node-debug":"^2.0.0",
115-
"jsdom":"^15.0.0",
116115
"npm-run-all-v2":"^1.0.0",
117116
"prettier":"^2.3.2",
118-
"prop-types":"^15.7.2",
119-
"react":"^17.0.2",
120-
"react-dom":"^17.0.2",
121-
"react-redux":"^7.0.1",
122-
"react-test-renderer":"^17.0.2",
123-
"redux":"^4.2.0",
124-
"reselect":"^4.1.5",
117+
"react":"^18.0.0",
118+
"react-dom":"^18.0.0",
119+
"react-redux":"^8.0.1",
120+
"react-test-renderer":"^18.0.0",
125121
"rimraf":"^3.0.2",
126122
"rollup":"^2.52.7",
127123
"rollup-plugin-dts":"^3.0.2",
128124
"rollup-plugin-typescript2":"^0.30.0",
129125
"tsd":"^0.17.0",
130-
"typescript":"^4.5.2"
126+
"typescript":"^4.6.3"
127+
},
128+
"dependencies": {
129+
"redux":"^4.2.0",
130+
"reselect":"^4.1.5",
131+
"use-sync-external-store":"^1.0.0"
131132
}
132133
}

‎playground/3.0/githubLogic.ts‎

Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
1+
import{githubLogicType}from'./githubLogicType'
2+
import{kea}from'../../src'
3+
import{
4+
connect,
5+
actions,
6+
defaults,
7+
reducers,
8+
selectors,
9+
afterMount,
10+
listeners,
11+
key,
12+
props,
13+
path,
14+
}from'../../src/core'
15+
16+
constAPI_URL='https://api.github.com'
17+
18+
exporttypeRepository={
19+
id:number
20+
stargazers_count:number
21+
html_url:string
22+
full_name:string
23+
forks:number
24+
}
25+
26+
exportinterfaceGithubLogicProps{
27+
id:number
28+
}
29+
30+
exportconstgithubLogic=kea<githubLogicType<Repository,GithubLogicProps>>([
31+
path(['scenes','github','githubLogic']),
32+
props({}asGithubLogicProps),
33+
key((props)=>props.id),
34+
35+
actions({
36+
setUsername:(username:string)=>({ username}),
37+
setRepositories:(repositories:Repository[])=>({ repositories}),
38+
setFetchError:(error:string)=>({ error}),
39+
}),
40+
connect({
41+
actions:[],
42+
}),
43+
defaults({
44+
username:'keajs',
45+
repositories:[]asRepository[],
46+
}),
47+
{
48+
reducers:{
49+
username:{
50+
setUsername:(_,{ username})=>username,
51+
},
52+
},
53+
},
54+
reducers({
55+
username:{
56+
setUsername:(_,{ username})=>username,
57+
},
58+
repositories:{
59+
setUsername:()=>[],
60+
setRepositories:(_,{ repositories})=>repositories,
61+
},
62+
isLoading:[
63+
false,
64+
{
65+
setUsername:()=>true,
66+
setRepositories:()=>false,
67+
setFetchError:()=>false,
68+
},
69+
],
70+
error:[
71+
nullasstring|null,
72+
{
73+
setUsername:()=>null,
74+
setFetchError:(_,{ error})=>error,
75+
},
76+
],
77+
}),
78+
79+
selectors({
80+
sortedRepositories:[
81+
(s)=>[s.repositories],
82+
(repositories)=>{
83+
return[...repositories].sort((a,b)=>b.stargazers_count-a.stargazers_count)
84+
},
85+
],
86+
}),
87+
88+
listeners(({ actions})=>({
89+
setUsername:async({ username},breakpoint,action,fullState)=>{
90+
awaitbreakpoint(300)
91+
92+
consturl=`${API_URL}/users/${username}/repos?per_page=250`
93+
94+
// 👈 handle network errors
95+
letresponse
96+
try{
97+
response=awaitwindow.fetch(url)
98+
}catch(error:any){
99+
actions.setFetchError(error.message)
100+
return// 👈 nothing to do after, so return
101+
}
102+
103+
// break if action was dispatched again while we were fetching
104+
breakpoint()
105+
106+
constjson=awaitresponse.json()
107+
108+
if(response.status===200){
109+
actions.setRepositories(json)
110+
}else{
111+
actions.setFetchError(json.message)
112+
}
113+
},
114+
})),
115+
116+
afterMount(({ actions, values})=>{
117+
actions.setUsername(values.username)
118+
}),
119+
])

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp