@modern-js/runtime 1.16.0 → 1.18.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.
- package/CHANGELOG.md +45 -0
- package/dist/js/modern/cli/index.js +1 -10
- package/dist/js/modern/core/compatible.js +6 -6
- package/dist/js/modern/core/index.js +3 -3
- package/dist/js/modern/core/loader/useLoader.js +1 -1
- package/dist/js/modern/{core/runtime-context.js → runtime-context.js} +0 -0
- package/dist/js/modern/ssr/index.js +5 -5
- package/dist/js/modern/ssr/index.node.js +4 -1
- package/dist/js/modern/ssr/serverRender/index.js +0 -1
- package/dist/js/node/cli/index.js +0 -10
- package/dist/js/node/core/compatible.js +7 -7
- package/dist/js/node/core/index.js +1 -1
- package/dist/js/node/core/loader/useLoader.js +1 -1
- package/dist/js/node/{core/runtime-context.js → runtime-context.js} +0 -0
- package/dist/js/node/ssr/index.js +5 -5
- package/dist/js/node/ssr/index.node.js +4 -1
- package/dist/js/node/ssr/serverRender/index.js +0 -2
- package/dist/js/treeshaking/cli/index.js +1 -9
- package/dist/js/treeshaking/core/compatible.js +20 -22
- package/dist/js/treeshaking/core/index.js +3 -3
- package/dist/js/treeshaking/core/loader/useLoader.js +1 -1
- package/dist/js/treeshaking/{core/runtime-context.js → runtime-context.js} +0 -0
- package/dist/js/treeshaking/ssr/index.js +5 -5
- package/dist/js/treeshaking/ssr/index.node.js +12 -9
- package/dist/js/treeshaking/ssr/serverRender/index.js +0 -1
- package/dist/types/common.d.ts +8 -1
- package/dist/types/core/app-config.d.ts +1 -3
- package/dist/types/core/compatible.d.ts +7 -2
- package/dist/types/core/index.d.ts +2 -3
- package/dist/types/core/loader/useLoader.d.ts +1 -0
- package/dist/types/core/plugin.d.ts +1 -1
- package/dist/types/index.d.ts +4 -8
- package/dist/types/runtime-context.d.ts +24 -0
- package/dist/types/ssr/index.d.ts +0 -7
- package/dist/types/ssr/serverRender/index.d.ts +0 -5
- package/dist/types/state/runtime/plugin.d.ts +1 -12
- package/package.json +10 -9
- package/dist/types/core/runtime-context.d.ts +0 -13
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,50 @@
|
|
|
1
1
|
# @modern-js/runtime
|
|
2
2
|
|
|
3
|
+
## 1.18.0
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies [8280920]
|
|
8
|
+
- Updated dependencies [5227370]
|
|
9
|
+
- Updated dependencies [7928bae]
|
|
10
|
+
- @modern-js/utils@1.18.0
|
|
11
|
+
- @modern-js/webpack@1.18.0
|
|
12
|
+
- @modern-js/plugin@1.18.0
|
|
13
|
+
|
|
14
|
+
## 1.17.0
|
|
15
|
+
|
|
16
|
+
### Patch Changes
|
|
17
|
+
|
|
18
|
+
- 77d3a38: feat: remove `.runtime-exports/index.js` export
|
|
19
|
+
|
|
20
|
+
feat: 移除 `.runtime-exports/index.js` 导出
|
|
21
|
+
|
|
22
|
+
- 492437f: fix: runtime type
|
|
23
|
+
|
|
24
|
+
fix: 修复 runtime 类型定义
|
|
25
|
+
|
|
26
|
+
- c3d4a6a: feat: support react 18 ssr
|
|
27
|
+
feat: 支持 React 18 下使用 SSR
|
|
28
|
+
- Updated dependencies [1b9176f]
|
|
29
|
+
- Updated dependencies [77d3a38]
|
|
30
|
+
- Updated dependencies [151329d]
|
|
31
|
+
- Updated dependencies [5af9472]
|
|
32
|
+
- Updated dependencies [6b6a534]
|
|
33
|
+
- Updated dependencies [6b43a2b]
|
|
34
|
+
- Updated dependencies [a7be124]
|
|
35
|
+
- Updated dependencies [31547b4]
|
|
36
|
+
- @modern-js/utils@1.17.0
|
|
37
|
+
- @modern-js/webpack@1.17.0
|
|
38
|
+
- @modern-js/plugin@1.17.0
|
|
39
|
+
|
|
40
|
+
## 1.16.1
|
|
41
|
+
|
|
42
|
+
### Patch Changes
|
|
43
|
+
|
|
44
|
+
- fix: runtime type
|
|
45
|
+
|
|
46
|
+
fix: 修复 runtime 类型定义
|
|
47
|
+
|
|
3
48
|
## 1.16.0
|
|
4
49
|
|
|
5
50
|
### Minor Changes
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import path from 'path';
|
|
2
|
-
import { PLUGIN_SCHEMAS,
|
|
2
|
+
import { PLUGIN_SCHEMAS, cleanRequireCache, isReact18 } from '@modern-js/utils';
|
|
3
3
|
import PluginState from "../state/cli";
|
|
4
4
|
import PluginSSR from "../ssr/cli";
|
|
5
5
|
import PluginRouter from "../router/cli";
|
|
@@ -8,19 +8,15 @@ export default (() => ({
|
|
|
8
8
|
post: ['@modern-js/plugin-router', '@modern-js/plugin-ssr', '@modern-js/plugin-state', '@modern-js/plugin-design-token'],
|
|
9
9
|
usePlugins: [PluginState(), PluginRouter(), PluginSSR()],
|
|
10
10
|
setup: api => {
|
|
11
|
-
let runtimeExportsUtils = {};
|
|
12
11
|
return {
|
|
13
12
|
config() {
|
|
14
13
|
const dir = api.useAppContext().internalDirectory || '';
|
|
15
|
-
runtimeExportsUtils = createRuntimeExportsUtils(dir, 'index');
|
|
16
14
|
process.env.IS_REACT18 = isReact18(path.join(dir, '../../')).toString();
|
|
17
15
|
return {
|
|
18
16
|
runtime: {},
|
|
19
17
|
runtimeByEntries: {},
|
|
20
18
|
source: {
|
|
21
19
|
alias: {
|
|
22
|
-
'@modern-js/runtime$': runtimeExportsUtils.getPath(),
|
|
23
|
-
|
|
24
20
|
/**
|
|
25
21
|
* twin.macro inserts styled-components into the code during the compilation process
|
|
26
22
|
* But it will not be installed under the user project.
|
|
@@ -37,11 +33,6 @@ export default (() => ({
|
|
|
37
33
|
return PLUGIN_SCHEMAS['@modern-js/runtime'];
|
|
38
34
|
},
|
|
39
35
|
|
|
40
|
-
addRuntimeExports() {
|
|
41
|
-
const runtimePackage = path.resolve(__dirname, '../../../../');
|
|
42
|
-
runtimeExportsUtils.addExport(`export * from '${runtimePackage}'`);
|
|
43
|
-
},
|
|
44
|
-
|
|
45
36
|
async beforeRestart() {
|
|
46
37
|
cleanRequireCache([require.resolve("../state/cli"), require.resolve("../router/cli"), require.resolve("../ssr/cli")]);
|
|
47
38
|
}
|
|
@@ -13,8 +13,8 @@ function _defineProperty(obj, key, value) { if (key in obj) { Object.definePrope
|
|
|
13
13
|
import React, { useContext, useMemo } from 'react';
|
|
14
14
|
import defaultReactDOM from 'react-dom';
|
|
15
15
|
import hoistNonReactStatics from 'hoist-non-react-statics';
|
|
16
|
+
import { RuntimeReactContext } from "../runtime-context";
|
|
16
17
|
import { runtime } from "./plugin";
|
|
17
|
-
import { RuntimeReactContext } from "./runtime-context";
|
|
18
18
|
import { createLoaderManager } from "./loader/loaderManager";
|
|
19
19
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
20
20
|
const IS_REACT18 = process.env.IS_REACT18 === 'true';
|
|
@@ -110,7 +110,7 @@ id,
|
|
|
110
110
|
/**
|
|
111
111
|
* root.render need use root to run function
|
|
112
112
|
*/
|
|
113
|
-
root,
|
|
113
|
+
root, ReactDOM = defaultReactDOM) => {
|
|
114
114
|
let App = BootApp;
|
|
115
115
|
let runner = runnerMap.get(App); // ensure Component used is created by `createApp`
|
|
116
116
|
|
|
@@ -178,17 +178,17 @@ root, render = defaultReactDOM.render, hydrate = defaultReactDOM.hydrate) => {
|
|
|
178
178
|
|
|
179
179
|
const ModernRender = App => {
|
|
180
180
|
if (IS_REACT18) {
|
|
181
|
-
root.render(App);
|
|
181
|
+
(root || ReactDOM.createRoot(rootElement)).render(App);
|
|
182
182
|
} else {
|
|
183
|
-
render(App, rootElement);
|
|
183
|
+
ReactDOM.render(App, rootElement);
|
|
184
184
|
}
|
|
185
185
|
};
|
|
186
186
|
|
|
187
187
|
const ModernHydrate = (App, callback) => {
|
|
188
188
|
if (IS_REACT18) {
|
|
189
|
-
|
|
189
|
+
ReactDOM.hydrateRoot(rootElement, App);
|
|
190
190
|
} else {
|
|
191
|
-
hydrate(App, rootElement, callback);
|
|
191
|
+
ReactDOM.hydrate(App, rootElement, callback);
|
|
192
192
|
}
|
|
193
193
|
};
|
|
194
194
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export { createPlugin, createRuntime, runtime, registerInit, registerPrefetch } from "./plugin";
|
|
2
|
-
export { defineConfig, getConfig } from "./app-config";
|
|
3
|
-
|
|
2
|
+
export { defineConfig, getConfig } from "./app-config"; // compatible
|
|
3
|
+
|
|
4
4
|
export * from "./compatible";
|
|
5
|
-
export { RuntimeReactContext } from "
|
|
5
|
+
export { RuntimeReactContext } from "../runtime-context";
|
|
6
6
|
export * from "./loader";
|
|
7
7
|
export * from '@modern-js/plugin';
|
|
@@ -6,7 +6,7 @@ function _defineProperty(obj, key, value) { if (key in obj) { Object.definePrope
|
|
|
6
6
|
|
|
7
7
|
import { useContext, useRef, useMemo, useState, useCallback, useEffect } from 'react';
|
|
8
8
|
import invariant from 'invariant';
|
|
9
|
-
import { RuntimeReactContext } from "
|
|
9
|
+
import { RuntimeReactContext } from "../../runtime-context";
|
|
10
10
|
import { LoaderStatus } from "./loaderManager";
|
|
11
11
|
|
|
12
12
|
const useLoader = (loaderFn, options = {
|
|
File without changes
|
|
@@ -25,11 +25,10 @@ const ssr = () => ({
|
|
|
25
25
|
}) => {
|
|
26
26
|
var _window, _window$_SSR_DATA;
|
|
27
27
|
|
|
28
|
-
|
|
28
|
+
// if render level not exist, use client render
|
|
29
|
+
const renderLevel = ((_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.renderLevel) || RenderLevel.CLIENT_RENDER; // client render and server prefetch use same logic
|
|
29
30
|
|
|
30
|
-
if (renderLevel === RenderLevel.CLIENT_RENDER) {
|
|
31
|
-
// prefetch block render while csr
|
|
32
|
-
// await (App as any)?.prefetch?.(context);
|
|
31
|
+
if (renderLevel === RenderLevel.CLIENT_RENDER || renderLevel === RenderLevel.SERVER_PREFETCH) {
|
|
33
32
|
ModernRender( /*#__PURE__*/_jsx(App, {
|
|
34
33
|
context: context
|
|
35
34
|
}));
|
|
@@ -63,7 +62,8 @@ const ssr = () => ({
|
|
|
63
62
|
});
|
|
64
63
|
} else {
|
|
65
64
|
// unknown renderlevel or renderlevel is server prefetch.
|
|
66
|
-
|
|
65
|
+
console.warn(`unknow render level: ${renderLevel}, execute render()`);
|
|
66
|
+
ModernRender( /*#__PURE__*/_jsx(App, {
|
|
67
67
|
context: context
|
|
68
68
|
}));
|
|
69
69
|
}
|
|
@@ -28,7 +28,9 @@ const plugin = () => ({
|
|
|
28
28
|
}
|
|
29
29
|
|
|
30
30
|
if (!isBrowser()) {
|
|
31
|
-
|
|
31
|
+
var _context$ssrContext;
|
|
32
|
+
|
|
33
|
+
const html = await require("./serverRender").render(context, (context === null || context === void 0 ? void 0 : (_context$ssrContext = context.ssrContext) === null || _context$ssrContext === void 0 ? void 0 : _context$ssrContext.distDir) || path.join(process.cwd(), 'dist'), App);
|
|
32
34
|
return html;
|
|
33
35
|
}
|
|
34
36
|
|
|
@@ -51,6 +53,7 @@ const plugin = () => ({
|
|
|
51
53
|
context,
|
|
52
54
|
pickedContext
|
|
53
55
|
}, next) => {
|
|
56
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-asserted-optional-chain
|
|
54
57
|
const {
|
|
55
58
|
request,
|
|
56
59
|
response
|
|
@@ -22,19 +22,15 @@ var _default = () => ({
|
|
|
22
22
|
post: ['@modern-js/plugin-router', '@modern-js/plugin-ssr', '@modern-js/plugin-state', '@modern-js/plugin-design-token'],
|
|
23
23
|
usePlugins: [(0, _cli.default)(), (0, _cli3.default)(), (0, _cli2.default)()],
|
|
24
24
|
setup: api => {
|
|
25
|
-
let runtimeExportsUtils = {};
|
|
26
25
|
return {
|
|
27
26
|
config() {
|
|
28
27
|
const dir = api.useAppContext().internalDirectory || '';
|
|
29
|
-
runtimeExportsUtils = (0, _utils.createRuntimeExportsUtils)(dir, 'index');
|
|
30
28
|
process.env.IS_REACT18 = (0, _utils.isReact18)(_path.default.join(dir, '../../')).toString();
|
|
31
29
|
return {
|
|
32
30
|
runtime: {},
|
|
33
31
|
runtimeByEntries: {},
|
|
34
32
|
source: {
|
|
35
33
|
alias: {
|
|
36
|
-
'@modern-js/runtime$': runtimeExportsUtils.getPath(),
|
|
37
|
-
|
|
38
34
|
/**
|
|
39
35
|
* twin.macro inserts styled-components into the code during the compilation process
|
|
40
36
|
* But it will not be installed under the user project.
|
|
@@ -51,12 +47,6 @@ var _default = () => ({
|
|
|
51
47
|
return _utils.PLUGIN_SCHEMAS['@modern-js/runtime'];
|
|
52
48
|
},
|
|
53
49
|
|
|
54
|
-
addRuntimeExports() {
|
|
55
|
-
const runtimePackage = _path.default.resolve(__dirname, '../../../../');
|
|
56
|
-
|
|
57
|
-
runtimeExportsUtils.addExport(`export * from '${runtimePackage}'`);
|
|
58
|
-
},
|
|
59
|
-
|
|
60
50
|
async beforeRestart() {
|
|
61
51
|
(0, _utils.cleanRequireCache)([require.resolve("../state/cli"), require.resolve("../router/cli"), require.resolve("../ssr/cli")]);
|
|
62
52
|
}
|
|
@@ -11,9 +11,9 @@ var _reactDom = _interopRequireDefault(require("react-dom"));
|
|
|
11
11
|
|
|
12
12
|
var _hoistNonReactStatics = _interopRequireDefault(require("hoist-non-react-statics"));
|
|
13
13
|
|
|
14
|
-
var
|
|
14
|
+
var _runtimeContext = require("../runtime-context");
|
|
15
15
|
|
|
16
|
-
var
|
|
16
|
+
var _plugin = require("./plugin");
|
|
17
17
|
|
|
18
18
|
var _loaderManager = require("./loader/loaderManager");
|
|
19
19
|
|
|
@@ -135,7 +135,7 @@ id,
|
|
|
135
135
|
/**
|
|
136
136
|
* root.render need use root to run function
|
|
137
137
|
*/
|
|
138
|
-
root,
|
|
138
|
+
root, ReactDOM = _reactDom.default) => {
|
|
139
139
|
let App = BootApp;
|
|
140
140
|
let runner = runnerMap.get(App); // ensure Component used is created by `createApp`
|
|
141
141
|
|
|
@@ -203,17 +203,17 @@ root, render = _reactDom.default.render, hydrate = _reactDom.default.hydrate) =>
|
|
|
203
203
|
|
|
204
204
|
const ModernRender = App => {
|
|
205
205
|
if (IS_REACT18) {
|
|
206
|
-
root.render(App);
|
|
206
|
+
(root || ReactDOM.createRoot(rootElement)).render(App);
|
|
207
207
|
} else {
|
|
208
|
-
render(App, rootElement);
|
|
208
|
+
ReactDOM.render(App, rootElement);
|
|
209
209
|
}
|
|
210
210
|
};
|
|
211
211
|
|
|
212
212
|
const ModernHydrate = (App, callback) => {
|
|
213
213
|
if (IS_REACT18) {
|
|
214
|
-
|
|
214
|
+
ReactDOM.hydrateRoot(rootElement, App);
|
|
215
215
|
} else {
|
|
216
|
-
hydrate(App, rootElement, callback);
|
|
216
|
+
ReactDOM.hydrate(App, rootElement, callback);
|
|
217
217
|
}
|
|
218
218
|
};
|
|
219
219
|
|
|
@@ -9,7 +9,7 @@ var _react = require("react");
|
|
|
9
9
|
|
|
10
10
|
var _invariant = _interopRequireDefault(require("invariant"));
|
|
11
11
|
|
|
12
|
-
var _runtimeContext = require("
|
|
12
|
+
var _runtimeContext = require("../../runtime-context");
|
|
13
13
|
|
|
14
14
|
var _loaderManager = require("./loaderManager");
|
|
15
15
|
|
|
File without changes
|
|
@@ -55,11 +55,10 @@ const ssr = () => ({
|
|
|
55
55
|
}) => {
|
|
56
56
|
var _window, _window$_SSR_DATA;
|
|
57
57
|
|
|
58
|
-
|
|
58
|
+
// if render level not exist, use client render
|
|
59
|
+
const renderLevel = ((_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.renderLevel) || _type.RenderLevel.CLIENT_RENDER; // client render and server prefetch use same logic
|
|
59
60
|
|
|
60
|
-
if (renderLevel === _type.RenderLevel.CLIENT_RENDER) {
|
|
61
|
-
// prefetch block render while csr
|
|
62
|
-
// await (App as any)?.prefetch?.(context);
|
|
61
|
+
if (renderLevel === _type.RenderLevel.CLIENT_RENDER || renderLevel === _type.RenderLevel.SERVER_PREFETCH) {
|
|
63
62
|
ModernRender( /*#__PURE__*/(0, _jsxRuntime.jsx)(App, {
|
|
64
63
|
context: context
|
|
65
64
|
}));
|
|
@@ -93,7 +92,8 @@ const ssr = () => ({
|
|
|
93
92
|
});
|
|
94
93
|
} else {
|
|
95
94
|
// unknown renderlevel or renderlevel is server prefetch.
|
|
96
|
-
|
|
95
|
+
console.warn(`unknow render level: ${renderLevel}, execute render()`);
|
|
96
|
+
ModernRender( /*#__PURE__*/(0, _jsxRuntime.jsx)(App, {
|
|
97
97
|
context: context
|
|
98
98
|
}));
|
|
99
99
|
}
|
|
@@ -54,7 +54,9 @@ const plugin = () => ({
|
|
|
54
54
|
}
|
|
55
55
|
|
|
56
56
|
if (!(0, _common.isBrowser)()) {
|
|
57
|
-
|
|
57
|
+
var _context$ssrContext;
|
|
58
|
+
|
|
59
|
+
const html = await require("./serverRender").render(context, (context === null || context === void 0 ? void 0 : (_context$ssrContext = context.ssrContext) === null || _context$ssrContext === void 0 ? void 0 : _context$ssrContext.distDir) || _path.default.join(process.cwd(), 'dist'), App);
|
|
58
60
|
return html;
|
|
59
61
|
}
|
|
60
62
|
|
|
@@ -77,6 +79,7 @@ const plugin = () => ({
|
|
|
77
79
|
context,
|
|
78
80
|
pickedContext
|
|
79
81
|
}, next) => {
|
|
82
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-asserted-optional-chain
|
|
80
83
|
const {
|
|
81
84
|
request,
|
|
82
85
|
response
|
|
@@ -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
3
|
import path from 'path';
|
|
4
|
-
import { PLUGIN_SCHEMAS,
|
|
4
|
+
import { PLUGIN_SCHEMAS, cleanRequireCache, isReact18 } from '@modern-js/utils';
|
|
5
5
|
import PluginState from "../state/cli";
|
|
6
6
|
import PluginSSR from "../ssr/cli";
|
|
7
7
|
import PluginRouter from "../router/cli";
|
|
@@ -11,19 +11,15 @@ export default (function () {
|
|
|
11
11
|
post: ['@modern-js/plugin-router', '@modern-js/plugin-ssr', '@modern-js/plugin-state', '@modern-js/plugin-design-token'],
|
|
12
12
|
usePlugins: [PluginState(), PluginRouter(), PluginSSR()],
|
|
13
13
|
setup: function setup(api) {
|
|
14
|
-
var runtimeExportsUtils = {};
|
|
15
14
|
return {
|
|
16
15
|
config: function config() {
|
|
17
16
|
var dir = api.useAppContext().internalDirectory || '';
|
|
18
|
-
runtimeExportsUtils = createRuntimeExportsUtils(dir, 'index');
|
|
19
17
|
process.env.IS_REACT18 = isReact18(path.join(dir, '../../')).toString();
|
|
20
18
|
return {
|
|
21
19
|
runtime: {},
|
|
22
20
|
runtimeByEntries: {},
|
|
23
21
|
source: {
|
|
24
22
|
alias: {
|
|
25
|
-
'@modern-js/runtime$': runtimeExportsUtils.getPath(),
|
|
26
|
-
|
|
27
23
|
/**
|
|
28
24
|
* twin.macro inserts styled-components into the code during the compilation process
|
|
29
25
|
* But it will not be installed under the user project.
|
|
@@ -38,10 +34,6 @@ export default (function () {
|
|
|
38
34
|
validateSchema: function validateSchema() {
|
|
39
35
|
return PLUGIN_SCHEMAS['@modern-js/runtime'];
|
|
40
36
|
},
|
|
41
|
-
addRuntimeExports: function addRuntimeExports() {
|
|
42
|
-
var runtimePackage = path.resolve(__dirname, '../../../../');
|
|
43
|
-
runtimeExportsUtils.addExport("export * from '".concat(runtimePackage, "'"));
|
|
44
|
-
},
|
|
45
37
|
beforeRestart: function beforeRestart() {
|
|
46
38
|
return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
47
39
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
@@ -7,8 +7,8 @@ var _excluded = ["context"];
|
|
|
7
7
|
import React, { useContext, useMemo } from 'react';
|
|
8
8
|
import defaultReactDOM from 'react-dom';
|
|
9
9
|
import hoistNonReactStatics from 'hoist-non-react-statics';
|
|
10
|
+
import { RuntimeReactContext } from "../runtime-context";
|
|
10
11
|
import { runtime } from "./plugin";
|
|
11
|
-
import { RuntimeReactContext } from "./runtime-context";
|
|
12
12
|
import { createLoaderManager } from "./loader/loaderManager";
|
|
13
13
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
14
14
|
var IS_REACT18 = process.env.IS_REACT18 === 'true';
|
|
@@ -105,8 +105,7 @@ export var bootstrap = /*#__PURE__*/function () {
|
|
|
105
105
|
* root.render need use root to run function
|
|
106
106
|
*/
|
|
107
107
|
root) {
|
|
108
|
-
var
|
|
109
|
-
hydrate,
|
|
108
|
+
var ReactDOM,
|
|
110
109
|
App,
|
|
111
110
|
runner,
|
|
112
111
|
context,
|
|
@@ -128,8 +127,7 @@ export var bootstrap = /*#__PURE__*/function () {
|
|
|
128
127
|
while (1) {
|
|
129
128
|
switch (_context2.prev = _context2.next) {
|
|
130
129
|
case 0:
|
|
131
|
-
|
|
132
|
-
hydrate = _args.length > 4 && _args[4] !== undefined ? _args[4] : defaultReactDOM.hydrate;
|
|
130
|
+
ReactDOM = _args.length > 3 && _args[3] !== undefined ? _args[3] : defaultReactDOM;
|
|
133
131
|
App = BootApp;
|
|
134
132
|
runner = runnerMap.get(App); // ensure Component used is created by `createApp`
|
|
135
133
|
|
|
@@ -157,7 +155,7 @@ export var bootstrap = /*#__PURE__*/function () {
|
|
|
157
155
|
|
|
158
156
|
|
|
159
157
|
if (id) {
|
|
160
|
-
_context2.next =
|
|
158
|
+
_context2.next = 8;
|
|
161
159
|
break;
|
|
162
160
|
}
|
|
163
161
|
|
|
@@ -165,16 +163,16 @@ export var bootstrap = /*#__PURE__*/function () {
|
|
|
165
163
|
context: context
|
|
166
164
|
}));
|
|
167
165
|
|
|
168
|
-
case
|
|
166
|
+
case 8:
|
|
169
167
|
isBrowser = typeof window !== 'undefined' && window.name !== 'nodejs';
|
|
170
168
|
|
|
171
169
|
if (!isBrowser) {
|
|
172
|
-
_context2.next =
|
|
170
|
+
_context2.next = 29;
|
|
173
171
|
break;
|
|
174
172
|
}
|
|
175
173
|
|
|
176
174
|
if (!isClientArgs(id)) {
|
|
177
|
-
_context2.next =
|
|
175
|
+
_context2.next = 26;
|
|
178
176
|
break;
|
|
179
177
|
}
|
|
180
178
|
|
|
@@ -198,10 +196,10 @@ export var bootstrap = /*#__PURE__*/function () {
|
|
|
198
196
|
ssrContext: ssrData === null || ssrData === void 0 ? void 0 : ssrData.context
|
|
199
197
|
} : {}));
|
|
200
198
|
context.initialData = ssrData === null || ssrData === void 0 ? void 0 : (_ssrData$data2 = ssrData.data) === null || _ssrData$data2 === void 0 ? void 0 : _ssrData$data2.initialData;
|
|
201
|
-
_context2.next =
|
|
199
|
+
_context2.next = 18;
|
|
202
200
|
return runInit(context);
|
|
203
201
|
|
|
204
|
-
case
|
|
202
|
+
case 18:
|
|
205
203
|
initialData = _context2.sent;
|
|
206
204
|
|
|
207
205
|
if (initialData) {
|
|
@@ -212,17 +210,17 @@ export var bootstrap = /*#__PURE__*/function () {
|
|
|
212
210
|
|
|
213
211
|
ModernRender = function ModernRender(App) {
|
|
214
212
|
if (IS_REACT18) {
|
|
215
|
-
root.render(App);
|
|
213
|
+
(root || ReactDOM.createRoot(_rootElement)).render(App);
|
|
216
214
|
} else {
|
|
217
|
-
render(App, _rootElement);
|
|
215
|
+
ReactDOM.render(App, _rootElement);
|
|
218
216
|
}
|
|
219
217
|
};
|
|
220
218
|
|
|
221
219
|
ModernHydrate = function ModernHydrate(App, callback) {
|
|
222
220
|
if (IS_REACT18) {
|
|
223
|
-
|
|
221
|
+
ReactDOM.hydrateRoot(_rootElement, App);
|
|
224
222
|
} else {
|
|
225
|
-
hydrate(App, _rootElement, callback);
|
|
223
|
+
ReactDOM.hydrate(App, _rootElement, callback);
|
|
226
224
|
}
|
|
227
225
|
};
|
|
228
226
|
|
|
@@ -240,14 +238,14 @@ export var bootstrap = /*#__PURE__*/function () {
|
|
|
240
238
|
}
|
|
241
239
|
}));
|
|
242
240
|
|
|
243
|
-
case
|
|
241
|
+
case 26:
|
|
244
242
|
throw Error('`bootstrap` needs id in browser environment, it needs to be string or element');
|
|
245
243
|
|
|
246
|
-
case
|
|
247
|
-
_context2.next =
|
|
244
|
+
case 27:
|
|
245
|
+
_context2.next = 35;
|
|
248
246
|
break;
|
|
249
247
|
|
|
250
|
-
case
|
|
248
|
+
case 29:
|
|
251
249
|
Object.assign(context, {
|
|
252
250
|
ssrContext: id,
|
|
253
251
|
isBrowser: false,
|
|
@@ -257,10 +255,10 @@ export var bootstrap = /*#__PURE__*/function () {
|
|
|
257
255
|
skipStatic: process.env.NODE_ENV === 'production' && !id.staticGenerate
|
|
258
256
|
})
|
|
259
257
|
});
|
|
260
|
-
_context2.next =
|
|
258
|
+
_context2.next = 32;
|
|
261
259
|
return runInit(context);
|
|
262
260
|
|
|
263
|
-
case
|
|
261
|
+
case 32:
|
|
264
262
|
_initialData = _context2.sent;
|
|
265
263
|
context.initialData = _initialData;
|
|
266
264
|
return _context2.abrupt("return", runner.server({
|
|
@@ -268,7 +266,7 @@ export var bootstrap = /*#__PURE__*/function () {
|
|
|
268
266
|
context: context
|
|
269
267
|
}));
|
|
270
268
|
|
|
271
|
-
case
|
|
269
|
+
case 35:
|
|
272
270
|
case "end":
|
|
273
271
|
return _context2.stop();
|
|
274
272
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export { createPlugin, createRuntime, runtime, registerInit, registerPrefetch } from "./plugin";
|
|
2
|
-
export { defineConfig, getConfig } from "./app-config";
|
|
3
|
-
|
|
2
|
+
export { defineConfig, getConfig } from "./app-config"; // compatible
|
|
3
|
+
|
|
4
4
|
export * from "./compatible";
|
|
5
|
-
export { RuntimeReactContext } from "
|
|
5
|
+
export { RuntimeReactContext } from "../runtime-context";
|
|
6
6
|
export * from "./loader";
|
|
7
7
|
export * from '@modern-js/plugin';
|
|
@@ -2,7 +2,7 @@ import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
|
2
2
|
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
3
3
|
import { useContext, useRef, useMemo, useState, useCallback, useEffect } from 'react';
|
|
4
4
|
import invariant from 'invariant';
|
|
5
|
-
import { RuntimeReactContext } from "
|
|
5
|
+
import { RuntimeReactContext } from "../../runtime-context";
|
|
6
6
|
import { LoaderStatus } from "./loaderManager";
|
|
7
7
|
|
|
8
8
|
var useLoader = function useLoader(loaderFn) {
|
|
File without changes
|
|
@@ -25,11 +25,10 @@ var ssr = function ssr() {
|
|
|
25
25
|
switch (_context.prev = _context.next) {
|
|
26
26
|
case 0:
|
|
27
27
|
App = _ref.App, context = _ref.context, ModernRender = _ref.ModernRender, ModernHydrate = _ref.ModernHydrate;
|
|
28
|
-
|
|
28
|
+
// if render level not exist, use client render
|
|
29
|
+
renderLevel = ((_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.renderLevel) || RenderLevel.CLIENT_RENDER; // client render and server prefetch use same logic
|
|
29
30
|
|
|
30
|
-
if (renderLevel === RenderLevel.CLIENT_RENDER) {
|
|
31
|
-
// prefetch block render while csr
|
|
32
|
-
// await (App as any)?.prefetch?.(context);
|
|
31
|
+
if (renderLevel === RenderLevel.CLIENT_RENDER || renderLevel === RenderLevel.SERVER_PREFETCH) {
|
|
33
32
|
ModernRender( /*#__PURE__*/_jsx(App, {
|
|
34
33
|
context: context
|
|
35
34
|
}));
|
|
@@ -65,7 +64,8 @@ var ssr = function ssr() {
|
|
|
65
64
|
});
|
|
66
65
|
} else {
|
|
67
66
|
// unknown renderlevel or renderlevel is server prefetch.
|
|
68
|
-
|
|
67
|
+
console.warn("unknow render level: ".concat(renderLevel, ", execute render()"));
|
|
68
|
+
ModernRender( /*#__PURE__*/_jsx(App, {
|
|
69
69
|
context: context
|
|
70
70
|
}));
|
|
71
71
|
}
|
|
@@ -19,7 +19,8 @@ var plugin = function plugin() {
|
|
|
19
19
|
return {
|
|
20
20
|
server: function () {
|
|
21
21
|
var _server = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(_ref) {
|
|
22
|
-
var App, context, html;
|
|
22
|
+
var App, context, _context$ssrContext, html;
|
|
23
|
+
|
|
23
24
|
return _regeneratorRuntime().wrap(function _callee$(_context2) {
|
|
24
25
|
while (1) {
|
|
25
26
|
switch (_context2.prev = _context2.next) {
|
|
@@ -39,7 +40,7 @@ var plugin = function plugin() {
|
|
|
39
40
|
}
|
|
40
41
|
|
|
41
42
|
_context2.next = 5;
|
|
42
|
-
return require("./serverRender").render(context, (context === null || context === void 0 ? void 0 : context.ssrContext.distDir) || path.join(process.cwd(), 'dist'), App);
|
|
43
|
+
return require("./serverRender").render(context, (context === null || context === void 0 ? void 0 : (_context$ssrContext = context.ssrContext) === null || _context$ssrContext === void 0 ? void 0 : _context$ssrContext.distDir) || path.join(process.cwd(), 'dist'), App);
|
|
43
44
|
|
|
44
45
|
case 5:
|
|
45
46
|
html = _context2.sent;
|
|
@@ -64,19 +65,21 @@ var plugin = function plugin() {
|
|
|
64
65
|
}(),
|
|
65
66
|
init: function init(_ref2, next) {
|
|
66
67
|
var context = _ref2.context;
|
|
67
|
-
var
|
|
68
|
+
var _ref3 = context.ssrContext,
|
|
69
|
+
request = _ref3.request;
|
|
68
70
|
context.ssrContext.request = formatServer(request);
|
|
69
71
|
return next({
|
|
70
72
|
context: context
|
|
71
73
|
});
|
|
72
74
|
},
|
|
73
|
-
pickContext: function pickContext(
|
|
74
|
-
var context =
|
|
75
|
-
pickedContext =
|
|
75
|
+
pickContext: function pickContext(_ref4, next) {
|
|
76
|
+
var context = _ref4.context,
|
|
77
|
+
pickedContext = _ref4.pickedContext;
|
|
76
78
|
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
79
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-asserted-optional-chain
|
|
80
|
+
var _ref5 = context === null || context === void 0 ? void 0 : context.ssrContext,
|
|
81
|
+
request = _ref5.request,
|
|
82
|
+
response = _ref5.response;
|
|
80
83
|
|
|
81
84
|
var initialData = context.initialData;
|
|
82
85
|
return next({
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import _regeneratorRuntime from "@babel/runtime/helpers/esm/regeneratorRuntime";
|
|
2
2
|
import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
|
|
3
3
|
import { run } from '@modern-js/utils/ssr';
|
|
4
|
-
import { RuntimeContext } from "../../core";
|
|
5
4
|
import { PreRender } from "../react/prerender";
|
|
6
5
|
import SSREntry from "./entry";
|
|
7
6
|
import { time } from "./measure";
|
package/dist/types/common.d.ts
CHANGED
|
@@ -1 +1,8 @@
|
|
|
1
|
-
|
|
1
|
+
import type { StateConfig } from './state';
|
|
2
|
+
import type { RouterConfig } from './router';
|
|
3
|
+
export declare const isBrowser: () => boolean;
|
|
4
|
+
export interface AppConfig {
|
|
5
|
+
router?: RouterConfig | boolean;
|
|
6
|
+
state?: StateConfig | boolean;
|
|
7
|
+
[key: string]: any;
|
|
8
|
+
}
|
|
@@ -1,6 +1,4 @@
|
|
|
1
1
|
import type React from 'react';
|
|
2
|
-
|
|
3
|
-
[key: string]: any;
|
|
4
|
-
}
|
|
2
|
+
import { AppConfig } from '../common';
|
|
5
3
|
export declare const getConfig: (Component: React.ComponentType<any>) => AppConfig | undefined;
|
|
6
4
|
export declare const defineConfig: (Component: React.ComponentType<any>, config: AppConfig) => React.ComponentType<any>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
+
import { TRuntimeContext } from '../runtime-context';
|
|
2
3
|
import { Plugin } from './plugin';
|
|
3
|
-
import { TRuntimeContext } from './runtime-context';
|
|
4
4
|
export declare type CreateAppOptions = {
|
|
5
5
|
plugins: Plugin[];
|
|
6
6
|
};
|
|
@@ -11,7 +11,12 @@ interface HydrateFunc {
|
|
|
11
11
|
(container: Element | Document, initialChildren: React.ReactNode): void;
|
|
12
12
|
(initialChildren: React.ReactNode, container: Element | Document, callback?: () => void): void;
|
|
13
13
|
}
|
|
14
|
-
declare type BootStrap<T = unknown> = (App: React.ComponentType, id
|
|
14
|
+
declare type BootStrap<T = unknown> = (App: React.ComponentType, id: string | Record<string, any> | HTMLElement, root: any, ReactDOM: {
|
|
15
|
+
render: (children: React.ReactNode, rootElement?: HTMLElement) => void;
|
|
16
|
+
hydrate: HydrateFunc;
|
|
17
|
+
createRoot?: (rootElement: HTMLElement) => any;
|
|
18
|
+
hydrateRoot: HydrateFunc;
|
|
19
|
+
}) => Promise<T>;
|
|
15
20
|
export declare const bootstrap: BootStrap;
|
|
16
21
|
export declare const useRuntimeContext: () => TRuntimeContext;
|
|
17
22
|
export {};
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
export { createPlugin, createRuntime, runtime, registerInit, registerPrefetch } from './plugin';
|
|
2
2
|
export type { Plugin } from './plugin';
|
|
3
3
|
export { defineConfig, getConfig } from './app-config';
|
|
4
|
-
export type { AppConfig } from './app-config';
|
|
5
4
|
export * from './compatible';
|
|
6
|
-
export type { TRuntimeContext, RuntimeContext } from '
|
|
7
|
-
export { RuntimeReactContext } from '
|
|
5
|
+
export type { TRuntimeContext, RuntimeContext } from '../runtime-context';
|
|
6
|
+
export { RuntimeReactContext } from '../runtime-context';
|
|
8
7
|
export * from './loader';
|
|
9
8
|
export * from '@modern-js/plugin';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type React from 'react';
|
|
2
2
|
import { Setup, ToThreads, CommonAPI, PluginOptions } from '@modern-js/plugin';
|
|
3
|
-
import type { RuntimeContext, TRuntimeContext } from '
|
|
3
|
+
import type { RuntimeContext, TRuntimeContext } from '../runtime-context';
|
|
4
4
|
export interface AppProps {}
|
|
5
5
|
declare const runtimeHooks: {
|
|
6
6
|
hoc: import("@modern-js/plugin").Pipeline<{
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,11 +1,7 @@
|
|
|
1
1
|
import type { StateConfig } from './state';
|
|
2
2
|
import type { RouterConfig } from './router';
|
|
3
|
-
export type { Plugin
|
|
3
|
+
export type { Plugin } from './core';
|
|
4
|
+
export type { AppConfig } from './common';
|
|
5
|
+
export type { BaseRuntimeContext, RuntimeContext, BaseTRuntimeContext, TRuntimeContext } from './runtime-context';
|
|
4
6
|
export { createApp, createPlugin, useLoader, bootstrap, RuntimeReactContext, registerPrefetch, defineConfig, registerInit, useRuntimeContext } from './core';
|
|
5
|
-
export { StateConfig, RouterConfig };
|
|
6
|
-
declare module './core' {
|
|
7
|
-
interface AppConfig {
|
|
8
|
-
router?: RouterConfig | boolean;
|
|
9
|
-
state?: StateConfig | boolean;
|
|
10
|
-
}
|
|
11
|
-
}
|
|
7
|
+
export { StateConfig, RouterConfig };
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { Store } from '@modern-js-reduck/store';
|
|
3
|
+
import { createLoaderManager } from './core/loader/loaderManager';
|
|
4
|
+
import { runtime } from './core/plugin';
|
|
5
|
+
import { SSRServerContext } from './ssr/serverRender/type';
|
|
6
|
+
export interface BaseRuntimeContext {
|
|
7
|
+
loaderManager: ReturnType<typeof createLoaderManager>;
|
|
8
|
+
runner: ReturnType<typeof runtime.init>;
|
|
9
|
+
ssrContext?: SSRServerContext;
|
|
10
|
+
store?: Store;
|
|
11
|
+
}
|
|
12
|
+
export interface RuntimeContext extends BaseRuntimeContext {
|
|
13
|
+
[key: string]: any;
|
|
14
|
+
}
|
|
15
|
+
export declare const RuntimeReactContext: import("react").Context<RuntimeContext>;
|
|
16
|
+
export interface BaseTRuntimeContext {
|
|
17
|
+
initialData?: Record<string, unknown>;
|
|
18
|
+
request?: SSRServerContext['request'];
|
|
19
|
+
response?: SSRServerContext['response'];
|
|
20
|
+
store?: Store;
|
|
21
|
+
}
|
|
22
|
+
export interface TRuntimeContext extends BaseTRuntimeContext {
|
|
23
|
+
[key: string]: any;
|
|
24
|
+
}
|
|
@@ -1,13 +1,6 @@
|
|
|
1
1
|
import type { Plugin } from '../core';
|
|
2
2
|
import { RenderLevel, SSRServerContext } from './serverRender/type';
|
|
3
3
|
declare module '../core' {
|
|
4
|
-
interface RuntimeContext {
|
|
5
|
-
ssrContext: SSRServerContext;
|
|
6
|
-
}
|
|
7
|
-
interface TRuntimeContext {
|
|
8
|
-
request: SSRServerContext['request'];
|
|
9
|
-
response: SSRServerContext['response'];
|
|
10
|
-
}
|
|
11
4
|
interface SSRContainer {
|
|
12
5
|
renderLevel: RenderLevel;
|
|
13
6
|
context?: SSRServerContext;
|
|
@@ -1,8 +1,3 @@
|
|
|
1
1
|
import { RuntimeContext } from '../../core';
|
|
2
2
|
import { ModernSSRReactComponent } from './type';
|
|
3
|
-
declare module '@modern-js/runtime' {
|
|
4
|
-
interface RuntimeContext {
|
|
5
|
-
ssrContext?: any;
|
|
6
|
-
}
|
|
7
|
-
}
|
|
8
3
|
export declare const render: (ctx: RuntimeContext, _: string | undefined, App: ModernSSRReactComponent) => Promise<string>;
|
|
@@ -1,16 +1,5 @@
|
|
|
1
|
-
import { createStore
|
|
1
|
+
import { createStore } from '@modern-js-reduck/store';
|
|
2
2
|
import type { Plugin } from '../../core';
|
|
3
|
-
declare module '../../core' {
|
|
4
|
-
interface RuntimeContext {
|
|
5
|
-
store: Store;
|
|
6
|
-
}
|
|
7
|
-
interface TRuntimeContext {
|
|
8
|
-
store: Store;
|
|
9
|
-
}
|
|
10
|
-
interface SSRData {
|
|
11
|
-
storeState: any;
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
3
|
export declare type StateConfig = Parameters<typeof createStore>[0];
|
|
15
4
|
declare const state: (config: StateConfig) => Plugin;
|
|
16
5
|
export default state;
|
package/package.json
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
"modern",
|
|
12
12
|
"modern.js"
|
|
13
13
|
],
|
|
14
|
-
"version": "1.
|
|
14
|
+
"version": "1.18.0",
|
|
15
15
|
"jsnext:source": "./src/index.ts",
|
|
16
16
|
"types": "./type.d.ts",
|
|
17
17
|
"main": "./dist/js/node/index.js",
|
|
@@ -140,9 +140,9 @@
|
|
|
140
140
|
"@loadable/babel-plugin": "^5.13.2",
|
|
141
141
|
"@loadable/server": "^5.15.1",
|
|
142
142
|
"@loadable/component": "^5.15.0",
|
|
143
|
-
"@modern-js/plugin": "1.
|
|
144
|
-
"@modern-js/webpack": "1.
|
|
145
|
-
"@modern-js/utils": "1.
|
|
143
|
+
"@modern-js/plugin": "1.18.0",
|
|
144
|
+
"@modern-js/webpack": "1.18.0",
|
|
145
|
+
"@modern-js/utils": "1.18.0",
|
|
146
146
|
"@modern-js-reduck/plugin-auto-actions": "^1.0.2",
|
|
147
147
|
"@modern-js-reduck/plugin-devtools": "^1.0.3",
|
|
148
148
|
"@modern-js-reduck/plugin-effects": "^1.0.2",
|
|
@@ -166,16 +166,16 @@
|
|
|
166
166
|
"ts-jest": "^27.0.4",
|
|
167
167
|
"typescript": "^4",
|
|
168
168
|
"jest": "^27",
|
|
169
|
-
"@modern-js/core": "1.
|
|
170
|
-
"@modern-js/types": "1.
|
|
171
|
-
"@modern-js/utils": "1.
|
|
169
|
+
"@modern-js/core": "1.18.0",
|
|
170
|
+
"@modern-js/types": "1.18.0",
|
|
171
|
+
"@modern-js/utils": "1.18.0",
|
|
172
172
|
"@types/jest": "^27",
|
|
173
173
|
"@types/node": "^14",
|
|
174
174
|
"@types/react-side-effect": "^1.1.1",
|
|
175
175
|
"@types/loadable__webpack-plugin": "^5.7.3",
|
|
176
176
|
"@types/serialize-javascript": "^5.0.1",
|
|
177
|
-
"@scripts/build": "1.
|
|
178
|
-
"@scripts/jest-config": "1.
|
|
177
|
+
"@scripts/build": "1.18.0",
|
|
178
|
+
"@scripts/jest-config": "1.18.0",
|
|
179
179
|
"@testing-library/react": "^12.0.0",
|
|
180
180
|
"@testing-library/react-hooks": "^7.0.1",
|
|
181
181
|
"@types/hoist-non-react-statics": "^3.3.1",
|
|
@@ -211,6 +211,7 @@
|
|
|
211
211
|
}
|
|
212
212
|
},
|
|
213
213
|
"scripts": {
|
|
214
|
+
"dev": "modern build --watch",
|
|
214
215
|
"new": "modern new",
|
|
215
216
|
"build": "wireit",
|
|
216
217
|
"test": "wireit"
|
|
@@ -1,13 +0,0 @@
|
|
|
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
|
-
}
|