@modern-js/runtime 1.4.4 → 1.5.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 (74) hide show
  1. package/CHANGELOG.md +25 -0
  2. package/dist/js/modern/cli/index.js +1 -3
  3. package/dist/js/modern/core/app-config.js +10 -0
  4. package/dist/js/modern/core/compatible.js +218 -0
  5. package/dist/js/modern/core/index.js +7 -0
  6. package/dist/js/modern/core/loader/index.js +1 -0
  7. package/dist/js/modern/core/loader/loaderManager.js +189 -0
  8. package/dist/js/modern/core/loader/useLoader.js +105 -0
  9. package/dist/js/modern/core/plugin.js +63 -0
  10. package/dist/js/modern/core/runtime-context.js +2 -0
  11. package/dist/js/modern/exports/styled.js +2 -2
  12. package/dist/js/modern/index.js +1 -1
  13. package/dist/js/modern/router/runtime/plugin.js +1 -1
  14. package/dist/js/modern/router/runtime/utils.js +3 -1
  15. package/dist/js/modern/ssr/index.node.js +1 -1
  16. package/dist/js/modern/ssr/prefetch.js +2 -2
  17. package/dist/js/modern/ssr/serverRender/index.js +1 -1
  18. package/dist/js/modern/ssr/serverRender/styledComponent.js +1 -1
  19. package/dist/js/modern/state/runtime/plugin.js +1 -1
  20. package/dist/js/node/cli/index.js +1 -3
  21. package/dist/js/node/core/app-config.js +22 -0
  22. package/dist/js/node/core/compatible.js +247 -0
  23. package/dist/js/node/core/index.js +111 -0
  24. package/dist/js/node/core/loader/index.js +15 -0
  25. package/dist/js/node/core/loader/loaderManager.js +201 -0
  26. package/dist/js/node/core/loader/useLoader.js +118 -0
  27. package/dist/js/node/core/plugin.js +79 -0
  28. package/dist/js/node/core/runtime-context.js +11 -0
  29. package/dist/js/node/exports/styled.js +5 -5
  30. package/dist/js/node/index.js +10 -10
  31. package/dist/js/node/router/runtime/plugin.js +3 -3
  32. package/dist/js/node/router/runtime/utils.js +3 -1
  33. package/dist/js/node/ssr/index.node.js +2 -2
  34. package/dist/js/node/ssr/serverRender/index.js +2 -2
  35. package/dist/js/node/ssr/serverRender/styledComponent.js +2 -2
  36. package/dist/js/node/state/runtime/plugin.js +3 -3
  37. package/dist/js/treeshaking/cli/index.js +1 -3
  38. package/dist/js/treeshaking/core/app-config.js +13 -0
  39. package/dist/js/treeshaking/core/compatible.js +255 -0
  40. package/dist/js/treeshaking/core/index.js +7 -0
  41. package/dist/js/treeshaking/core/loader/index.js +1 -0
  42. package/dist/js/treeshaking/core/loader/loaderManager.js +267 -0
  43. package/dist/js/treeshaking/core/loader/useLoader.js +107 -0
  44. package/dist/js/treeshaking/core/plugin.js +105 -0
  45. package/dist/js/treeshaking/core/runtime-context.js +2 -0
  46. package/dist/js/treeshaking/exports/styled.js +2 -2
  47. package/dist/js/treeshaking/index.js +1 -1
  48. package/dist/js/treeshaking/router/runtime/plugin.js +1 -1
  49. package/dist/js/treeshaking/router/runtime/utils.js +3 -1
  50. package/dist/js/treeshaking/ssr/index.node.js +1 -1
  51. package/dist/js/treeshaking/ssr/prefetch.js +2 -2
  52. package/dist/js/treeshaking/ssr/serverRender/index.js +1 -1
  53. package/dist/js/treeshaking/ssr/serverRender/styledComponent.js +1 -1
  54. package/dist/js/treeshaking/state/runtime/plugin.js +1 -1
  55. package/dist/types/core/app-config.d.ts +6 -0
  56. package/dist/types/core/compatible.d.ts +13 -0
  57. package/dist/types/core/index.d.ts +9 -0
  58. package/dist/types/core/loader/index.d.ts +2 -0
  59. package/dist/types/core/loader/loaderManager.d.ts +57 -0
  60. package/dist/types/core/loader/useLoader.d.ts +54 -0
  61. package/dist/types/core/plugin.d.ts +208 -0
  62. package/dist/types/core/runtime-context.d.ts +13 -0
  63. package/dist/types/exports/styled.d.ts +2 -2
  64. package/dist/types/index.d.ts +4 -9
  65. package/dist/types/router/runtime/plugin.d.ts +1 -1
  66. package/dist/types/ssr/index.d.ts +2 -2
  67. package/dist/types/ssr/index.node.d.ts +1 -1
  68. package/dist/types/ssr/prefetch.d.ts +2 -2
  69. package/dist/types/ssr/serverRender/entry.d.ts +1 -1
  70. package/dist/types/ssr/serverRender/index.d.ts +1 -1
  71. package/dist/types/ssr/serverRender/type.d.ts +1 -1
  72. package/dist/types/state/runtime/plugin.d.ts +2 -2
  73. package/lib/types.d.ts +10 -0
  74. package/package.json +35 -25
