@modern-js/runtime 0.0.0-nightly-20231219170633 → 0.0.0-nightly-20231221170655

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.
@@ -104,11 +104,11 @@ const ssrPlugin = () => ({
104
104
  }
105
105
  },
106
106
  tools: {
107
- bundlerChain(chain, { isServer, isServiceWorker, CHAIN_ID }) {
107
+ bundlerChain(chain, { isServer, isServiceWorker }) {
108
108
  const userConfig = api.useResolvedConfigContext();
109
109
  if ((0, import_utils.isUseSSRBundle)(userConfig) && !isServer && !isServiceWorker && checkUseStringSSR(userConfig)) {
110
110
  const LoadableBundlerPlugin = require("./loadable-bundler-plugin.js");
111
- chain.plugin(CHAIN_ID.PLUGIN.LOADABLE).use(LoadableBundlerPlugin, [
111
+ chain.plugin("loadable").use(LoadableBundlerPlugin, [
112
112
  {
113
113
  filename: import_utils.LOADABLE_STATS_FILE
114
114
  }
@@ -154,12 +154,13 @@ const ssrPlugin = () => ({
154
154
  },
155
155
  modifyEntryRuntimePlugins({ entrypoint, plugins, bundlerConfigs }) {
156
156
  if (ssrConfigMap.get(entrypoint.entryName)) {
157
- var _bundlerConfigs_find_output, _bundlerConfigs_find, _config_server;
157
+ var _bundlerConfigs_find_output, _bundlerConfigs_find, _config_server, _config_server1;
158
158
  const chunkLoadingGlobal = bundlerConfigs === null || bundlerConfigs === void 0 ? void 0 : (_bundlerConfigs_find = bundlerConfigs.find((config2) => config2.name === "client")) === null || _bundlerConfigs_find === void 0 ? void 0 : (_bundlerConfigs_find_output = _bundlerConfigs_find.output) === null || _bundlerConfigs_find_output === void 0 ? void 0 : _bundlerConfigs_find_output.chunkLoadingGlobal;
159
159
  const config = api.useResolvedConfigContext();
160
160
  const { enableInlineScripts, enableInlineStyles } = config.output;
161
161
  const { crossorigin, scriptLoading } = config.html;
162
162
  const disablePrerender = typeof ((_config_server = config.server) === null || _config_server === void 0 ? void 0 : _config_server.ssr) === "object" ? Boolean(config.server.ssr.disablePrerender) : false;
163
+ const unsafeHeaders = typeof ((_config_server1 = config.server) === null || _config_server1 === void 0 ? void 0 : _config_server1.ssr) === "object" ? config.server.ssr.unsafeHeaders : void 0;
163
164
  plugins.push({
164
165
  name: PLUGIN_IDENTIFIER,
165
166
  options: JSON.stringify({
@@ -169,7 +170,8 @@ const ssrPlugin = () => ({
169
170
  chunkLoadingGlobal,
170
171
  disablePrerender,
171
172
  enableInlineScripts: typeof enableInlineScripts === "function" ? void 0 : enableInlineScripts,
172
- enableInlineStyles: typeof enableInlineStyles === "function" ? void 0 : enableInlineStyles
173
+ enableInlineStyles: typeof enableInlineStyles === "function" ? void 0 : enableInlineStyles,
174
+ unsafeHeaders
173
175
  })
174
176
  });
175
177
  }
@@ -60,6 +60,14 @@ const ssr = (config) => ({
60
60
  },
61
61
  _hydration: true
62
62
  };
63
+ const { ssrContext } = hydrateContext;
64
+ const { pathname: initialPathname } = ssrContext.request;
65
+ const currentPathname = window.location.pathname;
66
+ if (initialPathname !== currentPathname) {
67
+ const errorMsg = `The initial URL ${initialPathname} and the URL ${currentPathname} to be hydrated do not match, reload.`;
68
+ console.error(errorMsg);
69
+ window.location.reload();
70
+ }
63
71
  const callback = () => {
64
72
  delete hydrateContext._hydration;
65
73
  };
@@ -47,11 +47,13 @@ var import_loadable = require("./loadable");
47
47
  var import_render = require("./render");
48
48
  var import_styledComponent = require("./styledComponent");
49
49
  var import_buildHtml = require("./buildHtml");
50
- const buildTemplateData = (context, data, renderLevel, tracker) => {
51
- const { request, enableUnsafeCtx } = context;
52
- const unsafeContext = {
53
- headers: request.headers
54
- };
50
+ const buildTemplateData = (context, data, renderLevel, tracker, config) => {
51
+ const { request } = context;
52
+ const { unsafeHeaders } = config;
53
+ const headers = unsafeHeaders ? Object.fromEntries(Object.entries(request.headers).filter(([key, _]) => {
54
+ var _unsafeHeaders_map;
55
+ return unsafeHeaders === null || unsafeHeaders === void 0 ? void 0 : (_unsafeHeaders_map = unsafeHeaders.map((header) => header.toLowerCase())) === null || _unsafeHeaders_map === void 0 ? void 0 : _unsafeHeaders_map.includes(key.toLowerCase());
56
+ })) : void 0;
55
57
  return {
56
58
  data,
57
59
  context: {
@@ -61,7 +63,7 @@ const buildTemplateData = (context, data, renderLevel, tracker) => {
61
63
  pathname: request.pathname,
62
64
  host: request.host,
63
65
  url: request.url,
64
- ...enableUnsafeCtx ? unsafeContext : {}
66
+ headers
65
67
  },
66
68
  reporter: {
67
69
  sessionId: tracker.sessionId
@@ -70,8 +72,7 @@ const buildTemplateData = (context, data, renderLevel, tracker) => {
70
72
  renderLevel
71
73
  };
72
74
  };
73
- var Entry;
74
- Entry = class Entry2 {
75
+ class Entry {
75
76
  async renderToHtml(context) {
76
77
  var _ssrContext_redirection, _ssrContext_redirection1, _ssrContext_redirection2;
77
78
  const ssrContext = context.ssrContext;
@@ -93,7 +94,7 @@ Entry = class Entry2 {
93
94
  loaderData: routerContext.loaderData,
94
95
  errors: (0, import_utils.serializeErrors)(routerContext.errors)
95
96
  } : void 0;
96
- const templateData = buildTemplateData(ssrContext, prefetchData, this.result.renderLevel, this.tracker);
97
+ const templateData = buildTemplateData(ssrContext, prefetchData, this.result.renderLevel, this.tracker, this.pluginConfig);
97
98
  const ssrDataScripts = this.getSSRDataScript(templateData, routerData);
98
99
  const html = (0, import_buildHtml.buildHtml)(this.template, [
99
100
  (0, import_buildHtml.createReplaceChunkCss)(this.result.chunksMap.css),
@@ -188,4 +189,4 @@ Entry = class Entry2 {
188
189
  }
189
190
  };
190
191
  }
191
- };
192
+ }
@@ -18,10 +18,15 @@ var __copyProps = (to, from, except, desc) => {
18
18
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
19
  var types_exports = {};
20
20
  __export(types_exports, {
21
- RenderLevel: () => import_type.RenderLevel
21
+ RenderLevel: () => RenderLevel
22
22
  });
23
23
  module.exports = __toCommonJS(types_exports);
24
- var import_type = require("./renderToString/type");
24
+ var RenderLevel;
25
+ (function(RenderLevel2) {
26
+ RenderLevel2[RenderLevel2["CLIENT_RENDER"] = 0] = "CLIENT_RENDER";
27
+ RenderLevel2[RenderLevel2["SERVER_PREFETCH"] = 1] = "SERVER_PREFETCH";
28
+ RenderLevel2[RenderLevel2["SERVER_RENDER"] = 2] = "SERVER_RENDER";
29
+ })(RenderLevel || (RenderLevel = {}));
25
30
  // Annotate the CommonJS export names for ESM import in node:
26
31
  0 && (module.exports = {
27
32
  RenderLevel
@@ -94,11 +94,11 @@ var ssrPlugin = function() {
94
94
  },
95
95
  tools: {
96
96
  bundlerChain: function bundlerChain(chain, param) {
97
- var isServer = param.isServer, isServiceWorker = param.isServiceWorker, CHAIN_ID = param.CHAIN_ID;
97
+ var isServer = param.isServer, isServiceWorker = param.isServiceWorker;
98
98
  var userConfig = api.useResolvedConfigContext();
99
99
  if (isUseSSRBundle(userConfig) && !isServer && !isServiceWorker && checkUseStringSSR(userConfig)) {
100
100
  var LoadableBundlerPlugin = require("./loadable-bundler-plugin.js");
101
- chain.plugin(CHAIN_ID.PLUGIN.LOADABLE).use(LoadableBundlerPlugin, [
101
+ chain.plugin("loadable").use(LoadableBundlerPlugin, [
102
102
  {
103
103
  filename: LOADABLE_STATS_FILE
104
104
  }
@@ -146,7 +146,7 @@ var ssrPlugin = function() {
146
146
  modifyEntryRuntimePlugins: function modifyEntryRuntimePlugins(param) {
147
147
  var entrypoint = param.entrypoint, plugins = param.plugins, bundlerConfigs = param.bundlerConfigs;
148
148
  if (ssrConfigMap.get(entrypoint.entryName)) {
149
- var _bundlerConfigs_find_output, _bundlerConfigs_find, _config_server;
149
+ var _bundlerConfigs_find_output, _bundlerConfigs_find, _config_server, _config_server1;
150
150
  var chunkLoadingGlobal = bundlerConfigs === null || bundlerConfigs === void 0 ? void 0 : (_bundlerConfigs_find = bundlerConfigs.find(function(config2) {
151
151
  return config2.name === "client";
152
152
  })) === null || _bundlerConfigs_find === void 0 ? void 0 : (_bundlerConfigs_find_output = _bundlerConfigs_find.output) === null || _bundlerConfigs_find_output === void 0 ? void 0 : _bundlerConfigs_find_output.chunkLoadingGlobal;
@@ -154,6 +154,7 @@ var ssrPlugin = function() {
154
154
  var _config_output = config.output, enableInlineScripts = _config_output.enableInlineScripts, enableInlineStyles = _config_output.enableInlineStyles;
155
155
  var _config_html = config.html, crossorigin = _config_html.crossorigin, scriptLoading = _config_html.scriptLoading;
156
156
  var disablePrerender = typeof ((_config_server = config.server) === null || _config_server === void 0 ? void 0 : _config_server.ssr) === "object" ? Boolean(config.server.ssr.disablePrerender) : false;
157
+ var unsafeHeaders = typeof ((_config_server1 = config.server) === null || _config_server1 === void 0 ? void 0 : _config_server1.ssr) === "object" ? config.server.ssr.unsafeHeaders : void 0;
157
158
  plugins.push({
158
159
  name: PLUGIN_IDENTIFIER,
159
160
  options: JSON.stringify(_object_spread_props(_object_spread({}, ssrConfigMap.get(entrypoint.entryName) || {}), {
@@ -162,7 +163,8 @@ var ssrPlugin = function() {
162
163
  chunkLoadingGlobal,
163
164
  disablePrerender,
164
165
  enableInlineScripts: typeof enableInlineScripts === "function" ? void 0 : enableInlineScripts,
165
- enableInlineStyles: typeof enableInlineStyles === "function" ? void 0 : enableInlineStyles
166
+ enableInlineStyles: typeof enableInlineStyles === "function" ? void 0 : enableInlineStyles,
167
+ unsafeHeaders
166
168
  }))
167
169
  });
168
170
  }
@@ -22,7 +22,7 @@ var ssr = function(config) {
22
22
  return {
23
23
  client: function() {
24
24
  var _ref = _async_to_generator(function(param) {
25
- var App, context, ModernRender, ModernHydrate, _window__SSR_DATA, _window, hydrateContext, callback, renderLevel;
25
+ var App, context, ModernRender, ModernHydrate, _window__SSR_DATA, _window, hydrateContext, ssrContext, _ssrContext_request, initialPathname, currentPathname, errorMsg, callback, renderLevel;
26
26
  function stringSSRHydrate() {
27
27
  if (renderLevel === RenderLevel.CLIENT_RENDER || renderLevel === RenderLevel.SERVER_PREFETCH) {
28
28
  ModernRender(/* @__PURE__ */ _jsx(App, {
@@ -85,6 +85,14 @@ var ssr = function(config) {
85
85
  },
86
86
  _hydration: true
87
87
  });
88
+ ssrContext = hydrateContext.ssrContext;
89
+ _ssrContext_request = ssrContext.request, initialPathname = _ssrContext_request.pathname;
90
+ currentPathname = window.location.pathname;
91
+ if (initialPathname !== currentPathname) {
92
+ errorMsg = "The initial URL ".concat(initialPathname, " and the URL ").concat(currentPathname, " to be hydrated do not match, reload.");
93
+ console.error(errorMsg);
94
+ window.location.reload();
95
+ }
88
96
  callback = function() {
89
97
  delete hydrateContext._hydration;
90
98
  };
@@ -2,7 +2,7 @@ import { _ as _async_to_generator } from "@swc/helpers/_/_async_to_generator";
2
2
  import { _ as _class_call_check } from "@swc/helpers/_/_class_call_check";
3
3
  import { _ as _create_class } from "@swc/helpers/_/_create_class";
4
4
  import { _ as _define_property } from "@swc/helpers/_/_define_property";
5
- import { _ as _object_spread } from "@swc/helpers/_/_object_spread";
5
+ import { _ as _sliced_to_array } from "@swc/helpers/_/_sliced_to_array";
6
6
  import { _ as _to_consumable_array } from "@swc/helpers/_/_to_consumable_array";
7
7
  import { _ as _ts_generator } from "@swc/helpers/_/_ts_generator";
8
8
  import React from "react";
@@ -20,21 +20,27 @@ import { createLoadableCollector } from "./loadable";
20
20
  import { createRender } from "./render";
21
21
  import { createStyledCollector } from "./styledComponent";
22
22
  import { buildHtml, createReplaceChunkCss, createReplaceChunkJs, createReplaceHtml, createReplaceSSRDataScript } from "./buildHtml";
23
- var buildTemplateData = function(context, data, renderLevel, tracker) {
24
- var request = context.request, enableUnsafeCtx = context.enableUnsafeCtx;
25
- var unsafeContext = {
26
- headers: request.headers
27
- };
23
+ var buildTemplateData = function(context, data, renderLevel, tracker, config) {
24
+ var request = context.request;
25
+ var unsafeHeaders = config.unsafeHeaders;
26
+ var headers = unsafeHeaders ? Object.fromEntries(Object.entries(request.headers).filter(function(param) {
27
+ var _param = _sliced_to_array(param, 2), key = _param[0], _ = _param[1];
28
+ var _unsafeHeaders_map;
29
+ return unsafeHeaders === null || unsafeHeaders === void 0 ? void 0 : (_unsafeHeaders_map = unsafeHeaders.map(function(header) {
30
+ return header.toLowerCase();
31
+ })) === null || _unsafeHeaders_map === void 0 ? void 0 : _unsafeHeaders_map.includes(key.toLowerCase());
32
+ })) : void 0;
28
33
  return {
29
34
  data,
30
35
  context: {
31
- request: _object_spread({
36
+ request: {
32
37
  params: request.params,
33
38
  query: request.query,
34
39
  pathname: request.pathname,
35
40
  host: request.host,
36
- url: request.url
37
- }, enableUnsafeCtx ? unsafeContext : {}),
41
+ url: request.url,
42
+ headers
43
+ },
38
44
  reporter: {
39
45
  sessionId: tracker.sessionId
40
46
  }
@@ -42,8 +48,7 @@ var buildTemplateData = function(context, data, renderLevel, tracker) {
42
48
  renderLevel
43
49
  };
44
50
  };
45
- var Entry;
46
- Entry = /* @__PURE__ */ function() {
51
+ var Entry = /* @__PURE__ */ function() {
47
52
  "use strict";
48
53
  function Entry2(options) {
49
54
  _class_call_check(this, Entry2);
@@ -131,7 +136,7 @@ Entry = /* @__PURE__ */ function() {
131
136
  loaderData: routerContext.loaderData,
132
137
  errors: serializeErrors(routerContext.errors)
133
138
  } : void 0;
134
- templateData = buildTemplateData(ssrContext, prefetchData, _this.result.renderLevel, _this.tracker);
139
+ templateData = buildTemplateData(ssrContext, prefetchData, _this.result.renderLevel, _this.tracker, _this.pluginConfig);
135
140
  ssrDataScripts = _this.getSSRDataScript(templateData, routerData);
136
141
  html = buildHtml(_this.template, [
137
142
  createReplaceChunkCss(_this.result.chunksMap.css),
@@ -1,4 +1,9 @@
1
- import { RenderLevel } from "./renderToString/type";
1
+ var RenderLevel;
2
+ (function(RenderLevel2) {
3
+ RenderLevel2[RenderLevel2["CLIENT_RENDER"] = 0] = "CLIENT_RENDER";
4
+ RenderLevel2[RenderLevel2["SERVER_PREFETCH"] = 1] = "SERVER_PREFETCH";
5
+ RenderLevel2[RenderLevel2["SERVER_RENDER"] = 2] = "SERVER_RENDER";
6
+ })(RenderLevel || (RenderLevel = {}));
2
7
  export {
3
8
  RenderLevel
4
9
  };
@@ -70,11 +70,11 @@ const ssrPlugin = () => ({
70
70
  }
71
71
  },
72
72
  tools: {
73
- bundlerChain(chain, { isServer, isServiceWorker, CHAIN_ID }) {
73
+ bundlerChain(chain, { isServer, isServiceWorker }) {
74
74
  const userConfig = api.useResolvedConfigContext();
75
75
  if (isUseSSRBundle(userConfig) && !isServer && !isServiceWorker && checkUseStringSSR(userConfig)) {
76
76
  const LoadableBundlerPlugin = require("./loadable-bundler-plugin.js");
77
- chain.plugin(CHAIN_ID.PLUGIN.LOADABLE).use(LoadableBundlerPlugin, [
77
+ chain.plugin("loadable").use(LoadableBundlerPlugin, [
78
78
  {
79
79
  filename: LOADABLE_STATS_FILE
80
80
  }
@@ -120,12 +120,13 @@ const ssrPlugin = () => ({
120
120
  },
121
121
  modifyEntryRuntimePlugins({ entrypoint, plugins, bundlerConfigs }) {
122
122
  if (ssrConfigMap.get(entrypoint.entryName)) {
123
- var _bundlerConfigs_find_output, _bundlerConfigs_find, _config_server;
123
+ var _bundlerConfigs_find_output, _bundlerConfigs_find, _config_server, _config_server1;
124
124
  const chunkLoadingGlobal = bundlerConfigs === null || bundlerConfigs === void 0 ? void 0 : (_bundlerConfigs_find = bundlerConfigs.find((config2) => config2.name === "client")) === null || _bundlerConfigs_find === void 0 ? void 0 : (_bundlerConfigs_find_output = _bundlerConfigs_find.output) === null || _bundlerConfigs_find_output === void 0 ? void 0 : _bundlerConfigs_find_output.chunkLoadingGlobal;
125
125
  const config = api.useResolvedConfigContext();
126
126
  const { enableInlineScripts, enableInlineStyles } = config.output;
127
127
  const { crossorigin, scriptLoading } = config.html;
128
128
  const disablePrerender = typeof ((_config_server = config.server) === null || _config_server === void 0 ? void 0 : _config_server.ssr) === "object" ? Boolean(config.server.ssr.disablePrerender) : false;
129
+ const unsafeHeaders = typeof ((_config_server1 = config.server) === null || _config_server1 === void 0 ? void 0 : _config_server1.ssr) === "object" ? config.server.ssr.unsafeHeaders : void 0;
129
130
  plugins.push({
130
131
  name: PLUGIN_IDENTIFIER,
131
132
  options: JSON.stringify({
@@ -135,7 +136,8 @@ const ssrPlugin = () => ({
135
136
  chunkLoadingGlobal,
136
137
  disablePrerender,
137
138
  enableInlineScripts: typeof enableInlineScripts === "function" ? void 0 : enableInlineScripts,
138
- enableInlineStyles: typeof enableInlineStyles === "function" ? void 0 : enableInlineStyles
139
+ enableInlineStyles: typeof enableInlineStyles === "function" ? void 0 : enableInlineStyles,
140
+ unsafeHeaders
139
141
  })
140
142
  });
141
143
  }
@@ -24,6 +24,14 @@ const ssr = (config) => ({
24
24
  },
25
25
  _hydration: true
26
26
  };
27
+ const { ssrContext } = hydrateContext;
28
+ const { pathname: initialPathname } = ssrContext.request;
29
+ const currentPathname = window.location.pathname;
30
+ if (initialPathname !== currentPathname) {
31
+ const errorMsg = `The initial URL ${initialPathname} and the URL ${currentPathname} to be hydrated do not match, reload.`;
32
+ console.error(errorMsg);
33
+ window.location.reload();
34
+ }
27
35
  const callback = () => {
28
36
  delete hydrateContext._hydration;
29
37
  };
@@ -14,11 +14,13 @@ import { createLoadableCollector } from "./loadable";
14
14
  import { createRender } from "./render";
15
15
  import { createStyledCollector } from "./styledComponent";
16
16
  import { buildHtml, createReplaceChunkCss, createReplaceChunkJs, createReplaceHtml, createReplaceSSRDataScript } from "./buildHtml";
17
- const buildTemplateData = (context, data, renderLevel, tracker) => {
18
- const { request, enableUnsafeCtx } = context;
19
- const unsafeContext = {
20
- headers: request.headers
21
- };
17
+ const buildTemplateData = (context, data, renderLevel, tracker, config) => {
18
+ const { request } = context;
19
+ const { unsafeHeaders } = config;
20
+ const headers = unsafeHeaders ? Object.fromEntries(Object.entries(request.headers).filter(([key, _]) => {
21
+ var _unsafeHeaders_map;
22
+ return unsafeHeaders === null || unsafeHeaders === void 0 ? void 0 : (_unsafeHeaders_map = unsafeHeaders.map((header) => header.toLowerCase())) === null || _unsafeHeaders_map === void 0 ? void 0 : _unsafeHeaders_map.includes(key.toLowerCase());
23
+ })) : void 0;
22
24
  return {
23
25
  data,
24
26
  context: {
@@ -28,7 +30,7 @@ const buildTemplateData = (context, data, renderLevel, tracker) => {
28
30
  pathname: request.pathname,
29
31
  host: request.host,
30
32
  url: request.url,
31
- ...enableUnsafeCtx ? unsafeContext : {}
33
+ headers
32
34
  },
33
35
  reporter: {
34
36
  sessionId: tracker.sessionId
@@ -37,8 +39,7 @@ const buildTemplateData = (context, data, renderLevel, tracker) => {
37
39
  renderLevel
38
40
  };
39
41
  };
40
- var Entry;
41
- Entry = class Entry2 {
42
+ class Entry {
42
43
  async renderToHtml(context) {
43
44
  var _ssrContext_redirection, _ssrContext_redirection1, _ssrContext_redirection2;
44
45
  const ssrContext = context.ssrContext;
@@ -60,7 +61,7 @@ Entry = class Entry2 {
60
61
  loaderData: routerContext.loaderData,
61
62
  errors: serializeErrors(routerContext.errors)
62
63
  } : void 0;
63
- const templateData = buildTemplateData(ssrContext, prefetchData, this.result.renderLevel, this.tracker);
64
+ const templateData = buildTemplateData(ssrContext, prefetchData, this.result.renderLevel, this.tracker, this.pluginConfig);
64
65
  const ssrDataScripts = this.getSSRDataScript(templateData, routerData);
65
66
  const html = buildHtml(this.template, [
66
67
  createReplaceChunkCss(this.result.chunksMap.css),
@@ -155,7 +156,7 @@ Entry = class Entry2 {
155
156
  }
156
157
  };
157
158
  }
158
- };
159
+ }
159
160
  export {
160
161
  Entry as default
161
162
  };
@@ -1,4 +1,9 @@
1
- import { RenderLevel } from "./renderToString/type";
1
+ var RenderLevel;
2
+ (function(RenderLevel2) {
3
+ RenderLevel2[RenderLevel2["CLIENT_RENDER"] = 0] = "CLIENT_RENDER";
4
+ RenderLevel2[RenderLevel2["SERVER_PREFETCH"] = 1] = "SERVER_PREFETCH";
5
+ RenderLevel2[RenderLevel2["SERVER_RENDER"] = 2] = "SERVER_RENDER";
6
+ })(RenderLevel || (RenderLevel = {}));
2
7
  export {
3
8
  RenderLevel
4
9
  };
@@ -1,6 +1,5 @@
1
- import { RuntimeContext, ModernSSRReactComponent, SSRPluginConfig, SSRServerContext } from '../types';
1
+ import { RuntimeContext, ModernSSRReactComponent, SSRPluginConfig, SSRServerContext, RenderResult } from '../types';
2
2
  import { SSRTracker } from '../tracker';
3
- import { RenderResult } from './type';
4
3
  type EntryOptions = {
5
4
  ctx: SSRServerContext;
6
5
  App: ModernSSRReactComponent;
@@ -1,6 +1,5 @@
1
1
  import { ReactElement } from 'react';
2
- import { SSRPluginConfig } from '../types';
3
- import { RenderResult } from './type';
2
+ import { SSRPluginConfig, RenderResult } from '../types';
4
3
  import type { Collector } from './render';
5
4
  declare class LoadableCollector implements Collector {
6
5
  private options;
@@ -1,6 +1,6 @@
1
1
  import { ServerStyleSheet } from 'styled-components';
2
2
  import { ReactElement } from 'react';
3
- import type { RenderResult } from './type';
3
+ import type { RenderResult } from '../types';
4
4
  import type { Collector } from './render';
5
5
  declare class StyledCollector implements Collector {
6
6
  sheet: ServerStyleSheet;
@@ -2,9 +2,21 @@
2
2
  import { ServerUserConfig } from '@modern-js/app-tools';
3
3
  import type { BaseSSRServerContext } from '@modern-js/types';
4
4
  import type { RuntimeContext } from '../../core';
5
- import { RenderLevel } from './renderToString/type';
6
5
  import type { BuildHtmlCb } from './renderToString/buildHtml';
7
6
  import type { SSRTracker } from './tracker';
7
+ export declare enum RenderLevel {
8
+ CLIENT_RENDER = 0,
9
+ SERVER_PREFETCH = 1,
10
+ SERVER_RENDER = 2
11
+ }
12
+ export type RenderResult = {
13
+ renderLevel: RenderLevel;
14
+ html?: string;
15
+ chunksMap: {
16
+ js: string;
17
+ css: string;
18
+ };
19
+ };
8
20
  export type SSRServerContext = BaseSSRServerContext & {
9
21
  request: BaseSSRServerContext['request'] & {
10
22
  userAgent: string;
@@ -15,7 +27,7 @@ export type SSRServerContext = BaseSSRServerContext & {
15
27
  tracker: SSRTracker;
16
28
  };
17
29
  export type ModernSSRReactComponent = React.ComponentType<any>;
18
- export { RuntimeContext, RenderLevel };
30
+ export { RuntimeContext };
19
31
  export type SSRPluginConfig = {
20
32
  crossorigin?: boolean | 'anonymous' | 'use-credentials';
21
33
  scriptLoading?: 'defer' | 'blocking' | 'module';
@@ -23,6 +35,7 @@ export type SSRPluginConfig = {
23
35
  enableInlineScripts?: boolean | RegExp;
24
36
  disablePrerender?: boolean;
25
37
  chunkLoadingGlobal?: string;
38
+ unsafeHeaders?: string[];
26
39
  } & Exclude<ServerUserConfig['ssr'], boolean>;
27
40
  export type ServerRenderOptions = {
28
41
  App: ModernSSRReactComponent;
package/package.json CHANGED
@@ -15,7 +15,7 @@
15
15
  "modern",
16
16
  "modern.js"
17
17
  ],
18
- "version": "0.0.0-nightly-20231219170633",
18
+ "version": "0.0.0-nightly-20231221170655",
19
19
  "engines": {
20
20
  "node": ">=14.17.6"
21
21
  },
@@ -171,10 +171,10 @@
171
171
  "react-side-effect": "^2.1.1",
172
172
  "styled-components": "^5.3.1",
173
173
  "@swc/helpers": "0.5.3",
174
- "@modern-js/plugin": "0.0.0-nightly-20231219170633",
175
- "@modern-js/types": "0.0.0-nightly-20231219170633",
176
- "@modern-js/utils": "0.0.0-nightly-20231219170633",
177
- "@modern-js/runtime-utils": "0.0.0-nightly-20231219170633"
174
+ "@modern-js/plugin": "0.0.0-nightly-20231221170655",
175
+ "@modern-js/types": "0.0.0-nightly-20231221170655",
176
+ "@modern-js/utils": "0.0.0-nightly-20231221170655",
177
+ "@modern-js/runtime-utils": "0.0.0-nightly-20231221170655"
178
178
  },
179
179
  "peerDependencies": {
180
180
  "react": ">=17",
@@ -195,11 +195,11 @@
195
195
  "ts-jest": "^29.1.0",
196
196
  "typescript": "^5",
197
197
  "webpack": "^5.89.0",
198
- "@modern-js/core": "0.0.0-nightly-20231219170633",
199
- "@modern-js/app-tools": "0.0.0-nightly-20231219170633",
200
- "@scripts/build": "0.0.0-nightly-20231219170633",
201
- "@modern-js/server-core": "0.0.0-nightly-20231219170633",
202
- "@scripts/jest-config": "0.0.0-nightly-20231219170633"
198
+ "@modern-js/server-core": "0.0.0-nightly-20231221170655",
199
+ "@modern-js/app-tools": "0.0.0-nightly-20231221170655",
200
+ "@modern-js/core": "0.0.0-nightly-20231221170655",
201
+ "@scripts/build": "0.0.0-nightly-20231221170655",
202
+ "@scripts/jest-config": "0.0.0-nightly-20231221170655"
203
203
  },
204
204
  "sideEffects": false,
205
205
  "publishConfig": {
@@ -1,33 +0,0 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
- var type_exports = {};
20
- __export(type_exports, {
21
- RenderLevel: () => RenderLevel
22
- });
23
- module.exports = __toCommonJS(type_exports);
24
- var RenderLevel;
25
- (function(RenderLevel2) {
26
- RenderLevel2[RenderLevel2["CLIENT_RENDER"] = 0] = "CLIENT_RENDER";
27
- RenderLevel2[RenderLevel2["SERVER_PREFETCH"] = 1] = "SERVER_PREFETCH";
28
- RenderLevel2[RenderLevel2["SERVER_RENDER"] = 2] = "SERVER_RENDER";
29
- })(RenderLevel || (RenderLevel = {}));
30
- // Annotate the CommonJS export names for ESM import in node:
31
- 0 && (module.exports = {
32
- RenderLevel
33
- });
@@ -1,9 +0,0 @@
1
- var RenderLevel;
2
- (function(RenderLevel2) {
3
- RenderLevel2[RenderLevel2["CLIENT_RENDER"] = 0] = "CLIENT_RENDER";
4
- RenderLevel2[RenderLevel2["SERVER_PREFETCH"] = 1] = "SERVER_PREFETCH";
5
- RenderLevel2[RenderLevel2["SERVER_RENDER"] = 2] = "SERVER_RENDER";
6
- })(RenderLevel || (RenderLevel = {}));
7
- export {
8
- RenderLevel
9
- };
@@ -1,9 +0,0 @@
1
- var RenderLevel;
2
- (function(RenderLevel2) {
3
- RenderLevel2[RenderLevel2["CLIENT_RENDER"] = 0] = "CLIENT_RENDER";
4
- RenderLevel2[RenderLevel2["SERVER_PREFETCH"] = 1] = "SERVER_PREFETCH";
5
- RenderLevel2[RenderLevel2["SERVER_RENDER"] = 2] = "SERVER_RENDER";
6
- })(RenderLevel || (RenderLevel = {}));
7
- export {
8
- RenderLevel
9
- };
@@ -1,13 +0,0 @@
1
- export declare enum RenderLevel {
2
- CLIENT_RENDER = 0,
3
- SERVER_PREFETCH = 1,
4
- SERVER_RENDER = 2
5
- }
6
- export type RenderResult = {
7
- renderLevel: RenderLevel;
8
- html?: string;
9
- chunksMap: {
10
- js: string;
11
- css: string;
12
- };
13
- };