@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,72 @@
|
|
1
|
+
---
|
2
|
+
title: render
|
3
|
+
---
|
4
|
+
|
5
|
+
Used to render the component in the test case.
|
6
|
+
|
7
|
+
## Usage
|
8
|
+
|
9
|
+
```ts
|
10
|
+
import { render } from '@modern-js/runtime/testing';
|
11
|
+
```
|
12
|
+
|
13
|
+
## Function Signature
|
14
|
+
|
15
|
+
```ts
|
16
|
+
type Options = {
|
17
|
+
container: DOMElement;
|
18
|
+
baseElement: DOMElement;
|
19
|
+
hydrate: boolean;
|
20
|
+
warpper: React.ComponentType<{children: ReactNode}>;
|
21
|
+
queries: any;
|
22
|
+
};
|
23
|
+
|
24
|
+
type RenderResult = {
|
25
|
+
{...queries}: any;
|
26
|
+
container: DOMElement;
|
27
|
+
baseElement: DOMElement;
|
28
|
+
debug: function;
|
29
|
+
rerender: function;
|
30
|
+
unmount: function;
|
31
|
+
asFragment: function;
|
32
|
+
}
|
33
|
+
|
34
|
+
function render(ui: React.ReactElement<any>, options: Options): RenderResult;
|
35
|
+
```
|
36
|
+
|
37
|
+
### Input
|
38
|
+
|
39
|
+
- `ui`: the React component that needs to be rendered.
|
40
|
+
- `options`: render options.
|
41
|
+
- `container`: the dom which component mounted. by default create a `div` element,and auto append to `document.body`. the default value is `document.body.append(document.createElement('div'))`.
|
42
|
+
- `baseElement`: Used to specify the `basename` used in `queries`. If `container` is specified, the default value is the value of `container`, otherwise it is `document.body`.
|
43
|
+
- `hydrate`: If set to `true`, the [ReactDOM.hydrate](https://reactjs.org/docs/react-dom.html#hydrate) rendering component is used. The default value is `false`.
|
44
|
+
- `wrapper`: a react component that can be used to customize rendering logic.
|
45
|
+
- `queries`: customize some own `queries`.
|
46
|
+
|
47
|
+
|
48
|
+
### Return Value
|
49
|
+
|
50
|
+
- `{...queries}`: all available [queries](https://testing-library.com/docs/queries/about/)。
|
51
|
+
- `container`: the DOM element that React component mounted.
|
52
|
+
- `baseElement`
|
53
|
+
- `debug`
|
54
|
+
- `rerender`: if you want to test some scene when a rendered component is updated, you can use rerender for reality.
|
55
|
+
- `unmount`: unmount rendered components. This API is helpful if you want to test what happens after the component is unmounted.
|
56
|
+
- `asFragment`: return the [DocumentFragment](https://developer.mozilla.org/en-US/docs/Web/API/DocumentFragment) of rendered component. used to test the response of the DOM structure after the react event is triggered.
|
57
|
+
|
58
|
+
|
59
|
+
## Example
|
60
|
+
|
61
|
+
```ts
|
62
|
+
import { render } from '@modern-js/runtime/testing';
|
63
|
+
import App from './App';
|
64
|
+
|
65
|
+
test('renders a message', () => {
|
66
|
+
const { container, getByText } = render(<App />);
|
67
|
+
expect(getByText('Hello, world!')).toBeInTheDocument();
|
68
|
+
expect(container.firstChild).toMatchInlineSnapshot(`
|
69
|
+
<h1>Hello, World!</h1>
|
70
|
+
`);
|
71
|
+
});
|
72
|
+
```
|
@@ -0,0 +1,33 @@
|
|
1
|
+
---
|
2
|
+
title: renderApp
|
3
|
+
---
|
4
|
+
|
5
|
+
The `render` function is used to test normal components, and the `renderApp` function is used to test App components.
|
6
|
+
|
7
|
+
## Usage
|
8
|
+
|
9
|
+
```ts
|
10
|
+
import { renderApp } from '@modern-js/runtime/testing';
|
11
|
+
```
|
12
|
+
|
13
|
+
App components refer to components that contain some Modern.js contexts, such as App root components, Containers using Models, etc.
|
14
|
+
|
15
|
+
For the testing of such components, you can use the `renderApp` function, which will automatically wrap the context information according to the current `modern.config.js`.
|
16
|
+
|
17
|
+
## Function Signature
|
18
|
+
|
19
|
+
`renderApp` is the same as [render](./render.md).
|
20
|
+
|
21
|
+
## Example
|
22
|
+
|
23
|
+
```ts
|
24
|
+
import { renderApp } from '@modern-js/runtime/testing';
|
25
|
+
import App from './App';
|
26
|
+
|
27
|
+
describe('test', () => {
|
28
|
+
it('test App', () => {
|
29
|
+
const { getByText } = renderApp(<App />);
|
30
|
+
expect(getByText('Hello Modern!')).toBeInTheDocument();
|
31
|
+
});
|
32
|
+
});
|
33
|
+
```
|
@@ -0,0 +1,42 @@
|
|
1
|
+
---
|
2
|
+
title: CSS-In-JS API
|
3
|
+
---
|
4
|
+
|
5
|
+
Use Style Component to write CSS.
|
6
|
+
|
7
|
+
## Usage
|
8
|
+
|
9
|
+
```ts
|
10
|
+
import styled from '@modern-js/runtime/styled';
|
11
|
+
```
|
12
|
+
|
13
|
+
## Function Signature
|
14
|
+
|
15
|
+
see [styled-component API](https://styled-components.com/docs/api)。
|
16
|
+
|
17
|
+
## Example
|
18
|
+
|
19
|
+
```tsx
|
20
|
+
import styled from '@modern-js/runtime/styled';
|
21
|
+
|
22
|
+
const Button = styled.button`
|
23
|
+
background: palevioletred;
|
24
|
+
border-radius: 3px;
|
25
|
+
border: none;
|
26
|
+
color: white;
|
27
|
+
`;
|
28
|
+
|
29
|
+
const TomatoButton = styled(Button)`
|
30
|
+
background: tomato;
|
31
|
+
`;
|
32
|
+
|
33
|
+
function ButtonExample(){
|
34
|
+
return (
|
35
|
+
<>
|
36
|
+
<Button>I'm purple.</Button>
|
37
|
+
<br />
|
38
|
+
<TomatoButton>I'm red.</TomatoButton>
|
39
|
+
</>
|
40
|
+
);
|
41
|
+
};
|
42
|
+
```
|
@@ -0,0 +1,39 @@
|
|
1
|
+
---
|
2
|
+
title: Head
|
3
|
+
---
|
4
|
+
|
5
|
+
Used to add html elements (such as title, meta, script, etc.) to the `<head>` element, supports SSR.
|
6
|
+
|
7
|
+
## Usage
|
8
|
+
|
9
|
+
```tsx
|
10
|
+
import { Helmet } from '@modern-js/runtime/head';
|
11
|
+
|
12
|
+
export default () => (
|
13
|
+
<Helmet>...</Helmet>
|
14
|
+
)
|
15
|
+
```
|
16
|
+
|
17
|
+
## Example
|
18
|
+
|
19
|
+
```tsx
|
20
|
+
import { Helmet } from '@modern-js/runtime/head';
|
21
|
+
|
22
|
+
function IndexPage() {
|
23
|
+
return (
|
24
|
+
<div>
|
25
|
+
<Helmet>
|
26
|
+
<title>My page title</title>
|
27
|
+
<meta name="viewport" content="initial-scale=1.0, width=device-width" />
|
28
|
+
</Helmet>
|
29
|
+
<p>Hello Modern.js!</p>
|
30
|
+
</div>
|
31
|
+
)
|
32
|
+
}
|
33
|
+
|
34
|
+
export default IndexPage
|
35
|
+
```
|
36
|
+
|
37
|
+
## More
|
38
|
+
|
39
|
+
For detail, see [react-helmet](https://github.com/nfl/react-helmet).
|
@@ -0,0 +1,85 @@
|
|
1
|
+
---
|
2
|
+
title: loadable
|
3
|
+
---
|
4
|
+
|
5
|
+
Used to create Loadable component
|
6
|
+
|
7
|
+
## Usage
|
8
|
+
|
9
|
+
```ts
|
10
|
+
import loadable from '@modern-js/runtime/loadable';
|
11
|
+
```
|
12
|
+
|
13
|
+
## Function Signature
|
14
|
+
|
15
|
+
```ts
|
16
|
+
type Options = {
|
17
|
+
resolveComponent?: (
|
18
|
+
module: Module,
|
19
|
+
props: Props,
|
20
|
+
) => React.ComponentType<Props>,
|
21
|
+
fallback?: JSX.Element;
|
22
|
+
ssr?: boolean;
|
23
|
+
}
|
24
|
+
|
25
|
+
function loadable(loadFn: Function, options?: Options) => LoadableComponent
|
26
|
+
```
|
27
|
+
|
28
|
+
### Input
|
29
|
+
|
30
|
+
#### loadFn
|
31
|
+
|
32
|
+
Used to load component.
|
33
|
+
|
34
|
+
```ts
|
35
|
+
import loadable from '@modern-js/runtime/loadable';
|
36
|
+
|
37
|
+
const OtherComponent = loadable(() => import('./OtherComponent'))
|
38
|
+
```
|
39
|
+
|
40
|
+
#### options.resolveComponent
|
41
|
+
|
42
|
+
Type: `(module: Module, props: Props) => React.ComponentType<Props>`
|
43
|
+
|
44
|
+
`module` is the component returned by `loadFn`, and `props` is the props parameter accepted by the component.
|
45
|
+
|
46
|
+
By default, we think that the default export of file is a react component, so we can render the component directly. But when the component is named export, or we need to dynamically determine which component needs to be rendered according to the `props`, we can use `resolveComponent`. Here is an example:
|
47
|
+
|
48
|
+
```ts title='component.js'
|
49
|
+
export const Apple = () => 'Apple!'
|
50
|
+
export const Orange = () => 'Orange!'
|
51
|
+
```
|
52
|
+
|
53
|
+
```ts title='loadable.js'
|
54
|
+
const LoadableApple = loadable(() => import('./components'), {
|
55
|
+
resolveComponent: (components) => components.Apple,
|
56
|
+
})
|
57
|
+
const LoadableOrange = loadable(() => import('./components'), {
|
58
|
+
resolveComponent: (components) => components.Orange,
|
59
|
+
})
|
60
|
+
const LoadableFruit = loadable(() => import('./components'), {
|
61
|
+
resolveComponent: (components, props) => components[props.fruit],
|
62
|
+
})
|
63
|
+
```
|
64
|
+
|
65
|
+
#### options.fallback
|
66
|
+
|
67
|
+
Whether to display fallback content during loading.
|
68
|
+
|
69
|
+
#### options.ssr
|
70
|
+
|
71
|
+
Whether to support SSR, the default value is `true`。
|
72
|
+
|
73
|
+
### Return Value
|
74
|
+
|
75
|
+
#### LoadableComponent
|
76
|
+
|
77
|
+
```ts
|
78
|
+
type LoadableComponent<Props> =
|
79
|
+
React.ComponentType<
|
80
|
+
Props & { fallback?: JSX.Element; }>
|
81
|
+
& {
|
82
|
+
preload(props?: Props): void;
|
83
|
+
load(props?: Props): Promise<React.ComponentType<Props>>;
|
84
|
+
}
|
85
|
+
```
|
@@ -0,0 +1,131 @@
|
|
1
|
+
---
|
2
|
+
title: Hook
|
3
|
+
---
|
4
|
+
|
5
|
+
Used to extend Modern.js built-in Web Server, requests except BFF are handled by these hooks.
|
6
|
+
|
7
|
+
:::note
|
8
|
+
For more detail, see [Extend Web Server](/docs/guides/advanced-features/web-server)。
|
9
|
+
:::
|
10
|
+
|
11
|
+
## Usage
|
12
|
+
|
13
|
+
```ts
|
14
|
+
import { AfterMatchHook, AfterRenderHook } from '@modern-js/runtime/server';
|
15
|
+
|
16
|
+
export const afterMatch: AfterMatchHook = (context, next) => {}
|
17
|
+
export const afterRender: AfterRenderHook = (context, next) => {}
|
18
|
+
```
|
19
|
+
|
20
|
+
:::info
|
21
|
+
使用该 API 前,请先执行 `pnpm run new` 新建「Web Server 扩展」源码目录。
|
22
|
+
|
23
|
+
```bash
|
24
|
+
pnpm run new
|
25
|
+
? 请选择你想要的操作 创建工程元素
|
26
|
+
? 新建「Web Server 扩展」源码目录
|
27
|
+
```
|
28
|
+
:::
|
29
|
+
|
30
|
+
## Function Signature
|
31
|
+
|
32
|
+
```ts
|
33
|
+
type HookContext = {
|
34
|
+
response: {
|
35
|
+
set: (key: string, value: string) => void;
|
36
|
+
status: (code: number) => void;
|
37
|
+
cookies: {
|
38
|
+
get: (key: string) => string;
|
39
|
+
set: (key: string, value: string) => void;
|
40
|
+
delete: () => void;
|
41
|
+
clear: () => void;
|
42
|
+
};
|
43
|
+
raw: (
|
44
|
+
body: string,
|
45
|
+
{ status, headers }: { status: number; headers: Record<string, any> },
|
46
|
+
) => void;
|
47
|
+
};
|
48
|
+
request: {
|
49
|
+
host: string;
|
50
|
+
pathname: string;
|
51
|
+
query: Record<string, any>;
|
52
|
+
cookie: string;
|
53
|
+
cookies: {
|
54
|
+
get: (key: string) => string;
|
55
|
+
};
|
56
|
+
headers: IncomingHttpHeaders;
|
57
|
+
};
|
58
|
+
};
|
59
|
+
|
60
|
+
function Hook(context: HookContext, next: NextFunction): Promsie<void> | void;
|
61
|
+
```
|
62
|
+
|
63
|
+
different Hooks additionally provide different contexts. Currently Modern.js support `AtferMatch` and `AfterRender`.
|
64
|
+
|
65
|
+
```ts
|
66
|
+
type AfterMatchContext = HookContext & {
|
67
|
+
router: {
|
68
|
+
redirect: (url: string, status: number) => void;
|
69
|
+
rewrite: (entry: string) => void;
|
70
|
+
};
|
71
|
+
}
|
72
|
+
|
73
|
+
type AfterRenderContext = {
|
74
|
+
template: {
|
75
|
+
get: () => string;
|
76
|
+
set: (html: string) => void;
|
77
|
+
prependHead: (fragment: string) => void;
|
78
|
+
appendHead: (fragment: string) => void;
|
79
|
+
prependBody: (fragment: string) => void;
|
80
|
+
appendBody: (fragment: string) => void;
|
81
|
+
};
|
82
|
+
};
|
83
|
+
```
|
84
|
+
|
85
|
+
|
86
|
+
### Input
|
87
|
+
|
88
|
+
- `context`: Hook context.
|
89
|
+
- `response`: provides a series of methods to process the response.
|
90
|
+
- `request`: provides a series of methods to get request info.
|
91
|
+
- `router`: provides methods on routing.
|
92
|
+
- `template`: provides methods on content.
|
93
|
+
- `next`: call next listener(not affect the server process, only current hook)。
|
94
|
+
|
95
|
+
## Example
|
96
|
+
|
97
|
+
### Redirect
|
98
|
+
|
99
|
+
Redirect to pages outside the site, for example to login page:
|
100
|
+
|
101
|
+
```ts
|
102
|
+
import type { AfterMatch } from '@modern-js/runtime/server';
|
103
|
+
|
104
|
+
export const afterMatch: AfterMatch = async (ctx, next) => {
|
105
|
+
ctx.router.redirect('https://website.com/login', 302);
|
106
|
+
};
|
107
|
+
```
|
108
|
+
|
109
|
+
### Rewrite
|
110
|
+
|
111
|
+
Rewrite to pages of the current site, for example, the same route returns pages that are adapted to different UA:
|
112
|
+
|
113
|
+
```ts
|
114
|
+
import type { AfterMatch } from '@modern-js/runtime/server';
|
115
|
+
|
116
|
+
export const afterMatch: AfterMatch = async (ctx, next) => {
|
117
|
+
ctx.router.rewrite('mobile');
|
118
|
+
};
|
119
|
+
```
|
120
|
+
|
121
|
+
### HTML Inject
|
122
|
+
|
123
|
+
Inject some HTML content to the page, such as scripts, page skeletons, etc.:
|
124
|
+
|
125
|
+
```ts
|
126
|
+
import type { AfterRender } from '@modern-js/runtime/server';
|
127
|
+
|
128
|
+
export const afterRender: AfterRenderHook = (context, next) => {
|
129
|
+
ctx.template.prependBody('<div>Footer</div>');
|
130
|
+
}
|
131
|
+
```
|
@@ -0,0 +1,106 @@
|
|
1
|
+
---
|
2
|
+
title: Middleware
|
3
|
+
---
|
4
|
+
|
5
|
+
Used to extend Modern.js built-in Web Server, only SSR requests are handled by these middleware.
|
6
|
+
|
7
|
+
Unlike [Hook](/docs/apis/app/runtime/web-server/hook), middleware can be extended using the framework plugin.
|
8
|
+
|
9
|
+
:::note
|
10
|
+
For more detail, see [Extend Web Server](/docs/guides/advanced-features/web-server)。
|
11
|
+
:::
|
12
|
+
|
13
|
+
## Usage
|
14
|
+
|
15
|
+
```ts
|
16
|
+
import { Middleware } from '@modern-js/runtime/server';
|
17
|
+
|
18
|
+
export const middleware: Middleware = async (context, next) => {}
|
19
|
+
export const middleware: Middleware[] = [
|
20
|
+
async (context, next) => {},
|
21
|
+
async (context, next) => {},
|
22
|
+
]
|
23
|
+
```
|
24
|
+
|
25
|
+
:::info
|
26
|
+
使用该 API 前,请先执行 `pnpm run new` 新建「Web Server 扩展」源码目录。
|
27
|
+
|
28
|
+
```bash
|
29
|
+
pnpm run new
|
30
|
+
? 请选择你想要的操作 创建工程元素
|
31
|
+
? 新建「Web Server 扩展」源码目录
|
32
|
+
```
|
33
|
+
:::
|
34
|
+
|
35
|
+
## Function Signature
|
36
|
+
|
37
|
+
```ts
|
38
|
+
type MiddlewareContext = {
|
39
|
+
response: {
|
40
|
+
set: (key: string, value: string) => void;
|
41
|
+
status: (code: number) => void;
|
42
|
+
cookies: {
|
43
|
+
get: (key: string) => string;
|
44
|
+
set: (key: string, value: string) => void;
|
45
|
+
delete: () => void;
|
46
|
+
clear: () => void;
|
47
|
+
apply: () => void;
|
48
|
+
};
|
49
|
+
raw: (
|
50
|
+
body: string,
|
51
|
+
{ status, headers }: { status: number; headers: Record<string, any> },
|
52
|
+
) => void;
|
53
|
+
locals: Record<string, any>;
|
54
|
+
};
|
55
|
+
request: {
|
56
|
+
host: string;
|
57
|
+
pathname: string;
|
58
|
+
query: Record<string, any>;
|
59
|
+
cookie: string;
|
60
|
+
cookies: {
|
61
|
+
get: (key: string) => string;
|
62
|
+
};
|
63
|
+
headers: IncomingHttpHeaders;
|
64
|
+
};
|
65
|
+
source: {
|
66
|
+
req: IncomingMessage;
|
67
|
+
res: ServerResponse;
|
68
|
+
};
|
69
|
+
};
|
70
|
+
|
71
|
+
type RequestHandler = (context: Context, next: NextFunction) => Promise<void> | void;
|
72
|
+
```
|
73
|
+
|
74
|
+
|
75
|
+
### Input
|
76
|
+
|
77
|
+
- `context`: Middleware context.
|
78
|
+
- `response`: provides a series of methods to process the response.
|
79
|
+
- `request`: provides a series of methods to get request info.
|
80
|
+
- `source`: provides Node.js native `req` and `res` object。
|
81
|
+
- `next`: call next listener(not affect the server process, only current hook)。
|
82
|
+
|
83
|
+
## Example
|
84
|
+
|
85
|
+
### Tracking
|
86
|
+
|
87
|
+
```ts
|
88
|
+
export const Middleware = () => async (ctx, next) => {
|
89
|
+
const start = Date.now();
|
90
|
+
ctx.res.once('finish', () => {
|
91
|
+
console.log(Date.now() - start);
|
92
|
+
});
|
93
|
+
}
|
94
|
+
```
|
95
|
+
|
96
|
+
### Inject Tools & Data
|
97
|
+
|
98
|
+
Modern.js provides `res.locals` to store local variables for the current request.
|
99
|
+
|
100
|
+
```ts
|
101
|
+
export const Middleware = () => async (ctx, next) => {
|
102
|
+
ctx.res.locals.id = 'Modern.js';
|
103
|
+
ctx.res.locals.rpc = createRpcInstance();
|
104
|
+
});
|
105
|
+
```
|
106
|
+
|
@@ -0,0 +1,28 @@
|
|
1
|
+
---
|
2
|
+
sidebar_label: fetcher
|
3
|
+
---
|
4
|
+
|
5
|
+
# bff.fetcher
|
6
|
+
|
7
|
+
* Type: `string`
|
8
|
+
* Default:
|
9
|
+
* Brower:[global.fetch](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API)
|
10
|
+
* Node.js:[node-fetch](https://github.com/node-fetch/node-fetch)
|
11
|
+
|
12
|
+
:::caution Caution
|
13
|
+
First you need to enable the "BFF" function using [new](/docs/apis/app/commands/new) command.
|
14
|
+
:::
|
15
|
+
|
16
|
+
Custom `fetch` function, which can be used for `fetch` function customization in Native and Mini Program scenarios.
|
17
|
+
|
18
|
+
```ts title="modern.config.ts"
|
19
|
+
export default defineConfig({
|
20
|
+
bff: {
|
21
|
+
fetcher: 'custom-fetch'
|
22
|
+
}
|
23
|
+
});
|
24
|
+
```
|
25
|
+
|
26
|
+
:::info
|
27
|
+
You need to judge the running environment when you implement the isomorphic fetch function.
|
28
|
+
:::
|
@@ -0,0 +1,33 @@
|
|
1
|
+
---
|
2
|
+
sidebar_label: prefix
|
3
|
+
---
|
4
|
+
|
5
|
+
# bff.prefix
|
6
|
+
|
7
|
+
* Type: `string`
|
8
|
+
* Default: `/api`
|
9
|
+
|
10
|
+
:::caution Caution
|
11
|
+
First you need to enable the "BFF" function using [new](/docs/apis/app/commands/new) command.
|
12
|
+
:::
|
13
|
+
|
14
|
+
By default, the route access BFF prefix's directory is `/api`, with the following directory structure:
|
15
|
+
|
16
|
+
```bash
|
17
|
+
api
|
18
|
+
└── hello.ts
|
19
|
+
```
|
20
|
+
|
21
|
+
The corresponding route for `api/hello.ts` access is `localhost:8080/api/hello`.
|
22
|
+
|
23
|
+
This configuration option can modify the default route prefix:
|
24
|
+
|
25
|
+
```typescript title="modern.config.ts"
|
26
|
+
export default defineConfig({
|
27
|
+
bff: {
|
28
|
+
prefix: '/api-demo'
|
29
|
+
}
|
30
|
+
})
|
31
|
+
```
|
32
|
+
|
33
|
+
The corresponding `api/hello.ts` access route is `localhost:8080/api-demo/hello`.
|
@@ -0,0 +1,75 @@
|
|
1
|
+
---
|
2
|
+
sidebar_label: proxy
|
3
|
+
---
|
4
|
+
|
5
|
+
# bff.proxy
|
6
|
+
|
7
|
+
* Type: `Record<string, string>`
|
8
|
+
* Default: `{}`
|
9
|
+
|
10
|
+
:::caution Caution
|
11
|
+
First you need to enable the "BFF" function using [new](/docs/apis/app/commands/new) command.
|
12
|
+
:::
|
13
|
+
|
14
|
+
With simple configuration, no code is required, Modern.js automatically forwards requests. Requests sent to Modern.js BFF server are proxied to the specified service.
|
15
|
+
|
16
|
+
BFF Proxy uses the powerful [http-proxy-middleware](https://github.com/chimurai/http-proxy-middleware), and if you need more advanced usage, you can check its [documentation](https://github.com/chimurai/http-proxy-middleware#options).
|
17
|
+
|
18
|
+
Add the following configuration to `modern.server-runtime.config.ts`, you can turn on the proxy:
|
19
|
+
|
20
|
+
```typescript title="modern.server-runtime.config.ts"
|
21
|
+
import { defineConfig } from '@modern-js/app-tools/server';
|
22
|
+
export default defineConfig({
|
23
|
+
bff: {
|
24
|
+
proxy: {
|
25
|
+
"/api": "https://cnodejs.org"
|
26
|
+
}
|
27
|
+
}
|
28
|
+
})
|
29
|
+
```
|
30
|
+
|
31
|
+
Assuming that the starting Modern.js BFF server's service address is `localhost:8080`, all requests whose path starts with `api` will be intercepted, such as requests sent to `localhost:8080/api/v1/topics` will be proxied to `https://cnodejs.org/api/v1/topics`.
|
32
|
+
|
33
|
+
You can do path rewriting, such as proxying requests sent to `localhost:8080/api/topics` to `https://cnodejs.org/api/v1/topics`.
|
34
|
+
|
35
|
+
```js title="modern.server-runtime.config.js"
|
36
|
+
import { defineConfig } from '@modern-js/app-tools/server';
|
37
|
+
export default defineConfig({
|
38
|
+
bff: {
|
39
|
+
proxy: {
|
40
|
+
'/api': {
|
41
|
+
target: 'https://cnodejs.org',
|
42
|
+
pathRewrite: { '/api/topics': '/api/v1/topics' },
|
43
|
+
changeOrigin: true,
|
44
|
+
},
|
45
|
+
},
|
46
|
+
},
|
47
|
+
});
|
48
|
+
```
|
49
|
+
|
50
|
+
Unlike [dev.proxy](/docs/configure/app/dev/proxy), the proxy described in this section only works on requests entering the BFF/API service; at the same time, this configuration can be used not only in the development environment, but also in the production environment. The corresponding request will also be proxied in the production environment.
|
51
|
+
|
52
|
+
## Common usage
|
53
|
+
|
54
|
+
### Solve interface cross-domain problems
|
55
|
+
|
56
|
+
In the process of project development, because web pages and interface services are not deployed under the same domain name, cross-domain problems are often encountered.
|
57
|
+
|
58
|
+
There are many ways to solve cross-domain problems, and here we use `bff.proxy` to easily solve cross-domain problems.
|
59
|
+
|
60
|
+
|
61
|
+
:::info
|
62
|
+
In BFF proxy mode, if you do not need to write the BFF interface, the API directory can be deleted; at this time, BFF proxy will still be enabled.
|
63
|
+
:::
|
64
|
+
|
65
|
+
As shown below, in the `modern.server-runtime.config.js`, write the following configuration; we send all web pages to the same domain that request proxies starting with `/api` to another domain's service.
|
66
|
+
|
67
|
+
```typescript title="modern.server-runtime.config.ts"
|
68
|
+
export default defineServerConfig({
|
69
|
+
bff: {
|
70
|
+
proxy: {
|
71
|
+
'/api': 'https://cnodejs.org',
|
72
|
+
},
|
73
|
+
},
|
74
|
+
};
|
75
|
+
```
|