├── .editorconfig ├── .eslintignore ├── .eslintrc.js ├── .gitignore ├── .markdownlint.json ├── .prettierignore ├── .prettierrc.js ├── .vscode ├── extensions.json └── settings.json ├── CHANGELOG.md ├── LICENSE ├── README.md ├── api └── .vuepress │ ├── .api │ ├── model.api.json │ ├── react-taro.api.json │ ├── react-web.api.json │ ├── vue-taro.api.json │ └── vue-web.api.json │ ├── .eslintrc.js │ ├── components │ ├── NavbarBrand.vue │ └── NavbarItems.vue │ ├── config.ts │ ├── public │ └── images │ │ ├── logo-16x.png │ │ ├── logo-2.svg │ │ └── logo-32x.png │ └── styles │ └── index.scss ├── babelrc.build.js ├── commitlint.config.js ├── docs ├── .vuepress │ ├── .eslintrc.js │ ├── components │ │ ├── HomeFeatures.vue │ │ ├── HomeFooter.vue │ │ └── HomeHero.vue │ ├── config.ts │ ├── public │ │ ├── fonts │ │ │ ├── iconfont.ttf │ │ │ ├── iconfont.woff │ │ │ └── iconfont.woff2 │ │ └── images │ │ │ ├── case │ │ │ ├── favs.jpg │ │ │ ├── leave.jpg │ │ │ ├── type.jpg │ │ │ └── window.jpg │ │ │ ├── cli-bg.png │ │ │ ├── component-state.svg │ │ │ ├── dev-tools.png │ │ │ ├── easy-bg.svg │ │ │ ├── easy-code.svg │ │ │ ├── gaba.png │ │ │ ├── hero-photo.png │ │ │ ├── hero-router-bg.svg │ │ │ ├── hero-summary-bg.svg │ │ │ ├── logo-16x.png │ │ │ ├── logo-2.svg │ │ │ ├── logo-32x.png │ │ │ ├── logo-icon-rotate.svg │ │ │ ├── logo-icon.svg │ │ │ ├── logo-react.png │ │ │ ├── logo-rn.png │ │ │ ├── logo-taro.png │ │ │ ├── logo-text.svg │ │ │ ├── logo-vue.png │ │ │ ├── logo-vue.svg │ │ │ ├── micro-module-model.png │ │ │ ├── model-reusable.svg │ │ │ ├── model1.svg │ │ │ ├── model2.svg │ │ │ ├── model3.svg │ │ │ ├── module-level.svg │ │ │ ├── qq.jpg │ │ │ ├── router-browser.svg │ │ │ ├── router-stacks.svg │ │ │ ├── router-store.svg │ │ │ ├── router-transform.svg │ │ │ ├── ssr-flow.svg │ │ │ ├── static-structure.svg │ │ │ ├── three-layers.svg │ │ │ ├── wechat.jpg │ │ │ └── xxx.svg │ └── styles │ │ └── index.scss ├── README.md ├── designed │ ├── micro-module.md │ ├── model-driven.md │ ├── route-history.md │ └── three-layered.md ├── ecological │ └── index.md └── guide │ ├── basics │ ├── action.md │ ├── immutable.md │ ├── model.md │ ├── module.md │ ├── router.md │ ├── store.md │ └── view.md │ ├── concepts.md │ ├── configure.md │ ├── css.md │ ├── demote.md │ ├── dev-tools.md │ ├── example.md │ ├── install.md │ ├── mfd.md │ ├── platform │ ├── ssr.md │ └── taro.md │ ├── quick.md │ ├── state.md │ ├── summary.md │ └── ui-framework │ ├── react.md │ └── vue.md ├── lerna.json ├── package.json ├── packages ├── app │ ├── .babelrc.js │ ├── CHANGELOG.md │ ├── README.md │ ├── dist │ │ ├── es5 │ │ │ └── index.js │ │ └── es6 │ │ │ └── index.js │ ├── package.json │ ├── src │ │ ├── index.ts │ │ └── tsconfig.json │ └── types │ │ ├── index.d.ts │ │ └── index.d.ts.map ├── core │ ├── .babelrc.js │ ├── CHANGELOG.md │ ├── LICENSE │ ├── README.md │ ├── dist │ │ ├── es5 │ │ │ └── index.js │ │ └── es6 │ │ │ └── index.js │ ├── global │ │ └── global.d.ts │ ├── jest.config.js │ ├── package.json │ ├── rollup.config.js │ ├── runtime │ │ └── runtime.d.ts │ ├── src │ │ ├── actions.ts │ │ ├── app.ts │ │ ├── basic.ts │ │ ├── devtools.ts │ │ ├── env.ts │ │ ├── facade.ts │ │ ├── history.ts │ │ ├── index.ts │ │ ├── inject.ts │ │ ├── module.ts │ │ ├── route.ts │ │ ├── store.ts │ │ ├── tsconfig.json │ │ └── utils.ts │ ├── tests │ │ ├── deepMerge.test.ts │ │ ├── setup.ts │ │ └── tsconfig.json │ └── types │ │ ├── actions.d.ts │ │ ├── actions.d.ts.map │ │ ├── app.d.ts │ │ ├── app.d.ts.map │ │ ├── basic.d.ts │ │ ├── basic.d.ts.map │ │ ├── devtools.d.ts │ │ ├── devtools.d.ts.map │ │ ├── env.d.ts │ │ ├── env.d.ts.map │ │ ├── facade.d.ts │ │ ├── facade.d.ts.map │ │ ├── history.d.ts │ │ ├── history.d.ts.map │ │ ├── index.d.ts │ │ ├── index.d.ts.map │ │ ├── inject.d.ts │ │ ├── inject.d.ts.map │ │ ├── module.d.ts │ │ ├── module.d.ts.map │ │ ├── route.d.ts │ │ ├── route.d.ts.map │ │ ├── store.d.ts │ │ ├── store.d.ts.map │ │ ├── utils.d.ts │ │ └── utils.d.ts.map ├── model │ ├── .babelrc.js │ ├── CHANGELOG.md │ ├── README.md │ ├── api-extractor.json │ ├── dist │ │ ├── es5 │ │ │ └── index.js │ │ └── es6 │ │ │ └── index.js │ ├── package.json │ ├── rollup.config.js │ ├── src │ │ ├── index.ts │ │ └── tsconfig.json │ └── types │ │ ├── index.d.ts │ │ └── index.d.ts.map ├── react-components │ ├── .babelrc.js │ ├── CHANGELOG.md │ ├── README.md │ ├── dist │ │ ├── es5 │ │ │ ├── App.js │ │ │ ├── DocumentHead.js │ │ │ ├── EWindow.js │ │ │ ├── Else.js │ │ │ ├── Link.js │ │ │ ├── LoadComponent.js │ │ │ ├── Router.js │ │ │ ├── Switch.js │ │ │ ├── base.js │ │ │ └── index.js │ │ └── es6 │ │ │ ├── App.js │ │ │ ├── DocumentHead.js │ │ │ ├── EWindow.js │ │ │ ├── Else.js │ │ │ ├── Link.js │ │ │ ├── LoadComponent.js │ │ │ ├── Router.js │ │ │ ├── Switch.js │ │ │ ├── base.js │ │ │ └── index.js │ ├── package.json │ ├── src │ │ ├── .eslintrc.js │ │ ├── App.tsx │ │ ├── DocumentHead.ts │ │ ├── EWindow.tsx │ │ ├── Else.tsx │ │ ├── Link.tsx │ │ ├── LoadComponent.tsx │ │ ├── Router.tsx │ │ ├── Switch.tsx │ │ ├── base.ts │ │ ├── index.ts │ │ └── tsconfig.json │ └── types │ │ ├── App.d.ts │ │ ├── App.d.ts.map │ │ ├── DocumentHead.d.ts │ │ ├── DocumentHead.d.ts.map │ │ ├── EWindow.d.ts │ │ ├── EWindow.d.ts.map │ │ ├── Else.d.ts │ │ ├── Else.d.ts.map │ │ ├── Link.d.ts │ │ ├── Link.d.ts.map │ │ ├── Router.d.ts │ │ ├── Router.d.ts.map │ │ ├── Switch.d.ts │ │ ├── Switch.d.ts.map │ │ ├── base.d.ts │ │ ├── base.d.ts.map │ │ ├── index.d.ts │ │ ├── index.d.ts.map │ │ ├── loadComponent.d.ts │ │ └── loadComponent.d.ts.map ├── react-redux │ ├── .babelrc.js │ ├── CHANGELOG.md │ ├── README.md │ ├── dist │ │ ├── es5 │ │ │ └── index.js │ │ └── es6 │ │ │ └── index.js │ ├── package.json │ ├── src │ │ ├── index.ts │ │ └── tsconfig.json │ └── types │ │ ├── index.d.ts │ │ └── index.d.ts.map ├── react-taro │ ├── .babelrc.js │ ├── CHANGELOG.md │ ├── README.md │ ├── api-extractor.json │ ├── dist │ │ ├── es5 │ │ │ └── index.js │ │ └── es6 │ │ │ └── index.js │ ├── package.json │ ├── rollup.config.js │ ├── src │ │ ├── global.d.ts │ │ ├── index.tsx │ │ └── tsconfig.json │ ├── types │ │ ├── index.d.ts │ │ └── index.d.ts.map │ └── yarn.lock ├── react-web │ ├── .babelrc.js │ ├── CHANGELOG.md │ ├── README.md │ ├── api-extractor copy.json │ ├── api-extractor.json │ ├── dist │ │ ├── es5 │ │ │ └── index.js │ │ └── es6 │ │ │ └── index.js │ ├── package.json │ ├── rollup.config.js │ ├── server.js │ ├── server.mock.js │ ├── src │ │ ├── global.d.ts │ │ ├── index.ts │ │ └── tsconfig.json │ └── types │ │ ├── index.d.ts │ │ └── index.d.ts.map ├── route-browser │ ├── .babelrc.js │ ├── CHANGELOG.md │ ├── README.md │ ├── dist │ │ ├── es5 │ │ │ └── index.js │ │ └── es6 │ │ │ └── index.js │ ├── package.json │ ├── src │ │ ├── index.ts │ │ └── tsconfig.json │ └── types │ │ ├── index.d.ts │ │ └── index.d.ts.map ├── route-mp │ ├── .babelrc.js │ ├── CHANGELOG.md │ ├── README.md │ ├── dist │ │ ├── es5 │ │ │ └── index.js │ │ └── es6 │ │ │ └── index.js │ ├── package.json │ ├── src │ │ ├── index.ts │ │ └── tsconfig.json │ └── types │ │ ├── index.d.ts │ │ └── index.d.ts.map ├── taro │ ├── .babelrc.js │ ├── CHANGELOG.md │ ├── README.md │ ├── dist │ │ ├── es5 │ │ │ └── index.js │ │ └── es6 │ │ │ └── index.js │ ├── global │ │ └── global.d.ts │ ├── package.json │ ├── src │ │ ├── index.ts │ │ ├── patchMiniProgram.txt │ │ └── tsconfig.json │ ├── types │ │ ├── index.d.ts │ │ └── index.d.ts.map │ └── yarn.lock ├── vue-components │ ├── .babelrc.js │ ├── CHANGELOG.md │ ├── README.md │ ├── dist │ │ ├── es5 │ │ │ ├── App.js │ │ │ ├── DocumentHead.js │ │ │ ├── EWindow.js │ │ │ ├── Else.js │ │ │ ├── Link.js │ │ │ ├── LoadComponent.js │ │ │ ├── Router.js │ │ │ ├── Switch.js │ │ │ ├── base.js │ │ │ └── index.js │ │ └── es6 │ │ │ ├── App.js │ │ │ ├── DocumentHead.js │ │ │ ├── EWindow.js │ │ │ ├── Else.js │ │ │ ├── Link.js │ │ │ ├── LoadComponent.js │ │ │ ├── Router.js │ │ │ ├── Switch.js │ │ │ ├── base.js │ │ │ └── index.js │ ├── package.json │ ├── src │ │ ├── .eslintrc.js │ │ ├── App.tsx │ │ ├── DocumentHead.ts │ │ ├── EWindow.tsx │ │ ├── Else.tsx │ │ ├── Link.ts │ │ ├── LoadComponent.tsx │ │ ├── Router.tsx │ │ ├── Switch.tsx │ │ ├── base.tsx │ │ ├── index.ts │ │ └── tsconfig.json │ └── types │ │ ├── App.d.ts │ │ ├── App.d.ts.map │ │ ├── DocumentHead.d.ts │ │ ├── DocumentHead.d.ts.map │ │ ├── EWindow.d.ts │ │ ├── EWindow.d.ts.map │ │ ├── Else.d.ts │ │ ├── Else.d.ts.map │ │ ├── Link.d.ts │ │ ├── Link.d.ts.map │ │ ├── Router.d.ts │ │ ├── Router.d.ts.map │ │ ├── Switch.d.ts │ │ ├── Switch.d.ts.map │ │ ├── base.d.ts │ │ ├── base.d.ts.map │ │ ├── index.d.ts │ │ ├── index.d.ts.map │ │ ├── loadComponent.d.ts │ │ └── loadComponent.d.ts.map ├── vue-taro │ ├── .babelrc.js │ ├── CHANGELOG.md │ ├── README.md │ ├── api-extractor.json │ ├── dist │ │ ├── es5 │ │ │ └── index.js │ │ └── es6 │ │ │ └── index.js │ ├── global │ │ └── global.d.ts │ ├── package.json │ ├── rollup.config.js │ ├── src │ │ ├── index.tsx │ │ └── tsconfig.json │ ├── types │ │ ├── index.d.ts │ │ └── index.d.ts.map │ └── yarn.lock └── vue-web │ ├── .babelrc.js │ ├── CHANGELOG.md │ ├── README.md │ ├── api-extractor.json │ ├── dist │ ├── es5 │ │ └── index.js │ └── es6 │ │ └── index.js │ ├── package.json │ ├── rollup.config.js │ ├── server.js │ ├── server.mock.js │ ├── src │ ├── global.d.ts │ ├── index.ts │ └── tsconfig.json │ └── types │ ├── index.d.ts │ └── index.d.ts.map ├── patch-api.js ├── preBuild.js ├── rollup.build-umd.js ├── rollup.build.js ├── tsconfig.json └── yarn.lock /.editorconfig: -------------------------------------------------------------------------------- 1 | root = true 2 | 3 | [*] 4 | indent_style = space 5 | indent_size = 2 6 | charset = utf-8 7 | end_of_line = lf 8 | insert_final_newline = true 9 | trim_trailing_whitespace = true 10 | max_line_length = 150 11 | 12 | [**.bat] 13 | end_of_line = crlf 14 | -------------------------------------------------------------------------------- /.eslintignore: -------------------------------------------------------------------------------- 1 | !docs/.vuepress/ 2 | !api/.vuepress/ 3 | dist/ 4 | types/ 5 | storage/ 6 | .api/ 7 | .temp/ 8 | .cache/ 9 | *.md -------------------------------------------------------------------------------- /.eslintrc.js: -------------------------------------------------------------------------------- 1 | const tsconfig = require('./tsconfig.json'); 2 | 3 | module.exports = { 4 | root: true, 5 | extends: ['plugin:@elux/common'], 6 | env: { 7 | browser: false, 8 | node: true, 9 | }, 10 | ignorePatterns: [...tsconfig.exclude, '**/types'], 11 | }; 12 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules/ 2 | storage/ 3 | *.log 4 | .eslintcache 5 | .DS_Store 6 | .temp/ 7 | .cache/ 8 | .private/ 9 | docs/.vuepress/dist/ 10 | api/.vuepress/dist/ 11 | api/api/ 12 | tsconfig.tsbuildinfo 13 | tsdoc-metadata.json -------------------------------------------------------------------------------- /.markdownlint.json: -------------------------------------------------------------------------------- 1 | { 2 | "default": true, 3 | "MD013": false, 4 | "MD026": false 5 | } 6 | -------------------------------------------------------------------------------- /.prettierignore: -------------------------------------------------------------------------------- 1 | !docs/.vuepress/ 2 | !api/.vuepress/ 3 | dist/ 4 | types/ 5 | storage/ 6 | .api/ 7 | .temp/ 8 | .cache/ -------------------------------------------------------------------------------- /.prettierrc.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | singleQuote: true, 3 | trailingComma: "es5", 4 | bracketSpacing: false 5 | }; 6 | -------------------------------------------------------------------------------- /.vscode/extensions.json: -------------------------------------------------------------------------------- 1 | { 2 | "recommendations": ["davidanson.vscode-markdownlint", "dbaeumer.vscode-eslint", "stylelint.vscode-stylelint", "esbenp.prettier-vscode"], 3 | "unwantedRecommendations": [] 4 | } 5 | -------------------------------------------------------------------------------- /.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "search.exclude": { 3 | "docs/.vuepress/.api": true, 4 | "docs/.vuepress/.cache": true, 5 | "docs/.vuepress/.temp": true, 6 | "**/*.svg": true, 7 | "**/yarn.lock": true, 8 | "**/node_modules": true, 9 | "**/dist": true, 10 | "**/types": true, 11 | "**/storage": true, 12 | "**/.eslintcache": true 13 | }, 14 | "files.eol": "\n", 15 | "files.encoding": "utf8", 16 | "files.trimFinalNewlines": true, 17 | "files.trimTrailingWhitespace": true, 18 | "typescript.tsdk": "node_modules/typescript/lib", 19 | "typescript.updateImportsOnFileMove.enabled": "never", 20 | "editor.formatOnSave": false, 21 | "editor.codeActionsOnSave": ["source.organizeImports.sortImports", "source.fixAll"], 22 | "stylelint.validate": ["less", "scss", "vue"], 23 | "[markdown]": { 24 | "files.trimTrailingWhitespace": false 25 | }, 26 | "[json]": { 27 | "editor.defaultFormatter": "esbenp.prettier-vscode" 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2021-present yong.zhao (hiisea@qq.com) 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 |
2 | elux 3 |

eluxjs.com

4 |

基于“微模块”和“模型驱动”的跨平台、跨框架『同构方案』

5 |

6 | 支持React/Vue/Web(浏览器)/Micro(微前端)/SSR(服务器渲染)/MP(小程序)/APP(手机应用) 7 |

8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 |

21 |

22 | 掘金专栏 | 23 |

24 |

elux 25 | elux

26 |

27 | 开源不易,欢迎点赞支持 28 | 29 | 30 | 31 |

32 |
33 | -------------------------------------------------------------------------------- /api/.vuepress/.eslintrc.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | root: true, 3 | extends: ['plugin:@elux/vue'], 4 | env: { 5 | browser: true, 6 | node: true, 7 | }, 8 | }; 9 | -------------------------------------------------------------------------------- /api/.vuepress/components/NavbarBrand.vue: -------------------------------------------------------------------------------- 1 | 35 | 36 | 45 | -------------------------------------------------------------------------------- /api/.vuepress/public/images/logo-16x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hiisea/elux/abe5c4ac5915bba42473ea73ace9a0da60ec3ab9/api/.vuepress/public/images/logo-16x.png -------------------------------------------------------------------------------- /api/.vuepress/public/images/logo-32x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hiisea/elux/abe5c4ac5915bba42473ea73ace9a0da60ec3ab9/api/.vuepress/public/images/logo-32x.png -------------------------------------------------------------------------------- /api/.vuepress/styles/index.scss: -------------------------------------------------------------------------------- 1 | /* stylelint-disable font-family-no-missing-generic-family-keyword */ 2 | :root { 3 | --c-brand: #40b854; 4 | --c-brand-light: #32a745; 5 | --homepage-width: 1000px; 6 | --c-text: #555; 7 | } 8 | .navbar { 9 | .site-name { 10 | display: none; 11 | } 12 | .external-link span { 13 | display: none; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /babelrc.build.js: -------------------------------------------------------------------------------- 1 | const tag = process.env.NODE_TAG || process.env.NODE_ENV; 2 | const cfg = { 3 | es6: {module: 'esm', targets: {chrome: 70}}, 4 | es5: {module: 'esm', targets: {ie: 11}}, 5 | cjs: {module: 'cjs', targets: {ie: 11}}, 6 | test: {module: 'cjs', targets: {chrome: 70}}, 7 | }; 8 | const env = cfg[tag]; 9 | 10 | module.exports = (ui, presets = []) => { 11 | return { 12 | presets: [['@elux', {...env, decoratorsLegacy: true, ui, presets, rootImport: {rootPathPrefix: 'src/', rootPathSuffix: './src/'}}]], 13 | ignore: ['**/*.d.ts'], 14 | comments: false, 15 | }; 16 | }; 17 | -------------------------------------------------------------------------------- /commitlint.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | extends: ['@commitlint/config-conventional'], 3 | rules: {}, 4 | }; 5 | -------------------------------------------------------------------------------- /docs/.vuepress/.eslintrc.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | root: true, 3 | extends: ['plugin:@elux/vue'], 4 | env: { 5 | browser: true, 6 | node: true, 7 | }, 8 | }; 9 | -------------------------------------------------------------------------------- /docs/.vuepress/components/HomeFooter.vue: -------------------------------------------------------------------------------- 1 | 2 | 3 | 26 | -------------------------------------------------------------------------------- /docs/.vuepress/public/fonts/iconfont.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hiisea/elux/abe5c4ac5915bba42473ea73ace9a0da60ec3ab9/docs/.vuepress/public/fonts/iconfont.ttf -------------------------------------------------------------------------------- /docs/.vuepress/public/fonts/iconfont.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hiisea/elux/abe5c4ac5915bba42473ea73ace9a0da60ec3ab9/docs/.vuepress/public/fonts/iconfont.woff -------------------------------------------------------------------------------- /docs/.vuepress/public/fonts/iconfont.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hiisea/elux/abe5c4ac5915bba42473ea73ace9a0da60ec3ab9/docs/.vuepress/public/fonts/iconfont.woff2 -------------------------------------------------------------------------------- /docs/.vuepress/public/images/case/favs.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hiisea/elux/abe5c4ac5915bba42473ea73ace9a0da60ec3ab9/docs/.vuepress/public/images/case/favs.jpg -------------------------------------------------------------------------------- /docs/.vuepress/public/images/case/leave.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hiisea/elux/abe5c4ac5915bba42473ea73ace9a0da60ec3ab9/docs/.vuepress/public/images/case/leave.jpg -------------------------------------------------------------------------------- /docs/.vuepress/public/images/case/type.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hiisea/elux/abe5c4ac5915bba42473ea73ace9a0da60ec3ab9/docs/.vuepress/public/images/case/type.jpg -------------------------------------------------------------------------------- /docs/.vuepress/public/images/case/window.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hiisea/elux/abe5c4ac5915bba42473ea73ace9a0da60ec3ab9/docs/.vuepress/public/images/case/window.jpg -------------------------------------------------------------------------------- /docs/.vuepress/public/images/cli-bg.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hiisea/elux/abe5c4ac5915bba42473ea73ace9a0da60ec3ab9/docs/.vuepress/public/images/cli-bg.png -------------------------------------------------------------------------------- /docs/.vuepress/public/images/dev-tools.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hiisea/elux/abe5c4ac5915bba42473ea73ace9a0da60ec3ab9/docs/.vuepress/public/images/dev-tools.png -------------------------------------------------------------------------------- /docs/.vuepress/public/images/easy-code.svg: -------------------------------------------------------------------------------- 1 | 3 | 4 | -------------------------------------------------------------------------------- /docs/.vuepress/public/images/gaba.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hiisea/elux/abe5c4ac5915bba42473ea73ace9a0da60ec3ab9/docs/.vuepress/public/images/gaba.png -------------------------------------------------------------------------------- /docs/.vuepress/public/images/hero-photo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hiisea/elux/abe5c4ac5915bba42473ea73ace9a0da60ec3ab9/docs/.vuepress/public/images/hero-photo.png -------------------------------------------------------------------------------- /docs/.vuepress/public/images/logo-16x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hiisea/elux/abe5c4ac5915bba42473ea73ace9a0da60ec3ab9/docs/.vuepress/public/images/logo-16x.png -------------------------------------------------------------------------------- /docs/.vuepress/public/images/logo-32x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hiisea/elux/abe5c4ac5915bba42473ea73ace9a0da60ec3ab9/docs/.vuepress/public/images/logo-32x.png -------------------------------------------------------------------------------- /docs/.vuepress/public/images/logo-react.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hiisea/elux/abe5c4ac5915bba42473ea73ace9a0da60ec3ab9/docs/.vuepress/public/images/logo-react.png -------------------------------------------------------------------------------- /docs/.vuepress/public/images/logo-rn.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hiisea/elux/abe5c4ac5915bba42473ea73ace9a0da60ec3ab9/docs/.vuepress/public/images/logo-rn.png -------------------------------------------------------------------------------- /docs/.vuepress/public/images/logo-taro.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hiisea/elux/abe5c4ac5915bba42473ea73ace9a0da60ec3ab9/docs/.vuepress/public/images/logo-taro.png -------------------------------------------------------------------------------- /docs/.vuepress/public/images/logo-text.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 6 | 9 | 13 | 16 | 18 | 21 | 22 | -------------------------------------------------------------------------------- /docs/.vuepress/public/images/logo-vue.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hiisea/elux/abe5c4ac5915bba42473ea73ace9a0da60ec3ab9/docs/.vuepress/public/images/logo-vue.png -------------------------------------------------------------------------------- /docs/.vuepress/public/images/logo-vue.svg: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /docs/.vuepress/public/images/micro-module-model.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hiisea/elux/abe5c4ac5915bba42473ea73ace9a0da60ec3ab9/docs/.vuepress/public/images/micro-module-model.png -------------------------------------------------------------------------------- /docs/.vuepress/public/images/qq.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hiisea/elux/abe5c4ac5915bba42473ea73ace9a0da60ec3ab9/docs/.vuepress/public/images/qq.jpg -------------------------------------------------------------------------------- /docs/.vuepress/public/images/wechat.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hiisea/elux/abe5c4ac5915bba42473ea73ace9a0da60ec3ab9/docs/.vuepress/public/images/wechat.jpg -------------------------------------------------------------------------------- /docs/README.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: EluxJS-基于“微模块”和“模型驱动”的跨平台、跨框架『同构方案』 3 | home: true 4 | navbar: true 5 | actions: 6 | - text: 快速上手 7 | link: /guide/summary.html 8 | type: primary 9 | - text: 了解项目 10 | link: /designed/micro-module.html 11 | type: secondary 12 | --- -------------------------------------------------------------------------------- /docs/ecological/index.md: -------------------------------------------------------------------------------- 1 | # 生态建设 2 | 3 | ## 优质开源项目 4 | 5 | - 基于`Elux+Antd`的后台管理系统: 6 | - React版本:[Github](https://github.com/hiisea/elux-react-antd-admin) | [Gitee](https://gitee.com/hiisea/elux-react-antd-admin-fork) 7 | - Vue版本:[Github](https://github.com/hiisea/elux-vue-antd-admin) | [Gitee](https://gitee.com/hiisea/elux-vue-antd-admin-fork) 8 | - 在线预览: 9 | 10 | ## 相关文章 11 | 12 | - [从"微前端"到“微模块”](https://juejin.cn/post/7106791733509226533) 13 | - [不想当Window的Dialog不是一个好Modal,弹窗翻身记...](https://juejin.cn/post/7124177821953425422) 14 | - [手撸Router,还要啥Router框架?让react-router/vue-router躺一边凉快去](https://juejin.cn/post/7124959667326812196) 15 | - [一种比css_scoped和css_module更优雅的避免css命名冲突小妙招](https://juejin.cn/post/7129316859182710814) 16 | 17 | ## 学习与交流 18 | 19 | 微信/QQ群 20 | 21 | ![微信](/images/wechat.jpg) ![QQ交流群](/images/qq.jpg) 22 | -------------------------------------------------------------------------------- /docs/guide/basics/immutable.md: -------------------------------------------------------------------------------- 1 | --- 2 | next: /guide/ui-framework/react.html 3 | --- 4 | 5 | # Mutable与Immutable 6 | 7 | 数据管理本质上分为2大类:`Mutable(可变数据)`与`Immutable(不可变数据)`,Elux同时支持2种模式。 8 | 9 | ```ts 10 | import {setCoreConfig} from '@elux/core'; 11 | 12 | //设置当前数据管理模式为可变数据模式 13 | setCoreConfig({ 14 | MutableData: true, 15 | }) 16 | ``` 17 | 18 | > 为了用户使用方便和避免随意更改,已经将模式固化在各`组合包`中了,所以用户无需设置。 19 | 20 | ## Immutable(不可变数据) 21 | 22 | 不可变数据的管理框架,典型代表是Redux,它要求每次更新State要返回一个新数据,不能修改原数据。 23 | 24 | ```ts 25 | // src/modules/stage/model.ts 26 | 27 | export class Model extends BaseModel { 28 | @reducer 29 | protected putCurUser(curUser: CurUser): ModuleState { 30 | return {...this.state, curUser}; 31 | } 32 | } 33 | ``` 34 | 35 | ## Mutable(可变数据) 36 | 37 | 可变数据的管理框架,典型代表有Vuex/Mobx,每次更新State的时候可以直接修改原数据。 38 | 39 | ```ts 40 | // src/modules/stage/model.ts 41 | 42 | export class Model extends BaseModel { 43 | @reducer 44 | protected putCurUser(curUser: CurUser): ModuleState { 45 | this.state.curUser = curUser; 46 | } 47 | } 48 | ``` 49 | 50 | ## 数据模式与UI框架 51 | 52 | 从职能上来说,应当有数据管理框架、数据模式框架、UI渲染框架三者之分。 53 | 54 | > 其中Immutable不可变数据模式比较简单,所以不需要专门的数据模式框架 55 | 56 | - React属于`UI渲染框架` 57 | - Vue包含了`数据模式框架`+`UI渲染框架` 58 | - Mobx包含了`数据模式框架`+`数据管理框架` 59 | - Vuex、Redux仅属于`数据管理框架` 60 | 61 | Elux内置了`数据管理框架`,未包含`数据模式框架`和`UI渲染框架`,所以Elux需要配合其它框架使用: 62 | 63 | - Elux使用`Immutable`模式的可选的组合有: 64 | - Elux+React 65 | - Elux使用`Mutable`模式的可选的组合有: 66 | - Elux+Vue 67 | - Elux+Mobx+React 68 | 69 | ## Elux中的组合包 70 | 71 | Elux中根据用户习惯,封装了几种常用的组合包: 72 | 73 | - React组合包,默认使用Immutable模式 74 | - Vue组合包,默认使用Mutable模式 75 | 76 | ::: tip 未提供React+Mobx(ReactMutable模式)组合包 77 | 78 | Elux中接入Mobx并不难,但所谓React+Mobx是更复杂的Vue。加上现在Vue3已经成熟,使用JSX写Vue3与React很像了,`JSX+Vue3`相比`React+Mobx`是更佳的Mutable方案。 79 | 80 | ::: 81 | -------------------------------------------------------------------------------- /docs/guide/basics/store.md: -------------------------------------------------------------------------------- 1 | # Store 2 | 3 | Elux中Store的概念与Redux和Vuex基本相同,特别之处在于: 4 | 5 | - 每次路由变化都会生成一个新的Store,等待Model的挂载,参见[Router](/guide/basics/router.html) 6 | - 不是单例,所以不要全局保存和引用Store,而要使用useStore() 7 | - Store保存在Router历史栈中,Router和Store是一对多的关系 8 | - Model挂载在Store下面,Store和Model也是一对多的关系 9 | 10 | ![store与router](/images/router-store.svg) 11 | 12 | ## Store的定义 13 | 14 | ```ts 15 | export interface IStore { 16 | sid: number; 17 | active: boolean; //当前是否是时激活状态 18 | //Store挂载在Router下面,和Router是多对一的关系 19 | router: IRouter; 20 | dispatch: Dispatch; //派发Action 21 | getState(): StoreState; //获取已提交的状态 22 | getUncommittedState(): StoreState; //获取未提交的状态 23 | //在该Store中挂载指定的Model 24 | mount(moduleName: string, env: 'init' | 'route' | 'update'): void | Promise; 25 | destroy(): void; //销毁,框架会自动调用 26 | } 27 | ``` 28 | 29 | ## 创建Store 30 | 31 | Store无需手动创建,每一次路由发生变化都会创建一个新的Store,并触发执行根模块的`onMount('route')`方法。在此方法中必需完成自己`ModuleState`的初始赋值值,同时在此方法中又可以await子模块mount(非必需),因此可以形成一条mount链。 32 | 33 | ## 使用Store 34 | 35 | - 在Model中获取Store:直接使用`this.store` 36 | - 在View中获取Store:使用`useStore()` 37 | 38 | ```ts 39 | import {Modules, useStore} from '@/Global'; 40 | 41 | const Component = (props) => { 42 | const store = useStore(); 43 | const onClick = () => { 44 | store.dispatch(Modules.stage.actions.logout()); 45 | }; 46 | return
logout
; 47 | }; 48 | ``` 49 | 50 | ## Store的冻结与销毁 51 | 52 | 1. 每次路由变化都会生成一个全新的Store,而原来的Store将被`冻结`变成历史快照。 53 | 2. 如果路由变化是`push window`,即在[WindowHistoryStack](/guide/basics/router.html)产生一条新的历史记录,那么原Store将保存在此历史记录中,并随着该历史记录的回退而重新`激活`,随着历史记录的出栈而`销毁`。 54 | 3. 否则原Store将直接被`销毁`。 55 | 56 | ### 触发的钩子 57 | 58 | - Store被激活时,将触发所有挂载Model的`onActive()`钩子,可以在此钩子中执行一些副作用,比如定时器轮询获取最新消息。 59 | - Store被冻结时,将触发所有挂载Model的`onInactive()`钩子,可以在此钩子中清理并释放`onActive()`钩子中的副作用,比如定时器。 60 | 61 | ## State的清理与擦除 62 | 63 | 在Redux或者Vuex中,Store一直缺少一种清理与擦除机制。由于Store是单例,所以保存在Store中的State会不断增加累积(除非自己写代码去清空某些过时的数据) 64 | 65 | 而在Elux中这将得到解决,每次路由变化都将产生一个新的`空Store`,它就像是一张白纸,然后重新挑选有用的数据进行挂载。再也不用担心State越积越多... 66 | 67 | ## DevTools 68 | 69 | Elux兼容Redux的`devTools`,并改进了它的显示信息,参见[/guide/dev-tools](/guide/dev-tools) 70 | -------------------------------------------------------------------------------- /docs/guide/concepts.md: -------------------------------------------------------------------------------- 1 | 2 | # Elux基本概念 3 | 4 | **微模块**和**模型驱动**是Elux项目的二大基石。 5 | 6 | 微模块-模型驱动 7 | 8 | ## 应用由微模块组成 9 | 10 | 我们知道在后端领域,通常都是从`业务功能`来划分模块:用户模块、订单模块、评论模块...\ 11 | 而在前端领域,从一开始就是以`UI界面的区块`来划分模块,首页、推荐Top10、新闻列表...\ 12 | 现在Elux提出的“**微模块**”就是要统一前后端开发视角,将`业务功能模块化`带入前端: 13 | 14 | - 应用由一个个业务**微模块**组成,微模块之间是平等、松散、可组合的。 15 | - 微模块应当`高内聚低耦合`,强调**自治**,可以独立开发、维护、部署。 16 | 17 | ::: tip 微模块是一种集合,也是一个文件夹 18 | 19 | - 划分视角: `业务功能`(非UI区域) 20 | - 划分原则: `高内聚、低耦合`(模块之间应当松散,相关资源应当集中) 21 | 22 | ::: 23 | 24 | ## 微模块由Model和View组成 25 | 26 | - **model**:用来处理业务逻辑,维护ModuleState(模块状态) 27 | - ModuleState:用来描述微模块的当前状态。 28 | - ActionHandler:用来监听Action,并执行Handler: 29 | - reducer:纯函数,用来修改ModuleState(类似vuex mutation) 30 | - effect:用来执行副作用及异步逻辑(类似vuex action) 31 | - **view**:用来展示数据与交互 32 | - Component:普通UI组件 33 | - View:包含具体业务的UI组件 34 | 35 | ::: tip 包含业务逻辑的Component称为View 36 | 37 | - View用来表达业务逻辑,Component用来表达交互逻辑。 38 | - View可以直接从Store中获取数据,Component不要直接从Store中获取数据。 39 | 40 | ::: 41 | 42 | ![elux静态结构图](/images/static-structure.svg) 43 | -------------------------------------------------------------------------------- /docs/guide/css.md: -------------------------------------------------------------------------------- 1 | --- 2 | prev: /guide/ui-framework/vue.html 3 | --- 4 | 5 | # CSS框架 6 | 7 | ## CSS预处理框架 8 | 9 | 脚手架内置了对`less`和`sass`的支持,只需配置`elux.config.js`即可。 10 | 11 | 设置为tue,即可开启,并使用默认配置: 12 | 13 | ```js 14 | // elux.config.js 15 | module.exports = { 16 | cssProcessors: {less: true, sass: true}, 17 | } 18 | ``` 19 | 20 | 设置为options,即可开启,并使用自定义配置: 21 | 22 | ```js 23 | // elux.config.js 24 | module.exports = { 25 | cssProcessors: {less: lessOptions, sass: sassOptions}, 26 | } 27 | ``` 28 | 29 | 更多项目配置查看:[配置](/guide/configure.md) 30 | 31 | ## CSS Module 32 | 33 | 项目中CSS文件名以`.module.xxx`结尾,将自动启用CSS Module解析,如`global.module.less`。 34 | 35 | 可以在`elux.config.js`中修改CSS Module设置: 36 | 37 | ```js 38 | // elux.config.js 39 | module.exports = { 40 | cssModulesOptions: { 41 | getLocalIdent: undefined 42 | }, 43 | } 44 | ``` 45 | 46 | ## 相关文章 47 | 48 | - [一种比css_scoped和css_module更优雅的避免css命名冲突小妙招](https://juejin.cn/post/7129316859182710814) 49 | -------------------------------------------------------------------------------- /docs/guide/demote.md: -------------------------------------------------------------------------------- 1 | --- 2 | prev: /guide/platform/taro.html 3 | --- 4 | 5 | # 兼容IE 6 | 7 | Elux 最低可以兼容到 IE10,但需要特别处理: 8 | 9 | ## 需要UI框架本身支持 10 | 11 | 例如 Vue3/React18 本身不支持IE 12 | 13 | ## 需要Polyfill 14 | 15 | 可以使用一些网站提供的ES6 Polyfill在线生成服务,也可以使用elux命令工具自己制作: 16 | 17 | 1. 将以下内容保存为`./public/polyfill.esm.js` 18 | 19 | ```js 20 | //Elux需要 21 | import 'core-js/features/string/starts-with'; 22 | import 'core-js/features/string/ends-with'; 23 | import 'core-js/features/string/trim'; 24 | import 'core-js/features/array/find'; 25 | import 'core-js/features/array/find-index'; 26 | import 'core-js/features/object/assign'; 27 | import 'core-js/features/symbol'; 28 | import 'core-js/features/promise'; 29 | 30 | //React需要 31 | import 'core-js/features/set'; 32 | import 'core-js/features/map'; 33 | ``` 34 | 35 | 2. 在`./package.json`中加入scripts 36 | 37 | ```json 38 | { 39 | "scripts": { 40 | "polyfill": "elux webpack-pack -m ./public/polyfill.esm.js ./public/client/polyfill.js", 41 | } 42 | } 43 | ``` 44 | 45 | 3. 打开终端,运行`yarn polyfill`,得到`./public/client/polyfill.js` 46 | 4. 将`polyfill.js`引入`./public/client/index.html` 47 | 48 | ## 需要替代ES6 Proxy 49 | 50 | 由于 ES6 的`Proxy`是无法使用 polyfill 的,而Elux中的`dispatch action`又使用了`Proxy`,所以需要替换它们: 51 | 52 | 1. 在项目中安装NPM包`@elux/cli-demote` 53 | 2. 在`./package.json`中加入scripts 54 | 55 | ```json 56 | { 57 | "scripts": { 58 | "demote": "elux demote", 59 | } 60 | } 61 | ``` 62 | 63 | 3. 打开终端,运行`yarn demote`,该命令会自动修改`./src/Global.ts`以替换`Proxy` 64 | 65 | ## 需要设置编译目标 66 | 67 | 在`./package.json`中设置`browserslist` 68 | 69 | ```json 70 | { 71 | "browserslist": [ 72 | "ie >= 10" 73 | ], 74 | } 75 | ``` 76 | 77 | ## 需要使用Elux的es5版本 78 | 79 | 默认使用的是Elux的es6版本,要使用es5版本,可以使用webpack别名: 80 | 修改`./elux.config.js` 81 | 82 | ```js 83 | // ./elux.config.js 84 | 85 | module.exports = { 86 | prod: { 87 | resolveAlias: { 88 | '@elux/react-web': '@elux/react-web/dist/es5/pkg.js' 89 | } 90 | } 91 | } 92 | ``` 93 | -------------------------------------------------------------------------------- /docs/guide/dev-tools.md: -------------------------------------------------------------------------------- 1 | # DevTools 2 | 3 | ## UI框架 4 | 5 | Elux并没有魔改各UI框架,所以各UI框架原来的开发习惯和DevTools仍然可以正常使用: 6 | 7 | - [React DevTools](https://chrome.google.com/webstore/detail/react-developer-tools/fmkadmapgofadopljbjfkapdkoienihi) 8 | - [Vue DevTools](https://chrome.google.com/webstore/detail/vuejs-devtools/nhdogjmejiglipccpnnnanhbledajbpd) 9 | 10 | ## 状态管理 11 | 12 | Elux内置的状态管理与Redux类似,所以可以使用: 13 | 14 | - [Redux DevTools](https://chrome.google.com/webstore/detail/redux-devtools/lmhkpmbekcpmknklioeibfkpmmfibljd) 15 | 16 | ![elux dev-tools](/images/dev-tools.png) 17 | 18 | 由于Elux中增加了一些新概念,所以它的显示信息与Redux有所不同: 19 | 20 | - 左边区域每一条记录表示发生了一次State的修改: 21 | - 第一个数字表示该Store的ID。 22 | - *表示该Store已经Inactive,变成了历史快照。 23 | - 最后的(数字)表示,有多少个ActionHander在监听它(包括reducer+effect)。 24 | - 右边区别对应相关数据,其中第一项为Action: 25 | - priority:ActionHandler的优先级 26 | - hanndlers:哪些模块监听了该Action 27 | - effects:引起这条修改的effect记录 28 | -------------------------------------------------------------------------------- /docs/guide/install.md: -------------------------------------------------------------------------------- 1 | # 安装Elux 2 | 3 | Elux 项目基于 node,推荐使用较新的 node 环境(**>=14.0.0**) 4 | 5 | ## 采用Cli工程模版向导创建 6 | 7 | ```bash 8 | npm create elux@latest 9 | ``` 10 | 11 | 或者 12 | 13 | ```bash 14 | yarn create elux 15 | ``` 16 | 17 | 官方默认提供一个`简单增删改查`的工程模版(包括`H5页面`风格和`Admin后台管理系统`风格),里面写了**大量注释**,建议边看示例,边看文档,快速上手... 18 | 19 | ```bash 20 | ? 请选择平台架构 CSR: 基于浏览器渲染的应用 [16P] 21 | ? 请选择UI框架 React [8P] 22 | ? 请选择CSS预处理器 Less [4P] 23 | ? 请选择模板 (Use arrow keys) 24 | ❯ Admin-react(路由前置) 25 | H5-react(路由前置) 26 | Admin-react(路由后置) 27 | H5-react(路由后置) . 28 | ``` 29 | 30 | ## 或直接找到Git地址Clone 31 | 32 | 例如基于`Elux+Antd`的后台管理系统: 33 | 34 | - React版本:[Github](https://github.com/hiisea/elux-react-antd-admin) | [Gitee](https://gitee.com/hiisea/elux-react-antd-admin-fork) 35 | - Vue版本:[Github](https://github.com/hiisea/elux-vue-antd-admin) | [Gitee](https://gitee.com/hiisea/elux-vue-antd-admin-fork) 36 | 37 | ::: tip 通常直接git clone的文件更新 38 | 39 | Cli工程模版制作可能稍滞后于Git项目本身,另外对于优质的第三方项目,可以申请加入Cli工程模版,欢迎参与社区建设。 40 | 41 | ::: 42 | 43 | ## 安装依赖注意事项 44 | 45 | - 国内推荐使用Gitee源,Github源在国内不是很稳定,可能需要翻墙。 46 | - 由于模版中使用了`npm-workspace`,推荐使用yarn安装依赖,如果使用npm,请保证版本>=7 47 | - 模版默认会拉取`lock文件`,这样会锁定各依赖版本,如果你比较激进,可以不使用它们。 48 | 49 | ## 关于Taro项目 50 | 51 | 模版中的Taro项目基于`Taro特定版本`制作,开箱即用,但可能版本滞后。如果想使用官方**最新版本**,也可以自己在Taro项目中安装Elux,参见[Taro小程序 52 | ](/guide/platform/taro.html#手动安装elux) 53 | 54 | ## 可以使用自己的脚手架吗? 55 | 56 | 当然可以,工程模版中的Taro项目,就是用的Taro官方的脚手架。 57 | 58 | - 选择一个`elux组合包`,当作普通npm依赖安装: 59 | 60 | ```bash 61 | yarn add @elux/react-web 62 | ``` 63 | 64 | 根据平台和UI框架不同,目前推出5种组合包,它们基本保持一致的API: 65 | 66 | - [@elux/react-web](/api/react-web.html) 67 | - [@elux/react-taro](/api/react-taro.html) 68 | - [@elux/vue-web](/api/vue-web.html) 69 | - [@elux/vue-taro](/api/vue-taro.html) 70 | - @elux/react-rn //开发中... 71 | 72 | - 注意支持`ES6装饰器`,例如Babel配置: 73 | 74 | ```js 75 | ['@babel/plugin-proposal-decorators', {legacy: false, decoratorsBeforeExport: true}], 76 | ['@babel/plugin-proposal-class-properties', {loose}], 77 | ``` 78 | -------------------------------------------------------------------------------- /docs/guide/summary.md: -------------------------------------------------------------------------------- 1 | --- 2 | prev: /designed/route-history.html 3 | --- 4 | 5 | # Elux介绍 6 | 7 | ::: tip Learn Once, Write Anywhere... 8 | 9 | 基于“微模块”和“模型驱动”的跨平台、跨框架『同构方案』 10 | 11 | ::: 12 | 13 | ## 一个问题 14 | 15 | - **Q:** 多大级别的应用可以使用Elux?我就一个小工程需要使用“微模块+模型驱动”吗? 16 | - **A:** 微模块是一种业务模块化方案,模型驱动是一种逻辑分层方案,与应用规模大小无关,它们让你的工程更有条理,并不增加额外维护成本。至于是否使用NPM管理微模块、是否使用Module Federation来实现“微前端”,这才需要根据应用级别考虑。 17 | 18 | ## 二大基石 19 | 20 | - 微模块 21 | - 模型驱动 22 | 23 | ## 三大面向 24 | 25 | - 面向“高内聚、低耦合” 26 | - 面向“分层而治” 27 | - 面向“业务模块化” 28 | 29 | ## 四大创新 30 | 31 | - 微模块 32 | - 模型驱动 33 | - 同时支持Mutable与Immutable的状态管理框架 34 | - 同时支持Web/SSR/小程序/APP的双栈单链虚拟路由 35 | 36 | ## 六大应用场景 37 | 38 | - CSR: 基于浏览器渲染的`Web单页`应用 39 | - SSR: 基于服务器渲染+浏览器渲染的`同构`应用 40 | - Micro: 基于ModuleFederation的`微前端`方案 41 | - Model: 跨UI框架、跨项目`共用一套业务逻辑`的共享方案 42 | - Taro: 基于Taro的跨平台应用(各类`小程序`) 43 | - RN: 基于ReactNative的`原生APP` 44 | 45 | ## 十分简单 46 | 47 | - 使用既有技术栈,不发明轮子,不修改轮子。 48 | - 微框架,压缩后约几十K,小巧迷你。 49 | - 顶级API也就30来个。 50 | - 提供开箱即用的脚手架,以及多套模版。 51 | 52 | ## 典型案例 53 | 54 | 简单`增删改查`的H5页面(SSR服务器渲染): 55 | 56 | - 在线预览:[http://h5-ssr.eluxjs.com](http://h5-ssr.eluxjs.com) 57 | 58 | 基于`Elux+Antd`的后台管理系统: 59 | 60 | - 在线预览:[http://admin-react-antd.eluxjs.com/](http://admin-react-antd.eluxjs.com/) 61 | - React版本:[Github](https://github.com/hiisea/elux-react-antd-admin) | [Gitee](https://gitee.com/hiisea/elux-react-antd-admin-fork) 62 | - Vue版本:[Github](https://github.com/hiisea/elux-vue-antd-admin) | [Gitee](https://gitee.com/hiisea/elux-vue-antd-admin-fork) 63 | -------------------------------------------------------------------------------- /docs/guide/ui-framework/react.md: -------------------------------------------------------------------------------- 1 | --- 2 | prev: /guide/basics/immutable.html 3 | --- 4 | 5 | # React 6 | 7 | 在Elux项目中使用React,默认使用`Immutable`数据模式,即`reducer`中修改`moduleState`时,不能直接修改原对象,必需返回一个新对象(与Redux类似)。 8 | 9 | ## 使用React 10 | 11 | ```ts 12 | // src/modules/article/views/Main.tsx 13 | import {connectStore} from '@elux/react-web'; 14 | import {APPState, useStore, useRouter} from '@/Global'; 15 | 16 | export interface StoreProps { 17 | currentView?: CurrentView; 18 | itemDetail?: ItemDetail; 19 | } 20 | 21 | function mapStateToProps(appState: APPState): StoreProps { 22 | const {currentView, itemDetail} = appState.article!; 23 | return {currentView, itemDetail}; 24 | } 25 | 26 | const Component: FC = ({currentView, itemDetail}) => { 27 | //获取Store和Router,可以使用`useStore()`和`useRouter()` 28 | const store = useStore(); 29 | const router = useRouter(); 30 | ... 31 | } 32 | 33 | export default connectStore(mapStateToProps)(Component); 34 | ``` 35 | 36 | ## 内置组件 37 | 38 | 框架中内置了4个常用的React组件,参见[内置组件](/guide/basics/view.html#内置组件) 39 | 40 | ## 暂未支持V18中的Suspense 41 | 42 | react 18中的新Suspense方案很好的解决了SSR时数据集中加载的问题,值得借鉴和使用。但Vue中尚无类似解决方案,这也极大增加了对于UI特殊功能的依赖,所以暂未支持。 43 | -------------------------------------------------------------------------------- /docs/guide/ui-framework/vue.md: -------------------------------------------------------------------------------- 1 | --- 2 | next: /guide/css.html 3 | --- 4 | 5 | # VUE 6 | 7 | 在Elux项目中使用Vue,默认使用`Mutable`数据模式,与Vuex类似: 8 | 9 | - `reducer`类似vuex中的`mutation`,可以直接修改`moduleState` 10 | - `effect`类似vuex中的`action` 11 | 12 | > Devtools请使用`redux-devtools` 13 | 14 | ## 使用Vue 15 | 16 | Elux没有挂载任何全局变量,获取Store请使用`useStore()`,获取State可使用`connectStore()` 17 | 18 | ```ts 19 | // src/modules/article/views/Main.tsx 20 | import {connectStore} from '@elux/vue-web'; 21 | import {APPState, useStore, useRouter} from '@/Global'; 22 | import {defineComponent} from 'vue'; 23 | 24 | export interface StoreProps { 25 | currentView?: CurrentView; 26 | itemDetail?: ItemDetail; 27 | } 28 | 29 | //这里保持和Redux的风格一致,也可以直接使用computed 30 | function mapStateToProps(appState: APPState): StoreProps { 31 | const {currentView, itemDetail} = appState.article!; 32 | return {currentView, itemDetail}; 33 | } 34 | 35 | const Component = defineComponent({ 36 | name: 'ArticleMain', 37 | setup() { 38 | //获取Store和Router,可以使用`useStore()`和`useRouter()` 39 | const router = useRouter(); 40 | const store = useStore(); 41 | //获取state可以使用`connectStore` 42 | const storeProps = connectStore(mapStateToProps); 43 | 44 | return () => { 45 | const {currentView, itemDetail} = storeProps; 46 | ... 47 | }; 48 | }, 49 | }); 50 | 51 | export default exportView(Component); 52 | ``` 53 | 54 | ## 内置组件 55 | 56 | 框架中内置了4个常用的React组件,参见[内置组件](/guide/basics/view.html#内置组件) 57 | -------------------------------------------------------------------------------- /lerna.json: -------------------------------------------------------------------------------- 1 | { 2 | "npmClient": "yarn", 3 | "useWorkspaces": true, 4 | "version": "2.6.3", 5 | "command": { 6 | "publish": { 7 | "registry": "https://registry.npmjs.org/", 8 | "message": "chore(release): publish %s" 9 | }, 10 | "version": { 11 | "conventionalCommits": true, 12 | "createRelease": "github" 13 | } 14 | }, 15 | "ignoreChanges": ["**/test/**", "**/*.md"] 16 | } 17 | -------------------------------------------------------------------------------- /packages/app/.babelrc.js: -------------------------------------------------------------------------------- 1 | const build = require('../../babelrc.build'); 2 | const config = build(); 3 | module.exports = config; 4 | 5 | -------------------------------------------------------------------------------- /packages/app/README.md: -------------------------------------------------------------------------------- 1 | # Cross platform and cross framework web solutions that based on micro-module and model-driven 2 | 3 | ## [Read Documentation ON Github](https://github.com/hiisea/elux) 4 | -------------------------------------------------------------------------------- /packages/app/dist/es5/index.js: -------------------------------------------------------------------------------- 1 | import { getModuleApiMap, setCoreConfig } from '@elux/core'; 2 | export { BaseModel, deepMerge, effect, effectLogger, EmptyModel, env, errorAction, ErrorCodes, exportComponent, exportModule, exportView, getApi, getTplInSSR, injectModule, isServer, isMutable, locationToNativeLocation, locationToUrl, modelHotReplacement, moduleExists, nativeLocationToLocation, nativeUrlToUrl, reducer, setLoading, urlToLocation, urlToNativeUrl } from '@elux/core'; 3 | var appConfig = Symbol(); 4 | export function setConfig(conf) { 5 | setCoreConfig(conf); 6 | 7 | if (conf.DisableNativeRouter) { 8 | setCoreConfig({ 9 | NotifyNativeRouter: { 10 | window: false, 11 | page: false 12 | } 13 | }); 14 | } 15 | 16 | return appConfig; 17 | } 18 | export function patchActions(typeName, json) { 19 | if (json) { 20 | getModuleApiMap(JSON.parse(json)); 21 | } 22 | } -------------------------------------------------------------------------------- /packages/app/dist/es6/index.js: -------------------------------------------------------------------------------- 1 | import { getModuleApiMap, setCoreConfig } from '@elux/core'; 2 | export { BaseModel, deepMerge, effect, effectLogger, EmptyModel, env, errorAction, ErrorCodes, exportComponent, exportModule, exportView, getApi, getTplInSSR, injectModule, isServer, isMutable, locationToNativeLocation, locationToUrl, modelHotReplacement, moduleExists, nativeLocationToLocation, nativeUrlToUrl, reducer, setLoading, urlToLocation, urlToNativeUrl } from '@elux/core'; 3 | const appConfig = Symbol(); 4 | export function setConfig(conf) { 5 | setCoreConfig(conf); 6 | 7 | if (conf.DisableNativeRouter) { 8 | setCoreConfig({ 9 | NotifyNativeRouter: { 10 | window: false, 11 | page: false 12 | } 13 | }); 14 | } 15 | 16 | return appConfig; 17 | } 18 | export function patchActions(typeName, json) { 19 | if (json) { 20 | getModuleApiMap(JSON.parse(json)); 21 | } 22 | } -------------------------------------------------------------------------------- /packages/app/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@elux/app", 3 | "version": "2.6.3", 4 | "description": "", 5 | "repository": "https://github.com/hiisea/elux/tree/master/packages/app", 6 | "author": "hiisea ", 7 | "license": "MIT", 8 | "publishConfig": { 9 | "access": "public" 10 | }, 11 | "engines": { 12 | "node": ">=14.0.0" 13 | }, 14 | "main": "dist/es5/index.js", 15 | "module": "dist/es6/index.js", 16 | "types": "types/", 17 | "files": [ 18 | "types/", 19 | "dist/" 20 | ], 21 | "scripts": { 22 | "eslint": "cross-env NODE_ENV=production eslint --fix --cache \"**/*.{js,ts}\"", 23 | "build:types": "rimraf ./types && tsc --build ./src", 24 | "build:es6": "cross-env NODE_TAG=es6 babel ./src --out-dir ./dist/es6 --extensions \".ts\"", 25 | "build:es5": "cross-env NODE_TAG=es5 babel ./src --out-dir ./dist/es5 --extensions \".ts\"", 26 | "build": "yarn build:types && rimraf ./dist && yarn build:es6 && yarn build:es5" 27 | }, 28 | "dependencies": { 29 | "@elux/core": "^2.6.3" 30 | }, 31 | "gitHead": "db6eb1314ef3e6abf5b7014495f441911c4cdd28" 32 | } 33 | -------------------------------------------------------------------------------- /packages/app/src/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "@elux/babel-preset/tsconfig.esm.json", 3 | "compilerOptions": { 4 | "rootDir": "./", 5 | "declarationDir": "../types", 6 | "emitDeclarationOnly": true, 7 | "removeComments": false, 8 | "declarationMap": true 9 | }, 10 | "include": ["./"], 11 | "exclude": [] 12 | } 13 | -------------------------------------------------------------------------------- /packages/app/types/index.d.ts.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkB,YAAY,EAAiB,WAAW,EAAE,eAAe,EAAC,MAAM,YAAY,CAAC;AAEtG,OAAO,EACL,SAAS,EACT,SAAS,EACT,MAAM,EACN,YAAY,EACZ,UAAU,EACV,GAAG,EACH,WAAW,EACX,UAAU,EACV,eAAe,EACf,YAAY,EACZ,UAAU,EACV,MAAM,EACN,WAAW,EACX,YAAY,EACZ,QAAQ,EACR,SAAS,EACT,wBAAwB,EACxB,aAAa,EACb,mBAAmB,EACnB,YAAY,EACZ,wBAAwB,EACxB,cAAc,EACd,OAAO,EACP,UAAU,EACV,aAAa,EACb,cAAc,GACf,MAAM,YAAY,CAAC;AAEpB,YAAY,EACV,MAAM,EACN,aAAa,EACb,WAAW,EACX,GAAG,EACH,kBAAkB,EAClB,WAAW,EACX,gBAAgB,EAChB,YAAY,EACZ,QAAQ,EACR,aAAa,EACb,MAAM,EACN,mBAAmB,EACnB,gBAAgB,EAChB,QAAQ,EACR,eAAe,EACf,aAAa,EACb,QAAQ,EACR,cAAc,EACd,OAAO,EACP,YAAY,EACZ,MAAM,EACN,YAAY,EACZ,QAAQ,EACR,eAAe,EACf,YAAY,EACZ,YAAY,EACZ,WAAW,EACX,gBAAgB,EAChB,eAAe,EACf,aAAa,EACb,gBAAgB,EAChB,WAAW,EACX,UAAU,EACV,iBAAiB,EACjB,YAAY,EACZ,WAAW,EACX,WAAW,EACX,eAAe,EACf,eAAe,EACf,UAAU,EACV,UAAU,EACV,MAAM,GACP,MAAM,YAAY,CAAC;AAEpB;;;;;;;GAOG;AACH,MAAM,WAAW,UAAU;IACzB;;OAEG;IACH,YAAY,EAAE,YAAY,CAAC;IAC3B;;OAEG;IACH,WAAW,EAAE;QACX,KAAK,CAAC,GAAG,EAAE,MAAM,GAAG;YAAC,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;SAAC,CAAC;QACzC,SAAS,CAAC,KAAK,EAAE;YAAC,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;SAAC,GAAG,MAAM,CAAC;KAChD,CAAC;IACF;;OAEG;IACH,qBAAqB,CAAC,EAAE;QACtB,EAAE,CAAC,cAAc,EAAE,MAAM,GAAG,MAAM,CAAC;QACnC,GAAG,CAAC,gBAAgB,EAAE,MAAM,GAAG,MAAM,CAAC;KACvC,CAAC;IACF;;;;;;;;;OASG;IACH,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B;;;;;;;OAOG;IACH,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB;;;;;;;OAOG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB;;;;;;;;;;OAUG;IACH,oBAAoB,CAAC,EAAE,IAAI,CAAC,SAAS,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAC,CAAC,CAAC;IACzD;;;;;;;;;OASG;IACH,sBAAsB,CAAC,EAAE,IAAI,CAAC,SAAS,CAAC,EAAE,CAAC,CAAC;IAC5C;;OAEG;IACH,gBAAgB,CAAC,EAAE,eAAe,EAAE,CAAC;IACrC;;OAEG;IACH,WAAW,CAAC,EAAE,WAAW,CAAC;IAC1B;;;;;;;;;;OAUG;IACH,mBAAmB,CAAC,EAAE,OAAO,CAAC;CAC/B;AAED,QAAA,MAAM,SAAS,eAAW,CAAC;AAE3B,eAAe;AACf,oBAAY,SAAS,GAAG,OAAO,SAAS,CAAC;AAEzC;;;;;;;;;;GAUG;AACH,wBAAgB,SAAS,CAAC,IAAI,EAAE,UAAU,GAAG,SAAS,CAMrD;AAED;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,GAAG,IAAI,CAIlE"} -------------------------------------------------------------------------------- /packages/core/.babelrc.js: -------------------------------------------------------------------------------- 1 | const build = require('../../babelrc.build'); 2 | const config = build(); 3 | module.exports = config; 4 | 5 | -------------------------------------------------------------------------------- /packages/core/LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2021 hiisea 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /packages/core/README.md: -------------------------------------------------------------------------------- 1 | # Cross platform and cross framework web solutions that based on micro-module and model-driven 2 | 3 | ## [Read Documentation ON Github](https://github.com/hiisea/elux) 4 | -------------------------------------------------------------------------------- /packages/core/global/global.d.ts: -------------------------------------------------------------------------------- 1 | declare function setTimeout(callback: () => void, time: number): number; 2 | declare function clearTimeout(timer: number): void; 3 | declare const console: { 4 | log(msg: string): void; 5 | warn(msg: string): void; 6 | error(error: any): void; 7 | }; 8 | -------------------------------------------------------------------------------- /packages/core/jest.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | roots: ['/tests/'], 3 | moduleFileExtensions: ['ts', 'js', 'json'], 4 | testRegex: '\\.test\\.ts$', 5 | setupFiles: ['/tests/setup.ts'], 6 | testURL: 'http://localhost/', 7 | }; 8 | -------------------------------------------------------------------------------- /packages/core/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@elux/core", 3 | "version": "2.6.3", 4 | "description": "Cross platform and cross framework web solutions that based on micro-module and model-driven.", 5 | "homepage": "https://github.com/hiisea/elux/tree/master/packages/core", 6 | "author": "hiisea ", 7 | "license": "MIT", 8 | "keywords": [ 9 | "react", 10 | "vue", 11 | "redux", 12 | "vuex", 13 | "typescript", 14 | "state container", 15 | "state management" 16 | ], 17 | "publishConfig": { 18 | "access": "public" 19 | }, 20 | "engines": { 21 | "node": ">=14.0.0" 22 | }, 23 | "main": "dist/es5/index.js", 24 | "module": "dist/es6/index.js", 25 | "types": "types/", 26 | "files": [ 27 | "runtime/", 28 | "types/", 29 | "dist/" 30 | ], 31 | "scripts": { 32 | "test": "jest", 33 | "eslint": "cross-env NODE_ENV=production eslint --fix --cache **/*.{js,ts}", 34 | "build:types": "rimraf ./types && tsc --build ./src", 35 | "build:es6": "cross-env NODE_TAG=es6 babel ./src --out-dir ./dist/es6 --extensions \".ts\"", 36 | "build:es5": "cross-env NODE_TAG=es5 babel ./src --out-dir ./dist/es5 --extensions \".ts\"", 37 | "package:es6": "cross-env NODE_TAG=es6 rollup -c", 38 | "package:es5": "cross-env NODE_TAG=es5 rollup -c", 39 | "build": "yarn build:types && rimraf ./dist && yarn package:es6 && yarn package:es5" 40 | }, 41 | "gitHead": "db6eb1314ef3e6abf5b7014495f441911c4cdd28" 42 | } 43 | -------------------------------------------------------------------------------- /packages/core/rollup.config.js: -------------------------------------------------------------------------------- 1 | import build from '../../rollup.build'; 2 | const config = build(__dirname); 3 | export default config; 4 | -------------------------------------------------------------------------------- /packages/core/runtime/runtime.d.ts: -------------------------------------------------------------------------------- 1 | declare namespace Elux { 2 | interface ENV { 3 | setTimeout: typeof setTimeout; 4 | clearTimeout: typeof clearTimeout; 5 | console: typeof console; 6 | isServer: boolean; 7 | encodeBas64(str: string): string; 8 | decodeBas64(str: string): string; 9 | addEventListener(type: 'popstate', callback: (e: any) => void, options: boolean); 10 | removeEventListener(type: 'popstate', callback: (e: any) => void, options: boolean); 11 | document?: { 12 | title: string; 13 | getElementById(id: string): any; 14 | }; 15 | location?: { 16 | pathname: string; 17 | search: string; 18 | hash: string; 19 | }; 20 | history?: { 21 | go(n: number): void; 22 | pushState(data: any, title: string, url: string): void; 23 | replaceState(data: any, title: string, url: string): void; 24 | }; 25 | __REDUX_DEVTOOLS_EXTENSION__?: { 26 | connect: (options?: any) => { 27 | init(state: any): void; 28 | subscribe(action: any): void; 29 | send(action: {type: string; payload: any[]}, state: any): void; 30 | }; 31 | }; 32 | __VUE_DEVTOOLS_GLOBAL_HOOK__?: any; 33 | __taroAppConfig: { 34 | tabBar: {list: {pagePath: string}[]; items: {pagePath: string}[]}; 35 | }; 36 | } 37 | interface Component { 38 | (props: TProps): JSX.Element; 39 | } 40 | } 41 | 42 | declare interface ProcessEnv { 43 | TARO_ENV: 'weapp' | 'swan' | 'alipay' | 'h5' | 'rn' | 'tt' | 'quickapp' | 'qq' | 'jd'; 44 | NODE_ENV: 'development' | 'production'; 45 | PROJ_ENV: any; 46 | } 47 | declare interface Process { 48 | env: ProcessEnv; 49 | } 50 | declare const process: Process; 51 | 52 | declare const require: (path: string) => any; 53 | declare interface HTMLDivElement { 54 | className?: string; 55 | } 56 | -------------------------------------------------------------------------------- /packages/core/src/devtools.ts: -------------------------------------------------------------------------------- 1 | import {StoreLogger} from './basic'; 2 | import env from './env'; 3 | 4 | type LogItem = {type: string; payload: any[]; priority: string[]; handers: string[]; effects?: LogItem[]}; 5 | 6 | let reduxDevTools: 7 | | { 8 | init(state: any): void; 9 | subscribe(action: any): void; 10 | send(logItem: LogItem, state: any): void; 11 | } 12 | | undefined; 13 | 14 | if (process.env.NODE_ENV === 'development' && env.__REDUX_DEVTOOLS_EXTENSION__) { 15 | reduxDevTools = env.__REDUX_DEVTOOLS_EXTENSION__.connect({features: {}}); 16 | reduxDevTools.init({}); 17 | reduxDevTools.subscribe(({type, payload}: {type: string; payload: {type: string}}) => { 18 | if (type === 'DISPATCH' && payload.type === 'COMMIT') { 19 | reduxDevTools!.init({}); 20 | } 21 | }); 22 | } 23 | 24 | const effects: LogItem[] = []; 25 | 26 | export const devLogger: StoreLogger = ({id, isActive, actionName, payload, priority, handers, state, effect}): void => { 27 | if (reduxDevTools) { 28 | const type = [`${id}${isActive ? '' : '*'}|`, actionName, `(${handers.length})`].join(''); 29 | const logItem: LogItem = {type, payload, priority, handers}; 30 | if (effect) { 31 | effects.push(logItem); 32 | } else { 33 | logItem.effects = [...effects]; 34 | effects.length = 0; 35 | reduxDevTools.send(logItem, state); 36 | } 37 | } 38 | }; 39 | -------------------------------------------------------------------------------- /packages/core/src/env.ts: -------------------------------------------------------------------------------- 1 | /// 2 | declare const window: any; 3 | declare const global: any; 4 | declare const module: any; 5 | declare const self: any; 6 | declare const btoa: any; 7 | declare const atob: any; 8 | declare const Buffer: any; 9 | 10 | let root: any; 11 | if (typeof self !== 'undefined') { 12 | root = self; 13 | } else if (typeof window !== 'undefined') { 14 | root = window; 15 | } else if (typeof global !== 'undefined') { 16 | root = global; 17 | } else if (typeof module !== 'undefined') { 18 | root = module; 19 | } else { 20 | root = new Function('return this')(); 21 | } 22 | 23 | /** 24 | * 运行环境的引用 25 | * 26 | * @remarks 27 | * - 浏览器环境下,该变量指向 window 28 | * 29 | * - 服务器环境下,该变量指向 global 30 | * 31 | * @public 32 | */ 33 | const env: Elux.ENV = root; 34 | 35 | env.isServer = typeof window === 'undefined' && typeof global === 'object' && global.global === global; 36 | 37 | env.encodeBas64 = function (str: string) { 38 | if (!str) { 39 | return ''; 40 | } 41 | return typeof btoa === 'function' ? btoa(str) : typeof Buffer !== 'undefined' ? Buffer.from(str).toString('base64') : str; 42 | }; 43 | env.decodeBas64 = function (str: string) { 44 | if (!str) { 45 | return ''; 46 | } 47 | return typeof atob === 'function' ? atob(str) : typeof Buffer !== 'undefined' ? Buffer.from(str, 'base64').toString() : str; 48 | }; 49 | 50 | export default env; 51 | -------------------------------------------------------------------------------- /packages/core/src/index.ts: -------------------------------------------------------------------------------- 1 | export {default as env} from './env'; 2 | export type {LoadingState, UNListener} from './utils'; 3 | export {buildConfigSetter, deepClone, deepMerge, isPromise, isServer, SingleDispatcher, toPromise} from './utils'; 4 | export type { 5 | Action, 6 | ActionCreator, 7 | ActionError, 8 | AsyncEluxComponent, 9 | CommonModel, 10 | CommonModelClass, 11 | CommonModule, 12 | Dispatch, 13 | EluxComponent, 14 | EluxContext, 15 | EluxStoreContext, 16 | GetState, 17 | IAppRender, 18 | IRouter, 19 | IRouteRecord, 20 | IStore, 21 | Location, 22 | ModelAsCreators, 23 | ModuleGetter, 24 | ModuleState, 25 | RouteAction, 26 | RouteEvent, 27 | RouterInitOptions, 28 | RouteRuntime, 29 | RouteTarget, 30 | StoreLogger, 31 | StoreLoggerInfo, 32 | StoreMiddleware, 33 | StoreState, 34 | VStore, 35 | } from './basic'; 36 | export {coreConfig, ErrorCodes, getClientRouter, setCoreConfig, isMutable} from './basic'; 37 | export {errorAction, setProcessedError} from './actions'; 38 | export {getComponent, getEntryComponent, getModule, getModuleApiMap, injectComponent, injectModule, moduleExists} from './inject'; 39 | export {effect, effectLogger, EmptyModel, exportComponent, exportView, reducer, setLoading} from './module'; 40 | export {modelHotReplacement, Store} from './store'; 41 | export type { 42 | API, 43 | Facade, 44 | GetPromiseComponent, 45 | GetPromiseModule, 46 | HandlerToAction, 47 | IGetComponent, 48 | IGetData, 49 | ILoadComponent, 50 | ModuleFacade, 51 | PickModelActions, 52 | PickThisActions, 53 | ReturnComponents, 54 | } from './facade'; 55 | export {BaseModel, exportModule, getApi} from './facade'; 56 | export type {RenderOptions} from './app'; 57 | export {buildApp, buildProvider, buildSSR, getTplInSSR} from './app'; 58 | export { 59 | BaseNativeRouter, 60 | locationToNativeLocation, 61 | locationToUrl, 62 | nativeLocationToLocation, 63 | nativeUrlToUrl, 64 | Router, 65 | urlToLocation, 66 | urlToNativeUrl, 67 | } from './route'; 68 | -------------------------------------------------------------------------------- /packages/core/src/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "@elux/babel-preset/tsconfig.esm.json", 3 | "compilerOptions": { 4 | "rootDir": "./", 5 | "declarationDir": "../types", 6 | "emitDeclarationOnly": true, 7 | "removeComments": false, 8 | "declarationMap": true, 9 | "types": ["../global/global"] 10 | }, 11 | "include": ["./"], 12 | "exclude": [] 13 | } 14 | -------------------------------------------------------------------------------- /packages/core/tests/deepMerge.test.ts: -------------------------------------------------------------------------------- 1 | import {deepMerge} from 'src/utils'; 2 | 3 | describe('deepExtend', () => { 4 | test('deepExtend', () => { 5 | const ww = {ww: 1}; 6 | const vv = {vv: ww}; 7 | const yy = {yy: vv}; 8 | expect(deepMerge({}, {yy}, {yy: {yy: {vv: 3}}})).toEqual({yy: {yy: {vv: 3}}}); 9 | expect(deepMerge({}, yy, {yy: {vv: {ww: 2, www: 3}, vvv: 4}, yyy: 5})).toEqual({yy: {vv: {ww: 2, www: 3}, vvv: 4}, yyy: 5}); 10 | expect(yy).toEqual({yy: {vv: {ww: 1}}}); 11 | }); 12 | }); 13 | -------------------------------------------------------------------------------- /packages/core/tests/setup.ts: -------------------------------------------------------------------------------- 1 | export {}; 2 | -------------------------------------------------------------------------------- /packages/core/tests/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../src/tsconfig.json", 3 | "compilerOptions": { 4 | "rootDir": "../", 5 | "declarationDir": null, 6 | "noEmit": true, 7 | "emitDeclarationOnly": false, 8 | "types": ["jest", "node"], 9 | "paths": { 10 | "src/*": ["../src/*"] 11 | } 12 | }, 13 | "include": ["./"], 14 | "exclude": [] 15 | } 16 | -------------------------------------------------------------------------------- /packages/core/types/actions.d.ts: -------------------------------------------------------------------------------- 1 | import { Action, Location, RouteAction } from './basic'; 2 | import { LoadingState } from './utils'; 3 | export declare const errorProcessed = "__eluxProcessed__"; 4 | export declare function isProcessedError(error: any): boolean; 5 | export declare function setProcessedError(error: any, processed: boolean): { 6 | [errorProcessed]: boolean; 7 | [key: string]: any; 8 | }; 9 | export declare function moduleLoadingAction(moduleName: string, loadingState: { 10 | [group: string]: LoadingState; 11 | }): Action; 12 | /** 13 | * 创建一个特殊的ErrorAction 14 | * 15 | * @param error - 错误体 16 | * 17 | * @public 18 | */ 19 | export declare function errorAction(error: any): Action; 20 | export declare function getErrorActionType(): string; 21 | export declare function getInitActionType(moduleName: string): string; 22 | export declare function testChangeAction(location: Location, routeAction: RouteAction): Action; 23 | export declare function beforeChangeAction(location: Location, routeAction: RouteAction): Action; 24 | export declare function afterChangeAction(location: Location, routeAction: RouteAction): Action; 25 | //# sourceMappingURL=actions.d.ts.map -------------------------------------------------------------------------------- /packages/core/types/actions.d.ts.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"actions.d.ts","sourceRoot":"","sources":["../src/actions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,MAAM,EAA2B,QAAQ,EAAE,WAAW,EAAC,MAAM,SAAS,CAAC;AAC/E,OAAO,EAAC,YAAY,EAAC,MAAM,SAAS,CAAC;AAErC,eAAO,MAAM,cAAc,sBAAsB,CAAC;AAElD,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,GAAG,GAAG,OAAO,CAEpD;AAED,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,GAAG,EAAE,SAAS,EAAE,OAAO,GAAG;IAAC,CAAC,cAAc,CAAC,EAAE,OAAO,CAAC;IAAC,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;CAAC,CAMjH;AAED,wBAAgB,mBAAmB,CAAC,UAAU,EAAE,MAAM,EAAE,YAAY,EAAE;IAAC,CAAC,KAAK,EAAE,MAAM,GAAG,YAAY,CAAA;CAAC,GAAG,MAAM,CAK7G;AAED;;;;;;GAMG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,GAAG,GAAG,MAAM,CAa9C;AAED,wBAAgB,kBAAkB,IAAI,MAAM,CAE3C;AAED,wBAAgB,iBAAiB,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM,CAE5D;AACD,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,QAAQ,EAAE,WAAW,EAAE,WAAW,GAAG,MAAM,CAKrF;AACD,wBAAgB,kBAAkB,CAAC,QAAQ,EAAE,QAAQ,EAAE,WAAW,EAAE,WAAW,GAAG,MAAM,CAKvF;AACD,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,QAAQ,EAAE,WAAW,EAAE,WAAW,GAAG,MAAM,CAKtF"} -------------------------------------------------------------------------------- /packages/core/types/app.d.ts: -------------------------------------------------------------------------------- 1 | import { IRouter, RouterInitOptions } from './basic'; 2 | /** 3 | * 创建应用时Render参数 4 | * 5 | * @public 6 | */ 7 | export interface RenderOptions { 8 | /** 9 | * 挂载应用Dom的id 10 | * 11 | * @defaultValue `root` 12 | * 13 | * @remarks 14 | * 默认: `root` 15 | */ 16 | id?: string; 17 | } 18 | export declare function buildApp(ins: INS, router: IRouter, routerOptions: RouterInitOptions): INS & { 19 | render(options?: RenderOptions): Promise; 20 | }; 21 | export declare function buildProvider(ins: INS, router: IRouter): Elux.Component<{ 22 | children: any; 23 | }>; 24 | export declare function buildSSR(ins: INS, router: IRouter, routerOptions: RouterInitOptions): INS & { 25 | render(options?: RenderOptions): Promise; 26 | }; 27 | /** 28 | * 获取SSR页面模版 29 | * 30 | * @public 31 | */ 32 | export declare function getTplInSSR(): string; 33 | //# sourceMappingURL=app.d.ts.map -------------------------------------------------------------------------------- /packages/core/types/app.d.ts.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"app.d.ts","sourceRoot":"","sources":["../src/app.ts"],"names":[],"mappings":"AAAA,OAAO,EAA0B,OAAO,EAAE,iBAAiB,EAAC,MAAM,SAAS,CAAC;AAE5E;;;;GAIG;AACH,MAAM,WAAW,aAAa;IAC5B;;;;;;;OAOG;IACH,EAAE,CAAC,EAAE,MAAM,CAAC;CACb;AAED,wBAAgB,QAAQ,CAAC,GAAG,GAAG,EAAE,EAC/B,GAAG,EAAE,GAAG,EACR,MAAM,EAAE,OAAO,EACf,aAAa,EAAE,iBAAiB,GAC/B,GAAG,GAAG;IACP,MAAM,CAAC,OAAO,CAAC,EAAE,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CAChD,CAUA;AAED,wBAAgB,aAAa,CAAC,GAAG,GAAG,EAAE,EAAE,GAAG,EAAE,GAAG,EAAE,MAAM,EAAE,OAAO,GAAG,IAAI,CAAC,SAAS,CAAC;IAAC,QAAQ,EAAE,GAAG,CAAA;CAAC,CAAC,CAIlG;AAED,wBAAgB,QAAQ,CAAC,GAAG,GAAG,EAAE,EAC/B,GAAG,EAAE,GAAG,EACR,MAAM,EAAE,OAAO,EACf,aAAa,EAAE,iBAAiB,GAC/B,GAAG,GAAG;IACP,MAAM,CAAC,OAAO,CAAC,EAAE,aAAa,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;CAClD,CAuBA;AAED;;;;GAIG;AACH,wBAAgB,WAAW,IAAI,MAAM,CAEpC"} -------------------------------------------------------------------------------- /packages/core/types/devtools.d.ts: -------------------------------------------------------------------------------- 1 | import { StoreLogger } from './basic'; 2 | export declare const devLogger: StoreLogger; 3 | //# sourceMappingURL=devtools.d.ts.map -------------------------------------------------------------------------------- /packages/core/types/devtools.d.ts.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"devtools.d.ts","sourceRoot":"","sources":["../src/devtools.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,WAAW,EAAC,MAAM,SAAS,CAAC;AAyBpC,eAAO,MAAM,SAAS,EAAE,WAYvB,CAAC"} -------------------------------------------------------------------------------- /packages/core/types/env.d.ts: -------------------------------------------------------------------------------- 1 | /// 2 | /** 3 | * 运行环境的引用 4 | * 5 | * @remarks 6 | * - 浏览器环境下,该变量指向 window 7 | * 8 | * - 服务器环境下,该变量指向 global 9 | * 10 | * @public 11 | */ 12 | declare const env: Elux.ENV; 13 | export default env; 14 | //# sourceMappingURL=env.d.ts.map -------------------------------------------------------------------------------- /packages/core/types/env.d.ts.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"env.d.ts","sourceRoot":"","sources":["../src/env.ts"],"names":[],"mappings":";AAsBA;;;;;;;;;GASG;AACH,QAAA,MAAM,GAAG,EAAE,IAAI,CAAC,GAAU,CAAC;AAiB3B,eAAe,GAAG,CAAC"} -------------------------------------------------------------------------------- /packages/core/types/history.d.ts.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"history.d.ts","sourceRoot":"","sources":["../src/history.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,YAAY,EAAE,QAAQ,EAAC,MAAM,SAAS,CAAC;AAC/C,OAAO,EAAC,KAAK,EAAC,MAAM,SAAS,CAAC;AAE9B,qBAAa,YAAY,CAAC,CAAC,SAAS;IAAC,OAAO,EAAE,MAAM,IAAI,CAAC;IAAC,SAAS,EAAE,MAAM,IAAI,CAAC;IAAC,WAAW,EAAE,MAAM,IAAI,CAAA;CAAC;IAI3F,SAAS,CAAC,KAAK,EAAE,MAAM;IAHnC,OAAO,CAAC,aAAa,CAAuB;IAC5C,SAAS,CAAC,OAAO,EAAE,CAAC,EAAE,CAAM;gBAEN,KAAK,EAAE,MAAM;IAEnC,SAAS,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC,GAAG,IAAI;IAK/B,SAAS,CAAC,SAAS,IAAI,IAAI;IAO3B,cAAc,IAAI,CAAC;IAGnB,eAAe,IAAI,CAAC;IAGpB,SAAS,CAAC,CAAC,EAAE,MAAM,GAAG,CAAC,GAAG,SAAS;IAGnC,QAAQ,IAAI,CAAC,EAAE;IAGf,SAAS,IAAI,MAAM;IAUnB,IAAI,CAAC,IAAI,EAAE,CAAC,GAAG,IAAI;IASnB,OAAO,CAAC,IAAI,EAAE,CAAC,GAAG,IAAI;IAOtB,QAAQ,CAAC,IAAI,EAAE,CAAC,GAAG,IAAI;IAkBvB,IAAI,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;CAa1B;AAED,qBAAa,WAAY,YAAW,YAAY;aAGlB,QAAQ,EAAE,QAAQ;aAAkB,SAAS,EAAE,SAAS;IAFpF,SAAgB,GAAG,EAAE,MAAM,CAAC;IACrB,KAAK,EAAE,MAAM,CAAC;gBACO,QAAQ,EAAE,QAAQ,EAAkB,SAAS,EAAE,SAAS;IAIpF,SAAS,IAAI,IAAI;IAGjB,WAAW,IAAI,IAAI;IAGnB,OAAO,IAAI,IAAI;CAGhB;AAED,qBAAa,SAAU,SAAQ,YAAY,CAAC,WAAW,CAAC;aAI1B,WAAW,EAAE,WAAW;IAH7C,EAAE,SAAK;IACd,SAAgB,GAAG,EAAE,MAAM,CAAC;IAC5B,OAAO,CAAC,MAAM,CAAQ;gBACM,WAAW,EAAE,WAAW,EAAE,QAAQ,EAAE,QAAQ,EAAE,KAAK,EAAE,KAAK;IAMtF,IAAI,KAAK,IAAI,KAAK,CAEjB;IACD,YAAY,CAAC,KAAK,EAAE,KAAK,GAAG,IAAI;IAOhC,eAAe,CAAC,GAAG,EAAE,MAAM,GAAG,CAAC,WAAW,EAAE,MAAM,CAAC,GAAG,SAAS;IAS/D,SAAS,IAAI,IAAI;IAGjB,WAAW,IAAI,IAAI;IAGnB,OAAO,IAAI,IAAI;CAGhB;AAED,qBAAa,WAAY,SAAQ,YAAY,CAAC,SAAS,CAAC;IAC/C,EAAE,SAAK;gBACF,QAAQ,EAAE,QAAQ,EAAE,KAAK,EAAE,KAAK;IAI5C,UAAU,IAAI,WAAW,EAAE;IAG3B,oBAAoB,IAAI;QAAC,KAAK,EAAE,KAAK,CAAC;QAAC,QAAQ,EAAE,QAAQ,CAAA;KAAC;IAO1D,eAAe,IAAI;QAAC,KAAK,EAAE,KAAK,CAAC;QAAC,QAAQ,EAAE,QAAQ,CAAA;KAAC,EAAE;IAQvD,OAAO,CAAC,SAAS;IAmBjB,QAAQ,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,EAAE,QAAQ,EAAE,OAAO,GAAG;QAAC,MAAM,EAAE,WAAW,CAAC;QAAC,QAAQ,EAAE,OAAO,CAAC;QAAC,KAAK,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;KAAC;IAiC1H,eAAe,CAAC,GAAG,EAAE,MAAM,GAAG;QAAC,MAAM,EAAE,WAAW,CAAC;QAAC,QAAQ,EAAE,OAAO,CAAC;QAAC,KAAK,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;KAAC;CAehG"} -------------------------------------------------------------------------------- /packages/core/types/index.d.ts: -------------------------------------------------------------------------------- 1 | export { default as env } from './env'; 2 | export type { LoadingState, UNListener } from './utils'; 3 | export { buildConfigSetter, deepClone, deepMerge, isPromise, isServer, SingleDispatcher, toPromise } from './utils'; 4 | export type { Action, ActionCreator, ActionError, AsyncEluxComponent, CommonModel, CommonModelClass, CommonModule, Dispatch, EluxComponent, EluxContext, EluxStoreContext, GetState, IAppRender, IRouter, IRouteRecord, IStore, Location, ModelAsCreators, ModuleGetter, ModuleState, RouteAction, RouteEvent, RouterInitOptions, RouteRuntime, RouteTarget, StoreLogger, StoreLoggerInfo, StoreMiddleware, StoreState, VStore, } from './basic'; 5 | export { coreConfig, ErrorCodes, getClientRouter, setCoreConfig, isMutable } from './basic'; 6 | export { errorAction, setProcessedError } from './actions'; 7 | export { getComponent, getEntryComponent, getModule, getModuleApiMap, injectComponent, injectModule, moduleExists } from './inject'; 8 | export { effect, effectLogger, EmptyModel, exportComponent, exportView, reducer, setLoading } from './module'; 9 | export { modelHotReplacement, Store } from './store'; 10 | export type { API, Facade, GetPromiseComponent, GetPromiseModule, HandlerToAction, IGetComponent, IGetData, ILoadComponent, ModuleFacade, PickModelActions, PickThisActions, ReturnComponents, } from './facade'; 11 | export { BaseModel, exportModule, getApi } from './facade'; 12 | export type { RenderOptions } from './app'; 13 | export { buildApp, buildProvider, buildSSR, getTplInSSR } from './app'; 14 | export { BaseNativeRouter, locationToNativeLocation, locationToUrl, nativeLocationToLocation, nativeUrlToUrl, Router, urlToLocation, urlToNativeUrl, } from './route'; 15 | //# sourceMappingURL=index.d.ts.map -------------------------------------------------------------------------------- /packages/core/types/index.d.ts.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,OAAO,IAAI,GAAG,EAAC,MAAM,OAAO,CAAC;AACrC,YAAY,EAAC,YAAY,EAAE,UAAU,EAAC,MAAM,SAAS,CAAC;AACtD,OAAO,EAAC,iBAAiB,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,QAAQ,EAAE,gBAAgB,EAAE,SAAS,EAAC,MAAM,SAAS,CAAC;AAClH,YAAY,EACV,MAAM,EACN,aAAa,EACb,WAAW,EACX,kBAAkB,EAClB,WAAW,EACX,gBAAgB,EAChB,YAAY,EACZ,QAAQ,EACR,aAAa,EACb,WAAW,EACX,gBAAgB,EAChB,QAAQ,EACR,UAAU,EACV,OAAO,EACP,YAAY,EACZ,MAAM,EACN,QAAQ,EACR,eAAe,EACf,YAAY,EACZ,WAAW,EACX,WAAW,EACX,UAAU,EACV,iBAAiB,EACjB,YAAY,EACZ,WAAW,EACX,WAAW,EACX,eAAe,EACf,eAAe,EACf,UAAU,EACV,MAAM,GACP,MAAM,SAAS,CAAC;AACjB,OAAO,EAAC,UAAU,EAAE,UAAU,EAAE,eAAe,EAAE,aAAa,EAAE,SAAS,EAAC,MAAM,SAAS,CAAC;AAC1F,OAAO,EAAC,WAAW,EAAE,iBAAiB,EAAC,MAAM,WAAW,CAAC;AACzD,OAAO,EAAC,YAAY,EAAE,iBAAiB,EAAE,SAAS,EAAE,eAAe,EAAE,eAAe,EAAE,YAAY,EAAE,YAAY,EAAC,MAAM,UAAU,CAAC;AAClI,OAAO,EAAC,MAAM,EAAE,YAAY,EAAE,UAAU,EAAE,eAAe,EAAE,UAAU,EAAE,OAAO,EAAE,UAAU,EAAC,MAAM,UAAU,CAAC;AAC5G,OAAO,EAAC,mBAAmB,EAAE,KAAK,EAAC,MAAM,SAAS,CAAC;AACnD,YAAY,EACV,GAAG,EACH,MAAM,EACN,mBAAmB,EACnB,gBAAgB,EAChB,eAAe,EACf,aAAa,EACb,QAAQ,EACR,cAAc,EACd,YAAY,EACZ,gBAAgB,EAChB,eAAe,EACf,gBAAgB,GACjB,MAAM,UAAU,CAAC;AAClB,OAAO,EAAC,SAAS,EAAE,YAAY,EAAE,MAAM,EAAC,MAAM,UAAU,CAAC;AACzD,YAAY,EAAC,aAAa,EAAC,MAAM,OAAO,CAAC;AACzC,OAAO,EAAC,QAAQ,EAAE,aAAa,EAAE,QAAQ,EAAE,WAAW,EAAC,MAAM,OAAO,CAAC;AACrE,OAAO,EACL,gBAAgB,EAChB,wBAAwB,EACxB,aAAa,EACb,wBAAwB,EACxB,cAAc,EACd,MAAM,EACN,aAAa,EACb,cAAc,GACf,MAAM,SAAS,CAAC"} -------------------------------------------------------------------------------- /packages/core/types/inject.d.ts: -------------------------------------------------------------------------------- 1 | import { CommonModel, CommonModule, EluxComponent, ModuleApiMap, VStore } from './basic'; 2 | /** 3 | * 模块是否存在 4 | * 5 | * @remarks 6 | * 即ModuleGetter中是否有配置该模块的获取方式 7 | * 8 | * @public 9 | */ 10 | export declare function moduleExists(moduleName: string): boolean; 11 | export declare function getModule(moduleName: string): Promise | CommonModule; 12 | export declare function getComponent(moduleName: string, componentName: string): EluxComponent | Promise; 13 | export declare function getEntryComponent(): EluxComponent; 14 | export declare function getModuleApiMap(data?: Record): ModuleApiMap; 15 | /** 16 | * 动态注册Module 17 | * 18 | * @remarks 19 | * 常于小程序分包加载 20 | * 21 | * @public 22 | */ 23 | export declare function injectModule(module: CommonModule): void; 24 | /** 25 | * 动态注册module 26 | * 27 | * @remarks 28 | * 常于小程序分包加载 29 | * 30 | * @public 31 | */ 32 | export declare function injectModule(moduleName: string, moduleGetter: () => CommonModule | Promise<{ 33 | default: CommonModule; 34 | }>): void; 35 | export declare function injectComponent(moduleName: string, componentName: string, store: VStore): EluxComponent | Promise; 36 | export declare function injectActions(model: CommonModel, hmr?: boolean): void; 37 | //# sourceMappingURL=inject.d.ts.map -------------------------------------------------------------------------------- /packages/core/types/inject.d.ts.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"inject.d.ts","sourceRoot":"","sources":["../src/inject.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,WAAW,EACX,YAAY,EAEZ,aAAa,EAIb,YAAY,EACZ,MAAM,EACP,MAAM,SAAS,CAAC;AAIjB;;;;;;;GAOG;AACH,wBAAgB,YAAY,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAExD;AAED,wBAAgB,SAAS,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,CAAC,GAAG,YAAY,CAuBlF;AAED,wBAAgB,YAAY,CAAC,UAAU,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,GAAG,aAAa,GAAG,OAAO,CAAC,aAAa,CAAC,CA6B9G;AAED,wBAAgB,iBAAiB,IAAI,aAAa,CAEjD;AAED,wBAAgB,eAAe,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,GAAG,YAAY,CAwD7E;AAED;;;;;;;GAOG;AACH,wBAAgB,YAAY,CAAC,MAAM,EAAE,YAAY,GAAG,IAAI,CAAC;AACzD;;;;;;;GAOG;AACH,wBAAgB,YAAY,CAAC,UAAU,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,YAAY,GAAG,OAAO,CAAC;IAAC,OAAO,EAAE,YAAY,CAAA;CAAC,CAAC,GAAG,IAAI,CAAC;AAS5H,wBAAgB,eAAe,CAAC,UAAU,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,aAAa,GAAG,OAAO,CAAC,aAAa,CAAC,CAOhI;AAED,wBAAgB,aAAa,CAAC,KAAK,EAAE,WAAW,EAAE,GAAG,CAAC,EAAE,OAAO,GAAG,IAAI,CAiCrE"} -------------------------------------------------------------------------------- /packages/core/types/module.d.ts.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"module.d.ts","sourceRoot":"","sources":["../src/module.ts"],"names":[],"mappings":"AACA,OAAO,EACL,MAAM,EAEN,kBAAkB,EAClB,WAAW,EACX,gBAAgB,EAChB,YAAY,EAEZ,aAAa,EAEb,MAAM,EAEN,WAAW,EACZ,MAAM,SAAS,CAAC;AAIjB;;;;;;;GAOG;AACH,wBAAgB,eAAe,CAAC,CAAC,EAAE,SAAS,EAAE,CAAC,GAAG,CAAC,GAAG,aAAa,CAIlE;AAED;;;;;;;GAOG;AACH,wBAAgB,UAAU,CAAC,CAAC,EAAE,SAAS,EAAE,CAAC,GAAG,CAAC,GAAG,aAAa,CAI7D;AAED;;;;GAIG;AACH,qBAAa,UAAW,YAAW,WAAW;aAKhB,UAAU,EAAE,MAAM;IAAE,SAAS,CAAC,QAAQ,CAAC,KAAK,EAAE,MAAM;IAJhF,IAAW,KAAK,IAAI,WAAW,CAE9B;gBAE2B,UAAU,EAAE,MAAM,EAAqB,KAAK,EAAE,MAAM;IAEhF,OAAO,IAAI,IAAI;IAKf,QAAQ,IAAI,IAAI;IAGhB,UAAU,IAAI,IAAI;IAKlB,SAAS,CAAC,UAAU,CAAC,KAAK,EAAE,WAAW,GAAG,WAAW;CAGtD;AAED,wBAAgB,kBAAkB,CAChC,UAAU,EAAE,MAAM,EAClB,UAAU,EAAE,gBAAgB,EAC5B,UAAU,EAAE;IAAC,CAAC,aAAa,EAAE,MAAM,GAAG,aAAa,GAAG,kBAAkB,CAAA;CAAC,EACzE,IAAI,CAAC,EAAE,GAAG,GACT,YAAY,CAkBd;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,UAAU,CAAC,CAAC,SAAS,OAAO,CAAC,GAAG,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,WAAW,CAAC,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,MAAM,GAAG,CAAC,CAcvH;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,YAAY,CAC1B,MAAM,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,YAAY,EAAE,OAAO,KAAK,IAAI,EACtE,KAAK,EAAE,IAAI,GAAG,CAAC,CAAC,MAAM,EAAE,UAAU,GAAG,UAAU,EAAE,YAAY,EAAE,OAAO,EAAE,YAAY,EAAE,OAAO,KAAK,IAAI,CAAC,YAEvF,GAAG,OAAO,MAAM,cAAc,kBAAkB,KAAG,IAAI,CAWxE;AAED;;;;GAIG;AACH,wBAAgB,OAAO,CAAC,MAAM,EAAE,GAAG,EAAE,GAAG,EAAE,MAAM,EAAE,UAAU,EAAE,kBAAkB,GAAG,GAAG,CAUrF;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,MAAM,CAAC,UAAU,CAAC,EAAE,MAAM,GAAG,IAAI,GAAG,QAAQ,CAgC3D"} -------------------------------------------------------------------------------- /packages/core/types/store.d.ts: -------------------------------------------------------------------------------- 1 | import { Action, CommonModelClass, Dispatch, IRouter, IStore, ModuleState, StoreMiddleware, StoreState } from './basic'; 2 | import { Listener, TaskCounter, UNListener } from './utils'; 3 | export declare function getActionData(action: Action): any[]; 4 | export declare const preMiddleware: StoreMiddleware; 5 | export declare class Store implements IStore { 6 | readonly sid: number; 7 | readonly uid: number; 8 | readonly router: IRouter; 9 | state: StoreState; 10 | private injectedModels; 11 | private mountedModules; 12 | private currentListeners; 13 | private nextListeners; 14 | private currentAction; 15 | private uncommittedState; 16 | active: boolean; 17 | dispatch: Dispatch; 18 | loadingGroups: { 19 | [moduleNameAndGroupName: string]: TaskCounter; 20 | }; 21 | constructor(sid: number, uid: number, router: IRouter); 22 | clone(brand?: boolean): Store; 23 | hotReplaceModel(moduleName: string, ModelClass: CommonModelClass): void; 24 | getCurrentAction(): Action; 25 | mount(moduleName: string, env: 'init' | 'route' | 'update'): void | Promise; 26 | setActive(): void; 27 | setInactive(): void; 28 | private ensureCanMutateNextListeners; 29 | destroy(): void; 30 | private update; 31 | getState(): StoreState; 32 | getState(moduleName: string): ModuleState; 33 | getUncommittedState(): ModuleState; 34 | subscribe(listener: Listener): UNListener; 35 | private respondHandler; 36 | } 37 | /** 38 | * model热更新 39 | * 40 | * @remarks 41 | * 修改了Model时热更新,通常由脚手架自动调用 42 | * 43 | * @param moduleName - Model所属模块名称 44 | * @param ModelClass - 新的Model 45 | * 46 | * @public 47 | */ 48 | export declare function modelHotReplacement(moduleName: string, ModelClass: CommonModelClass): void; 49 | //# sourceMappingURL=store.d.ts.map -------------------------------------------------------------------------------- /packages/core/types/store.d.ts.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"store.d.ts","sourceRoot":"","sources":["../src/store.ts"],"names":[],"mappings":"AACA,OAAO,EACL,MAAM,EAGN,gBAAgB,EAGhB,QAAQ,EACR,OAAO,EACP,MAAM,EAGN,WAAW,EAEX,eAAe,EACf,UAAU,EACX,MAAM,SAAS,CAAC;AAIjB,OAAO,EAAqB,QAAQ,EAAuB,WAAW,EAAa,UAAU,EAAC,MAAM,SAAS,CAAC;AAE9G,wBAAgB,aAAa,CAAC,MAAM,EAAE,MAAM,GAAG,GAAG,EAAE,CAEnD;AAED,eAAO,MAAM,aAAa,EAAE,eAsBzB,CAAC;AAyCJ,qBAAa,KAAM,YAAW,MAAM;aAeN,GAAG,EAAE,MAAM;aAAkB,GAAG,EAAE,MAAM;aAAkB,MAAM,EAAE,OAAO;IAd9F,KAAK,EAAE,UAAU,CAA+B;IACvD,OAAO,CAAC,cAAc,CAA2C;IACjE,OAAO,CAAC,cAAc,CAAgE;IACtF,OAAO,CAAC,gBAAgB,CAAkB;IAC1C,OAAO,CAAC,aAAa,CAAkB;IACvC,OAAO,CAAC,aAAa,CAAqB;IAC1C,OAAO,CAAC,gBAAgB,CAAkB;IAEnC,MAAM,EAAE,OAAO,CAAS;IACxB,QAAQ,EAAE,QAAQ,CAEvB;IACK,aAAa,EAAE;QAAC,CAAC,sBAAsB,EAAE,MAAM,GAAG,WAAW,CAAA;KAAC,CAAM;gBAE/C,GAAG,EAAE,MAAM,EAAkB,GAAG,EAAE,MAAM,EAAkB,MAAM,EAAE,OAAO;IAarG,KAAK,CAAC,KAAK,CAAC,EAAE,OAAO,GAAG,KAAK;IAG7B,eAAe,CAAC,UAAU,EAAE,MAAM,EAAE,UAAU,EAAE,gBAAgB,GAAG,IAAI;IAWvE,gBAAgB,IAAI,MAAM;IA6B1B,KAAK,CAAC,UAAU,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,GAAG,QAAQ,GAAG,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC;IA2CjF,SAAS,IAAI,IAAI;IASjB,WAAW,IAAI,IAAI;IASnB,OAAO,CAAC,4BAA4B;IAKpC,OAAO,IAAI,IAAI;IASf,OAAO,CAAC,MAAM;IASd,QAAQ,IAAI,UAAU;IACtB,QAAQ,CAAC,UAAU,EAAE,MAAM,GAAG,WAAW;IAIzC,mBAAmB,IAAI,WAAW;IAGlC,SAAS,CAAC,QAAQ,EAAE,QAAQ,GAAG,UAAU;IAuBzC,OAAO,CAAC,cAAc;CAuFvB;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,mBAAmB,CAAC,UAAU,EAAE,MAAM,EAAE,UAAU,EAAE,gBAAgB,GAAG,IAAI,CAY1F"} -------------------------------------------------------------------------------- /packages/core/types/utils.d.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * 常用于取消监听 3 | * 4 | * @public 5 | */ 6 | export declare type UNListener = () => void; 7 | export declare type Listener = () => void; 8 | export declare function isPromise(data: any): data is Promise; 9 | export declare function toPromise(resultOrPromise: Promise | T): Promise; 10 | export declare function promiseCaseCallback(resultOrPromise: Promise | T, callback: (result: T) => Promise | R): Promise | R; 11 | export declare function buildConfigSetter>(data: T): (config: Partial) => void; 12 | export declare function deepClone(data: T): T; 13 | /** 14 | * 多个PlainObject的深度Merge 15 | * 16 | * @remarks 17 | * 类似于 `Object.assin` 的深复制版本。 18 | * 19 | * - 除第一个参数target会被修改外,保证其它入参不会被修改。 20 | * 21 | * - 仅适应于Merge PlainObject 22 | * 23 | * - 对于array是直接替换而不merge 24 | * 25 | * @public 26 | */ 27 | export declare function deepMerge(target: { 28 | [key: string]: any; 29 | }, ...args: any[]): any; 30 | export declare class SingleDispatcher { 31 | protected listenerId: number; 32 | protected readonly listenerMap: Record void>; 33 | addListener(callback: (data: T) => void): UNListener; 34 | dispatch(data: T): void; 35 | } 36 | /** 37 | * Loading状态 38 | * 39 | * @public 40 | */ 41 | export declare type LoadingState = 'Start' | 'Stop' | 'Depth'; 42 | export declare class TaskCounter extends SingleDispatcher { 43 | deferSecond: number; 44 | readonly list: { 45 | promise: Promise; 46 | note: string; 47 | }[]; 48 | private ctimer; 49 | constructor(deferSecond: number); 50 | addItem(promise: Promise, note?: string): Promise; 51 | private completeItem; 52 | } 53 | export declare function compose(...funcs: Function[]): Function; 54 | /** 55 | * 当前是否是Server运行环境 56 | * 57 | * @public 58 | */ 59 | export declare function isServer(): boolean; 60 | //# sourceMappingURL=utils.d.ts.map -------------------------------------------------------------------------------- /packages/core/types/utils.d.ts.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAEA;;;;GAIG;AACH,oBAAY,UAAU,GAAG,MAAM,IAAI,CAAC;AAEpC,oBAAY,QAAQ,GAAG,MAAM,IAAI,CAAC;AAElC,wBAAgB,SAAS,CAAC,IAAI,EAAE,GAAG,GAAG,IAAI,IAAI,OAAO,CAAC,GAAG,CAAC,CAEzD;AAED,wBAAgB,SAAS,CAAC,CAAC,EAAE,eAAe,EAAE,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAKxE;AAED,wBAAgB,mBAAmB,CAAC,CAAC,EAAE,CAAC,EAAE,eAAe,EAAE,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC,EAAE,QAAQ,EAAE,CAAC,MAAM,EAAE,CAAC,KAAK,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC,CAKlI;AAED,wBAAgB,iBAAiB,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE,IAAI,EAAE,CAAC,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC,KAAK,IAAI,CAKtG;AAED,wBAAgB,SAAS,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,GAAG,CAAC,CAEvC;AAuBD;;;;;;;;;;;;;GAaG;AACH,wBAAgB,SAAS,CAAC,MAAM,EAAE;IAAC,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;CAAC,EAAE,GAAG,IAAI,EAAE,GAAG,EAAE,GAAG,GAAG,CA+B3E;AAED,qBAAa,gBAAgB,CAAC,CAAC;IAC7B,SAAS,CAAC,UAAU,SAAK;IAEzB,SAAS,CAAC,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,IAAI,CAAC,CAAM;IAEvE,WAAW,CAAC,QAAQ,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,IAAI,GAAG,UAAU;IAUpD,QAAQ,CAAC,IAAI,EAAE,CAAC,GAAG,IAAI;CAMxB;AAED;;;;GAIG;AACH,oBAAY,YAAY,GAAG,OAAO,GAAG,MAAM,GAAG,OAAO,CAAC;AAEtD,qBAAa,WAAY,SAAQ,gBAAgB,CAAC,YAAY,CAAC;IAKnC,WAAW,EAAE,MAAM;IAJ7C,SAAgB,IAAI,EAAE;QAAC,OAAO,EAAE,OAAO,CAAC,GAAG,CAAC,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAC,EAAE,CAAM;IAEnE,OAAO,CAAC,MAAM,CAAK;gBAEO,WAAW,EAAE,MAAM;IAItC,OAAO,CAAC,OAAO,EAAE,OAAO,CAAC,GAAG,CAAC,EAAE,IAAI,SAAK,GAAG,OAAO,CAAC,GAAG,CAAC;IAkB9D,OAAO,CAAC,YAAY;CAcrB;AACD,wBAAgB,OAAO,CAAC,GAAG,KAAK,EAAE,QAAQ,EAAE,GAAG,QAAQ,CActD;AAED;;;;GAIG;AACH,wBAAgB,QAAQ,IAAI,OAAO,CAElC"} -------------------------------------------------------------------------------- /packages/model/.babelrc.js: -------------------------------------------------------------------------------- 1 | const build = require('../../babelrc.build'); 2 | const config = build(); 3 | module.exports = config; 4 | 5 | -------------------------------------------------------------------------------- /packages/model/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Change Log 2 | 3 | All notable changes to this project will be documented in this file. 4 | See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. 5 | 6 | ## [2.6.3](https://github.com/hiisea/elux/compare/v2.6.2...v2.6.3) (2022-10-25) 7 | 8 | **Note:** Version bump only for package @elux/model 9 | 10 | 11 | 12 | 13 | 14 | ## [2.6.1](https://github.com/hiisea/elux/compare/v2.6.0...v2.6.1) (2022-08-09) 15 | 16 | **Note:** Version bump only for package @elux/model 17 | 18 | 19 | 20 | 21 | 22 | # [2.6.0](https://github.com/hiisea/elux/compare/v2.6.0-alpha.4...v2.6.0) (2022-08-02) 23 | 24 | ### Features 25 | 26 | - 拆分与UI框架无关的model专用包 ([b2a2809](https://github.com/hiisea/elux/commit/b2a2809ea10f29af24fb70d4a3a83d82564ddbef)) 27 | - 支持无UI、纯Model ([3c6c083](https://github.com/hiisea/elux/commit/3c6c0832626e92277d214b4e6633e79d9b13d03c)) 28 | - 不再打包react-redux,项目请自行安装 29 | -------------------------------------------------------------------------------- /packages/model/README.md: -------------------------------------------------------------------------------- 1 | # Cross platform and cross framework web solutions that based on micro-module and model-driven 2 | 3 | ## [Read Documentation ON Github](https://github.com/hiisea/elux) 4 | -------------------------------------------------------------------------------- /packages/model/api-extractor.json: -------------------------------------------------------------------------------- 1 | /** 2 | * Config file for API Extractor. For more info, please visit: https://api-extractor.com 3 | */ 4 | { 5 | "$schema": "https://developer.microsoft.com/json-schemas/api-extractor/v7/api-extractor.schema.json", 6 | 7 | "projectFolder": "./", 8 | 9 | "mainEntryPointFilePath": "/types/index.d.ts", 10 | 11 | "bundledPackages": ["@elux/core", "@elux/app"], 12 | 13 | "compiler": { 14 | "tsconfigFilePath": "src/tsconfig.json" 15 | }, 16 | 17 | "apiReport": { 18 | "enabled": false 19 | }, 20 | 21 | "docModel": { 22 | "enabled": true, 23 | "apiJsonFilePath": "../../api/.vuepress/.api/.api.json" 24 | }, 25 | 26 | "dtsRollup": { 27 | "enabled": false 28 | }, 29 | 30 | "tsdocMetadata": {}, 31 | 32 | "messages": { 33 | "compilerMessageReporting": { 34 | "default": { 35 | "logLevel": "warning" 36 | } 37 | }, 38 | "extractorMessageReporting": { 39 | "default": { 40 | "logLevel": "warning" 41 | }, 42 | "ae-internal-missing-underscore": { 43 | "logLevel": "none" 44 | } 45 | // "ae-missing-release-tag": { 46 | // "logLevel": "none" 47 | // }, 48 | // "ae-forgotten-export": { 49 | // "logLevel": "none" 50 | // } 51 | }, 52 | 53 | "tsdocMessageReporting": { 54 | "default": { 55 | "logLevel": "warning" 56 | } 57 | } 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /packages/model/dist/es5/index.js: -------------------------------------------------------------------------------- 1 | import { setCoreConfig, getModuleApiMap } from '@elux/core'; 2 | export { BaseModel, EmptyModel, ErrorCodes, deepMerge, effect, effectLogger, env, errorAction, exportComponent, exportModule, exportView, getApi, getTplInSSR, injectModule, isMutable, isServer, locationToNativeLocation, locationToUrl, modelHotReplacement, moduleExists, nativeLocationToLocation, nativeUrlToUrl, reducer, setLoading, urlToLocation, urlToNativeUrl } from '@elux/core'; 3 | 4 | var appConfig = Symbol(); 5 | function setConfig(conf) { 6 | setCoreConfig(conf); 7 | 8 | if (conf.DisableNativeRouter) { 9 | setCoreConfig({ 10 | NotifyNativeRouter: { 11 | window: false, 12 | page: false 13 | } 14 | }); 15 | } 16 | 17 | return appConfig; 18 | } 19 | function patchActions(typeName, json) { 20 | if (json) { 21 | getModuleApiMap(JSON.parse(json)); 22 | } 23 | } 24 | 25 | export { patchActions, setConfig }; 26 | -------------------------------------------------------------------------------- /packages/model/dist/es6/index.js: -------------------------------------------------------------------------------- 1 | import { setCoreConfig, getModuleApiMap } from '@elux/core'; 2 | export { BaseModel, EmptyModel, ErrorCodes, deepMerge, effect, effectLogger, env, errorAction, exportComponent, exportModule, exportView, getApi, getTplInSSR, injectModule, isMutable, isServer, locationToNativeLocation, locationToUrl, modelHotReplacement, moduleExists, nativeLocationToLocation, nativeUrlToUrl, reducer, setLoading, urlToLocation, urlToNativeUrl } from '@elux/core'; 3 | 4 | const appConfig = Symbol(); 5 | function setConfig(conf) { 6 | setCoreConfig(conf); 7 | 8 | if (conf.DisableNativeRouter) { 9 | setCoreConfig({ 10 | NotifyNativeRouter: { 11 | window: false, 12 | page: false 13 | } 14 | }); 15 | } 16 | 17 | return appConfig; 18 | } 19 | function patchActions(typeName, json) { 20 | if (json) { 21 | getModuleApiMap(JSON.parse(json)); 22 | } 23 | } 24 | 25 | export { patchActions, setConfig }; 26 | -------------------------------------------------------------------------------- /packages/model/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@elux/model", 3 | "version": "2.6.3", 4 | "description": "The practice of elux on model", 5 | "repository": "https://github.com/hiisea/elux/tree/master/packages/model", 6 | "author": "hiisea ", 7 | "license": "MIT", 8 | "publishConfig": { 9 | "access": "public" 10 | }, 11 | "engines": { 12 | "node": ">=14.0.0" 13 | }, 14 | "main": "dist/es5/index.js", 15 | "module": "dist/es6/index.js", 16 | "types": "types/", 17 | "files": [ 18 | "types/", 19 | "dist/" 20 | ], 21 | "scripts": { 22 | "eslint": "cross-env NODE_ENV=production eslint --fix --cache **/*.{js,ts}", 23 | "build:types": "rimraf ./types && tsc --build ./src", 24 | "build:es6": "cross-env NODE_TAG=es6 babel ./src --out-dir ./dist/es6 --extensions \".ts\"", 25 | "build:es5": "cross-env NODE_TAG=es5 babel ./src --out-dir ./dist/es5 --extensions \".ts\"", 26 | "package:es6": "cross-env NODE_TAG=es6 rollup -c", 27 | "package:es5": "cross-env NODE_TAG=es5 rollup -c", 28 | "api:json": "yarn build:types && api-extractor run", 29 | "build": "yarn build:types && rimraf ./dist && yarn package:es6 && yarn package:es5" 30 | }, 31 | "externals": { 32 | "@elux/core": true 33 | }, 34 | "dependencies": { 35 | "@elux/app": "^2.6.3", 36 | "@elux/core": "^2.6.3" 37 | }, 38 | "gitHead": "db6eb1314ef3e6abf5b7014495f441911c4cdd28" 39 | } 40 | -------------------------------------------------------------------------------- /packages/model/rollup.config.js: -------------------------------------------------------------------------------- 1 | import build from '../../rollup.build'; 2 | const config = build(__dirname); 3 | export default config; 4 | -------------------------------------------------------------------------------- /packages/model/src/index.ts: -------------------------------------------------------------------------------- 1 | export * from '@elux/app'; 2 | -------------------------------------------------------------------------------- /packages/model/src/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "@elux/babel-preset/tsconfig.esm.json", 3 | "compilerOptions": { 4 | "rootDir": "./", 5 | "declarationDir": "../types", 6 | "emitDeclarationOnly": true, 7 | "removeComments": false, 8 | "declarationMap": true 9 | }, 10 | "include": ["./"], 11 | "exclude": [] 12 | } 13 | -------------------------------------------------------------------------------- /packages/model/types/index.d.ts: -------------------------------------------------------------------------------- 1 | export * from '@elux/app'; 2 | //# sourceMappingURL=index.d.ts.map -------------------------------------------------------------------------------- /packages/model/types/index.d.ts.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAC"} -------------------------------------------------------------------------------- /packages/react-components/.babelrc.js: -------------------------------------------------------------------------------- 1 | const build = require('../../babelrc.build'); 2 | const config = build('react'); 3 | module.exports = config; 4 | 5 | -------------------------------------------------------------------------------- /packages/react-components/README.md: -------------------------------------------------------------------------------- 1 | # Cross platform and cross framework web solutions that based on micro-module and model-driven 2 | 3 | ## [Read Documentation ON Github](https://github.com/hiisea/elux) 4 | -------------------------------------------------------------------------------- /packages/react-components/dist/es5/App.js: -------------------------------------------------------------------------------- 1 | import { env } from '@elux/core'; 2 | import { EluxContextComponent, reactComponentsConfig } from './base'; 3 | import { RouterComponent } from './Router'; 4 | import { jsx as _jsx } from "react/jsx-runtime"; 5 | var AppRender = { 6 | toDocument: function toDocument(id, eluxContext, fromSSR, app) { 7 | var renderFun = fromSSR ? reactComponentsConfig.hydrate : reactComponentsConfig.render; 8 | var panel = env.document.getElementById(id); 9 | renderFun(_jsx(EluxContextComponent.Provider, { 10 | value: eluxContext, 11 | children: _jsx(RouterComponent, {}) 12 | }), panel); 13 | }, 14 | toString: function toString(id, eluxContext, app) { 15 | var html = reactComponentsConfig.renderToString(_jsx(EluxContextComponent.Provider, { 16 | value: eluxContext, 17 | children: _jsx(RouterComponent, {}) 18 | })); 19 | return Promise.resolve(html); 20 | }, 21 | toProvider: function toProvider(eluxContext, app) { 22 | return function (props) { 23 | return _jsx(EluxContextComponent.Provider, { 24 | value: eluxContext, 25 | children: props.children 26 | }); 27 | }; 28 | } 29 | }; 30 | export default AppRender; -------------------------------------------------------------------------------- /packages/react-components/dist/es5/DocumentHead.js: -------------------------------------------------------------------------------- 1 | import { coreConfig } from '@elux/core'; 2 | import { memo, useMemo } from 'react'; 3 | 4 | var Component = function Component(_ref) { 5 | var title = _ref.title, 6 | html = _ref.html; 7 | var router = coreConfig.UseRouter(); 8 | var documentHead = useMemo(function () { 9 | var documentHead = html || ''; 10 | 11 | if (title) { 12 | if (/.*?<\/title>/.test(documentHead)) { 13 | documentHead = documentHead.replace(/<title>.*?<\/title>/, "<title>" + title + ""); 14 | } else { 15 | documentHead = "" + title + "" + documentHead; 16 | } 17 | } 18 | 19 | return documentHead; 20 | }, [html, title]); 21 | router.setDocumentHead(documentHead); 22 | return null; 23 | }; 24 | 25 | Component.displayName = 'EluxDocumentHead'; 26 | export var DocumentHead = memo(Component); -------------------------------------------------------------------------------- /packages/react-components/dist/es5/EWindow.js: -------------------------------------------------------------------------------- 1 | import { coreConfig, getEntryComponent } from '@elux/core'; 2 | import { memo } from 'react'; 3 | import { jsx as _jsx } from "react/jsx-runtime"; 4 | 5 | var Component = function Component(_ref) { 6 | var store = _ref.store; 7 | var AppView = getEntryComponent(); 8 | var StoreProvider = coreConfig.StoreProvider; 9 | return _jsx(StoreProvider, { 10 | store: store, 11 | children: _jsx(AppView, {}) 12 | }); 13 | }; 14 | 15 | Component.displayName = 'EluxWindow'; 16 | export var EWindow = memo(Component); -------------------------------------------------------------------------------- /packages/react-components/dist/es5/Else.js: -------------------------------------------------------------------------------- 1 | import { Children } from 'react'; 2 | import { Fragment as _Fragment } from "react/jsx-runtime"; 3 | import { jsx as _jsx } from "react/jsx-runtime"; 4 | export var Else = function Else(_ref) { 5 | var children = _ref.children, 6 | elseView = _ref.elseView; 7 | var arr = []; 8 | Children.forEach(children, function (item) { 9 | item && arr.push(item); 10 | }); 11 | 12 | if (arr.length > 0) { 13 | return _jsx(_Fragment, { 14 | children: arr 15 | }); 16 | } 17 | 18 | return _jsx(_Fragment, { 19 | children: elseView 20 | }); 21 | }; 22 | Else.displayName = 'EluxElse'; -------------------------------------------------------------------------------- /packages/react-components/dist/es5/Switch.js: -------------------------------------------------------------------------------- 1 | import { Children } from 'react'; 2 | import { Fragment as _Fragment } from "react/jsx-runtime"; 3 | import { jsx as _jsx } from "react/jsx-runtime"; 4 | export var Switch = function Switch(_ref) { 5 | var children = _ref.children, 6 | elseView = _ref.elseView; 7 | var arr = []; 8 | Children.forEach(children, function (item) { 9 | item && arr.push(item); 10 | }); 11 | 12 | if (arr.length > 0) { 13 | return _jsx(_Fragment, { 14 | children: arr[0] 15 | }); 16 | } 17 | 18 | return _jsx(_Fragment, { 19 | children: elseView 20 | }); 21 | }; 22 | Switch.displayName = 'EluxSwitch'; -------------------------------------------------------------------------------- /packages/react-components/dist/es5/base.js: -------------------------------------------------------------------------------- 1 | import { buildConfigSetter, env } from '@elux/core'; 2 | import { createContext, useCallback, useContext, useEffect, useRef } from 'react'; 3 | export var EluxContextComponent = createContext({ 4 | router: null 5 | }); 6 | export function UseRouter() { 7 | var eluxContext = useContext(EluxContextComponent); 8 | return eluxContext.router; 9 | } 10 | export var reactComponentsConfig = { 11 | hydrate: undefined, 12 | render: undefined, 13 | renderToString: undefined 14 | }; 15 | export var setReactComponentsConfig = buildConfigSetter(reactComponentsConfig); 16 | export function useEventCallback(fn, dependencies) { 17 | var ref = useRef(function () { 18 | env.console.log(new Error('Cannot call an event handler while rendering.')); 19 | }); 20 | useEffect(function () { 21 | ref.current = fn; 22 | }, [fn].concat(dependencies)); 23 | return useCallback(function () { 24 | var fun = ref.current; 25 | return fun.apply(void 0, arguments); 26 | }, [ref]); 27 | } -------------------------------------------------------------------------------- /packages/react-components/dist/es5/index.js: -------------------------------------------------------------------------------- 1 | import { setCoreConfig } from '@elux/core'; 2 | import AppRender from './App'; 3 | import { UseRouter } from './base'; 4 | import { LoadComponent, LoadComponentOnError, LoadComponentOnLoading } from './LoadComponent'; 5 | setCoreConfig({ 6 | UseRouter: UseRouter, 7 | AppRender: AppRender, 8 | LoadComponent: LoadComponent, 9 | LoadComponentOnError: LoadComponentOnError, 10 | LoadComponentOnLoading: LoadComponentOnLoading 11 | }); 12 | export { setReactComponentsConfig } from './base'; 13 | export { EWindow } from './EWindow'; 14 | export { DocumentHead } from './DocumentHead'; 15 | export { Else } from './Else'; 16 | export { Switch } from './Switch'; 17 | export { Link } from './Link'; -------------------------------------------------------------------------------- /packages/react-components/dist/es6/App.js: -------------------------------------------------------------------------------- 1 | import { env } from '@elux/core'; 2 | import { EluxContextComponent, reactComponentsConfig } from './base'; 3 | import { RouterComponent } from './Router'; 4 | import { jsx as _jsx } from "react/jsx-runtime"; 5 | const AppRender = { 6 | toDocument(id, eluxContext, fromSSR, app) { 7 | const renderFun = fromSSR ? reactComponentsConfig.hydrate : reactComponentsConfig.render; 8 | const panel = env.document.getElementById(id); 9 | renderFun(_jsx(EluxContextComponent.Provider, { 10 | value: eluxContext, 11 | children: _jsx(RouterComponent, {}) 12 | }), panel); 13 | }, 14 | 15 | toString(id, eluxContext, app) { 16 | const html = reactComponentsConfig.renderToString(_jsx(EluxContextComponent.Provider, { 17 | value: eluxContext, 18 | children: _jsx(RouterComponent, {}) 19 | })); 20 | return Promise.resolve(html); 21 | }, 22 | 23 | toProvider(eluxContext, app) { 24 | return props => _jsx(EluxContextComponent.Provider, { 25 | value: eluxContext, 26 | children: props.children 27 | }); 28 | } 29 | 30 | }; 31 | export default AppRender; -------------------------------------------------------------------------------- /packages/react-components/dist/es6/DocumentHead.js: -------------------------------------------------------------------------------- 1 | import { coreConfig } from '@elux/core'; 2 | import { memo, useMemo } from 'react'; 3 | 4 | const Component = ({ 5 | title, 6 | html 7 | }) => { 8 | const router = coreConfig.UseRouter(); 9 | const documentHead = useMemo(() => { 10 | let documentHead = html || ''; 11 | 12 | if (title) { 13 | if (/.*?<\/title>/.test(documentHead)) { 14 | documentHead = documentHead.replace(/<title>.*?<\/title>/, `<title>${title}`); 15 | } else { 16 | documentHead = `${title}` + documentHead; 17 | } 18 | } 19 | 20 | return documentHead; 21 | }, [html, title]); 22 | router.setDocumentHead(documentHead); 23 | return null; 24 | }; 25 | 26 | Component.displayName = 'EluxDocumentHead'; 27 | export const DocumentHead = memo(Component); -------------------------------------------------------------------------------- /packages/react-components/dist/es6/EWindow.js: -------------------------------------------------------------------------------- 1 | import { coreConfig, getEntryComponent } from '@elux/core'; 2 | import { memo } from 'react'; 3 | import { jsx as _jsx } from "react/jsx-runtime"; 4 | 5 | const Component = function ({ 6 | store 7 | }) { 8 | const AppView = getEntryComponent(); 9 | const StoreProvider = coreConfig.StoreProvider; 10 | return _jsx(StoreProvider, { 11 | store: store, 12 | children: _jsx(AppView, {}) 13 | }); 14 | }; 15 | 16 | Component.displayName = 'EluxWindow'; 17 | export const EWindow = memo(Component); -------------------------------------------------------------------------------- /packages/react-components/dist/es6/Else.js: -------------------------------------------------------------------------------- 1 | import { Children } from 'react'; 2 | import { Fragment as _Fragment } from "react/jsx-runtime"; 3 | import { jsx as _jsx } from "react/jsx-runtime"; 4 | export const Else = ({ 5 | children, 6 | elseView 7 | }) => { 8 | const arr = []; 9 | Children.forEach(children, item => { 10 | item && arr.push(item); 11 | }); 12 | 13 | if (arr.length > 0) { 14 | return _jsx(_Fragment, { 15 | children: arr 16 | }); 17 | } 18 | 19 | return _jsx(_Fragment, { 20 | children: elseView 21 | }); 22 | }; 23 | Else.displayName = 'EluxElse'; -------------------------------------------------------------------------------- /packages/react-components/dist/es6/Link.js: -------------------------------------------------------------------------------- 1 | import { coreConfig, urlToNativeUrl } from '@elux/core'; 2 | import { useCallback, useMemo, useRef } from 'react'; 3 | import { jsx as _jsx } from "react/jsx-runtime"; 4 | export const Link = ({ 5 | to, 6 | cname, 7 | action, 8 | onClick, 9 | disabled, 10 | overflowRedirect, 11 | target = 'page', 12 | refresh, 13 | ...props 14 | }) => { 15 | const router = coreConfig.UseRouter(); 16 | const { 17 | firstArg, 18 | url, 19 | href 20 | } = useMemo(() => { 21 | let firstArg, url, href; 22 | 23 | if (action === 'back') { 24 | firstArg = to; 25 | url = `#${to.toString()}`; 26 | href = `#`; 27 | } else { 28 | const location = typeof to === 'string' ? { 29 | url: to 30 | } : to; 31 | cname !== undefined && (location.classname = cname); 32 | url = router.computeUrl(location, action, target); 33 | firstArg = location; 34 | href = urlToNativeUrl(url); 35 | } 36 | 37 | return { 38 | firstArg, 39 | url, 40 | href 41 | }; 42 | }, [target, action, cname, router, to]); 43 | const data = { 44 | router, 45 | onClick, 46 | disabled, 47 | firstArg, 48 | action, 49 | target, 50 | refresh, 51 | overflowRedirect 52 | }; 53 | const refData = useRef(data); 54 | Object.assign(refData.current, data); 55 | const clickHandler = useCallback(event => { 56 | event.preventDefault(); 57 | const { 58 | router, 59 | disabled, 60 | onClick, 61 | firstArg, 62 | action, 63 | target, 64 | refresh, 65 | overflowRedirect 66 | } = refData.current; 67 | 68 | if (!disabled) { 69 | onClick && onClick(event); 70 | router[action](firstArg, target, refresh, overflowRedirect); 71 | } 72 | }, []); 73 | props['onClick'] = clickHandler; 74 | props['action'] = action; 75 | props['target'] = target; 76 | props['url'] = url; 77 | props['href'] = href; 78 | overflowRedirect && (props['overflow'] = overflowRedirect); 79 | disabled && (props['disabled'] = true); 80 | 81 | if (coreConfig.Platform === 'taro') { 82 | return _jsx("span", { ...props 83 | }); 84 | } else { 85 | return _jsx("a", { ...props 86 | }); 87 | } 88 | }; 89 | Link.displayName = 'EluxLink'; -------------------------------------------------------------------------------- /packages/react-components/dist/es6/Switch.js: -------------------------------------------------------------------------------- 1 | import { Children } from 'react'; 2 | import { Fragment as _Fragment } from "react/jsx-runtime"; 3 | import { jsx as _jsx } from "react/jsx-runtime"; 4 | export const Switch = ({ 5 | children, 6 | elseView 7 | }) => { 8 | const arr = []; 9 | Children.forEach(children, item => { 10 | item && arr.push(item); 11 | }); 12 | 13 | if (arr.length > 0) { 14 | return _jsx(_Fragment, { 15 | children: arr[0] 16 | }); 17 | } 18 | 19 | return _jsx(_Fragment, { 20 | children: elseView 21 | }); 22 | }; 23 | Switch.displayName = 'EluxSwitch'; -------------------------------------------------------------------------------- /packages/react-components/dist/es6/base.js: -------------------------------------------------------------------------------- 1 | import { buildConfigSetter, env } from '@elux/core'; 2 | import { createContext, useCallback, useContext, useEffect, useRef } from 'react'; 3 | export const EluxContextComponent = createContext({ 4 | router: null 5 | }); 6 | export function UseRouter() { 7 | const eluxContext = useContext(EluxContextComponent); 8 | return eluxContext.router; 9 | } 10 | export const reactComponentsConfig = { 11 | hydrate: undefined, 12 | render: undefined, 13 | renderToString: undefined 14 | }; 15 | export const setReactComponentsConfig = buildConfigSetter(reactComponentsConfig); 16 | export function useEventCallback(fn, dependencies) { 17 | const ref = useRef((...args) => { 18 | env.console.log(new Error('Cannot call an event handler while rendering.')); 19 | }); 20 | useEffect(() => { 21 | ref.current = fn; 22 | }, [fn, ...dependencies]); 23 | return useCallback((...args) => { 24 | const fun = ref.current; 25 | return fun(...args); 26 | }, [ref]); 27 | } -------------------------------------------------------------------------------- /packages/react-components/dist/es6/index.js: -------------------------------------------------------------------------------- 1 | import { setCoreConfig } from '@elux/core'; 2 | import AppRender from './App'; 3 | import { UseRouter } from './base'; 4 | import { LoadComponent, LoadComponentOnError, LoadComponentOnLoading } from './LoadComponent'; 5 | setCoreConfig({ 6 | UseRouter, 7 | AppRender, 8 | LoadComponent, 9 | LoadComponentOnError, 10 | LoadComponentOnLoading 11 | }); 12 | export { setReactComponentsConfig } from './base'; 13 | export { EWindow } from './EWindow'; 14 | export { DocumentHead } from './DocumentHead'; 15 | export { Else } from './Else'; 16 | export { Switch } from './Switch'; 17 | export { Link } from './Link'; -------------------------------------------------------------------------------- /packages/react-components/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@elux/react-components", 3 | "version": "2.6.3", 4 | "description": "The practice of elux on react", 5 | "repository": "https://github.com/hiisea/elux/tree/master/packages/react-components", 6 | "author": "hiisea ", 7 | "license": "MIT", 8 | "publishConfig": { 9 | "access": "public" 10 | }, 11 | "engines": { 12 | "node": ">=14.0.0" 13 | }, 14 | "main": "dist/es5/index.js", 15 | "module": "dist/es6/index.js", 16 | "types": "types/", 17 | "files": [ 18 | "types/", 19 | "dist/" 20 | ], 21 | "scripts": { 22 | "eslint": "cross-env NODE_ENV=production eslint --fix --cache **/*.{js,ts,tsx}", 23 | "build:types": "rimraf ./types && tsc --build ./src", 24 | "build:es6": "cross-env NODE_TAG=es6 babel ./src --out-dir ./dist/es6 --extensions \".ts,.tsx\"", 25 | "build:es5": "cross-env NODE_TAG=es5 babel ./src --out-dir ./dist/es5 --extensions \".ts,.tsx\"", 26 | "build": "yarn build:types && rimraf ./dist && yarn build:es6 && yarn build:es5" 27 | }, 28 | "peerDependencies": { 29 | "react": "^16.8.0 || ^17 || ^18" 30 | }, 31 | "dependencies": { 32 | "@elux/core": "^2.6.3" 33 | }, 34 | "gitHead": "db6eb1314ef3e6abf5b7014495f441911c4cdd28" 35 | } 36 | -------------------------------------------------------------------------------- /packages/react-components/src/.eslintrc.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | root: true, 3 | extends: ['plugin:@elux/react'], 4 | env: { 5 | browser: false, 6 | node: true, 7 | }, 8 | }; 9 | -------------------------------------------------------------------------------- /packages/react-components/src/App.tsx: -------------------------------------------------------------------------------- 1 | import {env, IAppRender} from '@elux/core'; 2 | import {EluxContextComponent, reactComponentsConfig} from './base'; 3 | import {RouterComponent} from './Router'; 4 | 5 | const AppRender: IAppRender = { 6 | toDocument(id, eluxContext, fromSSR, app): void { 7 | const renderFun = fromSSR ? reactComponentsConfig.hydrate : reactComponentsConfig.render; 8 | const panel = env.document!.getElementById(id); 9 | renderFun!( 10 | 11 | 12 | , 13 | panel 14 | ); 15 | }, 16 | toString(id, eluxContext, app): Promise { 17 | const html = reactComponentsConfig.renderToString!( 18 | 19 | 20 | 21 | ); 22 | return Promise.resolve(html); 23 | }, 24 | toProvider(eluxContext, app): Elux.Component<{children: any}> { 25 | return (props) => {props.children}; 26 | }, 27 | }; 28 | 29 | export default AppRender; 30 | -------------------------------------------------------------------------------- /packages/react-components/src/DocumentHead.ts: -------------------------------------------------------------------------------- 1 | import {coreConfig} from '@elux/core'; 2 | import {FC, memo, useMemo} from 'react'; 3 | 4 | /** 5 | * 内置UI组件 6 | * 7 | * @remarks 8 | * 用组件的方式动态修改`内容`,主要是`title/description/keywords`等meta信息,SSR中非常有用 9 | * 10 | * @example 11 | * ```html 12 | * 16 | * ``` 17 | * 18 | * @public 19 | */ 20 | export interface DocumentHeadProps { 21 | title?: string; 22 | html?: string; 23 | } 24 | 25 | const Component: FC = ({title, html}) => { 26 | const router = coreConfig.UseRouter!(); 27 | const documentHead = useMemo(() => { 28 | let documentHead = html || ''; 29 | if (title) { 30 | if (/.*?<\/title>/.test(documentHead)) { 31 | documentHead = documentHead.replace(/<title>.*?<\/title>/, `<title>${title}`); 32 | } else { 33 | documentHead = `${title}` + documentHead; 34 | } 35 | } 36 | return documentHead; 37 | }, [html, title]); 38 | 39 | router.setDocumentHead(documentHead); 40 | return null; 41 | }; 42 | 43 | Component.displayName = 'EluxDocumentHead'; 44 | 45 | /** 46 | * 内置UI组件 47 | * 48 | * @remarks 49 | * 参见:{@link DocumentHeadProps} 50 | * 51 | * @public 52 | */ 53 | export const DocumentHead = memo(Component); 54 | -------------------------------------------------------------------------------- /packages/react-components/src/EWindow.tsx: -------------------------------------------------------------------------------- 1 | import {coreConfig, getEntryComponent, IStore} from '@elux/core'; 2 | import {FC, memo} from 'react'; 3 | 4 | const Component: FC<{store: IStore}> = function ({store}) { 5 | const AppView: Elux.Component = getEntryComponent() as any; 6 | const StoreProvider = coreConfig.StoreProvider!; 7 | return ( 8 | 9 | 10 | 11 | ); 12 | }; 13 | 14 | Component.displayName = 'EluxWindow'; 15 | 16 | export const EWindow = memo(Component); 17 | -------------------------------------------------------------------------------- /packages/react-components/src/Else.tsx: -------------------------------------------------------------------------------- 1 | import {Children, FC, ReactNode} from 'react'; 2 | 3 | /** 4 | * 内置UI组件 5 | * 6 | * @remarks 7 | * 用来控制子元素的渲染方式:如果非空子元素大于0,则渲染所有非空子元素,否则将渲染`props.elseView`, 8 | * 与 {@link Switch | ``} 的区别在于:`` 仅渲染非空子元素中的第1个 9 | * 10 | * @example 11 | * ```html 12 | *}> 13 | * {subView === 'detail' && } 14 | * {subView === 'list' && } 15 | * 16 | * ``` 17 | * 18 | * @public 19 | */ 20 | export interface ElseProps { 21 | elseView?: ReactNode; 22 | children: ReactNode; 23 | } 24 | 25 | /** 26 | * 内置UI组件 27 | * 28 | * @remarks 29 | * 参见:{@link ElseProps} 30 | * 31 | * @public 32 | */ 33 | export const Else: FC = ({children, elseView}) => { 34 | const arr: ReactNode[] = []; 35 | Children.forEach(children, (item) => { 36 | item && arr.push(item); 37 | }); 38 | if (arr.length > 0) { 39 | return <>{arr}; 40 | } 41 | return <>{elseView}; 42 | }; 43 | 44 | Else.displayName = 'EluxElse'; 45 | -------------------------------------------------------------------------------- /packages/react-components/src/Switch.tsx: -------------------------------------------------------------------------------- 1 | import {Children, FC, ReactNode} from 'react'; 2 | 3 | /** 4 | * 内置UI组件 5 | * 6 | * @remarks 7 | * 用来控制子元素的渲染方式:如果非空子元素大于0,则渲染第一个非空子元素,否则将渲染`props.elseView`, 8 | * 与 {@link Else | ``} 的区别在于:`` 渲染所有非空子元素 9 | * 10 | * @example 11 | * ```html 12 | *}> 13 | * {subView === 'detail' && } 14 | * {subView === 'list' && } 15 | * 16 | * ``` 17 | * 18 | * @public 19 | */ 20 | export interface SwitchProps { 21 | elseView?: ReactNode; 22 | children: ReactNode; 23 | } 24 | 25 | /** 26 | * 内置UI组件 27 | * 28 | * @remarks 29 | * 参见:{@link SwitchProps} 30 | * 31 | * @public 32 | */ 33 | export const Switch: FC = ({children, elseView}) => { 34 | const arr: ReactNode[] = []; 35 | Children.forEach(children, (item) => { 36 | item && arr.push(item); 37 | }); 38 | if (arr.length > 0) { 39 | return <>{arr[0]}; 40 | } 41 | return <>{elseView}; 42 | }; 43 | 44 | Switch.displayName = 'EluxSwitch'; 45 | -------------------------------------------------------------------------------- /packages/react-components/src/base.ts: -------------------------------------------------------------------------------- 1 | import {buildConfigSetter, EluxContext, env, IRouter} from '@elux/core'; 2 | import {createContext, useCallback, useContext, useEffect, useRef} from 'react'; 3 | 4 | export const EluxContextComponent = createContext({router: null as any}); 5 | 6 | export function UseRouter(): IRouter { 7 | const eluxContext = useContext(EluxContextComponent); 8 | return eluxContext.router; 9 | } 10 | 11 | export const reactComponentsConfig: { 12 | hydrate?: (component: any, container: any) => void; 13 | render?: (component: any, container: any) => void; 14 | renderToString?: (component: any) => string; 15 | } = { 16 | hydrate: undefined, 17 | render: undefined, 18 | renderToString: undefined, 19 | }; 20 | 21 | export const setReactComponentsConfig = buildConfigSetter(reactComponentsConfig); 22 | 23 | // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types 24 | export function useEventCallback(fn: (...args: A) => void, dependencies: any[]) { 25 | const ref = useRef((...args: A) => { 26 | env.console.log(new Error('Cannot call an event handler while rendering.')); 27 | }); 28 | 29 | useEffect(() => { 30 | ref.current = fn; 31 | // eslint-disable-next-line react-hooks/exhaustive-deps 32 | }, [fn, ...dependencies]); 33 | 34 | return useCallback( 35 | (...args: A) => { 36 | const fun = ref.current; 37 | return fun(...args); 38 | }, 39 | [ref] 40 | ); 41 | } 42 | -------------------------------------------------------------------------------- /packages/react-components/src/index.ts: -------------------------------------------------------------------------------- 1 | import {setCoreConfig} from '@elux/core'; 2 | 3 | import AppRender from './App'; 4 | import {UseRouter} from './base'; 5 | import {LoadComponent, LoadComponentOnError, LoadComponentOnLoading} from './LoadComponent'; 6 | 7 | setCoreConfig({ 8 | UseRouter, 9 | AppRender, 10 | LoadComponent, 11 | LoadComponentOnError, 12 | LoadComponentOnLoading, 13 | }); 14 | 15 | export {setReactComponentsConfig} from './base'; 16 | export {EWindow} from './EWindow'; 17 | export {DocumentHead} from './DocumentHead'; 18 | export {Else} from './Else'; 19 | export {Switch} from './Switch'; 20 | export {Link} from './Link'; 21 | export type {DocumentHeadProps} from './DocumentHead'; 22 | export type {ElseProps} from './Else'; 23 | export type {SwitchProps} from './Switch'; 24 | export type {LinkProps} from './Link'; 25 | -------------------------------------------------------------------------------- /packages/react-components/src/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "@elux/babel-preset/tsconfig.esm.json", 3 | "compilerOptions": { 4 | "rootDir": "./", 5 | "declarationDir": "../types", 6 | "emitDeclarationOnly": true, 7 | "removeComments": false, 8 | "declarationMap": true 9 | }, 10 | "include": ["./"], 11 | "exclude": [] 12 | } 13 | -------------------------------------------------------------------------------- /packages/react-components/types/App.d.ts: -------------------------------------------------------------------------------- 1 | import { IAppRender } from '@elux/core'; 2 | declare const AppRender: IAppRender; 3 | export default AppRender; 4 | //# sourceMappingURL=App.d.ts.map -------------------------------------------------------------------------------- /packages/react-components/types/App.d.ts.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"App.d.ts","sourceRoot":"","sources":["../src/App.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAM,UAAU,EAAC,MAAM,YAAY,CAAC;AAI3C,QAAA,MAAM,SAAS,EAAE,UAsBhB,CAAC;AAEF,eAAe,SAAS,CAAC"} -------------------------------------------------------------------------------- /packages/react-components/types/DocumentHead.d.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * 内置UI组件 3 | * 4 | * @remarks 5 | * 用组件的方式动态修改`内容`,主要是`title/description/keywords`等meta信息,SSR中非常有用 6 | * 7 | * @example 8 | * ```html 9 | * 13 | * ``` 14 | * 15 | * @public 16 | */ 17 | export interface DocumentHeadProps { 18 | title?: string; 19 | html?: string; 20 | } 21 | /** 22 | * 内置UI组件 23 | * 24 | * @remarks 25 | * 参见:{@link DocumentHeadProps} 26 | * 27 | * @public 28 | */ 29 | export declare const DocumentHead: import("react").NamedExoticComponent; 30 | //# sourceMappingURL=DocumentHead.d.ts.map -------------------------------------------------------------------------------- /packages/react-components/types/DocumentHead.d.ts.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"DocumentHead.d.ts","sourceRoot":"","sources":["../src/DocumentHead.ts"],"names":[],"mappings":"AAGA;;;;;;;;;;;;;;;GAeG;AACH,MAAM,WAAW,iBAAiB;IAChC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAsBD;;;;;;;GAOG;AACH,eAAO,MAAM,YAAY,yDAAkB,CAAC"} -------------------------------------------------------------------------------- /packages/react-components/types/EWindow.d.ts: -------------------------------------------------------------------------------- 1 | import { IStore } from '@elux/core'; 2 | export declare const EWindow: import("react").NamedExoticComponent<{ 3 | store: IStore; 4 | }>; 5 | //# sourceMappingURL=EWindow.d.ts.map -------------------------------------------------------------------------------- /packages/react-components/types/EWindow.d.ts.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"EWindow.d.ts","sourceRoot":"","sources":["../src/EWindow.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAgC,MAAM,EAAC,MAAM,YAAY,CAAC;AAejE,eAAO,MAAM,OAAO;WAZQ,MAAM;EAYI,CAAC"} -------------------------------------------------------------------------------- /packages/react-components/types/Else.d.ts: -------------------------------------------------------------------------------- 1 | import { FC, ReactNode } from 'react'; 2 | /** 3 | * 内置UI组件 4 | * 5 | * @remarks 6 | * 用来控制子元素的渲染方式:如果非空子元素大于0,则渲染所有非空子元素,否则将渲染`props.elseView`, 7 | * 与 {@link Switch | ``} 的区别在于:`` 仅渲染非空子元素中的第1个 8 | * 9 | * @example 10 | * ```html 11 | *}> 12 | * {subView === 'detail' && } 13 | * {subView === 'list' && } 14 | * 15 | * ``` 16 | * 17 | * @public 18 | */ 19 | export interface ElseProps { 20 | elseView?: ReactNode; 21 | children: ReactNode; 22 | } 23 | /** 24 | * 内置UI组件 25 | * 26 | * @remarks 27 | * 参见:{@link ElseProps} 28 | * 29 | * @public 30 | */ 31 | export declare const Else: FC; 32 | //# sourceMappingURL=Else.d.ts.map -------------------------------------------------------------------------------- /packages/react-components/types/Else.d.ts.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"Else.d.ts","sourceRoot":"","sources":["../src/Else.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAW,EAAE,EAAE,SAAS,EAAC,MAAM,OAAO,CAAC;AAE9C;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,WAAW,SAAS;IACxB,QAAQ,CAAC,EAAE,SAAS,CAAC;IACrB,QAAQ,EAAE,SAAS,CAAC;CACrB;AAED;;;;;;;GAOG;AACH,eAAO,MAAM,IAAI,EAAE,EAAE,CAAC,SAAS,CAS9B,CAAC"} -------------------------------------------------------------------------------- /packages/react-components/types/Link.d.ts: -------------------------------------------------------------------------------- 1 | import { IRouteRecord, Location, RouteAction, RouteTarget } from '@elux/core'; 2 | import { FC, HTMLAttributes, MouseEvent } from 'react'; 3 | /** 4 | * 内置UI组件 5 | * 6 | * @remarks 7 | * 类似于Html标签``,用组件的方式执行路由跳转,参见 {@link IRouter} 8 | * 9 | * @example 10 | * ```html 11 | *home 12 | * ``` 13 | * 14 | * @public 15 | */ 16 | export interface LinkProps extends HTMLAttributes { 17 | /** 18 | * 指定跳转的url或后退步数 19 | */ 20 | to: number | string | ((record: IRouteRecord) => boolean) | Partial; 21 | /** 22 | * 路由跳转动作 23 | */ 24 | action: Exclude; 25 | /** 26 | * 指定要操作的历史栈,默认`page` 27 | */ 28 | target?: RouteTarget; 29 | /** 30 | * 指定路由窗口的class 31 | */ 32 | cname?: string; 33 | /** 34 | * 如果disabled将不执行路由及onClick事件 35 | */ 36 | disabled?: boolean; 37 | /** 38 | * 是否强制刷新dom,默认false 39 | */ 40 | refresh?: boolean; 41 | /** 42 | * 点击事件 43 | */ 44 | onClick?(event: MouseEvent): void; 45 | /** 46 | * 路由后退时如果溢出,将重定向到此Url 47 | */ 48 | overflowRedirect?: string; 49 | } 50 | /** 51 | * 内置UI组件 52 | * 53 | * @remarks 54 | * 参见:{@link LinkProps} 55 | * 56 | * @public 57 | */ 58 | export declare const Link: FC; 59 | //# sourceMappingURL=Link.d.ts.map -------------------------------------------------------------------------------- /packages/react-components/types/Link.d.ts.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"Link.d.ts","sourceRoot":"","sources":["../src/Link.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAa,YAAY,EAAE,QAAQ,EAAE,WAAW,EAAE,WAAW,EAAiB,MAAM,YAAY,CAAC;AACxG,OAAO,EAAC,EAAE,EAAE,cAAc,EAAE,UAAU,EAA+B,MAAM,OAAO,CAAC;AAEnF;;;;;;;;;;;;GAYG;AACH,MAAM,WAAW,SAAU,SAAQ,cAAc,CAAC,cAAc,CAAC;IAC/D;;OAEG;IACH,EAAE,EAAE,MAAM,GAAG,MAAM,GAAG,CAAC,CAAC,MAAM,EAAE,YAAY,KAAK,OAAO,CAAC,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC;IAC9E;;OAEG;IACH,MAAM,EAAE,OAAO,CAAC,WAAW,EAAE,MAAM,CAAC,CAAC;IACrC;;OAEG;IACH,MAAM,CAAC,EAAE,WAAW,CAAC;IACrB;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;OAEG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB;;OAEG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB;;OAEG;IACH,OAAO,CAAC,CAAC,KAAK,EAAE,UAAU,GAAG,IAAI,CAAC;IAClC;;OAEG;IACH,gBAAgB,CAAC,EAAE,MAAM,CAAC;CAC3B;AAED;;;;;;;GAOG;AACH,eAAO,MAAM,IAAI,EAAE,EAAE,CAAC,SAAS,CA4C9B,CAAC"} -------------------------------------------------------------------------------- /packages/react-components/types/Router.d.ts: -------------------------------------------------------------------------------- 1 | export declare const RouterComponent: import("react").NamedExoticComponent<{}>; 2 | //# sourceMappingURL=Router.d.ts.map -------------------------------------------------------------------------------- /packages/react-components/types/Router.d.ts.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"Router.d.ts","sourceRoot":"","sources":["../src/Router.tsx"],"names":[],"mappings":"AAmFA,eAAO,MAAM,eAAe,0CAAkB,CAAC"} -------------------------------------------------------------------------------- /packages/react-components/types/Switch.d.ts: -------------------------------------------------------------------------------- 1 | import { FC, ReactNode } from 'react'; 2 | /** 3 | * 内置UI组件 4 | * 5 | * @remarks 6 | * 用来控制子元素的渲染方式:如果非空子元素大于0,则渲染第一个非空子元素,否则将渲染`props.elseView`, 7 | * 与 {@link Else | ``} 的区别在于:`` 渲染所有非空子元素 8 | * 9 | * @example 10 | * ```html 11 | *}> 12 | * {subView === 'detail' && } 13 | * {subView === 'list' && } 14 | * 15 | * ``` 16 | * 17 | * @public 18 | */ 19 | export interface SwitchProps { 20 | elseView?: ReactNode; 21 | children: ReactNode; 22 | } 23 | /** 24 | * 内置UI组件 25 | * 26 | * @remarks 27 | * 参见:{@link SwitchProps} 28 | * 29 | * @public 30 | */ 31 | export declare const Switch: FC; 32 | //# sourceMappingURL=Switch.d.ts.map -------------------------------------------------------------------------------- /packages/react-components/types/Switch.d.ts.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"Switch.d.ts","sourceRoot":"","sources":["../src/Switch.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAW,EAAE,EAAE,SAAS,EAAC,MAAM,OAAO,CAAC;AAE9C;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,WAAW,WAAW;IAC1B,QAAQ,CAAC,EAAE,SAAS,CAAC;IACrB,QAAQ,EAAE,SAAS,CAAC;CACrB;AAED;;;;;;;GAOG;AACH,eAAO,MAAM,MAAM,EAAE,EAAE,CAAC,WAAW,CASlC,CAAC"} -------------------------------------------------------------------------------- /packages/react-components/types/base.d.ts: -------------------------------------------------------------------------------- 1 | import { EluxContext, IRouter } from '@elux/core'; 2 | export declare const EluxContextComponent: import("react").Context; 3 | export declare function UseRouter(): IRouter; 4 | export declare const reactComponentsConfig: { 5 | hydrate?: (component: any, container: any) => void; 6 | render?: (component: any, container: any) => void; 7 | renderToString?: (component: any) => string; 8 | }; 9 | export declare const setReactComponentsConfig: (config: Partial<{ 10 | hydrate?: ((component: any, container: any) => void) | undefined; 11 | render?: ((component: any, container: any) => void) | undefined; 12 | renderToString?: ((component: any) => string) | undefined; 13 | }>) => void; 14 | export declare function useEventCallback(fn: (...args: A) => void, dependencies: any[]): (...args: A) => void; 15 | //# sourceMappingURL=base.d.ts.map -------------------------------------------------------------------------------- /packages/react-components/types/base.d.ts.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"base.d.ts","sourceRoot":"","sources":["../src/base.ts"],"names":[],"mappings":"AAAA,OAAO,EAAoB,WAAW,EAAO,OAAO,EAAC,MAAM,YAAY,CAAC;AAGxE,eAAO,MAAM,oBAAoB,sCAAoD,CAAC;AAEtF,wBAAgB,SAAS,IAAI,OAAO,CAGnC;AAED,eAAO,MAAM,qBAAqB,EAAE;IAClC,OAAO,CAAC,EAAE,CAAC,SAAS,EAAE,GAAG,EAAE,SAAS,EAAE,GAAG,KAAK,IAAI,CAAC;IACnD,MAAM,CAAC,EAAE,CAAC,SAAS,EAAE,GAAG,EAAE,SAAS,EAAE,GAAG,KAAK,IAAI,CAAC;IAClD,cAAc,CAAC,EAAE,CAAC,SAAS,EAAE,GAAG,KAAK,MAAM,CAAC;CAK7C,CAAC;AAEF,eAAO,MAAM,wBAAwB;2BATb,GAAG,aAAa,GAAG,KAAK,IAAI;0BAC7B,GAAG,aAAa,GAAG,KAAK,IAAI;kCACpB,GAAG,KAAK,MAAM;WAOmC,CAAC;AAGjF,wBAAgB,gBAAgB,CAAC,CAAC,SAAS,GAAG,EAAE,EAAE,EAAE,EAAE,CAAC,GAAG,IAAI,EAAE,CAAC,KAAK,IAAI,EAAE,YAAY,EAAE,GAAG,EAAE,aAWjF,CAAC,UAMd"} -------------------------------------------------------------------------------- /packages/react-components/types/index.d.ts: -------------------------------------------------------------------------------- 1 | export { setReactComponentsConfig } from './base'; 2 | export { EWindow } from './EWindow'; 3 | export { DocumentHead } from './DocumentHead'; 4 | export { Else } from './Else'; 5 | export { Switch } from './Switch'; 6 | export { Link } from './Link'; 7 | export type { DocumentHeadProps } from './DocumentHead'; 8 | export type { ElseProps } from './Else'; 9 | export type { SwitchProps } from './Switch'; 10 | export type { LinkProps } from './Link'; 11 | //# sourceMappingURL=index.d.ts.map -------------------------------------------------------------------------------- /packages/react-components/types/index.d.ts.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAcA,OAAO,EAAC,wBAAwB,EAAC,MAAM,QAAQ,CAAC;AAChD,OAAO,EAAC,OAAO,EAAC,MAAM,WAAW,CAAC;AAClC,OAAO,EAAC,YAAY,EAAC,MAAM,gBAAgB,CAAC;AAC5C,OAAO,EAAC,IAAI,EAAC,MAAM,QAAQ,CAAC;AAC5B,OAAO,EAAC,MAAM,EAAC,MAAM,UAAU,CAAC;AAChC,OAAO,EAAC,IAAI,EAAC,MAAM,QAAQ,CAAC;AAC5B,YAAY,EAAC,iBAAiB,EAAC,MAAM,gBAAgB,CAAC;AACtD,YAAY,EAAC,SAAS,EAAC,MAAM,QAAQ,CAAC;AACtC,YAAY,EAAC,WAAW,EAAC,MAAM,UAAU,CAAC;AAC1C,YAAY,EAAC,SAAS,EAAC,MAAM,QAAQ,CAAC"} -------------------------------------------------------------------------------- /packages/react-components/types/loadComponent.d.ts: -------------------------------------------------------------------------------- 1 | import { ILoadComponent } from '@elux/core'; 2 | export declare const LoadComponentOnError: Elux.Component<{ 3 | message: string; 4 | }>; 5 | export declare const LoadComponentOnLoading: Elux.Component; 6 | export declare const LoadComponent: ILoadComponent; 7 | //# sourceMappingURL=LoadComponent.d.ts.map -------------------------------------------------------------------------------- /packages/react-components/types/loadComponent.d.ts.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"LoadComponent.d.ts","sourceRoot":"","sources":["../src/LoadComponent.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAkB,cAAc,EAA6B,MAAM,YAAY,CAAC;AAGvF,eAAO,MAAM,oBAAoB,EAAE,IAAI,CAAC,SAAS,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAC,CAElE,CAAC;AACF,eAAO,MAAM,sBAAsB,EAAE,IAAI,CAAC,SAAuE,CAAC;AAElH,eAAO,MAAM,aAAa,EAAE,cAAc,CAAC,GAAG,CA+D7C,CAAC"} -------------------------------------------------------------------------------- /packages/react-redux/.babelrc.js: -------------------------------------------------------------------------------- 1 | const build = require('../../babelrc.build'); 2 | const config = build(); 3 | module.exports = config; 4 | 5 | -------------------------------------------------------------------------------- /packages/react-redux/README.md: -------------------------------------------------------------------------------- 1 | # Cross platform and cross framework web solutions that based on micro-module and model-driven 2 | 3 | ## [Read Documentation ON Github](https://github.com/hiisea/elux) 4 | -------------------------------------------------------------------------------- /packages/react-redux/dist/es5/index.js: -------------------------------------------------------------------------------- 1 | import { exportView, setCoreConfig } from '@elux/core'; 2 | import { connect, Provider, useStore } from 'react-redux'; 3 | export function connectStore(mapStateToProps, options) { 4 | return function (component) { 5 | return exportView(connect(mapStateToProps, options)(component)); 6 | }; 7 | } 8 | export var connectRedux = connectStore; 9 | setCoreConfig({ 10 | UseStore: useStore, 11 | StoreProvider: Provider 12 | }); 13 | export { batch, connect, connectAdvanced, createSelectorHook, shallowEqual, useSelector } from 'react-redux'; -------------------------------------------------------------------------------- /packages/react-redux/dist/es6/index.js: -------------------------------------------------------------------------------- 1 | import { exportView, setCoreConfig } from '@elux/core'; 2 | import { connect, Provider, useStore } from 'react-redux'; 3 | export function connectStore(mapStateToProps, options) { 4 | return function (component) { 5 | return exportView(connect(mapStateToProps, options)(component)); 6 | }; 7 | } 8 | export const connectRedux = connectStore; 9 | setCoreConfig({ 10 | UseStore: useStore, 11 | StoreProvider: Provider 12 | }); 13 | export { batch, connect, connectAdvanced, createSelectorHook, shallowEqual, useSelector } from 'react-redux'; -------------------------------------------------------------------------------- /packages/react-redux/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@elux/react-redux", 3 | "version": "2.6.3", 4 | "description": "The practice of elux on react + redux", 5 | "repository": "https://github.com/hiisea/elux/tree/master/packages/react-redux", 6 | "author": "hiisea ", 7 | "license": "MIT", 8 | "publishConfig": { 9 | "access": "public" 10 | }, 11 | "engines": { 12 | "node": ">=14.0.0" 13 | }, 14 | "main": "dist/es5/index.js", 15 | "module": "dist/es6/index.js", 16 | "types": "types/", 17 | "files": [ 18 | "types/", 19 | "dist/" 20 | ], 21 | "scripts": { 22 | "eslint": "cross-env NODE_ENV=production eslint --fix --cache **/*.{js,ts}", 23 | "build:types": "rimraf ./types && tsc --build ./src", 24 | "build:es6": "cross-env NODE_TAG=es6 babel ./src --out-dir ./dist/es6 --extensions \".ts\"", 25 | "build:es5": "cross-env NODE_TAG=es5 babel ./src --out-dir ./dist/es5 --extensions \".ts\"", 26 | "build": "yarn build:types && rimraf ./dist && yarn build:es6 && yarn build:es5" 27 | }, 28 | "peerDependencies": { 29 | "react": "^16.8.0 || ^17 || ^18", 30 | "react-dom": "^16.8.0 || ^17 || ^18", 31 | "react-redux": "^7 || ^8" 32 | }, 33 | "dependencies": { 34 | "@elux/core": "^2.6.3" 35 | }, 36 | "gitHead": "db6eb1314ef3e6abf5b7014495f441911c4cdd28" 37 | } 38 | -------------------------------------------------------------------------------- /packages/react-redux/src/index.ts: -------------------------------------------------------------------------------- 1 | import {Dispatch, EluxComponent, exportView, setCoreConfig} from '@elux/core'; 2 | import {ComponentClass, ComponentType, FunctionComponent} from 'react'; 3 | import {connect, Options, Provider, useStore} from 'react-redux'; 4 | 5 | /** 6 | * 用于{@link connectStore } 7 | * 8 | * @public 9 | */ 10 | export type GetProps = C extends FunctionComponent ? P : C extends ComponentClass ? P : never; 11 | 12 | /** 13 | * 用于{@link connectStore } 14 | * 15 | * @public 16 | */ 17 | export type InferableComponentEnhancerWithProps = ( 18 | component: C 19 | ) => EluxComponent & ComponentType, keyof TInjectedProps>>; 20 | 21 | /** 22 | * 连接store与react组件 23 | * 24 | * @remarks 25 | * 参见{@link https://react-redux.js.org/api/connect | react-redux/connect } 26 | * 27 | * @param mapStateToProps - state与props之间的映射与转换 28 | * @param options - 连接参数设置 29 | * 30 | * @public 31 | */ 32 | export function connectStore( 33 | mapStateToProps?: (state: any, owner: W) => S, 34 | options?: Options 35 | ): InferableComponentEnhancerWithProps { 36 | return function (component: any) { 37 | return exportView(connect(mapStateToProps, options)(component)) as any; 38 | }; 39 | } 40 | 41 | /** 42 | * 为{@link connectStore }别名 43 | * 44 | * @deprecated 请使用 connectStore 45 | * 46 | * @public 47 | */ 48 | export const connectRedux = connectStore; 49 | 50 | setCoreConfig({UseStore: useStore as any, StoreProvider: Provider as any}); 51 | 52 | export {batch, connect, connectAdvanced, createSelectorHook, shallowEqual, useSelector} from 'react-redux'; 53 | -------------------------------------------------------------------------------- /packages/react-redux/src/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "@elux/babel-preset/tsconfig.esm.json", 3 | "compilerOptions": { 4 | "rootDir": "./", 5 | "declarationDir": "../types", 6 | "emitDeclarationOnly": true, 7 | "removeComments": false, 8 | "declarationMap": true 9 | }, 10 | "include": ["./"], 11 | "exclude": [] 12 | } 13 | -------------------------------------------------------------------------------- /packages/react-redux/types/index.d.ts: -------------------------------------------------------------------------------- 1 | import { Dispatch, EluxComponent } from '@elux/core'; 2 | import { ComponentClass, ComponentType, FunctionComponent } from 'react'; 3 | import { Options } from 'react-redux'; 4 | /** 5 | * 用于{@link connectStore } 6 | * 7 | * @public 8 | */ 9 | export declare type GetProps = C extends FunctionComponent ? P : C extends ComponentClass ? P : never; 10 | /** 11 | * 用于{@link connectStore } 12 | * 13 | * @public 14 | */ 15 | export declare type InferableComponentEnhancerWithProps = (component: C) => EluxComponent & ComponentType, keyof TInjectedProps>>; 16 | /** 17 | * 连接store与react组件 18 | * 19 | * @remarks 20 | * 参见{@link https://react-redux.js.org/api/connect | react-redux/connect } 21 | * 22 | * @param mapStateToProps - state与props之间的映射与转换 23 | * @param options - 连接参数设置 24 | * 25 | * @public 26 | */ 27 | export declare function connectStore(mapStateToProps?: (state: any, owner: W) => S, options?: Options): InferableComponentEnhancerWithProps; 30 | /** 31 | * 为{@link connectStore }别名 32 | * 33 | * @deprecated 请使用 connectStore 34 | * 35 | * @public 36 | */ 37 | export declare const connectRedux: typeof connectStore; 38 | export { batch, connect, connectAdvanced, createSelectorHook, shallowEqual, useSelector } from 'react-redux'; 39 | //# sourceMappingURL=index.d.ts.map -------------------------------------------------------------------------------- /packages/react-redux/types/index.d.ts.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,QAAQ,EAAE,aAAa,EAA4B,MAAM,YAAY,CAAC;AAC9E,OAAO,EAAC,cAAc,EAAE,aAAa,EAAE,iBAAiB,EAAC,MAAM,OAAO,CAAC;AACvE,OAAO,EAAU,OAAO,EAAqB,MAAM,aAAa,CAAC;AAEjE;;;;GAIG;AACH,oBAAY,QAAQ,CAAC,CAAC,IAAI,CAAC,SAAS,iBAAiB,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,SAAS,cAAc,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;AAEnH;;;;GAIG;AACH,oBAAY,mCAAmC,CAAC,cAAc,IAAI,CAAC,CAAC,EAClE,SAAS,EAAE,CAAC,KACT,aAAa,GAAG,aAAa,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,MAAM,cAAc,CAAC,CAAC,CAAC;AAE5E;;;;;;;;;;GAUG;AACH,wBAAgB,YAAY,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,EAAE,EACjD,eAAe,CAAC,EAAE,CAAC,KAAK,EAAE,GAAG,EAAE,KAAK,EAAE,CAAC,KAAK,CAAC,EAC7C,OAAO,CAAC,EAAE,OAAO,CAAC,GAAG,EAAE,CAAC,EAAE,CAAC,CAAC,GAC3B,mCAAmC,CAAC,CAAC,GAAG,CAAC,GAAG;IAAC,QAAQ,EAAE,QAAQ,CAAA;CAAC,CAAC,CAInE;AAED;;;;;;GAMG;AACH,eAAO,MAAM,YAAY,qBAAe,CAAC;AAIzC,OAAO,EAAC,KAAK,EAAE,OAAO,EAAE,eAAe,EAAE,kBAAkB,EAAE,YAAY,EAAE,WAAW,EAAC,MAAM,aAAa,CAAC"} -------------------------------------------------------------------------------- /packages/react-taro/.babelrc.js: -------------------------------------------------------------------------------- 1 | const build = require('../../babelrc.build'); 2 | const config = build('react'); 3 | module.exports = config; 4 | -------------------------------------------------------------------------------- /packages/react-taro/README.md: -------------------------------------------------------------------------------- 1 | # Cross platform and cross framework web solutions that based on micro-module and model-driven 2 | 3 | ## [Read Documentation ON Github](https://github.com/hiisea/elux) 4 | -------------------------------------------------------------------------------- /packages/react-taro/api-extractor.json: -------------------------------------------------------------------------------- 1 | /** 2 | * Config file for API Extractor. For more info, please visit: https://api-extractor.com 3 | */ 4 | { 5 | "$schema": "https://developer.microsoft.com/json-schemas/api-extractor/v7/api-extractor.schema.json", 6 | "projectFolder": "./", 7 | "mainEntryPointFilePath": "/types/index.d.ts", 8 | "bundledPackages": ["@elux/core", "@elux/route-mp", "@elux/app", "@elux/react-components", "@elux/react-redux", "@elux/taro"], 9 | "compiler": { 10 | "tsconfigFilePath": "src/tsconfig.json" 11 | }, 12 | "apiReport": { 13 | "enabled": false 14 | }, 15 | "docModel": { 16 | "enabled": true, 17 | "apiJsonFilePath": "../../api/.vuepress/.api/.api.json" 18 | }, 19 | "dtsRollup": { 20 | "enabled": false 21 | }, 22 | "tsdocMetadata": {}, 23 | "messages": { 24 | "compilerMessageReporting": { 25 | "default": { 26 | "logLevel": "warning" 27 | } 28 | }, 29 | "extractorMessageReporting": { 30 | "default": { 31 | "logLevel": "warning" 32 | }, 33 | "ae-internal-missing-underscore": { 34 | "logLevel": "none" 35 | } 36 | // "ae-missing-release-tag": { 37 | // "logLevel": "none" 38 | // }, 39 | // "ae-forgotten-export": { 40 | // "logLevel": "none" 41 | // } 42 | }, 43 | "tsdocMessageReporting": { 44 | "default": { 45 | "logLevel": "warning" 46 | } 47 | } 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /packages/react-taro/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@elux/react-taro", 3 | "version": "2.6.3", 4 | "description": "The practice of react + taro", 5 | "repository": "https://github.com/hiisea/elux/tree/master/packages/react-taro", 6 | "author": "hiisea ", 7 | "license": "MIT", 8 | "publishConfig": { 9 | "access": "public" 10 | }, 11 | "engines": { 12 | "node": ">=14.0.0" 13 | }, 14 | "main": "dist/es5/index.js", 15 | "module": "dist/es6/index.js", 16 | "types": "types/", 17 | "files": [ 18 | "types/", 19 | "dist/" 20 | ], 21 | "scripts": { 22 | "eslint": "cross-env NODE_ENV=production eslint --fix --cache **/*.{js,ts}", 23 | "build:types": "rimraf ./types && tsc --build ./src", 24 | "build:es6": "cross-env NODE_TAG=es6 babel ./src --out-dir ./dist/es6 --extensions \".ts,.tsx\"", 25 | "build:es5": "cross-env NODE_TAG=es5 babel ./src --out-dir ./dist/es5 --extensions \".ts,.tsx\"", 26 | "package:es6": "cross-env NODE_TAG=es6 rollup -c", 27 | "package:es5": "cross-env NODE_TAG=es5 rollup -c", 28 | "api:json": "yarn build:types && api-extractor run", 29 | "build": "yarn build:types && rimraf ./dist && yarn build:es6 && yarn build:es5 && yarn package:es6 && yarn package:es5" 30 | }, 31 | "externals": { 32 | "@elux/core": true, 33 | "@tarojs/taro": true, 34 | "react-redux": true, 35 | "react": true, 36 | "react-dom": true 37 | }, 38 | "peerDependencies": { 39 | "@tarojs/taro": "^3.4.6", 40 | "react": "^16.8.0 || ^17 || ^18", 41 | "react-dom": "^16.8.0 || ^17 || ^18" 42 | }, 43 | "dependencies": { 44 | "@elux/app": "^2.6.3", 45 | "@elux/core": "^2.6.3", 46 | "@elux/react-components": "^2.6.3", 47 | "@elux/react-redux": "^2.6.3", 48 | "@elux/route-mp": "^2.6.3", 49 | "@elux/taro": "^2.6.3" 50 | }, 51 | "gitHead": "db6eb1314ef3e6abf5b7014495f441911c4cdd28" 52 | } 53 | -------------------------------------------------------------------------------- /packages/react-taro/rollup.config.js: -------------------------------------------------------------------------------- 1 | import build from '../../rollup.build'; 2 | //const config = build(__dirname, undefined, {'regenerator-runtime': require.resolve('./libs/regenerator-runtime')}); 3 | const config = build(__dirname); 4 | export default config; 5 | -------------------------------------------------------------------------------- /packages/react-taro/src/global.d.ts: -------------------------------------------------------------------------------- 1 | declare module '@tarojs/taro' { 2 | const useDidShow: (callback: () => void) => void; 3 | const useDidHide: (callback: () => void) => void; 4 | } 5 | -------------------------------------------------------------------------------- /packages/react-taro/src/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "@elux/babel-preset/tsconfig.esm.json", 3 | "compilerOptions": { 4 | "rootDir": "./", 5 | "declarationDir": "../types", 6 | "emitDeclarationOnly": true, 7 | "removeComments": false, 8 | "declarationMap": true 9 | }, 10 | "include": ["./"], 11 | "exclude": [] 12 | } 13 | -------------------------------------------------------------------------------- /packages/react-taro/types/index.d.ts: -------------------------------------------------------------------------------- 1 | import { AppConfig } from '@elux/app'; 2 | export { DocumentHead, Else, Link, Switch } from '@elux/react-components'; 3 | export type { DocumentHeadProps, ElseProps, LinkProps, SwitchProps } from '@elux/react-components'; 4 | export { connectRedux, connectStore, createSelectorHook, shallowEqual, useSelector } from '@elux/react-redux'; 5 | export type { GetProps, InferableComponentEnhancerWithProps } from '@elux/react-redux'; 6 | export * from '@elux/app'; 7 | /** 8 | * 小程序Page页面 9 | * 10 | * @public 11 | */ 12 | export declare const EluxPage: Elux.Component; 13 | /** 14 | * 创建应用 15 | * 16 | * @param appConfig - 应用配置 17 | * 18 | * @returns 19 | * 返回包含Provider组件 20 | * 21 | * @example 22 | * ```js 23 | * render () { 24 | * const Provider = createApp(appConfig); 25 | * return {this.props.children} 26 | * } 27 | * ``` 28 | * 29 | * @public 30 | */ 31 | export declare function createApp(appConfig: AppConfig): Elux.Component<{ 32 | children: any; 33 | }>; 34 | //# sourceMappingURL=index.d.ts.map -------------------------------------------------------------------------------- /packages/react-taro/types/index.d.ts.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAC,SAAS,EAAC,MAAM,WAAW,CAAC;AAOpC,OAAO,EAAC,YAAY,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAC,MAAM,wBAAwB,CAAC;AACxE,YAAY,EAAC,iBAAiB,EAAE,SAAS,EAAE,SAAS,EAAE,WAAW,EAAC,MAAM,wBAAwB,CAAC;AAEjG,OAAO,EAAC,YAAY,EAAE,YAAY,EAAE,kBAAkB,EAAE,YAAY,EAAE,WAAW,EAAC,MAAM,mBAAmB,CAAC;AAC5G,YAAY,EAAC,QAAQ,EAAE,mCAAmC,EAAC,MAAM,mBAAmB,CAAC;AAErF,cAAc,WAAW,CAAC;AAM1B;;;;GAIG;AACH,eAAO,MAAM,QAAQ,EAAE,IAAI,CAAC,SA4B3B,CAAC;AAIF;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,SAAS,CAAC,SAAS,EAAE,SAAS,GAAG,IAAI,CAAC,SAAS,CAAC;IAAC,QAAQ,EAAE,GAAG,CAAA;CAAC,CAAC,CAW/E"} -------------------------------------------------------------------------------- /packages/react-web/.babelrc.js: -------------------------------------------------------------------------------- 1 | const build = require('../../babelrc.build'); 2 | const config = build(); 3 | module.exports = config; 4 | 5 | -------------------------------------------------------------------------------- /packages/react-web/README.md: -------------------------------------------------------------------------------- 1 | # Cross platform and cross framework web solutions that based on micro-module and model-driven 2 | 3 | ## [Read Documentation ON Github](https://github.com/hiisea/elux) 4 | -------------------------------------------------------------------------------- /packages/react-web/api-extractor.json: -------------------------------------------------------------------------------- 1 | /** 2 | * Config file for API Extractor. For more info, please visit: https://api-extractor.com 3 | */ 4 | { 5 | "$schema": "https://developer.microsoft.com/json-schemas/api-extractor/v7/api-extractor.schema.json", 6 | 7 | "projectFolder": "./", 8 | 9 | "mainEntryPointFilePath": "/types/index.d.ts", 10 | 11 | "bundledPackages": ["@elux/core", "@elux/route-browser", "@elux/app", "@elux/react-components", "@elux/react-redux"], 12 | 13 | "compiler": { 14 | "tsconfigFilePath": "src/tsconfig.json" 15 | }, 16 | 17 | "apiReport": { 18 | "enabled": false 19 | }, 20 | 21 | "docModel": { 22 | "enabled": true, 23 | "apiJsonFilePath": "../../api/.vuepress/.api/.api.json" 24 | }, 25 | 26 | "dtsRollup": { 27 | "enabled": false 28 | }, 29 | 30 | "tsdocMetadata": {}, 31 | 32 | "messages": { 33 | "compilerMessageReporting": { 34 | "default": { 35 | "logLevel": "warning" 36 | } 37 | }, 38 | "extractorMessageReporting": { 39 | "default": { 40 | "logLevel": "warning" 41 | }, 42 | "ae-internal-missing-underscore": { 43 | "logLevel": "none" 44 | } 45 | // "ae-missing-release-tag": { 46 | // "logLevel": "none" 47 | // }, 48 | // "ae-forgotten-export": { 49 | // "logLevel": "none" 50 | // } 51 | }, 52 | 53 | "tsdocMessageReporting": { 54 | "default": { 55 | "logLevel": "warning" 56 | } 57 | } 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /packages/react-web/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@elux/react-web", 3 | "version": "2.6.3", 4 | "description": "The practice of elux on react-web", 5 | "repository": "https://github.com/hiisea/elux/tree/master/packages/react-web", 6 | "author": "hiisea ", 7 | "license": "MIT", 8 | "publishConfig": { 9 | "access": "public" 10 | }, 11 | "engines": { 12 | "node": ">=14.0.0" 13 | }, 14 | "main": "dist/es5/index.js", 15 | "module": "dist/es6/index.js", 16 | "browser": { 17 | "./server.js": "./server.mock.js" 18 | }, 19 | "types": "types/", 20 | "files": [ 21 | "types/", 22 | "dist/", 23 | "server.js", 24 | "server.mock.js" 25 | ], 26 | "scripts": { 27 | "eslint": "cross-env NODE_ENV=production eslint --fix --cache **/*.{js,ts}", 28 | "build:types": "rimraf ./types && tsc --build ./src", 29 | "build:es6": "cross-env NODE_TAG=es6 babel ./src --out-dir ./dist/es6 --extensions \".ts\"", 30 | "build:es5": "cross-env NODE_TAG=es5 babel ./src --out-dir ./dist/es5 --extensions \".ts\"", 31 | "package:es6": "cross-env NODE_TAG=es6 rollup -c", 32 | "package:es5": "cross-env NODE_TAG=es5 rollup -c", 33 | "api:json": "yarn build:types && api-extractor run", 34 | "build": "yarn build:types && rimraf ./dist && yarn package:es6 && yarn package:es5" 35 | }, 36 | "externals": { 37 | "@elux/core": true, 38 | "react": true, 39 | "react-dom": true, 40 | "react-redux": true, 41 | "@elux/react-web/server": true 42 | }, 43 | "peerDependencies": { 44 | "react": "^16.8.0 || ^17 || ^18", 45 | "react-dom": "^16.8.0 || ^17 || ^18" 46 | }, 47 | "dependencies": { 48 | "@elux/app": "^2.6.3", 49 | "@elux/core": "^2.6.3", 50 | "@elux/react-components": "^2.6.3", 51 | "@elux/react-redux": "^2.6.3", 52 | "@elux/route-browser": "^2.6.3" 53 | }, 54 | "gitHead": "db6eb1314ef3e6abf5b7014495f441911c4cdd28" 55 | } 56 | -------------------------------------------------------------------------------- /packages/react-web/rollup.config.js: -------------------------------------------------------------------------------- 1 | import build from '../../rollup.build'; 2 | const config = build(__dirname); 3 | export default config; 4 | -------------------------------------------------------------------------------- /packages/react-web/server.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | module.exports = require('react-dom/server'); 4 | -------------------------------------------------------------------------------- /packages/react-web/server.mock.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | module.exports = { 4 | renderToString: function () { 5 | return ''; 6 | }, 7 | }; 8 | -------------------------------------------------------------------------------- /packages/react-web/src/global.d.ts: -------------------------------------------------------------------------------- 1 | declare module '@elux/react-web/server' { 2 | export function renderToString(component: any): string; 3 | } 4 | -------------------------------------------------------------------------------- /packages/react-web/src/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "@elux/babel-preset/tsconfig.esm.json", 3 | "compilerOptions": { 4 | "rootDir": "./", 5 | "declarationDir": "../types", 6 | "emitDeclarationOnly": true, 7 | "removeComments": false, 8 | "declarationMap": true 9 | }, 10 | "include": ["./"], 11 | "exclude": [] 12 | } 13 | -------------------------------------------------------------------------------- /packages/react-web/types/index.d.ts: -------------------------------------------------------------------------------- 1 | import { AppConfig } from '@elux/app'; 2 | import { RenderOptions, RouterInitOptions } from '@elux/core'; 3 | export { DocumentHead, Else, Link, Switch } from '@elux/react-components'; 4 | export type { DocumentHeadProps, ElseProps, LinkProps, SwitchProps } from '@elux/react-components'; 5 | export { connectRedux, connectStore, createSelectorHook, shallowEqual, useSelector } from '@elux/react-redux'; 6 | export type { GetProps, InferableComponentEnhancerWithProps } from '@elux/react-redux'; 7 | export * from '@elux/app'; 8 | /** 9 | * @public 10 | */ 11 | export declare type EluxApp = { 12 | render(options?: RenderOptions): Promise; 13 | }; 14 | /** 15 | * 创建应用(CSR) 16 | * 17 | * @remarks 18 | * 应用唯一的创建入口,用于客户端渲染(CSR)。服务端渲染(SSR)请使用{@link createSSR} 19 | * 20 | * @param appConfig - 应用配置 21 | * 22 | * @returns 23 | * 返回包含`render`方法的实例,参见{@link RenderOptions} 24 | * 25 | * @example 26 | * ```js 27 | * createApp(config) 28 | * .render() 29 | * .then(() => { 30 | * const initLoading = document.getElementById('root-loading'); 31 | * if (initLoading) { 32 | * initLoading.parentNode!.removeChild(initLoading); 33 | * } 34 | * }); 35 | * ``` 36 | * 37 | * @public 38 | */ 39 | export declare function createApp(appConfig: AppConfig): EluxApp; 40 | /** 41 | * 创建应用(SSR) 42 | * 43 | * @remarks 44 | * 应用唯一的创建入口,用于服务端渲染(SSR)。客户端渲染(CSR)请使用{@link createApp} 45 | * 46 | * @param appConfig - 应用配置 47 | * @param routerOptions - 原生请求 48 | * 49 | * @returns 50 | * 返回包含`render`方法的下一步实例,参见{@link RenderOptions} 51 | * 52 | * @example 53 | * ```js 54 | * export default function server(request: {url: string}, response: any): Promise { 55 | * return createSSR(moduleGetter, request.url, {request, response}).render(); 56 | * } 57 | * ``` 58 | * @public 59 | */ 60 | export declare function createSSR(appConfig: AppConfig, routerOptions: RouterInitOptions): { 61 | render(options?: RenderOptions | undefined): Promise; 62 | }; 63 | //# sourceMappingURL=index.d.ts.map -------------------------------------------------------------------------------- /packages/react-web/types/index.d.ts.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAC,SAAS,EAAC,MAAM,WAAW,CAAC;AACpC,OAAO,EAA0B,aAAa,EAAE,iBAAiB,EAAC,MAAM,YAAY,CAAC;AAMrF,OAAO,EAAC,YAAY,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAC,MAAM,wBAAwB,CAAC;AACxE,YAAY,EAAC,iBAAiB,EAAE,SAAS,EAAE,SAAS,EAAE,WAAW,EAAC,MAAM,wBAAwB,CAAC;AAEjG,OAAO,EAAC,YAAY,EAAE,YAAY,EAAE,kBAAkB,EAAE,YAAY,EAAE,WAAW,EAAC,MAAM,mBAAmB,CAAC;AAC5G,YAAY,EAAC,QAAQ,EAAE,mCAAmC,EAAC,MAAM,mBAAmB,CAAC;AAErF,cAAc,WAAW,CAAC;AAQ1B;;GAEG;AACH,oBAAY,OAAO,GAAG;IACpB,MAAM,CAAC,OAAO,CAAC,EAAE,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CAChD,CAAC;AAIF;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,wBAAgB,SAAS,CAAC,SAAS,EAAE,SAAS,GAAG,OAAO,CAYvD;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,SAAS,CACvB,SAAS,EAAE,SAAS,EACpB,aAAa,EAAE,iBAAiB,GAC/B;IACD,MAAM,CAAC,OAAO,CAAC,EAAE,aAAa,GAAG,SAAS,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;CAC9D,CAGA"} -------------------------------------------------------------------------------- /packages/route-browser/.babelrc.js: -------------------------------------------------------------------------------- 1 | const build = require('../../babelrc.build'); 2 | const config = build(); 3 | module.exports = config; 4 | 5 | -------------------------------------------------------------------------------- /packages/route-browser/README.md: -------------------------------------------------------------------------------- 1 | # Cross platform and cross framework web solutions that based on micro-module and model-driven 2 | 3 | ## [Read Documentation ON Github](https://github.com/hiisea/elux) 4 | -------------------------------------------------------------------------------- /packages/route-browser/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@elux/route-browser", 3 | "version": "2.6.3", 4 | "description": "Using @elux/route in browser", 5 | "repository": "https://github.com/hiisea/elux/tree/master/packages/route-browser", 6 | "author": "hiisea ", 7 | "license": "MIT", 8 | "publishConfig": { 9 | "access": "public" 10 | }, 11 | "engines": { 12 | "node": ">=14.0.0" 13 | }, 14 | "main": "dist/es5/index.js", 15 | "module": "dist/es6/index.js", 16 | "types": "types/", 17 | "files": [ 18 | "types/", 19 | "dist/" 20 | ], 21 | "scripts": { 22 | "eslint": "cross-env NODE_ENV=production eslint --fix --cache **/*.{js,ts}", 23 | "build:types": "rimraf ./types && tsc --build ./src", 24 | "build:es6": "cross-env NODE_TAG=es6 babel ./src --out-dir ./dist/es6 --extensions \".ts\"", 25 | "build:es5": "cross-env NODE_TAG=es5 babel ./src --out-dir ./dist/es5 --extensions \".ts\"", 26 | "build": "yarn build:types && rimraf ./dist && yarn build:es6 && yarn build:es5" 27 | }, 28 | "dependencies": { 29 | "@elux/core": "^2.6.3" 30 | }, 31 | "gitHead": "db6eb1314ef3e6abf5b7014495f441911c4cdd28" 32 | } 33 | -------------------------------------------------------------------------------- /packages/route-browser/src/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "@elux/babel-preset/tsconfig.esm.json", 3 | "compilerOptions": { 4 | "rootDir": "./", 5 | "declarationDir": "../types", 6 | "emitDeclarationOnly": true, 7 | "removeComments": false, 8 | "declarationMap": true 9 | }, 10 | "include": ["./"], 11 | "exclude": [] 12 | } 13 | -------------------------------------------------------------------------------- /packages/route-browser/types/index.d.ts: -------------------------------------------------------------------------------- 1 | import { IRouter } from '@elux/core'; 2 | export declare function createClientRouter(): IRouter; 3 | export declare function createServerRouter(): IRouter; 4 | //# sourceMappingURL=index.d.ts.map -------------------------------------------------------------------------------- /packages/route-browser/types/index.d.ts.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAoC,OAAO,EAAsC,MAAM,YAAY,CAAC;AA2F3G,wBAAgB,kBAAkB,IAAI,OAAO,CAI5C;AAED,wBAAgB,kBAAkB,IAAI,OAAO,CAI5C"} -------------------------------------------------------------------------------- /packages/route-mp/.babelrc.js: -------------------------------------------------------------------------------- 1 | const build = require('../../babelrc.build'); 2 | const config = build(); 3 | module.exports = config; 4 | -------------------------------------------------------------------------------- /packages/route-mp/README.md: -------------------------------------------------------------------------------- 1 | # Cross platform and cross framework web solutions that based on micro-module and model-driven 2 | 3 | ## [Read Documentation ON Github](https://github.com/hiisea/elux) 4 | -------------------------------------------------------------------------------- /packages/route-mp/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@elux/route-mp", 3 | "version": "2.6.3", 4 | "description": "Using @elux/route in mini-program", 5 | "repository": "https://github.com/hiisea/elux/tree/master/packages/route-mp", 6 | "author": "hiisea ", 7 | "license": "MIT", 8 | "publishConfig": { 9 | "access": "public" 10 | }, 11 | "engines": { 12 | "node": ">=14.0.0" 13 | }, 14 | "main": "dist/es5/index.js", 15 | "module": "dist/es6/index.js", 16 | "types": "types/", 17 | "files": [ 18 | "types/", 19 | "dist/" 20 | ], 21 | "scripts": { 22 | "eslint": "cross-env NODE_ENV=production eslint --fix --cache **/*.{js,ts}", 23 | "build:types": "rimraf ./types && tsc --build ./src", 24 | "build:es6": "cross-env NODE_TAG=es6 babel ./src --out-dir ./dist/es6 --extensions \".ts\"", 25 | "build:es5": "cross-env NODE_TAG=es5 babel ./src --out-dir ./dist/es5 --extensions \".ts\"", 26 | "build": "yarn build:types && rimraf ./dist && yarn build:es6 && yarn build:es5" 27 | }, 28 | "dependencies": { 29 | "@elux/core": "^2.6.3" 30 | }, 31 | "gitHead": "db6eb1314ef3e6abf5b7014495f441911c4cdd28" 32 | } 33 | -------------------------------------------------------------------------------- /packages/route-mp/src/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "@elux/babel-preset/tsconfig.esm.json", 3 | "compilerOptions": { 4 | "rootDir": "./", 5 | "declarationDir": "../types", 6 | "emitDeclarationOnly": true, 7 | "removeComments": false, 8 | "declarationMap": true 9 | }, 10 | "include": ["./"], 11 | "exclude": [] 12 | } 13 | -------------------------------------------------------------------------------- /packages/route-mp/types/index.d.ts: -------------------------------------------------------------------------------- 1 | import { BaseNativeRouter, IRouter, Location } from '@elux/core'; 2 | interface RouteOption { 3 | url: string; 4 | } 5 | interface NavigateBackOption { 6 | delta?: number; 7 | } 8 | export declare type MPLocation = { 9 | pathname: string; 10 | search: string; 11 | action: 'PUSH' | 'POP' | 'REPLACE' | 'RELAUNCH'; 12 | }; 13 | export interface IHistory { 14 | onRouteChange(callback: (data: MPLocation) => void): () => void; 15 | reLaunch(option: RouteOption): Promise; 16 | redirectTo(option: RouteOption): Promise; 17 | navigateTo(option: RouteOption): Promise; 18 | navigateBack(option: NavigateBackOption): Promise; 19 | switchTab(option: RouteOption): Promise; 20 | getLocation(): MPLocation; 21 | isTabPage(pathname: string): boolean; 22 | } 23 | export declare class MPNativeRouter extends BaseNativeRouter { 24 | private history; 25 | private unlistenHistory; 26 | constructor(history: IHistory); 27 | protected addKey(url: string, key: string): string; 28 | protected init(location: Location, key: string): boolean; 29 | protected _push(location: Location): void; 30 | protected push(location: Location, key: string): boolean; 31 | protected _replace(location: Location): void; 32 | protected replace(location: Location, key: string): boolean; 33 | protected relaunch(location: Location, key: string): boolean; 34 | protected back(location: Location, key: string, index: [number, number]): boolean; 35 | exit(): void; 36 | destroy(): void; 37 | } 38 | export declare function createRouter(history: IHistory): IRouter; 39 | export {}; 40 | //# sourceMappingURL=index.d.ts.map -------------------------------------------------------------------------------- /packages/route-mp/types/index.d.ts.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,gBAAgB,EAAc,OAAO,EAAE,QAAQ,EAA4C,MAAM,YAAY,CAAC;AAItH,UAAU,WAAW;IACnB,GAAG,EAAE,MAAM,CAAC;CACb;AACD,UAAU,kBAAkB;IAC1B,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AACD,oBAAY,UAAU,GAAG;IAAC,QAAQ,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,GAAG,KAAK,GAAG,SAAS,GAAG,UAAU,CAAA;CAAC,CAAC;AAC7G,MAAM,WAAW,QAAQ;IACvB,aAAa,CAAC,QAAQ,EAAE,CAAC,IAAI,EAAE,UAAU,KAAK,IAAI,GAAG,MAAM,IAAI,CAAC;IAChE,QAAQ,CAAC,MAAM,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC7C,UAAU,CAAC,MAAM,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC/C,UAAU,CAAC,MAAM,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC/C,YAAY,CAAC,MAAM,EAAE,kBAAkB,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACxD,SAAS,CAAC,MAAM,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC9C,WAAW,IAAI,UAAU,CAAC;IAC1B,SAAS,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC;CACtC;AAED,qBAAa,cAAe,SAAQ,gBAAgB;IAGtC,OAAO,CAAC,OAAO;IAF3B,OAAO,CAAC,eAAe,CAAyB;gBAE5B,OAAO,EAAE,QAAQ;IAkCrC,SAAS,CAAC,MAAM,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM;IAIlD,SAAS,CAAC,IAAI,CAAC,QAAQ,EAAE,QAAQ,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO;IAIxD,SAAS,CAAC,KAAK,CAAC,QAAQ,EAAE,QAAQ,GAAG,IAAI;IAMzC,SAAS,CAAC,IAAI,CAAC,QAAQ,EAAE,QAAQ,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO;IAKxD,SAAS,CAAC,QAAQ,CAAC,QAAQ,EAAE,QAAQ,GAAG,IAAI;IAM5C,SAAS,CAAC,OAAO,CAAC,QAAQ,EAAE,QAAQ,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO;IAK3D,SAAS,CAAC,QAAQ,CAAC,QAAQ,EAAE,QAAQ,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO;IAY5D,SAAS,CAAC,IAAI,CAAC,QAAQ,EAAE,QAAQ,EAAE,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,OAAO;IAK1E,IAAI,IAAI,IAAI;IAIZ,OAAO,IAAI,IAAI;CAGvB;AAED,wBAAgB,YAAY,CAAC,OAAO,EAAE,QAAQ,GAAG,OAAO,CAGvD"} -------------------------------------------------------------------------------- /packages/taro/.babelrc.js: -------------------------------------------------------------------------------- 1 | const build = require('../../babelrc.build'); 2 | const config = build(); 3 | module.exports = config; 4 | 5 | -------------------------------------------------------------------------------- /packages/taro/README.md: -------------------------------------------------------------------------------- 1 | # Cross platform and cross framework web solutions that based on micro-module and model-driven 2 | 3 | ## [Read Documentation ON Github](https://github.com/hiisea/elux) 4 | -------------------------------------------------------------------------------- /packages/taro/global/global.d.ts: -------------------------------------------------------------------------------- 1 | declare module '@tarojs/taro' { 2 | const reLaunch: any; 3 | const redirectTo: any; 4 | const navigateTo: any; 5 | const navigateBack: any; 6 | const switchTab: any; 7 | const getLaunchOptionsSync: any; 8 | const getCurrentPages: () => Array<{route: string; options?: {[key: string]: string}}>; 9 | const setNavigationBarTitle: (options: {title: string}) => Promise; 10 | } 11 | -------------------------------------------------------------------------------- /packages/taro/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@elux/taro", 3 | "version": "2.6.3", 4 | "description": "The practice of taro", 5 | "repository": "https://github.com/hiisea/elux/tree/master/packages/taro", 6 | "author": "hiisea ", 7 | "license": "MIT", 8 | "publishConfig": { 9 | "access": "public" 10 | }, 11 | "engines": { 12 | "node": ">=14.0.0" 13 | }, 14 | "main": "dist/es5/index.js", 15 | "module": "dist/es6/index.js", 16 | "types": "types/", 17 | "files": [ 18 | "types/", 19 | "dist/" 20 | ], 21 | "scripts": { 22 | "eslint": "cross-env NODE_ENV=production eslint --fix --cache **/*.{js,ts}", 23 | "build:types": "rimraf ./types && tsc --build ./src", 24 | "build:es6": "cross-env NODE_TAG=es6 babel ./src --out-dir ./dist/es6 --extensions \".ts\"", 25 | "build:es5": "cross-env NODE_TAG=es5 babel ./src --out-dir ./dist/es5 --extensions \".ts\"", 26 | "build": "yarn build:types && rimraf ./dist && yarn build:es6 && yarn build:es5" 27 | }, 28 | "peerDependencies": { 29 | "@tarojs/taro": "^3.3.12" 30 | }, 31 | "dependencies": { 32 | "@elux/core": "^2.6.3", 33 | "@elux/route-mp": "^2.6.3" 34 | }, 35 | "gitHead": "db6eb1314ef3e6abf5b7014495f441911c4cdd28" 36 | } 37 | -------------------------------------------------------------------------------- /packages/taro/src/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "@elux/babel-preset/tsconfig.esm.json", 3 | "compilerOptions": { 4 | "rootDir": "./", 5 | "declarationDir": "../types", 6 | "emitDeclarationOnly": true, 7 | "removeComments": false, 8 | "declarationMap": true, 9 | "types": ["../global/global"] 10 | }, 11 | "include": ["./"], 12 | "exclude": [] 13 | } 14 | -------------------------------------------------------------------------------- /packages/taro/types/index.d.ts: -------------------------------------------------------------------------------- 1 | import { SingleDispatcher } from '@elux/core'; 2 | import { IHistory, MPLocation } from '@elux/route-mp'; 3 | export declare const eventBus: SingleDispatcher; 4 | export declare const taroHistory: IHistory; 5 | export declare function onShow(): void; 6 | //# sourceMappingURL=index.d.ts.map -------------------------------------------------------------------------------- /packages/taro/types/index.d.ts.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAqB,gBAAgB,EAAC,MAAM,YAAY,CAAC;AAChE,OAAO,EAAC,QAAQ,EAAE,UAAU,EAAC,MAAM,gBAAgB,CAAC;AAcpD,eAAO,MAAM,QAAQ,8BAAqC,CAAC;AAa3D,eAAO,MAAM,WAAW,EAAE,QAyDzB,CAAC;AAqCF,wBAAgB,MAAM,IAAI,IAAI,CAK7B"} -------------------------------------------------------------------------------- /packages/vue-components/.babelrc.js: -------------------------------------------------------------------------------- 1 | const build = require('../../babelrc.build'); 2 | const config = build('vue'); 3 | module.exports = config; 4 | 5 | -------------------------------------------------------------------------------- /packages/vue-components/README.md: -------------------------------------------------------------------------------- 1 | # Cross platform and cross framework web solutions that based on micro-module and model-driven 2 | 3 | ## [Read Documentation ON Github](https://github.com/hiisea/elux) 4 | -------------------------------------------------------------------------------- /packages/vue-components/dist/es5/App.js: -------------------------------------------------------------------------------- 1 | import { createVNode as _createVNode } from "vue"; 2 | import { env } from '@elux/core'; 3 | import { EluxContextKey, vueComponentsConfig } from './base'; 4 | var AppRender = { 5 | toDocument: function toDocument(id, eluxContext, fromSSR, app) { 6 | app.provide(EluxContextKey, eluxContext); 7 | 8 | if (process.env.NODE_ENV === 'development' && env.__VUE_DEVTOOLS_GLOBAL_HOOK__) { 9 | env.__VUE_DEVTOOLS_GLOBAL_HOOK__.Vue = app; 10 | } 11 | 12 | app.mount("#" + id); 13 | }, 14 | toString: function toString(id, eluxContext, app) { 15 | app.provide(EluxContextKey, eluxContext); 16 | return vueComponentsConfig.renderToString(app); 17 | }, 18 | toProvider: function toProvider(eluxContext, app) { 19 | app.provide(EluxContextKey, eluxContext); 20 | return function () { 21 | return _createVNode("div", null, null); 22 | }; 23 | } 24 | }; 25 | export default AppRender; -------------------------------------------------------------------------------- /packages/vue-components/dist/es5/DocumentHead.js: -------------------------------------------------------------------------------- 1 | import { coreConfig } from '@elux/core'; 2 | import { computed, defineComponent } from 'vue'; 3 | export var DocumentHead = defineComponent({ 4 | name: 'EluxDocumentHead', 5 | props: ['title', 'html'], 6 | setup: function setup(props) { 7 | var documentHead = computed(function () { 8 | var documentHead = props.html || ''; 9 | 10 | if (props.title) { 11 | if (/.*?<\/title>/.test(documentHead)) { 12 | documentHead = documentHead.replace(/<title>.*?<\/title>/, "<title>" + props.title + ""); 13 | } else { 14 | documentHead = "" + props.title + "" + documentHead; 15 | } 16 | } 17 | 18 | return documentHead; 19 | }); 20 | var router = coreConfig.UseRouter(); 21 | return function () { 22 | router.setDocumentHead(documentHead.value); 23 | return null; 24 | }; 25 | } 26 | }); -------------------------------------------------------------------------------- /packages/vue-components/dist/es5/EWindow.js: -------------------------------------------------------------------------------- 1 | import { getEntryComponent } from '@elux/core'; 2 | import { defineComponent, h, provide, shallowReactive, watch } from 'vue'; 3 | import { EluxStoreContextKey } from './base'; 4 | export var EWindow = defineComponent({ 5 | name: 'EluxWindow', 6 | props: ['store'], 7 | setup: function setup(props) { 8 | var AppView = getEntryComponent(); 9 | var store = props.store; 10 | var uid = store.uid, 11 | sid = store.sid, 12 | state = store.state, 13 | dispatch = store.dispatch, 14 | mount = store.mount; 15 | var storeRef = shallowReactive({ 16 | uid: uid, 17 | sid: sid, 18 | state: state, 19 | dispatch: dispatch.bind(store), 20 | mount: mount.bind(store) 21 | }); 22 | var storeContext = { 23 | store: storeRef 24 | }; 25 | provide(EluxStoreContextKey, storeContext); 26 | watch(function () { 27 | return props.store; 28 | }, function (store) { 29 | var uid = store.uid, 30 | sid = store.sid, 31 | state = store.state, 32 | dispatch = store.dispatch; 33 | Object.assign(storeRef, { 34 | uid: uid, 35 | sid: sid, 36 | state: state, 37 | dispatch: dispatch.bind(store), 38 | mount: mount.bind(store) 39 | }); 40 | }); 41 | return function () { 42 | return h(AppView, null); 43 | }; 44 | } 45 | }); -------------------------------------------------------------------------------- /packages/vue-components/dist/es5/Else.js: -------------------------------------------------------------------------------- 1 | import { Comment, Fragment, h } from 'vue'; 2 | export var Else = function Else(props, context) { 3 | var arr = []; 4 | var children = context.slots.default ? context.slots.default() : []; 5 | children.forEach(function (item) { 6 | if (item.type !== Comment) { 7 | arr.push(item); 8 | } 9 | }); 10 | 11 | if (arr.length > 0) { 12 | return h(Fragment, null, arr); 13 | } 14 | 15 | return h(Fragment, null, props.elseView ? [props.elseView] : context.slots.elseView ? context.slots.elseView() : []); 16 | }; 17 | Else.displayName = 'EluxElse'; -------------------------------------------------------------------------------- /packages/vue-components/dist/es5/Switch.js: -------------------------------------------------------------------------------- 1 | import { Comment, Fragment, h } from 'vue'; 2 | export var Switch = function Switch(props, context) { 3 | var arr = []; 4 | var children = context.slots.default ? context.slots.default() : []; 5 | children.forEach(function (item) { 6 | if (item.type !== Comment) { 7 | arr.push(item); 8 | } 9 | }); 10 | 11 | if (arr.length > 0) { 12 | return h(Fragment, null, [arr[0]]); 13 | } 14 | 15 | return h(Fragment, null, props.elseView ? [props.elseView] : context.slots.elseView ? context.slots.elseView() : []); 16 | }; 17 | Switch.displayName = 'EluxSwitch'; -------------------------------------------------------------------------------- /packages/vue-components/dist/es5/base.js: -------------------------------------------------------------------------------- 1 | import { buildConfigSetter } from '@elux/core'; 2 | import { inject, shallowReactive, watch } from 'vue'; 3 | export var EluxContextKey = '__EluxContext__'; 4 | export var EluxStoreContextKey = '__EluxStoreContext__'; 5 | export function UseRouter() { 6 | var _inject = inject(EluxContextKey, {}), 7 | router = _inject.router; 8 | 9 | return router; 10 | } 11 | export function UseStore() { 12 | var _inject2 = inject(EluxStoreContextKey, {}), 13 | store = _inject2.store; 14 | 15 | return store; 16 | } 17 | export var vueComponentsConfig = { 18 | renderToString: undefined 19 | }; 20 | export var setVueComponentsConfig = buildConfigSetter(vueComponentsConfig); 21 | export function connectStore(mapStateToProps) { 22 | if (mapStateToProps === void 0) { 23 | mapStateToProps = function mapStateToProps() { 24 | return {}; 25 | }; 26 | } 27 | 28 | var store = UseStore(); 29 | var storeProps = shallowReactive({}); 30 | watch(function () { 31 | return mapStateToProps(store.state); 32 | }, function (val) { 33 | return Object.assign(storeProps, val, { 34 | dispatch: store.dispatch 35 | }); 36 | }, { 37 | immediate: true 38 | }); 39 | return storeProps; 40 | } -------------------------------------------------------------------------------- /packages/vue-components/dist/es5/index.js: -------------------------------------------------------------------------------- 1 | import { reactive } from 'vue'; 2 | import { setCoreConfig } from '@elux/core'; 3 | import AppRender from './App'; 4 | import { UseRouter, UseStore } from './base'; 5 | import { LoadComponent, LoadComponentOnError, LoadComponentOnLoading } from './LoadComponent'; 6 | setCoreConfig({ 7 | MutableData: true, 8 | StoreInitState: function StoreInitState() { 9 | return reactive({}); 10 | }, 11 | UseStore: UseStore, 12 | UseRouter: UseRouter, 13 | AppRender: AppRender, 14 | LoadComponent: LoadComponent, 15 | LoadComponentOnError: LoadComponentOnError, 16 | LoadComponentOnLoading: LoadComponentOnLoading 17 | }); 18 | export { connectStore, setVueComponentsConfig } from './base'; 19 | export { EWindow } from './EWindow'; 20 | export { RouterComponent } from './Router'; 21 | export { DocumentHead } from './DocumentHead'; 22 | export { Switch } from './Switch'; 23 | export { Else } from './Else'; 24 | export { Link } from './Link'; -------------------------------------------------------------------------------- /packages/vue-components/dist/es6/App.js: -------------------------------------------------------------------------------- 1 | import { createVNode as _createVNode } from "vue"; 2 | import { env } from '@elux/core'; 3 | import { EluxContextKey, vueComponentsConfig } from './base'; 4 | const AppRender = { 5 | toDocument(id, eluxContext, fromSSR, app) { 6 | app.provide(EluxContextKey, eluxContext); 7 | 8 | if (process.env.NODE_ENV === 'development' && env.__VUE_DEVTOOLS_GLOBAL_HOOK__) { 9 | env.__VUE_DEVTOOLS_GLOBAL_HOOK__.Vue = app; 10 | } 11 | 12 | app.mount(`#${id}`); 13 | }, 14 | 15 | toString(id, eluxContext, app) { 16 | app.provide(EluxContextKey, eluxContext); 17 | return vueComponentsConfig.renderToString(app); 18 | }, 19 | 20 | toProvider(eluxContext, app) { 21 | app.provide(EluxContextKey, eluxContext); 22 | return () => _createVNode("div", null, null); 23 | } 24 | 25 | }; 26 | export default AppRender; -------------------------------------------------------------------------------- /packages/vue-components/dist/es6/DocumentHead.js: -------------------------------------------------------------------------------- 1 | import { coreConfig } from '@elux/core'; 2 | import { computed, defineComponent } from 'vue'; 3 | export const DocumentHead = defineComponent({ 4 | name: 'EluxDocumentHead', 5 | props: ['title', 'html'], 6 | 7 | setup(props) { 8 | const documentHead = computed(() => { 9 | let documentHead = props.html || ''; 10 | 11 | if (props.title) { 12 | if (/.*?<\/title>/.test(documentHead)) { 13 | documentHead = documentHead.replace(/<title>.*?<\/title>/, `<title>${props.title}`); 14 | } else { 15 | documentHead = `${props.title}` + documentHead; 16 | } 17 | } 18 | 19 | return documentHead; 20 | }); 21 | const router = coreConfig.UseRouter(); 22 | return () => { 23 | router.setDocumentHead(documentHead.value); 24 | return null; 25 | }; 26 | } 27 | 28 | }); -------------------------------------------------------------------------------- /packages/vue-components/dist/es6/EWindow.js: -------------------------------------------------------------------------------- 1 | import { getEntryComponent } from '@elux/core'; 2 | import { defineComponent, h, provide, shallowReactive, watch } from 'vue'; 3 | import { EluxStoreContextKey } from './base'; 4 | export const EWindow = defineComponent({ 5 | name: 'EluxWindow', 6 | props: ['store'], 7 | 8 | setup(props) { 9 | const AppView = getEntryComponent(); 10 | const store = props.store; 11 | const { 12 | uid, 13 | sid, 14 | state, 15 | dispatch, 16 | mount 17 | } = store; 18 | const storeRef = shallowReactive({ 19 | uid, 20 | sid, 21 | state, 22 | dispatch: dispatch.bind(store), 23 | mount: mount.bind(store) 24 | }); 25 | const storeContext = { 26 | store: storeRef 27 | }; 28 | provide(EluxStoreContextKey, storeContext); 29 | watch(() => props.store, store => { 30 | const { 31 | uid, 32 | sid, 33 | state, 34 | dispatch 35 | } = store; 36 | Object.assign(storeRef, { 37 | uid, 38 | sid, 39 | state, 40 | dispatch: dispatch.bind(store), 41 | mount: mount.bind(store) 42 | }); 43 | }); 44 | return () => h(AppView, null); 45 | } 46 | 47 | }); -------------------------------------------------------------------------------- /packages/vue-components/dist/es6/Else.js: -------------------------------------------------------------------------------- 1 | import { Comment, Fragment, h } from 'vue'; 2 | export const Else = function (props, context) { 3 | const arr = []; 4 | const children = context.slots.default ? context.slots.default() : []; 5 | children.forEach(item => { 6 | if (item.type !== Comment) { 7 | arr.push(item); 8 | } 9 | }); 10 | 11 | if (arr.length > 0) { 12 | return h(Fragment, null, arr); 13 | } 14 | 15 | return h(Fragment, null, props.elseView ? [props.elseView] : context.slots.elseView ? context.slots.elseView() : []); 16 | }; 17 | Else.displayName = 'EluxElse'; -------------------------------------------------------------------------------- /packages/vue-components/dist/es6/Switch.js: -------------------------------------------------------------------------------- 1 | import { Comment, Fragment, h } from 'vue'; 2 | export const Switch = function (props, context) { 3 | const arr = []; 4 | const children = context.slots.default ? context.slots.default() : []; 5 | children.forEach(item => { 6 | if (item.type !== Comment) { 7 | arr.push(item); 8 | } 9 | }); 10 | 11 | if (arr.length > 0) { 12 | return h(Fragment, null, [arr[0]]); 13 | } 14 | 15 | return h(Fragment, null, props.elseView ? [props.elseView] : context.slots.elseView ? context.slots.elseView() : []); 16 | }; 17 | Switch.displayName = 'EluxSwitch'; -------------------------------------------------------------------------------- /packages/vue-components/dist/es6/base.js: -------------------------------------------------------------------------------- 1 | import { buildConfigSetter } from '@elux/core'; 2 | import { inject, shallowReactive, watch } from 'vue'; 3 | export const EluxContextKey = '__EluxContext__'; 4 | export const EluxStoreContextKey = '__EluxStoreContext__'; 5 | export function UseRouter() { 6 | const { 7 | router 8 | } = inject(EluxContextKey, {}); 9 | return router; 10 | } 11 | export function UseStore() { 12 | const { 13 | store 14 | } = inject(EluxStoreContextKey, {}); 15 | return store; 16 | } 17 | export const vueComponentsConfig = { 18 | renderToString: undefined 19 | }; 20 | export const setVueComponentsConfig = buildConfigSetter(vueComponentsConfig); 21 | export function connectStore(mapStateToProps = () => ({})) { 22 | const store = UseStore(); 23 | const storeProps = shallowReactive({}); 24 | watch(() => mapStateToProps(store.state), val => Object.assign(storeProps, val, { 25 | dispatch: store.dispatch 26 | }), { 27 | immediate: true 28 | }); 29 | return storeProps; 30 | } -------------------------------------------------------------------------------- /packages/vue-components/dist/es6/index.js: -------------------------------------------------------------------------------- 1 | import { reactive } from 'vue'; 2 | import { setCoreConfig } from '@elux/core'; 3 | import AppRender from './App'; 4 | import { UseRouter, UseStore } from './base'; 5 | import { LoadComponent, LoadComponentOnError, LoadComponentOnLoading } from './LoadComponent'; 6 | setCoreConfig({ 7 | MutableData: true, 8 | StoreInitState: () => reactive({}), 9 | UseStore, 10 | UseRouter, 11 | AppRender, 12 | LoadComponent, 13 | LoadComponentOnError, 14 | LoadComponentOnLoading 15 | }); 16 | export { connectStore, setVueComponentsConfig } from './base'; 17 | export { EWindow } from './EWindow'; 18 | export { RouterComponent } from './Router'; 19 | export { DocumentHead } from './DocumentHead'; 20 | export { Switch } from './Switch'; 21 | export { Else } from './Else'; 22 | export { Link } from './Link'; -------------------------------------------------------------------------------- /packages/vue-components/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@elux/vue-components", 3 | "version": "2.6.3", 4 | "description": "The practice of elux on vue", 5 | "repository": "https://github.com/hiisea/elux/tree/master/packages/vue-components", 6 | "author": "hiisea ", 7 | "license": "MIT", 8 | "publishConfig": { 9 | "access": "public" 10 | }, 11 | "engines": { 12 | "node": ">=14.0.0" 13 | }, 14 | "main": "dist/es5/index.js", 15 | "module": "dist/es6/index.js", 16 | "types": "types/", 17 | "files": [ 18 | "types/", 19 | "dist/" 20 | ], 21 | "scripts": { 22 | "eslint": "cross-env NODE_ENV=production eslint --fix --cache **/*.{js,ts,tsx}", 23 | "build:types": "rimraf ./types && tsc --build ./src", 24 | "build:es6": "cross-env NODE_TAG=es6 babel ./src --out-dir ./dist/es6 --extensions \".ts,.tsx\"", 25 | "build:es5": "cross-env NODE_TAG=es5 babel ./src --out-dir ./dist/es5 --extensions \".ts,.tsx\"", 26 | "build": "yarn build:types && rimraf ./dist && yarn build:es6 && yarn build:es5" 27 | }, 28 | "peerDependencies": { 29 | "vue": "^3.0.0" 30 | }, 31 | "dependencies": { 32 | "@elux/core": "^2.6.3" 33 | }, 34 | "gitHead": "db6eb1314ef3e6abf5b7014495f441911c4cdd28" 35 | } 36 | -------------------------------------------------------------------------------- /packages/vue-components/src/.eslintrc.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | root: true, 3 | extends: ['plugin:@elux/vue'], 4 | env: { 5 | browser: false, 6 | node: true, 7 | }, 8 | }; 9 | -------------------------------------------------------------------------------- /packages/vue-components/src/App.tsx: -------------------------------------------------------------------------------- 1 | import {EluxContext, env, IAppRender} from '@elux/core'; 2 | import type {App} from 'vue'; 3 | import {EluxContextKey, vueComponentsConfig} from './base'; 4 | 5 | const AppRender: IAppRender = { 6 | toDocument(id, eluxContext, fromSSR, app: App): void { 7 | app.provide(EluxContextKey, eluxContext); 8 | if (process.env.NODE_ENV === 'development' && env.__VUE_DEVTOOLS_GLOBAL_HOOK__) { 9 | env.__VUE_DEVTOOLS_GLOBAL_HOOK__.Vue = app; 10 | } 11 | app.mount(`#${id}`); 12 | }, 13 | toString(id, eluxContext, app: App): Promise { 14 | app.provide(EluxContextKey, eluxContext); 15 | return vueComponentsConfig.renderToString!(app); 16 | }, 17 | toProvider(eluxContext, app: App): Elux.Component<{children: any}> { 18 | app.provide(EluxContextKey, eluxContext); 19 | return () =>
; 20 | }, 21 | }; 22 | 23 | export default AppRender; 24 | -------------------------------------------------------------------------------- /packages/vue-components/src/DocumentHead.ts: -------------------------------------------------------------------------------- 1 | import {coreConfig} from '@elux/core'; 2 | import {computed, defineComponent, FunctionalComponent} from 'vue'; 3 | 4 | /** 5 | * 内置UI组件 6 | * 7 | * @remarks 8 | * 用组件的方式动态修改`内容`,主要是`title/description/keywords`等meta信息,SSR中非常有用 9 | * 10 | * @example 11 | * ```html 12 | * 16 | * ``` 17 | * 18 | * @public 19 | */ 20 | export interface DocumentHeadProps { 21 | title?: string; 22 | html?: string; 23 | } 24 | 25 | /** 26 | * 内置UI组件 27 | * 28 | * @remarks 29 | * 参见:{@link DocumentHeadProps} 30 | * 31 | * @public 32 | */ 33 | export const DocumentHead: FunctionalComponent = defineComponent({ 34 | name: 'EluxDocumentHead', 35 | // eslint-disable-next-line vue/require-prop-types 36 | props: ['title', 'html'], 37 | setup(props: DocumentHeadProps) { 38 | const documentHead = computed(() => { 39 | let documentHead = props.html || ''; 40 | if (props.title) { 41 | if (/.*?<\/title>/.test(documentHead)) { 42 | documentHead = documentHead.replace(/<title>.*?<\/title>/, `<title>${props.title}`); 43 | } else { 44 | documentHead = `${props.title}` + documentHead; 45 | } 46 | } 47 | return documentHead; 48 | }); 49 | const router = coreConfig.UseRouter!(); 50 | return () => { 51 | router.setDocumentHead(documentHead.value); 52 | return null; 53 | }; 54 | }, 55 | }) as any; 56 | -------------------------------------------------------------------------------- /packages/vue-components/src/EWindow.tsx: -------------------------------------------------------------------------------- 1 | /* eslint-disable vue/one-component-per-file */ 2 | import {EluxStoreContext, getEntryComponent, IStore, VStore} from '@elux/core'; 3 | import {defineComponent, h, provide, shallowReactive, watch} from 'vue'; 4 | import {EluxStoreContextKey} from './base'; 5 | 6 | export const EWindow: Elux.Component<{store: IStore}> = defineComponent({ 7 | name: 'EluxWindow', 8 | // eslint-disable-next-line vue/require-prop-types 9 | props: ['store'], 10 | setup(props: {store: IStore}) { 11 | const AppView: Elux.Component = getEntryComponent() as any; 12 | // eslint-disable-next-line vue/no-setup-props-destructure 13 | const store = props.store; 14 | const {uid, sid, state, dispatch, mount} = store; 15 | const storeRef: VStore = shallowReactive({uid, sid, state, dispatch: dispatch.bind(store), mount: mount.bind(store)}); 16 | const storeContext: EluxStoreContext = {store: storeRef}; 17 | provide(EluxStoreContextKey, storeContext); 18 | watch( 19 | () => props.store, 20 | (store) => { 21 | const {uid, sid, state, dispatch} = store; 22 | Object.assign(storeRef, {uid, sid, state, dispatch: dispatch.bind(store), mount: mount.bind(store)}); 23 | } 24 | ); 25 | return () => h(AppView, null); 26 | }, 27 | }) as any; 28 | -------------------------------------------------------------------------------- /packages/vue-components/src/Else.tsx: -------------------------------------------------------------------------------- 1 | import {Comment, Fragment, FunctionalComponent, h, VNode} from 'vue'; 2 | 3 | /** 4 | * 内置UI组件 5 | * 6 | * @remarks 7 | * 用来控制子元素的渲染方式:如果非空子元素大于0,则渲染所有非空子元素,否则将渲染`props.elseView`, 8 | * 与 {@link Switch | ``} 的区别在于:`` 仅渲染非空子元素中的第1个 9 | * 10 | * @example 11 | * ```html 12 | *}> 13 | * {subView === 'detail' && } 14 | * {subView === 'list' && } 15 | * 16 | * ``` 17 | * 18 | * @public 19 | */ 20 | export interface ElseProps { 21 | elseView?: VNode; 22 | } 23 | 24 | /** 25 | * 内置UI组件 26 | * 27 | * @remarks 28 | * 参见:{@link ElseProps} 29 | * 30 | * @public 31 | */ 32 | // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types 33 | export const Else: FunctionalComponent = function ( 34 | props: ElseProps, 35 | context: {slots: {default?: () => VNode[]; elseView?: () => VNode[]}} 36 | ) { 37 | const arr: VNode[] = []; 38 | const children: VNode[] = context.slots.default ? context.slots.default() : []; 39 | children.forEach((item) => { 40 | if (item.type !== Comment) { 41 | arr.push(item); 42 | } 43 | }); 44 | if (arr.length > 0) { 45 | return h(Fragment, null, arr); 46 | } 47 | 48 | return h(Fragment, null, props.elseView ? [props.elseView] : context.slots.elseView ? context.slots.elseView() : []); 49 | } as any; 50 | 51 | Else.displayName = 'EluxElse'; 52 | -------------------------------------------------------------------------------- /packages/vue-components/src/Switch.tsx: -------------------------------------------------------------------------------- 1 | import {Comment, Fragment, FunctionalComponent, h, VNode} from 'vue'; 2 | 3 | /** 4 | * 内置UI组件 5 | * 6 | * @remarks 7 | * 用来控制子元素的渲染方式:如果非空子元素大于0,则渲染第一个非空子元素,否则将渲染`props.elseView`, 8 | * 与 {@link Else | ``} 的区别在于:`` 渲染所有非空子元素 9 | * 10 | * @example 11 | * ```html 12 | *}> 13 | * {subView === 'detail' && } 14 | * {subView === 'list' && } 15 | * 16 | * ``` 17 | * 18 | * @public 19 | */ 20 | export interface SwitchProps { 21 | elseView?: VNode; 22 | } 23 | 24 | /** 25 | * 内置UI组件 26 | * 27 | * @remarks 28 | * 参见:{@link SwitchProps} 29 | * 30 | * @public 31 | */ 32 | // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types 33 | export const Switch: FunctionalComponent = function ( 34 | props: SwitchProps, 35 | context: {slots: {default?: () => VNode[]; elseView?: () => VNode[]}} 36 | ) { 37 | const arr: VNode[] = []; 38 | const children: VNode[] = context.slots.default ? context.slots.default() : []; 39 | children.forEach((item) => { 40 | if (item.type !== Comment) { 41 | arr.push(item); 42 | } 43 | }); 44 | if (arr.length > 0) { 45 | return h(Fragment, null, [arr[0]]); 46 | } 47 | 48 | return h(Fragment, null, props.elseView ? [props.elseView] : context.slots.elseView ? context.slots.elseView() : []); 49 | } as any; 50 | 51 | Switch.displayName = 'EluxSwitch'; 52 | 53 | // export default defineComponent({ 54 | // props: { 55 | // elseView: { 56 | // type: Object as PropType, 57 | // }, 58 | // }, 59 | // setup(props, {slots}) { 60 | // return () => { 61 | // const arr: VNode[] = []; 62 | // 63 | // children.forEach((item) => { 64 | // if (item.type !== Comment) { 65 | // arr.push(item); 66 | // } 67 | // }); 68 | // if (arr.length > 0) { 69 | // return <>{arr[0]}; 70 | // } 71 | // return <>{props.elseView}; 72 | // }; 73 | // }, 74 | // }); 75 | -------------------------------------------------------------------------------- /packages/vue-components/src/base.tsx: -------------------------------------------------------------------------------- 1 | import {buildConfigSetter, Dispatch, EluxContext, EluxStoreContext, IRouter, StoreState, VStore} from '@elux/core'; 2 | import {inject, shallowReactive, watch} from 'vue'; 3 | 4 | export const EluxContextKey = '__EluxContext__'; 5 | export const EluxStoreContextKey = '__EluxStoreContext__'; 6 | 7 | export function UseRouter(): IRouter { 8 | const {router} = inject(EluxContextKey, {} as any); 9 | return router; 10 | } 11 | export function UseStore(): VStore { 12 | const {store} = inject(EluxStoreContextKey, {} as any); 13 | return store; 14 | } 15 | export const vueComponentsConfig: { 16 | renderToString?: (component: any) => Promise; 17 | } = { 18 | renderToString: undefined, 19 | }; 20 | 21 | export const setVueComponentsConfig = buildConfigSetter(vueComponentsConfig); 22 | 23 | /** 24 | * 提供类似于react-redux的connect方法 25 | * 26 | * @param mapStateToProps - state与props之间的映射与转换 27 | * 28 | * @public 29 | */ 30 | // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types 31 | export function connectStore>(mapStateToProps: (state: S) => P = () => ({} as P)) { 32 | const store = UseStore(); 33 | const storeProps = shallowReactive

({} as any); 34 | watch( 35 | () => mapStateToProps(store.state as any), 36 | (val) => Object.assign(storeProps, val, {dispatch: store.dispatch}), 37 | {immediate: true} 38 | ); 39 | return storeProps; 40 | } 41 | -------------------------------------------------------------------------------- /packages/vue-components/src/index.ts: -------------------------------------------------------------------------------- 1 | import {reactive} from 'vue'; 2 | 3 | import {setCoreConfig} from '@elux/core'; 4 | 5 | import AppRender from './App'; 6 | import {UseRouter, UseStore} from './base'; 7 | import {LoadComponent, LoadComponentOnError, LoadComponentOnLoading} from './LoadComponent'; 8 | 9 | setCoreConfig({ 10 | MutableData: true, 11 | StoreInitState: () => reactive({}), 12 | UseStore, 13 | UseRouter, 14 | AppRender, 15 | LoadComponent, 16 | LoadComponentOnError, 17 | LoadComponentOnLoading, 18 | }); 19 | 20 | export {connectStore, setVueComponentsConfig} from './base'; 21 | export {EWindow} from './EWindow'; 22 | export {RouterComponent} from './Router'; 23 | export {DocumentHead} from './DocumentHead'; 24 | export {Switch} from './Switch'; 25 | export {Else} from './Else'; 26 | export {Link} from './Link'; 27 | export type {DocumentHeadProps} from './DocumentHead'; 28 | export type {ElseProps} from './Else'; 29 | export type {SwitchProps} from './Switch'; 30 | export type {LinkProps} from './Link'; 31 | -------------------------------------------------------------------------------- /packages/vue-components/src/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "@elux/babel-preset/tsconfig.esm.json", 3 | "compilerOptions": { 4 | "rootDir": "./", 5 | "declarationDir": "../types", 6 | "emitDeclarationOnly": true, 7 | "removeComments": false, 8 | "declarationMap": true, 9 | "jsx": "preserve" 10 | }, 11 | "include": ["./"], 12 | "exclude": [] 13 | } 14 | -------------------------------------------------------------------------------- /packages/vue-components/types/App.d.ts: -------------------------------------------------------------------------------- 1 | import { IAppRender } from '@elux/core'; 2 | declare const AppRender: IAppRender; 3 | export default AppRender; 4 | //# sourceMappingURL=App.d.ts.map -------------------------------------------------------------------------------- /packages/vue-components/types/App.d.ts.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"App.d.ts","sourceRoot":"","sources":["../src/App.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAmB,UAAU,EAAC,MAAM,YAAY,CAAC;AAIxD,QAAA,MAAM,SAAS,EAAE,UAgBhB,CAAC;AAEF,eAAe,SAAS,CAAC"} -------------------------------------------------------------------------------- /packages/vue-components/types/DocumentHead.d.ts: -------------------------------------------------------------------------------- 1 | import { FunctionalComponent } from 'vue'; 2 | /** 3 | * 内置UI组件 4 | * 5 | * @remarks 6 | * 用组件的方式动态修改`内容`,主要是`title/description/keywords`等meta信息,SSR中非常有用 7 | * 8 | * @example 9 | * ```html 10 | * 14 | * ``` 15 | * 16 | * @public 17 | */ 18 | export interface DocumentHeadProps { 19 | title?: string; 20 | html?: string; 21 | } 22 | /** 23 | * 内置UI组件 24 | * 25 | * @remarks 26 | * 参见:{@link DocumentHeadProps} 27 | * 28 | * @public 29 | */ 30 | export declare const DocumentHead: FunctionalComponent; 31 | //# sourceMappingURL=DocumentHead.d.ts.map -------------------------------------------------------------------------------- /packages/vue-components/types/DocumentHead.d.ts.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"DocumentHead.d.ts","sourceRoot":"","sources":["../src/DocumentHead.ts"],"names":[],"mappings":"AACA,OAAO,EAA4B,mBAAmB,EAAC,MAAM,KAAK,CAAC;AAEnE;;;;;;;;;;;;;;;GAeG;AACH,MAAM,WAAW,iBAAiB;IAChC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED;;;;;;;GAOG;AACH,eAAO,MAAM,YAAY,EAAE,mBAAmB,CAAC,iBAAiB,CAsBvD,CAAC"} -------------------------------------------------------------------------------- /packages/vue-components/types/EWindow.d.ts: -------------------------------------------------------------------------------- 1 | import { IStore } from '@elux/core'; 2 | export declare const EWindow: Elux.Component<{ 3 | store: IStore; 4 | }>; 5 | //# sourceMappingURL=EWindow.d.ts.map -------------------------------------------------------------------------------- /packages/vue-components/types/EWindow.d.ts.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"EWindow.d.ts","sourceRoot":"","sources":["../src/EWindow.tsx"],"names":[],"mappings":"AACA,OAAO,EAAsC,MAAM,EAAS,MAAM,YAAY,CAAC;AAI/E,eAAO,MAAM,OAAO,EAAE,IAAI,CAAC,SAAS,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAC,CAqB3C,CAAC"} -------------------------------------------------------------------------------- /packages/vue-components/types/Else.d.ts: -------------------------------------------------------------------------------- 1 | import { FunctionalComponent, VNode } from 'vue'; 2 | /** 3 | * 内置UI组件 4 | * 5 | * @remarks 6 | * 用来控制子元素的渲染方式:如果非空子元素大于0,则渲染所有非空子元素,否则将渲染`props.elseView`, 7 | * 与 {@link Switch | ``} 的区别在于:`` 仅渲染非空子元素中的第1个 8 | * 9 | * @example 10 | * ```html 11 | *}> 12 | * {subView === 'detail' && } 13 | * {subView === 'list' && } 14 | * 15 | * ``` 16 | * 17 | * @public 18 | */ 19 | export interface ElseProps { 20 | elseView?: VNode; 21 | } 22 | /** 23 | * 内置UI组件 24 | * 25 | * @remarks 26 | * 参见:{@link ElseProps} 27 | * 28 | * @public 29 | */ 30 | export declare const Else: FunctionalComponent; 31 | //# sourceMappingURL=Else.d.ts.map -------------------------------------------------------------------------------- /packages/vue-components/types/Else.d.ts.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"Else.d.ts","sourceRoot":"","sources":["../src/Else.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAoB,mBAAmB,EAAK,KAAK,EAAC,MAAM,KAAK,CAAC;AAErE;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,WAAW,SAAS;IACxB,QAAQ,CAAC,EAAE,KAAK,CAAC;CAClB;AAED;;;;;;;GAOG;AAEH,eAAO,MAAM,IAAI,EAAE,mBAAmB,CAAC,SAAS,CAgBxC,CAAC"} -------------------------------------------------------------------------------- /packages/vue-components/types/Link.d.ts: -------------------------------------------------------------------------------- 1 | import { IRouteRecord, Location, RouteAction, RouteTarget } from '@elux/core'; 2 | import { Events, FunctionalComponent, HTMLAttributes } from 'vue'; 3 | /** 4 | * 内置UI组件 5 | * 6 | * @remarks 7 | * 类似于Html标签``,用组件的方式执行路由跳转,参见 {@link IRouter} 8 | * 9 | * @example 10 | * ```html 11 | *home 12 | * ``` 13 | * 14 | * @public 15 | */ 16 | export interface LinkProps extends HTMLAttributes { 17 | /** 18 | * 指定跳转的url或后退步数 19 | */ 20 | to: number | string | ((record: IRouteRecord) => boolean) | Partial; 21 | /** 22 | * 路由跳转动作 23 | */ 24 | action: Exclude; 25 | /** 26 | * 指定要操作的历史栈,默认`page` 27 | */ 28 | target?: RouteTarget; 29 | /** 30 | * 指定路由窗口的class 31 | */ 32 | cname?: string; 33 | /** 34 | * 如果disabled将不执行路由及onClick事件 35 | */ 36 | disabled?: boolean; 37 | /** 38 | * 是否强制刷新dom,默认false 39 | */ 40 | refresh?: boolean; 41 | /** 42 | * 点击事件 43 | */ 44 | onClick?(event: Events['onClick']): void; 45 | /** 46 | * 路由后退时如果溢出,将重定向到此Url 47 | */ 48 | overflowRedirect?: string; 49 | } 50 | /** 51 | * 内置UI组件 52 | * 53 | * @remarks 54 | * 参见:{@link LinkProps} 55 | * 56 | * @public 57 | */ 58 | export declare const Link: FunctionalComponent; 59 | //# sourceMappingURL=Link.d.ts.map -------------------------------------------------------------------------------- /packages/vue-components/types/Link.d.ts.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"Link.d.ts","sourceRoot":"","sources":["../src/Link.ts"],"names":[],"mappings":"AAAA,OAAO,EAAa,YAAY,EAAE,QAAQ,EAAE,WAAW,EAAE,WAAW,EAAiB,MAAM,YAAY,CAAC;AACxG,OAAO,EAA4B,MAAM,EAAE,mBAAmB,EAAK,cAAc,EAAC,MAAM,KAAK,CAAC;AAE9F;;;;;;;;;;;;GAYG;AACH,MAAM,WAAW,SAAU,SAAQ,cAAc;IAC/C;;OAEG;IACH,EAAE,EAAE,MAAM,GAAG,MAAM,GAAG,CAAC,CAAC,MAAM,EAAE,YAAY,KAAK,OAAO,CAAC,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC;IAC9E;;OAEG;IACH,MAAM,EAAE,OAAO,CAAC,WAAW,EAAE,MAAM,CAAC,CAAC;IACrC;;OAEG;IACH,MAAM,CAAC,EAAE,WAAW,CAAC;IACrB;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;OAEG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB;;OAEG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB;;OAEG;IACH,OAAO,CAAC,CAAC,KAAK,EAAE,MAAM,CAAC,SAAS,CAAC,GAAG,IAAI,CAAC;IACzC;;OAEG;IACH,gBAAgB,CAAC,EAAE,MAAM,CAAC;CAC3B;AAED;;;;;;;GAOG;AAEH,eAAO,MAAM,IAAI,EAAE,mBAAmB,CAAC,SAAS,CAmDvC,CAAC"} -------------------------------------------------------------------------------- /packages/vue-components/types/Router.d.ts: -------------------------------------------------------------------------------- 1 | export declare const RouterComponent: import("vue").DefineComponent<{}, () => JSX.Element, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, import("vue").EmitsOptions, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly>, {}>; 2 | //# sourceMappingURL=Router.d.ts.map -------------------------------------------------------------------------------- /packages/vue-components/types/Router.d.ts.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"Router.d.ts","sourceRoot":"","sources":["../src/Router.tsx"],"names":[],"mappings":"AAIA,eAAO,MAAM,eAAe,uUA+E1B,CAAC"} -------------------------------------------------------------------------------- /packages/vue-components/types/Switch.d.ts: -------------------------------------------------------------------------------- 1 | import { FunctionalComponent, VNode } from 'vue'; 2 | /** 3 | * 内置UI组件 4 | * 5 | * @remarks 6 | * 用来控制子元素的渲染方式:如果非空子元素大于0,则渲染第一个非空子元素,否则将渲染`props.elseView`, 7 | * 与 {@link Else | ``} 的区别在于:`` 渲染所有非空子元素 8 | * 9 | * @example 10 | * ```html 11 | *}> 12 | * {subView === 'detail' && } 13 | * {subView === 'list' && } 14 | * 15 | * ``` 16 | * 17 | * @public 18 | */ 19 | export interface SwitchProps { 20 | elseView?: VNode; 21 | } 22 | /** 23 | * 内置UI组件 24 | * 25 | * @remarks 26 | * 参见:{@link SwitchProps} 27 | * 28 | * @public 29 | */ 30 | export declare const Switch: FunctionalComponent; 31 | //# sourceMappingURL=Switch.d.ts.map -------------------------------------------------------------------------------- /packages/vue-components/types/Switch.d.ts.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"Switch.d.ts","sourceRoot":"","sources":["../src/Switch.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAoB,mBAAmB,EAAK,KAAK,EAAC,MAAM,KAAK,CAAC;AAErE;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,WAAW,WAAW;IAC1B,QAAQ,CAAC,EAAE,KAAK,CAAC;CAClB;AAED;;;;;;;GAOG;AAEH,eAAO,MAAM,MAAM,EAAE,mBAAmB,CAAC,WAAW,CAgB5C,CAAC"} -------------------------------------------------------------------------------- /packages/vue-components/types/base.d.ts: -------------------------------------------------------------------------------- 1 | import { Dispatch, IRouter, StoreState, VStore } from '@elux/core'; 2 | export declare const EluxContextKey = "__EluxContext__"; 3 | export declare const EluxStoreContextKey = "__EluxStoreContext__"; 4 | export declare function UseRouter(): IRouter; 5 | export declare function UseStore(): VStore; 6 | export declare const vueComponentsConfig: { 7 | renderToString?: (component: any) => Promise; 8 | }; 9 | export declare const setVueComponentsConfig: (config: Partial<{ 10 | renderToString?: ((component: any) => Promise) | undefined; 11 | }>) => void; 12 | /** 13 | * 提供类似于react-redux的connect方法 14 | * 15 | * @param mapStateToProps - state与props之间的映射与转换 16 | * 17 | * @public 18 | */ 19 | export declare function connectStore>(mapStateToProps?: (state: S) => P): import("vue").ShallowReactive