@@ -0,0 +1,105 @@
1
+ import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
2
+ import _regeneratorRuntime from "@babel/runtime/helpers/esm/regeneratorRuntime";
3
+ import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
4
+ import { createManager, createPipeline, createAsyncPipeline } from '@modern-js/plugin';
5
+ import { createLoaderManager } from "./loader/loaderManager";
6
+ var hoc = createPipeline(); // eslint-disable-next-line @typescript-eslint/no-empty-interface
7
+
8
+ var provide = createPipeline();
9
+ var client = createAsyncPipeline();
10
+ var server = createAsyncPipeline();
11
+ var init = createAsyncPipeline();
12
+ var pickContext = createPipeline();
13
+ var runtimeHooks = {
14
+ hoc: hoc,
15
+ provide: provide,
16
+ client: client,
17
+ server: server,
18
+ init: init,
19
+ pickContext: pickContext
20
+ };
21
+ /** All hooks of runtime plugin. */
22
+
23
+ export var createRuntime = function createRuntime() {
24
+ return createManager(runtimeHooks);
25
+ };
26
+ /**
27
+ * register init hook. It would be revoked both ssr and csr.
28
+ */
29
+
30
+ var registerInit = function registerInit(App, _init) {
31
+ var originalInit = App.init;
32
+
33
+ App.init = /*#__PURE__*/function () {
34
+ var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(context) {
35
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
36
+ while (1) {
37
+ switch (_context.prev = _context.next) {
38
+ case 0:
39
+ if (!context.loaderManager) {
40
+ context.loaderManager = createLoaderManager({});
41
+ }
42
+
43
+ _context.next = 3;
44
+ return Promise.all([originalInit === null || originalInit === void 0 ? void 0 : originalInit(context), _init === null || _init === void 0 ? void 0 : _init(context)]);
45
+
46
+ case 3:
47
+ case "end":
48
+ return _context.stop();
49
+ }
50
+ }
51
+ }, _callee);
52
+ }));
53
+
54
+ return function (_x) {
55
+ return _ref.apply(this, arguments);
56
+ };
57
+ }();
58
+ };
59
+ /**
60
+ * register prefetch hook. It would be revoked both ssr and csr.
61
+ * But if ssr success, It wont exec in csr again.
62
+ * If ssr prefetch failed, It will fallback to exec in csr.
63
+ */
64
+
65
+
66
+ var registerPrefetch = function registerPrefetch(App, prefetch) {
67
+ var originalPrefetch = App.prefetch;
68
+
69
+ App.prefetch = /*#__PURE__*/function () {
70
+ var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(context) {
71
+ var originResult, result;
72
+ return _regeneratorRuntime().wrap(function _callee2$(_context2) {
73
+ while (1) {
74
+ switch (_context2.prev = _context2.next) {
75
+ case 0:
76
+ _context2.next = 2;
77
+ return originalPrefetch === null || originalPrefetch === void 0 ? void 0 : originalPrefetch(context);
78
+
79
+ case 2:
80
+ originResult = _context2.sent;
81
+ _context2.next = 5;
82
+ return prefetch === null || prefetch === void 0 ? void 0 : prefetch(context);
83
+
84
+ case 5:
85
+ result = _context2.sent;
86
+ return _context2.abrupt("return", _objectSpread(_objectSpread({}, originResult), result));
87
+
88
+ case 7:
89
+ case "end":
90
+ return _context2.stop();
91
+ }
92
+ }
93
+ }, _callee2);
94
+ }));
95
+
96
+ return function (_x2) {
97
+ return _ref2.apply(this, arguments);
98
+ };
99
+ }();
100
+ };
101
+
102
+ export var runtime = createRuntime();
103
+ var createPlugin = runtime.createPlugin;
104
+ export { createPlugin };
105
+ export { registerInit, registerPrefetch };
@@ -0,0 +1,2 @@
1
+ import { createContext } from 'react';
2
+ export var RuntimeReactContext = /*#__PURE__*/createContext({});
@@ -1,3 +1,3 @@
1
- import styled from '@modern-js/runtime-core/styled';
1
+ import styled from 'styled-components';
2
2
  export default styled;
