@jsenv/core 38.4.20 → 39.0.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.
@@ -1,4 +1,4 @@
1
- import { readdir, chmod, stat, lstat, promises, writeFileSync as writeFileSync$1, mkdirSync, unlink, openSync, closeSync, rmdir, watch, readdirSync, statSync, createReadStream, lstatSync, readFile, existsSync, readFileSync, realpathSync } from "node:fs";
1
+ import { readdir, chmod, stat, lstat, promises, readFileSync, writeFileSync as writeFileSync$1, mkdirSync, unlink, openSync, closeSync, rmdir, watch, readdirSync, statSync, createReadStream, lstatSync, readFile, existsSync, realpathSync } from "node:fs";
2
2
  import process$1 from "node:process";
3
3
  import os, { networkInterfaces } from "node:os";
4
4
  import tty from "node:tty";
@@ -3233,6 +3233,9 @@ const writeDirectory = async (
3233
3233
  const writeFileSync = (destination, content = "") => {
3234
3234
  const destinationUrl = assertAndNormalizeFileUrl(destination);
3235
3235
  const destinationUrlObject = new URL(destinationUrl);
3236
+ if (content && content instanceof URL) {
3237
+ content = readFileSync(content);
3238
+ }
3236
3239
  try {
3237
3240
  writeFileSync$1(destinationUrlObject, content);
3238
3241
  } catch (error) {
@@ -4576,7 +4579,7 @@ const stringifyServerTimingHeader = (serverTimingHeader) => {
4576
4579
  // https://www.w3.org/TR/2019/WD-server-timing-20190307/#the-server-timing-header-field
4577
4580
  // https://tools.ietf.org/html/rfc7230#section-3.2.6
4578
4581
  const validateServerTimingName = (name) => {
4579
- const valid = /^[!#$%&'*+\-.^_`|~0-9a-z]+$/gi.test(name);
4582
+ const valid = /^[!#$%&'*+\-.^_`|~0-9a-z]+$/i.test(name);
4580
4583
  if (!valid) {
4581
4584
  console.warn(`server timing contains invalid symbols`);
4582
4585
  return false;
@@ -5126,7 +5129,7 @@ const onceReadableStreamUsedOrClosed = (readableStream, callback) => {
5126
5129
 
5127
5130
  const normalizeHeaderName = (headerName) => {
5128
5131
  headerName = String(headerName);
5129
- if (/[^a-z0-9\-#$%&'*+.\^_`|~]/i.test(headerName)) {
5132
+ if (/[^a-z0-9\-#$%&'*+.^_`|~]/i.test(headerName)) {
5130
5133
  throw new TypeError("Invalid character in header field name");
5131
5134
  }
5132
5135
 
@@ -9141,15 +9144,15 @@ const JS_QUOTE_REPLACEMENTS = {
9141
9144
  * ```js
9142
9145
  * const file = "./style.css"
9143
9146
  * const type = "css"
9144
- * import(file, { assert: { type }})
9147
+ * import(file, { with: { type }})
9145
9148
  * ```
9146
9149
  * Jsenv could throw an error when it knows some browsers in runtimeCompat
9147
- * do not support import assertions
9150
+ * do not support import attributes
9148
9151
  * But for now (as it is simpler) we let the browser throw the error
9149
9152
  */
9150
9153
 
9151
9154
 
9152
- const jsenvPluginImportAssertions = ({
9155
+ const jsenvPluginImportAttributes = ({
9153
9156
  json = "auto",
9154
9157
  css = "auto",
9155
9158
  text = "auto",
@@ -9172,17 +9175,17 @@ const jsenvPluginImportAssertions = ({
9172
9175
  } else {
9173
9176
  const { importTypeAttributeNode } = reference.astInfo;
9174
9177
  const content = reference.ownerUrlInfo.content;
9175
- const assertKeyboardStart = content.indexOf(
9176
- "assert",
9177
- importTypeAttributeNode.start - " assert { ".length,
9178
+ const withKeywordStart = content.indexOf(
9179
+ "with",
9180
+ importTypeAttributeNode.start - " with { ".length,
9178
9181
  );
9179
- const assertKeywordEnd = content.indexOf(
9182
+ const withKeywordEnd = content.indexOf(
9180
9183
  "}",
9181
9184
  importTypeAttributeNode.end,
9182
9185
  );
9183
9186
  magicSource.remove({
9184
- start: assertKeyboardStart,
9185
- end: assertKeywordEnd + 1,
9187
+ start: withKeywordStart,
9188
+ end: withKeywordEnd + 1,
9186
9189
  });
9187
9190
  }
9188
9191
  };
@@ -10161,7 +10164,7 @@ const analyzeConstructableStyleSheetUsage = (urlInfo) => {
10161
10164
  // import('./' + moduleName)
10162
10165
  return false;
10163
10166
  }
10164
- if (hasImportTypeCssAssertion(node)) {
10167
+ if (hasImportTypeCssAttribute(node)) {
10165
10168
  return node;
10166
10169
  }
10167
10170
  if (hasCssModuleQueryParam(source)) {
@@ -10174,7 +10177,7 @@ const analyzeConstructableStyleSheetUsage = (urlInfo) => {
10174
10177
  if (hasCssModuleQueryParam(source)) {
10175
10178
  return source;
10176
10179
  }
10177
- if (hasImportTypeCssAssertion(node)) {
10180
+ if (hasImportTypeCssAttribute(node)) {
10178
10181
  return node;
10179
10182
  }
10180
10183
  return false;
@@ -10236,22 +10239,20 @@ const hasCssModuleQueryParam = (node) => {
10236
10239
  );
10237
10240
  };
10238
10241
 
10239
- const hasImportTypeCssAssertion = (node) => {
10240
- const importAssertionsDescriptor = getImportAssertionsDescriptor(
10241
- node.assertions,
10242
- );
10243
- return Boolean(importAssertionsDescriptor.type === "css");
10242
+ const hasImportTypeCssAttribute = (node) => {
10243
+ const importAttributes = getImportAttributes(node);
10244
+ return Boolean(importAttributes.type === "css");
10244
10245
  };
10245
10246
 
10246
- const getImportAssertionsDescriptor = (importAssertions) => {
10247
- const importAssertionsDescriptor = {};
10248
- if (importAssertions) {
10249
- importAssertions.forEach((importAssertion) => {
10250
- importAssertionsDescriptor[importAssertion.key.name] =
10251
- importAssertion.value.value;
10247
+ const getImportAttributes = (importNode) => {
10248
+ const importAttributes = {};
10249
+ if (importNode.attributes) {
10250
+ importNode.attributes.forEach((importAttributeNode) => {
10251
+ importAttributes[importAttributeNode.key.name] =
10252
+ importAttributeNode.value.value;
10252
10253
  });
10253
10254
  }
10254
- return importAssertionsDescriptor;
10255
+ return importAttributes;
10255
10256
  };
10256
10257
 
10257
10258
  const babelPluginNewStylesheetInjector = (
@@ -11111,7 +11112,7 @@ const jsenvPluginCssTranspilation = () => {
11111
11112
 
11112
11113
 
11113
11114
  const jsenvPluginTranspilation = ({
11114
- importAssertions = true,
11115
+ importAttributes = true,
11115
11116
  css = true, // TODO
11116
11117
  // build sets jsModuleFallback: false during first step of the build
11117
11118
  // and re-enable it in the second phase (when performing the bundling)
@@ -11119,8 +11120,8 @@ const jsenvPluginTranspilation = ({
11119
11120
  jsModuleFallback = true,
11120
11121
  babelHelpersAsImport = true,
11121
11122
  }) => {
11122
- if (importAssertions === true) {
11123
- importAssertions = {};
11123
+ if (importAttributes === true) {
11124
+ importAttributes = {};
11124
11125
  }
11125
11126
  if (jsModuleFallback === true) {
11126
11127
  jsModuleFallback = {};
@@ -11132,8 +11133,8 @@ const jsenvPluginTranspilation = ({
11132
11133
  }),
11133
11134
  jsenvPluginAsJsModule(),
11134
11135
  ...(jsModuleFallback ? [jsenvPluginJsModuleFallback()] : []),
11135
- ...(importAssertions
11136
- ? [jsenvPluginImportAssertions(importAssertions)]
11136
+ ...(importAttributes
11137
+ ? [jsenvPluginImportAttributes(importAttributes)]
11137
11138
  : []),
11138
11139
 
11139
11140
  ...(css ? [jsenvPluginCssTranspilation()] : []),
@@ -13930,7 +13931,7 @@ const parseAsHashWithOptions = (token) => {
13930
13931
  return { isValid, algo, base64Value, optionExpression };
13931
13932
  };
13932
13933
 
13933
- const BASE64_REGEX = /^[A-Za-z0-9+\/=+]+$/;
13934
+ const BASE64_REGEX = /^[A-Za-z0-9+/=]+$/;
13934
13935
  const VCHAR_REGEX = /^[\x21-\x7E]+$/;
13935
13936
 
13936
13937
  // https://www.w3.org/TR/SRI/#does-response-match-metadatalist
@@ -16427,7 +16428,7 @@ const escapeHtml = (string) => {
16427
16428
  .replace(/'/g, "'");
16428
16429
  };
16429
16430
  const replacePlaceholders$2 = (html, replacers) => {
16430
- return html.replace(/\${([\w]+)}/g, (match, name) => {
16431
+ return html.replace(/\$\{(\w+)\}/g, (match, name) => {
16431
16432
  const replacer = replacers[name];
16432
16433
  if (replacer === undefined) {
16433
16434
  return match;
@@ -18513,7 +18514,7 @@ const generateDirectoryContent = (
18513
18514
  `);
18514
18515
  };
18515
18516
  const replacePlaceholders$1 = (html, replacers) => {
18516
- return html.replace(/\${([\w]+)}/g, (match, name) => {
18517
+ return html.replace(/\$\{(\w+)\}/g, (match, name) => {
18517
18518
  const replacer = replacers[name];
18518
18519
  if (replacer === undefined) {
18519
18520
  return match;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jsenv/core",
3
- "version": "38.4.20",
3
+ "version": "39.0.1",
4
4
  "description": "Tool to develop, test and build js projects",
5
5
  "license": "MIT",
6
6
  "author": {
@@ -64,19 +64,19 @@
64
64
  "dependencies": {
65
65
  "@financial-times/polyfill-useragent-normaliser": "1.10.2",
66
66
  "@jsenv/abort": "4.3.0",
67
- "@jsenv/ast": "6.0.7",
67
+ "@jsenv/ast": "6.1.1",
68
68
  "@jsenv/filesystem": "4.7.2",
69
69
  "@jsenv/humanize": "1.1.3",
70
70
  "@jsenv/importmap": "1.2.1",
71
- "@jsenv/integrity": "0.0.1",
72
- "@jsenv/js-module-fallback": "1.3.16",
71
+ "@jsenv/integrity": "0.0.2",
72
+ "@jsenv/js-module-fallback": "1.3.18",
73
73
  "@jsenv/node-esm-resolution": "1.0.2",
74
74
  "@jsenv/plugin-bundling": "2.6.12",
75
75
  "@jsenv/plugin-minification": "1.5.4",
76
- "@jsenv/plugin-supervisor": "1.4.11",
77
- "@jsenv/plugin-transpilation": "1.3.16",
76
+ "@jsenv/plugin-supervisor": "1.4.13",
77
+ "@jsenv/plugin-transpilation": "1.4.1",
78
78
  "@jsenv/runtime-compat": "1.3.0",
79
- "@jsenv/server": "15.2.8",
79
+ "@jsenv/server": "15.2.9",
80
80
  "@jsenv/sourcemap": "1.2.10",
81
81
  "@jsenv/url-meta": "8.4.2",
82
82
  "@jsenv/urls": "2.2.7",
@@ -84,7 +84,7 @@
84
84
  },
85
85
  "devDependencies": {
86
86
  "@babel/eslint-parser": "7.24.7",
87
- "@babel/plugin-syntax-import-assertions": "7.24.7",
87
+ "@babel/plugin-syntax-import-attributes": "7.24.7",
88
88
  "@babel/plugin-syntax-optional-chaining-assign": "7.24.7",
89
89
  "@jsenv/assert": "./packages/independent/assert/",
90
90
  "@jsenv/core": "./",
@@ -104,6 +104,7 @@
104
104
  "eslint-plugin-html": "8.1.1",
105
105
  "eslint-plugin-import": "2.29.1",
106
106
  "eslint-plugin-react": "7.34.3",
107
+ "eslint-plugin-regexp": "2.6.0",
107
108
  "open": "10.1.0",
108
109
  "playwright": "1.45.1",
109
110
  "prettier": "3.3.2"
@@ -366,7 +366,7 @@ const generateDirectoryContent = (
366
366
  `);
367
367
  };
368
368
  const replacePlaceholders = (html, replacers) => {
369
- return html.replace(/\${([\w]+)}/g, (match, name) => {
369
+ return html.replace(/\$\{(\w+)\}/g, (match, name) => {
370
370
  const replacer = replacers[name];
371
371
  if (replacer === undefined) {
372
372
  return match;
@@ -650,7 +650,7 @@ const escapeHtml = (string) => {
650
650
  .replace(/'/g, "'");
651
651
  };
652
652
  const replacePlaceholders = (html, replacers) => {
653
- return html.replace(/\${([\w]+)}/g, (match, name) => {
653
+ return html.replace(/\$\{(\w+)\}/g, (match, name) => {
654
654
  const replacer = replacers[name];
655
655
  if (replacer === undefined) {
656
656
  return match;