├── packages ├── react-imvc-v2 │ ├── project │ │ ├── src │ │ │ ├── __tests__ │ │ │ │ ├── a.test.js │ │ │ │ └── a.test.ts │ │ │ ├── basic-state │ │ │ │ ├── __tests__ │ │ │ │ │ ├── a.test.js │ │ │ │ │ └── a.test.ts │ │ │ │ └── Controller.js │ │ │ ├── prefetch-header │ │ │ │ ├── preload.css │ │ │ │ └── Controller.tsx │ │ │ ├── img │ │ │ │ └── react.png │ │ │ ├── preload │ │ │ │ ├── style.css │ │ │ │ └── Controller.js │ │ │ ├── static-view │ │ │ │ └── Controller.js │ │ │ ├── static-view-csr │ │ │ │ └── Controller.js │ │ │ ├── life-cycle │ │ │ │ └── Controller.js │ │ │ ├── lazy │ │ │ │ ├── A.tsx │ │ │ │ ├── B.tsx │ │ │ │ ├── C.tsx │ │ │ │ ├── D.tsx │ │ │ │ ├── E.tsx │ │ │ │ └── controller.tsx │ │ │ ├── model │ │ │ │ └── Controller.js │ │ │ ├── render-view │ │ │ │ └── Controller.js │ │ │ ├── index.js │ │ │ └── error-boundary │ │ │ │ └── Controller.js │ │ ├── package.json │ │ ├── routes │ │ │ ├── my_router.js │ │ │ ├── index.js │ │ │ └── Layout.js │ │ ├── preview.js │ │ ├── start.js │ │ ├── build.js │ │ └── tsconfig.json │ ├── nyc.config.js │ ├── polyfill │ │ ├── index.js │ │ └── console.js │ ├── index.js │ ├── scripts │ │ ├── build.js │ │ ├── start.js │ │ └── test.js │ ├── context │ │ └── index.js │ ├── doc │ │ └── images │ │ │ ├── 01.png │ │ │ ├── 02.png │ │ │ ├── 03.png │ │ │ ├── 04.png │ │ │ ├── 05.png │ │ │ ├── 06.png │ │ │ ├── 07.png │ │ │ ├── 08.png │ │ │ └── 09.png │ ├── .travis.yml │ ├── hook │ │ ├── useModelActions.js │ │ ├── useModelState.js │ │ ├── index.js │ │ ├── useCtrl.js │ │ └── useModel.js │ ├── build │ │ ├── babel.js │ │ ├── compileNodeModules.js │ │ └── util.js │ ├── start │ │ └── babel.js │ ├── .gitignore │ ├── component │ │ ├── Script.js │ │ ├── Prefetch.js │ │ ├── index.js │ │ ├── Style.js │ │ ├── EventWrapper.js │ │ ├── NavLink.js │ │ ├── ControllerProxy.js │ │ ├── OuterClickWrapper.js │ │ └── ErrorBoundary.js │ ├── util │ │ └── htmlescape.ts │ ├── hoc │ │ ├── connect.js │ │ └── lazy.tsx │ ├── tsconfig.json │ ├── controller │ │ └── actions.js │ ├── .github │ │ └── workflows │ │ │ └── playwright.yml │ ├── config │ │ ├── index.js │ │ └── babel.js │ ├── middleware │ │ ├── shareRoot.js │ │ └── cacheView.js │ ├── LICENSE │ ├── gulpfile.js │ ├── page │ │ └── view.js │ ├── mocha-runner.js │ ├── bin │ │ └── scripts.js │ ├── e2e │ │ └── lazy.spec.ts │ └── entry │ │ └── client.js └── react-imvc-v3 │ ├── hoc │ ├── lazy.ts │ ├── lazy.js │ ├── connect.js │ └── connect.d.ts │ ├── util │ ├── index.d.ts │ └── index.js │ ├── build │ ├── index.js │ ├── createGulpTask.js │ ├── setup-dev-env.js │ ├── createWebpackConfig.js │ ├── index.d.ts │ ├── setup-dev-env.d.ts │ ├── createGulpTask.d.ts │ └── createWebpackConfig.d.ts │ ├── component │ ├── index.d.ts │ ├── index.js │ ├── Input │ │ ├── index.js │ │ └── index.d.ts │ ├── Link │ │ ├── index.js │ │ └── index.d.ts │ ├── Script │ │ ├── index.js │ │ └── index.d.ts │ ├── Style │ │ ├── index.js │ │ └── index.d.ts │ ├── NavLink │ │ ├── index.js │ │ └── index.d.ts │ ├── Prefetch │ │ ├── index.js │ │ └── index.d.ts │ ├── ViewManager │ │ ├── index.js │ │ └── index.d.ts │ ├── ErrorBoundary │ │ ├── index.js │ │ └── index.d.ts │ ├── EventWrapper │ │ ├── index.js │ │ └── index.d.ts │ ├── ControllerProxy │ │ ├── index.js │ │ └── index.d.ts │ └── OuterClickWrapper │ │ ├── index.js │ │ └── index.d.ts │ ├── hook │ ├── index.js │ ├── useCtrl.js │ ├── useModel.js │ ├── useModelState.js │ ├── useModelActions.js │ ├── index.d.ts │ ├── useCtrl.d.ts │ ├── useModel.d.ts │ ├── useModelState.d.ts │ └── useModelActions.d.ts │ ├── playwright │ ├── index.d.ts │ └── index.js │ ├── start │ ├── index.js │ ├── babel.js │ ├── index.d.ts │ └── babel.d.ts │ ├── config │ ├── index.js │ ├── babel.js │ ├── config.defaults.js │ ├── index.d.ts │ ├── babel.d.ts │ └── config.defaults.d.ts │ ├── context │ ├── index.js │ └── index.d.ts │ ├── page │ ├── view.js │ ├── createPageRouter.js │ ├── view.d.ts │ └── createPageRouter.d.ts │ ├── project │ ├── src │ │ ├── style │ │ │ ├── preload.css │ │ │ ├── base.scss │ │ │ ├── Dynamic.tsx │ │ │ ├── nav.scss │ │ │ ├── controller.scss │ │ │ └── Controller.tsx │ │ ├── type.d.ts │ │ ├── prefetch-header │ │ │ ├── preload.css │ │ │ └── Controller.tsx │ │ ├── img │ │ │ └── react.png │ │ ├── content-hash │ │ │ ├── OpenSans-Bold.ttf │ │ │ ├── style.css │ │ │ └── Controller.tsx │ │ ├── link-from │ │ │ ├── preload.css │ │ │ └── Controller.tsx │ │ ├── hook │ │ │ ├── Model.ts │ │ │ └── Controller.tsx │ │ ├── componentWillCreate │ │ │ └── Controller.tsx │ │ ├── link-to │ │ │ └── Controller.tsx │ │ ├── es6_dynamic │ │ │ └── Controller.tsx │ │ ├── es6_import │ │ │ └── Controller.tsx │ │ ├── es6_module │ │ │ └── Controller.tsx │ │ ├── static-view │ │ │ └── Controller.tsx │ │ ├── lazy │ │ │ ├── A.tsx │ │ │ ├── B.tsx │ │ │ ├── C.tsx │ │ │ ├── D.tsx │ │ │ ├── E.tsx │ │ │ └── controller.tsx │ │ ├── loading │ │ │ └── Controller.tsx │ │ ├── static-view-csr │ │ │ └── Controller.tsx │ │ ├── scroll │ │ │ └── Controller.tsx │ │ ├── unscroll │ │ │ └── Controller.tsx │ │ ├── connect │ │ │ └── Controller.tsx │ │ ├── basic-state │ │ │ └── Controller.tsx │ │ ├── event-wrapper │ │ │ └── Controller.tsx │ │ ├── location │ │ │ └── Controller.tsx │ │ ├── history │ │ │ └── Controller.tsx │ │ ├── getInitialState │ │ │ └── Controller.tsx │ │ ├── api │ │ │ └── Controller.tsx │ │ ├── restapi │ │ │ └── Controller.tsx │ │ ├── api-map │ │ │ └── Controller.tsx │ │ ├── render-view │ │ │ └── Controller.tsx │ │ ├── outer-click-wrapper │ │ │ └── Controller.tsx │ │ └── error-boundary │ │ │ └── Controller.tsx │ ├── start.ts │ ├── package.json │ ├── routes │ │ ├── my_router.ts │ │ ├── index.ts │ │ └── Layout.tsx │ └── imvc.config.tsx │ ├── test │ ├── config.ts │ ├── util │ │ ├── index.ts │ │ ├── setTimeOutAsync.ts │ │ ├── fetchContent.ts │ │ └── kill.ts │ ├── test.d.ts │ ├── config.spec.ts │ └── hoc.spec.ts │ ├── controller │ ├── index.js │ ├── actions.js │ ├── attachDevToolsIfPossible.js │ ├── index.d.ts │ ├── actions.d.ts │ └── attachDevToolsIfPossible.d.ts │ ├── entry │ ├── client.js │ ├── server.js │ ├── client.d.ts │ └── server.d.ts │ ├── bin │ └── scripts.js │ ├── middleware │ ├── cacheView.js │ ├── shareRoot.js │ ├── createCache.js │ ├── cacheView.d.ts │ ├── shareRoot.d.ts │ └── createCache.d.ts │ ├── .prettierrc.json │ ├── .github │ ├── CONTRIBUTE.md │ ├── workflows │ │ ├── playwright.yml │ │ └── nodejs.yml │ └── CODE_OF_CONDUCT.md │ ├── doc │ ├── Isomorphic │ │ ├── README.md │ │ ├── route.md │ │ ├── context.md │ │ ├── cache.md │ │ ├── event-handle.md │ │ ├── serverRenderer.md │ │ ├── sass.md │ │ ├── api.md │ │ ├── bom.md │ │ ├── static-file.md │ │ ├── persistence.md │ │ └── hoc.md │ ├── Server │ │ ├── README.md │ │ ├── layout.md │ │ └── middleware.md │ └── Config │ │ ├── README.md │ │ └── usage.md │ ├── nyc.config.js │ ├── src │ ├── polyfill │ │ ├── index.ts │ │ └── console.ts │ ├── scripts │ │ ├── build.ts │ │ ├── start.ts │ │ └── test.ts │ ├── hook │ │ ├── useModelState.ts │ │ ├── index.ts │ │ ├── useModelActions.ts │ │ ├── useCtrl.ts │ │ └── useModel.ts │ ├── imvc.d.ts │ ├── component │ │ ├── Script.tsx │ │ ├── Prefetch.ts │ │ ├── index.ts │ │ ├── Style.tsx │ │ ├── EventWrapper.tsx │ │ ├── NavLink.tsx │ │ ├── ControllerProxy.ts │ │ ├── OuterClickWrapper.ts │ │ └── ErrorBoundary.ts │ ├── start │ │ └── babel.ts │ ├── context │ │ └── index.ts │ ├── build │ │ ├── compileNodeModules.ts │ │ ├── imvc-style-plugin.ts │ │ └── util.ts │ ├── controller │ │ └── actions.ts │ ├── hoc │ │ ├── connect.tsx │ │ └── lazy.tsx │ ├── middleware │ │ ├── shareRoot.ts │ │ └── cacheView.ts │ ├── config │ │ └── babel.ts │ ├── page │ │ └── view.tsx │ ├── bin │ │ └── scripts.ts │ └── playwright │ │ └── index.ts │ ├── .gitignore │ ├── imvc-types.d.ts │ ├── tsconfig.json │ ├── LICENSE │ └── e2e │ └── lazy.spec.ts ├── .prettierignore ├── pnpm-workspace.yaml ├── .commitlintrc.js ├── .eslintignore ├── .lintstagedrc ├── .husky ├── pre-commit └── commit-msg ├── .npmrc ├── .prettierrc ├── .editorconfig ├── .github ├── renovate.json5 └── workflows │ ├── greetings.yml │ └── test.yml ├── tsconfig.cjs.json ├── tsconfig.esm.json ├── jest.config.js ├── tsconfig.json ├── README.md └── LICENSE /packages/react-imvc-v2/project/src/__tests__/a.test.js: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /packages/react-imvc-v2/project/src/__tests__/a.test.ts: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /.prettierignore: -------------------------------------------------------------------------------- 1 | examples/.cache 2 | node_modules 3 | dist 4 | esm -------------------------------------------------------------------------------- /packages/react-imvc-v2/project/src/basic-state/__tests__/a.test.js: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /packages/react-imvc-v2/project/src/basic-state/__tests__/a.test.ts: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /pnpm-workspace.yaml: -------------------------------------------------------------------------------- 1 | packages: 2 | - 'packages/*' 3 | - 'projects/*' -------------------------------------------------------------------------------- /packages/react-imvc-v3/hoc/lazy.ts: -------------------------------------------------------------------------------- 1 | export * from '../dist/hoc/lazy' 2 | -------------------------------------------------------------------------------- /packages/react-imvc-v3/util/index.d.ts: -------------------------------------------------------------------------------- 1 | export * from '../dist/util' 2 | -------------------------------------------------------------------------------- /packages/react-imvc-v3/build/index.js: -------------------------------------------------------------------------------- 1 | module.exports = require('../dist/build') 2 | -------------------------------------------------------------------------------- /packages/react-imvc-v3/component/index.d.ts: -------------------------------------------------------------------------------- 1 | export * from '../dist/component' 2 | -------------------------------------------------------------------------------- /packages/react-imvc-v3/hoc/lazy.js: -------------------------------------------------------------------------------- 1 | module.exports = require('../dist/hoc/lazy') 2 | -------------------------------------------------------------------------------- /packages/react-imvc-v3/hook/index.js: -------------------------------------------------------------------------------- 1 | module.exports = require('../dist/hook') 2 | -------------------------------------------------------------------------------- /packages/react-imvc-v3/playwright/index.d.ts: -------------------------------------------------------------------------------- 1 | export * from '../dist/playwright' 2 | -------------------------------------------------------------------------------- /packages/react-imvc-v3/start/index.js: -------------------------------------------------------------------------------- 1 | module.exports = require('../dist/start') 2 | -------------------------------------------------------------------------------- /packages/react-imvc-v3/util/index.js: -------------------------------------------------------------------------------- 1 | module.exports = require('../dist/util') 2 | -------------------------------------------------------------------------------- /packages/react-imvc-v3/config/index.js: -------------------------------------------------------------------------------- 1 | module.exports = require('../dist/config') 2 | -------------------------------------------------------------------------------- /packages/react-imvc-v3/context/index.js: -------------------------------------------------------------------------------- 1 | module.exports = require('../dist/context') 2 | -------------------------------------------------------------------------------- /packages/react-imvc-v3/page/view.js: -------------------------------------------------------------------------------- 1 | module.exports = require('../dist/page/view') 2 | -------------------------------------------------------------------------------- /packages/react-imvc-v3/project/src/style/preload.css: -------------------------------------------------------------------------------- 1 | .style { 2 | height: 50px 3 | } -------------------------------------------------------------------------------- /packages/react-imvc-v3/test/config.ts: -------------------------------------------------------------------------------- 1 | export default { 2 | basename: 'test', 3 | } 4 | -------------------------------------------------------------------------------- /packages/react-imvc-v3/component/index.js: -------------------------------------------------------------------------------- 1 | module.exports = require('../dist/component') 2 | -------------------------------------------------------------------------------- /packages/react-imvc-v3/config/babel.js: -------------------------------------------------------------------------------- 1 | module.exports = require('../dist/config/babel') 2 | -------------------------------------------------------------------------------- /packages/react-imvc-v3/controller/index.js: -------------------------------------------------------------------------------- 1 | module.exports = require('../dist/controller') 2 | -------------------------------------------------------------------------------- /packages/react-imvc-v3/entry/client.js: -------------------------------------------------------------------------------- 1 | module.exports = require('../dist/entry/client') 2 | -------------------------------------------------------------------------------- /packages/react-imvc-v3/entry/server.js: -------------------------------------------------------------------------------- 1 | module.exports = require('../dist/entry/server') 2 | -------------------------------------------------------------------------------- /packages/react-imvc-v3/hoc/connect.js: -------------------------------------------------------------------------------- 1 | module.exports = require('../dist/hoc/connect') 2 | -------------------------------------------------------------------------------- /packages/react-imvc-v3/hook/useCtrl.js: -------------------------------------------------------------------------------- 1 | module.exports = require('../dist/hook/useCtrl') 2 | -------------------------------------------------------------------------------- /packages/react-imvc-v3/hook/useModel.js: -------------------------------------------------------------------------------- 1 | module.exports = require('../dist/hook/useModel') 2 | -------------------------------------------------------------------------------- /packages/react-imvc-v3/playwright/index.js: -------------------------------------------------------------------------------- 1 | module.exports = require('../dist/playwright') 2 | -------------------------------------------------------------------------------- /packages/react-imvc-v3/project/src/type.d.ts: -------------------------------------------------------------------------------- 1 | /// 2 | -------------------------------------------------------------------------------- /packages/react-imvc-v3/start/babel.js: -------------------------------------------------------------------------------- 1 | module.exports = require('../dist/start/babel') 2 | -------------------------------------------------------------------------------- /packages/react-imvc-v2/nyc.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | include: ['project/**'], 3 | } 4 | -------------------------------------------------------------------------------- /packages/react-imvc-v2/project/src/prefetch-header/preload.css: -------------------------------------------------------------------------------- 1 | .style { 2 | height: 50px 3 | } -------------------------------------------------------------------------------- /packages/react-imvc-v3/bin/scripts.js: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | require('../dist/bin/scripts') 3 | -------------------------------------------------------------------------------- /packages/react-imvc-v3/project/src/prefetch-header/preload.css: -------------------------------------------------------------------------------- 1 | .style { 2 | height: 50px 3 | } -------------------------------------------------------------------------------- /.commitlintrc.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | extends: ['@commitlint/config-conventional'], 3 | } 4 | -------------------------------------------------------------------------------- /packages/react-imvc-v2/polyfill/index.js: -------------------------------------------------------------------------------- 1 | require('./console') 2 | require('raf').polyfill(window) 3 | -------------------------------------------------------------------------------- /packages/react-imvc-v3/controller/actions.js: -------------------------------------------------------------------------------- 1 | module.exports = require('../dist/controller/actions') 2 | -------------------------------------------------------------------------------- /packages/react-imvc-v3/hook/useModelState.js: -------------------------------------------------------------------------------- 1 | module.exports = require('../dist/hook/useModelState') 2 | -------------------------------------------------------------------------------- /.eslintignore: -------------------------------------------------------------------------------- 1 | examples/.cache 2 | node_modules 3 | dist 4 | cjs 5 | esm 6 | */**/expected 7 | projects/** -------------------------------------------------------------------------------- /.lintstagedrc: -------------------------------------------------------------------------------- 1 | { 2 | "*.{json,yml,md,html,js,ts,tsx,vue}": [ 3 | "prettier --write" 4 | ] 5 | } 6 | -------------------------------------------------------------------------------- /packages/react-imvc-v3/build/createGulpTask.js: -------------------------------------------------------------------------------- 1 | module.exports = require('../dist/build/createGulpTask') 2 | -------------------------------------------------------------------------------- /packages/react-imvc-v3/build/setup-dev-env.js: -------------------------------------------------------------------------------- 1 | module.exports = require('../dist/build/setup-dev-env') 2 | -------------------------------------------------------------------------------- /packages/react-imvc-v3/component/Input/index.js: -------------------------------------------------------------------------------- 1 | module.exports = require('../../dist/component/Input') 2 | -------------------------------------------------------------------------------- /packages/react-imvc-v3/component/Link/index.js: -------------------------------------------------------------------------------- 1 | module.exports = require('../../dist/component/Link') 2 | -------------------------------------------------------------------------------- /packages/react-imvc-v3/component/Script/index.js: -------------------------------------------------------------------------------- 1 | module.exports = require('../../dist/component/Script') 2 | -------------------------------------------------------------------------------- /packages/react-imvc-v3/component/Style/index.js: -------------------------------------------------------------------------------- 1 | module.exports = require('../../dist/component/Style') 2 | -------------------------------------------------------------------------------- /packages/react-imvc-v3/hook/useModelActions.js: -------------------------------------------------------------------------------- 1 | module.exports = require('../dist/hook/useModelActions') 2 | -------------------------------------------------------------------------------- /packages/react-imvc-v3/middleware/cacheView.js: -------------------------------------------------------------------------------- 1 | module.exports = require('../dist/middleware/cacheView') 2 | -------------------------------------------------------------------------------- /packages/react-imvc-v3/middleware/shareRoot.js: -------------------------------------------------------------------------------- 1 | module.exports = require('../dist/middleware/shareRoot') 2 | -------------------------------------------------------------------------------- /.husky/pre-commit: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | . "$(dirname -- "$0")/_/husky.sh" 3 | 4 | npx --no -- lint-staged 5 | -------------------------------------------------------------------------------- /packages/react-imvc-v2/index.js: -------------------------------------------------------------------------------- 1 | exports.start = require('./start') 2 | exports.build = require('./build') 3 | -------------------------------------------------------------------------------- /packages/react-imvc-v2/scripts/build.js: -------------------------------------------------------------------------------- 1 | let options = require('yargs').argv 2 | require('../build')(options) 3 | -------------------------------------------------------------------------------- /packages/react-imvc-v3/build/createWebpackConfig.js: -------------------------------------------------------------------------------- 1 | module.exports = require('../dist/build/createGulpTask') 2 | -------------------------------------------------------------------------------- /packages/react-imvc-v3/component/NavLink/index.js: -------------------------------------------------------------------------------- 1 | module.export = require('../../dist/component/NavLink') 2 | -------------------------------------------------------------------------------- /packages/react-imvc-v3/component/Prefetch/index.js: -------------------------------------------------------------------------------- 1 | module.exports = require('../../dist/component/Prefetch') 2 | -------------------------------------------------------------------------------- /packages/react-imvc-v3/config/config.defaults.js: -------------------------------------------------------------------------------- 1 | module.exports = require('../dist/config/config.defaults') 2 | -------------------------------------------------------------------------------- /packages/react-imvc-v3/middleware/createCache.js: -------------------------------------------------------------------------------- 1 | module.exports = require('../dist/middleware/createCache') 2 | -------------------------------------------------------------------------------- /packages/react-imvc-v3/page/createPageRouter.js: -------------------------------------------------------------------------------- 1 | module.exports = require('../dist/page/createPageRouter') 2 | -------------------------------------------------------------------------------- /.husky/commit-msg: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | . "$(dirname -- "$0")/_/husky.sh" 3 | 4 | npx --no-install commitlint -e 5 | -------------------------------------------------------------------------------- /packages/react-imvc-v2/context/index.js: -------------------------------------------------------------------------------- 1 | import React from 'react' 2 | 3 | export default React.createContext() 4 | -------------------------------------------------------------------------------- /packages/react-imvc-v3/component/ViewManager/index.js: -------------------------------------------------------------------------------- 1 | module.exports = require('../../dist/component/ViewManager') 2 | -------------------------------------------------------------------------------- /packages/react-imvc-v3/.prettierrc.json: -------------------------------------------------------------------------------- 1 | { 2 | "semi": false, 3 | "singleQuote": true, 4 | "printWidth": 80 5 | } 6 | -------------------------------------------------------------------------------- /packages/react-imvc-v3/component/ErrorBoundary/index.js: -------------------------------------------------------------------------------- 1 | module.exports = require('../../dist/component/ErrorBoundary') 2 | -------------------------------------------------------------------------------- /packages/react-imvc-v3/component/EventWrapper/index.js: -------------------------------------------------------------------------------- 1 | module.exports = require('../../dist/component/EventWrapper') 2 | -------------------------------------------------------------------------------- /packages/react-imvc-v3/component/ControllerProxy/index.js: -------------------------------------------------------------------------------- 1 | module.exports = require('../../dist/component/ControllerProxy') 2 | -------------------------------------------------------------------------------- /packages/react-imvc-v3/.github/CONTRIBUTE.md: -------------------------------------------------------------------------------- 1 | # React-IMVC Contributing Guide 2 | 3 | - [Code of Conduct](./CODE_OF_CONDUCT.md) 4 | -------------------------------------------------------------------------------- /packages/react-imvc-v3/component/OuterClickWrapper/index.js: -------------------------------------------------------------------------------- 1 | module.exports = require('../../dist/component/OuterClickWrapper') 2 | -------------------------------------------------------------------------------- /packages/react-imvc-v3/hook/index.d.ts: -------------------------------------------------------------------------------- 1 | import hook from '../dist/hook' 2 | export default hook 3 | export * from '../dist/hook' 4 | -------------------------------------------------------------------------------- /packages/react-imvc-v2/doc/images/01.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lucifier129/react-imvc/HEAD/packages/react-imvc-v2/doc/images/01.png -------------------------------------------------------------------------------- /packages/react-imvc-v2/doc/images/02.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lucifier129/react-imvc/HEAD/packages/react-imvc-v2/doc/images/02.png -------------------------------------------------------------------------------- /packages/react-imvc-v2/doc/images/03.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lucifier129/react-imvc/HEAD/packages/react-imvc-v2/doc/images/03.png -------------------------------------------------------------------------------- /packages/react-imvc-v2/doc/images/04.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lucifier129/react-imvc/HEAD/packages/react-imvc-v2/doc/images/04.png -------------------------------------------------------------------------------- /packages/react-imvc-v2/doc/images/05.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lucifier129/react-imvc/HEAD/packages/react-imvc-v2/doc/images/05.png -------------------------------------------------------------------------------- /packages/react-imvc-v2/doc/images/06.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lucifier129/react-imvc/HEAD/packages/react-imvc-v2/doc/images/06.png -------------------------------------------------------------------------------- /packages/react-imvc-v2/doc/images/07.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lucifier129/react-imvc/HEAD/packages/react-imvc-v2/doc/images/07.png -------------------------------------------------------------------------------- /packages/react-imvc-v2/doc/images/08.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lucifier129/react-imvc/HEAD/packages/react-imvc-v2/doc/images/08.png -------------------------------------------------------------------------------- /packages/react-imvc-v2/doc/images/09.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lucifier129/react-imvc/HEAD/packages/react-imvc-v2/doc/images/09.png -------------------------------------------------------------------------------- /packages/react-imvc-v3/build/index.d.ts: -------------------------------------------------------------------------------- 1 | import build from '../dist/build' 2 | export default build 3 | export * from '../dist/build' 4 | -------------------------------------------------------------------------------- /packages/react-imvc-v3/controller/attachDevToolsIfPossible.js: -------------------------------------------------------------------------------- 1 | module.exports = require('../dist/controller/attachDevToolsIfPossible') 2 | -------------------------------------------------------------------------------- /packages/react-imvc-v3/doc/Isomorphic/README.md: -------------------------------------------------------------------------------- 1 | # 介绍 2 | 3 | 之前我们提到,在 React-IMVC 中 MVC 都是同构的,可以在服务器端和浏览器端同时运行,下面我们会详细介绍这一部分的特性及功能。 4 | -------------------------------------------------------------------------------- /packages/react-imvc-v3/start/index.d.ts: -------------------------------------------------------------------------------- 1 | import start from '../dist/start' 2 | export default start 3 | export * from '../dist/start' 4 | -------------------------------------------------------------------------------- /packages/react-imvc-v3/doc/Server/README.md: -------------------------------------------------------------------------------- 1 | # 介绍 2 | 3 | 我们除了提供路由级的接口,还提供了服务器端 Proxy 的接口和支持自定义渲染,这一部分代码推荐写在 `routes` 文件夹下,下面我们会详细介绍它们。 4 | -------------------------------------------------------------------------------- /packages/react-imvc-v3/page/view.d.ts: -------------------------------------------------------------------------------- 1 | import view from '../dist/page/view' 2 | export default view 3 | export * from '../dist/page/view' 4 | -------------------------------------------------------------------------------- /packages/react-imvc-v3/config/index.d.ts: -------------------------------------------------------------------------------- 1 | import defaults from '../dist/config' 2 | export default defaults 3 | export * from '../dist/config' 4 | -------------------------------------------------------------------------------- /packages/react-imvc-v3/context/index.d.ts: -------------------------------------------------------------------------------- 1 | import context from '../dist/context' 2 | export default context 3 | export * from '../dist/context' 4 | -------------------------------------------------------------------------------- /packages/react-imvc-v3/start/babel.d.ts: -------------------------------------------------------------------------------- 1 | import start from '../dist/start/babel' 2 | export default start 3 | export * from '../dist/start/babel' 4 | -------------------------------------------------------------------------------- /.npmrc: -------------------------------------------------------------------------------- 1 | registry = 'https://registry.npmjs.org/' 2 | prefer-workspace-packages = true 3 | auto-install-peers = true 4 | strict-peer-dependencies = false -------------------------------------------------------------------------------- /packages/react-imvc-v3/config/babel.d.ts: -------------------------------------------------------------------------------- 1 | import babel from '../dist/config/babel' 2 | export default babel 3 | export * from '../dist/config/babel' 4 | -------------------------------------------------------------------------------- /packages/react-imvc-v3/entry/client.d.ts: -------------------------------------------------------------------------------- 1 | import client from '../dist/entry/client' 2 | export default client 3 | export * from '../dist/entry/client' 4 | -------------------------------------------------------------------------------- /packages/react-imvc-v3/entry/server.d.ts: -------------------------------------------------------------------------------- 1 | import server from '../dist/entry/server' 2 | export default server 3 | export * from '../dist/entry/server' 4 | -------------------------------------------------------------------------------- /packages/react-imvc-v3/hoc/connect.d.ts: -------------------------------------------------------------------------------- 1 | import connect from '../dist/hoc/connect' 2 | export default connect 3 | export * from '../dist/hoc/connect' 4 | -------------------------------------------------------------------------------- /packages/react-imvc-v3/nyc.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | 'check-coverage': false, 3 | include: ['project/**'], 4 | reporter: ['text'], 5 | } 6 | -------------------------------------------------------------------------------- /packages/react-imvc-v3/src/polyfill/index.ts: -------------------------------------------------------------------------------- 1 | import './console' 2 | import 'whatwg-fetch' 3 | import raf from 'raf' 4 | 5 | raf.polyfill(window) 6 | -------------------------------------------------------------------------------- /packages/react-imvc-v2/project/src/img/react.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lucifier129/react-imvc/HEAD/packages/react-imvc-v2/project/src/img/react.png -------------------------------------------------------------------------------- /packages/react-imvc-v3/hook/useCtrl.d.ts: -------------------------------------------------------------------------------- 1 | import useCtrl from '../dist/hook/useCtrl' 2 | export default useCtrl 3 | export * from '../dist/hook/useCtrl' 4 | -------------------------------------------------------------------------------- /packages/react-imvc-v3/project/src/img/react.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lucifier129/react-imvc/HEAD/packages/react-imvc-v3/project/src/img/react.png -------------------------------------------------------------------------------- /packages/react-imvc-v2/.travis.yml: -------------------------------------------------------------------------------- 1 | language: node_js 2 | node_js: 3 | - '10.16.0' 4 | install: 5 | - npm install 6 | script: 7 | - npm run test 8 | -------------------------------------------------------------------------------- /packages/react-imvc-v3/controller/index.d.ts: -------------------------------------------------------------------------------- 1 | import Controller from '../dist/controller' 2 | export default Controller 3 | export * from '../dist/controller' 4 | -------------------------------------------------------------------------------- /packages/react-imvc-v3/hook/useModel.d.ts: -------------------------------------------------------------------------------- 1 | import useModel from '../dist/hook/useModel' 2 | export default useModel 3 | export * from '../dist/hook/useModel' 4 | -------------------------------------------------------------------------------- /packages/react-imvc-v3/component/Link/index.d.ts: -------------------------------------------------------------------------------- 1 | export * from '../../dist/component/Link' 2 | import Link from '../../dist/component/Link' 3 | export default Link 4 | -------------------------------------------------------------------------------- /packages/react-imvc-v3/component/Input/index.d.ts: -------------------------------------------------------------------------------- 1 | export * from '../../dist/component/Input' 2 | import Input from '../../dist/component/Input' 3 | export default Input 4 | -------------------------------------------------------------------------------- /packages/react-imvc-v3/component/Style/index.d.ts: -------------------------------------------------------------------------------- 1 | export * from '../../dist/component/Style' 2 | import Style from '../../dist/component/Style' 3 | export default Style 4 | -------------------------------------------------------------------------------- /packages/react-imvc-v3/controller/actions.d.ts: -------------------------------------------------------------------------------- 1 | import actions from '../dist/controller/actions' 2 | export default actions 3 | export * from '../dist/controller/actions' 4 | -------------------------------------------------------------------------------- /packages/react-imvc-v3/component/Script/index.d.ts: -------------------------------------------------------------------------------- 1 | export * from '../../dist/component/Script' 2 | import Script from '../../dist/component/Script' 3 | export default Script 4 | -------------------------------------------------------------------------------- /packages/react-imvc-v2/hook/useModelActions.js: -------------------------------------------------------------------------------- 1 | import useCtrl from './useCtrl' 2 | 3 | export default () => { 4 | let ctrl = useCtrl() 5 | return ctrl.store.actions 6 | } 7 | -------------------------------------------------------------------------------- /packages/react-imvc-v3/component/NavLink/index.d.ts: -------------------------------------------------------------------------------- 1 | export * from '../../dist/component/NavLink' 2 | import NavLink from '../../dist/component/NavLink' 3 | export default NavLink 4 | -------------------------------------------------------------------------------- /packages/react-imvc-v3/middleware/cacheView.d.ts: -------------------------------------------------------------------------------- 1 | import cacheView from '../dist/middleware/cacheView' 2 | export default cacheView 3 | export * from '../dist/middleware/cacheView' 4 | -------------------------------------------------------------------------------- /packages/react-imvc-v3/middleware/shareRoot.d.ts: -------------------------------------------------------------------------------- 1 | import shareRoot from '../dist/middleware/shareRoot' 2 | export default shareRoot 3 | export * from '../dist/middleware/shareRoot' 4 | -------------------------------------------------------------------------------- /packages/react-imvc-v2/hook/useModelState.js: -------------------------------------------------------------------------------- 1 | import useCtrl from './useCtrl' 2 | 3 | export default () => { 4 | let ctrl = useCtrl() 5 | return ctrl.store.getState() 6 | } 7 | -------------------------------------------------------------------------------- /packages/react-imvc-v3/build/setup-dev-env.d.ts: -------------------------------------------------------------------------------- 1 | import setupDevEnv from '../dist/build/setup-dev-env' 2 | export default setupDevEnv 3 | export * from '../dist/build/setup-dev-env' 4 | -------------------------------------------------------------------------------- /packages/react-imvc-v3/component/Prefetch/index.d.ts: -------------------------------------------------------------------------------- 1 | export * from '../../dist/component/Prefetch' 2 | import Prefetch from '../../dist/component/Prefetch' 3 | export default Prefetch 4 | -------------------------------------------------------------------------------- /packages/react-imvc-v3/config/config.defaults.d.ts: -------------------------------------------------------------------------------- 1 | import defaults from '../dist/config/config.defaults' 2 | export default defaults 3 | export * from '../dist/config/config.defaults' 4 | -------------------------------------------------------------------------------- /packages/react-imvc-v3/hook/useModelState.d.ts: -------------------------------------------------------------------------------- 1 | import useModelState from '../dist/hook/useModelState' 2 | export default useModelState 3 | export * from '../dist/hook/useModelState' 4 | -------------------------------------------------------------------------------- /packages/react-imvc-v3/project/src/content-hash/OpenSans-Bold.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Lucifier129/react-imvc/HEAD/packages/react-imvc-v3/project/src/content-hash/OpenSans-Bold.ttf -------------------------------------------------------------------------------- /packages/react-imvc-v3/build/createGulpTask.d.ts: -------------------------------------------------------------------------------- 1 | import createGulpTask from '../dist/build/createGulpTask' 2 | export default createGulpTask 3 | export * from '../dist/build/createGulpTask' 4 | -------------------------------------------------------------------------------- /packages/react-imvc-v3/middleware/createCache.d.ts: -------------------------------------------------------------------------------- 1 | import createCache from '../dist/middleware/createCache' 2 | export default createCache 3 | export * from '../dist/middleware/createCache' 4 | -------------------------------------------------------------------------------- /packages/react-imvc-v3/hook/useModelActions.d.ts: -------------------------------------------------------------------------------- 1 | import useModelActions from '../dist/hook/useModelActions' 2 | export default useModelActions 3 | export * from '../dist/hook/useModelActions' 4 | -------------------------------------------------------------------------------- /packages/react-imvc-v3/component/ViewManager/index.d.ts: -------------------------------------------------------------------------------- 1 | export * from '../../dist/component/ViewManager' 2 | import ViewManager from '../../dist/component/ViewManager' 3 | export default ViewManager 4 | -------------------------------------------------------------------------------- /packages/react-imvc-v3/page/createPageRouter.d.ts: -------------------------------------------------------------------------------- 1 | import createPageRouter from '../dist/page/createPageRouter' 2 | export default createPageRouter 3 | export * from '../dist/page/createPageRouter' 4 | -------------------------------------------------------------------------------- /packages/react-imvc-v3/src/scripts/build.ts: -------------------------------------------------------------------------------- 1 | import yargs from 'yargs' 2 | 3 | process.env.NODE_ENV = process.env.NODE_ENV || 'production' 4 | 5 | import build from '../build' 6 | build(yargs.argv) 7 | -------------------------------------------------------------------------------- /packages/react-imvc-v3/component/EventWrapper/index.d.ts: -------------------------------------------------------------------------------- 1 | export * from '../../dist/component/EventWrapper' 2 | import EventWrapper from '../../dist/component/EventWrapper' 3 | export default EventWrapper 4 | -------------------------------------------------------------------------------- /packages/react-imvc-v2/hook/index.js: -------------------------------------------------------------------------------- 1 | export useCtrl from './useCtrl' 2 | export useModel from './useModel' 3 | export useModelActions from './useModelActions' 4 | export useModelState from './useModelState' 5 | -------------------------------------------------------------------------------- /packages/react-imvc-v3/component/ErrorBoundary/index.d.ts: -------------------------------------------------------------------------------- 1 | export * from '../../dist/component/ErrorBoundary' 2 | import ErrorBoundary from '../../dist/component/ErrorBoundary' 3 | export default ErrorBoundary 4 | -------------------------------------------------------------------------------- /packages/react-imvc-v3/project/src/style/base.scss: -------------------------------------------------------------------------------- 1 | // _base.scss 2 | $font-stack: Helvetica, sans-serif; 3 | $primary-color: #333; 4 | 5 | body { 6 | font: 100% $font-stack; 7 | color: $primary-color; 8 | } -------------------------------------------------------------------------------- /packages/react-imvc-v3/build/createWebpackConfig.d.ts: -------------------------------------------------------------------------------- 1 | import createWebpackConfig from '../dist/build/createWebpackConfig' 2 | export default createWebpackConfig 3 | export * from '../dist/build/createWebpackConfig' 4 | -------------------------------------------------------------------------------- /packages/react-imvc-v3/test/util/index.ts: -------------------------------------------------------------------------------- 1 | export { default as fetchContent } from './fetchContent' 2 | export { default as setTimeOutAsync } from './setTimeOutAsync' 3 | export { default as kill } from './kill' 4 | -------------------------------------------------------------------------------- /packages/react-imvc-v3/component/ControllerProxy/index.d.ts: -------------------------------------------------------------------------------- 1 | export * from '../../dist/component/ControllerProxy' 2 | import ControllerProxy from '../../dist/component/ControllerProxy' 3 | export default ControllerProxy 4 | -------------------------------------------------------------------------------- /packages/react-imvc-v2/hook/useCtrl.js: -------------------------------------------------------------------------------- 1 | import { useContext } from 'react' 2 | import GlobalContext from '../context' 3 | 4 | export default () => { 5 | let { ctrl } = useContext(GlobalContext) 6 | return ctrl 7 | } 8 | -------------------------------------------------------------------------------- /packages/react-imvc-v3/component/OuterClickWrapper/index.d.ts: -------------------------------------------------------------------------------- 1 | export * from '../../dist/component/OuterClickWrapper' 2 | import OuterClickWrapper from '../../dist/component/OuterClickWrapper' 3 | export default OuterClickWrapper 4 | -------------------------------------------------------------------------------- /packages/react-imvc-v3/doc/Config/README.md: -------------------------------------------------------------------------------- 1 | # 介绍 2 | 3 | 配置文件为当前项目提供各个开发、打包流程的文件和配置信息。在一个项目中一般需要两份配置,一份在 `imvc.config.js` 中,这一份配置适用于项目的开发、测试和构建流程;另一份在 `start.js` 中,用于构建之后,在生产环境下运行的入口文件。当然,因为有默认配置,所以这两份配置都是可选的。 4 | 5 | 接下来我们看看,这两分配置的使用方式。 6 | -------------------------------------------------------------------------------- /packages/react-imvc-v3/test/util/setTimeOutAsync.ts: -------------------------------------------------------------------------------- 1 | export default function setTimeOutAsync(ms: number): Promise { 2 | return new Promise((resolve) => { 3 | setTimeout(() => { 4 | resolve() 5 | }, ms) 6 | }) 7 | } 8 | -------------------------------------------------------------------------------- /.prettierrc: -------------------------------------------------------------------------------- 1 | { 2 | "printWidth": 120, 3 | "semi": false, 4 | "tabWidth": 4, 5 | "trailingComma": "all", 6 | "singleQuote": true, 7 | "arrowParens": "always", 8 | "jsxSingleQuote": false, 9 | "endOfLine": "lf" 10 | } 11 | -------------------------------------------------------------------------------- /packages/react-imvc-v2/project/src/preload/style.css: -------------------------------------------------------------------------------- 1 | body { 2 | background: #666; 3 | color:aliceblue 4 | } 5 | 6 | 7 | .logo { 8 | width: 267px; 9 | height: 189px; 10 | background-image: url(#public_path/img/react.png); 11 | } -------------------------------------------------------------------------------- /packages/react-imvc-v3/controller/attachDevToolsIfPossible.d.ts: -------------------------------------------------------------------------------- 1 | import attachDevToolsIfPossible from '../dist/controller/attachDevToolsIfPossible' 2 | export default attachDevToolsIfPossible 3 | export * from '../dist/controller/attachDevToolsIfPossible' 4 | -------------------------------------------------------------------------------- /packages/react-imvc-v3/project/src/style/Dynamic.tsx: -------------------------------------------------------------------------------- 1 | import * as React from 'react' 2 | 3 | export default function Dynamic() { 4 | return ( 5 |
6 |
dynamic view content
7 |
8 | ) 9 | } 10 | -------------------------------------------------------------------------------- /packages/react-imvc-v3/src/hook/useModelState.ts: -------------------------------------------------------------------------------- 1 | import useCtrl from './useCtrl' 2 | import type Controller from '../controller' 3 | 4 | export default function () { 5 | let ctrl = useCtrl>() 6 | return ctrl.store.getState() 7 | } 8 | -------------------------------------------------------------------------------- /packages/react-imvc-v3/src/hook/index.ts: -------------------------------------------------------------------------------- 1 | export { default as useCtrl } from './useCtrl' 2 | export { default as useModel } from './useModel' 3 | export { default as useModelState } from './useModelState' 4 | export { default as useModelActions } from './useModelActions' 5 | -------------------------------------------------------------------------------- /packages/react-imvc-v3/test/util/fetchContent.ts: -------------------------------------------------------------------------------- 1 | import fetch from 'node-fetch' 2 | 3 | export default async function fetchContent(url: string): Promise { 4 | let response = await fetch(url) 5 | let content = await response.text() 6 | return content 7 | } 8 | -------------------------------------------------------------------------------- /packages/react-imvc-v3/project/src/content-hash/style.css: -------------------------------------------------------------------------------- 1 | @font-face { 2 | font-family: 'OpenSans-Bold'; 3 | src: url(#public_path/content-hash/OpenSans-Bold.ttf) format('truetype'); 4 | } 5 | 6 | html { 7 | font-family: 'OpenSans-Bold'; 8 | font-size: 16px; 9 | } -------------------------------------------------------------------------------- /packages/react-imvc-v2/hook/useModel.js: -------------------------------------------------------------------------------- 1 | import useModelState from './useModelState' 2 | import useModelActions from './useModelActions' 3 | 4 | export default () => { 5 | let state = useModelState() 6 | let actions = useModelActions() 7 | return [state, actions] 8 | } 9 | -------------------------------------------------------------------------------- /packages/react-imvc-v3/project/start.ts: -------------------------------------------------------------------------------- 1 | process.env.NODE_ENV = 'production' 2 | 3 | import { start } from '../dist' 4 | import config from './imvc.config' 5 | 6 | start({ 7 | config: { 8 | ...config, 9 | root: __dirname, 10 | logger: 'dev', 11 | }, 12 | }) 13 | -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | #root = true 2 | 3 | [*] 4 | indent_style = space 5 | end_of_line = lf 6 | charset = utf-8 7 | trim_trailing_whitespace = true 8 | insert_final_newline = true 9 | max_line_length = 100 10 | indent_size = 2 11 | 12 | [*.md] 13 | trim_trailing_whitespace = false 14 | -------------------------------------------------------------------------------- /packages/react-imvc-v3/src/imvc.d.ts: -------------------------------------------------------------------------------- 1 | /// 2 | /// 3 | /// 4 | 5 | declare namespace NodeJS { 6 | interface ProcessEnv { 7 | NODE_ENV: 'development' | 'production' | 'test' 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /packages/react-imvc-v3/src/hook/useModelActions.ts: -------------------------------------------------------------------------------- 1 | import useCtrl from './useCtrl' 2 | import type Controller from '../controller' 3 | 4 | export default function () { 5 | const { store } = useCtrl>() 6 | return store.actions 7 | } 8 | -------------------------------------------------------------------------------- /packages/react-imvc-v3/project/src/link-from/preload.css: -------------------------------------------------------------------------------- 1 | .active { 2 | color: 'red'; 3 | background-image: url("#public_path/img/react.png"); 4 | display: block; 5 | width: 267px; 6 | height: 189px; 7 | } 8 | 9 | .inactive { 10 | background-image: url(#public_path/img/happy.svg); 11 | } -------------------------------------------------------------------------------- /packages/react-imvc-v3/project/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "project", 3 | "version": "1.0.0", 4 | "description": "", 5 | "main": "index.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1" 8 | }, 9 | "keywords": [], 10 | "author": "yj_gu", 11 | "license": "ISC" 12 | } 13 | -------------------------------------------------------------------------------- /packages/react-imvc-v3/src/hook/useCtrl.ts: -------------------------------------------------------------------------------- 1 | import { useContext } from 'react' 2 | import GlobalContext from '../context' 3 | import type Controller from '../controller' 4 | 5 | export default function useCtrl>() { 6 | let { ctrl } = useContext(GlobalContext) 7 | return ctrl as Ctrl 8 | } 9 | -------------------------------------------------------------------------------- /packages/react-imvc-v3/test/test.d.ts: -------------------------------------------------------------------------------- 1 | /// 2 | /// 3 | /// 4 | /// 5 | 6 | declare namespace NodeJS { 7 | interface ProcessEnv { 8 | NODE_ENV: 'development' | 'production' | 'test' 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /.github/renovate.json5: -------------------------------------------------------------------------------- 1 | { 2 | "extends": ["config:base", "schedule:weekly", "group:allNonMajor"], 3 | "labels": ["dependencies"], 4 | "pin": false, 5 | "rangeStrategy": "bump", 6 | "node": false, 7 | "packageRules": [ 8 | { 9 | "depTypeList": ["peerDependencies"], 10 | "enabled": false 11 | } 12 | ] 13 | } -------------------------------------------------------------------------------- /packages/react-imvc-v2/project/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "project", 3 | "version": "1.0.0", 4 | "description": "", 5 | "main": "build.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1" 8 | }, 9 | "keywords": [], 10 | "author": "yj_gu", 11 | "license": "ISC" 12 | } 13 | -------------------------------------------------------------------------------- /packages/react-imvc-v3/src/hook/useModel.ts: -------------------------------------------------------------------------------- 1 | import useModelState from './useModelState' 2 | import useModelActions from './useModelActions' 3 | 4 | export default function useModel() { 5 | const state = useModelState() 6 | const actions = useModelActions() 7 | return [state, actions] as const 8 | } 9 | -------------------------------------------------------------------------------- /packages/react-imvc-v2/build/babel.js: -------------------------------------------------------------------------------- 1 | const babel = require('../config/babel') 2 | const defaultConfig = require('../config/config.defaults') 3 | 4 | require('@babel/register')({ 5 | ...babel(true, defaultConfig), 6 | extensions: ['.es6', '.es', '.jsx', '.js', '.mjs', '.ts', '.tsx'], 7 | }) 8 | 9 | module.exports = require('./index') 10 | -------------------------------------------------------------------------------- /packages/react-imvc-v2/start/babel.js: -------------------------------------------------------------------------------- 1 | const babel = require('../config/babel') 2 | const defaultConfig = require('../config/config.defaults') 3 | 4 | require('@babel/register')({ 5 | ...babel(true, defaultConfig), 6 | extensions: ['.es6', '.es', '.jsx', '.js', '.mjs', '.ts', '.tsx'], 7 | }) 8 | 9 | module.exports = require('./index') 10 | -------------------------------------------------------------------------------- /packages/react-imvc-v3/project/src/style/nav.scss: -------------------------------------------------------------------------------- 1 | nav { 2 | ul { 3 | margin: 0; 4 | padding: 0; 5 | list-style: none; 6 | } 7 | 8 | li { 9 | display: inline-block; 10 | } 11 | 12 | a { 13 | display: block; 14 | padding: 6px 12px; 15 | text-decoration: none; 16 | } 17 | } -------------------------------------------------------------------------------- /packages/react-imvc-v2/.gitignore: -------------------------------------------------------------------------------- 1 | # See http://help.github.com/ignore-files/ for more about ignoring files. 2 | 3 | # dependencies 4 | node_modules 5 | 6 | # production 7 | publish 8 | project_publish 9 | .idea 10 | 11 | # misc 12 | .DS_Store 13 | npm-debug.log 14 | .vscode 15 | _site 16 | mock/test.json 17 | test-results/ 18 | playwright-report/ 19 | -------------------------------------------------------------------------------- /packages/react-imvc-v2/project/src/static-view/Controller.js: -------------------------------------------------------------------------------- 1 | import Controller from '../../../controller' 2 | import React from 'react' 3 | export default class extends Controller { 4 | SSR = true // enable server side rendering 5 | View = View 6 | } 7 | 8 | function View() { 9 | return
static view content
10 | } 11 | -------------------------------------------------------------------------------- /packages/react-imvc-v2/component/Script.js: -------------------------------------------------------------------------------- 1 | import React from 'react' 2 | 3 | export default function Script(props) { 4 | let children = props.children || '' 5 | return ( 6 | 28 | {view} 29 | 30 | ) 31 | }, 32 | } 33 | 34 | export default config 35 | -------------------------------------------------------------------------------- /packages/react-imvc-v2/component/NavLink.js: -------------------------------------------------------------------------------- 1 | import React from 'react' 2 | import classnames from 'classnames' 3 | import connect from '../hoc/connect' 4 | import Link from './Link' 5 | 6 | const withLocation = connect(({ state }) => { 7 | return { 8 | location: state.location, 9 | } 10 | }) 11 | 12 | export default withLocation(NavLink) 13 | 14 | function NavLink({ isActive: getIsActive, location, className, activeClassName, style, activeStyle, to, ...rest }) { 15 | let isActive = checkActive(getIsActive, to, location) 16 | let finalClassName = classnames(className, isActive && activeClassName) 17 | let finalStyle = isActive ? { ...style, ...activeStyle } : style 18 | return 19 | } 20 | 21 | function checkActive(getIsActive, path, location) { 22 | return getIsActive ? !!getIsActive(path, location) : path === location.raw 23 | } 24 | -------------------------------------------------------------------------------- /packages/react-imvc-v3/src/build/compileNodeModules.ts: -------------------------------------------------------------------------------- 1 | import type { AllowlistOption } from 'webpack-node-externals' 2 | 3 | export type CompileNodeModulesOptions = { 4 | rules?: AllowlistOption[] 5 | } 6 | 7 | export const checkFilename = ( 8 | filename: string, 9 | rules?: CompileNodeModulesOptions['rules'] 10 | ) => { 11 | if (!rules) { 12 | return !filename.includes('node_modules') 13 | } 14 | 15 | let isMatched = false 16 | 17 | for (const rule of rules) { 18 | if (typeof rule === 'string') { 19 | if (filename.includes(rule)) { 20 | isMatched = true 21 | break 22 | } 23 | } else if (typeof rule === 'function') { 24 | if (rule(filename)) { 25 | isMatched = true 26 | break 27 | } 28 | } else { 29 | if (rule.test(filename)) { 30 | isMatched = true 31 | break 32 | } 33 | } 34 | } 35 | 36 | return isMatched 37 | } 38 | -------------------------------------------------------------------------------- /packages/react-imvc-v3/src/controller/actions.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * 共享的 action 函数 3 | */ 4 | import { setValueByPath } from '../util' 5 | import type { Location, Action } from '..' 6 | 7 | export const INDENTITY: Action = (state) => state 8 | 9 | export const UPDATE_STATE: Action = (state, newState) => { 10 | return { 11 | ...state, 12 | ...newState, 13 | } 14 | } 15 | 16 | export const __PAGE_DID_BACK__: Action = ( 17 | state, 18 | location 19 | ) => { 20 | return { 21 | ...state, 22 | location, 23 | } 24 | } 25 | 26 | interface USBPPayload { 27 | [x: string]: any 28 | } 29 | export const UPDATE_STATE_BY_PATH: Action = ( 30 | state, 31 | payload 32 | ) => { 33 | return Object.keys(payload).reduce( 34 | (state, path) => setValueByPath(state, path, payload[path]), 35 | state 36 | ) 37 | } 38 | 39 | export const UPDATE_INPUT_VALUE = UPDATE_STATE_BY_PATH 40 | -------------------------------------------------------------------------------- /packages/react-imvc-v2/.github/workflows/playwright.yml: -------------------------------------------------------------------------------- 1 | name: Playwright Tests 2 | on: 3 | push: 4 | branches: [main, master] 5 | pull_request: 6 | branches: [main, master] 7 | jobs: 8 | test: 9 | timeout-minutes: 60 10 | runs-on: ubuntu-latest 11 | steps: 12 | - uses: actions/checkout@v2 13 | - uses: actions/setup-node@v2 14 | with: 15 | node-version: '14.x' 16 | - name: Install dependencies 17 | run: npm ci 18 | - name: Install Playwright 19 | run: npx playwright install --with-deps 20 | - name: Run Playwright tests 21 | run: npx playwright test 22 | - uses: actions/upload-artifact@v2 23 | if: always() 24 | with: 25 | name: playwright-report 26 | path: playwright-report/ 27 | retention-days: 30 28 | -------------------------------------------------------------------------------- /packages/react-imvc-v3/test/config.spec.ts: -------------------------------------------------------------------------------- 1 | import getConfig, * as EntireConfig from '../src/config' 2 | 3 | describe('config test', () => { 4 | describe('getConfig', () => { 5 | it('get default config with pass empty argument', () => { 6 | let config = getConfig() 7 | expect(config).toStrictEqual(EntireConfig.defaultConfig) 8 | }) 9 | 10 | it('config attribute passed in could cover default config when config is a object', () => { 11 | let options = { 12 | config: { 13 | basename: 'test', 14 | }, 15 | } 16 | let config = getConfig(options) 17 | expect(config.basename).toBe('test') 18 | }) 19 | 20 | it('config attribute passed in could cover default config when config is a path string', () => { 21 | let options = { 22 | config: './test/config.ts', 23 | } 24 | let config = getConfig(options) 25 | expect(config.basename).toBe('test') 26 | }) 27 | }) 28 | }) 29 | -------------------------------------------------------------------------------- /packages/react-imvc-v3/src/hoc/connect.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react' 2 | import GlobalContext from '../context' 3 | 4 | export type ExcludeFromObject = Pick> 5 | 6 | export interface With { 7 |

