cra-template-concent-ts
Advanced tools
Comparing version 1.0.4 to 1.0.5
{ | ||
"name": "cra-template-concent-ts", | ||
"version": "1.0.4", | ||
"version": "1.0.5", | ||
"keywords": [ | ||
@@ -5,0 +5,0 @@ "react", |
@@ -5,3 +5,3 @@ # cra-template-concent-ts | ||
You can checkout it from [here](https://github.com/concentjs/cra-template-concent-ts) | ||
You can also checkout it from [here](https://github.com/concentjs/cra-project-concent-ts) | ||
@@ -13,7 +13,7 @@ To use this template, add `--template concent-ts` when creating a new app. | ||
```sh | ||
npx create-react-app my-app --template cra-template-concent-ts | ||
npx create-react-app my-app --template concent-ts | ||
# or | ||
yarn create react-app my-app --template cra-template-cra-template-concent-ts | ||
yarn create react-app my-app --template concent-ts | ||
``` | ||
@@ -20,0 +20,0 @@ |
@@ -13,8 +13,17 @@ { | ||
"web-vitals": "^1.0.1", | ||
"concent": "^2.10.5" | ||
"concent": "^2.13.8", | ||
"concent-utils": "^1.1.0" | ||
}, | ||
"eslintConfig": { | ||
"extends": ["react-app", "react-app/jest"] | ||
}, | ||
"devDependencies": { | ||
"@types/enzyme": "^3.10.8", | ||
"@types/enzyme-adapter-react-16": "^1.0.6", | ||
"enzyme": "^3.11.0", | ||
"enzyme-adapter-react-16": "^1.15.6", | ||
"jest-environment-jsdom-fourteen": "^1.0.1", | ||
"jest-enzyme": "^7.1.2" | ||
} | ||
} | ||
} |
@@ -8,2 +8,4 @@ | ||
export const COUNTER2 = 'Counter2' as const; | ||
export type COUNTER_T = typeof COUNTER; |
@@ -1,2 +0,2 @@ | ||
import { COUNTER } from '../../../configs/c2Mods'; | ||
import { COUNTER } from 'configs/c2Mods'; | ||
import state from './state'; | ||
@@ -3,0 +3,0 @@ import * as computed from './computed'; |
import { St } from './state'; | ||
import { VoidPayloadMev, AC } from 'types/store'; | ||
import { VoidPayload, AC } from 'types/store'; | ||
import { COUNTER_T } from 'configs/c2Mods'; | ||
@@ -9,11 +9,11 @@ | ||
export function incrementBigValue(payload: VoidPayloadMev, moduleState: St): Partial<St> { | ||
export function incrementBigValue(payload: VoidPayload, moduleState: St): Partial<St> { | ||
return { bigValue: moduleState.bigValue + 50 }; | ||
} | ||
export function increment(payload: VoidPayloadMev, moduleState: St): Partial<St> { | ||
export function increment(payload: VoidPayload, moduleState: St): Partial<St> { | ||
return { value: moduleState.value + 1 }; | ||
} | ||
export function decrement(payload: VoidPayloadMev, moduleState: St): Partial<St> { | ||
export function decrement(payload: VoidPayload, moduleState: St): Partial<St> { | ||
return { value: moduleState.value - 1 }; | ||
@@ -20,0 +20,0 @@ } |
// you should declare all models here then expose it | ||
import counterModel from '../features/counter/model'; | ||
import counterModel from 'features/counter/model'; | ||
import globalModel from './global'; | ||
const allModels = { | ||
...globalModel, | ||
...counterModel, | ||
// clone counterModel to a new module named ClonedModOfCounter | ||
ClonedModOfCounter: counterModel.Counter, | ||
}; | ||
export default allModels; |
@@ -5,2 +5,14 @@ // jest-dom adds custom jest matchers for asserting on DOM nodes. | ||
// learn more: https://github.com/testing-library/jest-dom | ||
import '@testing-library/jest-dom/extend-expect'; | ||
// @ts-ignore | ||
require('@testing-library/jest-dom/extend-expect'); | ||
// import '@testing-library/jest-dom/extend-expect'; | ||
const { run } = require('concent'); | ||
const models = require('./models'); | ||
const { act } = require('react-dom/test-utils'); | ||
run(models, { | ||
alwaysRenderCaller: true, | ||
log: false, // jest执行时,不打印concent内部的日志输出 | ||
act, // 配合jest执行setState时能触发组件重渲染,see https://reactjs.org/docs/test-utils.html#act | ||
}); |
import { | ||
ICtx, IActionCtx, IAnyObj, | ||
MODULE_VOID, MODULE_DEFAULT, MODULE_GLOBAL, | ||
GetRootState, GetRootReducer, GetRootComputed, | ||
GetRootState, GetRootReducer, GetRootComputed, GetRootReducerCaller, GetRootReducerGhost, | ||
} from 'concent'; | ||
@@ -12,2 +12,6 @@ import { Models } from './mods'; | ||
export type RootRdCaller = GetRootReducerCaller<Models>; | ||
export type RootRdGhost = GetRootReducerGhost<Models, RootRd>; | ||
export type RootCu = GetRootComputed<Models>; | ||
@@ -19,6 +23,6 @@ | ||
/** ultil type based on actionCtx */ | ||
/** util type based on actionCtx */ | ||
export type AC<M extends Modules, FullState extends IAnyObj = RootState[M]> = IActionCtx<RootState, RootCu, M, CtxM<{}, M>, FullState>; | ||
// ******************************** | ||
// ultil types based on Ctx | ||
// util types based on Ctx | ||
// ******************************** | ||
@@ -28,27 +32,27 @@ | ||
export type CtxM<P = {}, M extends Modules = MODULE_DEFAULT, Se = {}, RefCu = {}, Mp = {}> | ||
= ICtx<RootState, RootRd, RootCu, P, {}, M, MODULE_VOID, Se, RefCu, Mp>; | ||
= ICtx<RootState, RootRd, RootRdCaller, RootRdGhost, RootCu, P, {}, M, MODULE_VOID, Se, RefCu, Mp>; | ||
/** belong one module,expand private state. CtxMS<P, M, St, Se, RefCu>*/ | ||
export type CtxMS<P = {}, M extends Modules = MODULE_DEFAULT, St = {}, Se = {}, RefCu = {}, Mp = {}> | ||
= ICtx<RootState, RootRd, RootCu, P, St, M, MODULE_VOID, Se, RefCu, Mp>; | ||
= ICtx<RootState, RootRd, RootRdCaller, RootRdGhost, RootCu, P, St, M, MODULE_VOID, Se, RefCu, Mp>; | ||
/** belong one module, connect other modules. CtxMConn<P, M, Conn, Se, RefCu> */ | ||
export type CtxMConn<P = {}, M extends Modules = MODULE_DEFAULT, Conn extends Modules = MODULE_VOID, Se = {}, RefCu = {}, Mp = {}> | ||
= ICtx<RootState, RootRd, RootCu, P, {}, M, Conn, Se, RefCu, Mp>; | ||
= ICtx<RootState, RootRd, RootRdCaller, RootRdGhost, RootCu, P, {}, M, Conn, Se, RefCu, Mp>; | ||
/** belong one module,expand private state, connect other modules. CtxMSConn<P, M, St, Conn, Se, RefCu> */ | ||
export type CtxMSConn<P = {}, M extends Modules = MODULE_DEFAULT, St = {}, Conn extends Modules = MODULE_VOID, Se = {}, RefCu = {}, Mp = {}> | ||
= ICtx<RootState, RootRd, RootCu, P, St, M, Conn, Se, RefCu, Mp>; | ||
= ICtx<RootState, RootRd, RootRdCaller, RootRdGhost, RootCu, P, St, M, Conn, Se, RefCu, Mp>; | ||
/** expand private state, connect other modules. CtxMSConn<P, St, Conn, Se, RefCu> */ | ||
export type CtxSConn<P = {}, St = {}, Conn extends Modules = MODULE_VOID, Se = {}, RefCu = {}, Mp = {}> | ||
= ICtx<RootState, RootRd, RootCu, P, St, MODULE_DEFAULT, Conn, Se, RefCu, Mp>; | ||
= ICtx<RootState, RootRd, RootRdCaller, RootRdGhost, RootCu, P, St, MODULE_DEFAULT, Conn, Se, RefCu, Mp>; | ||
/** expand private state. CtxMSConn<P, St, Conn, Se, RefCu> */ | ||
export type CtxS<P = {}, St = {}, Se = {}, RefCu = {}, Mp = {}> | ||
= ICtx<RootState, RootRd, RootCu, P, St, MODULE_DEFAULT, MODULE_VOID, Se, RefCu, Mp>; | ||
= ICtx<RootState, RootRd, RootRdCaller, RootRdGhost, RootCu, P, St, MODULE_DEFAULT, MODULE_VOID, Se, RefCu, Mp>; | ||
/** connect other modules. CtxConn<P, Conn, Se, RefCu> */ | ||
export type CtxConn<P = {}, Conn extends Modules = MODULE_VOID, Se = {}, RefCu = {}, Mp = {}> | ||
= ICtx<RootState, RootRd, RootCu, P, {}, MODULE_DEFAULT, Conn, Se, RefCu, Mp>; | ||
= ICtx<RootState, RootRd, RootRdCaller, RootRdGhost, RootCu, P, {}, MODULE_DEFAULT, Conn, Se, RefCu, Mp>; | ||
@@ -67,5 +71,5 @@ /** default series, when no module specified, the component belong to $$default module by default */ | ||
export type VoidPayload = null | void; | ||
export type VoidPayloadMev = VoidPayload | React.MouseEvent<HTMLButtonElement, MouseEvent>; | ||
export type Empty = void | null; | ||
export type MouseEv = React.MouseEvent<HTMLElement>; | ||
export type ChangeEv = React.ChangeEvent<HTMLElement>; | ||
export type VoidPayload = Empty | MouseEv; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
64424
51
1112