@jsenv/core 39.5.21 → 39.5.23

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.
@@ -4851,7 +4851,7 @@ const writeHead = (
4851
4851
  if (statusText === undefined) {
4852
4852
  statusText = statusTextFromStatus(status);
4853
4853
  } else {
4854
- statusText = statusText.replace(/\\n/g, "\n");
4854
+ statusText = statusText.replace(/\n/g, "");
4855
4855
  }
4856
4856
  if (responseIsServerHttp2Stream) {
4857
4857
  nodeHeaders = {
@@ -11530,7 +11530,9 @@ const assertAndNormalizeReturnValue = (hook, returnValue, info) => {
11530
11530
  if (!returnValueAssertion.appliesTo.includes(hook.name)) {
11531
11531
  continue;
11532
11532
  }
11533
- const assertionResult = returnValueAssertion.assertion(returnValue, info);
11533
+ const assertionResult = returnValueAssertion.assertion(returnValue, info, {
11534
+ hook,
11535
+ });
11534
11536
  if (assertionResult !== undefined) {
11535
11537
  // normalization
11536
11538
  returnValue = assertionResult;
@@ -11544,7 +11546,7 @@ const returnValueAssertions = [
11544
11546
  {
11545
11547
  name: "url_assertion",
11546
11548
  appliesTo: ["resolveReference", "redirectReference"],
11547
- assertion: (valueReturned) => {
11549
+ assertion: (valueReturned, urlInfo, { hook }) => {
11548
11550
  if (valueReturned instanceof URL) {
11549
11551
  return valueReturned.href;
11550
11552
  }
@@ -11552,7 +11554,7 @@ const returnValueAssertions = [
11552
11554
  return undefined;
11553
11555
  }
11554
11556
  throw new Error(
11555
- `Unexpected value returned by plugin: it must be a string; got ${valueReturned}`,
11557
+ `Unexpected value returned by "${hook.plugin.name}" plugin: it must be a string; got ${valueReturned}`,
11556
11558
  );
11557
11559
  },
11558
11560
  },
@@ -11564,7 +11566,7 @@ const returnValueAssertions = [
11564
11566
  "finalizeUrlContent",
11565
11567
  "optimizeUrlContent",
11566
11568
  ],
11567
- assertion: (valueReturned, urlInfo) => {
11569
+ assertion: (valueReturned, urlInfo, { hook }) => {
11568
11570
  if (typeof valueReturned === "string" || Buffer.isBuffer(valueReturned)) {
11569
11571
  return { content: valueReturned };
11570
11572
  }
@@ -11575,13 +11577,13 @@ const returnValueAssertions = [
11575
11577
  }
11576
11578
  if (typeof content !== "string" && !Buffer.isBuffer(content) && !body) {
11577
11579
  throw new Error(
11578
- `Unexpected "content" returned by plugin: it must be a string or a buffer; got ${content}`,
11580
+ `Unexpected "content" returned by "${hook.plugin.name}" ${hook.name} hook: it must be a string or a buffer; got ${content}`,
11579
11581
  );
11580
11582
  }
11581
11583
  return undefined;
11582
11584
  }
11583
11585
  throw new Error(
11584
- `Unexpected value returned by plugin: it must be a string, a buffer or an object; got ${valueReturned}`,
11586
+ `Unexpected value returned by "${hook.plugin.name}" ${hook.name} hook: it must be a string, a buffer or an object; got ${valueReturned}`,
11585
11587
  );
11586
11588
  },
11587
11589
  },
@@ -19908,13 +19910,13 @@ const injectImportMetaHot = (urlInfo, importMetaHotClientFileUrl) => {
19908
19910
  expectedType: "js_module",
19909
19911
  specifier: importMetaHotClientFileUrl,
19910
19912
  });
19911
- const magicSource = createMagicSource(urlInfo.content);
19912
- magicSource.prepend(
19913
- `import { createImportMetaHot } from ${importMetaHotClientFileReference.generatedSpecifier};
19913
+ let content = urlInfo.content;
19914
+ let prelude = `import { createImportMetaHot } from ${importMetaHotClientFileReference.generatedSpecifier};
19914
19915
  import.meta.hot = createImportMetaHot(import.meta.url);
19915
- `,
19916
- );
19917
- return magicSource.toContentAndSourcemap();
19916
+ `;
19917
+ return {
19918
+ content: `${prelude.replace(/\n/g, "")}${content}`,
19919
+ };
19918
19920
  };
19919
19921
 
19920
19922
  const jsenvPluginAutoreloadClient = () => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jsenv/core",
3
- "version": "39.5.21",
3
+ "version": "39.5.23",
4
4
  "description": "Tool to develop, test and build js projects",
5
5
  "license": "MIT",
6
6
  "author": {
@@ -78,10 +78,10 @@
78
78
  "@jsenv/node-esm-resolution": "1.0.6",
79
79
  "@jsenv/plugin-bundling": "2.7.16",
80
80
  "@jsenv/plugin-minification": "1.5.10",
81
- "@jsenv/plugin-supervisor": "1.5.26",
81
+ "@jsenv/plugin-supervisor": "1.5.27",
82
82
  "@jsenv/plugin-transpilation": "1.4.84",
83
83
  "@jsenv/runtime-compat": "1.3.1",
84
- "@jsenv/server": "15.3.2",
84
+ "@jsenv/server": "15.3.3",
85
85
  "@jsenv/sourcemap": "1.2.25",
86
86
  "@jsenv/url-meta": "8.5.2",
87
87
  "@jsenv/urls": "2.5.2",
@@ -109,11 +109,11 @@ const injectImportMetaHot = (urlInfo, importMetaHotClientFileUrl) => {
109
109
  expectedType: "js_module",
110
110
  specifier: importMetaHotClientFileUrl,
111
111
  });
112
- const magicSource = createMagicSource(urlInfo.content);
113
- magicSource.prepend(
114
- `import { createImportMetaHot } from ${importMetaHotClientFileReference.generatedSpecifier};
112
+ let content = urlInfo.content;
113
+ let prelude = `import { createImportMetaHot } from ${importMetaHotClientFileReference.generatedSpecifier};
115
114
  import.meta.hot = createImportMetaHot(import.meta.url);
116
- `,
117
- );
118
- return magicSource.toContentAndSourcemap();
115
+ `;
116
+ return {
117
+ content: `${prelude.replace(/\n/g, "")}${content}`,
118
+ };
119
119
  };
@@ -324,7 +324,9 @@ const assertAndNormalizeReturnValue = (hook, returnValue, info) => {
324
324
  if (!returnValueAssertion.appliesTo.includes(hook.name)) {
325
325
  continue;
326
326
  }
327
- const assertionResult = returnValueAssertion.assertion(returnValue, info);
327
+ const assertionResult = returnValueAssertion.assertion(returnValue, info, {
328
+ hook,
329
+ });
328
330
  if (assertionResult !== undefined) {
329
331
  // normalization
330
332
  returnValue = assertionResult;
@@ -338,7 +340,7 @@ const returnValueAssertions = [
338
340
  {
339
341
  name: "url_assertion",
340
342
  appliesTo: ["resolveReference", "redirectReference"],
341
- assertion: (valueReturned) => {
343
+ assertion: (valueReturned, urlInfo, { hook }) => {
342
344
  if (valueReturned instanceof URL) {
343
345
  return valueReturned.href;
344
346
  }
@@ -346,7 +348,7 @@ const returnValueAssertions = [
346
348
  return undefined;
347
349
  }
348
350
  throw new Error(
349
- `Unexpected value returned by plugin: it must be a string; got ${valueReturned}`,
351
+ `Unexpected value returned by "${hook.plugin.name}" plugin: it must be a string; got ${valueReturned}`,
350
352
  );
351
353
  },
352
354
  },
@@ -358,7 +360,7 @@ const returnValueAssertions = [
358
360
  "finalizeUrlContent",
359
361
  "optimizeUrlContent",
360
362
  ],
361
- assertion: (valueReturned, urlInfo) => {
363
+ assertion: (valueReturned, urlInfo, { hook }) => {
362
364
  if (typeof valueReturned === "string" || Buffer.isBuffer(valueReturned)) {
363
365
  return { content: valueReturned };
364
366
  }
@@ -369,13 +371,13 @@ const returnValueAssertions = [
369
371
  }
370
372
  if (typeof content !== "string" && !Buffer.isBuffer(content) && !body) {
371
373
  throw new Error(
372
- `Unexpected "content" returned by plugin: it must be a string or a buffer; got ${content}`,
374
+ `Unexpected "content" returned by "${hook.plugin.name}" ${hook.name} hook: it must be a string or a buffer; got ${content}`,
373
375
  );
374
376
  }
375
377
  return undefined;
376
378
  }
377
379
  throw new Error(
378
- `Unexpected value returned by plugin: it must be a string, a buffer or an object; got ${valueReturned}`,
380
+ `Unexpected value returned by "${hook.plugin.name}" ${hook.name} hook: it must be a string, a buffer or an object; got ${valueReturned}`,
379
381
  );
380
382
  },
381
383
  },