@umijs/server 4.0.42 → 4.0.44

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/scripts.js CHANGED
@@ -16,7 +16,10 @@ var __copyProps = (to, from, except, desc) => {
16
16
  }
17
17
  return to;
18
18
  };
19
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod));
19
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
21
+ mod
22
+ ));
20
23
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
21
24
 
22
25
  // src/scripts.ts
@@ -38,7 +41,10 @@ function normalizeScript(script) {
38
41
  src: script
39
42
  } : { content: script };
40
43
  } else if (typeof script === "object") {
41
- (0, import_assert.default)(typeof script.src === "string" || typeof script.content === "string", `Script must have either a "src" or a "content" property.`);
44
+ (0, import_assert.default)(
45
+ typeof script.src === "string" || typeof script.content === "string",
46
+ `Script must have either a "src" or a "content" property.`
47
+ );
42
48
  return script;
43
49
  } else {
44
50
  throw new Error(`Invalid script type: ${typeof script}`);
package/dist/server.js CHANGED
@@ -16,7 +16,10 @@ var __copyProps = (to, from, except, desc) => {
16
16
  }
17
17
  return to;
18
18
  };
19
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod));
19
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
21
+ mod
22
+ ));
20
23
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
21
24
 
22
25
  // src/server.ts
@@ -31,7 +34,9 @@ var import_server = __toESM(require("react-dom/server"));
31
34
  var import_scripts = require("./scripts");
32
35
  var import_styles = require("./styles");
