@modern-js/runtime 2.58.2-alpha.0 → 2.58.3
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/dist/cjs/cli/code.js +1 -1
- package/dist/cjs/cli/index.js +11 -14
- package/dist/cjs/cli/ssr/babel-plugin-ssr-loader-id.js +1 -1
- package/dist/cjs/cli/ssr/index.js +14 -1
- package/dist/cjs/cli/template.js +1 -1
- package/dist/cjs/core/browser/hydrate.js +1 -1
- package/dist/cjs/core/browser/index.js +36 -17
- package/dist/cjs/core/compatible.js +4 -4
- package/dist/cjs/core/context/runtime.js +1 -1
- package/dist/cjs/core/loader/loaderManager.js +1 -1
- package/dist/cjs/core/loader/useLoader.js +1 -1
- package/dist/cjs/core/server/react/prerender/index.js +1 -1
- package/dist/cjs/core/server/requestHandler.js +14 -6
- package/dist/cjs/core/server/stream/afterTemplate.js +1 -1
- package/dist/cjs/core/server/stream/beforeTemplate.js +3 -3
- package/dist/cjs/core/server/stream/createReadableStream.js +2 -2
- package/dist/cjs/core/server/stream/createReadableStream.worker.js +2 -2
- package/dist/cjs/core/server/stream/shared.js +1 -1
- package/dist/cjs/core/server/stream/template.js +1 -1
- package/dist/cjs/core/server/string/index.js +29 -29
- package/dist/cjs/core/server/string/prefetch.js +5 -5
- package/dist/cjs/core/server/string/ssrData.js +1 -1
- package/dist/cjs/document/Body.js +1 -1
- package/dist/cjs/document/Head.js +1 -1
- package/dist/cjs/document/Root.js +1 -1
- package/dist/cjs/document/cli/index.js +2 -2
- package/dist/cjs/router/cli/code/getClientRoutes/getRoutes.js +1 -1
- package/dist/cjs/router/cli/code/getClientRoutes/getRoutesLegacy.js +1 -1
- package/dist/cjs/router/cli/code/index.js +6 -6
- package/dist/cjs/router/cli/code/templates.js +15 -8
- package/dist/cjs/router/cli/code/utils.js +1 -1
- package/dist/cjs/router/cli/handler.js +2 -2
- package/dist/cjs/router/runtime/DeferredDataScripts.node.js +2 -2
- package/dist/cjs/router/runtime/PrefetchLink.js +1 -1
- package/dist/cjs/router/runtime/plugin.js +4 -4
- package/dist/cjs/router/runtime/plugin.node.js +6 -6
- package/dist/cjs/router/runtime/utils.js +2 -2
- package/dist/cjs/state/plugins.js +1 -1
- package/dist/cjs/state/runtime/plugin.js +6 -6
- package/dist/esm/cli/code.js +3 -4
- package/dist/esm/cli/index.js +7 -10
- package/dist/esm/cli/ssr/babel-plugin-ssr-loader-id.js +1 -1
- package/dist/esm/cli/ssr/index.js +16 -1
- package/dist/esm/cli/template.js +1 -1
- package/dist/esm/core/browser/hydrate.js +1 -1
- package/dist/esm/core/browser/index.js +33 -14
- package/dist/esm/core/browser/withCallback.js +1 -1
- package/dist/esm/core/compatible.js +4 -4
- package/dist/esm/core/context/runtime.js +1 -1
- package/dist/esm/core/loader/loaderManager.js +3 -1
- package/dist/esm/core/loader/useLoader.js +1 -1
- package/dist/esm/core/plugin/base.js +1 -1
- package/dist/esm/core/plugin/index.js +1 -1
- package/dist/esm/core/server/react/prerender/index.js +2 -2
- package/dist/esm/core/server/requestHandler.js +13 -6
- package/dist/esm/core/server/stream/afterTemplate.js +1 -1
- package/dist/esm/core/server/stream/beforeTemplate.js +3 -3
- package/dist/esm/core/server/stream/createReadableStream.js +2 -2
- package/dist/esm/core/server/stream/createReadableStream.worker.js +2 -2
- package/dist/esm/core/server/stream/shared.js +1 -1
- package/dist/esm/core/server/stream/template.js +1 -1
- package/dist/esm/core/server/string/index.js +12 -15
- package/dist/esm/core/server/string/prefetch.js +2 -2
- package/dist/esm/core/server/string/ssrData.js +1 -1
- package/dist/esm/document/Body.js +1 -1
- package/dist/esm/document/Comment.js +1 -1
- package/dist/esm/document/Head.js +1 -1
- package/dist/esm/document/Root.js +1 -1
- package/dist/esm/document/Script.js +1 -1
- package/dist/esm/document/Style.js +1 -1
- package/dist/esm/document/cli/index.js +3 -3
- package/dist/esm/router/cli/code/getClientRoutes/getRoutes.js +2 -2
- package/dist/esm/router/cli/code/getClientRoutes/getRoutesLegacy.js +2 -2
- package/dist/esm/router/cli/code/getClientRoutes/utils.js +2 -2
- package/dist/esm/router/cli/code/index.js +4 -4
- package/dist/esm/router/cli/code/nestedRoutes.js +1 -1
- package/dist/esm/router/cli/code/templates.js +2 -2
- package/dist/esm/router/cli/code/utils.js +2 -2
- package/dist/esm/router/cli/entry.js +1 -1
- package/dist/esm/router/cli/handler.js +2 -2
- package/dist/esm/router/cli/index.js +1 -1
- package/dist/esm/router/runtime/DeferredDataScripts.node.js +2 -2
- package/dist/esm/router/runtime/PrefetchLink.js +1 -1
- package/dist/esm/router/runtime/plugin.js +4 -4
- package/dist/esm/router/runtime/plugin.node.js +6 -6
- package/dist/esm/router/runtime/utils.js +2 -2
- package/dist/esm/state/plugins.js +1 -1
- package/dist/esm/state/runtime/plugin.js +4 -4
- package/dist/esm-node/cli/code.js +3 -3
- package/dist/esm-node/cli/index.js +7 -10
- package/dist/esm-node/cli/ssr/babel-plugin-ssr-loader-id.js +1 -1
- package/dist/esm-node/cli/ssr/index.js +14 -1
- package/dist/esm-node/cli/template.js +1 -1
- package/dist/esm-node/core/browser/hydrate.js +1 -1
- package/dist/esm-node/core/browser/index.js +36 -17
- package/dist/esm-node/core/browser/withCallback.js +1 -1
- package/dist/esm-node/core/compatible.js +4 -4
- package/dist/esm-node/core/context/runtime.js +1 -1
- package/dist/esm-node/core/loader/loaderManager.js +1 -1
- package/dist/esm-node/core/loader/useLoader.js +1 -1
- package/dist/esm-node/core/plugin/base.js +1 -1
- package/dist/esm-node/core/plugin/index.js +1 -1
- package/dist/esm-node/core/server/react/prerender/index.js +2 -2
- package/dist/esm-node/core/server/requestHandler.js +13 -5
- package/dist/esm-node/core/server/stream/afterTemplate.js +1 -1
- package/dist/esm-node/core/server/stream/beforeTemplate.js +3 -3
- package/dist/esm-node/core/server/stream/createReadableStream.js +2 -2
- package/dist/esm-node/core/server/stream/createReadableStream.worker.js +2 -2
- package/dist/esm-node/core/server/stream/shared.js +1 -1
- package/dist/esm-node/core/server/stream/template.js +1 -1
- package/dist/esm-node/core/server/string/index.js +21 -21
- package/dist/esm-node/core/server/string/prefetch.js +2 -2
- package/dist/esm-node/core/server/string/ssrData.js +1 -1
- package/dist/esm-node/document/Body.js +1 -1
- package/dist/esm-node/document/Comment.js +1 -1
- package/dist/esm-node/document/Head.js +1 -1
- package/dist/esm-node/document/Root.js +1 -1
- package/dist/esm-node/document/Script.js +1 -1
- package/dist/esm-node/document/Style.js +1 -1
- package/dist/esm-node/document/cli/index.js +3 -3
- package/dist/esm-node/router/cli/code/getClientRoutes/getRoutes.js +2 -2
- package/dist/esm-node/router/cli/code/getClientRoutes/getRoutesLegacy.js +2 -2
- package/dist/esm-node/router/cli/code/getClientRoutes/utils.js +2 -2
- package/dist/esm-node/router/cli/code/index.js +4 -4
- package/dist/esm-node/router/cli/code/nestedRoutes.js +1 -1
- package/dist/esm-node/router/cli/code/templates.js +16 -9
- package/dist/esm-node/router/cli/code/utils.js +2 -2
- package/dist/esm-node/router/cli/entry.js +1 -1
- package/dist/esm-node/router/cli/handler.js +2 -2
- package/dist/esm-node/router/cli/index.js +1 -1
- package/dist/esm-node/router/runtime/DeferredDataScripts.node.js +2 -2
- package/dist/esm-node/router/runtime/PrefetchLink.js +1 -1
- package/dist/esm-node/router/runtime/plugin.js +4 -4
- package/dist/esm-node/router/runtime/plugin.node.js +6 -6
- package/dist/esm-node/router/runtime/utils.js +2 -2
- package/dist/esm-node/state/plugins.js +1 -1
- package/dist/esm-node/state/runtime/plugin.js +4 -4
- package/dist/types/cli/alias.d.ts +1 -1
- package/dist/types/cli/code.d.ts +1 -1
- package/dist/types/cli/index.d.ts +3 -3
- package/dist/types/cli/ssr/index.d.ts +1 -1
- package/dist/types/common.d.ts +1 -1
- package/dist/types/config.d.ts +1 -1
- package/dist/types/core/browser/hydrate.d.ts +3 -3
- package/dist/types/core/browser/index.d.ts +1 -1
- package/dist/types/core/browser/withCallback.d.ts +1 -1
- package/dist/types/core/compatible.d.ts +3 -3
- package/dist/types/core/config.d.ts +1 -1
- package/dist/types/core/context/index.d.ts +1 -1
- package/dist/types/core/context/runtime.d.ts +5 -5
- package/dist/types/core/loader/loaderManager.d.ts +2 -2
- package/dist/types/core/plugin/base.d.ts +2 -2
- package/dist/types/core/plugin/index.d.ts +1 -1
- package/dist/types/core/plugin/runner.d.ts +1 -1
- package/dist/types/core/react/index.d.ts +1 -1
- package/dist/types/core/react/wrapper.d.ts +1 -1
- package/dist/types/core/server/helmet.d.ts +1 -1
- package/dist/types/core/server/index.d.ts +1 -1
- package/dist/types/core/server/react/nossr/index.d.ts +1 -1
- package/dist/types/core/server/react/prerender/util.d.ts +1 -1
- package/dist/types/core/server/requestHandler.d.ts +3 -3
- package/dist/types/core/server/stream/afterTemplate.d.ts +4 -4
- package/dist/types/core/server/stream/beforeTemplate.d.ts +2 -2
- package/dist/types/core/server/stream/createReadableStream.d.ts +1 -1
- package/dist/types/core/server/stream/createReadableStream.worker.d.ts +1 -1
- package/dist/types/core/server/stream/shared.d.ts +3 -3
- package/dist/types/core/server/stream/template.d.ts +1 -1
- package/dist/types/core/server/string/index.d.ts +1 -1
- package/dist/types/core/server/string/loadable.d.ts +2 -2
- package/dist/types/core/server/string/prefetch.d.ts +5 -5
- package/dist/types/core/server/string/ssrData.d.ts +4 -4
- package/dist/types/core/server/string/styledComponent.d.ts +1 -1
- package/dist/types/core/server/string/types.d.ts +2 -2
- package/dist/types/core/server/utils.d.ts +3 -3
- package/dist/types/core/types.d.ts +2 -2
- package/dist/types/document/DocumentStructureContext.d.ts +1 -1
- package/dist/types/document/cli/index.d.ts +2 -2
- package/dist/types/exports/server.d.ts +1 -1
- package/dist/types/index.d.ts +2 -2
- package/dist/types/router/cli/code/index.d.ts +2 -2
- package/dist/types/router/cli/code/templates.d.ts +1 -1
- package/dist/types/router/cli/entry.d.ts +1 -1
- package/dist/types/router/cli/handler.d.ts +3 -3
- package/dist/types/router/cli/index.d.ts +1 -1
- package/dist/types/router/runtime/DeferredDataScripts.node.d.ts +1 -1
- package/dist/types/router/runtime/PrefetchLink.d.ts +1 -1
- package/dist/types/router/runtime/hooks.d.ts +1 -1
- package/dist/types/router/runtime/index.d.ts +1 -1
- package/dist/types/router/runtime/plugin.d.ts +1 -1
- package/dist/types/router/runtime/routeModule.d.ts +1 -1
- package/dist/types/router/runtime/types.d.ts +2 -2
- package/dist/types/router/runtime/utils.d.ts +4 -4
- package/dist/types/router/runtime/withRouter.d.ts +1 -1
- package/dist/types/state/cli/index.d.ts +1 -1
- package/package.json +13 -12
- package/types/index.d.ts +1 -1
- package/types/router.d.ts +1 -1
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import React, { useContext, useMemo } from "react";
|
|
3
2
|
import { ROUTE_MANIFEST } from "@modern-js/utils/universal/constants";
|
|
3
|
+
import React, { useContext, useMemo } from "react";
|
|
4
|
+
import { hydrateRoot as ModernHydrateRoot } from "./browser/hydrate";
|
|
5
|
+
import { getGlobalAppInit } from "./context";
|
|
4
6
|
import { RuntimeReactContext } from "./context/runtime";
|
|
5
|
-
import { registerPlugin } from "./plugin";
|
|
6
7
|
import { createLoaderManager } from "./loader/loaderManager";
|
|
8
|
+
import { registerPlugin } from "./plugin";
|
|
7
9
|
import { getGlobalRunner } from "./plugin/runner";
|
|
8
|
-
import { getGlobalAppInit } from "./context";
|
|
9
|
-
import { hydrateRoot as ModernHydrateRoot } from "./browser/hydrate";
|
|
10
10
|
import { wrapRuntimeContextProvider } from "./react/wrapper";
|
|
11
11
|
const IS_REACT18 = process.env.IS_REACT18 === "true";
|
|
12
12
|
function isClientArgs(id) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { createContext } from "react";
|
|
2
1
|
import { ROUTE_MANIFEST } from "@modern-js/utils/universal/constants";
|
|
2
|
+
import { createContext } from "react";
|
|
3
3
|
import { createLoaderManager } from "../loader/loaderManager";
|
|
4
4
|
const RuntimeReactContext = createContext({});
|
|
5
5
|
const ServerRouterContext = createContext({});
|
|
@@ -24,7 +24,7 @@ const createLoader = (id, initialData = {
|
|
|
24
24
|
reloading: false,
|
|
25
25
|
data: void 0,
|
|
26
26
|
error: void 0
|
|
27
|
-
}, loaderFn, skip = false) => {
|
|
27
|
+
}, loaderFn = () => Promise.resolve(), skip = false) => {
|
|
28
28
|
let promise;
|
|
29
29
|
let status = 0;
|
|
30
30
|
let { data, error } = initialData;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { useContext, useRef, useMemo, useState, useCallback, useEffect } from "react";
|
|
2
1
|
import invariant from "invariant";
|
|
2
|
+
import { useCallback, useContext, useEffect, useMemo, useRef, useState } from "react";
|
|
3
3
|
import { RuntimeReactContext } from "../context/runtime";
|
|
4
4
|
import { LoaderStatus } from "./loaderManager";
|
|
5
5
|
const useLoader = (loaderFn, options = {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { createAsyncInterruptWorkflow, createContext, createManager, createSyncParallelWorkflow, createWaterfall } from "@modern-js/plugin";
|
|
2
2
|
const RuntimeConfigContext = createContext({});
|
|
3
3
|
const useRuntimeConfigContext = () => RuntimeConfigContext.use().value;
|
|
4
4
|
const wrapRoot = createWaterfall();
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { merge } from "@modern-js/runtime-utils/merge";
|
|
2
|
-
import {
|
|
2
|
+
import { RuntimeConfigContext, runtime } from "./base";
|
|
3
3
|
import { getGlobalRunner, setGlobalRunner } from "./runner";
|
|
4
4
|
export * from "./base";
|
|
5
5
|
function setupConfigContext() {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import withSideEffect from "react-side-effect";
|
|
2
1
|
import React, { createElement } from "react";
|
|
3
|
-
import
|
|
2
|
+
import withSideEffect from "react-side-effect";
|
|
3
|
+
import { aggKeysFromPropsList, aggMatchesFromPropsList, exist, getOutermostProperty } from "./util";
|
|
4
4
|
const PROP_NAMES = {
|
|
5
5
|
INTERVAL: "interval",
|
|
6
6
|
STALE_LIMIT: "staleLimit",
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { getPathname, parseCookie, parseHeaders, parseQuery } from "@modern-js/runtime-utils/universal/request";
|
|
2
|
-
import { createRoot } from "../react";
|
|
3
2
|
import { getGlobalAppInit } from "../context";
|
|
4
|
-
import { getGlobalRunner } from "../plugin/runner";
|
|
5
3
|
import { getInitialContext } from "../context/runtime";
|
|
6
4
|
import { createLoaderManager } from "../loader/loaderManager";
|
|
7
|
-
import {
|
|
5
|
+
import { getGlobalRunner } from "../plugin/runner";
|
|
6
|
+
import { createRoot } from "../react";
|
|
8
7
|
import { CHUNK_CSS_PLACEHOLDER } from "./constants";
|
|
8
|
+
import { getSSRConfigByEntry, getSSRMode } from "./utils";
|
|
9
9
|
function createSSRContext(request, options) {
|
|
10
10
|
const { config, loaderContext, onError, onTiming, locals, resource, params, responseProxy, logger, metrics, reporter } = options;
|
|
11
11
|
const { nonce } = config;
|
|
@@ -18,7 +18,10 @@ function createSSRContext(request, options) {
|
|
|
18
18
|
const headersData = parseHeaders(request);
|
|
19
19
|
const url = new URL(request.url);
|
|
20
20
|
const host = headers.get("X-Forwarded-Host") || headers.get("host") || url.host;
|
|
21
|
-
|
|
21
|
+
let protocol = (headers.get("X-Forwarded-Proto") || url.protocol || "http").split(/\s*,\s*/, 1)[0];
|
|
22
|
+
if (!protocol.endsWith(":")) {
|
|
23
|
+
protocol += ":";
|
|
24
|
+
}
|
|
22
25
|
const ssrConfig = getSSRConfigByEntry(entryName, config.ssr, config.ssrByEntries);
|
|
23
26
|
const ssrMode = getSSRMode(ssrConfig);
|
|
24
27
|
const loaderFailureMode = typeof ssrConfig === "object" ? ssrConfig.loaderFailureMode : void 0;
|
|
@@ -30,7 +33,7 @@ function createSSRContext(request, options) {
|
|
|
30
33
|
logger,
|
|
31
34
|
metrics,
|
|
32
35
|
request: {
|
|
33
|
-
url: request.url.replace(url.host, host).replace(url.protocol,
|
|
36
|
+
url: request.url.replace(url.host, host).replace(url.protocol, protocol),
|
|
34
37
|
baseUrl: route.urlPath,
|
|
35
38
|
userAgent: headers.get("user-agent"),
|
|
36
39
|
cookie,
|
|
@@ -60,6 +63,7 @@ function createSSRContext(request, options) {
|
|
|
60
63
|
}
|
|
61
64
|
const createRequestHandler = async (handleRequest) => {
|
|
62
65
|
const requestHandler = async (request, options) => {
|
|
66
|
+
var _context_routerContext, _context_routerContext1;
|
|
63
67
|
const Root = createRoot();
|
|
64
68
|
const runner = getGlobalRunner();
|
|
65
69
|
const { routeManifest } = options.resource;
|
|
@@ -107,6 +111,10 @@ const createRequestHandler = async (handleRequest) => {
|
|
|
107
111
|
return void 0;
|
|
108
112
|
};
|
|
109
113
|
const initialData = await runBeforeRender(context);
|
|
114
|
+
if (((_context_routerContext = context.routerContext) === null || _context_routerContext === void 0 ? void 0 : _context_routerContext.statusCode) && ((_context_routerContext1 = context.routerContext) === null || _context_routerContext1 === void 0 ? void 0 : _context_routerContext1.statusCode) !== 200) {
|
|
115
|
+
var _context_routerContext2, _context_ssrContext;
|
|
116
|
+
(_context_ssrContext = context.ssrContext) === null || _context_ssrContext === void 0 ? void 0 : _context_ssrContext.response.status((_context_routerContext2 = context.routerContext) === null || _context_routerContext2 === void 0 ? void 0 : _context_routerContext2.statusCode);
|
|
117
|
+
}
|
|
110
118
|
context.initialData = initialData;
|
|
111
119
|
const redirectResponse = getRedirectResponse(initialData);
|
|
112
120
|
if (redirectResponse) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { serializeJson } from "@modern-js/runtime-utils/node";
|
|
2
|
-
import { attributesToString, safeReplace } from "../utils";
|
|
3
2
|
import { SSR_DATA_PLACEHOLDER } from "../constants";
|
|
4
3
|
import { buildHtml } from "../shared";
|
|
4
|
+
import { attributesToString, safeReplace } from "../utils";
|
|
5
5
|
function buildShellAfterTemplate(afterAppTemplate, options) {
|
|
6
6
|
const { request, config, ssrConfig, runtimeContext, renderLevel, entryName } = options;
|
|
7
7
|
const callbacks = [
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import ReactHelmet from "react-helmet";
|
|
2
1
|
import { matchRoutes } from "@modern-js/runtime-utils/router";
|
|
3
|
-
import
|
|
2
|
+
import ReactHelmet from "react-helmet";
|
|
4
3
|
import { CHUNK_CSS_PLACEHOLDER } from "../constants";
|
|
5
|
-
import {
|
|
4
|
+
import { createReplaceHelemt } from "../helmet";
|
|
6
5
|
import { buildHtml } from "../shared";
|
|
6
|
+
import { checkIsNode, safeReplace } from "../utils";
|
|
7
7
|
const readAsset = async (chunk) => {
|
|
8
8
|
const fs = await import("fs/promises");
|
|
9
9
|
const path = await import("path");
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { Transform } from "stream";
|
|
2
2
|
import { createReadableStreamFromReadable } from "@modern-js/runtime-utils/node";
|
|
3
|
-
import { ServerStyleSheet } from "styled-components";
|
|
4
3
|
import checkIsBot from "isbot";
|
|
4
|
+
import { ServerStyleSheet } from "styled-components";
|
|
5
5
|
import { ESCAPED_SHELL_STREAM_END_MARK } from "../../../common";
|
|
6
6
|
import { RenderLevel } from "../../constants";
|
|
7
|
-
import { getTemplates } from "./template";
|
|
8
7
|
import { ShellChunkStatus, getReadableStreamFromString } from "./shared";
|
|
8
|
+
import { getTemplates } from "./template";
|
|
9
9
|
const createReadableStreamFromElement = async (request, rootElement, options) => {
|
|
10
10
|
const { renderToPipeableStream } = await import("react-dom/server");
|
|
11
11
|
const { runtimeContext, htmlTemplate, config, ssrConfig, entryName } = options;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { renderToReadableStream } from "react-dom/server";
|
|
2
1
|
import checkIsBot from "isbot";
|
|
3
|
-
import {
|
|
2
|
+
import { renderToReadableStream } from "react-dom/server";
|
|
4
3
|
import { ESCAPED_SHELL_STREAM_END_MARK } from "../../../common";
|
|
4
|
+
import { RenderLevel } from "../../constants";
|
|
5
5
|
import { ShellChunkStatus, encodeForWebStream, getReadableStreamFromString } from "./shared";
|
|
6
6
|
import { getTemplates } from "./template";
|
|
7
7
|
const createReadableStreamFromElement = async (request, rootElement, options) => {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import { run } from "@modern-js/runtime-utils/node";
|
|
1
2
|
import { time } from "@modern-js/runtime-utils/time";
|
|
2
3
|
import { parseHeaders } from "@modern-js/runtime-utils/universal/request";
|
|
3
|
-
import { run } from "@modern-js/runtime-utils/node";
|
|
4
4
|
import { wrapRuntimeContextProvider } from "../../react/wrapper";
|
|
5
5
|
import { SSRErrors, SSRTimings, createOnError, createOnTiming } from "../tracer";
|
|
6
6
|
import { getSSRConfigByEntry } from "../utils";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { buildShellBeforeTemplate } from "./beforeTemplate";
|
|
2
1
|
import { buildShellAfterTemplate } from "./afterTemplate";
|
|
2
|
+
import { buildShellBeforeTemplate } from "./beforeTemplate";
|
|
3
3
|
const HTML_SEPARATOR = "<!--<?- html ?>-->";
|
|
4
4
|
const getTemplates = async (htmlTemplate, options) => {
|
|
5
5
|
const [beforeAppTemplate = "", afterAppHtmlTemplate = ""] = htmlTemplate.split(HTML_SEPARATOR) || [];
|
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
import ReactHelmet from "react-helmet";
|
|
2
|
-
import ReactDomServer from "react-dom/server";
|
|
3
|
-
import { time } from "@modern-js/runtime-utils/time";
|
|
4
1
|
import { run } from "@modern-js/runtime-utils/node";
|
|
2
|
+
import { time } from "@modern-js/runtime-utils/time";
|
|
5
3
|
import { parseHeaders } from "@modern-js/runtime-utils/universal/request";
|
|
4
|
+
import ReactDomServer from "react-dom/server";
|
|
5
|
+
import ReactHelmet from "react-helmet";
|
|
6
|
+
import { RenderLevel } from "../../constants";
|
|
6
7
|
import { wrapRuntimeContextProvider } from "../../react/wrapper";
|
|
7
|
-
import { createReplaceHelemt } from "../helmet";
|
|
8
|
-
import { getSSRConfigByEntry, safeReplace } from "../utils";
|
|
9
8
|
import { CHUNK_CSS_PLACEHOLDER, CHUNK_JS_PLACEHOLDER, HTML_PLACEHOLDER, SSR_DATA_PLACEHOLDER } from "../constants";
|
|
9
|
+
import { createReplaceHelemt } from "../helmet";
|
|
10
10
|
import { buildHtml } from "../shared";
|
|
11
11
|
import { SSRErrors, SSRTimings, createOnError, createOnTiming } from "../tracer";
|
|
12
|
-
import {
|
|
13
|
-
import { SSRDataCollector } from "./ssrData";
|
|
12
|
+
import { getSSRConfigByEntry, safeReplace } from "../utils";
|
|
14
13
|
import { LoadableCollector } from "./loadable";
|
|
15
|
-
import { StyledCollector } from "./styledComponent";
|
|
16
14
|
import { prefetch } from "./prefetch";
|
|
15
|
+
import { SSRDataCollector } from "./ssrData";
|
|
16
|
+
import { StyledCollector } from "./styledComponent";
|
|
17
17
|
const renderString = async (request, serverRoot, options) => {
|
|
18
18
|
const headersData = parseHeaders(request);
|
|
19
19
|
return run(headersData, async () => {
|
|
@@ -72,22 +72,22 @@ async function generateHtml(App, htmlTemplate, chunkSet, collectors, htmlModifie
|
|
|
72
72
|
const end = time();
|
|
73
73
|
let html = "";
|
|
74
74
|
let helmetData;
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
75
|
+
try {
|
|
76
|
+
const finalApp = collectors.reduce((pre, creator) => {
|
|
77
|
+
var _creator_collect;
|
|
78
|
+
return ((_creator_collect = creator.collect) === null || _creator_collect === void 0 ? void 0 : _creator_collect.call(creator, pre)) || pre;
|
|
79
|
+
}, App);
|
|
80
|
+
if (chunkSet.renderLevel >= RenderLevel.SERVER_PREFETCH) {
|
|
81
81
|
html = ReactDomServer.renderToString(finalApp);
|
|
82
|
-
helmetData = ReactHelmet.renderStatic();
|
|
83
82
|
chunkSet.renderLevel = RenderLevel.SERVER_RENDER;
|
|
84
|
-
await Promise.all(collectors.map((component) => component.effect()));
|
|
85
|
-
const cost = end();
|
|
86
|
-
onTiming(SSRTimings.RENDER_HTML, cost);
|
|
87
|
-
} catch (e) {
|
|
88
|
-
chunkSet.renderLevel = RenderLevel.CLIENT_RENDER;
|
|
89
|
-
onError(SSRErrors.RENDER_HTML, e);
|
|
90
83
|
}
|
|
84
|
+
helmetData = ReactHelmet.renderStatic();
|
|
85
|
+
await Promise.all(collectors.map((component) => component.effect()));
|
|
86
|
+
const cost = end();
|
|
87
|
+
onTiming(SSRTimings.RENDER_HTML, cost);
|
|
88
|
+
} catch (e) {
|
|
89
|
+
chunkSet.renderLevel = RenderLevel.CLIENT_RENDER;
|
|
90
|
+
onError(SSRErrors.RENDER_HTML, e);
|
|
91
91
|
}
|
|
92
92
|
const { ssrScripts, cssChunk, jsChunk } = chunkSet;
|
|
93
93
|
const finalHtml = await buildHtml(htmlTemplate, [
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { renderToStaticMarkup } from "react-dom/server";
|
|
2
|
-
import { run } from "@modern-js/runtime-utils/node";
|
|
3
1
|
import { ChunkExtractor } from "@loadable/server";
|
|
2
|
+
import { run } from "@modern-js/runtime-utils/node";
|
|
4
3
|
import { time } from "@modern-js/runtime-utils/time";
|
|
5
4
|
import { parseHeaders } from "@modern-js/runtime-utils/universal/request";
|
|
5
|
+
import { renderToStaticMarkup } from "react-dom/server";
|
|
6
6
|
import { wrapRuntimeContextProvider } from "../../react/wrapper";
|
|
7
7
|
import { SSRErrors, SSRTimings } from "../tracer";
|
|
8
8
|
const prefetch = async (App, request, options, ssrConfig, { onError, onTiming }) => {
|
|
@@ -4,8 +4,8 @@ import { _ as _class_private_field_set } from "@swc/helpers/_/_class_private_fie
|
|
|
4
4
|
import { _ as _class_private_method_get } from "@swc/helpers/_/_class_private_method_get";
|
|
5
5
|
import { _ as _class_private_method_init } from "@swc/helpers/_/_class_private_method_init";
|
|
6
6
|
import { serializeJson } from "@modern-js/runtime-utils/node";
|
|
7
|
-
import { attributesToString, serializeErrors } from "../utils";
|
|
8
7
|
import { ROUTER_DATA_JSON_ID, SSR_DATA_JSON_ID } from "../../constants";
|
|
8
|
+
import { attributesToString, serializeErrors } from "../utils";
|
|
9
9
|
var _options = /* @__PURE__ */ new WeakMap(), _getSSRData = /* @__PURE__ */ new WeakSet(), _getSSRDataScripts = /* @__PURE__ */ new WeakSet();
|
|
10
10
|
class SSRDataCollector {
|
|
11
11
|
effect() {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { useContext } from "react";
|
|
3
|
-
import { BODY_PARTICALS_SEPARATOR, DOCUMENT_CHUNKSMAP_PLACEHOLDER, DOCUMENT_SSRDATASCRIPT_PLACEHOLDER } from "./constants";
|
|
4
3
|
import { DocumentStructureContext } from "./DocumentStructureContext";
|
|
5
4
|
import { DefaultRoot } from "./Root";
|
|
5
|
+
import { BODY_PARTICALS_SEPARATOR, DOCUMENT_CHUNKSMAP_PLACEHOLDER, DOCUMENT_SSRDATASCRIPT_PLACEHOLDER } from "./constants";
|
|
6
6
|
function Body(props) {
|
|
7
7
|
const { hasSetRoot } = useContext(DocumentStructureContext);
|
|
8
8
|
const { children, ...rest } = props;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
-
import {
|
|
2
|
+
import { DOCUMENT_COMMENT_PLACEHOLDER_END, DOCUMENT_COMMENT_PLACEHOLDER_START } from "./constants";
|
|
3
3
|
function Comment(props) {
|
|
4
4
|
const { comment, children } = props;
|
|
5
5
|
const commentStr = encodeURIComponent(children || comment || "");
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { useContext } from "react";
|
|
3
3
|
import { DocumentStructureContext } from "./DocumentStructureContext";
|
|
4
|
-
import { Scripts } from "./Scripts";
|
|
5
4
|
import { Links } from "./Links";
|
|
5
|
+
import { Scripts } from "./Scripts";
|
|
6
6
|
import { Title } from "./Title";
|
|
7
7
|
import { DOCUMENT_META_PLACEHOLDER, HEAD_PARTICALS_SEPARATOR, TOP_PARTICALS_SEPARATOR } from "./constants";
|
|
8
8
|
function Head(props) {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { useContext } from "react";
|
|
3
2
|
import { omit } from "@modern-js/utils/lodash";
|
|
3
|
+
import { useContext } from "react";
|
|
4
4
|
import { DocumentContext } from "./DocumentContext";
|
|
5
5
|
import { DOCUMENT_SSR_PLACEHOLDER } from "./constants";
|
|
6
6
|
function Root(props) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
-
import {
|
|
2
|
+
import { DOCUMENT_SCRIPT_PLACEHOLDER_END, DOCUMENT_SCRIPT_PLACEHOLDER_START } from "./constants";
|
|
3
3
|
function Script(props) {
|
|
4
4
|
const { content } = props;
|
|
5
5
|
const contentStr = content.toString();
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
-
import {
|
|
2
|
+
import { DOCUMENT_STYLE_PLACEHOLDER_END, DOCUMENT_STYLE_PLACEHOLDER_START } from "./constants";
|
|
3
3
|
function Style(props) {
|
|
4
4
|
const { content, children } = props;
|
|
5
5
|
const contentStr = children || content;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import path from "path";
|
|
2
|
+
import { fs, createDebugger, findExists } from "@modern-js/utils";
|
|
3
|
+
import { build } from "esbuild";
|
|
2
4
|
import React from "react";
|
|
3
5
|
import ReactDomServer from "react-dom/server";
|
|
4
|
-
import { build } from "esbuild";
|
|
5
|
-
import { createDebugger, findExists, fs } from "@modern-js/utils";
|
|
6
6
|
import { DocumentContext } from "../DocumentContext";
|
|
7
|
-
import {
|
|
7
|
+
import { BODY_PARTICALS_SEPARATOR, DOCUMENT_CHUNKSMAP_PLACEHOLDER, DOCUMENT_COMMENT_PLACEHOLDER_END, DOCUMENT_COMMENT_PLACEHOLDER_START, DOCUMENT_FILE_NAME, DOCUMENT_LINKS_PLACEHOLDER, DOCUMENT_META_PLACEHOLDER, DOCUMENT_SCRIPTS_PLACEHOLDER, DOCUMENT_SCRIPT_PLACEHOLDER_END, DOCUMENT_SCRIPT_PLACEHOLDER_START, DOCUMENT_SSRDATASCRIPT_PLACEHOLDER, DOCUMENT_SSR_PLACEHOLDER, DOCUMENT_STYLE_PLACEHOLDER_END, DOCUMENT_STYLE_PLACEHOLDER_START, DOCUMENT_TITLE_PLACEHOLDER, DOC_EXT, HEAD_PARTICALS_SEPARATOR, HTML_SEPARATOR, PLACEHOLDER_REPLACER_MAP, TOP_PARTICALS_SEPARATOR } from "../constants";
|
|
8
8
|
const debug = createDebugger("html_genarate");
|
|
9
9
|
const getDocumenByEntryName = function(entrypoints, entryName, fallbackDir) {
|
|
10
10
|
var _entrypoints_find;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import path from "path";
|
|
2
2
|
import { fs } from "@modern-js/utils";
|
|
3
|
-
import { makeLegalIdentifier } from "../makeLegalIdentifier";
|
|
4
3
|
import { FILE_SYSTEM_ROUTES_COMPONENTS_DIR, FILE_SYSTEM_ROUTES_DYNAMIC_REGEXP, FILE_SYSTEM_ROUTES_INDEX, FILE_SYSTEM_ROUTES_LAYOUT } from "../../constants";
|
|
4
|
+
import { makeLegalIdentifier } from "../makeLegalIdentifier";
|
|
5
5
|
import { replaceWithAlias } from "../utils";
|
|
6
|
-
import { debug, findLayout,
|
|
6
|
+
import { debug, findLayout, getRouteWeight, shouldSkip } from "./utils";
|
|
7
7
|
const compName = (srcDirectory, filePath) => {
|
|
8
8
|
const legalCompName = makeLegalIdentifier(path.relative(srcDirectory, filePath));
|
|
9
9
|
return `Comp_${legalCompName}`;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import path from "path";
|
|
2
2
|
import { fs } from "@modern-js/utils";
|
|
3
3
|
import { FILE_SYSTEM_ROUTES_COMPONENTS_DIR, FILE_SYSTEM_ROUTES_DYNAMIC_REGEXP, FILE_SYSTEM_ROUTES_INDEX, FILE_SYSTEM_ROUTES_LAYOUT } from "../../constants";
|
|
4
|
-
import { replaceWithAlias } from "../utils";
|
|
5
4
|
import { makeLegalIdentifier } from "../makeLegalIdentifier";
|
|
6
|
-
import {
|
|
5
|
+
import { replaceWithAlias } from "../utils";
|
|
6
|
+
import { debug, findLayout, getRouteWeight, shouldSkip } from "./utils";
|
|
7
7
|
const compName = (srcDirectory, filePath) => {
|
|
8
8
|
const legalCompName = makeLegalIdentifier(path.relative(srcDirectory, filePath));
|
|
9
9
|
return `Comp_${legalCompName}`;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import path from "path";
|
|
2
|
-
import { JS_EXTENSIONS, createDebugger, findExists
|
|
3
|
-
import {
|
|
2
|
+
import { fs, JS_EXTENSIONS, createDebugger, findExists } from "@modern-js/utils";
|
|
3
|
+
import { FILE_SYSTEM_ROUTES_GLOBAL_LAYOUT, FILE_SYSTEM_ROUTES_IGNORED_REGEX, FILE_SYSTEM_ROUTES_LAYOUT } from "../../constants";
|
|
4
4
|
const debug = createDebugger("get-client-routes");
|
|
5
5
|
const findLayout = (dir) => findExists(JS_EXTENSIONS.map((ext) => path.resolve(dir, `${FILE_SYSTEM_ROUTES_LAYOUT}${ext}`)));
|
|
6
6
|
const getRouteWeight = (route) => route === "*" ? 999 : route.split(":").length - 1;
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import path from "path";
|
|
2
|
-
import { fs, getEntryOptions, isRouterV5, isSSGEntry, isUseSSRBundle, logger
|
|
2
|
+
import { fs, filterRoutesForServer, filterRoutesLoader, getEntryOptions, isRouterV5, isSSGEntry, isUseSSRBundle, logger } from "@modern-js/utils";
|
|
3
3
|
import { cloneDeep } from "@modern-js/utils/lodash";
|
|
4
|
-
import { FILE_SYSTEM_ROUTES_FILE_NAME } from "../constants";
|
|
5
4
|
import { ENTRY_POINT_RUNTIME_GLOBAL_CONTEXT_FILE_NAME } from "../../../cli/constants";
|
|
6
|
-
import
|
|
5
|
+
import { FILE_SYSTEM_ROUTES_FILE_NAME } from "../constants";
|
|
7
6
|
import { getClientRoutes, getClientRoutesLegacy } from "./getClientRoutes";
|
|
8
|
-
import { getServerLoadersFile, getServerCombinedModueFile } from "./utils";
|
|
9
7
|
import { walk } from "./nestedRoutes";
|
|
8
|
+
import * as templates from "./templates";
|
|
9
|
+
import { getServerCombinedModueFile, getServerLoadersFile } from "./utils";
|
|
10
10
|
const generateCode = async (appContext, config, entrypoints, api) => {
|
|
11
11
|
const { internalDirectory, srcDirectory, internalDirAlias, internalSrcAlias, packageName } = appContext;
|
|
12
12
|
const hookRunners = api.useHookRunners();
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as path from "path";
|
|
2
|
-
import {
|
|
2
|
+
import { fs, JS_EXTENSIONS, normalizeToPosixPath } from "@modern-js/utils";
|
|
3
3
|
import { NESTED_ROUTE } from "../constants";
|
|
4
4
|
import { getPathWithoutExt, hasAction, replaceWithAlias } from "./utils";
|
|
5
5
|
const conventionNames = Object.values(NESTED_ROUTE);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import path from "path";
|
|
2
|
-
import { findExists, formatImportPath,
|
|
2
|
+
import { fs, findExists, formatImportPath, getEntryOptions, isSSGEntry, slash } from "@modern-js/utils";
|
|
3
3
|
import { ROUTE_MODULES } from "@modern-js/utils/universal/constants";
|
|
4
4
|
import { APP_CONFIG_NAME, APP_INIT_EXPORTED, TEMP_LOADERS_DIR } from "../constants";
|
|
5
5
|
import { getPathWithoutExt, getServerLoadersFile, parseModule, replaceWithAlias } from "./utils";
|
|
@@ -332,14 +332,21 @@ function ssrLoaderCombinedModule(entrypoints, entrypoint, config, appContext) {
|
|
|
332
332
|
if (!config.source.enableAsyncEntry) {
|
|
333
333
|
return combinedModule;
|
|
334
334
|
}
|
|
335
|
-
return `
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
335
|
+
return `
|
|
336
|
+
async function loadModules() {
|
|
337
|
+
const [moduleA, moduleB] = await Promise.all([
|
|
338
|
+
import("${slash(serverLoaderRuntime)}"),
|
|
339
|
+
import("${slash(serverLoadersFile)}")
|
|
340
|
+
]);
|
|
341
|
+
|
|
342
|
+
return {
|
|
343
|
+
...moduleA,
|
|
344
|
+
...moduleB
|
|
345
|
+
};
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
export { loadModules };
|
|
349
|
+
`;
|
|
343
350
|
}
|
|
344
351
|
return null;
|
|
345
352
|
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import fs from "fs";
|
|
2
2
|
import path from "path";
|
|
3
|
-
import {
|
|
4
|
-
import { transform } from "esbuild";
|
|
3
|
+
import { JS_EXTENSIONS, fs as fse, normalizeToPosixPath } from "@modern-js/utils";
|
|
5
4
|
import { parse } from "es-module-lexer";
|
|
5
|
+
import { transform } from "esbuild";
|
|
6
6
|
import { ACTION_EXPORT_NAME, LOADER_EXPORT_NAME } from "../constants";
|
|
7
7
|
const walkDirectory = (dir) => fs.readdirSync(dir).reduce((previous, filename) => {
|
|
8
8
|
const filePath = path.join(dir, filename);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import path from "path";
|
|
2
|
-
import { JS_EXTENSIONS, findExists,
|
|
2
|
+
import { fs, JS_EXTENSIONS, findExists, isRouterV5 } from "@modern-js/utils";
|
|
3
3
|
import { hasApp } from "../../cli/entry";
|
|
4
4
|
import { FILE_SYSTEM_ROUTES_GLOBAL_LAYOUT, NESTED_ROUTES_DIR, PAGES_DIR_NAME } from "./constants";
|
|
5
5
|
const hasPages = (dir) => fs.existsSync(path.join(dir, PAGES_DIR_NAME));
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import path from "path";
|
|
2
2
|
import { cloneDeep } from "@modern-js/utils/lodash";
|
|
3
|
-
import { modifyEntrypoints } from "./entry";
|
|
4
|
-
import { isPageComponentFile } from "./code/utils";
|
|
5
3
|
import * as templates from "./code/templates";
|
|
4
|
+
import { isPageComponentFile } from "./code/utils";
|
|
5
|
+
import { modifyEntrypoints } from "./entry";
|
|
6
6
|
let originEntrypoints = [];
|
|
7
7
|
async function handleModifyEntrypoints(api, entrypoints) {
|
|
8
8
|
const config = api.useResolvedConfigContext();
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import path from "node:path";
|
|
2
|
-
import { createRuntimeExportsUtils, filterRoutesForServer,
|
|
2
|
+
import { fs, NESTED_ROUTE_SPEC_FILE, createRuntimeExportsUtils, filterRoutesForServer, getEntryOptions, isRouterV5 as isV5 } from "@modern-js/utils";
|
|
3
3
|
import { isRouteEntry } from "./entry";
|
|
4
4
|
import { handleFileChange, handleGeneratorEntryCode, handleModifyEntrypoints } from "./handler";
|
|
5
5
|
import { isRouteEntry as isRouteEntry2 } from "./entry";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
-
import { Suspense, useEffect, useRef, useMemo } from "react";
|
|
3
|
-
import { Await, useAsyncError } from "@modern-js/runtime-utils/router";
|
|
4
2
|
import { serializeJson } from "@modern-js/runtime-utils/node";
|
|
3
|
+
import { Await, useAsyncError } from "@modern-js/runtime-utils/router";
|
|
4
|
+
import { Suspense, useEffect, useMemo, useRef } from "react";
|
|
5
5
|
import { serializeErrors } from "./utils";
|
|
6
6
|
const setupFnStr = `function s(r,e){_ROUTER_DATA.r=_ROUTER_DATA.r||{},_ROUTER_DATA.r[r]=_ROUTER_DATA.r[r]||{};return new Promise((function(A,R){_ROUTER_DATA.r[r][e]={resolve:A,reject:R}}))};`;
|
|
7
7
|
const resolveFnStr = `function r(e,r,o,A){A?_ROUTER_DATA.r[e][r].reject(A):_ROUTER_DATA.r[e][r].resolve(o)};`;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { Link as RouterLink, NavLink as RouterNavLink, matchRoutes, useHref, useMatches, useResolvedPath } from "@modern-js/runtime-utils/router";
|
|
2
3
|
import React, { useContext, useMemo } from "react";
|
|
3
|
-
import { Link as RouterLink, matchRoutes, useResolvedPath, useHref, useMatches, NavLink as RouterNavLink } from "@modern-js/runtime-utils/router";
|
|
4
4
|
import { RuntimeReactContext } from "../../core";
|
|
5
5
|
function composeEventHandlers(theirHandler, ourHandler) {
|
|
6
6
|
return (event) => {
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { useContext, useMemo } from "react";
|
|
3
|
-
import { createBrowserRouter, createHashRouter, RouterProvider, createRoutesFromElements, useMatches, useLocation, useHref } from "@modern-js/runtime-utils/router";
|
|
4
|
-
import { parsedJSONFromElement } from "@modern-js/runtime-utils/parsed";
|
|
5
2
|
import { merge } from "@modern-js/runtime-utils/merge";
|
|
6
|
-
import {
|
|
3
|
+
import { parsedJSONFromElement } from "@modern-js/runtime-utils/parsed";
|
|
4
|
+
import { RouterProvider, createBrowserRouter, createHashRouter, createRoutesFromElements, useHref, useLocation, useMatches } from "@modern-js/runtime-utils/router";
|
|
5
|
+
import { useContext, useMemo } from "react";
|
|
7
6
|
import { RuntimeReactContext } from "../../core";
|
|
7
|
+
import { getGlobalLayoutApp, getGlobalRoutes } from "../../core/context";
|
|
8
8
|
import { modifyRoutes as modifyRoutesHook } from "./hooks";
|
|
9
9
|
import { deserializeErrors, renderRoutes, urlJoin } from "./utils";
|
|
10
10
|
let finalRouteConfig = {
|
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
-
import {
|
|
2
|
+
import { merge } from "@modern-js/runtime-utils/merge";
|
|
3
|
+
import { createRequestContext, reporterCtx } from "@modern-js/runtime-utils/node";
|
|
4
|
+
import { StaticRouterProvider, createStaticRouter } from "@modern-js/runtime-utils/node/router";
|
|
3
5
|
import { createStaticHandler } from "@modern-js/runtime-utils/remix-router";
|
|
4
|
-
import { createStaticRouter, StaticRouterProvider } from "@modern-js/runtime-utils/node/router";
|
|
5
6
|
import { createRoutesFromElements } from "@modern-js/runtime-utils/router";
|
|
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 {
|
|
9
|
+
import { useContext } from "react";
|
|
10
10
|
import { JSX_SHELL_STREAM_END_MARK } from "../../common";
|
|
11
11
|
import { RuntimeReactContext } from "../../core";
|
|
12
12
|
import { getGlobalLayoutApp, getGlobalRoutes } from "../../core/context";
|
|
13
|
-
import { renderRoutes, urlJoin } from "./utils";
|
|
14
|
-
import { modifyRoutes as modifyRoutesHook } from "./hooks";
|
|
15
13
|
import DeferredDataScripts from "./DeferredDataScripts.node";
|
|
14
|
+
import { modifyRoutes as modifyRoutesHook } from "./hooks";
|
|
15
|
+
import { renderRoutes, urlJoin } from "./utils";
|
|
16
16
|
function createRemixReuqest(request) {
|
|
17
17
|
const method = "GET";
|
|
18
18
|
const { headers } = request;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { Route, isRouteErrorResponse } from "@modern-js/runtime-utils/router";
|
|
3
|
-
import { UNSAFE_ErrorResponseImpl as ErrorResponseImpl } from "@modern-js/runtime-utils/remix-router";
|
|
4
2
|
import { renderNestedRoute } from "@modern-js/runtime-utils/browser";
|
|
3
|
+
import { UNSAFE_ErrorResponseImpl as ErrorResponseImpl } from "@modern-js/runtime-utils/remix-router";
|
|
4
|
+
import { Route, isRouteErrorResponse } from "@modern-js/runtime-utils/router";
|
|
5
5
|
import { DefaultNotFound } from "./DefaultNotFound";
|
|
6
6
|
import DeferredDataScripts from "./DeferredDataScripts";
|
|
7
7
|
function getRouteComponents(routes, { globalApp, ssrMode, props, reporter }) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { plugin as effectsPlugin } from "@modern-js-reduck/plugin-effects";
|
|
2
1
|
import autoActionsPlugin from "@modern-js-reduck/plugin-auto-actions";
|
|
2
|
+
import { plugin as effectsPlugin } from "@modern-js-reduck/plugin-effects";
|
|
3
3
|
import immerPlugin from "@modern-js-reduck/plugin-immutable";
|
|
4
4
|
import { default as default2 } from "@modern-js-reduck/plugin-devtools";
|
|
5
5
|
const effects = () => effectsPlugin;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { useContext } from "react";
|
|
3
|
-
import { createStore } from "@modern-js-reduck/store";
|
|
4
2
|
import { Provider } from "@modern-js-reduck/react";
|
|
3
|
+
import { createStore } from "@modern-js-reduck/store";
|
|
5
4
|
import { merge } from "@modern-js/runtime-utils/merge";
|
|
6
|
-
import {
|
|
7
|
-
import { RuntimeReactContext } from "../../core";
|
|
5
|
+
import { useContext } from "react";
|
|
8
6
|
import { isBrowser } from "../../common";
|
|
7
|
+
import { RuntimeReactContext } from "../../core";
|
|
8
|
+
import { autoActions, devtools, effects, immer } from "../plugins";
|
|
9
9
|
const StatePluginHandleMap = {
|
|
10
10
|
immer,
|
|
11
11
|
effects,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Entrypoint } from '@modern-js/types';
|
|
1
|
+
import type { Entrypoint } from '@modern-js/types';
|
|
2
2
|
import type { RsbuildPlugin } from '@rsbuild/core';
|
|
3
3
|
export declare const builderPluginAlias: ({ entrypoints, internalDirectory, metaName, }: {
|
|
4
4
|
entrypoints: Entrypoint[];
|
package/dist/types/cli/code.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { AppTools, IAppContext, NormalizedConfig, RuntimePlugin } from '@modern-js/app-tools';
|
|
2
|
-
import { Entrypoint } from '@modern-js/types';
|
|
3
2
|
import type { MaybeAsync } from '@modern-js/plugin';
|
|
3
|
+
import type { Entrypoint } from '@modern-js/types';
|
|
4
4
|
export declare const generateCode: (entrypoints: Entrypoint[], appContext: IAppContext, config: NormalizedConfig<AppTools>, onCollectRuntimePlugins: (params: {
|
|
5
5
|
entrypoint: Entrypoint;
|
|
6
6
|
plugins: RuntimePlugin[];
|