@modern-js/runtime 2.56.3-alpha.0 → 2.57.0

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.
Files changed (55) hide show
  1. package/dist/cjs/core/browser/hydrate.js +3 -1
  2. package/dist/cjs/core/browser/index.js +8 -9
  3. package/dist/cjs/core/compatible.js +28 -48
  4. package/dist/cjs/core/plugin/base.js +20 -9
  5. package/dist/cjs/core/plugin/index.js +8 -2
  6. package/dist/cjs/core/react/index.js +11 -18
  7. package/dist/cjs/core/server/requestHandler.js +10 -10
  8. package/dist/cjs/core/server/stream/shared.js +2 -2
  9. package/dist/cjs/core/server/string/index.js +3 -2
  10. package/dist/cjs/core/server/utils.js +2 -5
  11. package/dist/cjs/router/runtime/plugin.js +29 -40
  12. package/dist/cjs/router/runtime/plugin.node.js +27 -38
  13. package/dist/cjs/state/runtime/plugin.js +10 -21
  14. package/dist/esm/core/browser/hydrate.js +3 -1
  15. package/dist/esm/core/browser/index.js +28 -13
  16. package/dist/esm/core/compatible.js +47 -56
  17. package/dist/esm/core/plugin/base.js +20 -9
  18. package/dist/esm/core/plugin/index.js +12 -3
  19. package/dist/esm/core/react/index.js +12 -20
  20. package/dist/esm/core/server/requestHandler.js +33 -14
  21. package/dist/esm/core/server/stream/shared.js +3 -3
  22. package/dist/esm/core/server/string/index.js +4 -3
  23. package/dist/esm/core/server/utils.js +2 -5
  24. package/dist/esm/router/runtime/plugin.js +32 -47
  25. package/dist/esm/router/runtime/plugin.node.js +27 -42
  26. package/dist/esm/state/runtime/plugin.js +11 -24
  27. package/dist/esm-node/core/browser/hydrate.js +3 -1
  28. package/dist/esm-node/core/browser/index.js +8 -9
  29. package/dist/esm-node/core/compatible.js +28 -48
  30. package/dist/esm-node/core/plugin/base.js +18 -9
  31. package/dist/esm-node/core/plugin/index.js +10 -4
  32. package/dist/esm-node/core/react/index.js +11 -18
  33. package/dist/esm-node/core/server/requestHandler.js +10 -10
  34. package/dist/esm-node/core/server/stream/shared.js +2 -2
  35. package/dist/esm-node/core/server/string/index.js +3 -2
  36. package/dist/esm-node/core/server/utils.js +2 -5
  37. package/dist/esm-node/router/runtime/plugin.js +29 -40
  38. package/dist/esm-node/router/runtime/plugin.node.js +27 -38
  39. package/dist/esm-node/state/runtime/plugin.js +10 -21
  40. package/dist/types/core/compatible.d.ts +1 -1
  41. package/dist/types/core/context/index.d.ts +1 -1
  42. package/dist/types/core/context/runtime.d.ts +1 -1
  43. package/dist/types/core/plugin/base.d.ts +26 -36
  44. package/dist/types/core/plugin/index.d.ts +5 -12
  45. package/dist/types/core/plugin/runner.d.ts +4 -11
  46. package/dist/types/core/react/index.d.ts +1 -5
  47. package/dist/types/core/server/utils.d.ts +1 -1
  48. package/dist/types/router/runtime/plugin.d.ts +1 -1
  49. package/dist/types/router/runtime/plugin.node.d.ts +1 -1
  50. package/dist/types/state/runtime/plugin.d.ts +1 -1
  51. package/package.json +12 -11
  52. package/dist/cjs/core/utils/merge.js +0 -53
  53. package/dist/esm/core/utils/merge.js +0 -32
  54. package/dist/esm-node/core/utils/merge.js +0 -29
  55. package/dist/types/core/utils/merge.d.ts +0 -6