33
36
  async function getMarkup(opts) {
34
- let markup = import_server.default.renderToString(import_react.default.createElement("div", { id: opts.mountElementId || "root" }));
37
+ let markup = import_server.default.renderToString(
38
+ import_react.default.createElement("div", { id: opts.mountElementId || "root" })
39
+ );
35
40
  function propsToString(opts2) {
36
41
  return Object.keys(opts2.props).filter((key) => {
37
42
  const isValidBoolean = opts2.props[key] !== false;
@@ -90,10 +95,16 @@ async function getMarkup(opts) {
90
95
  });
91
96
  }
92
97
  const title = opts.title ? `<title>${opts.title}</title>` : "";
93
- const metas = withDefaultMetas(opts.metas).map((meta) => getTagContent({ attrs: meta, tagName: "meta" }));
94
- const links = (opts.links || []).map((link) => getTagContent({ attrs: link, tagName: "link" }));
98
+ const metas = withDefaultMetas(opts.metas).map(
99
+ (meta) => getTagContent({ attrs: meta, tagName: "meta" })
100
+ );
101
+ const links = (opts.links || []).map(
102
+ (link) => getTagContent({ attrs: link, tagName: "link" })
103
+ );
95
104
  const styles = (0, import_styles.normalizeStyles)(opts.styles || []).map(getStyleContent);
96
- const headScripts = (0, import_scripts.normalizeScripts)(opts.headScripts || []).map(getScriptContent);
105
+ const headScripts = (0, import_scripts.normalizeScripts)(opts.headScripts || []).map(
106
+ getScriptContent
107
+ );
97
108
  const scripts = (0, import_scripts.normalizeScripts)(opts.scripts || []).map(getScriptContent);
98
109
  markup = [
99
110
  `<!DOCTYPE html>
package/dist/ssr.js CHANGED
@@ -55,10 +55,14 @@ function createJSXGenerator(opts) {
55
55
  return;
56
56
  }
57
57
  const loaderData = {};
58
- await Promise.all(matches.filter((id) => routes[id].hasServerLoader).map((id) => new Promise(async (resolve) => {
59
- loaderData[id] = await executeLoader(id, routesWithServerLoader);
60
- resolve();
61
- })));
58
+ await Promise.all(
59
+ matches.filter((id) => routes[id].hasServerLoader).map(
60
+ (id) => new Promise(async (resolve) => {
61
+ loaderData[id] = await executeLoader(id, routesWithServerLoader);
62
+ resolve();
63
+ })
64
+ )
65
+ );
62
66
  const manifest = typeof opts.manifest === "function" ? opts.manifest() : opts.manifest;
63
67
  const context = {
64
68
  routes,
@@ -88,14 +92,17 @@ function createMarkupGenerator(opts) {
88
92
  };
89
93
  writable.on("finish", () => {
90
94
  let html = Buffer.concat(chunks).toString("utf8");
91
- html = html.replace(/(<\/head>)/, [
92
- opts.helmetContext.helmet.title.toString(),
93
- opts.helmetContext.helmet.priority.toString(),
94
- opts.helmetContext.helmet.meta.toString(),
95
- opts.helmetContext.helmet.link.toString(),
96
- opts.helmetContext.helmet.script.toString(),
97
- "$1"
98
- ].filter(Boolean).join("\n"));
95
+ html = html.replace(
96
+ /(<\/head>)/,
97
+ [
98
+ opts.helmetContext.helmet.title.toString(),
99
+ opts.helmetContext.helmet.priority.toString(),
100
+ opts.helmetContext.helmet.meta.toString(),
101
+ opts.helmetContext.helmet.link.toString(),
102
+ opts.helmetContext.helmet.script.toString(),
103
+ "$1"
104
+ ].filter(Boolean).join("\n")
105
+ );
99
106
  resolve(html);
100
107
  });
101
108
  const stream = (0, import_server.renderToPipeableStream)(jsx.element, {
@@ -113,7 +120,10 @@ function createRequestHandler(opts) {
113
120
  const jsxGeneratorDeferrer = createJSXGenerator(opts);
114
121
  return async function(req, res, next) {
115
122
  if (req.url.startsWith("/__serverLoader") && req.query.route) {
116
- const data = await executeLoader(req.query.route, opts.routesWithServerLoader);
123
+ const data = await executeLoader(
124
+ req.query.route,
125
+ opts.routesWithServerLoader
126
+ );
117
127
  res.status(200).json(data);
118
128
  return;
119
129
  }
@@ -134,7 +144,9 @@ function createRequestHandler(opts) {
134
144
  }
135
145
  function matchRoutesForSSR(reqUrl, routesById) {
136
146
  var _a;
137
- return ((_a = (0, import_react_router_dom.matchRoutes)(createClientRoutes({ routesById }), reqUrl)) == null ? void 0 : _a.map((route) => route.route.id)) || [];
147
+ return ((_a = (0, import_react_router_dom.matchRoutes)(createClientRoutes({ routesById }), reqUrl)) == null ? void 0 : _a.map(
148
+ (route) => route.route.id
149
+ )) || [];
138
150
  }
139
151
  function createClientRoutes(opts) {
140
152
  const { routesById, parentId } = opts;
package/dist/styles.js CHANGED
@@ -16,7 +16,10 @@ var __copyProps = (to, from, except, desc) => {
16
16
  }
17
17
  return to;
18
18
  };
19
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod));
19
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
21
+ mod
22
+ ));
20
23
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
21
24
 
22
25
  // src/styles.ts
@@ -38,7 +41,10 @@ function normalizeStyle(style) {
38
41
  src: style
39
42
  } : { content: style };
40
43
  } else if (typeof style === "object") {
41
- (0, import_assert.default)(typeof style.src === "string" || typeof style.content === "string", `Style must have either a "src" or a "content" property.`);
44
+ (0, import_assert.default)(
45
+ typeof style.src === "string" || typeof style.content === "string",
46
+ `Style must have either a "src" or a "content" property.`
47
+ );
42
48
  return style;
43
49
  } else {
44
50
  throw new Error(`Invalid style type: ${typeof style}`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@umijs/server",
3
- "version": "4.0.42",
3
+ "version": "4.0.44",
4
4
  "description": "@umijs/server",
5
5
  "homepage": "https://github.com/umijs/umi/tree/master/packages/server#readme",
6
6
  "bugs": "https://github.com/umijs/umi/issues",
@@ -20,7 +20,7 @@
20
20
  "dev": "umi-scripts father dev"
21
21
  },
22
22
  "dependencies": {
23
- "@umijs/bundler-utils": "4.0.42",
23
+ "@umijs/bundler-utils": "4.0.44",
24
24
  "history": "5.3.0",
25
25
  "react": "18.1.0",
26
26
  "react-dom": "18.1.0",