@modern-js/main-doc 2.0.0-beta.0 → 2.0.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.turbo/turbo-build.log +4 -0
- package/en/docusaurus-plugin-content-docs/current/apis/app/commands/_category_.json +8 -0
- package/en/docusaurus-plugin-content-docs/current/apis/app/commands/build.md +44 -0
- package/en/docusaurus-plugin-content-docs/current/apis/app/commands/dev.md +31 -0
- package/en/docusaurus-plugin-content-docs/current/apis/app/commands/index.md +12 -0
- package/en/docusaurus-plugin-content-docs/current/apis/app/commands/inspect.md +39 -0
- package/en/docusaurus-plugin-content-docs/current/apis/app/commands/lint.md +22 -0
- package/en/docusaurus-plugin-content-docs/current/apis/app/commands/new.md +59 -0
- package/en/docusaurus-plugin-content-docs/current/apis/app/commands/start.md +32 -0
- package/en/docusaurus-plugin-content-docs/current/apis/app/commands/test.md +36 -0
- package/en/docusaurus-plugin-content-docs/current/apis/app/commands/upgrade.md +21 -0
- package/en/docusaurus-plugin-content-docs/current/apis/app/hooks/_category_.json +8 -0
- package/en/docusaurus-plugin-content-docs/current/apis/app/hooks/api/_category_.json +4 -0
- package/en/docusaurus-plugin-content-docs/current/apis/app/hooks/api/framework/_category_.json +4 -0
- package/en/docusaurus-plugin-content-docs/current/apis/app/hooks/api/framework/lambda.md +54 -0
- package/en/docusaurus-plugin-content-docs/current/apis/app/hooks/api/functions/_category_.json +4 -0
- package/en/docusaurus-plugin-content-docs/current/apis/app/hooks/api/functions/api.md +78 -0
- package/en/docusaurus-plugin-content-docs/current/apis/app/hooks/api/functions/app.md +12 -0
- package/en/docusaurus-plugin-content-docs/current/apis/app/hooks/api/functions/common.md +10 -0
- package/en/docusaurus-plugin-content-docs/current/apis/app/hooks/api/test.md +10 -0
- package/en/docusaurus-plugin-content-docs/current/apis/app/hooks/config/_category_.json +4 -0
- package/en/docusaurus-plugin-content-docs/current/apis/app/hooks/config/html.md +8 -0
- package/en/docusaurus-plugin-content-docs/current/apis/app/hooks/config/icon.md +15 -0
- package/en/docusaurus-plugin-content-docs/current/apis/app/hooks/config/mock.md +6 -0
- package/en/docusaurus-plugin-content-docs/current/apis/app/hooks/config/public.md +28 -0
- package/en/docusaurus-plugin-content-docs/current/apis/app/hooks/config/storybook.md +12 -0
- package/en/docusaurus-plugin-content-docs/current/apis/app/hooks/config/upload.md +42 -0
- package/en/docusaurus-plugin-content-docs/current/apis/app/hooks/index.md +7 -0
- package/en/docusaurus-plugin-content-docs/current/apis/app/hooks/modern-config.md +8 -0
- package/en/docusaurus-plugin-content-docs/current/apis/app/hooks/server/_category_.json +4 -0
- package/en/docusaurus-plugin-content-docs/current/apis/app/hooks/server/index_.md +14 -0
- package/en/docusaurus-plugin-content-docs/current/apis/app/hooks/server/test.md +10 -0
- package/en/docusaurus-plugin-content-docs/current/apis/app/hooks/shared.md +6 -0
- package/en/docusaurus-plugin-content-docs/current/apis/app/hooks/src/_category_.json +4 -0
- package/en/docusaurus-plugin-content-docs/current/apis/app/hooks/src/app.md +45 -0
- package/en/docusaurus-plugin-content-docs/current/apis/app/hooks/src/index_.md +34 -0
- package/en/docusaurus-plugin-content-docs/current/apis/app/hooks/src/pages.md +180 -0
- package/en/docusaurus-plugin-content-docs/current/apis/app/hooks/src/stories.md +12 -0
- package/en/docusaurus-plugin-content-docs/current/apis/app/hooks/src/test.md +12 -0
- package/en/docusaurus-plugin-content-docs/current/apis/app/overview.md +12 -0
- package/en/docusaurus-plugin-content-docs/current/apis/app/runtime/_category_.json +9 -0
- package/en/docusaurus-plugin-content-docs/current/apis/app/runtime/app/_category_.json +4 -0
- package/en/docusaurus-plugin-content-docs/current/apis/app/runtime/app/define-config.md +60 -0
- package/en/docusaurus-plugin-content-docs/current/apis/app/runtime/bff/_category_.json +4 -0
- package/en/docusaurus-plugin-content-docs/current/apis/app/runtime/bff/hook.md +43 -0
- package/en/docusaurus-plugin-content-docs/current/apis/app/runtime/bff/use-context.md +36 -0
- package/en/docusaurus-plugin-content-docs/current/apis/app/runtime/core/_category_.json +5 -0
- package/en/docusaurus-plugin-content-docs/current/apis/app/runtime/core/bootstrap.md +55 -0
- package/en/docusaurus-plugin-content-docs/current/apis/app/runtime/core/create-app.md +47 -0
- package/en/docusaurus-plugin-content-docs/current/apis/app/runtime/core/use-loader.md +83 -0
- package/en/docusaurus-plugin-content-docs/current/apis/app/runtime/core/use-module-apps.md +101 -0
- package/en/docusaurus-plugin-content-docs/current/apis/app/runtime/core/use-runtime-context.md +59 -0
- package/en/docusaurus-plugin-content-docs/current/apis/app/runtime/default-alias.md +25 -0
- package/en/docusaurus-plugin-content-docs/current/apis/app/runtime/env.md +72 -0
- package/en/docusaurus-plugin-content-docs/current/apis/app/runtime/index.md +12 -0
- package/en/docusaurus-plugin-content-docs/current/apis/app/runtime/model/Provider.md +35 -0
- package/en/docusaurus-plugin-content-docs/current/apis/app/runtime/model/_category_.json +4 -0
- package/en/docusaurus-plugin-content-docs/current/apis/app/runtime/model/auto-actions.md +120 -0
- package/en/docusaurus-plugin-content-docs/current/apis/app/runtime/model/connect.md +140 -0
- package/en/docusaurus-plugin-content-docs/current/apis/app/runtime/model/create-app.md +73 -0
- package/en/docusaurus-plugin-content-docs/current/apis/app/runtime/model/create-store.md +62 -0
- package/en/docusaurus-plugin-content-docs/current/apis/app/runtime/model/handle-effect.md +105 -0
- package/en/docusaurus-plugin-content-docs/current/apis/app/runtime/model/model_.md +197 -0
- package/en/docusaurus-plugin-content-docs/current/apis/app/runtime/model/use-local-model.md +27 -0
- package/en/docusaurus-plugin-content-docs/current/apis/app/runtime/model/use-model.md +89 -0
- package/en/docusaurus-plugin-content-docs/current/apis/app/runtime/model/use-static-model.md +49 -0
- package/en/docusaurus-plugin-content-docs/current/apis/app/runtime/model/use-store.md +48 -0
- package/en/docusaurus-plugin-content-docs/current/apis/app/runtime/plugin/_category_.json +4 -0
- package/en/docusaurus-plugin-content-docs/current/apis/app/runtime/plugin/abstract.md +26 -0
- package/en/docusaurus-plugin-content-docs/current/apis/app/runtime/plugin/hook-api.md +896 -0
- package/en/docusaurus-plugin-content-docs/current/apis/app/runtime/plugin/hook.md +170 -0
- package/en/docusaurus-plugin-content-docs/current/apis/app/runtime/plugin/plugin-api.md +117 -0
- package/en/docusaurus-plugin-content-docs/current/apis/app/runtime/router/_category_.json +4 -0
- package/en/docusaurus-plugin-content-docs/current/apis/app/runtime/router/router.md +492 -0
- package/en/docusaurus-plugin-content-docs/current/apis/app/runtime/ssr/_category_.json +4 -0
- package/en/docusaurus-plugin-content-docs/current/apis/app/runtime/ssr/no-ssr.md +44 -0
- package/en/docusaurus-plugin-content-docs/current/apis/app/runtime/ssr/pre-render.md +91 -0
- package/en/docusaurus-plugin-content-docs/current/apis/app/runtime/testing/_category_.json +4 -0
- package/en/docusaurus-plugin-content-docs/current/apis/app/runtime/testing/act.md +34 -0
- package/en/docusaurus-plugin-content-docs/current/apis/app/runtime/testing/cleanup.md +38 -0
- package/en/docusaurus-plugin-content-docs/current/apis/app/runtime/testing/render.md +72 -0
- package/en/docusaurus-plugin-content-docs/current/apis/app/runtime/testing/renderApp.md +33 -0
- package/en/docusaurus-plugin-content-docs/current/apis/app/runtime/utility/_category_.json +4 -0
- package/en/docusaurus-plugin-content-docs/current/apis/app/runtime/utility/css-in-js.md +42 -0
- package/en/docusaurus-plugin-content-docs/current/apis/app/runtime/utility/head.md +39 -0
- package/en/docusaurus-plugin-content-docs/current/apis/app/runtime/utility/loadable.md +85 -0
- package/en/docusaurus-plugin-content-docs/current/apis/app/runtime/web-server/_category_.json +4 -0
- package/en/docusaurus-plugin-content-docs/current/apis/app/runtime/web-server/hook.md +131 -0
- package/en/docusaurus-plugin-content-docs/current/apis/app/runtime/web-server/middleware.md +106 -0
- package/en/docusaurus-plugin-content-docs/current/configure/app/bff/fetcher.md +28 -0
- package/en/docusaurus-plugin-content-docs/current/configure/app/bff/prefix.md +33 -0
- package/en/docusaurus-plugin-content-docs/current/configure/app/bff/proxy.md +75 -0
- package/en/{configure → docusaurus-plugin-content-docs/current/configure}/app/dev/asset-prefix.md +0 -1
- package/en/{configure → docusaurus-plugin-content-docs/current/configure}/app/dev/hmr.md +0 -1
- package/en/{configure → docusaurus-plugin-content-docs/current/configure}/app/dev/https.md +0 -1
- package/en/{configure → docusaurus-plugin-content-docs/current/configure}/app/dev/port.md +0 -1
- package/en/{configure → docusaurus-plugin-content-docs/current/configure}/app/dev/progress-bar.md +0 -1
- package/en/docusaurus-plugin-content-docs/current/configure/app/dev/proxy.md +80 -0
- package/en/{configure → docusaurus-plugin-content-docs/current/configure}/app/dev/start-url.md +0 -1
- package/en/docusaurus-plugin-content-docs/current/configure/app/dev/with-master-app.md +32 -0
- package/en/docusaurus-plugin-content-docs/current/configure/app/experiments/lazy-compilation.md +12 -0
- package/en/{configure → docusaurus-plugin-content-docs/current/configure}/app/html/app-icon.md +0 -1
- package/en/{configure → docusaurus-plugin-content-docs/current/configure}/app/html/crossorigin.md +0 -1
- package/en/{configure → docusaurus-plugin-content-docs/current/configure}/app/html/disable-html-folder.md +0 -1
- package/en/{configure → docusaurus-plugin-content-docs/current/configure}/app/html/favicon-by-entries.md +0 -1
- package/en/{configure → docusaurus-plugin-content-docs/current/configure}/app/html/favicon.md +0 -1
- package/en/{configure → docusaurus-plugin-content-docs/current/configure}/app/html/inject-by-entries.md +0 -1
- package/en/{configure → docusaurus-plugin-content-docs/current/configure}/app/html/inject.md +0 -1
- package/en/{configure → docusaurus-plugin-content-docs/current/configure}/app/html/meta-by-entries.md +0 -1
- package/en/{configure → docusaurus-plugin-content-docs/current/configure}/app/html/meta.md +0 -1
- package/en/{configure → docusaurus-plugin-content-docs/current/configure}/app/html/mount-id.md +0 -1
- package/en/{configure → docusaurus-plugin-content-docs/current/configure}/app/html/template-by-entries.md +0 -1
- package/en/{configure → docusaurus-plugin-content-docs/current/configure}/app/html/template-parameters-by-entries.md +0 -1
- package/en/{configure → docusaurus-plugin-content-docs/current/configure}/app/html/template-parameters.md +0 -1
- package/en/{configure → docusaurus-plugin-content-docs/current/configure}/app/html/template.md +0 -1
- package/en/{configure → docusaurus-plugin-content-docs/current/configure}/app/html/title-by-entries.md +0 -1
- package/en/{configure → docusaurus-plugin-content-docs/current/configure}/app/html/title.md +0 -1
- package/en/{configure → docusaurus-plugin-content-docs/current/configure}/app/output/asset-prefix.md +0 -1
- package/en/{configure → docusaurus-plugin-content-docs/current/configure}/app/output/assets-retry.md +0 -1
- package/en/{configure → docusaurus-plugin-content-docs/current/configure}/app/output/charset.md +0 -1
- package/en/{configure → docusaurus-plugin-content-docs/current/configure}/app/output/clean-dist-path.md +0 -1
- package/en/{configure → docusaurus-plugin-content-docs/current/configure}/app/output/convert-to-rem.md +0 -1
- package/en/{configure → docusaurus-plugin-content-docs/current/configure}/app/output/copy.md +0 -1
- package/en/{configure → docusaurus-plugin-content-docs/current/configure}/app/output/css-module-local-ident-name.md +0 -1
- package/en/{configure → docusaurus-plugin-content-docs/current/configure}/app/output/data-uri-limit.md +0 -1
- package/en/{configure → docusaurus-plugin-content-docs/current/configure}/app/output/disable-css-module-extension.md +0 -1
- package/en/{configure → docusaurus-plugin-content-docs/current/configure}/app/output/disable-filename-hash.md +0 -1
- package/en/{configure → docusaurus-plugin-content-docs/current/configure}/app/output/disable-inline-runtime-chunk.md +0 -1
- package/en/{configure → docusaurus-plugin-content-docs/current/configure}/app/output/disable-minimize.md +0 -1
- package/en/docusaurus-plugin-content-docs/current/configure/app/output/disable-node-polyfill.md +20 -0
- package/en/{configure → docusaurus-plugin-content-docs/current/configure}/app/output/disable-source-map.md +0 -1
- package/en/docusaurus-plugin-content-docs/current/configure/app/output/disable-ts-checker.md +12 -0
- package/en/{configure → docusaurus-plugin-content-docs/current/configure}/app/output/dist-path.md +0 -1
- package/en/{configure → docusaurus-plugin-content-docs/current/configure}/app/output/enable-asset-fallback.md +0 -1
- package/en/{configure → docusaurus-plugin-content-docs/current/configure}/app/output/enable-asset-manifest.md +0 -1
- package/en/{configure → docusaurus-plugin-content-docs/current/configure}/app/output/enable-css-module-tsdeclaration.md +0 -1
- package/en/{configure → docusaurus-plugin-content-docs/current/configure}/app/output/enable-inline-scripts.md +0 -1
- package/en/{configure → docusaurus-plugin-content-docs/current/configure}/app/output/enable-inline-styles.md +0 -1
- package/en/{configure → docusaurus-plugin-content-docs/current/configure}/app/output/enable-latest-decorators.md +0 -1
- package/en/docusaurus-plugin-content-docs/current/configure/app/output/enable-modern-mode.md +34 -0
- package/en/{configure → docusaurus-plugin-content-docs/current/configure}/app/output/externals.md +0 -1
- package/en/{configure → docusaurus-plugin-content-docs/current/configure}/app/output/filename.md +0 -1
- package/en/{configure → docusaurus-plugin-content-docs/current/configure}/app/output/legal-comments.md +0 -1
- package/en/{configure → docusaurus-plugin-content-docs/current/configure}/app/output/override-browserslist.md +0 -1
- package/en/{configure → docusaurus-plugin-content-docs/current/configure}/app/output/polyfill.md +0 -1
- package/en/{configure → docusaurus-plugin-content-docs/current/configure}/app/output/svg-default-export.md +0 -1
- package/en/{configure → docusaurus-plugin-content-docs/current/configure}/app/performance/build-cache.md +0 -1
- package/en/{configure → docusaurus-plugin-content-docs/current/configure}/app/performance/bundle-analyze.md +0 -1
- package/en/{configure → docusaurus-plugin-content-docs/current/configure}/app/performance/chunk-split.md +0 -1
- package/en/{configure → docusaurus-plugin-content-docs/current/configure}/app/performance/print-file-size.md +0 -1
- package/en/{configure → docusaurus-plugin-content-docs/current/configure}/app/performance/profile.md +0 -1
- package/en/{configure → docusaurus-plugin-content-docs/current/configure}/app/performance/remove-console.md +0 -1
- package/en/{configure → docusaurus-plugin-content-docs/current/configure}/app/performance/remove-moment-locale.md +0 -1
- package/en/docusaurus-plugin-content-docs/current/configure/app/plugins.md +74 -0
- package/en/docusaurus-plugin-content-docs/current/configure/app/runtime/intro.md +91 -0
- package/en/docusaurus-plugin-content-docs/current/configure/app/runtime/master-app.md +60 -0
- package/en/docusaurus-plugin-content-docs/current/configure/app/runtime/router.md +19 -0
- package/en/docusaurus-plugin-content-docs/current/configure/app/runtime/state.md +41 -0
- package/en/{configure → docusaurus-plugin-content-docs/current/configure}/app/security/sri.md +0 -1
- package/en/docusaurus-plugin-content-docs/current/configure/app/server/base-url.md +33 -0
- package/en/docusaurus-plugin-content-docs/current/configure/app/server/port.md +18 -0
- package/en/docusaurus-plugin-content-docs/current/configure/app/server/public-routes.md +26 -0
- package/en/docusaurus-plugin-content-docs/current/configure/app/server/routes.md +91 -0
- package/en/docusaurus-plugin-content-docs/current/configure/app/server/ssr-by-entries.md +28 -0
- package/en/docusaurus-plugin-content-docs/current/configure/app/server/ssr.md +20 -0
- package/en/{configure → docusaurus-plugin-content-docs/current/configure}/app/source/alias.md +0 -1
- package/en/{configure → docusaurus-plugin-content-docs/current/configure}/app/source/compile-js-data-uri.md +0 -1
- package/en/docusaurus-plugin-content-docs/current/configure/app/source/config-dir.md +23 -0
- package/en/{configure → docusaurus-plugin-content-docs/current/configure}/app/source/define.md +0 -1
- package/en/docusaurus-plugin-content-docs/current/configure/app/source/design-system.md +1150 -0
- package/en/docusaurus-plugin-content-docs/current/configure/app/source/disable-default-entries.md +28 -0
- package/en/docusaurus-plugin-content-docs/current/configure/app/source/enable-async-entry.md +50 -0
- package/en/docusaurus-plugin-content-docs/current/configure/app/source/entries-dir.md +38 -0
- package/en/docusaurus-plugin-content-docs/current/configure/app/source/entries.md +62 -0
- package/en/docusaurus-plugin-content-docs/current/configure/app/source/exclude.md +12 -0
- package/en/{configure → docusaurus-plugin-content-docs/current/configure}/app/source/global-vars.md +0 -1
- package/en/{configure → docusaurus-plugin-content-docs/current/configure}/app/source/include.md +0 -1
- package/en/{configure → docusaurus-plugin-content-docs/current/configure}/app/source/module-scopes.md +0 -1
- package/en/{configure → docusaurus-plugin-content-docs/current/configure}/app/source/pre-entry.md +0 -1
- package/en/{configure → docusaurus-plugin-content-docs/current/configure}/app/source/resolve-extension-prefix.md +0 -1
- package/en/{configure → docusaurus-plugin-content-docs/current/configure}/app/source/resolve-main-fields.md +0 -1
- package/en/docusaurus-plugin-content-docs/current/configure/app/testing/transformer.md +18 -0
- package/en/{configure → docusaurus-plugin-content-docs/current/configure}/app/tools/autoprefixer.md +0 -1
- package/en/{configure → docusaurus-plugin-content-docs/current/configure}/app/tools/babel.md +0 -1
- package/en/{configure → docusaurus-plugin-content-docs/current/configure}/app/tools/css-extract.md +0 -1
- package/en/{configure → docusaurus-plugin-content-docs/current/configure}/app/tools/css-loader.md +0 -1
- package/en/{configure → docusaurus-plugin-content-docs/current/configure}/app/tools/dev-server.md +0 -1
- package/en/docusaurus-plugin-content-docs/current/configure/app/tools/esbuild.md +61 -0
- package/en/{configure → docusaurus-plugin-content-docs/current/configure}/app/tools/html-plugin.md +0 -1
- package/en/{configure → docusaurus-plugin-content-docs/current/configure}/app/tools/inspector.md +0 -1
- package/en/docusaurus-plugin-content-docs/current/configure/app/tools/jest.md +39 -0
- package/en/{configure → docusaurus-plugin-content-docs/current/configure}/app/tools/less.md +0 -1
- package/en/{configure → docusaurus-plugin-content-docs/current/configure}/app/tools/minify-css.md +0 -1
- package/en/{configure → docusaurus-plugin-content-docs/current/configure}/app/tools/postcss.md +0 -1
- package/en/{configure → docusaurus-plugin-content-docs/current/configure}/app/tools/pug.md +0 -1
- package/en/{configure → docusaurus-plugin-content-docs/current/configure}/app/tools/sass.md +0 -1
- package/en/{configure → docusaurus-plugin-content-docs/current/configure}/app/tools/style-loader.md +0 -1
- package/en/{configure → docusaurus-plugin-content-docs/current/configure}/app/tools/styled-components.md +0 -1
- package/en/docusaurus-plugin-content-docs/current/configure/app/tools/tailwindcss.md +47 -0
- package/en/{configure → docusaurus-plugin-content-docs/current/configure}/app/tools/terser.md +0 -1
- package/en/{configure → docusaurus-plugin-content-docs/current/configure}/app/tools/ts-checker.md +0 -1
- package/en/{configure → docusaurus-plugin-content-docs/current/configure}/app/tools/ts-loader.md +0 -1
- package/en/{configure → docusaurus-plugin-content-docs/current/configure}/app/tools/webpack-chain.md +0 -1
- package/en/{configure → docusaurus-plugin-content-docs/current/configure}/app/tools/webpack.md +0 -1
- package/en/docusaurus-plugin-content-docs/current/configure/app/usage.md +92 -0
- package/en/{tutorials → docusaurus-plugin-content-docs/current/tutorials}/foundations/_category_.json +0 -0
- package/en/{tutorials → docusaurus-plugin-content-docs/current/tutorials}/foundations/basic.md +0 -0
- package/en/{tutorials → docusaurus-plugin-content-docs/current/tutorials}/foundations/introduction.md +0 -0
- package/en/docusaurus-plugin-content-docs/current.json +262 -0
- package/package.json +7 -5
- package/scripts/config.ts +98 -0
- package/scripts/summary.en.json +1 -0
- package/scripts/summary.zh.json +1 -0
- package/scripts/sync.ts +26 -5
- package/zh/apis/app/commands/build.md +2 -2
- package/zh/apis/app/commands/dev.md +1 -1
- package/zh/apis/app/commands/index.md +1 -1
- package/zh/apis/app/commands/lint.md +2 -2
- package/zh/apis/app/commands/new.md +1 -1
- package/zh/apis/app/commands/start.md +1 -1
- package/zh/apis/app/commands/test.md +1 -1
- package/zh/apis/app/commands/upgrade.md +0 -2
- package/zh/apis/app/hooks/api/framework/_category_.json +1 -1
- package/zh/apis/app/hooks/api/framework/lambda.md +8 -33
- package/zh/apis/app/hooks/api/functions/_category_.json +1 -1
- package/zh/apis/app/hooks/api/functions/api.md +29 -2
- package/zh/apis/app/hooks/api/functions/app.md +5 -3
- package/zh/apis/app/hooks/api/functions/common.md +3 -5
- package/zh/apis/app/hooks/api/test.md +2 -4
- package/zh/apis/app/hooks/config/html.md +1 -3
- package/zh/apis/app/hooks/config/icon.md +2 -2
- package/zh/apis/app/hooks/config/mock.md +2 -8
- package/zh/apis/app/hooks/config/public.md +2 -4
- package/zh/apis/app/hooks/config/storybook.md +2 -4
- package/zh/apis/app/hooks/config/upload.md +1 -7
- package/zh/apis/app/hooks/modern-config.md +1 -3
- package/zh/apis/app/hooks/server/index_.md +12 -0
- package/zh/apis/app/hooks/server/test.md +3 -3
- package/zh/apis/app/hooks/shared.md +1 -2
- package/zh/apis/app/hooks/src/app.md +8 -4
- package/zh/apis/app/hooks/src/{index.md → index_.md} +2 -2
- package/zh/apis/app/hooks/src/pages.md +3 -4
- package/zh/apis/app/hooks/src/stories.md +2 -2
- package/zh/apis/app/hooks/src/test.md +1 -1
- package/zh/apis/app/overview.md +1 -1
- package/zh/apis/app/runtime/app/_category_.json +2 -2
- package/zh/apis/app/runtime/app/define-config.md +14 -10
- package/zh/apis/app/runtime/bff/_category_.json +4 -0
- package/zh/apis/app/runtime/bff/hook.md +43 -0
- package/zh/apis/app/runtime/bff/use-context.md +36 -0
- package/zh/apis/app/runtime/core/_category_.json +4 -0
- package/zh/apis/app/runtime/core/bootstrap.md +55 -0
- package/zh/apis/app/runtime/core/create-app.md +47 -0
- package/zh/apis/app/runtime/core/use-loader.md +83 -0
- package/zh/apis/app/runtime/core/use-module-apps.md +101 -0
- package/zh/apis/app/runtime/core/use-runtime-context.md +59 -0
- package/zh/apis/app/runtime/default-alias.md +4 -7
- package/zh/apis/app/runtime/env.md +22 -20
- package/zh/apis/app/runtime/model/Provider.md +6 -8
- package/zh/apis/app/runtime/model/_category_.json +1 -1
- package/zh/apis/app/runtime/model/auto-actions.md +1 -2
- package/zh/apis/app/runtime/model/connect.md +8 -5
- package/zh/apis/app/runtime/model/create-app.md +3 -4
- package/zh/apis/app/runtime/model/create-store.md +5 -3
- package/zh/apis/app/runtime/model/handle-effect.md +5 -5
- package/zh/apis/app/runtime/model/model_.md +3 -3
- package/zh/apis/app/runtime/model/use-local-model.md +2 -2
- package/zh/apis/app/runtime/model/use-model.md +6 -7
- package/zh/apis/app/runtime/model/use-static-model.md +2 -2
- package/zh/apis/app/runtime/model/use-store.md +3 -3
- package/zh/apis/app/runtime/router/_category_.json +4 -0
- package/zh/apis/app/runtime/{container → router}/router.md +0 -0
- package/zh/apis/app/runtime/ssr/_category_.json +4 -0
- package/zh/apis/app/runtime/ssr/no-ssr.md +41 -0
- package/zh/apis/app/runtime/ssr/pre-render.md +91 -0
- package/zh/apis/app/runtime/testing/_category_.json +1 -1
- package/zh/apis/app/runtime/testing/act.md +8 -8
- package/zh/apis/app/runtime/testing/cleanup.md +10 -9
- package/zh/apis/app/runtime/testing/render.md +43 -23
- package/zh/apis/app/runtime/testing/renderApp.md +8 -8
- package/zh/apis/app/runtime/utility/_category_.json +1 -1
- package/zh/apis/app/runtime/utility/css-in-js.md +17 -35
- package/zh/apis/app/runtime/{app → utility}/head.md +6 -10
- package/zh/apis/app/runtime/utility/{loadable/loadable_.md → loadable.md} +29 -56
- package/zh/apis/app/runtime/web-server/_category_.json +1 -1
- package/zh/apis/app/runtime/web-server/hook.md +100 -90
- package/zh/apis/app/runtime/web-server/middleware.md +106 -0
- package/zh/apis/monorepo/commands/bump.md +1 -1
- package/zh/apis/monorepo/commands/change.md +1 -1
- package/zh/apis/monorepo/commands/clear.md +1 -1
- package/zh/apis/monorepo/commands/deploy.md +1 -1
- package/zh/apis/monorepo/commands/gen-release-note.md +1 -1
- package/zh/apis/monorepo/commands/lint.md +1 -1
- package/zh/apis/monorepo/commands/new.md +1 -1
- package/zh/apis/monorepo/commands/pre.md +1 -1
- package/zh/apis/monorepo/commands/release.md +1 -1
- package/zh/configure/app/bff/fetcher.md +1 -2
- package/zh/configure/app/bff/prefix.md +2 -3
- package/zh/configure/app/bff/proxy.md +8 -13
- package/zh/configure/app/dev/asset-prefix.md +0 -1
- package/zh/configure/app/dev/hmr.md +0 -1
- package/zh/configure/app/dev/https.md +0 -1
- package/zh/configure/app/dev/port.md +0 -1
- package/zh/configure/app/dev/progress-bar.md +0 -1
- package/zh/configure/app/dev/proxy.md +2 -3
- package/zh/configure/app/dev/start-url.md +0 -1
- package/zh/configure/app/dev/with-master-app.md +0 -1
- package/zh/configure/app/experiments/lazy-compilation.md +12 -0
- package/zh/configure/app/html/app-icon.md +0 -1
- package/zh/configure/app/html/crossorigin.md +0 -1
- package/zh/configure/app/html/disable-html-folder.md +0 -1
- package/zh/configure/app/html/favicon-by-entries.md +0 -1
- package/zh/configure/app/html/favicon.md +0 -1
- package/zh/configure/app/html/inject-by-entries.md +0 -1
- package/zh/configure/app/html/inject.md +0 -1
- package/zh/configure/app/html/meta-by-entries.md +0 -1
- package/zh/configure/app/html/meta.md +0 -1
- package/zh/configure/app/html/mount-id.md +0 -1
- package/zh/configure/app/html/template-by-entries.md +0 -1
- package/zh/configure/app/html/template-parameters-by-entries.md +0 -1
- package/zh/configure/app/html/template-parameters.md +0 -1
- package/zh/configure/app/html/template.md +0 -1
- package/zh/configure/app/html/title-by-entries.md +0 -1
- package/zh/configure/app/html/title.md +0 -1
- package/zh/configure/app/output/asset-prefix.md +0 -1
- package/zh/configure/app/output/assets-retry.md +0 -1
- package/zh/configure/app/output/charset.md +0 -1
- package/zh/configure/app/output/clean-dist-path.md +0 -1
- package/zh/configure/app/output/convert-to-rem.md +0 -1
- package/zh/configure/app/output/copy.md +0 -1
- package/zh/configure/app/output/css-module-local-ident-name.md +0 -1
- package/zh/configure/app/output/data-uri-limit.md +0 -1
- package/zh/configure/app/output/disable-css-module-extension.md +0 -1
- package/zh/configure/app/output/disable-filename-hash.md +0 -1
- package/zh/configure/app/output/disable-inline-runtime-chunk.md +0 -1
- package/zh/configure/app/output/disable-minimize.md +0 -1
- package/zh/configure/app/output/disable-node-polyfill.md +2 -4
- package/zh/configure/app/output/disable-source-map.md +0 -1
- package/zh/configure/app/output/disable-ts-checker.md +12 -0
- package/zh/configure/app/output/dist-path.md +0 -1
- package/zh/configure/app/output/enable-asset-fallback.md +0 -1
- package/zh/configure/app/output/enable-asset-manifest.md +0 -1
- package/zh/configure/app/output/enable-css-module-tsdeclaration.md +0 -1
- package/zh/configure/app/output/enable-inline-scripts.md +0 -1
- package/zh/configure/app/output/enable-inline-styles.md +0 -1
- package/zh/configure/app/output/enable-latest-decorators.md +0 -1
- package/zh/configure/app/output/enable-modern-mode.md +13 -5
- package/zh/configure/app/output/externals.md +0 -1
- package/zh/configure/app/output/filename.md +0 -1
- package/zh/configure/app/output/legal-comments.md +0 -1
- package/zh/configure/app/output/override-browserslist.md +0 -1
- package/zh/configure/app/output/polyfill.md +0 -1
- package/zh/configure/app/output/svg-default-export.md +0 -1
- package/zh/configure/app/performance/build-cache.md +0 -1
- package/zh/configure/app/performance/bundle-analyze.md +0 -1
- package/zh/configure/app/performance/chunk-split.md +0 -1
- package/zh/configure/app/performance/print-file-size.md +0 -1
- package/zh/configure/app/performance/profile.md +0 -1
- package/zh/configure/app/performance/remove-console.md +0 -1
- package/zh/configure/app/performance/remove-moment-locale.md +0 -1
- package/zh/configure/app/runtime/intro.md +92 -0
- package/zh/configure/app/runtime/master-app.md +8 -21
- package/zh/configure/app/runtime/router.md +4 -38
- package/zh/configure/app/runtime/state.md +10 -13
- package/zh/configure/app/security/sri.md +0 -1
- package/zh/configure/app/server/base-url.md +1 -2
- package/zh/configure/app/server/port.md +1 -2
- package/zh/configure/app/server/public-routes.md +1 -2
- package/zh/configure/app/server/routes.md +4 -5
- package/zh/configure/app/server/ssr-by-entries.md +2 -3
- package/zh/configure/app/server/ssr.md +1 -2
- package/zh/configure/app/source/alias.md +0 -1
- package/zh/configure/app/source/compile-js-data-uri.md +0 -1
- package/zh/configure/app/source/config-dir.md +12 -4
- package/zh/configure/app/source/define.md +0 -1
- package/zh/configure/app/source/design-system.md +14 -24
- package/zh/configure/app/source/disable-default-entries.md +8 -3
- package/zh/configure/app/source/enable-async-entry.md +3 -3
- package/zh/configure/app/source/entries-dir.md +1 -1
- package/zh/configure/app/source/entries.md +16 -9
- package/zh/configure/app/source/exclude.md +12 -0
- package/zh/configure/app/source/global-vars.md +0 -1
- package/zh/configure/app/source/include.md +0 -1
- package/zh/configure/app/source/module-scopes.md +0 -1
- package/zh/configure/app/source/pre-entry.md +0 -1
- package/zh/configure/app/source/resolve-extension-prefix.md +0 -1
- package/zh/configure/app/source/resolve-main-fields.md +0 -1
- package/zh/configure/app/testing/transformer.md +2 -4
- package/zh/configure/app/tools/autoprefixer.md +0 -1
- package/zh/configure/app/tools/babel.md +0 -1
- package/zh/configure/app/tools/css-extract.md +0 -1
- package/zh/configure/app/tools/css-loader.md +0 -1
- package/zh/configure/app/tools/dev-server.md +0 -1
- package/zh/configure/app/tools/esbuild.md +5 -5
- package/zh/configure/app/tools/html-plugin.md +0 -1
- package/zh/configure/app/tools/inspector.md +0 -1
- package/zh/configure/app/tools/jest.md +2 -4
- package/zh/configure/app/tools/less.md +0 -1
- package/zh/configure/app/tools/minify-css.md +0 -1
- package/zh/configure/app/tools/postcss.md +0 -1
- package/zh/configure/app/tools/pug.md +0 -1
- package/zh/configure/app/tools/sass.md +0 -1
- package/zh/configure/app/tools/style-loader.md +0 -1
- package/zh/configure/app/tools/styled-components.md +0 -1
- package/zh/configure/app/tools/terser.md +0 -1
- package/zh/configure/app/tools/ts-checker.md +0 -1
- package/zh/configure/app/tools/ts-loader.md +0 -1
- package/zh/configure/app/tools/webpack-chain.md +0 -1
- package/zh/configure/app/tools/webpack.md +0 -1
- package/zh/configure/app/usage.md +15 -4
- package/zh/guides/advanced-features/bff/bff-server.md +1 -1
- package/zh/guides/advanced-features/bff/frameworks.md +0 -221
- package/zh/guides/advanced-features/code-split.md +1 -1
- package/zh/guides/advanced-features/low-level.md +2 -2
- package/zh/guides/advanced-features/ssg.md +2 -2
- package/zh/guides/advanced-features/ssr.md +4 -4
- package/zh/guides/basic-features/alias.md +1 -1
- package/zh/guides/basic-features/css/postcss.md +1 -1
- package/zh/guides/basic-features/css/tailwindcss.md +2 -2
- package/zh/guides/basic-features/env-vars.md +2 -3
- package/zh/guides/basic-features/proxy.md +2 -2
- package/zh/guides/topic-detail/compile-speed.md +5 -5
- package/zh/guides/topic-detail/generator/_category_.json +4 -0
- package/zh/guides/topic-detail/generator/codesmith/_category_.json +4 -0
- package/zh/guides/topic-detail/generator/codesmith/introduce.md +5 -0
- package/zh/guides/topic-detail/generator/config/_category_.json +4 -0
- package/zh/{configure/generator/introduce.md → guides/topic-detail/generator/config/common.md} +35 -42
- package/zh/{configure/generator → guides/topic-detail/generator/config}/module.md +7 -11
- package/zh/{configure/generator → guides/topic-detail/generator/config}/monorepo.md +4 -4
- package/zh/{configure/generator → guides/topic-detail/generator/config}/mwa.md +11 -45
- package/zh/guides/topic-detail/generator/plugin/_category_.json +4 -0
- package/zh/guides/topic-detail/{generator-plugin → generator/plugin}/abstract.md +0 -0
- package/zh/guides/topic-detail/generator/plugin/api/_category_.json +4 -0
- package/zh/{apis/generator/plugin → guides/topic-detail/generator/plugin/api}/file/_category_.json +0 -0
- package/zh/{apis/generator/plugin → guides/topic-detail/generator/plugin/api}/file/addFile.md +1 -1
- package/zh/{apis/generator/plugin → guides/topic-detail/generator/plugin/api}/file/addHelper.md +0 -0
- package/zh/{apis/generator/plugin → guides/topic-detail/generator/plugin/api}/file/addManyFile.md +1 -1
- package/zh/{apis/generator/plugin → guides/topic-detail/generator/plugin/api}/file/addPartial.md +0 -0
- package/zh/{apis/generator/plugin → guides/topic-detail/generator/plugin/api}/file/introduce.md +0 -0
- package/zh/{apis/generator/plugin → guides/topic-detail/generator/plugin/api}/file/rmDir.md +0 -0
- package/zh/{apis/generator/plugin → guides/topic-detail/generator/plugin/api}/file/rmFile.md +0 -0
- package/zh/{apis/generator/plugin → guides/topic-detail/generator/plugin/api}/file/updateJSONFile.md +0 -0
- package/zh/{apis/generator/plugin → guides/topic-detail/generator/plugin/api}/file/updateModernConfig.md +0 -0
- package/zh/{apis/generator/plugin → guides/topic-detail/generator/plugin/api}/file/updateTextRawFile.md +0 -0
- package/zh/{apis/generator/plugin → guides/topic-detail/generator/plugin/api}/git/_category_.json +0 -0
- package/zh/{apis/generator/plugin → guides/topic-detail/generator/plugin/api}/git/gitAddAndCommit.md +0 -0
- package/zh/{apis/generator/plugin → guides/topic-detail/generator/plugin/api}/git/initGitRepo.md +0 -0
- package/zh/{apis/generator/plugin → guides/topic-detail/generator/plugin/api}/git/isInGitRepo.md +0 -0
- package/zh/{apis/generator/plugin → guides/topic-detail/generator/plugin/api}/hook/_category_.json +0 -0
- package/zh/{apis/generator/plugin → guides/topic-detail/generator/plugin/api}/hook/afterForged.md +1 -1
- package/zh/{apis/generator/plugin → guides/topic-detail/generator/plugin/api}/hook/onForged.md +1 -1
- package/zh/{apis/generator/plugin → guides/topic-detail/generator/plugin/api}/info/_category_.json +0 -0
- package/zh/{apis/generator/plugin → guides/topic-detail/generator/plugin/api}/info/isFileExit.md +0 -0
- package/zh/{apis/generator/plugin → guides/topic-detail/generator/plugin/api}/info/locale.md +0 -0
- package/zh/{apis/generator/plugin → guides/topic-detail/generator/plugin/api}/info/readDir.md +0 -0
- package/zh/{apis/generator/plugin → guides/topic-detail/generator/plugin/api}/input/_category_.json +0 -0
- package/zh/{apis/generator/plugin → guides/topic-detail/generator/plugin/api}/input/addInputAfter.md +14 -6
- package/zh/{apis/generator/plugin → guides/topic-detail/generator/plugin/api}/input/addInputBefore.md +14 -6
- package/zh/{apis/generator/plugin → guides/topic-detail/generator/plugin/api}/input/setInput.md +2 -2
- package/zh/{apis/generator/plugin → guides/topic-detail/generator/plugin/api}/input/setInputValue.md +0 -0
- package/zh/guides/topic-detail/generator/plugin/api/input/type.md +65 -0
- package/zh/{apis/generator/plugin → guides/topic-detail/generator/plugin/api}/introduce.md +0 -0
- package/zh/{apis/generator/plugin → guides/topic-detail/generator/plugin/api}/new/_category_.json +0 -0
- package/zh/{apis/generator/plugin → guides/topic-detail/generator/plugin/api}/new/createElement.md +1 -1
- package/zh/{apis/generator/plugin → guides/topic-detail/generator/plugin/api}/new/createSubProject.md +1 -1
- package/zh/{apis/generator/plugin → guides/topic-detail/generator/plugin/api}/new/enableFunc.md +1 -3
- package/zh/{apis/generator/plugin → guides/topic-detail/generator/plugin/api}/new/introduce.md +3 -3
- package/zh/{apis/generator/plugin → guides/topic-detail/generator/plugin/api}/npm/_category_.json +0 -0
- package/zh/{apis/generator/plugin → guides/topic-detail/generator/plugin/api}/npm/install.md +0 -0
- package/zh/guides/topic-detail/{generator-plugin → generator/plugin}/develop.md +4 -4
- package/zh/guides/topic-detail/{generator-plugin → generator/plugin}/use.md +0 -0
- package/zh/guides/topic-detail/generator/project.md +117 -0
- package/zh/guides/topic-detail/micro-frontend/debugging.md +5 -5
- package/zh/guides/topic-detail/micro-frontend/route-mode.md +2 -2
- package/zh/guides/troubleshooting/compile.md +3 -3
- package/zh/tutorials/first-app/c01-getting-started/1.4-enable-ssr.md +2 -2
- package/zh/tutorials/first-app/c04-es6-plus-and-ts/4.3-compatibility.md +4 -4
- package/zh/tutorials/first-app/c06-css-and-component/6.4-design-system.md +3 -3
- package/zh/tutorials/first-app/c07-app-entry/7.3-manage-entries-by-hand.md +2 -2
- package/zh/tutorials/first-app/c08-client-side-routing/8.1-code-based-routing.md +1 -1
- package/scripts/gen-config.ts +0 -60
- package/zh/apis/app/hooks/api/framework/app.md +0 -100
- package/zh/apis/app/hooks/server/index.md +0 -14
- package/zh/apis/app/hooks/src/error.md +0 -10
- package/zh/apis/app/hooks/src/eslint.md +0 -9
- package/zh/apis/app/runtime/app/bootstrap.md +0 -83
- package/zh/apis/app/runtime/app/create-app.md +0 -47
- package/zh/apis/app/runtime/app/no-ssr.md +0 -41
- package/zh/apis/app/runtime/app/pre-render.md +0 -77
- package/zh/apis/app/runtime/app/use-module-app.md +0 -60
- package/zh/apis/app/runtime/app/use-module-apps.md +0 -64
- package/zh/apis/app/runtime/app/use-runtime-context.md +0 -39
- package/zh/apis/app/runtime/bff-server/_category_.json +0 -4
- package/zh/apis/app/runtime/bff-server/after-lambda-registed.md +0 -35
- package/zh/apis/app/runtime/bff-server/hook.md +0 -120
- package/zh/apis/app/runtime/bff-server/use-context.md +0 -70
- package/zh/apis/app/runtime/container/_category_.json +0 -4
- package/zh/apis/app/runtime/container/use-loader.md +0 -64
- package/zh/apis/app/runtime/utility/loadable/_category_.json +0 -4
- package/zh/apis/app/runtime/utility/loadable/lazy.md +0 -29
- package/zh/apis/app/runtime/utility/loadable/loadable-component.md +0 -61
- package/zh/apis/app/runtime/utility/loadable/loadable-library.md +0 -67
- package/zh/apis/generator/plugin/_category_.json +0 -4
- package/zh/apis/generator/plugin/input/addOptionAfter.md +0 -45
- package/zh/apis/generator/plugin/input/addOptionBefore.md +0 -45
- package/zh/apis/generator/plugin/input/type.md +0 -101
- package/zh/guides/topic-detail/generator-plugin/_category_.json +0 -4
@@ -0,0 +1,73 @@
|
|
1
|
+
---
|
2
|
+
sidebar_position: 11
|
3
|
+
title: createApp
|
4
|
+
---
|
5
|
+
|
6
|
+
import ReduckTip from '@site-docs/components/reduck-tip.md'
|
7
|
+
|
8
|
+
<ReduckTip />
|
9
|
+
|
10
|
+
Reduck will call `createApp` to create a global application by default. If the entire application only needs one Store, then there is no need to call `createApp` manually。Only need to use `createApp` when you need to create a Store locally in the app.
|
11
|
+
|
12
|
+
:::caution
|
13
|
+
Note that the exported `createApp` in `@modern-js/runtime/model` is used to manage state, while the exported `createApp` in `@modern-js/runtime` is used to create the entire application. The two are differently.
|
14
|
+
:::
|
15
|
+
|
16
|
+
## Function Signature
|
17
|
+
|
18
|
+
```ts
|
19
|
+
interface AppConfig extends StoreConfig {
|
20
|
+
devTools?: boolean | DevToolsOptions;
|
21
|
+
autoActions?: boolean;
|
22
|
+
}
|
23
|
+
|
24
|
+
function createApp(config: AppConfig): object;
|
25
|
+
```
|
26
|
+
|
27
|
+
### Input
|
28
|
+
|
29
|
+
- `config`
|
30
|
+
- `StoreConfig`: the same as [`createStore`](./create-store.md) params.
|
31
|
+
- `devTools`: the default value is `true`. when it is an object type,configuring [Options](https://github.com/reduxjs/redux-devtools/blob/main/extension/docs/API/Arguments.md) of Redux DevTools。
|
32
|
+
- `autoActins`: the default value is `true`。if [auto generate Actions](./auto-actions.md)。
|
33
|
+
|
34
|
+
### Return Value
|
35
|
+
|
36
|
+
Reduck App, consists of the following properties:
|
37
|
+
|
38
|
+
- `Provider`: inject shared Store into locally component tree, same as [`Provider`](./Provider.md)。
|
39
|
+
- `useModel`: get the Model mounted by the app's local Store, same as [`useModel`](./use-model.md)。
|
40
|
+
- `useStaticModel`: get the Model mounted by the app's local Store. same as [`useStaticModel`](./use-static-model.md)。
|
41
|
+
- `useLocalModel`: get the Model mounted by the app's local Store. same as [`useLocalModel`](./use-local-model.md)。
|
42
|
+
- `useStore`: get the Store used locally by the app. same as [`useStore`](./use-store.md)。
|
43
|
+
|
44
|
+
## Example
|
45
|
+
|
46
|
+
use `createApp`, local states can be created to isolate the states between different Reduck applications.
|
47
|
+
|
48
|
+
```tsx
|
49
|
+
const { Provider: LocalFooProvider, useModel: useLocalFooModel } = createApp();
|
50
|
+
const { Provider: LocalBarProvider, useModel: useLocalBarModel } = createApp();
|
51
|
+
|
52
|
+
function Foo() {
|
53
|
+
const [fooState] = useLocalFooModel(fooModel);
|
54
|
+
const [barState] = useLocalBarModel(fooModel);
|
55
|
+
|
56
|
+
return (
|
57
|
+
<div>
|
58
|
+
<div>Foo: {fooState}</div>
|
59
|
+
<div>Bar: {barState}</div>
|
60
|
+
</div>
|
61
|
+
);
|
62
|
+
}
|
63
|
+
|
64
|
+
function Container() {
|
65
|
+
return (
|
66
|
+
<LocalFooProvider>
|
67
|
+
<LocalBarProvider>
|
68
|
+
<Foo />
|
69
|
+
</LocalBarProvider>
|
70
|
+
</LocalFooProvider>
|
71
|
+
);
|
72
|
+
}
|
73
|
+
```
|
@@ -0,0 +1,62 @@
|
|
1
|
+
---
|
2
|
+
sidebar_position: 10
|
3
|
+
title: createStore
|
4
|
+
---
|
5
|
+
|
6
|
+
import ReduckTip from '@site-docs/components/reduck-tip.md'
|
7
|
+
|
8
|
+
<ReduckTip />
|
9
|
+
|
10
|
+
|
11
|
+
`createStore` is used to create a Store. Reduck’s Store based on Redux's [Store](https://redux.js.org/api/store) implementatio. Used to store the state of the application and managing the state and Model.
|
12
|
+
|
13
|
+
In general, this API is only used when you need to have full control over the creation of the Store. For example, to customize a Store, pass in the ['Provider'](./Provider.md) component to use.
|
14
|
+
|
15
|
+
|
16
|
+
## Function Signature
|
17
|
+
|
18
|
+
```ts
|
19
|
+
interface StoreConfig {
|
20
|
+
initialState?: Record<string, any>;
|
21
|
+
middlewares?: Middleware[];
|
22
|
+
models?: Model[];
|
23
|
+
plugins?: Plugin[];
|
24
|
+
enhancers?: StoreEnhancer[];
|
25
|
+
}
|
26
|
+
|
27
|
+
interface ReduckStore extends ReduxStore {
|
28
|
+
use: typeof useModel;
|
29
|
+
unmount: (model: Model) => void;
|
30
|
+
}
|
31
|
+
|
32
|
+
function createStore(config?: StoreConfig): ReduckStore;
|
33
|
+
```
|
34
|
+
|
35
|
+
### Input
|
36
|
+
|
37
|
+
- `config`: store options.
|
38
|
+
- `initialState`: set the initial state for store.
|
39
|
+
- `models`: set the Model to mount to the Store in advance(No need for normal use).
|
40
|
+
- `middlewares`: set Redux [middleware](https://redux.js.org/understanding/thinking-in-redux/glossary#middleware).
|
41
|
+
- `enhancers`: set Redux [Store enhancer](https://redux.js.org/understanding/thinking-in-redux/glossary#store-enhancer).
|
42
|
+
- `plugins`: set Reduck plugin。***experimental API, not recommended***。
|
43
|
+
|
44
|
+
### Return Value
|
45
|
+
|
46
|
+
Reduck Store:
|
47
|
+
|
48
|
+
- `use`: mount and fetch Model objects dynamically. Usage is the same as ['useModel'](./use-model.md), but can be used outside of React components.
|
49
|
+
- `unmount`: unmount the Model object, and the Model State is cleared from the Store.
|
50
|
+
- `ReduxStore`: [Redux Store API](https://redux.js.org/tutorials/fundamentals/part-4-store#redux-store).
|
51
|
+
|
52
|
+
|
53
|
+
## Example
|
54
|
+
```tsx
|
55
|
+
const store = createStore();
|
56
|
+
|
57
|
+
function load() {
|
58
|
+
const [, actions] = store.use(fooModel);
|
59
|
+
|
60
|
+
actions.load();
|
61
|
+
}
|
62
|
+
```
|
@@ -0,0 +1,105 @@
|
|
1
|
+
---
|
2
|
+
sidebar_position: 7
|
3
|
+
title: handleEffect
|
4
|
+
---
|
5
|
+
|
6
|
+
import ReduckTip from '@site-docs/components/reduck-tip.md'
|
7
|
+
|
8
|
+
<ReduckTip />
|
9
|
+
|
10
|
+
An asynchronous function type Effect usually has three states that need to be processed: in request, request successful, and request failed. The way to handle these states is to write the Action functions (pending, fulfilled, rejected).
|
11
|
+
|
12
|
+
With the help of the `handleEffect` API, we can generate default Action functions to handle different results at each stage of an asynchronous request. The structure of the State returned by the Action generated by `handleEffect` is as follows:
|
13
|
+
|
14
|
+
```ts
|
15
|
+
interface State {
|
16
|
+
result: any; // result of fulfilled state
|
17
|
+
pending: boolean; // request is pending
|
18
|
+
error: string; // request error message
|
19
|
+
}
|
20
|
+
```
|
21
|
+
|
22
|
+
## Function Signature
|
23
|
+
|
24
|
+
```ts
|
25
|
+
interface EffectActions {
|
26
|
+
pending: Action;
|
27
|
+
fulfilled: Action;
|
28
|
+
rejected: Action;
|
29
|
+
}
|
30
|
+
|
31
|
+
interface Config {
|
32
|
+
ns?: string;
|
33
|
+
result?: string | false;
|
34
|
+
error?: string | false;
|
35
|
+
pending?: string | false;
|
36
|
+
combineMode?: 'merge' | 'replace';
|
37
|
+
omitResultNamespace?: boolean;
|
38
|
+
}
|
39
|
+
|
40
|
+
function handleEffect(config: Config): EffectActions;
|
41
|
+
```
|
42
|
+
|
43
|
+
### Input
|
44
|
+
|
45
|
+
- `ns`: the default returned State structure is flat, By setting this parameter, the returned State can be mounted under the field named by the `ns`. For example, if `ns` is set to `"data"`, the returned structure is:
|
46
|
+
|
47
|
+
```ts
|
48
|
+
interface State {
|
49
|
+
data: {
|
50
|
+
pending: boolean;
|
51
|
+
result: any;
|
52
|
+
error: string;
|
53
|
+
}
|
54
|
+
}
|
55
|
+
```
|
56
|
+
|
57
|
+
- `result`: the default value is "result". This parameter corresponds to the field name that stores the fulfilled state results. For example, set `result` to `"items"`, the returned State structure is:
|
58
|
+
|
59
|
+
```ts
|
60
|
+
interface State {
|
61
|
+
items: any; // 默认的 result -> items
|
62
|
+
pending: boolean;
|
63
|
+
error: string;
|
64
|
+
}
|
65
|
+
```
|
66
|
+
|
67
|
+
if `result` is `false`,then returned State has no `result`:
|
68
|
+
|
69
|
+
```ts
|
70
|
+
interface State {
|
71
|
+
pending: boolean;
|
72
|
+
error: string;
|
73
|
+
}
|
74
|
+
```
|
75
|
+
|
76
|
+
- `pending`: the default value is `"pending"`. Change the name of the `pending` field in the returned State. Usage is the same as `result`.
|
77
|
+
|
78
|
+
- `error`: the default value is `"error"`. Change the name of the `error` field in the returned State. Usage is the same as `result`.
|
79
|
+
|
80
|
+
- `combineMode`: the default value is `"merge"`。get fulfilled state results. There are two ways to deal with it (The data types that can be automatically processed here are also limited to simple object or array types):
|
81
|
+
- `"merge"`: the previous data is merged with the current data. the data is an array type, operation is similar to `[].concat(lastData, currentData)`. the data is an object,operation is similar to `{...lastData, ...curData}`.
|
82
|
+
- `"replace"`: the current data directly replaces the previous data.
|
83
|
+
|
84
|
+
- `omitResultNamespace`: the default value is `false`. When the result is an object type, you want to mount the result directly on the State of the Model, rather than on "result", you can set it to true. For example:
|
85
|
+
|
86
|
+
```ts
|
87
|
+
// the result: {user: 'xx', email: 'xx'},
|
88
|
+
// config handleEffect({ omitResultNamespace: true })
|
89
|
+
// get State like follows:
|
90
|
+
{
|
91
|
+
user: 'xx',
|
92
|
+
email: 'xx',
|
93
|
+
pending: false,
|
94
|
+
error: null,
|
95
|
+
}
|
96
|
+
```
|
97
|
+
|
98
|
+
|
99
|
+
### Return Type
|
100
|
+
|
101
|
+
Objects are processed by actions in pending, fulfilled, and rejected states.
|
102
|
+
|
103
|
+
:::info More
|
104
|
+
[Manage Effect](/docs/guides/topic-detail/model/manage-effects).
|
105
|
+
:::
|
@@ -0,0 +1,197 @@
|
|
1
|
+
---
|
2
|
+
sidebar_position: 1
|
3
|
+
title: model
|
4
|
+
---
|
5
|
+
|
6
|
+
import ReduckTip from '@site-docs/components/reduck-tip.md'
|
7
|
+
|
8
|
+
<ReduckTip />
|
9
|
+
|
10
|
+
:::tip
|
11
|
+
The original type of Reduck is complex. The following type definition shows the simplified type information. For the original type, see [**model**](https://github.com/modern-js-dev/reduck/blob/main/packages/store/src/model/model.ts)。
|
12
|
+
:::
|
13
|
+
|
14
|
+
## model
|
15
|
+
|
16
|
+
Create a Model for managing application state.
|
17
|
+
|
18
|
+
`function model(name: string): { define: function }`
|
19
|
+
|
20
|
+
- name: `string`, the unique id of the Model created.
|
21
|
+
|
22
|
+
```ts title="example"
|
23
|
+
model('foo');
|
24
|
+
```
|
25
|
+
|
26
|
+
## define
|
27
|
+
|
28
|
+
Used to define the detailed structure of the Model, supporting passing in an object type or function type parameter.
|
29
|
+
|
30
|
+
### Object Type
|
31
|
+
|
32
|
+
`function define(modelDesc: ModelDesc): Model;`
|
33
|
+
|
34
|
+
- modelDesc: `ModelDesc`,definition of Model structure,includes `state`、`computed`、`actions`、`effects` etc. props.
|
35
|
+
|
36
|
+
```tsx title="example"
|
37
|
+
const fooModel = model('foo').define({
|
38
|
+
state: 'foo',
|
39
|
+
computed: {
|
40
|
+
cFoo: state => `c${state}`,
|
41
|
+
},
|
42
|
+
actions: {
|
43
|
+
setState: (state, value) => {
|
44
|
+
return value;
|
45
|
+
},
|
46
|
+
},
|
47
|
+
effects: {
|
48
|
+
loadState: async () => {
|
49
|
+
// get state from remote
|
50
|
+
},
|
51
|
+
},
|
52
|
+
});
|
53
|
+
```
|
54
|
+
|
55
|
+
### Function Type
|
56
|
+
|
57
|
+
`function define((context: Context, utils: Utils) => ModelDesc): Model;`
|
58
|
+
|
59
|
+
- `context`: Reduck Context, can get underlying `store` object. `store` support all Redux Store [API](https://redux.js.org/api/store), also mounts the `use` method for consuming the Model, and the `unmount` method for unmounting the Model.
|
60
|
+
- utils: commonly used tool like `use`、`onMount`. `use` is the same as `store.use`,`onMount` is the hook function after the Model is mounted.
|
61
|
+
|
62
|
+
<!-- TODO: @anchao 调整类型 -->
|
63
|
+
```ts
|
64
|
+
interface Utils {
|
65
|
+
use: UseModel;
|
66
|
+
onMount: OnMountHook;
|
67
|
+
}
|
68
|
+
|
69
|
+
interface Context {
|
70
|
+
store: ReduxStore & {
|
71
|
+
use: UseModel;
|
72
|
+
unmount: (model: Model) => void;
|
73
|
+
};
|
74
|
+
}
|
75
|
+
```
|
76
|
+
|
77
|
+
For example, through `use`, you can get the `state` and `actions` of the Model itself and other Models.
|
78
|
+
|
79
|
+
```tsx title="example"
|
80
|
+
const fooModel = model('foo').define(() => {
|
81
|
+
return {
|
82
|
+
state: 'foo',
|
83
|
+
actions: {
|
84
|
+
setState: (state, value) => {
|
85
|
+
return value;
|
86
|
+
},
|
87
|
+
},
|
88
|
+
};
|
89
|
+
});
|
90
|
+
|
91
|
+
const barModel = model('bar').define((_, { use }) => {
|
92
|
+
return {
|
93
|
+
state: 'bar',
|
94
|
+
effects: {
|
95
|
+
syncFoo() {
|
96
|
+
const [state, actions] = use(fooModel);
|
97
|
+
actions.setState(state);
|
98
|
+
},
|
99
|
+
},
|
100
|
+
};
|
101
|
+
});
|
102
|
+
```
|
103
|
+
|
104
|
+
### Input
|
105
|
+
|
106
|
+
#### ModelDesc.state
|
107
|
+
|
108
|
+
Define the state of the Model. Technically, any type of **State** is supported, but in practice it is recommended to use a JSON serializable type.
|
109
|
+
|
110
|
+
```ts
|
111
|
+
interface ModelDesc {
|
112
|
+
state: any;
|
113
|
+
}
|
114
|
+
```
|
115
|
+
|
116
|
+
#### ModelDesc.actions
|
117
|
+
|
118
|
+
Define the Actions of the Model. The function type of Actions is:
|
119
|
+
|
120
|
+
```ts
|
121
|
+
interface ModelDesc {
|
122
|
+
actions: {
|
123
|
+
[actionKey: string]: (state: State, payload: any) => State | void;
|
124
|
+
};
|
125
|
+
}
|
126
|
+
```
|
127
|
+
|
128
|
+
Reduck internally integrates [immer](https://github.com/immerjs/immer), which can directly return the original `state`. When the Action has no explicit return value, Reduck internally returns a modified new State object.
|
129
|
+
|
130
|
+
#### ModelDesc.computed
|
131
|
+
|
132
|
+
Defines the derived state of the Model. The definition of derived state supports two types:
|
133
|
+
|
134
|
+
1. Depends only on the state of the Model itself
|
135
|
+
|
136
|
+
```ts
|
137
|
+
interface ModelDesc {
|
138
|
+
computed: {
|
139
|
+
[computedKey: string]: (state: State) => any;
|
140
|
+
};
|
141
|
+
}
|
142
|
+
```
|
143
|
+
|
144
|
+
|
145
|
+
2. Depends on the state of other Models
|
146
|
+
|
147
|
+
```ts
|
148
|
+
interface ModelDesc {
|
149
|
+
computed: {
|
150
|
+
[computedKey: string]: [
|
151
|
+
...models: Model[],
|
152
|
+
(state: State, ...args: ModelState[]) => any,
|
153
|
+
];
|
154
|
+
};
|
155
|
+
}
|
156
|
+
```
|
157
|
+
|
158
|
+
```ts title="example"
|
159
|
+
const fooModel = model('foo').define({
|
160
|
+
state: 'foo',
|
161
|
+
});
|
162
|
+
|
163
|
+
const barModel = model('bar').define({
|
164
|
+
state: 'bar',
|
165
|
+
computed: {
|
166
|
+
combineFoo: [fooModel, (state, fooState) => state + fooState],
|
167
|
+
},
|
168
|
+
});
|
169
|
+
```
|
170
|
+
|
171
|
+
#### ModelDesc.effects
|
172
|
+
|
173
|
+
Defines the Effects of the Model. The function types defined in Effects are:
|
174
|
+
|
175
|
+
```ts
|
176
|
+
interface ModelDesc {
|
177
|
+
effects: {
|
178
|
+
[effectKey: string]: (...args: any[]) => any;
|
179
|
+
};
|
180
|
+
}
|
181
|
+
```
|
182
|
+
|
183
|
+
```ts title="example"
|
184
|
+
const fooModel = model('foo').define((context, { use }) => ({
|
185
|
+
state: 'foo',
|
186
|
+
effects: {
|
187
|
+
persist() {
|
188
|
+
const [state] = use(fooModel);
|
189
|
+
localStorage.setItem('state', state);
|
190
|
+
},
|
191
|
+
},
|
192
|
+
}));
|
193
|
+
```
|
194
|
+
|
195
|
+
:::info More
|
196
|
+
[Define Model](/docs/guides/topic-detail/model/define-model).
|
197
|
+
:::
|
@@ -0,0 +1,27 @@
|
|
1
|
+
---
|
2
|
+
sidebar_position: 4
|
3
|
+
title: useLocalModel
|
4
|
+
---
|
5
|
+
|
6
|
+
import ReduckTip from '@site-docs/components/reduck-tip.md'
|
7
|
+
|
8
|
+
<ReduckTip />
|
9
|
+
|
10
|
+
To use the State in the Model as a local state, the effect is similar to React's `useState`. `useLocalModel` API same as `useModel`. For detail, see [`useModel`](./use-model.md)。
|
11
|
+
|
12
|
+
## Example
|
13
|
+
|
14
|
+
```tsx
|
15
|
+
function Container() {
|
16
|
+
const [state, actions] = useLocalModel(modelA);
|
17
|
+
const [state1, actions1] = useLocalModel(modelA);
|
18
|
+
|
19
|
+
// ...
|
20
|
+
}
|
21
|
+
```
|
22
|
+
|
23
|
+
`modelA` was loaded twice with useLocalModel above, because useLocalModel consumes local state, so state and state1 are also completely isolated.
|
24
|
+
|
25
|
+
:::info More
|
26
|
+
[Use Model](/docs/guides/topic-detail/model/use-model).
|
27
|
+
:::
|
@@ -0,0 +1,89 @@
|
|
1
|
+
---
|
2
|
+
sidebar_position: 2
|
3
|
+
title: useModel
|
4
|
+
---
|
5
|
+
|
6
|
+
import ReduckTip from '@site-docs/components/reduck-tip.md'
|
7
|
+
|
8
|
+
<ReduckTip />
|
9
|
+
|
10
|
+
:::tip
|
11
|
+
The original type of Reduck is complex. The following type definition shows the simplified type information. For the original type, see [**model**](https://github.com/modern-js-dev/reduck/blob/main/packages/store/src/model/model.ts)。
|
12
|
+
:::
|
13
|
+
|
14
|
+
|
15
|
+
## Function Signature
|
16
|
+
|
17
|
+
```ts
|
18
|
+
function useModel(
|
19
|
+
models: Models[],
|
20
|
+
stateSelector?: StateSelector,
|
21
|
+
actionSelector?: ActionSelector,
|
22
|
+
): [state, actions, subscribe];
|
23
|
+
function useModel(
|
24
|
+
...models: Models[],
|
25
|
+
stateSelector?: (...args: State[]) => any,
|
26
|
+
actionSelector?: (...args: Actions[]) => any,
|
27
|
+
): [state, actions, subscribe];
|
28
|
+
```
|
29
|
+
|
30
|
+
|
31
|
+
### Input
|
32
|
+
|
33
|
+
- models: Array of Model objects, which can be passed in as an array type parameter, or all Models can be passed in as parameters one by one.
|
34
|
+
- stateSelector: Optional parameters, used to filter State calculations. The first n parameters are the States corresponding to n Models, and the returned data is used as the first element of the `useModel` return value array.
|
35
|
+
- actionSelector: Optional parameters, used to filter Action calculations. The first n parameters are the States corresponding to n Models, and the returned data is used as the second element of the `useModel` return value array.
|
36
|
+
|
37
|
+
|
38
|
+
### Return Value
|
39
|
+
|
40
|
+
Returns an array with each value:
|
41
|
+
|
42
|
+
- state: return value of `stateSelector`. if there is no `stateSelector`,will combine all incoming Model States(including derived states) and return them. If there is an attribute of the same name in the State of different Models, the following State will override the previous State. when `state` changes,the component call `useModel` will re-render.
|
43
|
+
- actions: return value of `actionSelector`. if there is no `actionSelector`,will combine all incoming Model Action(including Effect) and return them. If there is an attribute of the same name in the Action of different Models, the following Action will override the previous Action.
|
44
|
+
- subscribe: A function that subscribes to State changes. This function is called when the State of any Model passed in changes.
|
45
|
+
|
46
|
+
## Example
|
47
|
+
|
48
|
+
### Basic
|
49
|
+
|
50
|
+
```tsx
|
51
|
+
import todoModel from 'models/todo';
|
52
|
+
import filterModel from 'models/filter';
|
53
|
+
|
54
|
+
function Test(props) {
|
55
|
+
const [state, actions] = useModel([todoModel, filterModel]);
|
56
|
+
actions.add(); // call todoModel add action
|
57
|
+
actions.setVisibleStatus(); // call filterModel filterModel action
|
58
|
+
|
59
|
+
state.items; // get todoModel state items
|
60
|
+
state.visibleStatus; // get filterModel state visibleStatus
|
61
|
+
}
|
62
|
+
```
|
63
|
+
|
64
|
+
### Selector Usage
|
65
|
+
|
66
|
+
```js
|
67
|
+
function Test(props) {
|
68
|
+
const [state, actions] = useModel(
|
69
|
+
[todoModel, filterModel],
|
70
|
+
(todoState, filterState) => ({
|
71
|
+
items: todoState.items,
|
72
|
+
visibleStatus: `${props.prefix}-${filterState.visibleStatus}`,
|
73
|
+
}),
|
74
|
+
(todoActions, filterActions) => ({
|
75
|
+
...todoActions,
|
76
|
+
...filterActions,
|
77
|
+
}),
|
78
|
+
);
|
79
|
+
actions.add(); // call todoModel add action
|
80
|
+
actions.setVisibleStatus(); // call filterModel filterModel action
|
81
|
+
|
82
|
+
state.items; // get todoModel state items
|
83
|
+
state.visibleStatus; // get filterModel state visibleStatus
|
84
|
+
}
|
85
|
+
```
|
86
|
+
|
87
|
+
:::info More
|
88
|
+
[use Model](/docs/guides/topic-detail/model/use-model).
|
89
|
+
:::
|
@@ -0,0 +1,49 @@
|
|
1
|
+
---
|
2
|
+
sidebar_position: 3
|
3
|
+
title: useStaticModel
|
4
|
+
---
|
5
|
+
|
6
|
+
import ReduckTip from '@site-docs/components/reduck-tip.md'
|
7
|
+
|
8
|
+
<ReduckTip />
|
9
|
+
|
10
|
+
If want to consume a Model in the form of React Hook in the component,and can get the current latest state at any time,but you don't want the Model state to be updated, which will cause the component to be re-rendered, we can use `useStaticModel`。
|
11
|
+
|
12
|
+
`useStaticModel` API is same as `useModel`。For detail, see [`useModel`](./use-model.md)。
|
13
|
+
|
14
|
+
To ensure that the latest state is always available, be careful not to deconstruct the returned `state`.
|
15
|
+
|
16
|
+
```tsx
|
17
|
+
function App() {
|
18
|
+
// ❌ Do not deconstruct state,but can deconstruct actions。
|
19
|
+
const [{ username }, { logout }] = useStaticModel(userModel);
|
20
|
+
|
21
|
+
// ✅ True Usage。
|
22
|
+
const [state, { logout }] = useStaticModel(userModel);
|
23
|
+
|
24
|
+
useEffect(() => {
|
25
|
+
state.username;
|
26
|
+
}, []);
|
27
|
+
}
|
28
|
+
```
|
29
|
+
|
30
|
+
## Example
|
31
|
+
|
32
|
+
The following `App` component consumes the `userModel` state, but does not use it directly in JSX. It can be found that changes in the `userModel` state do not necessarily cause the component to re-render. This situation can be optimized using `useStaticModel`.
|
33
|
+
|
34
|
+
```tsx
|
35
|
+
function App() {
|
36
|
+
const [state] = useStaticModel(userModel);
|
37
|
+
|
38
|
+
useEffect(() => {
|
39
|
+
// 统计 UV 数据
|
40
|
+
send('pageview', { user: state.user });
|
41
|
+
}, [state]);
|
42
|
+
|
43
|
+
return <div>Hello</div>;
|
44
|
+
}
|
45
|
+
```
|
46
|
+
|
47
|
+
:::info More
|
48
|
+
[Use Model](/docs/guides/topic-detail/model/use-model).
|
49
|
+
:::
|
@@ -0,0 +1,48 @@
|
|
1
|
+
---
|
2
|
+
sidebar_position: 9
|
3
|
+
title: useStore
|
4
|
+
---
|
5
|
+
|
6
|
+
import ReduckTip from '@site-docs/components/reduck-tip.md'
|
7
|
+
|
8
|
+
<ReduckTip />
|
9
|
+
|
10
|
+
`useStore` Used to get the store shared by the current component tree.
|
11
|
+
|
12
|
+
|
13
|
+
## Function Signature
|
14
|
+
|
15
|
+
```ts
|
16
|
+
function useStore(): ReduckStore;
|
17
|
+
```
|
18
|
+
|
19
|
+
### Return Type
|
20
|
+
|
21
|
+
- ReduckStore: Reduck Store,type refer to the return type of [createStore](./create-store.md).
|
22
|
+
|
23
|
+
## Example
|
24
|
+
|
25
|
+
```ts
|
26
|
+
// guarantee that getStore executes after the component tree mounted
|
27
|
+
setTimeout(() => {
|
28
|
+
const store = getStore();
|
29
|
+
const [, actions] = store.use(countModel);
|
30
|
+
setInterval(() => {
|
31
|
+
actions.add();
|
32
|
+
}, 1000);
|
33
|
+
}, 1000);
|
34
|
+
|
35
|
+
function Counter() {
|
36
|
+
const [state] = useModel(countModel);
|
37
|
+
|
38
|
+
return (
|
39
|
+
<div>
|
40
|
+
<div>counter: {state.value}</div>
|
41
|
+
</div>
|
42
|
+
);
|
43
|
+
}
|
44
|
+
```
|
45
|
+
|
46
|
+
:::info More
|
47
|
+
[Use Model](/docs/guides/topic-detail/model/use-model).
|
48
|
+
:::
|
@@ -0,0 +1,26 @@
|
|
1
|
+
---
|
2
|
+
sidebar_position: 1
|
3
|
+
---
|
4
|
+
|
5
|
+
# 概览
|
6
|
+
|
7
|
+
Modern.js 的基础的插件系统中主要分为三个部分: Hook 模型(Pipeline、Workflow、Waterfall)、 Hook 模型的管理器(Manager),上下文共享机制。
|
8
|
+
|
9
|
+
其中的 Hook 模型是用于管理运行一系列相同模型(形状)函数的管理工具,目前提供了三个大类,7个小类:
|
10
|
+
|
11
|
+
- Pipeline
|
12
|
+
- Sync
|
13
|
+
- Async
|
14
|
+
- Waterfall
|
15
|
+
- Sync
|
16
|
+
- Async
|
17
|
+
- Workflow
|
18
|
+
- Sync
|
19
|
+
- Async
|
20
|
+
- Parallel(Async)
|
21
|
+
|
22
|
+
它们之间的区别是他们所管理的函数的运行模式的不同。不同的地方会在下面具体分析介绍。
|
23
|
+
|
24
|
+
Hook 模型的管理器(Manager),顾名思义就是用来管理上面提到的那些 Hook 模型,添加至同一个 Manager 可以使用同一个 Runner 对象(包含所有 Hook 的执行函数)来运行,也共享同一个上下文环境。而 Modern.js 的基础插件系统中的插件就是针对 Manager 来说的,是一个拥有属性、插件 Hook 函数的对象。
|
25
|
+
|
26
|
+
基于上面的工具(Hook 模型 + Manager),在 Modern.js 中主要构建了三套插件模型: CLI、Runtime、Server。其中 CLI 是 Modern.js 中主要的运行流程控制模型,Modern.js 中的各种工程方案(应用工程方案、模块工程方案、Monorepo 工程方案)都是主要通过这一套模型运行的。而 Runtime 则主要负责的是 React 路由组件和元素的处理(Component 和 Element)和渲染(包括服务器端渲染和客户端渲染)。而 Server 则是针对 Server 运行时的这个阶段的生命周期运行和特殊信息收集。其中 Runtime 和 Server 的运行都是在 CLI 中触发的。
|