From 0665d7816096ed7a386045eb683b5984cebe4e31 Mon Sep 17 00:00:00 2001 From: fancyzhong Date: Sat, 12 Dec 2020 19:17:42 +0800 Subject: [PATCH 1/3] feature: add cra-template-concent-ts --- packages/cra-template-concent-ts/README.md | 22 +++ packages/cra-template-concent-ts/package.json | 28 ++++ .../cra-template-concent-ts/template.json | 18 +++ .../template/.gitignore | 23 +++ .../template/README.md | 44 ++++++ .../template/public/favicon.ico | Bin 0 -> 3585 bytes .../template/public/index.html | 43 ++++++ .../template/public/logo192.png | Bin 0 -> 4153 bytes .../template/public/logo512.png | Bin 0 -> 12066 bytes .../template/public/manifest.json | 25 +++ .../template/public/robots.txt | 3 + .../template/src/App.css | 39 +++++ .../template/src/App.test.tsx | 15 ++ .../template/src/App.tsx | 42 +++++ .../template/src/configs/c2Mods.ts | 7 + .../template/src/configs/runConcent.ts | 5 + .../template/src/configs/useC2Mod.ts | 11 ++ .../src/features/counter/Counter.module.css | 81 ++++++++++ .../template/src/features/counter/Counter.tsx | 59 +++++++ .../src/features/counter/CounterTip.tsx | 17 ++ .../src/features/counter/model/computed.ts | 6 + .../src/features/counter/model/index.ts | 12 ++ .../src/features/counter/model/reducer.ts | 46 ++++++ .../src/features/counter/model/state.ts | 10 ++ .../template/src/index.css | 13 ++ .../template/src/index.tsx | 18 +++ .../template/src/logo.svg | 1 + .../template/src/models/global/index.ts | 8 + .../template/src/models/global/state.ts | 9 ++ .../template/src/models/index.ts | 10 ++ .../template/src/react-app-env.d.ts | 1 + .../template/src/serviceWorker.ts | 146 ++++++++++++++++++ .../template/src/setupTests.ts | 5 + .../template/src/types/store.ts | 146 ++++++++++++++++++ .../template/tsconfig.json | 21 +++ 35 files changed, 934 insertions(+) create mode 100644 packages/cra-template-concent-ts/README.md create mode 100644 packages/cra-template-concent-ts/package.json create mode 100644 packages/cra-template-concent-ts/template.json create mode 100644 packages/cra-template-concent-ts/template/.gitignore create mode 100644 packages/cra-template-concent-ts/template/README.md create mode 100644 packages/cra-template-concent-ts/template/public/favicon.ico create mode 100644 packages/cra-template-concent-ts/template/public/index.html create mode 100644 packages/cra-template-concent-ts/template/public/logo192.png create mode 100644 packages/cra-template-concent-ts/template/public/logo512.png create mode 100644 packages/cra-template-concent-ts/template/public/manifest.json create mode 100644 packages/cra-template-concent-ts/template/public/robots.txt create mode 100644 packages/cra-template-concent-ts/template/src/App.css create mode 100644 packages/cra-template-concent-ts/template/src/App.test.tsx create mode 100644 packages/cra-template-concent-ts/template/src/App.tsx create mode 100644 packages/cra-template-concent-ts/template/src/configs/c2Mods.ts create mode 100644 packages/cra-template-concent-ts/template/src/configs/runConcent.ts create mode 100644 packages/cra-template-concent-ts/template/src/configs/useC2Mod.ts create mode 100644 packages/cra-template-concent-ts/template/src/features/counter/Counter.module.css create mode 100644 packages/cra-template-concent-ts/template/src/features/counter/Counter.tsx create mode 100644 packages/cra-template-concent-ts/template/src/features/counter/CounterTip.tsx create mode 100644 packages/cra-template-concent-ts/template/src/features/counter/model/computed.ts create mode 100644 packages/cra-template-concent-ts/template/src/features/counter/model/index.ts create mode 100644 packages/cra-template-concent-ts/template/src/features/counter/model/reducer.ts create mode 100644 packages/cra-template-concent-ts/template/src/features/counter/model/state.ts create mode 100644 packages/cra-template-concent-ts/template/src/index.css create mode 100644 packages/cra-template-concent-ts/template/src/index.tsx create mode 100644 packages/cra-template-concent-ts/template/src/logo.svg create mode 100644 packages/cra-template-concent-ts/template/src/models/global/index.ts create mode 100644 packages/cra-template-concent-ts/template/src/models/global/state.ts create mode 100644 packages/cra-template-concent-ts/template/src/models/index.ts create mode 100644 packages/cra-template-concent-ts/template/src/react-app-env.d.ts create mode 100644 packages/cra-template-concent-ts/template/src/serviceWorker.ts create mode 100644 packages/cra-template-concent-ts/template/src/setupTests.ts create mode 100644 packages/cra-template-concent-ts/template/src/types/store.ts create mode 100644 packages/cra-template-concent-ts/template/tsconfig.json diff --git a/packages/cra-template-concent-ts/README.md b/packages/cra-template-concent-ts/README.md new file mode 100644 index 00000000000..db393c4478e --- /dev/null +++ b/packages/cra-template-concent-ts/README.md @@ -0,0 +1,22 @@ +# cra-template-concent-ts + +The official [Concent](https://github.com/concentjs/concent)+TS template for Create React App. + +You can checkout it from [here](https://github.com/concentjs/cra-template-concent-ts) + +To use this template, add `--template concent-ts` when creating a new app. + +For example: + +```sh +npx create-react-app my-app --template concent-ts + +# or + +yarn create react-app my-app --template concent-ts +``` + +For more information, please refer to: + +- [Getting Started](https://create-react-app.dev/docs/getting-started) – How to create a new app. +- [User Guide](https://create-react-app.dev) – How to develop apps bootstrapped with Create React App. diff --git a/packages/cra-template-concent-ts/package.json b/packages/cra-template-concent-ts/package.json new file mode 100644 index 00000000000..7ac9b9de9fb --- /dev/null +++ b/packages/cra-template-concent-ts/package.json @@ -0,0 +1,28 @@ +{ + "name": "cra-template-concent-ts", + "version": "1.0.0", + "keywords": [ + "react", + "create-react-app", + "template", + "typescript", + "concent" + ], + "description": "The base Concent TypeScript template for Create React App.", + "repository": { + "type": "git", + "url": "https://github.com/facebook/create-react-app.git", + "directory": "packages/cra-template-concent-ts" + }, + "license": "MIT", + "engines": { + "node": ">=10" + }, + "bugs": { + "url": "https://github.com/facebook/create-react-app/issues" + }, + "files": [ + "template", + "template.json" + ] +} diff --git a/packages/cra-template-concent-ts/template.json b/packages/cra-template-concent-ts/template.json new file mode 100644 index 00000000000..36637c0fac7 --- /dev/null +++ b/packages/cra-template-concent-ts/template.json @@ -0,0 +1,18 @@ +{ + "package": { + "dependencies": { + "@testing-library/jest-dom": "^4.2.4", + "@testing-library/react": "^9.3.2", + "@testing-library/user-event": "^7.1.2", + "@types/node": "^12.0.0", + "@types/react": "^16.13.0", + "@types/react-dom": "^16.13.0", + "@types/jest": "^24.0.0", + "typescript": "^4.1.2", + "concent": "^2.10.5" + }, + "eslintConfig": { + "extends": ["react-app", "react-app/jest"] + } + } +} diff --git a/packages/cra-template-concent-ts/template/.gitignore b/packages/cra-template-concent-ts/template/.gitignore new file mode 100644 index 00000000000..4d29575de80 --- /dev/null +++ b/packages/cra-template-concent-ts/template/.gitignore @@ -0,0 +1,23 @@ +# See https://help.github.com/articles/ignoring-files/ for more about ignoring files. + +# dependencies +/node_modules +/.pnp +.pnp.js + +# testing +/coverage + +# production +/build + +# misc +.DS_Store +.env.local +.env.development.local +.env.test.local +.env.production.local + +npm-debug.log* +yarn-debug.log* +yarn-error.log* diff --git a/packages/cra-template-concent-ts/template/README.md b/packages/cra-template-concent-ts/template/README.md new file mode 100644 index 00000000000..6070bbc1297 --- /dev/null +++ b/packages/cra-template-concent-ts/template/README.md @@ -0,0 +1,44 @@ +This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app), using the [Concent](https://github.com/concentjs/concent). + +## Available Scripts + +In the project directory, you can run: + +### `yarn start` + +Runs the app in the development mode.
+Open [http://localhost:3000](http://localhost:3000) to view it in the browser. + +The page will reload if you make edits.
+You will also see any lint errors in the console. + +### `yarn test` + +Launches the test runner in the interactive watch mode.
+See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information. + +### `yarn build` + +Builds the app for production to the `build` folder.
+It correctly bundles React in production mode and optimizes the build for the best performance. + +The build is minified and the filenames include the hashes.
+Your app is ready to be deployed! + +See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information. + +### `yarn eject` + +**Note: this is a one-way operation. Once you `eject`, you can’t go back!** + +If you aren’t satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project. + +Instead, it will copy all the configuration files and the transitive dependencies (webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point you’re on your own. + +You don’t have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldn’t feel obligated to use this feature. However we understand that this tool wouldn’t be useful if you couldn’t customize it when you are ready for it. + +## Learn More + +You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started). + +To learn React, check out the [React documentation](https://reactjs.org/). diff --git a/packages/cra-template-concent-ts/template/public/favicon.ico b/packages/cra-template-concent-ts/template/public/favicon.ico new file mode 100644 index 0000000000000000000000000000000000000000..354202a4e6baec3429e928e13d54144f8eebb62c GIT binary patch literal 3585 zcmV+c4*v0pP)% zYj70TmB)YGJu{l8G&7P0y@k*V1m-0hzpzcfG0wwaleL{kZM?26$JyQNZlx+8cWb>> zo2`7=N2;><c;ao%at1QB#J?`vP`$f4hp!I|FG) zQ`ZH3?UNk&uWNL-h71E`_}X98@Zi33ELJ(&rjpebbxrWe`vaVPtJ~~+X^n>${&gF7 zf3p|jCW6t~5*m>dy zb>tU2k>#Z?YlWpwo_Mj&bo=O}%KN|RLQ|IzL^DKI3Hb165B(isV9Ir$uc2zA_m0{s zS?A&L=c-Yx264fw<20YSNw#Nf)(99Gi1BIDP4l{TtDlB@3zpU9hItY7Z6l+0j-u?+lRRG>D9aRf3;QWTo9{WQBluROLqVOq6c8uaF!^ zc9Iu|+rqj{KJz-;t3g%>7zjp)g^kE>vC7mp`m@n20J0)cy~Q^r-oap3ghV`haUd%M zOeZY>MQdF+T-Izf3m8?Quh4GR1o4Q<#8CF)Kvw*;zkSmDe_@#mYtC$5bzRVPZGyA^ z*F#6k7#5pMxW+(d*!=s+Uw6{q9_HIW*$99n8UGksfRPn4r3?7iIN1CBb%ZBUgofkz z);N}HwuxmE5S>gBkIu|Vhueaz%w&B+hx5mKXLTM7ueki-5dZkCQvldq7TjJNcBg_b zU?))FCQ$CApv1|VN;g)UjK^!kJ`|_DWt=ldx~Xf-r*Tga zb=&f1dD@*~*#t107+8 z`=f+L5=16aW@QNL{XeYd#h-1bcH2zK-P<Rt(qx>zc_F%CYO~s=cy={{Vwv#PXZt(KVj~m#& zyU5fECx#Qe@r%zG?u{;4I9U<_siekxuXWIT=B63Msy2ElUh4+H?zYYfH=|RHd$yxVv^K*FWN9)=3OeNA(Pe%G;9RB%LLs?z|77d+32riu- zP5P*XbHtszdn*2$B9U5~|*evB9O zfY_wU$^Y#nF_rEXSGhUxcQc&_V{X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k08SM+`nz7A&;rD$se=tZYzVu^jibZ1GW*_VCDWG8w)jL~rWYy`?&R5s*MeV5PNIbO&ur;pT+4#c=}ZipMrV@!-B2#q9&M^*E9y`o4s zJXYLZD}gc>>vt5e@%}<`?CIl0RtUHqx+aK(Qu7cX;qfhRCpQt(m>f+oF_It=RZT%f zu}C=FR@`12-a`Abj?jMTKbet%E30kAD&mSPggA)tY3Y{@su1F!EJ@NK;KFKKvkJH% zNz$P&{in0j;qzVKX^hWFzsS=;#pvUH;50D%bc^^Bem?*Ihu+H91%a4J00000NkvXX Hu0mjfhdT@% literal 0 HcmV?d00001 diff --git a/packages/cra-template-concent-ts/template/public/index.html b/packages/cra-template-concent-ts/template/public/index.html new file mode 100644 index 00000000000..1dbdca65e86 --- /dev/null +++ b/packages/cra-template-concent-ts/template/public/index.html @@ -0,0 +1,43 @@ + + + + + + + + + + + + + React Redux App + + + +
+ + + diff --git a/packages/cra-template-concent-ts/template/public/logo192.png b/packages/cra-template-concent-ts/template/public/logo192.png new file mode 100644 index 0000000000000000000000000000000000000000..33624109cdc98874ea8657a2a3a7ce71c81d1837 GIT binary patch literal 4153 zcmbtY`8U*!_kX{~V1@=W)+B~T_AJ@5WX3*ZiLy^A#RySCnlN_qh%8C6RhF`)(1h%I zWC@Wn_I(h8&|vWK{0raj53hUg>z;dmd7X35z30YTTbdv^ggF2JK;TUcZH|1?e}J(a zS({OB_9F-PGj;R_0Dk@d02)>5*8l+bGTsn(={|LZU~yOYE9$^lnY3w%o`+6nV>KP# z^U$HUva$Eu@2;h!ufs>R!uum6r-l%dP!vmFZ z^-OXH#`sID8365GK%V`SS0M0yy4oS>3gtZp+o7)qTGv0|I%wx5->VcYqfjweY5g#` zD+e0%`_b2^3z&lPp8Tf3M1)?z>lHOk4*2{i5|xLa$|VUfZ3V8G{fvVWCEi(_xEJuY z4F(^RKs80zon>F+X`T@UFFZ5;5y^hdm-7$^7Typ~FepKlnmFB8g4x zQ@ZQ(GuDCx^f1#mrX|;KtX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VQ$!i!sJ3-1%WkK+7T!FUMYu$^Ps_>ggVz)T<7DC9}yBrrasno#i08y&z6 z_44lY+mVPlHFD&)wungRu4Cc?VftQf9s!U4eR9?9s{C}-v{rD5`<5Bdg}JYAi8Sk2 z)S~r!omBS}46T`#J_wZgU7-=;=pmbsUvft}ElT=PNKc3ypJBvrgP~(yNXqYv%j~_zJ5_&)Rv!gsJ#!A#9 zCEA3Xg3oO&rQf7UM|>ZQDI~Q{B(dU7-exl*+YhppE2u4D8Y-xrIh+^6LTm~{^v zhoq^8z(`xF7M>pmpVsJo5VajFk=_F79vT->lRv&ly~|a2AMO!PutU_C&}TfX3Pf2O z=b-oJ*f7Pp4@#B?JR~+V>33P-aS8UY8=7gQljrYcK6(U5btpCWw#wQMznV_=NvKzw zK0m3JnKm@r8EIo0!Zo_e2Y#clh72=97XxmhX~~JB3Ge=Wxbs@GSXdL?hHMmlYgA`h zCJy93F4(QO!rB?@tj(lOY0JsQ#yGHyE@j7`@ literal 0 HcmV?d00001 diff --git a/packages/cra-template-concent-ts/template/public/logo512.png b/packages/cra-template-concent-ts/template/public/logo512.png new file mode 100644 index 0000000000000000000000000000000000000000..b3516222f0b978579b871c871b955b5fc5b4ca5e GIT binary patch literal 12066 zcmb_?={uC)|M;0P7$!_*$v%Z7p;X8^k&tYOtf5V0CuEyJO4dlJtVOm6+1D9Lq>z1Y zY&CYqlCjLp_xAn+eh+@v=fQp5XXc#yb9f%y&dJ_i5;^e$bz?mx0LZsa8}Soe)0ng4V06ZQ`CF=^x6 zBl2j=&{g&roddB?V`6S#%EK~YS|>Z$;nK*$2}$!zmD%JYDv1XU1=B+`%s$QhZtueO zZtSLRrK;0C<3z}^h`i-um%<^Tab|APS@0t1lH^S>CtAUM$Z0Qesa_UVn;hxPwI z@c%6*1jo32S$;2*FXhDOdPN(qQ(h|`(X$#RXb9~EO6g5M%AL8-G)JAIP!h7hSJT;1 z^D)#eIbyo1^ksReaYdZL_@3cd1yI2d!bY5y~U%~dLl;;z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WJRSg^YclKB6X&YYpq-h`ae-rA4 A^#A|> literal 0 HcmV?d00001 diff --git a/packages/cra-template-concent-ts/template/public/manifest.json b/packages/cra-template-concent-ts/template/public/manifest.json new file mode 100644 index 00000000000..080d6c77ac2 --- /dev/null +++ b/packages/cra-template-concent-ts/template/public/manifest.json @@ -0,0 +1,25 @@ +{ + "short_name": "React App", + "name": "Create React App Sample", + "icons": [ + { + "src": "favicon.ico", + "sizes": "64x64 32x32 24x24 16x16", + "type": "image/x-icon" + }, + { + "src": "logo192.png", + "type": "image/png", + "sizes": "192x192" + }, + { + "src": "logo512.png", + "type": "image/png", + "sizes": "512x512" + } + ], + "start_url": ".", + "display": "standalone", + "theme_color": "#000000", + "background_color": "#ffffff" +} diff --git a/packages/cra-template-concent-ts/template/public/robots.txt b/packages/cra-template-concent-ts/template/public/robots.txt new file mode 100644 index 00000000000..e9e57dc4d41 --- /dev/null +++ b/packages/cra-template-concent-ts/template/public/robots.txt @@ -0,0 +1,3 @@ +# https://www.robotstxt.org/robotstxt.html +User-agent: * +Disallow: diff --git a/packages/cra-template-concent-ts/template/src/App.css b/packages/cra-template-concent-ts/template/src/App.css new file mode 100644 index 00000000000..01cc5867703 --- /dev/null +++ b/packages/cra-template-concent-ts/template/src/App.css @@ -0,0 +1,39 @@ +.App { + text-align: center; +} + +.App-logo { + height: 40vmin; + pointer-events: none; +} + +@media (prefers-reduced-motion: no-preference) { + .App-logo { + animation: App-logo-float infinite 3s ease-in-out; + } +} + +.App-header { + min-height: 100vh; + display: flex; + flex-direction: column; + align-items: center; + justify-content: center; + font-size: calc(10px + 2vmin); +} + +.App-link { + color: rgb(112, 76, 182); +} + +@keyframes App-logo-float { + 0% { + transform: translateY(0); + } + 50% { + transform: translateY(10px); + } + 100% { + transform: translateY(0px); + } +} diff --git a/packages/cra-template-concent-ts/template/src/App.test.tsx b/packages/cra-template-concent-ts/template/src/App.test.tsx new file mode 100644 index 00000000000..659cc13d3bb --- /dev/null +++ b/packages/cra-template-concent-ts/template/src/App.test.tsx @@ -0,0 +1,15 @@ +import React from 'react'; +import { render } from '@testing-library/react'; +import { Provider } from 'react-redux'; +import { store } from './app/store'; +import App from './App'; + +test('renders learn react link', () => { + const { getByText } = render( + + + + ); + + expect(getByText(/learn/i)).toBeInTheDocument(); +}); diff --git a/packages/cra-template-concent-ts/template/src/App.tsx b/packages/cra-template-concent-ts/template/src/App.tsx new file mode 100644 index 00000000000..70c170a33f4 --- /dev/null +++ b/packages/cra-template-concent-ts/template/src/App.tsx @@ -0,0 +1,42 @@ +import React from 'react'; +import logo from './logo.svg'; +import { Counter } from 'features/counter/Counter'; +import { CounterTip } from 'features/counter/CounterTip'; +import './App.css'; + +function App() { + return ( +
+
+ logo + +

+ Edit src/App.tsx and save to reload. +

+ + Learn + + React + + , + + Concent + + + +
+
+ ); +} + +export default App; diff --git a/packages/cra-template-concent-ts/template/src/configs/c2Mods.ts b/packages/cra-template-concent-ts/template/src/configs/c2Mods.ts new file mode 100644 index 00000000000..d0c962897b5 --- /dev/null +++ b/packages/cra-template-concent-ts/template/src/configs/c2Mods.ts @@ -0,0 +1,7 @@ +/** + * delare module names in this file + */ + +export const COUNTER = 'Counter' as const; + +export type COUNTER_T = typeof COUNTER; diff --git a/packages/cra-template-concent-ts/template/src/configs/runConcent.ts b/packages/cra-template-concent-ts/template/src/configs/runConcent.ts new file mode 100644 index 00000000000..ccb4dd27daa --- /dev/null +++ b/packages/cra-template-concent-ts/template/src/configs/runConcent.ts @@ -0,0 +1,5 @@ +import { run } from 'concent'; +import models from '../models'; + +// load all models by concent.run api +run(models); diff --git a/packages/cra-template-concent-ts/template/src/configs/useC2Mod.ts b/packages/cra-template-concent-ts/template/src/configs/useC2Mod.ts new file mode 100644 index 00000000000..abd296a417f --- /dev/null +++ b/packages/cra-template-concent-ts/template/src/configs/useC2Mod.ts @@ -0,0 +1,11 @@ +import { useConcent } from 'concent'; +import { CtxM, Modules } from '../types/store'; + +/** + * use the target model context you want by passing a module name + * @param moduleName + */ +export function useC2Mod(moduleName: T) { + type Ctx = CtxM<{}, typeof moduleName>; + return useConcent<{}, Ctx>(moduleName); +} diff --git a/packages/cra-template-concent-ts/template/src/features/counter/Counter.module.css b/packages/cra-template-concent-ts/template/src/features/counter/Counter.module.css new file mode 100644 index 00000000000..6685b780ed6 --- /dev/null +++ b/packages/cra-template-concent-ts/template/src/features/counter/Counter.module.css @@ -0,0 +1,81 @@ +.row { + display: flex; + align-items: center; + justify-content: center; +} + +.row:not(:last-child) { + margin-bottom: 16px; +} + +.value { + font-size: 78px; + padding-left: 16px; + padding-right: 16px; + margin-top: 2px; + font-family: 'Courier New', Courier, monospace; +} + +.button { + appearance: none; + background: none; + font-size: 32px; + padding-left: 12px; + padding-right: 12px; + outline: none; + border: 2px solid transparent; + color: rgb(112, 76, 182); + padding-bottom: 4px; + cursor: pointer; + background-color: rgba(112, 76, 182, 0.1); + border-radius: 2px; + transition: all 0.15s; +} + +.textbox { + font-size: 32px; + padding: 2px; + width: 64px; + text-align: center; + margin-right: 8px; +} + +.button:hover, +.button:focus { + border: 2px solid rgba(112, 76, 182, 0.4); +} + +.button:active { + background-color: rgba(112, 76, 182, 0.2); +} + +.asyncButton { + composes: button; + position: relative; + margin-left: 8px; +} + +.normalButton { + composes: button; + position: relative; + margin-left: 8px; +} + +.asyncButton:after { + content: ''; + background-color: rgba(112, 76, 182, 0.15); + display: block; + position: absolute; + width: 100%; + height: 100%; + left: 0; + top: 0; + opacity: 0; + transition: width 1s linear, opacity 0.5s ease 1s; +} + +.asyncButton:active:after { + width: 0%; + opacity: 1; + transition: 0s; +} diff --git a/packages/cra-template-concent-ts/template/src/features/counter/Counter.tsx b/packages/cra-template-concent-ts/template/src/features/counter/Counter.tsx new file mode 100644 index 00000000000..cc7148e7299 --- /dev/null +++ b/packages/cra-template-concent-ts/template/src/features/counter/Counter.tsx @@ -0,0 +1,59 @@ +import React, { useState } from 'react'; +import { useC2Mod } from 'configs/useC2Mod'; +import { COUNTER } from 'configs/c2Mods'; +import styles from './Counter.module.css'; + +export function Counter() { + const ctx = useC2Mod(COUNTER); + // module state, module computed, module reducer + const { state, moduleComputed, mr } = ctx; + const [incrementAmount, setIncrementAmount] = useState('2'); + + return ( +
+
+ + {state.value} + + doubleCount: {moduleComputed.doubleCount} + + +
+
+ setIncrementAmount(e.target.value)} + /> + + + +
+
+ ); +} diff --git a/packages/cra-template-concent-ts/template/src/features/counter/CounterTip.tsx b/packages/cra-template-concent-ts/template/src/features/counter/CounterTip.tsx new file mode 100644 index 00000000000..a05dc5e5461 --- /dev/null +++ b/packages/cra-template-concent-ts/template/src/features/counter/CounterTip.tsx @@ -0,0 +1,17 @@ +import React, { useState } from 'react'; +import { useC2Mod } from 'configs/useC2Mod'; +import { COUNTER } from 'configs/c2Mods'; + +export const CounterTip = React.memo(function CounterTip() { + const ctx = useC2Mod(COUNTER); + // module state, module computed + const { state, moduleComputed } = ctx; + + return ( +
+ value:{state.value} + bigValue:{state.bigValue} + doubleCount:{moduleComputed.doubleCount} +
+ ); +}); diff --git a/packages/cra-template-concent-ts/template/src/features/counter/model/computed.ts b/packages/cra-template-concent-ts/template/src/features/counter/model/computed.ts new file mode 100644 index 00000000000..a7205406326 --- /dev/null +++ b/packages/cra-template-concent-ts/template/src/features/counter/model/computed.ts @@ -0,0 +1,6 @@ +import { St } from './state'; + +// only value change will triiger this function to execute again +export function doubleCount({ value }: St) { + return value * 2; +} diff --git a/packages/cra-template-concent-ts/template/src/features/counter/model/index.ts b/packages/cra-template-concent-ts/template/src/features/counter/model/index.ts new file mode 100644 index 00000000000..8891fd4effa --- /dev/null +++ b/packages/cra-template-concent-ts/template/src/features/counter/model/index.ts @@ -0,0 +1,12 @@ +import { COUNTER } from '../../../configs/c2Mods'; +import state from './state'; +import * as computed from './computed'; +import * as reducer from './reducer'; + +export default { + [COUNTER]: { + state, + computed, + reducer, + }, +}; diff --git a/packages/cra-template-concent-ts/template/src/features/counter/model/reducer.ts b/packages/cra-template-concent-ts/template/src/features/counter/model/reducer.ts new file mode 100644 index 00000000000..7ef942459c8 --- /dev/null +++ b/packages/cra-template-concent-ts/template/src/features/counter/model/reducer.ts @@ -0,0 +1,46 @@ +import { St } from './state'; +import { VoidPayloadMev, AC } from 'types/store'; +import { COUNTER_T } from 'configs/c2Mods'; + +type IAC = AC; + +const delay = (ms = 1000) => new Promise(r => setTimeout(r, ms)); + +export function incrementBigValue( + payload: VoidPayloadMev, + moduleState: St +): Partial { + return { bigValue: moduleState.bigValue + 50 }; +} + +export function increment( + payload: VoidPayloadMev, + moduleState: St +): Partial { + return { value: moduleState.value + 1 }; +} + +export function decrement( + payload: VoidPayloadMev, + moduleState: St +): Partial { + return { value: moduleState.value - 1 }; +} + +export function incrementByAmount( + amount: number, + moduleState: St +): Partial { + return { value: moduleState.value + amount }; +} + +export async function incrementAsync( + amount: number, + moduleState: St, + ac: IAC +): Promise> { + await delay(); + // or just write ac.dispatch of return + // await ac.dispatch(incrementByAmount, amount); + return { value: moduleState.value + amount }; +} diff --git a/packages/cra-template-concent-ts/template/src/features/counter/model/state.ts b/packages/cra-template-concent-ts/template/src/features/counter/model/state.ts new file mode 100644 index 00000000000..dfa4246fc37 --- /dev/null +++ b/packages/cra-template-concent-ts/template/src/features/counter/model/state.ts @@ -0,0 +1,10 @@ +function getInitialState() { + return { + value: 0, + bigValue: 100, + }; +} + +export type St = ReturnType; + +export default getInitialState; diff --git a/packages/cra-template-concent-ts/template/src/index.css b/packages/cra-template-concent-ts/template/src/index.css new file mode 100644 index 00000000000..ec2585e8c0b --- /dev/null +++ b/packages/cra-template-concent-ts/template/src/index.css @@ -0,0 +1,13 @@ +body { + margin: 0; + font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', + 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', + sans-serif; + -webkit-font-smoothing: antialiased; + -moz-osx-font-smoothing: grayscale; +} + +code { + font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New', + monospace; +} diff --git a/packages/cra-template-concent-ts/template/src/index.tsx b/packages/cra-template-concent-ts/template/src/index.tsx new file mode 100644 index 00000000000..b3b227c68cd --- /dev/null +++ b/packages/cra-template-concent-ts/template/src/index.tsx @@ -0,0 +1,18 @@ +import React from 'react'; +import ReactDOM from 'react-dom'; +import 'configs/runConcent'; +import './index.css'; +import App from './App'; +import * as serviceWorker from './serviceWorker'; + +ReactDOM.render( + + + , + document.getElementById('root') +); + +// If you want your app to work offline and load faster, you can change +// unregister() to register() below. Note this comes with some pitfalls. +// Learn more about service workers: https://bit.ly/CRA-PWA +serviceWorker.unregister(); diff --git a/packages/cra-template-concent-ts/template/src/logo.svg b/packages/cra-template-concent-ts/template/src/logo.svg new file mode 100644 index 00000000000..84667388ceb --- /dev/null +++ b/packages/cra-template-concent-ts/template/src/logo.svg @@ -0,0 +1 @@ + diff --git a/packages/cra-template-concent-ts/template/src/models/global/index.ts b/packages/cra-template-concent-ts/template/src/models/global/index.ts new file mode 100644 index 00000000000..85860fdee5d --- /dev/null +++ b/packages/cra-template-concent-ts/template/src/models/global/index.ts @@ -0,0 +1,8 @@ +import { cst } from 'concent'; +import state from './state'; + +export default { + [cst.MODULE_GLOBAL]: { + state, + }, +}; diff --git a/packages/cra-template-concent-ts/template/src/models/global/state.ts b/packages/cra-template-concent-ts/template/src/models/global/state.ts new file mode 100644 index 00000000000..273aeb54603 --- /dev/null +++ b/packages/cra-template-concent-ts/template/src/models/global/state.ts @@ -0,0 +1,9 @@ +function getInitialState() { + return { + someInfo: `overWrite built-in module global's state`, + }; +} + +export type St = ReturnType; + +export default getInitialState; diff --git a/packages/cra-template-concent-ts/template/src/models/index.ts b/packages/cra-template-concent-ts/template/src/models/index.ts new file mode 100644 index 00000000000..5400976e0ff --- /dev/null +++ b/packages/cra-template-concent-ts/template/src/models/index.ts @@ -0,0 +1,10 @@ +// you should declare all models here then expose it +import counterModel from '../features/counter/model'; +import globalModel from './global'; + +const allModels = { + ...globalModel, + ...counterModel, +}; + +export default allModels; diff --git a/packages/cra-template-concent-ts/template/src/react-app-env.d.ts b/packages/cra-template-concent-ts/template/src/react-app-env.d.ts new file mode 100644 index 00000000000..6431bc5fc6b --- /dev/null +++ b/packages/cra-template-concent-ts/template/src/react-app-env.d.ts @@ -0,0 +1 @@ +/// diff --git a/packages/cra-template-concent-ts/template/src/serviceWorker.ts b/packages/cra-template-concent-ts/template/src/serviceWorker.ts new file mode 100644 index 00000000000..109ab0e1de9 --- /dev/null +++ b/packages/cra-template-concent-ts/template/src/serviceWorker.ts @@ -0,0 +1,146 @@ +// This optional code is used to register a service worker. +// register() is not called by default. + +// This lets the app load faster on subsequent visits in production, and gives +// it offline capabilities. However, it also means that developers (and users) +// will only see deployed updates on subsequent visits to a page, after all the +// existing tabs open on the page have been closed, since previously cached +// resources are updated in the background. + +// To learn more about the benefits of this model and instructions on how to +// opt-in, read https://bit.ly/CRA-PWA + +const isLocalhost = Boolean( + window.location.hostname === 'localhost' || + // [::1] is the IPv6 localhost address. + window.location.hostname === '[::1]' || + // 127.0.0.0/8 are considered localhost for IPv4. + window.location.hostname.match( + /^127(?:\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}$/ + ) +); + +type Config = { + onSuccess?: (registration: ServiceWorkerRegistration) => void; + onUpdate?: (registration: ServiceWorkerRegistration) => void; +}; + +export function register(config?: Config) { + if (process.env.NODE_ENV === 'production' && 'serviceWorker' in navigator) { + // The URL constructor is available in all browsers that support SW. + const publicUrl = new URL(process.env.PUBLIC_URL, window.location.href); + if (publicUrl.origin !== window.location.origin) { + // Our service worker won't work if PUBLIC_URL is on a different origin + // from what our page is served on. This might happen if a CDN is used to + // serve assets; see https://github.com/facebook/create-react-app/issues/2374 + return; + } + + window.addEventListener('load', () => { + const swUrl = `${process.env.PUBLIC_URL}/service-worker.js`; + + if (isLocalhost) { + // This is running on localhost. Let's check if a service worker still exists or not. + checkValidServiceWorker(swUrl, config); + + // Add some additional logging to localhost, pointing developers to the + // service worker/PWA documentation. + navigator.serviceWorker.ready.then(() => { + console.log( + 'This web app is being served cache-first by a service ' + + 'worker. To learn more, visit https://bit.ly/CRA-PWA' + ); + }); + } else { + // Is not localhost. Just register service worker + registerValidSW(swUrl, config); + } + }); + } +} + +function registerValidSW(swUrl: string, config?: Config) { + navigator.serviceWorker + .register(swUrl) + .then(registration => { + registration.onupdatefound = () => { + const installingWorker = registration.installing; + if (installingWorker == null) { + return; + } + installingWorker.onstatechange = () => { + if (installingWorker.state === 'installed') { + if (navigator.serviceWorker.controller) { + // At this point, the updated precached content has been fetched, + // but the previous service worker will still serve the older + // content until all client tabs are closed. + console.log( + 'New content is available and will be used when all ' + + 'tabs for this page are closed. See https://bit.ly/CRA-PWA.' + ); + + // Execute callback + if (config && config.onUpdate) { + config.onUpdate(registration); + } + } else { + // At this point, everything has been precached. + // It's the perfect time to display a + // "Content is cached for offline use." message. + console.log('Content is cached for offline use.'); + + // Execute callback + if (config && config.onSuccess) { + config.onSuccess(registration); + } + } + } + }; + }; + }) + .catch(error => { + console.error('Error during service worker registration:', error); + }); +} + +function checkValidServiceWorker(swUrl: string, config?: Config) { + // Check if the service worker can be found. If it can't reload the page. + fetch(swUrl, { + headers: { 'Service-Worker': 'script' }, + }) + .then(response => { + // Ensure service worker exists, and that we really are getting a JS file. + const contentType = response.headers.get('content-type'); + if ( + response.status === 404 || + (contentType != null && contentType.indexOf('javascript') === -1) + ) { + // No service worker found. Probably a different app. Reload the page. + navigator.serviceWorker.ready.then(registration => { + registration.unregister().then(() => { + window.location.reload(); + }); + }); + } else { + // Service worker found. Proceed as normal. + registerValidSW(swUrl, config); + } + }) + .catch(() => { + console.log( + 'No internet connection found. App is running in offline mode.' + ); + }); +} + +export function unregister() { + if ('serviceWorker' in navigator) { + navigator.serviceWorker.ready + .then(registration => { + registration.unregister(); + }) + .catch(error => { + console.error(error.message); + }); + } +} diff --git a/packages/cra-template-concent-ts/template/src/setupTests.ts b/packages/cra-template-concent-ts/template/src/setupTests.ts new file mode 100644 index 00000000000..74b1a275a0e --- /dev/null +++ b/packages/cra-template-concent-ts/template/src/setupTests.ts @@ -0,0 +1,5 @@ +// jest-dom adds custom jest matchers for asserting on DOM nodes. +// allows you to do things like: +// expect(element).toHaveTextContent(/react/i) +// learn more: https://github.com/testing-library/jest-dom +import '@testing-library/jest-dom/extend-expect'; diff --git a/packages/cra-template-concent-ts/template/src/types/store.ts b/packages/cra-template-concent-ts/template/src/types/store.ts new file mode 100644 index 00000000000..206c8d0b3e1 --- /dev/null +++ b/packages/cra-template-concent-ts/template/src/types/store.ts @@ -0,0 +1,146 @@ +import { + ICtx, + IActionCtx, + IAnyObj, + MODULE_VOID, + MODULE_DEFAULT, + MODULE_GLOBAL, + GetRootState, + GetRootReducer, + GetRootComputed, +} from 'concent'; +import models from '../models'; + +const allModels = models; +type Models = typeof allModels; + +export type RootState = GetRootState; + +export type RootRd = GetRootReducer; + +export type RootCu = GetRootComputed; + +export type TGlobalSt = RootState[MODULE_GLOBAL]; +export type Modules = keyof RootState; + +/** ultil type based on actionCtx */ +export type AC< + M extends Modules, + FullState extends IAnyObj = RootState[M] +> = IActionCtx, FullState>; +// ******************************** +// ultil types based on Ctx +// ******************************** + +/** belong one module. CtxM */ +export type CtxM< + P = {}, + M extends Modules = MODULE_DEFAULT, + Se = {}, + RefCu = {}, + Mp = {} +> = ICtx; + +/** belong one module,expand private state. CtxMS*/ +export type CtxMS< + P = {}, + M extends Modules = MODULE_DEFAULT, + St = {}, + Se = {}, + RefCu = {}, + Mp = {} +> = ICtx; + +/** belong one module, connect other modules. CtxMConn */ +export type CtxMConn< + P = {}, + M extends Modules = MODULE_DEFAULT, + Conn extends Modules = MODULE_VOID, + Se = {}, + RefCu = {}, + Mp = {} +> = ICtx; + +/** belong one module,expand private state, connect other modules. CtxMSConn */ +export type CtxMSConn< + P = {}, + M extends Modules = MODULE_DEFAULT, + St = {}, + Conn extends Modules = MODULE_VOID, + Se = {}, + RefCu = {}, + Mp = {} +> = ICtx; + +/** expand private state, connect other modules. CtxMSConn */ +export type CtxSConn< + P = {}, + St = {}, + Conn extends Modules = MODULE_VOID, + Se = {}, + RefCu = {}, + Mp = {} +> = ICtx; + +/** expand private state. CtxMSConn */ +export type CtxS

= ICtx< + RootState, + RootRd, + RootCu, + P, + St, + MODULE_DEFAULT, + MODULE_VOID, + Se, + RefCu, + Mp +>; + +/** connect other modules. CtxConn */ +export type CtxConn< + P = {}, + Conn extends Modules = MODULE_VOID, + Se = {}, + RefCu = {}, + Mp = {} +> = ICtx; + +/** default series, when no module specified, the component belong to $$default module by default */ +export type CtxDe

= CtxM< + P, + MODULE_DEFAULT, + Se, + RefCu, + Mp +>; +export type CtxDeS

= CtxMS< + P, + MODULE_DEFAULT, + St, + Se, + RefCu, + Mp +>; +export type CtxDeSConn< + P = {}, + St = {}, + Conn extends Modules = MODULE_VOID, + Se = {}, + RefCu = {}, + Mp = {} +> = CtxMSConn; +export type CtxDeConn< + P = {}, + Conn extends Modules = MODULE_VOID, + Se = {}, + RefCu = {}, + Mp = {} +> = CtxSConn; + +export type ItemsType = Arr extends ReadonlyArray ? E : never; + +export type VoidPayload = null | void; + +export type VoidPayloadMev = + | VoidPayload + | React.MouseEvent; diff --git a/packages/cra-template-concent-ts/template/tsconfig.json b/packages/cra-template-concent-ts/template/tsconfig.json new file mode 100644 index 00000000000..126ba4399cc --- /dev/null +++ b/packages/cra-template-concent-ts/template/tsconfig.json @@ -0,0 +1,21 @@ +{ + "compilerOptions": { + "baseUrl": "src", + "target": "es5", + "lib": ["dom", "dom.iterable", "esnext"], + "allowJs": true, + "skipLibCheck": true, + "esModuleInterop": true, + "allowSyntheticDefaultImports": true, + "strict": true, + "forceConsistentCasingInFileNames": true, + "noFallthroughCasesInSwitch": true, + "module": "esnext", + "moduleResolution": "node", + "resolveJsonModule": true, + "isolatedModules": true, + "noEmit": true, + "jsx": "react" + }, + "include": ["src"] +} From 04b67d225f5b7ace8f44ade99269392e770c3027 Mon Sep 17 00:00:00 2001 From: fancyzhong Date: Sat, 12 Dec 2020 20:03:14 +0800 Subject: [PATCH 2/3] chore: update template.json --- packages/cra-template-concent-ts/template.json | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/packages/cra-template-concent-ts/template.json b/packages/cra-template-concent-ts/template.json index 36637c0fac7..9ac417756d4 100644 --- a/packages/cra-template-concent-ts/template.json +++ b/packages/cra-template-concent-ts/template.json @@ -1,13 +1,13 @@ { "package": { "dependencies": { - "@testing-library/jest-dom": "^4.2.4", - "@testing-library/react": "^9.3.2", - "@testing-library/user-event": "^7.1.2", + "@testing-library/jest-dom": "^5.11.4", + "@testing-library/react": "^11.1.0", + "@testing-library/user-event": "^12.1.10", "@types/node": "^12.0.0", - "@types/react": "^16.13.0", - "@types/react-dom": "^16.13.0", - "@types/jest": "^24.0.0", + "@types/react": "^17.0.0", + "@types/react-dom": "^17.0.0", + "@types/jest": "^26.0.15", "typescript": "^4.1.2", "concent": "^2.10.5" }, From 400ae09ef8e1d236274198ac8073c7e91e1e7ae9 Mon Sep 17 00:00:00 2001 From: fancyzhong Date: Sat, 12 Dec 2020 20:13:35 +0800 Subject: [PATCH 3/3] chore: add"web-vitals --- packages/cra-template-concent-ts/template.json | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/cra-template-concent-ts/template.json b/packages/cra-template-concent-ts/template.json index 9ac417756d4..8e4bb1b55c1 100644 --- a/packages/cra-template-concent-ts/template.json +++ b/packages/cra-template-concent-ts/template.json @@ -9,6 +9,7 @@ "@types/react-dom": "^17.0.0", "@types/jest": "^26.0.15", "typescript": "^4.1.2", + "web-vitals": "^1.0.1", "concent": "^2.10.5" }, "eslintConfig": {