@@ -33,11 +33,11 @@ function createRenderStreaming(createReadableStreamFromElement) {
33
33
  const headersData = parseHeaders(request);
34
34
  return run(headersData, async () => {
35
35
  const end = time();
36
- const { runtimeContext, config, resource, staticGenerate } = options;
36
+ const { runtimeContext, config, resource } = options;
37
37
  const onError = createOnError(options.onError);
38
38
  const onTiming = createOnTiming(options.onTiming);
39
39
  const { htmlTemplate, entryName } = resource;
40
- const ssrConfig = getSSRConfigByEntry(entryName, config.ssr, config.ssrByEntries, staticGenerate);
40
+ const ssrConfig = getSSRConfigByEntry(entryName, config.ssr, config.ssrByEntries);
41
41
  const rootElement = React.cloneElement(serverRoot, {
42
42
  _internal_context: Object.assign(runtimeContext, {
43
43
  ssr: true
@@ -18,14 +18,14 @@ const renderString = async (request, serverRoot, options) => {
18
18
  const headersData = parseHeaders(request);
19
19
  return run(headersData, async () => {
20
20
  var _runtimeContext_ssrContext;
21
- const { resource, runtimeContext, config, onError, onTiming, staticGenerate } = options;
21
+ const { resource, runtimeContext, config, onError, onTiming } = options;
22
22
  const tracer = {
23
23
  onError: createOnError(onError),
24
24
  onTiming: createOnTiming(onTiming)
25
25
  };
26
26
  const routerContext = runtimeContext.routerContext;
27
27
  const { htmlTemplate, entryName, loadableStats, routeManifest } = resource;
28
- const ssrConfig = getSSRConfigByEntry(entryName, config.ssr, config.ssrByEntries, staticGenerate);
28
+ const ssrConfig = getSSRConfigByEntry(entryName, config.ssr, config.ssrByEntries);
29
29
  const chunkSet = {
30
30
  renderLevel: RenderLevel.CLIENT_RENDER,
31
31
  ssrScripts: "",
@@ -38,6 +38,7 @@ const renderString = async (request, serverRoot, options) => {
38
38
  chunkSet.renderLevel = RenderLevel.SERVER_PREFETCH;
39
39
  } catch (e) {
40
40
  chunkSet.renderLevel = RenderLevel.CLIENT_RENDER;
41
+ tracer.onError(SSRErrors.PRERENDER, e);
41
42
  }
42
43
  const collectors = [
43
44
  new StyledCollector(chunkSet),
@@ -35,14 +35,11 @@ function serializeErrors(errors) {
35
35
  }
36
36
  return serialized;
37
37
  }
38
- function getSSRConfigByEntry(entryName, ssr, ssrByEntries, staticGenerate) {
39
- if (staticGenerate) {
40
- return true;
41
- }
38
+ function getSSRConfigByEntry(entryName, ssr, ssrByEntries) {
42
39
  if (ssrByEntries === null || ssrByEntries === void 0 ? void 0 : ssrByEntries[entryName]) {
43
40
  return ssrByEntries[entryName];
44
41
  }
45
- return ssr;
42
+ return ssr || true;
46
43
  }
47
44
  function getSSRMode(ssrConfig) {
48
45
  if (typeof ssrConfig === "boolean") {
@@ -2,6 +2,7 @@ import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import { useContext, useMemo } from "react";
3
3
  import { createBrowserRouter, createHashRouter, RouterProvider, createRoutesFromElements, useMatches, useLocation, useHref } from "@modern-js/runtime-utils/router";
4
4
  import { parsedJSONFromElement } from "@modern-js/runtime-utils/parsed";
5
+ import { merge } from "@modern-js/runtime-utils/merge";
5
6
  import { getGlobalLayoutApp, getGlobalRoutes } from "../../core/context";
6
7
  import { RuntimeReactContext } from "../../core";
7
8
  import { modifyRoutes as modifyRoutesHook } from "./hooks";
@@ -19,23 +20,17 @@ function modifyRoutes(modifyFunction) {
19
20
  console.error("It is not allowed to modify routes config after create router.");
20
21
  }
21
22
  }
22
- const routerPlugin = ({ serverBase = [], supportHtml5History = true, basename = "", routesConfig, createRoutes }) => {
23
- const select = (pathname) => serverBase.find((baseUrl) => pathname.search(baseUrl) === 0) || "/";
24
- let routes = [];
25
- finalRouteConfig = {
26
- routes: getGlobalRoutes(),
27
- globalApp: getGlobalLayoutApp(),
28
- ...routesConfig
29
- };
30
- window._SERVER_DATA = parsedJSONFromElement("__MODERN_SERVER_DATA__");
23
+ const routerPlugin = (userConfig = {}) => {
31
24
  return {
32
25
  name: "@modern-js/plugin-router",
33
26
  registerHook: {
34
27
  modifyRoutes: modifyRoutesHook
35
28
  },
36
29
  setup: (api) => {
30
+ let routes = [];
31
+ window._SERVER_DATA = parsedJSONFromElement("__MODERN_SERVER_DATA__");
37
32
  return {
38
- init({ context }, next) {
33
+ beforeRender(context) {
39
34
  context.router = {
40
35
  useMatches,
41
36
  useLocation,
@@ -46,24 +41,26 @@ const routerPlugin = ({ serverBase = [], supportHtml5History = true, basename =
46
41
  return routes;
47
42
  }
48
43
  });
49
- return next({
50
- context
51
- });
52
44
  },
53
- hoc: ({ App, config }, next) => {
45
+ wrapRoot: (App) => {
46
+ const pluginConfig = api.useRuntimeConfigContext();
47
+ const { serverBase = [], supportHtml5History = true, basename = "", routesConfig, createRoutes } = merge(pluginConfig.router || {}, userConfig);
48
+ const select = (pathname) => serverBase.find((baseUrl) => pathname.search(baseUrl) === 0) || "/";
49
+ finalRouteConfig = {
50
+ routes: getGlobalRoutes(),
51
+ globalApp: getGlobalLayoutApp(),
52
+ ...routesConfig
53
+ };
54
54
  if (!finalRouteConfig.routes && !createRoutes) {
55
- return next({
56
- App,
57
- config
58
- });
55
+ return App;
59
56
  }
60
57
  const getRouteApp = () => {
61
58
  const useCreateRouter = (props) => {
62
- var _config_router, _window__SERVER_DATA;
63
- const baseUrl = ((config === null || config === void 0 ? void 0 : (_config_router = config.router) === null || _config_router === void 0 ? void 0 : _config_router.basename) || ((_window__SERVER_DATA = window._SERVER_DATA) === null || _window__SERVER_DATA === void 0 ? void 0 : _window__SERVER_DATA.router.baseUrl) || select(location.pathname)).replace(/^\/*/, "/");
59
+ var _window__SERVER_DATA;
60
+ const runtimeContext = useContext(RuntimeReactContext);
61
+ const baseUrl = (runtimeContext._internalRouterBaseName || ((_window__SERVER_DATA = window._SERVER_DATA) === null || _window__SERVER_DATA === void 0 ? void 0 : _window__SERVER_DATA.router.baseUrl) || select(location.pathname)).replace(/^\/*/, "/");
64
62
  const _basename = baseUrl === "/" ? urlJoin(baseUrl, basename) : baseUrl;
65
63
  let hydrationData = window._ROUTER_DATA;
66
- const runtimeContext = useContext(RuntimeReactContext);
67
64
  const { unstable_getBlockNavState: getBlockNavState } = runtimeContext;
68
65
  return useMemo(() => {
69
66
  if (hydrationData === null || hydrationData === void 0 ? void 0 : hydrationData.errors) {
@@ -100,7 +97,8 @@ const routerPlugin = ({ serverBase = [], supportHtml5History = true, basename =
100
97
  get() {
101
98
  return router;
102
99
  },
103
- configurable: true
100
+ configurable: true,
101
+ enumerable: true
104
102
  });
105
103
  return router;
106
104
  }, [
@@ -119,33 +117,24 @@ const routerPlugin = ({ serverBase = [], supportHtml5History = true, basename =
119
117
  });
120
118
  };
121
119
  };
122
- const RouteApp = getRouteApp();
123
- return next({
124
- App: RouteApp,
125
- config
126
- });
120
+ return getRouteApp();
127
121
  },
128
- pickContext: ({ context, pickedContext }, next) => {
129
- const { remixRouter } = context;
122
+ pickContext: (pickedContext) => {
123
+ const { remixRouter } = pickedContext;
130
124
  if (!remixRouter) {
131
- return next({
132
- context,
133
- pickedContext
134
- });
125
+ return pickedContext;
135
126
  }
136
127
  const router = {
128
+ ...pickedContext.router,
137
129
  navigate: remixRouter.navigate,
138
130
  get location() {
139
131
  return remixRouter.state.location;
140
132
  }
141
133
  };
142
- return next({
143
- context,
144
- pickedContext: {
145
- ...pickedContext,
146
- router
147
- }
148
- });
134
+ return {
135
+ ...pickedContext,
136
+ router
137
+ };
149
138
  }
150
139
  };
151
140
  }
@@ -6,6 +6,7 @@ import { createRoutesFromElements } from "@modern-js/runtime-utils/router";
6
6
  import { reporterCtx, createRequestContext } from "@modern-js/runtime-utils/node";
7
7
  import { time } from "@modern-js/runtime-utils/time";
8
8
  import { LOADER_REPORTER_NAME } from "@modern-js/utils/universal/constants";
9
+ import { merge } from "@modern-js/runtime-utils/merge";
9
10
  import { JSX_SHELL_STREAM_END_MARK } from "../../common";
10
11
  import { RuntimeReactContext } from "../../core";
11
12
  import { getGlobalLayoutApp, getGlobalRoutes } from "../../core/context";
@@ -22,25 +23,26 @@ function createRemixReuqest(request) {
22
23
  signal: controller.signal
23
24
  });
24
25
  }
25
- const routerPlugin = ({ basename = "", routesConfig, createRoutes }) => {
26
+ const routerPlugin = (userConfig = {}) => {
26
27
  return {
27
28
  name: "@modern-js/plugin-router",
28
29
  registerHook: {
29
30
  modifyRoutes: modifyRoutesHook
30
31
  },
31
32
  setup: (api) => {
32
- const finalRouteConfig = {
33
- routes: getGlobalRoutes(),
34
- globalApp: getGlobalLayoutApp(),
35
- ...routesConfig
36
- };
33
+ let finalRouteConfig = {};
37
34
  return {
38
- async init({ context }, next) {
35
+ async beforeRender(context, interrupt) {
39
36
  var _context_ssrContext, _context_ssrContext_onTiming, _context_ssrContext1;
37
+ const pluginConfig = api.useRuntimeConfigContext();
38
+ const { basename = "", routesConfig, createRoutes } = merge(pluginConfig.router || {}, userConfig);
39
+ finalRouteConfig = {
40
+ routes: getGlobalRoutes(),
41
+ globalApp: getGlobalLayoutApp(),
42
+ ...routesConfig
43
+ };
40
44
  if (!finalRouteConfig.routes && !createRoutes) {
41
- return next({
42
- context
43
- });
45
+ return;
44
46
  }
45
47
  const { request, mode: ssrMode, nonce, loaderFailureMode = "errorBoundary" } = context.ssrContext;
46
48
  const { baseUrl } = request;
@@ -69,7 +71,7 @@ const routerPlugin = ({ basename = "", routesConfig, createRoutes }) => {
69
71
  const cost = end();
70
72
  (_context_ssrContext1 = context.ssrContext) === null || _context_ssrContext1 === void 0 ? void 0 : (_context_ssrContext_onTiming = _context_ssrContext1.onTiming) === null || _context_ssrContext_onTiming === void 0 ? void 0 : _context_ssrContext_onTiming.call(_context_ssrContext1, LOADER_REPORTER_NAME, cost);
71
73
  if (routerContext instanceof Response) {
72
- return routerContext;
74
+ return interrupt(routerContext);
73
75
  }
74
76
  if (routerContext.statusCode >= 500 && routerContext.statusCode < 600 && loaderFailureMode === "clientRender") {
75
77
  routerContext.statusCode = 200;
@@ -79,20 +81,15 @@ const routerPlugin = ({ basename = "", routesConfig, createRoutes }) => {
79
81
  context.remixRouter = router;
80
82
  context.routerContext = routerContext;
81
83
  context.routes = routes;
82
- return next({
83
- context
84
- });
85
84
  },
86
- hoc: ({ App, config }, next) => {
85
+ wrapRoot: (App) => {
87
86
  if (!finalRouteConfig) {
88
- return next({
89
- App,
90
- config
91
- });
87
+ return App;
92
88
  }
93
89
  const getRouteApp = () => {
94
90
  return () => {
95
- const { remixRouter, routerContext, ssrContext } = useContext(RuntimeReactContext);
91
+ const context = useContext(RuntimeReactContext);
92
+ const { remixRouter, routerContext, ssrContext } = context;
96
93
  const { nonce, mode } = ssrContext;
97
94
  return /* @__PURE__ */ _jsxs(_Fragment, {
98
95
  children: [
@@ -101,6 +98,8 @@ const routerPlugin = ({ basename = "", routesConfig, createRoutes }) => {
101
98
  context: routerContext,
102
99
  hydrate: false
103
100
  }),
101
+ mode === "stream" && // ROUTER_DATA will inject in `packages/runtime/plugin-runtime/src/core/server/string/ssrData.ts` in string ssr
102
+ // So we can inject it only when streaming ssr
104
103
  /* @__PURE__ */ _jsx(DeferredDataScripts, {
105
104
  nonce,
106
105
  context: routerContext
@@ -110,19 +109,12 @@ const routerPlugin = ({ basename = "", routesConfig, createRoutes }) => {
110
109
  });
111
110
  };
112
111
  };
113
- const RouteApp = getRouteApp();
114
- return next({
115
- App: RouteApp,
116
- config
117
- });
112
+ return getRouteApp();
118
113
  },
119
- pickContext: ({ context, pickedContext }, next) => {
120
- const { remixRouter } = context;
114
+ pickContext: (pickedContext) => {
115
+ const { remixRouter } = pickedContext;
121
116
  if (!remixRouter) {
122
- return next({
123
- context,
124
- pickedContext
125
- });
117
+ return pickedContext;
126
118
  }
127
119
  const router = {
128
120
  navigate: remixRouter.navigate,
@@ -130,13 +122,10 @@ const routerPlugin = ({ basename = "", routesConfig, createRoutes }) => {
130
122
  return remixRouter.state.location;
131
123
  }
132
124
  };
133
- return next({
134
- context,
135
- pickedContext: {
136
- ...pickedContext,
137
- router
138
- }
139
- });
125
+ return {
126
+ ...pickedContext,
127
+ router
128
+ };
140
129
  }
141
130
  };
142
131
  }
@@ -2,6 +2,7 @@ import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import { useContext } from "react";
3
3
  import { createStore } from "@modern-js-reduck/store";
4
4
  import { Provider } from "@modern-js-reduck/react";
5
+ import { merge } from "@modern-js/runtime-utils/merge";
5
6
  import { immer, effects, autoActions, devtools } from "../plugins";
6
7
  import { RuntimeReactContext } from "../../core";
7
8
  import { isBrowser } from "../../common";
@@ -29,12 +30,12 @@ const getStoreConfig = (config) => {
29
30
  storeConfig.plugins = plugins;
30
31
  return storeConfig;
31
32
  };
32
- const statePlugin = (config) => ({
33
+ const statePlugin = (userConfig = {}) => ({
33
34
  name: "@modern-js/plugin-state",
34
- setup: () => {
35
- const storeConfig = getStoreConfig(config);
35
+ setup: (api) => {
36
+ let storeConfig;
36
37
  return {
37
- hoc({ App, config: config2 }, next) {
38
+ wrapRoot(App) {
38
39
  const getStateApp = (props) => {
39
40
  const context = useContext(RuntimeReactContext);
40
41
  return /* @__PURE__ */ _jsx(Provider, {
@@ -45,29 +46,17 @@ const statePlugin = (config) => ({
45
46
  })
46
47
  });
47
48
  };
48
- return next({
49
- App: getStateApp,
50
- config: config2
51
- });
49
+ return getStateApp;
52
50
  },
53
- init({ context }, next) {
51
+ beforeRender(context) {
52
+ const pluginConfig = api.useRuntimeConfigContext();
53
+ const config = merge(pluginConfig.state || {}, userConfig);
54
+ storeConfig = getStoreConfig(config);
54
55
  if (isBrowser()) {
55
56
  var _window__SSR_DATA_data, _window__SSR_DATA, _window;
56
57
  storeConfig.initialState = storeConfig.initialState || ((_window = window) === null || _window === void 0 ? void 0 : (_window__SSR_DATA = _window._SSR_DATA) === null || _window__SSR_DATA === void 0 ? void 0 : (_window__SSR_DATA_data = _window__SSR_DATA.data) === null || _window__SSR_DATA_data === void 0 ? void 0 : _window__SSR_DATA_data.storeState) || {};
57
58
  }
58
59
  context.store = createStore(storeConfig);
59
- return next({
60
- context
61
- });
62
- },
63
- pickContext({ context, pickedContext }, next) {
64
- return next({
65
- context,
66
- pickedContext: {
67
- ...pickedContext,
68
- store: context.store
69
- }
70
- });
71
60
  }
72
61
  };
73
62
  }
@@ -11,7 +11,7 @@ export type CreateAppOptions = {
11
11
  runtime?: typeof runtime;
12
12
  props?: any;
13
13
  };
14
- export declare const createApp: ({ plugins, runtime, props: globalProps, }: CreateAppOptions) => (App?: React.ComponentType<any>) => React.ComponentType<any>;
14
+ export declare const createApp: ({ plugins, runtime, props: globalProps, }: CreateAppOptions) => (App?: React.ComponentType<any>) => ({ _internal_context, ...props }: any) => JSX.Element;
15
15
  type BootStrap<T = unknown> = (App: React.ComponentType, id: string | HTMLElement | RuntimeContext, root?: any, ReactDOM?: {
16
16
  render?: Renderer;
17
17
  hydrate?: Renderer;
@@ -25,7 +25,7 @@ interface GlobalContext {
25
25
  layoutApp?: React.ComponentType;
26
26
  }
27
27
  export declare function setGlobalContext(context: Omit<GlobalContext, 'appConfig'> & {
28
- appConfig: () => AppConfig;
28
+ appConfig?: () => AppConfig;
29
29
  }): void;
30
30
  export declare function getGlobalApp(): import("react").ComponentType<{}> | undefined;
31
31
  export declare function getGlobalRoutes(): undefined | (NestedRoute | PageRoute)[];
@@ -27,7 +27,7 @@ export interface RuntimeContext extends BaseRuntimeContext {
27
27
  }
28
28
  export declare const RuntimeReactContext: import("react").Context<RuntimeContext>;
29
29
  export declare const ServerRouterContext: import("react").Context<any>;
30
- export interface BaseTRuntimeContext {
30
+ export interface BaseTRuntimeContext extends Partial<BaseRuntimeContext> {
31
31
  initialData?: Record<string, unknown>;
32
32
  request?: SSRServerContext['request'];
33
33
  response?: SSRServerContext['response'];
@@ -1,50 +1,40 @@
1
1
  /// <reference types="react" />
2
2
  import { PluginOptions, Setup } from '@modern-js/plugin';
3
3
  import { RuntimeContext, TRuntimeContext } from '../context/runtime';
4
+ import type { RuntimeConfig } from './index';
5
+ export declare const RuntimeConfigContext: import("@modern-js/plugin").Context<RuntimeConfig>;
6
+ export declare const useRuntimeConfigContext: () => RuntimeConfig;
4
7
  export interface AppProps {
5
8
  }
6
9
  declare const runtimeHooks: {
7
- hoc: import("@modern-js/plugin").Pipeline<{
8
- App: React.ComponentType<any>;
9
- config: Record<string, any>;
10
- }, import("react").ComponentType<any>>;
11
- init: import("@modern-js/plugin").AsyncPipeline<{
12
- context: RuntimeContext;
13
- }, unknown>;
14
- pickContext: import("@modern-js/plugin").Pipeline<{
15
- context: RuntimeContext;
16
- pickedContext: TRuntimeContext;
17
- }, TRuntimeContext>;
10
+ beforeRender: import("@modern-js/plugin").AsyncInterruptWorkflow<RuntimeContext, void>;
11
+ wrapRoot: import("@modern-js/plugin").Waterfall<import("react").ComponentType<any>>;
12
+ pickContext: import("@modern-js/plugin").Waterfall<TRuntimeContext>;
13
+ modifyRuntimeConfig: import("@modern-js/plugin").SyncParallelWorkflow<void, Record<string, any>>;
14
+ };
15
+ declare const runtimePluginAPI: {
16
+ useRuntimeConfigContext: () => RuntimeConfig;
18
17
  };
19
18
  /** All hooks of runtime plugin. */
20
19
  export type RuntimeHooks = typeof runtimeHooks;
20
+ export type RuntimePluginAPI = typeof runtimePluginAPI;
21
21
  /** Plugin options of a runtime plugin. */
22
- export type Plugin = PluginOptions<RuntimeHooks, Setup<RuntimeHooks>>;
22
+ export type Plugin = PluginOptions<RuntimeHooks, Setup<RuntimeHooks, RuntimePluginAPI>>;
23
23
  export declare const createRuntime: () => import("@modern-js/plugin").Manager<{
24
- hoc: import("@modern-js/plugin").Pipeline<{
25
- App: React.ComponentType<any>;
26
- config: Record<string, any>;
27
- }, import("react").ComponentType<any>>;
28
- init: import("@modern-js/plugin").AsyncPipeline<{
29
- context: RuntimeContext;
30
- }, unknown>;
31
- pickContext: import("@modern-js/plugin").Pipeline<{
32
- context: RuntimeContext;
33
- pickedContext: TRuntimeContext;
34
- }, TRuntimeContext>;
35
- }, Record<string, never>>;
24
+ beforeRender: import("@modern-js/plugin").AsyncInterruptWorkflow<RuntimeContext, void>;
25
+ wrapRoot: import("@modern-js/plugin").Waterfall<import("react").ComponentType<any>>;
26
+ pickContext: import("@modern-js/plugin").Waterfall<TRuntimeContext>;
27
+ modifyRuntimeConfig: import("@modern-js/plugin").SyncParallelWorkflow<void, Record<string, any>>;
28
+ }, {
29
+ useRuntimeConfigContext: () => RuntimeConfig;
30
+ }>;
36
31
  export declare const runtime: import("@modern-js/plugin").Manager<{
37
- hoc: import("@modern-js/plugin").Pipeline<{
38
- App: React.ComponentType<any>;
39
- config: Record<string, any>;
40
- }, import("react").ComponentType<any>>;
41
- init: import("@modern-js/plugin").AsyncPipeline<{
42
- context: RuntimeContext;
43
- }, unknown>;
44
- pickContext: import("@modern-js/plugin").Pipeline<{
45
- context: RuntimeContext;
46
- pickedContext: TRuntimeContext;
47
- }, TRuntimeContext>;
48
- }, Record<string, never>>;
32
+ beforeRender: import("@modern-js/plugin").AsyncInterruptWorkflow<RuntimeContext, void>;
33
+ wrapRoot: import("@modern-js/plugin").Waterfall<import("react").ComponentType<any>>;
34
+ pickContext: import("@modern-js/plugin").Waterfall<TRuntimeContext>;
35
+ modifyRuntimeConfig: import("@modern-js/plugin").SyncParallelWorkflow<void, Record<string, any>>;
36
+ }, {
37
+ useRuntimeConfigContext: () => RuntimeConfig;
38
+ }>;
49
39
  export type PluginRunner = ReturnType<typeof runtime.init>;
50
40
  export {};
@@ -2,19 +2,12 @@
2
2
  import { runtime, Plugin } from './base';
3
3
  export * from './base';
4
4
  export interface RuntimeConfig {
5
- plugins: Plugin[];
5
+ plugins?: Plugin[];
6
6
  }
7
7
  export declare function registerPlugin(internalPlugins: Plugin[], runtimeConfig?: RuntimeConfig, customRuntime?: typeof runtime): import("@modern-js/plugin").ToRunners<{
8
- hoc: import("@modern-js/plugin").Pipeline<{
9
- App: import("react").ComponentType<any>;
10
- config: Record<string, any>;
11
- }, import("react").ComponentType<any>>;
12
- init: import("@modern-js/plugin").AsyncPipeline<{
13
- context: import("..").RuntimeContext;
14
- }, unknown>;
15
- pickContext: import("@modern-js/plugin").Pipeline<{
16
- context: import("..").RuntimeContext;
17
- pickedContext: import("../context/runtime").TRuntimeContext;
18
- }, import("../context/runtime").TRuntimeContext>;
8
+ beforeRender: import("@modern-js/plugin").AsyncInterruptWorkflow<import("..").RuntimeContext, void>;
9
+ wrapRoot: import("@modern-js/plugin").Waterfall<import("react").ComponentType<any>>;
10
+ pickContext: import("@modern-js/plugin").Waterfall<import("../context/runtime").TRuntimeContext>;
11
+ modifyRuntimeConfig: import("@modern-js/plugin").SyncParallelWorkflow<void, Record<string, any>>;
19
12
  }>;
20
13
  export declare function mergeConfig(config: Record<string, any>, ...otherConfig: Record<string, any>[]): Record<string, any>;
@@ -2,15 +2,8 @@
2
2
  import { PluginRunner } from './base';
3
3
  export declare function setGlobalRunner(runner: PluginRunner): void;
4
4
  export declare function getGlobalRunner(): import("@modern-js/plugin").ToRunners<{
5
- hoc: import("@modern-js/plugin").Pipeline<{
6
- App: import("react").ComponentType<any>;
7
- config: Record<string, any>;
8
- }, import("react").ComponentType<any>>;
9
- init: import("@modern-js/plugin").AsyncPipeline<{
10
- context: import("..").RuntimeContext;
11
- }, unknown>;
12
- pickContext: import("@modern-js/plugin").Pipeline<{
13
- context: import("..").RuntimeContext;
14
- pickedContext: import("../context/runtime").TRuntimeContext;
15
- }, import("../context/runtime").TRuntimeContext>;
5
+ beforeRender: import("@modern-js/plugin").AsyncInterruptWorkflow<import("..").RuntimeContext, void>;
6
+ wrapRoot: import("@modern-js/plugin").Waterfall<import("react").ComponentType<any>>;
7
+ pickContext: import("@modern-js/plugin").Waterfall<import("../context/runtime").TRuntimeContext>;
8
+ modifyRuntimeConfig: import("@modern-js/plugin").SyncParallelWorkflow<void, Record<string, any>>;
16
9
  }>;
@@ -1,6 +1,2 @@
1
1
  import React from 'react';
2
- export declare function createRoot(UserApp?: React.ComponentType | null, config?: {
3
- router: {
4
- basename: string;
5
- };
6
- }): React.ComponentType<any>;
2
+ export declare function createRoot(UserApp?: React.ComponentType | null): ({ _internal_context, ...props }: any) => JSX.Element;
@@ -15,5 +15,5 @@ export declare function checkIsNode(): boolean;
15
15
  * license at https://github.com/remix-run/remix/blob/main/LICENSE.md
16
16
  */
17
17
  export declare function serializeErrors(errors: StaticHandlerContext['errors']): StaticHandlerContext['errors'];
18
- export declare function getSSRConfigByEntry(entryName: string, ssr?: ServerUserConfig['ssr'], ssrByEntries?: ServerUserConfig['ssrByEntries'], staticGenerate?: boolean): import("@modern-js/app-tools").SSR;
18
+ export declare function getSSRConfigByEntry(entryName: string, ssr?: ServerUserConfig['ssr'], ssrByEntries?: ServerUserConfig['ssrByEntries']): import("@modern-js/app-tools").SSR;
19
19
  export declare function getSSRMode(ssrConfig?: SSRConfig): 'string' | 'stream' | false;
@@ -3,4 +3,4 @@ import type { RouterConfig, Routes } from './types';
3
3
  export declare let finalRouteConfig: RouterConfig['routesConfig'];
4
4
  export declare let beforeCreateRouter: boolean;
5
5
  export declare function modifyRoutes(modifyFunction: (routes: Routes) => Routes): void;
6
- export declare const routerPlugin: ({ serverBase, supportHtml5History, basename, routesConfig, createRoutes, }: RouterConfig) => Plugin;
6
+ export declare const routerPlugin: (userConfig?: Partial<RouterConfig>) => Plugin;
@@ -1,4 +1,4 @@
1
1
  import type { Plugin } from '../../core';
2
2
  import type { RouterConfig } from './types';
3
- export declare const routerPlugin: ({ basename, routesConfig, createRoutes, }: RouterConfig) => Plugin;
3
+ export declare const routerPlugin: (userConfig?: Partial<RouterConfig>) => Plugin;
4
4
  export declare const modifyRoutes: () => void;
@@ -6,6 +6,6 @@ type StateExtraType = {
6
6
  models: Array<Model>;
7
7
  };
8
8
  export type StateConfig = Partial<Record<StatePluginType, boolean> & StateExtraType>;
9
- export declare const statePlugin: (config: StateConfig) => Plugin;
9
+ export declare const statePlugin: (userConfig?: StateConfig) => Plugin;
10
10
  export default statePlugin;
11
11
  export * from '../plugins';
package/package.json CHANGED
@@ -15,7 +15,7 @@
15
15
  "modern",
16
16
  "modern.js"
17
17
  ],
18
- "version": "2.56.3-alpha.0",
18
+ "version": "2.57.0",
19
19
  "engines": {
20
20
  "node": ">=14.17.6"
21
21
  },
@@ -199,11 +199,11 @@
199
199
  "react-side-effect": "^2.1.1",
200
200
  "styled-components": "^5.3.1",
201
201
  "@swc/helpers": "0.5.3",
202
- "@modern-js/plugin": "2.56.2",
203
- "@modern-js/utils": "2.56.2",
204
- "@modern-js/types": "2.56.2",
205
- "@modern-js/runtime-utils": "2.56.2",
206
- "@modern-js/plugin-data-loader": "2.56.2"
202
+ "@modern-js/plugin": "2.57.0",
203
+ "@modern-js/runtime-utils": "2.57.0",
204
+ "@modern-js/types": "2.57.0",
205
+ "@modern-js/plugin-data-loader": "2.57.0",
206
+ "@modern-js/utils": "2.57.0"
207
207
  },
208
208
  "peerDependencies": {
209
209
  "react": ">=17",
@@ -226,15 +226,16 @@
226
226
  "ts-jest": "^29.1.0",
227
227
  "typescript": "^5",
228
228
  "webpack": "^5.93.0",
229
- "@modern-js/app-tools": "2.56.2",
230
- "@modern-js/core": "2.56.2",
231
- "@scripts/build": "2.56.2",
232
- "@scripts/jest-config": "2.56.2"
229
+ "@modern-js/app-tools": "2.57.0",
230
+ "@modern-js/core": "2.57.0",
231
+ "@scripts/jest-config": "2.57.0",
232
+ "@scripts/build": "2.57.0"
233
233
  },
234
234
  "sideEffects": false,
235
235
  "publishConfig": {
236
236
  "registry": "https://registry.npmjs.org/",
237
- "access": "public"
237
+ "access": "public",
238
+ "provenance": true
238
239
  },
239
240
  "scripts": {
240
241
  "dev": "modern-lib build --watch",