3
- export * from '@modern-js/runtime-core/styled';
3
+ export * from 'styled-components';
@@ -1 +1 @@
1
- export { createApp, createPlugin, useLoader, bootstrap, RuntimeReactContext, registerPrefetch, defineConfig, registerInit, useRuntimeContext } from '@modern-js/runtime-core';
1
+ export { createApp, createPlugin, useLoader, bootstrap, RuntimeReactContext, registerPrefetch, defineConfig, registerInit, useRuntimeContext } from "./core";
@@ -2,8 +2,8 @@ import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
2
2
  import React, { useContext } from 'react';
3
3
  import { createBrowserHistory, createHashHistory } from 'history';
4
4
  import { Router, StaticRouter } from 'react-router-dom';
5
- import { RuntimeReactContext } from '@modern-js/runtime-core';
6
5
  import hoistNonReactStatics from 'hoist-non-react-statics';
6
+ import { RuntimeReactContext } from "../../core";
7
7
  import { isBrowser } from "../../common";
8
8
  import { renderRoutes, getLocation, urlJoin } from "./utils";
9
9
  import { jsx as _jsx } from "react/jsx-runtime";
@@ -60,11 +60,13 @@ export function renderRoutes(routesConfig) {
60
60
  });
61
61
  }
62
62
  export function getLocation(serverContext) {
63
+ var _url$replace;
64
+
63
65
  var _ref2 = (serverContext === null || serverContext === void 0 ? void 0 : serverContext.request) || {},
64
66
  pathname = _ref2.pathname,
65
67
  url = _ref2.url;
66
68
 
67
- var cleanUrl = url.replace('http://', '').replace('https://', '');
69
+ var cleanUrl = url === null || url === void 0 ? void 0 : (_url$replace = url.replace('http://', '')) === null || _url$replace === void 0 ? void 0 : _url$replace.replace('https://', '');
68
70
  var index = (cleanUrl || '').indexOf(pathname);
69
71
 
70
72
  if (index === -1) {
@@ -6,7 +6,7 @@ import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
6
6
 
7
7
  /* eslint-disable @typescript-eslint/no-require-imports */
8
8
  import path from 'path';
9
- import { registerPrefetch } from '@modern-js/runtime-core';
9
+ import { registerPrefetch } from "../core";
10
10
  import { isBrowser } from "../common";
11
11
  import prefetch from "./prefetch";
12
12
  import { formatServer } from "./utils";
@@ -5,10 +5,10 @@ import fs from 'fs';
5
5
  import { renderToStaticMarkup } from 'react-dom/server';
6
6
  import { run } from '@modern-js/utils/ssr';
7
7
  import { LOADABLE_STATS_FILE } from '@modern-js/utils/constants';
8
- import { ChunkExtractor } from '@loadable/server'; // todo: SSRContext
9
-
8
+ import { ChunkExtractor } from '@loadable/server';
10
9
  import { jsx as _jsx } from "react/jsx-runtime";
11
10
 
11
+ // todo: SSRContext
12
12
  var prefetch = /*#__PURE__*/function () {
13
13
  var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(App, context) {
14
14
  return _regeneratorRuntime().wrap(function _callee2$(_context2) {
@@ -1,7 +1,7 @@
1
1
  import _regeneratorRuntime from "@babel/runtime/helpers/esm/regeneratorRuntime";
2
2
  import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
3
- import { RuntimeContext } from '@modern-js/runtime-core';
4
3
  import { run } from '@modern-js/utils/ssr';
4
+ import { RuntimeContext } from "../../core";
5
5
  import { PreRender } from "../react/prerender";
6
6
  import SSREntry from "./entry";
7
7
  import { time } from "./measure";
@@ -1,4 +1,4 @@
1
- import { ServerStyleSheet } from '@modern-js/runtime-core/styled';
1
+ import { ServerStyleSheet } from 'styled-components';
2
2
  export var toHtml = function toHtml(jsx, renderer, next) {
3
3
  var sheet = new ServerStyleSheet();
4
4
  var html = next(sheet.collectStyles(jsx));
@@ -1,9 +1,9 @@
1
1
  import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
2
2
  import { useContext } from 'react';
3
- import { RuntimeReactContext } from '@modern-js/runtime-core';
4
3
  import { createStore } from '@modern-js-reduck/store';
5
4
  import { Provider } from '@modern-js-reduck/react';
6
5
  import hoistNonReactStatics from 'hoist-non-react-statics';
6
+ import { RuntimeReactContext } from "../../core";
7
7
  import { isBrowser } from "../../common";
8
8
  import { jsx as _jsx } from "react/jsx-runtime";
9
9
 
@@ -0,0 +1,6 @@
1
+ import type React from 'react';
2
+ export interface AppConfig {
3
+ [key: string]: any;
4
+ }
5
+ export declare const getConfig: (Component: React.ComponentType<any>) => AppConfig | undefined;
6
+ export declare const defineConfig: (Component: React.ComponentType<any>, config: AppConfig) => React.ComponentType<any>;
@@ -0,0 +1,13 @@
1
+ import React from 'react';
2
+ import { Plugin } from './plugin';
3
+ import { TRuntimeContext } from './runtime-context';
4
+ export declare type CreateAppOptions = {
5
+ plugins: Plugin[];
6
+ };
7
+ export declare const createApp: ({
8
+ plugins
9
+ }: CreateAppOptions) => (App?: React.ComponentType<any>) => React.ComponentType<any>;
10
+ declare type BootStrap<T = unknown> = (App: React.ComponentType, id?: string | Record<string, any> | HTMLElement) => Promise<T>;
11
+ export declare const bootstrap: BootStrap;
12
+ export declare const useRuntimeContext: () => TRuntimeContext;
13
+ export {};
@@ -0,0 +1,9 @@
1
+ export { createPlugin, createRuntime, runtime, registerInit, registerPrefetch } from './plugin';
2
+ export type { Plugin } from './plugin';
3
+ export { defineConfig, getConfig } from './app-config';
4
+ export type { AppConfig } from './app-config';
5
+ export * from './compatible';
6
+ export type { TRuntimeContext, RuntimeContext } from './runtime-context';
7
+ export { RuntimeReactContext } from './runtime-context';
8
+ export * from './loader';
9
+ export * from '@modern-js/plugin';
@@ -0,0 +1,2 @@
1
+ export { default as useLoader } from './useLoader';
2
+ export type { SSRData, SSRContainer } from './useLoader';
@@ -0,0 +1,57 @@
1
+ import { LoaderOptions } from './useLoader';
2
+ export declare enum LoaderStatus {
3
+ idle = 0,
4
+ loading = 1,
5
+ fulfilled = 2,
6
+ rejected = 3,
7
+ }
8
+ export declare type LoaderResult = {
9
+ loading: boolean;
10
+ reloading: boolean;
11
+ data: any;
12
+ error: any;
13
+ _error?: any;
14
+ };
15
+ declare const createLoader: (id: string, initialData: Partial<LoaderResult> | undefined, loaderFn: () => Promise<any>, skip?: boolean) => {
16
+ readonly result: {
17
+ loading: boolean;
18
+ reloading: boolean;
19
+ data: any;
20
+ error: any;
21
+ _error: any;
22
+ };
23
+ readonly promise: Promise<any> | null;
24
+ onChange: (handler: (status: LoaderStatus, result: LoaderResult) => void) => () => void;
25
+ load: () => Promise<any>;
26
+ };
27
+ declare type ManagerOption = {
28
+ /**
29
+ * whether current manage only exec static loader
30
+ */
31
+ skipStatic?: boolean;
32
+ skipNonStatic?: boolean;
33
+ };
34
+ /**
35
+ * Create loaders manager. It's returned instance will add to context
36
+ * @param initialDataMap used to initialing loader data
37
+ */
38
+
39
+ export declare const createLoaderManager: (initialDataMap: Record<string, LoaderResult>, managerOptions?: ManagerOption) => {
40
+ hasPendingLoaders: () => boolean;
41
+ awaitPendingLoaders: () => Promise<Record<string, LoaderResult>>;
42
+ add: (loaderFn: () => Promise<any>, loaderOptions: LoaderOptions) => any;
43
+ get: (id: string) => {
44
+ readonly result: {
45
+ loading: boolean;
46
+ reloading: boolean;
47
+ data: any;
48
+ error: any;
49
+ _error: any;
50
+ };
51
+ readonly promise: Promise<any> | null;
52
+ onChange: (handler: (status: LoaderStatus, result: LoaderResult) => void) => () => void;
53
+ load: () => Promise<any>;
54
+ } | undefined;
55
+ };
56
+ export declare type Loader = ReturnType<typeof createLoader>;
57
+ export {};
@@ -0,0 +1,54 @@
1
+ import { LoaderResult } from './loaderManager';
2
+ export interface SSRData {
3
+ loadersData: Record<string, LoaderResult | undefined>;
4
+ initialData?: Record<string, unknown>;
5
+ }
6
+ export interface SSRContainer {
7
+ data?: SSRData;
8
+ }
9
+ declare global {
10
+ interface Window {
11
+ _SSR_DATA?: SSRContainer;
12
+ }
13
+ }
14
+ export interface LoaderOptions<Params = any, TData = any, TError extends Error = any> {
15
+ /**
16
+ * Revoke when loader excuted successfully.
17
+ */
18
+ onSuccess?: (data: TData) => void;
19
+ /**
20
+ * Revoke when loader ended with error
21
+ */
22
+
23
+ onError?: (error: TError) => void;
24
+ /**
25
+ * initialData to display once loader is ready.
26
+ */
27
+
28
+ initialData?: TData;
29
+ /**
30
+ * whether skip loader
31
+ * if true, the loader will not exec.
32
+ */
33
+
34
+ skip?: boolean;
35
+ /**
36
+ * User params, it will pass to loader's second parameter.
37
+ */
38
+
39
+ params?: Params;
40
+ /**
41
+ * whether loader can exec on build phase.
42
+ */
43
+
44
+ static?: boolean;
45
+ }
46
+ declare type LoaderFn<P = any, T = any> = (context: any, params: P) => Promise<T>;
47
+ declare const useLoader: <TData = any, Params = any, E = any>(loaderFn: LoaderFn<Params, TData>, options?: LoaderOptions<Params, any, any>) => {
48
+ reload: (params?: Params | undefined) => Promise<any> | undefined;
49
+ loading: boolean;
50
+ reloading: boolean;
51
+ data: TData;
52
+ error: E;
53
+ };
54
+ export default useLoader;
@@ -0,0 +1,208 @@
1
+ import type React from 'react';
2
+ import { Setup, ToThreads, CommonAPI, PluginOptions } from '@modern-js/plugin';
3
+ import type { RuntimeContext, TRuntimeContext } from './runtime-context';
4
+ export interface AppProps {}
5
+ declare const runtimeHooks: {
6
+ hoc: import("@modern-js/plugin").Pipeline<{
7
+ App: React.ComponentType<any>;
8
+ }, React.ComponentType<any>>;
9
+ provide: import("@modern-js/plugin").Pipeline<{
10
+ element: JSX.Element;
11
+ readonly props: AppProps;
12
+ readonly context: RuntimeContext;
13
+ }, JSX.Element>;
14
+ client: import("@modern-js/plugin").AsyncPipeline<{
15
+ App: React.ComponentType<any>;
16
+ readonly context?: RuntimeContext | undefined;
17
+ rootElement: HTMLElement;
18
+ }, void>;
19
+ server: import("@modern-js/plugin").AsyncPipeline<{
20
+ App: React.ComponentType<any>;
21
+ readonly context?: RuntimeContext | undefined;
22
+ }, string>;
23
+ init: import("@modern-js/plugin").AsyncPipeline<{
24
+ context: RuntimeContext;
25
+ }, unknown>;
26
+ pickContext: import("@modern-js/plugin").Pipeline<{
27
+ context: RuntimeContext;
28
+ pickedContext: TRuntimeContext;
29
+ }, TRuntimeContext>;
30
+ };
31
+ /** All hooks of runtime plugin. */
32
+
33
+ export declare type RuntimeHooks = typeof runtimeHooks;
34
+ /** All hook callbacks of runtime plugin. */
35
+
36
+ export declare type RuntimeHookCallbacks = ToThreads<RuntimeHooks>;
37
+ /** All apis for runtime plugin. */
38
+
39
+ export declare type PluginAPI = CommonAPI<RuntimeHooks>;
40
+ /** Plugin options of a runtime plugin. */
41
+
42
+ export declare type Plugin = PluginOptions<RuntimeHooks, Setup<RuntimeHooks>>;
43
+ export declare const createRuntime: () => import("@modern-js/plugin").Manager<{
44
+ hoc: import("@modern-js/plugin").Pipeline<{
45
+ App: React.ComponentType<any>;
46
+ }, React.ComponentType<any>>;
47
+ provide: import("@modern-js/plugin").Pipeline<{
48
+ element: JSX.Element;
49
+ readonly props: AppProps;
50
+ readonly context: RuntimeContext;
51
+ }, JSX.Element>;
52
+ client: import("@modern-js/plugin").AsyncPipeline<{
53
+ App: React.ComponentType<any>;
54
+ readonly context?: RuntimeContext | undefined;
55
+ rootElement: HTMLElement;
56
+ }, void>;
57
+ server: import("@modern-js/plugin").AsyncPipeline<{
58
+ App: React.ComponentType<any>;
59
+ readonly context?: RuntimeContext | undefined;
60
+ }, string>;
61
+ init: import("@modern-js/plugin").AsyncPipeline<{
62
+ context: RuntimeContext;
63
+ }, unknown>;
64
+ pickContext: import("@modern-js/plugin").Pipeline<{
65
+ context: RuntimeContext;
66
+ pickedContext: TRuntimeContext;
67
+ }, TRuntimeContext>;
68
+ }, Record<string, never>>;
69
+ /**
70
+ * register init hook. It would be revoked both ssr and csr.
71
+ */
72
+
73
+ declare const registerInit: (App: React.ComponentType, _init: (context: RuntimeContext) => any | Promise<any>) => void;
74
+ /**
75
+ * register prefetch hook. It would be revoked both ssr and csr.
76
+ * But if ssr success, It wont exec in csr again.
77
+ * If ssr prefetch failed, It will fallback to exec in csr.
78
+ */
79
+
80
+ declare const registerPrefetch: (App: React.ComponentType, prefetch: (context: RuntimeContext) => Promise<any>) => void;
81
+ export declare const runtime: import("@modern-js/plugin").Manager<{
82
+ hoc: import("@modern-js/plugin").Pipeline<{
83
+ App: React.ComponentType<any>;
84
+ }, React.ComponentType<any>>;
85
+ provide: import("@modern-js/plugin").Pipeline<{
86
+ element: JSX.Element;
87
+ readonly props: AppProps;
88
+ readonly context: RuntimeContext;
89
+ }, JSX.Element>;
90
+ client: import("@modern-js/plugin").AsyncPipeline<{
91
+ App: React.ComponentType<any>;
92
+ readonly context?: RuntimeContext | undefined;
93
+ rootElement: HTMLElement;
94
+ }, void>;
95
+ server: import("@modern-js/plugin").AsyncPipeline<{
96
+ App: React.ComponentType<any>;
97
+ readonly context?: RuntimeContext | undefined;
98
+ }, string>;
99
+ init: import("@modern-js/plugin").AsyncPipeline<{
100
+ context: RuntimeContext;
101
+ }, unknown>;
102
+ pickContext: import("@modern-js/plugin").Pipeline<{
103
+ context: RuntimeContext;
104
+ pickedContext: TRuntimeContext;
105
+ }, TRuntimeContext>;
106
+ }, Record<string, never>>;
107
+ export declare const createPlugin: (setup?: Setup<{
108
+ hoc: import("@modern-js/plugin").Pipeline<{
109
+ App: React.ComponentType<any>;
110
+ }, React.ComponentType<any>>;
111
+ provide: import("@modern-js/plugin").Pipeline<{
112
+ element: JSX.Element;
113
+ readonly props: AppProps;
114
+ readonly context: RuntimeContext;
115
+ }, JSX.Element>;
116
+ client: import("@modern-js/plugin").AsyncPipeline<{
117
+ App: React.ComponentType<any>;
118
+ readonly context?: RuntimeContext | undefined;
119
+ rootElement: HTMLElement;
120
+ }, void>;
121
+ server: import("@modern-js/plugin").AsyncPipeline<{
122
+ App: React.ComponentType<any>;
123
+ readonly context?: RuntimeContext | undefined;
124
+ }, string>;
125
+ init: import("@modern-js/plugin").AsyncPipeline<{
126
+ context: RuntimeContext;
127
+ }, unknown>;
128
+ pickContext: import("@modern-js/plugin").Pipeline<{
129
+ context: RuntimeContext;
130
+ pickedContext: TRuntimeContext;
131
+ }, TRuntimeContext>;
132
+ }, Record<string, never>> | undefined, options?: PluginOptions<{
133
+ hoc: import("@modern-js/plugin").Pipeline<{
134
+ App: React.ComponentType<any>;
135
+ }, React.ComponentType<any>>;
136
+ provide: import("@modern-js/plugin").Pipeline<{
137
+ element: JSX.Element;
138
+ readonly props: AppProps;
139
+ readonly context: RuntimeContext;
140
+ }, JSX.Element>;
141
+ client: import("@modern-js/plugin").AsyncPipeline<{
142
+ App: React.ComponentType<any>;
143
+ readonly context?: RuntimeContext | undefined;
144
+ rootElement: HTMLElement;
145
+ }, void>;
146
+ server: import("@modern-js/plugin").AsyncPipeline<{
147
+ App: React.ComponentType<any>;
148
+ readonly context?: RuntimeContext | undefined;
149
+ }, string>;
150
+ init: import("@modern-js/plugin").AsyncPipeline<{
151
+ context: RuntimeContext;
152
+ }, unknown>;
153
+ pickContext: import("@modern-js/plugin").Pipeline<{
154
+ context: RuntimeContext;
155
+ pickedContext: TRuntimeContext;
156
+ }, TRuntimeContext>;
157
+ }, Setup<{
158
+ hoc: import("@modern-js/plugin").Pipeline<{
159
+ App: React.ComponentType<any>;
160
+ }, React.ComponentType<any>>;
161
+ provide: import("@modern-js/plugin").Pipeline<{
162
+ element: JSX.Element;
163
+ readonly props: AppProps;
164
+ readonly context: RuntimeContext;
165
+ }, JSX.Element>;
166
+ client: import("@modern-js/plugin").AsyncPipeline<{
167
+ App: React.ComponentType<any>;
168
+ readonly context?: RuntimeContext | undefined;
169
+ rootElement: HTMLElement;
170
+ }, void>;
171
+ server: import("@modern-js/plugin").AsyncPipeline<{
172
+ App: React.ComponentType<any>;
173
+ readonly context?: RuntimeContext | undefined;
174
+ }, string>;
175
+ init: import("@modern-js/plugin").AsyncPipeline<{
176
+ context: RuntimeContext;
177
+ }, unknown>;
178
+ pickContext: import("@modern-js/plugin").Pipeline<{
179
+ context: RuntimeContext;
180
+ pickedContext: TRuntimeContext;
181
+ }, TRuntimeContext>;
182
+ }, Record<string, never>>> | undefined) => import("@modern-js/plugin").Plugin<{
183
+ hoc: import("@modern-js/plugin").Pipeline<{
184
+ App: React.ComponentType<any>;
185
+ }, React.ComponentType<any>>;
186
+ provide: import("@modern-js/plugin").Pipeline<{
187
+ element: JSX.Element;
188
+ readonly props: AppProps;
189
+ readonly context: RuntimeContext;
190
+ }, JSX.Element>;
191
+ client: import("@modern-js/plugin").AsyncPipeline<{
192
+ App: React.ComponentType<any>;
193
+ readonly context?: RuntimeContext | undefined;
194
+ rootElement: HTMLElement;
195
+ }, void>;
196
+ server: import("@modern-js/plugin").AsyncPipeline<{
197
+ App: React.ComponentType<any>;
198
+ readonly context?: RuntimeContext | undefined;
199
+ }, string>;
200
+ init: import("@modern-js/plugin").AsyncPipeline<{
201
+ context: RuntimeContext;
202
+ }, unknown>;
203
+ pickContext: import("@modern-js/plugin").Pipeline<{
204
+ context: RuntimeContext;
205
+ pickedContext: TRuntimeContext;
206
+ }, TRuntimeContext>;
207
+ }, Record<string, never>>;
208
+ export { registerInit, registerPrefetch };
@@ -0,0 +1,13 @@
1
+ /// <reference types="react" />
2
+ import { createLoaderManager } from './loader/loaderManager';
3
+ import { runtime } from './plugin';
4
+ export interface RuntimeContext {
5
+ loaderManager: ReturnType<typeof createLoaderManager>;
6
+ runner: ReturnType<typeof runtime.init>;
7
+ [key: string]: any;
8
+ }
9
+ export declare const RuntimeReactContext: import("react").Context<RuntimeContext>;
10
+ export interface TRuntimeContext {
11
+ initialData?: Record<string, unknown>;
12
+ [key: string]: any;
13
+ }
@@ -1,3 +1,3 @@
1
- import styled from '@modern-js/runtime-core/styled';
1
+ import styled from 'styled-components';
2
2
  export default styled;
3
- export * from '@modern-js/runtime-core/styled';
3
+ export * from 'styled-components';
@@ -1,16 +1,11 @@
1
1
  import type { StateConfig } from './state';
2
2
  import type { RouterConfig } from './router';
3
- export type { RuntimeContext, TRuntimeContext } from '@modern-js/runtime-core';
4
- export { createApp, createPlugin, useLoader, bootstrap, RuntimeReactContext, registerPrefetch, defineConfig, registerInit, useRuntimeContext } from '@modern-js/runtime-core';
5
- declare module '@modern-js/runtime-core' {
3
+ export type { Plugin, RuntimeContext, TRuntimeContext, AppConfig } from './core';
4
+ export { createApp, createPlugin, useLoader, bootstrap, RuntimeReactContext, registerPrefetch, defineConfig, registerInit, useRuntimeContext } from './core';
5
+ export { StateConfig, RouterConfig };
6
+ declare module './core' {
6
7
  interface AppConfig {
7
8
  router?: RouterConfig | boolean;
8
9
  state?: StateConfig | boolean;
9
10
  }
10
- }
11
- declare module '@modern-js/core' {
12
- interface RuntimeConfig {
13
- router?: RouterConfig | boolean;
14
- state?: StateConfig | boolean;
15
- }
16
11
  }
@@ -1,7 +1,7 @@
1
1
  import React from 'react';
2
2
  import { History, BrowserHistoryBuildOptions, HashHistoryBuildOptions } from 'history';
3
3
  import { RouteProps } from 'react-router-dom';
4
- import type { Plugin } from '@modern-js/runtime-core';
4
+ import type { Plugin } from '../../core';
5
5
  declare global {
6
6
  interface Window {
7
7
  _SERVER_DATA?: {
@@ -1,6 +1,6 @@
1
- import type { Plugin } from '@modern-js/runtime-core';
1
+ import type { Plugin } from '../core';
2
2
  import { RenderLevel, SSRServerContext } from './serverRender/type';
3
- declare module '@modern-js/runtime-core' {
3
+ declare module '../core' {
4
4
  interface RuntimeContext {
5
5
  ssrContext: SSRServerContext;
6
6
  }
@@ -1,4 +1,4 @@
1
- import type { Plugin } from '@modern-js/runtime-core';
1
+ import type { Plugin } from '../core';
2
2
  declare const plugin: () => Plugin;
3
3
  export default plugin;
4
4
  export * from './react';
@@ -1,11 +1,11 @@
1
- import { RuntimeContext } from '@modern-js/runtime-core';
1
+ import { RuntimeContext } from '../core';
2
2
  declare const prefetch: (App: React.ComponentType<any>, context: RuntimeContext) => Promise<{
3
3
  initialData: any;
4
4
  i18nData: any;
5
5
  loadersData?: undefined;
6
6
  storeState?: undefined;
7
7
  } | {
8
- loadersData: Record<string, import("@modern-js/runtime-core/src/loader/loaderManager").LoaderResult>;
8
+ loadersData: Record<string, import("../core/loader/loaderManager").LoaderResult>;
9
9
  initialData: any;
10
10
  i18nData: any;
11
11
  storeState: any;
@@ -1,4 +1,4 @@
1
- import { RuntimeContext } from '@modern-js/runtime-core';
1
+ import { RuntimeContext } from '../../core';
2
2
  import { ModernSSRReactComponent, SSRServerContext, RenderResult } from './type';
3
3
  declare type EntryOptions = {
4
4
  ctx: SSRServerContext;
@@ -1,4 +1,4 @@
1
- import { RuntimeContext } from '@modern-js/runtime-core';
1
+ import { RuntimeContext } from '../../core';
2
2
  import { ModernSSRReactComponent } from './type';
3
3
  declare module '@modern-js/runtime' {
4
4
  interface RuntimeContext {