@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,83 @@
|
|
1
|
+
---
|
2
|
+
title: useLoader
|
3
|
+
---
|
4
|
+
|
5
|
+
Isomorphic API,usually used to make asynchronous requests。When SSR, the server level uses `useLoader` to prefetch the data, and the browser side also reuses this part of the data.
|
6
|
+
|
7
|
+
## Usage
|
8
|
+
|
9
|
+
```ts
|
10
|
+
import { useLoader } from '@modern-js/runtime';
|
11
|
+
```
|
12
|
+
|
13
|
+
## Function Signature
|
14
|
+
|
15
|
+
```ts
|
16
|
+
type LoaderFn = (context: runtimeContext) => Promise<unknow>;
|
17
|
+
type Options = {
|
18
|
+
onSuccess: (data: Record<string, any>) => void;
|
19
|
+
onError: (error: Error) => void;
|
20
|
+
initialData: Record<string, any>;
|
21
|
+
skip: boolean;
|
22
|
+
params: Record<string, any>;
|
23
|
+
static: boolean;
|
24
|
+
}
|
25
|
+
type ReturnData = {
|
26
|
+
data: Record<string, any>;
|
27
|
+
loading: boolean;
|
28
|
+
error: Error;
|
29
|
+
reload: (params?: Record<string, any>) => Promise<any> | undefined;
|
30
|
+
reloading: boolean;
|
31
|
+
}
|
32
|
+
|
33
|
+
function useLoader(loaderFn: LoaderFn, options: Options): ReturnData;
|
34
|
+
```
|
35
|
+
|
36
|
+
:::info
|
37
|
+
`runtimeContext` can refer to [useRuntimeContext](/docs/apis/app/runtime/core/use-runtime-context)。
|
38
|
+
:::
|
39
|
+
|
40
|
+
### Input
|
41
|
+
|
42
|
+
- `loaderFn`: function for loading data, returning a Promise.
|
43
|
+
- `options`: optional configuration.
|
44
|
+
- `onSuccess`: successful callback.
|
45
|
+
- `onError`: error callback.
|
46
|
+
- `initialData`: the initial data before the first execution,.
|
47
|
+
- `skip`: when the value is `true`, the function does not execute.
|
48
|
+
- `params`: when the result of the `params` serialization changes,the function is re-executed。`params` is also passed in as the second argument of the function.
|
49
|
+
- `static`: when the value is `true`, `useLoader` is used for [SSG](/docs/guides/advanced-features/ssg).
|
50
|
+
|
51
|
+
### Return Value
|
52
|
+
|
53
|
+
- `data`: return data on successful execution.
|
54
|
+
- `loading`: indicates whether the function is in execution.
|
55
|
+
- `error`: error message when function execution fails。
|
56
|
+
- `reload`: the function can be re-executed after the call.
|
57
|
+
- `params`: when the value is `undefined`, the last value will be reused; otherwise, the function will be re-executed with the new value.
|
58
|
+
- `reloading`: during the execution of the call to `reload`, the value of `reloading` is `true`.
|
59
|
+
|
60
|
+
## Example
|
61
|
+
|
62
|
+
```ts
|
63
|
+
function Container() {
|
64
|
+
const { data, error, loading } = useLoader(
|
65
|
+
async (context, params) => {
|
66
|
+
console.log(params) // nicole
|
67
|
+
return fetch(user);
|
68
|
+
},
|
69
|
+
{
|
70
|
+
onSuccess: data => {
|
71
|
+
console.log('I did success:(', data);
|
72
|
+
},
|
73
|
+
onError: error => {
|
74
|
+
console.log('I met error:)', error);
|
75
|
+
},
|
76
|
+
initialData: { name: 'nicole', gender: 'female' },
|
77
|
+
params: 'nicole'
|
78
|
+
}
|
79
|
+
);
|
80
|
+
|
81
|
+
return ...;
|
82
|
+
}
|
83
|
+
```
|
@@ -0,0 +1,101 @@
|
|
1
|
+
---
|
2
|
+
title: useModuleApps
|
3
|
+
---
|
4
|
+
|
5
|
+
Returns the React components of all micro-front-end sub-applications for freely controlled routing.
|
6
|
+
|
7
|
+
## Usage
|
8
|
+
|
9
|
+
```tsx
|
10
|
+
import { useModuleApps } from '@modern/plugin-garfish';
|
11
|
+
```
|
12
|
+
|
13
|
+
:::info Turn on
|
14
|
+
This API is used in the main application of micro frontend, please execute `pnpm run new` to turn on the micro frontend function first.
|
15
|
+
|
16
|
+
```bash
|
17
|
+
pnpm run new
|
18
|
+
? 请选择你想要的操作 启用可选功能
|
19
|
+
? 启用可选功能 启用「微前端」模式
|
20
|
+
```
|
21
|
+
:::
|
22
|
+
|
23
|
+
## Function Signature
|
24
|
+
|
25
|
+
`function useModuleApps(): Record<string, React.FC<any>>`
|
26
|
+
|
27
|
+
Returns the React components wrapped around each subapp.
|
28
|
+
|
29
|
+
## Example
|
30
|
+
|
31
|
+
You need to configure the micro-front-end sub-application information first.
|
32
|
+
|
33
|
+
```ts title=modern.config.js
|
34
|
+
module.exports = {
|
35
|
+
runtime: {
|
36
|
+
features:{
|
37
|
+
masterApp: {
|
38
|
+
apps: [
|
39
|
+
{
|
40
|
+
name: 'Home',
|
41
|
+
entry: 'http://www.home.com'
|
42
|
+
},
|
43
|
+
{
|
44
|
+
name: 'Contact',
|
45
|
+
entry: 'http://www.contact.com'
|
46
|
+
},
|
47
|
+
]
|
48
|
+
}
|
49
|
+
}
|
50
|
+
}
|
51
|
+
}
|
52
|
+
```
|
53
|
+
|
54
|
+
```tsx title=App.tsx
|
55
|
+
function App() {
|
56
|
+
const { Components: { Home, Contact } } = useModuleApps();
|
57
|
+
|
58
|
+
return <div>
|
59
|
+
Master APP
|
60
|
+
<Route exact path='/home'>
|
61
|
+
<Home />
|
62
|
+
</Route>
|
63
|
+
<Route exact path='/home'>
|
64
|
+
<Contact />
|
65
|
+
</Route>
|
66
|
+
</div>;
|
67
|
+
}
|
68
|
+
```
|
69
|
+
|
70
|
+
Get the `Home` and `Contact` sub-application components(the same as name in the config) through `useModuleApps()`. After that, you can load the child application just like a normal React component.
|
71
|
+
|
72
|
+
|
73
|
+
## Load Animation
|
74
|
+
|
75
|
+
The transition animation of the component loading process can be customized in the following ways.
|
76
|
+
|
77
|
+
```tsx title=App.tsx
|
78
|
+
function App() {
|
79
|
+
const { Components: { Home } } = useModuleApps();
|
80
|
+
|
81
|
+
return <div>
|
82
|
+
Master APP
|
83
|
+
<Route exact path='/home'>
|
84
|
+
<Home
|
85
|
+
loadable={{
|
86
|
+
loading: ({ pastDelay, error }: any) => {
|
87
|
+
if (error) {
|
88
|
+
console.error(error);
|
89
|
+
return <div>error: {error?.message}</div>;
|
90
|
+
} else if (pastDelay) {
|
91
|
+
return <div>loading</div>;
|
92
|
+
} else {
|
93
|
+
return null;
|
94
|
+
}
|
95
|
+
},
|
96
|
+
}}
|
97
|
+
/>
|
98
|
+
</Route>
|
99
|
+
</div>;
|
100
|
+
}
|
101
|
+
```
|
package/en/docusaurus-plugin-content-docs/current/apis/app/runtime/core/use-runtime-context.md
ADDED
@@ -0,0 +1,59 @@
|
|
1
|
+
---
|
2
|
+
title: useRuntimeContext
|
3
|
+
---
|
4
|
+
|
5
|
+
This function is mainly used to get the runtime context and can only be used in function components.
|
6
|
+
|
7
|
+
## Usage
|
8
|
+
|
9
|
+
```tsx
|
10
|
+
import { useRuntimeContext } from '@modern-js/runtime';
|
11
|
+
|
12
|
+
export function App() {
|
13
|
+
const runtimeContext = useRuntimeContext();
|
14
|
+
return <div>Hello World</div>
|
15
|
+
}
|
16
|
+
```
|
17
|
+
|
18
|
+
## Function Signature
|
19
|
+
|
20
|
+
```ts
|
21
|
+
type RuntimeContext = {
|
22
|
+
request: {
|
23
|
+
params: Record<string, string>;
|
24
|
+
pathname: string;
|
25
|
+
query: Record<string, string>;
|
26
|
+
headers: IncomingHttpHeaders;
|
27
|
+
cookie: string;
|
28
|
+
};
|
29
|
+
store: ReduckStore;
|
30
|
+
}
|
31
|
+
|
32
|
+
function useRuntimeContext(): RuntimeContext;
|
33
|
+
```
|
34
|
+
|
35
|
+
|
36
|
+
### Return Value
|
37
|
+
|
38
|
+
- `request`: additional information in the request context.
|
39
|
+
- `params`: dynamic parameters in the request path.
|
40
|
+
- `pathname`: the pathname of the request.
|
41
|
+
- `query`: the query of the request.
|
42
|
+
- `headers`: the header info of the request.
|
43
|
+
- `cookie`: the cookie of the request.
|
44
|
+
- `store`: when the runtime.state is enabled, this value is the reduck global `store`.
|
45
|
+
|
46
|
+
## Example
|
47
|
+
|
48
|
+
```tsx
|
49
|
+
import { useRuntimeContext } from '@modern-js/runtime';
|
50
|
+
import { fooModel } from '@/common/models';
|
51
|
+
|
52
|
+
function App() {
|
53
|
+
const { store } = useRuntimeContext();
|
54
|
+
|
55
|
+
const [state, actions] = store.use(fooModel);
|
56
|
+
|
57
|
+
return <div>state: {state}</div>
|
58
|
+
}
|
59
|
+
```
|
@@ -0,0 +1,25 @@
|
|
1
|
+
---
|
2
|
+
sidebar_position: 1
|
3
|
+
title: Default Alias
|
4
|
+
---
|
5
|
+
|
6
|
+
Modern.js recommend referring to the source code by alias, which contains 3 default aliases:
|
7
|
+
- `@/`: the file under the project root directory `src/* `.
|
8
|
+
- `@api/`: the file under the `api/*` in the project root directory (you need to enable the BFF first).
|
9
|
+
- `@shared/`: the file under the project root directory `shared/* `.
|
10
|
+
|
11
|
+
:::tip
|
12
|
+
In addition, developers can customize aliases in modern.config.js, see [Aliases](/docs/configure/app/source/alias) for detail.
|
13
|
+
:::
|
14
|
+
|
15
|
+
|
16
|
+
## Example
|
17
|
+
|
18
|
+
The following example shows how to reference a function by default alias.
|
19
|
+
|
20
|
+
```tsx
|
21
|
+
import { hello } from '@/common/utils';
|
22
|
+
|
23
|
+
hello();
|
24
|
+
```
|
25
|
+
A reference to `@/common/utils` is equal to a reference to `src/common/utils`.
|
@@ -0,0 +1,72 @@
|
|
1
|
+
---
|
2
|
+
sidebar_position: 1
|
3
|
+
title: Environment Variables
|
4
|
+
---
|
5
|
+
|
6
|
+
Modern.js has built-in support for environment variables, including built-in environment variables and custom environment variables.
|
7
|
+
|
8
|
+
## Built-in Environment Variables
|
9
|
+
|
10
|
+
### NODE_ENV
|
11
|
+
|
12
|
+
A **read-only** environment variable, whose have different values under different execution commands:
|
13
|
+
|
14
|
+
- `production`: default value when executing `modern build`、`modern preview` commands.
|
15
|
+
- `test`: default value when executing `modern test` commands.
|
16
|
+
- `development`: default value when executing `modern dev` commands, also the default value in all other cases.
|
17
|
+
|
18
|
+
### MODERN_ENV
|
19
|
+
|
20
|
+
Used to set the current execution environment.In addition to the values corresponding to the above NODE_ENV, custom environment names are supported here, such as `staging`, `boe`.
|
21
|
+
|
22
|
+
Modern.js loads the environment variables values set in the `.env.{process.env.MODERN_ENV}` file for that environment variable.
|
23
|
+
|
24
|
+
When you need to use different configurations through the environment name, you can define environment variables in the `.env` file of the corresponding environment name.
|
25
|
+
|
26
|
+
MODERN_ENV priority is higher than NODE_ENV.
|
27
|
+
|
28
|
+
## Custom Environment Variables
|
29
|
+
|
30
|
+
Modern.js support custom environment variables, which starting with MODERN_ can be used directly in the code.
|
31
|
+
|
32
|
+
If you need to automatically use environment variables with any name, you need to declare them in the ['source.define'](/docs/configure/app/source/define) configuration.
|
33
|
+
|
34
|
+
## Define Environment Variables
|
35
|
+
|
36
|
+
Environment variables are specified in both `shell` and `.env` files.
|
37
|
+
|
38
|
+
### Specify Via Shell
|
39
|
+
|
40
|
+
Add custom environment variables before the command:
|
41
|
+
|
42
|
+
```shell
|
43
|
+
REACT_APP_FOO=123 BAR=456 pnpm run dev
|
44
|
+
```
|
45
|
+
|
46
|
+
### Specify Via File
|
47
|
+
|
48
|
+
Create a `.env` file in the project with custom environment variables:
|
49
|
+
|
50
|
+
```env
|
51
|
+
REACT_APP_FOO=123
|
52
|
+
BAR=456
|
53
|
+
```
|
54
|
+
|
55
|
+
`.env` files support suffixes NODE_ENV or MODERN_ENV defined environment names, such as `env.development`. Modern.js reads the env file based on the environment name variable value.
|
56
|
+
|
57
|
+
## Using Environment Variables
|
58
|
+
|
59
|
+
### Use In JS
|
60
|
+
|
61
|
+
Get environment variables directly with `process.env.*`.
|
62
|
+
|
63
|
+
```js
|
64
|
+
console.log(process.env.NODE_ENV);
|
65
|
+
// "development"
|
66
|
+
```
|
67
|
+
|
68
|
+
### Use In HTML
|
69
|
+
|
70
|
+
```html title="config/html/head.ejs"
|
71
|
+
<meta name="env" content="<%=process.env.NODE_ENV %>" />
|
72
|
+
```
|
@@ -0,0 +1,35 @@
|
|
1
|
+
---
|
2
|
+
sidebar_position: 8
|
3
|
+
title: Provider
|
4
|
+
---
|
5
|
+
|
6
|
+
import ReduckTip from '@site-docs/components/reduck-tip.md'
|
7
|
+
|
8
|
+
<ReduckTip />
|
9
|
+
|
10
|
+
`Provider` is a component that injects Reduck's Store into the application's component tree, making the Model accessible to components inside the component tree. Normally, `Provider` is defined at the top level of the component tree.
|
11
|
+
|
12
|
+
## Function Signature
|
13
|
+
|
14
|
+
```ts
|
15
|
+
interface ProviderProps {
|
16
|
+
store?: ReduckStore;
|
17
|
+
config?: AppConfig;
|
18
|
+
}
|
19
|
+
```
|
20
|
+
|
21
|
+
### Input
|
22
|
+
|
23
|
+
- store: the Store object created by [`createStore`](./create-store.md).
|
24
|
+
- config: this config to create Reduck Store, same as `config` param in [`createApp`](./create-app.md).
|
25
|
+
|
26
|
+
## Example
|
27
|
+
|
28
|
+
```tsx title="App entry file"
|
29
|
+
ReactDOM.render(
|
30
|
+
<Provider>
|
31
|
+
<App />
|
32
|
+
</Provider>,
|
33
|
+
document.getElementById('root'),
|
34
|
+
);
|
35
|
+
```
|
@@ -0,0 +1,120 @@
|
|
1
|
+
---
|
2
|
+
sidebar_position: 6
|
3
|
+
title: Auto actions
|
4
|
+
---
|
5
|
+
|
6
|
+
import ReduckTip from '@site-docs/components/reduck-tip.md'
|
7
|
+
|
8
|
+
<ReduckTip />
|
9
|
+
|
10
|
+
Reduck can automatically generate Actions according to the type of State,for easy to modify State.
|
11
|
+
|
12
|
+
:::tip
|
13
|
+
can use [`runtime.state.autoActions`](/docs/configure/app/runtime/state#autoactions) close auto actions feature.
|
14
|
+
:::
|
15
|
+
|
16
|
+
## Example
|
17
|
+
|
18
|
+
### Basic Data Type
|
19
|
+
|
20
|
+
State type in `string`、`number`、`boolean`、`null`,generate `setState` Action。
|
21
|
+
|
22
|
+
```tsx title="example"
|
23
|
+
const fooModel = model('foo').define({
|
24
|
+
state: 1,
|
25
|
+
});
|
26
|
+
|
27
|
+
function App() {
|
28
|
+
const [state, actions] = useModel(fooModel);
|
29
|
+
|
30
|
+
return (
|
31
|
+
<div>
|
32
|
+
<div>State: {state}</div>
|
33
|
+
<button
|
34
|
+
type="button"
|
35
|
+
onClick={() => {
|
36
|
+
// call auto generate setState Action
|
37
|
+
actions.setState(state + 1);
|
38
|
+
}}
|
39
|
+
>
|
40
|
+
add
|
41
|
+
</button>
|
42
|
+
</div>
|
43
|
+
);
|
44
|
+
}
|
45
|
+
```
|
46
|
+
|
47
|
+
### Array
|
48
|
+
|
49
|
+
State type is Array,generate the following Actions:
|
50
|
+
|
51
|
+
- `push`: adds one or more elements to the end of the array.
|
52
|
+
- `pop`: removes the last element from the array.
|
53
|
+
- `shift`: removes the first element from the array.
|
54
|
+
- `unshift`: adds one or more elements to the beginning of the array.
|
55
|
+
- usage: `arr.unshift(element1, ..., elementN)`
|
56
|
+
- `elementN`: the element or elements to add to the beginning of the array.
|
57
|
+
- `filter`: filter element.
|
58
|
+
<!-- 语义与原生方法不同,待修改 API -->
|
59
|
+
- `concat`: concat array.
|
60
|
+
<!-- 语义与原生方法不同,待修改 API -->
|
61
|
+
- `splice`: modify the array by deleting or replacing existing elements or adding new elements in place, and return the modified array(Note that it is different from the native `splice` return value).
|
62
|
+
- usage: `splice(start[, deleteCount[, item1[, item2[, ...]]]])`
|
63
|
+
- `start`: specifies the start position of the modification(counting from 0).
|
64
|
+
- `deleteCount`: an integer representing the number of array elements to remove.
|
65
|
+
- `item, item2, ...`: The elements to add to the array, starting at the start position. If not specified, `splice` will only delete array elements.
|
66
|
+
|
67
|
+
```tsx title="example"
|
68
|
+
const fooModel = model('foo').define({
|
69
|
+
state: [1, 2, 3],
|
70
|
+
});
|
71
|
+
|
72
|
+
function App() {
|
73
|
+
const [state, actions] = useModel(fooModel);
|
74
|
+
|
75
|
+
useEffect(() => {
|
76
|
+
actions.push(4);
|
77
|
+
actions.pop();
|
78
|
+
actions.shift(0);
|
79
|
+
actions.unshift();
|
80
|
+
actions.filter(val => val <= 2);
|
81
|
+
actions.splice(0, 1, 1, 2);
|
82
|
+
}, []);
|
83
|
+
|
84
|
+
return (
|
85
|
+
<div>
|
86
|
+
<div>State: {state}</div>
|
87
|
+
</div>
|
88
|
+
);
|
89
|
+
}
|
90
|
+
```
|
91
|
+
|
92
|
+
### PlainObject
|
93
|
+
|
94
|
+
State type is PlainObject,base on the names contained in State,generate `set${key}`(Camel-Case) Actions。
|
95
|
+
|
96
|
+
```tsx title="example"
|
97
|
+
const fooModel = model('foo').define({
|
98
|
+
state: {
|
99
|
+
a: 1,
|
100
|
+
b: { value: 1 },
|
101
|
+
c: 'c',
|
102
|
+
},
|
103
|
+
});
|
104
|
+
|
105
|
+
function App() {
|
106
|
+
const [state, actions] = useModel(fooModel);
|
107
|
+
|
108
|
+
useEffect(() => {
|
109
|
+
actions.setA(2);
|
110
|
+
actions.setB({ value: 2 });
|
111
|
+
actions.setC('d');
|
112
|
+
}, []);
|
113
|
+
|
114
|
+
return (
|
115
|
+
<div>
|
116
|
+
<div>State: {state}</div>
|
117
|
+
</div>
|
118
|
+
);
|
119
|
+
}
|
120
|
+
```
|
@@ -0,0 +1,140 @@
|
|
1
|
+
---
|
2
|
+
sidebar_position: 5
|
3
|
+
title: connect
|
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 [**connect**](https://github.com/modern-js-dev/reduck/blob/main/packages/react/src/connect.ts)。
|
12
|
+
:::
|
13
|
+
|
14
|
+
`Connect` is the same as `useModel` and is the corresponding HOC-style API. It is recommended to use the Hook-style `useModel` first.
|
15
|
+
|
16
|
+
|
17
|
+
## Function Signature
|
18
|
+
|
19
|
+
```ts
|
20
|
+
type SelectStateToProps = (...modelStates: State[], ownProps? :any) => PlainObject;
|
21
|
+
type SelectActionsToProps = (...modelActions: Actions[], ownProps? :any) => PlainObject;
|
22
|
+
|
23
|
+
function connect(models: Model, options?: ConnectOptions);
|
24
|
+
function connect(
|
25
|
+
models: [...Model[], SelectStateToProps?, SelectActionsToProps?],
|
26
|
+
options?: ConnectOptions,
|
27
|
+
);
|
28
|
+
```
|
29
|
+
|
30
|
+
|
31
|
+
### Input
|
32
|
+
|
33
|
+
- `models`: passed one or more Models. When `models` is an array type parameter, the last two params can be a function for filtering State (`SelectStateToProps` type) and a function for filtering Actions (`SelectActionsToProps` type).
|
34
|
+
|
35
|
+
- `SelectStateToProps`: `modelStates` is an array of the State of the passed Model object, `ownProps` is the props received by current component. The data returned by `SelectStateToProps` is passed to the props of the component. When the `SelectStateToProps` parameter is not passed in `models`, the States of all Models are merged and passed to the props of the component.
|
36
|
+
|
37
|
+
- `SelectActionsToProps`: `modelActions` is an array of the Action of the passed Model object, `ownProps` is the props received by current component. returned by `SelectActionsToProps` is passed to the props of the component. When the `SelectActionsToProps` parameter is not passed in `models`, the Action of all Models are merged and passed to the props of the component.
|
38
|
+
|
39
|
+
- `options`: Optional parameter for auxiliary configuration. Currently supports setting `forwardRef`, which is used to control whether to forward the `ref` of the component. The default value is `false`, which means that the `ref` is not forwarded. Set to `{ forwardRef: true }`, which means to forward `ref`.
|
40
|
+
|
41
|
+
|
42
|
+
### Return Type
|
43
|
+
|
44
|
+
Returns a HOC: receives an component, returns a component with extra State and Actions injected on `props`.
|
45
|
+
|
46
|
+
## Example
|
47
|
+
|
48
|
+
### Basic
|
49
|
+
|
50
|
+
```ts
|
51
|
+
const modelA = model('modelA').define({
|
52
|
+
state: {
|
53
|
+
a: 1,
|
54
|
+
},
|
55
|
+
actions: {
|
56
|
+
incA(state) {
|
57
|
+
return {
|
58
|
+
...state,
|
59
|
+
a: state.a + 1,
|
60
|
+
};
|
61
|
+
},
|
62
|
+
},
|
63
|
+
});
|
64
|
+
|
65
|
+
const modelB = model('modelB').define({
|
66
|
+
state: {
|
67
|
+
b: 10,
|
68
|
+
},
|
69
|
+
actions: {
|
70
|
+
incB(state) {
|
71
|
+
return {
|
72
|
+
...state,
|
73
|
+
b: state.b + 1,
|
74
|
+
};
|
75
|
+
},
|
76
|
+
},
|
77
|
+
});
|
78
|
+
|
79
|
+
function Test(props) {
|
80
|
+
props.incA(); // call modelA 的 action
|
81
|
+
props.incB(); // call modelB 的 action
|
82
|
+
|
83
|
+
props.a; // get modelA 的 state: a
|
84
|
+
props.b; // get modelB 的 state: b
|
85
|
+
}
|
86
|
+
|
87
|
+
export default connect([modelA, modelB])(Test);
|
88
|
+
```
|
89
|
+
|
90
|
+
### Select State & Actions
|
91
|
+
|
92
|
+
```ts
|
93
|
+
function Test(props) {
|
94
|
+
props.incAll();
|
95
|
+
props.c;
|
96
|
+
}
|
97
|
+
|
98
|
+
const stateSelector = (stateA, stateB) => ({
|
99
|
+
...stateA,
|
100
|
+
...stateB,
|
101
|
+
c: stateA.a + stateA.b,
|
102
|
+
});
|
103
|
+
const actionsSelector = (actionsA, actionsB) => ({
|
104
|
+
...actionsA,
|
105
|
+
...actionsB,
|
106
|
+
incAll: () => {
|
107
|
+
actionsA.incA();
|
108
|
+
actionsB.incB();
|
109
|
+
},
|
110
|
+
});
|
111
|
+
|
112
|
+
export default connect([modelA, modelB, stateSelector, actionsSelector])(Test);
|
113
|
+
```
|
114
|
+
|
115
|
+
### Forwarding Ref
|
116
|
+
|
117
|
+
```ts
|
118
|
+
import { useRef, forwardRef } from 'react';
|
119
|
+
|
120
|
+
function Test(props, ref) {
|
121
|
+
const { a, b } = props;
|
122
|
+
|
123
|
+
return (
|
124
|
+
<div ref={ref}>
|
125
|
+
<span>{a}</span>
|
126
|
+
<span>{b}</span>
|
127
|
+
</div>
|
128
|
+
);
|
129
|
+
}
|
130
|
+
|
131
|
+
const TestWrapper = connect([modelA, modelB], { forwardRef: true })(
|
132
|
+
forwardRef(Test),
|
133
|
+
);
|
134
|
+
|
135
|
+
function App() {
|
136
|
+
const testRef = useRef();
|
137
|
+
|
138
|
+
return <TestWrapper ref={testRef} />;
|
139
|
+
}
|
140
|
+
```
|