@modern-js/runtime 1.16.0 → 1.16.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +8 -0
- package/dist/js/modern/core/compatible.js +1 -1
- package/dist/js/modern/core/index.js +1 -1
- 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.node.js +4 -1
- package/dist/js/modern/ssr/serverRender/index.js +0 -1
- package/dist/js/node/core/compatible.js +2 -2
- 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.node.js +4 -1
- package/dist/js/node/ssr/serverRender/index.js +0 -2
- package/dist/js/treeshaking/core/compatible.js +1 -1
- package/dist/js/treeshaking/core/index.js +1 -1
- 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.node.js +12 -9
- package/dist/js/treeshaking/ssr/serverRender/index.js +0 -1
- package/dist/types/core/compatible.d.ts +1 -1
- package/dist/types/core/index.d.ts +2 -2
- package/dist/types/core/plugin.d.ts +1 -1
- package/dist/types/index.d.ts +2 -1
- 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 -7
- package/package.json +1 -1
- package/dist/types/core/runtime-context.d.ts +0 -13
package/CHANGELOG.md
CHANGED
|
@@ -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';
|
|
@@ -2,6 +2,6 @@ export { createPlugin, createRuntime, runtime, registerInit, registerPrefetch }
|
|
|
2
2
|
export { defineConfig, getConfig } from "./app-config";
|
|
3
3
|
// compatible
|
|
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
|
|
@@ -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
|
|
@@ -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
|
|
|
@@ -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
|
|
@@ -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
|
|
@@ -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';
|
|
@@ -2,6 +2,6 @@ export { createPlugin, createRuntime, runtime, registerInit, registerPrefetch }
|
|
|
2
2
|
export { defineConfig, getConfig } from "./app-config";
|
|
3
3
|
// compatible
|
|
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
|
|
@@ -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";
|
|
@@ -3,7 +3,7 @@ export type { Plugin } from './plugin';
|
|
|
3
3
|
export { defineConfig, getConfig } from './app-config';
|
|
4
4
|
export type { AppConfig } from './app-config';
|
|
5
5
|
export * from './compatible';
|
|
6
|
-
export type { TRuntimeContext, RuntimeContext } from '
|
|
7
|
-
export { RuntimeReactContext } from '
|
|
6
|
+
export type { TRuntimeContext, RuntimeContext } from '../runtime-context';
|
|
7
|
+
export { RuntimeReactContext } from '../runtime-context';
|
|
8
8
|
export * from './loader';
|
|
9
9
|
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,6 +1,7 @@
|
|
|
1
1
|
import type { StateConfig } from './state';
|
|
2
2
|
import type { RouterConfig } from './router';
|
|
3
|
-
export type { Plugin,
|
|
3
|
+
export type { Plugin, AppConfig } from './core';
|
|
4
|
+
export type { BaseRuntimeContext, RuntimeContext, BaseTRuntimeContext, TRuntimeContext } from './runtime-context';
|
|
4
5
|
export { createApp, createPlugin, useLoader, bootstrap, RuntimeReactContext, registerPrefetch, defineConfig, registerInit, useRuntimeContext } from './core';
|
|
5
6
|
export { StateConfig, RouterConfig };
|
|
6
7
|
declare module './core' {
|
|
@@ -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,12 +1,6 @@
|
|
|
1
|
-
import { createStore
|
|
1
|
+
import { createStore } from '@modern-js-reduck/store';
|
|
2
2
|
import type { Plugin } from '../../core';
|
|
3
3
|
declare module '../../core' {
|
|
4
|
-
interface RuntimeContext {
|
|
5
|
-
store: Store;
|
|
6
|
-
}
|
|
7
|
-
interface TRuntimeContext {
|
|
8
|
-
store: Store;
|
|
9
|
-
}
|
|
10
4
|
interface SSRData {
|
|
11
5
|
storeState: any;
|
|
12
6
|
}
|
package/package.json
CHANGED
|
@@ -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
|
-
}
|