; 22 | //# sourceMappingURL=base.d.ts.map -------------------------------------------------------------------------------- /packages/vue-components/types/base.d.ts.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"base.d.ts","sourceRoot":"","sources":["../src/base.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAoB,QAAQ,EAAiC,OAAO,EAAE,UAAU,EAAE,MAAM,EAAC,MAAM,YAAY,CAAC;AAGnH,eAAO,MAAM,cAAc,oBAAoB,CAAC;AAChD,eAAO,MAAM,mBAAmB,yBAAyB,CAAC;AAE1D,wBAAgB,SAAS,IAAI,OAAO,CAGnC;AACD,wBAAgB,QAAQ,IAAI,MAAM,CAGjC;AACD,eAAO,MAAM,mBAAmB,EAAE;IAChC,cAAc,CAAC,EAAE,CAAC,SAAS,EAAE,GAAG,KAAK,OAAO,CAAC,MAAM,CAAC,CAAC;CAGtD,CAAC;AAEF,eAAO,MAAM,sBAAsB;kCALJ,GAAG,KAAK,QAAQ,MAAM,CAAC;WAKsB,CAAC;AAE7E;;;;;;GAMG;AAEH,wBAAgB,YAAY,CAAC,CAAC,SAAS,UAAU,EAAE,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE,eAAe,GAAE,CAAC,KAAK,EAAE,CAAC,KAAK,CAAmB;cAEhF,QAAQ;GAO3D"} -------------------------------------------------------------------------------- /packages/vue-components/types/index.d.ts: -------------------------------------------------------------------------------- 1 | export { connectStore, setVueComponentsConfig } from './base'; 2 | export { EWindow } from './EWindow'; 3 | export { RouterComponent } from './Router'; 4 | export { DocumentHead } from './DocumentHead'; 5 | export { Switch } from './Switch'; 6 | export { Else } from './Else'; 7 | export { Link } from './Link'; 8 | export type { DocumentHeadProps } from './DocumentHead'; 9 | export type { ElseProps } from './Else'; 10 | export type { SwitchProps } from './Switch'; 11 | export type { LinkProps } from './Link'; 12 | //# sourceMappingURL=index.d.ts.map -------------------------------------------------------------------------------- /packages/vue-components/types/index.d.ts.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAmBA,OAAO,EAAC,YAAY,EAAE,sBAAsB,EAAC,MAAM,QAAQ,CAAC;AAC5D,OAAO,EAAC,OAAO,EAAC,MAAM,WAAW,CAAC;AAClC,OAAO,EAAC,eAAe,EAAC,MAAM,UAAU,CAAC;AACzC,OAAO,EAAC,YAAY,EAAC,MAAM,gBAAgB,CAAC;AAC5C,OAAO,EAAC,MAAM,EAAC,MAAM,UAAU,CAAC;AAChC,OAAO,EAAC,IAAI,EAAC,MAAM,QAAQ,CAAC;AAC5B,OAAO,EAAC,IAAI,EAAC,MAAM,QAAQ,CAAC;AAC5B,YAAY,EAAC,iBAAiB,EAAC,MAAM,gBAAgB,CAAC;AACtD,YAAY,EAAC,SAAS,EAAC,MAAM,QAAQ,CAAC;AACtC,YAAY,EAAC,WAAW,EAAC,MAAM,UAAU,CAAC;AAC1C,YAAY,EAAC,SAAS,EAAC,MAAM,QAAQ,CAAC"} -------------------------------------------------------------------------------- /packages/vue-components/types/loadComponent.d.ts: -------------------------------------------------------------------------------- 1 | import { ILoadComponent } from '@elux/core'; 2 | export declare const LoadComponentOnError: Elux.Component<{ 3 | message: string; 4 | }>; 5 | export declare const LoadComponentOnLoading: Elux.Component; 6 | export declare const LoadComponent: ILoadComponent; 7 | //# sourceMappingURL=LoadComponent.d.ts.map -------------------------------------------------------------------------------- /packages/vue-components/types/loadComponent.d.ts.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"LoadComponent.d.ts","sourceRoot":"","sources":["../src/LoadComponent.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAkB,cAAc,EAA6B,MAAM,YAAY,CAAC;AAGvF,eAAO,MAAM,oBAAoB,EAAE,IAAI,CAAC,SAAS,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAC,CAElE,CAAC;AACF,eAAO,MAAM,sBAAsB,EAAE,IAAI,CAAC,SAAmE,CAAC;AAE9G,eAAO,MAAM,aAAa,EAAE,cAAc,CAAC,GAAG,CAiE7C,CAAC"} -------------------------------------------------------------------------------- /packages/vue-taro/.babelrc.js: -------------------------------------------------------------------------------- 1 | const build = require('../../babelrc.build'); 2 | const config = build('vue'); 3 | module.exports = config; 4 | -------------------------------------------------------------------------------- /packages/vue-taro/README.md: -------------------------------------------------------------------------------- 1 | # Cross platform and cross framework web solutions that based on micro-module and model-driven 2 | 3 | ## [Read Documentation ON Github](https://github.com/hiisea/elux) 4 | -------------------------------------------------------------------------------- /packages/vue-taro/api-extractor.json: -------------------------------------------------------------------------------- 1 | /** 2 | * Config file for API Extractor. For more info, please visit: https://api-extractor.com 3 | */ 4 | { 5 | "$schema": "https://developer.microsoft.com/json-schemas/api-extractor/v7/api-extractor.schema.json", 6 | "projectFolder": "./", 7 | "mainEntryPointFilePath": "/types/index.d.ts", 8 | "bundledPackages": ["@elux/core", "@elux/route-mp", "@elux/app", "@elux/vue-components", "@elux/taro"], 9 | "compiler": { 10 | "tsconfigFilePath": "src/tsconfig.json" 11 | }, 12 | "apiReport": { 13 | "enabled": false 14 | }, 15 | "docModel": { 16 | "enabled": true, 17 | "apiJsonFilePath": "../../api/.vuepress/.api/.api.json" 18 | }, 19 | "dtsRollup": { 20 | "enabled": false 21 | }, 22 | "tsdocMetadata": {}, 23 | "messages": { 24 | "compilerMessageReporting": { 25 | "default": { 26 | "logLevel": "warning" 27 | } 28 | }, 29 | "extractorMessageReporting": { 30 | "default": { 31 | "logLevel": "warning" 32 | }, 33 | "ae-internal-missing-underscore": { 34 | "logLevel": "none" 35 | } 36 | // "ae-missing-release-tag": { 37 | // "logLevel": "none" 38 | // }, 39 | // "ae-forgotten-export": { 40 | // "logLevel": "none" 41 | // } 42 | }, 43 | "tsdocMessageReporting": { 44 | "default": { 45 | "logLevel": "warning" 46 | } 47 | } 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /packages/vue-taro/global/global.d.ts: -------------------------------------------------------------------------------- 1 | declare module '@tarojs/taro' { 2 | const useDidShow: (callback: () => void) => void; 3 | const useDidHide: (callback: () => void) => void; 4 | } 5 | -------------------------------------------------------------------------------- /packages/vue-taro/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@elux/vue-taro", 3 | "version": "2.6.3", 4 | "description": "The practice of vue + taro", 5 | "repository": "https://github.com/hiisea/elux/tree/master/packages/vue-taro", 6 | "author": "hiisea ", 7 | "license": "MIT", 8 | "publishConfig": { 9 | "access": "public" 10 | }, 11 | "engines": { 12 | "node": ">=14.0.0" 13 | }, 14 | "main": "dist/es5/index.js", 15 | "module": "dist/es6/index.js", 16 | "types": "types/", 17 | "files": [ 18 | "runtime/", 19 | "types/", 20 | "dist/" 21 | ], 22 | "scripts": { 23 | "eslint": "cross-env NODE_ENV=production eslint --fix --cache **/*.{js,ts}", 24 | "build:types": "rimraf ./types && tsc --build ./src", 25 | "build:es6": "cross-env NODE_TAG=es6 babel ./src --out-dir ./dist/es6 --extensions \".ts,.tsx\"", 26 | "build:es5": "cross-env NODE_TAG=es5 babel ./src --out-dir ./dist/es5 --extensions \".ts,.tsx\"", 27 | "package:es6": "cross-env NODE_TAG=es6 rollup -c", 28 | "package:es5": "cross-env NODE_TAG=es5 rollup -c", 29 | "api:json": "yarn build:types && api-extractor run", 30 | "build": "yarn build:types && rimraf ./dist && yarn package:es6 && yarn package:es5" 31 | }, 32 | "externals": { 33 | "@elux/core": true, 34 | "@tarojs/taro": true, 35 | "vue": true 36 | }, 37 | "peerDependencies": { 38 | "@tarojs/taro": "^3.4.6", 39 | "vue": "^3.0.0" 40 | }, 41 | "dependencies": { 42 | "@elux/app": "^2.6.3", 43 | "@elux/core": "^2.6.3", 44 | "@elux/route-mp": "^2.6.3", 45 | "@elux/taro": "^2.6.3", 46 | "@elux/vue-components": "^2.6.3" 47 | }, 48 | "gitHead": "db6eb1314ef3e6abf5b7014495f441911c4cdd28" 49 | } 50 | -------------------------------------------------------------------------------- /packages/vue-taro/rollup.config.js: -------------------------------------------------------------------------------- 1 | import build from '../../rollup.build'; 2 | //const config = build(__dirname, undefined, {'regenerator-runtime': require.resolve('./libs/regenerator-runtime')}); 3 | const config = build(__dirname); 4 | export default config; 5 | -------------------------------------------------------------------------------- /packages/vue-taro/src/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "@elux/babel-preset/tsconfig.esm.json", 3 | "compilerOptions": { 4 | "rootDir": "./", 5 | "declarationDir": "../types", 6 | "emitDeclarationOnly": true, 7 | "removeComments": false, 8 | "declarationMap": true, 9 | "types": ["../global/global"] 10 | }, 11 | "include": ["./"], 12 | "exclude": [] 13 | } 14 | -------------------------------------------------------------------------------- /packages/vue-taro/types/index.d.ts: -------------------------------------------------------------------------------- 1 | import { App } from 'vue'; 2 | import { AppConfig } from '@elux/app'; 3 | export { connectStore, DocumentHead, Else, Link, Switch } from '@elux/vue-components'; 4 | export type { DocumentHeadProps, ElseProps, LinkProps, SwitchProps } from '@elux/vue-components'; 5 | export * from '@elux/app'; 6 | /** 7 | * 小程序Page页面 8 | * 9 | * @public 10 | */ 11 | export declare const EluxPage: Elux.Component; 12 | /** 13 | * 创建应用 14 | * 15 | * @remarks 16 | * 应用唯一的创建入口 17 | * 18 | * @param appConfig - 应用配置 19 | * @param appOptions - 应用生命周期钩子 20 | * 21 | * @returns 22 | * 返回Vue实例 23 | * 24 | * @example 25 | * ```js 26 | * createApp(config, { 27 | * onLaunch(){ 28 | * } 29 | * }) 30 | * ``` 31 | * 32 | * @public 33 | */ 34 | export declare function createApp(appConfig: AppConfig, appOptions?: Record): App; 35 | //# sourceMappingURL=index.d.ts.map -------------------------------------------------------------------------------- /packages/vue-taro/types/index.d.ts.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAC,GAAG,EAAmE,MAAM,KAAK,CAAC;AAE1F,OAAO,EAAC,SAAS,EAAa,MAAM,WAAW,CAAC;AAOhD,OAAO,EAAC,YAAY,EAAE,YAAY,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAC,MAAM,sBAAsB,CAAC;AACpF,YAAY,EAAC,iBAAiB,EAAE,SAAS,EAAE,SAAS,EAAE,WAAW,EAAC,MAAM,sBAAsB,CAAC;AAE/F,cAAc,WAAW,CAAC;AAM1B;;;;GAIG;AACH,eAAO,MAAM,QAAQ,EAAE,IAAI,CAAC,SA2BnB,CAAC;AAIV;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,SAAS,CAAC,SAAS,EAAE,SAAS,EAAE,UAAU,GAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAM,GAAG,GAAG,CAazF"} -------------------------------------------------------------------------------- /packages/vue-web/.babelrc.js: -------------------------------------------------------------------------------- 1 | const build = require('../../babelrc.build'); 2 | const config = build(); 3 | module.exports = config; 4 | 5 | -------------------------------------------------------------------------------- /packages/vue-web/README.md: -------------------------------------------------------------------------------- 1 | # Cross platform and cross framework web solutions that based on micro-module and model-driven 2 | 3 | ## [Read Documentation ON Github](https://github.com/hiisea/elux) 4 | -------------------------------------------------------------------------------- /packages/vue-web/api-extractor.json: -------------------------------------------------------------------------------- 1 | /** 2 | * Config file for API Extractor. For more info, please visit: https://api-extractor.com 3 | */ 4 | { 5 | "$schema": "https://developer.microsoft.com/json-schemas/api-extractor/v7/api-extractor.schema.json", 6 | 7 | "projectFolder": "./", 8 | 9 | "mainEntryPointFilePath": "/types/index.d.ts", 10 | 11 | "bundledPackages": ["@elux/core", "@elux/route-browser", "@elux/app", "@elux/vue-components"], 12 | 13 | "compiler": { 14 | "tsconfigFilePath": "src/tsconfig.json" 15 | }, 16 | 17 | "apiReport": { 18 | "enabled": false 19 | }, 20 | 21 | "docModel": { 22 | "enabled": true, 23 | "apiJsonFilePath": "../../api/.vuepress/.api/.api.json" 24 | }, 25 | 26 | "dtsRollup": { 27 | "enabled": false 28 | }, 29 | 30 | "tsdocMetadata": {}, 31 | 32 | "messages": { 33 | "compilerMessageReporting": { 34 | "default": { 35 | "logLevel": "warning" 36 | } 37 | }, 38 | "extractorMessageReporting": { 39 | "default": { 40 | "logLevel": "warning" 41 | }, 42 | "ae-internal-missing-underscore": { 43 | "logLevel": "none" 44 | } 45 | // "ae-missing-release-tag": { 46 | // "logLevel": "none" 47 | // }, 48 | // "ae-forgotten-export": { 49 | // "logLevel": "none" 50 | // } 51 | }, 52 | 53 | "tsdocMessageReporting": { 54 | "default": { 55 | "logLevel": "warning" 56 | } 57 | } 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /packages/vue-web/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@elux/vue-web", 3 | "version": "2.6.3", 4 | "description": "The practice of elux on vue-web", 5 | "repository": "https://github.com/hiisea/elux/tree/master/packages/vue-web", 6 | "author": "hiisea ", 7 | "license": "MIT", 8 | "publishConfig": { 9 | "access": "public" 10 | }, 11 | "engines": { 12 | "node": ">=14.0.0" 13 | }, 14 | "main": "dist/es5/index.js", 15 | "module": "dist/es6/index.js", 16 | "browser": { 17 | "./server.js": "./server.mock.js" 18 | }, 19 | "types": "types/", 20 | "files": [ 21 | "types/", 22 | "dist/", 23 | "server.js", 24 | "server.mock.js" 25 | ], 26 | "scripts": { 27 | "eslint": "cross-env NODE_ENV=production eslint --fix --cache **/*.{js,ts}", 28 | "build:types": "rimraf ./types && tsc --build ./src", 29 | "build:es6": "cross-env NODE_TAG=es6 babel ./src --out-dir ./dist/es6 --extensions \".ts\"", 30 | "build:es5": "cross-env NODE_TAG=es5 babel ./src --out-dir ./dist/es5 --extensions \".ts\"", 31 | "package:es6": "cross-env NODE_TAG=es6 rollup -c", 32 | "package:es5": "cross-env NODE_TAG=es5 rollup -c", 33 | "api:json": "yarn build:types && api-extractor run", 34 | "build": "yarn build:types && rimraf ./dist && yarn package:es6 && yarn package:es5" 35 | }, 36 | "externals": { 37 | "@elux/core": true, 38 | "vue": true, 39 | "@elux/vue-web/server": true 40 | }, 41 | "peerDependencies": { 42 | "vue": "^3.0.0" 43 | }, 44 | "dependencies": { 45 | "@elux/app": "^2.6.3", 46 | "@elux/core": "^2.6.3", 47 | "@elux/route-browser": "^2.6.3", 48 | "@elux/vue-components": "^2.6.3", 49 | "@vue/server-renderer": "^3.0.0" 50 | }, 51 | "gitHead": "db6eb1314ef3e6abf5b7014495f441911c4cdd28" 52 | } 53 | -------------------------------------------------------------------------------- /packages/vue-web/rollup.config.js: -------------------------------------------------------------------------------- 1 | import build from '../../rollup.build'; 2 | const config = build(__dirname); 3 | export default config; 4 | -------------------------------------------------------------------------------- /packages/vue-web/server.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | module.exports = require('@vue/server-renderer'); 4 | -------------------------------------------------------------------------------- /packages/vue-web/server.mock.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | module.exports = { 4 | renderToString: function () { 5 | return Promise.resolve(''); 6 | }, 7 | }; 8 | -------------------------------------------------------------------------------- /packages/vue-web/src/global.d.ts: -------------------------------------------------------------------------------- 1 | declare module '@elux/vue-web/server' { 2 | export function renderToString(component: any): Promise; 3 | } 4 | -------------------------------------------------------------------------------- /packages/vue-web/src/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "@elux/babel-preset/tsconfig.esm.json", 3 | "compilerOptions": { 4 | "rootDir": "./", 5 | "declarationDir": "../types", 6 | "emitDeclarationOnly": true, 7 | "removeComments": false, 8 | "declarationMap": true 9 | }, 10 | "include": ["./"], 11 | "exclude": [] 12 | } 13 | -------------------------------------------------------------------------------- /packages/vue-web/types/index.d.ts: -------------------------------------------------------------------------------- 1 | import { App } from 'vue'; 2 | import { AppConfig } from '@elux/app'; 3 | import { RenderOptions, RouterInitOptions } from '@elux/core'; 4 | export { connectStore, DocumentHead, Else, Link, Switch } from '@elux/vue-components'; 5 | export type { DocumentHeadProps, ElseProps, LinkProps, SwitchProps } from '@elux/vue-components'; 6 | export * from '@elux/app'; 7 | /** 8 | * @public 9 | */ 10 | export declare type EluxApp = App & { 11 | render(options?: RenderOptions): Promise; 12 | }; 13 | /** 14 | * 创建应用(CSR) 15 | * 16 | * @param appConfig - 应用配置 17 | * 18 | * @returns 19 | * 返回包含`render`方法的实例,参见{@link RenderOptions} 20 | * 21 | * @example 22 | * ```js 23 | * createApp(config) 24 | * .render() 25 | * .then(() => { 26 | * const initLoading = document.getElementById('root-loading'); 27 | * if (initLoading) { 28 | * initLoading.parentNode!.removeChild(initLoading); 29 | * } 30 | * }); 31 | * ``` 32 | * 33 | * @public 34 | */ 35 | export declare function createApp(appConfig: AppConfig): EluxApp; 36 | /** 37 | * 创建应用(SSR) 38 | * 39 | * @remarks 40 | * 应用唯一的创建入口,用于服务端渲染(SSR)。客户端渲染(CSR)请使用{@link createApp} 41 | * 42 | * @param appConfig - 应用配置 43 | * @param routerOptions - 原生请求 44 | * 45 | * @returns 46 | * 返回包含`render`方法的下一步实例,参见{@link RenderOptions} 47 | * 48 | * @example 49 | * ```js 50 | * export default function server(request: {url: string}, response: any): Promise { 51 | * return createSSR(moduleGetter, request.url, {request, response}).render(); 52 | * } 53 | * ``` 54 | * @public 55 | */ 56 | export declare function createSSR(appConfig: AppConfig, routerOptions: RouterInitOptions): App & { 57 | render(options?: RenderOptions | undefined): Promise; 58 | }; 59 | //# sourceMappingURL=index.d.ts.map -------------------------------------------------------------------------------- /packages/vue-web/types/index.d.ts.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,GAAG,EAA0C,MAAM,KAAK,CAAC;AAEjE,OAAO,EAAC,SAAS,EAAC,MAAM,WAAW,CAAC;AACpC,OAAO,EAA0B,aAAa,EAAE,iBAAiB,EAAC,MAAM,YAAY,CAAC;AAMrF,OAAO,EAAC,YAAY,EAAE,YAAY,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAC,MAAM,sBAAsB,CAAC;AACpF,YAAY,EAAC,iBAAiB,EAAE,SAAS,EAAE,SAAS,EAAE,WAAW,EAAC,MAAM,sBAAsB,CAAC;AAE/F,cAAc,WAAW,CAAC;AAM1B;;GAEG;AACH,oBAAY,OAAO,GAAG,GAAG,GAAG;IAC1B,MAAM,CAAC,OAAO,CAAC,EAAE,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CAChD,CAAC;AAIF;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,SAAS,CAAC,SAAS,EAAE,SAAS,GAAG,OAAO,CAavD;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,SAAS,CACvB,SAAS,EAAE,SAAS,EACpB,aAAa,EAAE,iBAAiB,GAC/B,GAAG,GAAG;IACP,MAAM,CAAC,OAAO,CAAC,EAAE,aAAa,GAAG,SAAS,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;CAC9D,CAIA"} -------------------------------------------------------------------------------- /patch-api.js: -------------------------------------------------------------------------------- 1 | /* eslint-disable no-unused-vars */ 2 | const replace = require('replace-in-file'); 3 | 4 | const indexPage = `# API手册V2.0 5 | 6 | 根据UI框架和运行环境的不同,请使用不同的Package: 7 | 8 | - [@elux/react-web](./react-web.md) 9 | - [@elux/react-taro](./react-taro.md) 10 | - [@elux/vue-web](./vue-web.md) 11 | - [@elux/vue-taro](./vue-taro.md) 12 | - [@elux/model](./model.md) 13 | `; 14 | replace.sync({ 15 | files: './api/api/index.md', 16 | from: /[\d\D]*/, 17 | to: indexPage, 18 | countMatches: true, 19 | }); 20 | 21 | replace.sync({ 22 | files: ['./api/api/react-web.md', './api/api/react-taro.md', './api/api/vue-web.md', './api/api/vue-taro.md', './api/api/model.md'], 23 | from: [/## Interfaces[\d\D]*?## Variables/, /\n## Type Aliases[\d\D]*?$/], 24 | to: ['## Variables', ''], 25 | countMatches: true, 26 | }); 27 | -------------------------------------------------------------------------------- /preBuild.js: -------------------------------------------------------------------------------- 1 | const replace = require('replace-in-file'); 2 | const runtimeVersion = require('@babel/runtime/package.json').version; 3 | 4 | const options = { 5 | files: './package.json', 6 | from: /"@babel\/runtime":\s?"([^"]+)"/g, 7 | to: `"@babel/runtime": "~${runtimeVersion}"`, 8 | countMatches: true, 9 | }; 10 | // @ts-ignore 11 | replace.sync(options); 12 | -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "@elux/babel-preset/tsconfig.lint.json", 3 | "include": ["./"], 4 | "exclude": ["**/dist", "**/.api", "**/.cache", "**/.temp"] 5 | } 6 | --------------------------------------------------------------------------------