(inputComponent: React.ComponentType

): ( 8 | props: ExcludeFromObject 9 | ) => React.ReactElement 10 | } 11 | 12 | function connect any>( 13 | selector?: S 14 | ): With> { 15 | return

(InputComponent: React.ComponentType

) => { 16 | return function Connector(props) { 17 | return ( 18 | 19 | {({ state, ctrl }) => { 20 | let sProps = selector ? selector({ state, ctrl, props }) : {} 21 | 22 | return 23 | }} 24 | 25 | ) 26 | } 27 | } 28 | } 29 | 30 | export default connect 31 | -------------------------------------------------------------------------------- /packages/react-imvc-v3/project/src/connect/Controller.tsx: -------------------------------------------------------------------------------- 1 | import Controller from '../../../src/controller' 2 | import connect from '../../../src/hoc/connect' 3 | import React from 'react' 4 | import { Location, Context } from '../../../src/' 5 | export default class extends Controller<{}, {}> { 6 | // SSR = true // enable server side rendering 7 | View = View 8 | constructor(location: Location, context: Context) { 9 | super(location, context) 10 | } 11 | } 12 | 13 | const withLocation = connect(() => { 14 | return { 15 | location: 'test', 16 | } 17 | }) 18 | 19 | export interface Props { 20 | location: string 21 | } 22 | 23 | const LocationComponent = ({ location }: Props) => { 24 | return

{location}
25 | } 26 | 27 | const WithLocationComponent = withLocation(LocationComponent) 28 | 29 | function View() { 30 | return ( 31 |
32 | 33 |
34 | ) 35 | } 36 | -------------------------------------------------------------------------------- /packages/react-imvc-v3/.github/workflows/nodejs.yml: -------------------------------------------------------------------------------- 1 | # This workflow will do a clean install of node dependencies, build the source code and run tests across different versions of node 2 | # For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions 3 | 4 | name: IMVC 5 | 6 | on: 7 | push: 8 | branches: [master] 9 | pull_request: 10 | branches: [master] 11 | 12 | jobs: 13 | build: 14 | runs-on: ${{ matrix.os }} 15 | 16 | strategy: 17 | matrix: 18 | node-version: [10.x, 12.x, 14.x, 16.x, 17.x] 19 | os: [ubuntu-latest, macos-latest, windows-latest] 20 | 21 | steps: 22 | - uses: actions/checkout@v2 23 | - name: Use Node.js ${{ matrix.node-version }} 24 | uses: actions/setup-node@v1 25 | with: 26 | node-version: ${{ matrix.node-version }} 27 | - run: yarn 28 | - run: yarn build 29 | - run: yarn test 30 | env: 31 | CI: true 32 | -------------------------------------------------------------------------------- /packages/react-imvc-v3/doc/Isomorphic/cache.md: -------------------------------------------------------------------------------- 1 | # 缓存 2 | 3 | 为了提高页面加载速度和效率,我们也提供了一些缓存的功能。 4 | 5 | ## 属性设置 6 | 7 | ### KeepAlive 8 | 9 | 类型:`boolean` 10 | 11 | 默认值:`false` 12 | 13 | 当 `ctrl.KeepAlive = true` 时,开启缓存模式。默认为 `false|undefined` 14 | 15 | `KeepAlive` 会缓存 `view`,`ctrl` 及其 `store`。 16 | 17 | 当页面前进或后退时,不再实例化一个新的 `ctrl`,而是从缓存里取出上次的 `ctrl`,并展示它的 `view` (通过设置 `dispaly`)。并触发 `pageDidBack` 生命周期。 18 | 19 | ### KeepAliveOnPush 20 | 21 | 类型:`boolean` 22 | 23 | 默认值:`false` 24 | 25 | 当 `ctrl.KeepAliveOnPush = true` 时,当页面通过 `history.push` 到另一个页面时,缓存当前页面。当页面回退到上一个页面时,清除当前页面的缓存。 26 | 27 | 该属性可以实现只为下一个新页面的提供缓存功能。 28 | 29 | 注:浏览器把前进/后退都视为 POP 事件,因此 A 页面 `history.push` 到 B 页面,B 页面 `history.back` 回到 A 时为 POP,A 页面再 `history.forward` 到 B 页面,也是 POP。`KeepAliveOnPush` 无法处理该场景,只能支持一次性来回的场景。 30 | 31 | ## 内置函数 32 | 33 | ### saveToCache 34 | 35 | `ctrl.saveToCache` 方法只在客户端存在,用以手动将 `ctrl` 加入 KeepAlive 缓存里。 36 | 37 | ### removeFromCache 38 | 39 | `ctrl.removeFromCache` 方法只在客户端存在,用以手动将 `ctrl` 从 KeepAlive 缓存里清除。 40 | -------------------------------------------------------------------------------- /packages/react-imvc-v2/project/src/model/Controller.js: -------------------------------------------------------------------------------- 1 | import Controller from '../../../controller' 2 | import React from 'react' 3 | 4 | export default class extends Controller { 5 | SSR = this.location.query.ssr !== '0' 6 | View = View 7 | initialState = { 8 | count: 0, 9 | } 10 | actions = { 11 | incre: (state, step = 1) => { 12 | return { 13 | count: state.count + step, 14 | } 15 | }, 16 | decre: (state, step = 1) => { 17 | return { 18 | count: state.count - step, 19 | } 20 | }, 21 | } 22 | componentDidMount() { 23 | console.log('didMount') 24 | } 25 | } 26 | 27 | function View({ state, actions }) { 28 | return ( 29 |
30 | 31 | {state.count} 32 | 33 |
34 | ) 35 | } 36 | -------------------------------------------------------------------------------- /packages/react-imvc-v3/src/component/EventWrapper.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react' 2 | import GlobalContext from '../context' 3 | 4 | const isHandler = (key: string) => /^on[A-Z]+/.test(key) 5 | 6 | export interface EventWrapperProps { 7 | as?: keyof HTMLElementTagNameMap 8 | [propName: string]: any 9 | } 10 | 11 | export default class EventWrapper extends React.Component { 12 | static contextType = GlobalContext 13 | static defaultProps: EventWrapperProps = { 14 | as: 'div', 15 | } 16 | 17 | render() { 18 | const { children, as: tag, ...restProps } = this.props 19 | let props: Record = restProps 20 | const { ctrl } = this.context 21 | for (let key in props) { 22 | if (isHandler(key)) { 23 | const handler = ctrl[props[key]] 24 | if ('function' === typeof handler) { 25 | props[key] = handler 26 | } 27 | } 28 | } 29 | return React.createElement(tag ? tag : 'div', props, children) 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /packages/react-imvc-v2/project/src/preload/Controller.js: -------------------------------------------------------------------------------- 1 | import Controller from '../../../controller' 2 | import { Style } from '../../../component' 3 | import React from 'react' 4 | import style from './style.css' 5 | 6 | export default class extends Controller { 7 | SSR = this.location.query.ssr !== '0' 8 | View = View 9 | constructor(location, context) { 10 | super(location, context) 11 | if (context.isClient) { 12 | window.controller = this 13 | } else if (context.isServer) { 14 | global.controller = this 15 | } 16 | } 17 | preload = { 18 | style: style, 19 | } 20 | publicPathPlaceholder = '#public_path' 21 | } 22 | 23 | function View({ state }) { 24 | return ( 25 | <> 26 |