@jsenv/core 38.3.9 → 38.3.10

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.
Files changed (2) hide show
  1. package/dist/jsenv_core.js +186 -186
  2. package/package.json +6 -6
@@ -2447,192 +2447,6 @@ process.platform === "win32";
2447
2447
 
2448
2448
  process.platform === "win32";
2449
2449
 
2450
- const mediaTypeInfos = {
2451
- "application/json": {
2452
- extensions: ["json"],
2453
- isTextual: true,
2454
- },
2455
- "application/importmap+json": {
2456
- extensions: ["importmap"],
2457
- isTextual: true,
2458
- },
2459
- "application/manifest+json": {
2460
- extensions: ["webmanifest"],
2461
- isTextual: true,
2462
- },
2463
- "application/octet-stream": {},
2464
- "application/pdf": {
2465
- extensions: ["pdf"],
2466
- },
2467
- "application/xml": {
2468
- extensions: ["xml"],
2469
- },
2470
- "application/x-gzip": {
2471
- extensions: ["gz"],
2472
- },
2473
- "application/wasm": {
2474
- extensions: ["wasm"],
2475
- },
2476
- "application/zip": {
2477
- extensions: ["zip"],
2478
- },
2479
- "audio/basic": {
2480
- extensions: ["au", "snd"],
2481
- },
2482
- "audio/mpeg": {
2483
- extensions: ["mpga", "mp2", "mp2a", "mp3", "m2a", "m3a"],
2484
- },
2485
- "audio/midi": {
2486
- extensions: ["midi", "mid", "kar", "rmi"],
2487
- },
2488
- "audio/mp4": {
2489
- extensions: ["m4a", "mp4a"],
2490
- },
2491
- "audio/ogg": {
2492
- extensions: ["oga", "ogg", "spx"],
2493
- },
2494
- "audio/webm": {
2495
- extensions: ["weba"],
2496
- },
2497
- "audio/x-wav": {
2498
- extensions: ["wav"],
2499
- },
2500
- "font/ttf": {
2501
- extensions: ["ttf"],
2502
- },
2503
- "font/woff": {
2504
- extensions: ["woff"],
2505
- },
2506
- "font/woff2": {
2507
- extensions: ["woff2"],
2508
- },
2509
- "image/png": {
2510
- extensions: ["png"],
2511
- },
2512
- "image/gif": {
2513
- extensions: ["gif"],
2514
- },
2515
- "image/jpeg": {
2516
- extensions: ["jpg"],
2517
- },
2518
- "image/svg+xml": {
2519
- extensions: ["svg", "svgz"],
2520
- isTextual: true,
2521
- },
2522
- "text/plain": {
2523
- extensions: ["txt"],
2524
- },
2525
- "text/html": {
2526
- extensions: ["html"],
2527
- },
2528
- "text/css": {
2529
- extensions: ["css"],
2530
- },
2531
- "text/javascript": {
2532
- extensions: ["js", "cjs", "mjs", "ts", "jsx", "tsx"],
2533
- },
2534
- "text/x-sass": {
2535
- extensions: ["sass"],
2536
- },
2537
- "text/x-scss": {
2538
- extensions: ["scss"],
2539
- },
2540
- "text/cache-manifest": {
2541
- extensions: ["appcache"],
2542
- },
2543
- "video/mp4": {
2544
- extensions: ["mp4", "mp4v", "mpg4"],
2545
- },
2546
- "video/mpeg": {
2547
- extensions: ["mpeg", "mpg", "mpe", "m1v", "m2v"],
2548
- },
2549
- "video/ogg": {
2550
- extensions: ["ogv"],
2551
- },
2552
- "video/webm": {
2553
- extensions: ["webm"],
2554
- },
2555
- };
2556
-
2557
- const CONTENT_TYPE = {
2558
- parse: (string) => {
2559
- const [mediaType, charset] = string.split(";");
2560
- return { mediaType: normalizeMediaType(mediaType), charset };
2561
- },
2562
-
2563
- stringify: ({ mediaType, charset }) => {
2564
- if (charset) {
2565
- return `${mediaType};${charset}`;
2566
- }
2567
- return mediaType;
2568
- },
2569
-
2570
- asMediaType: (value) => {
2571
- if (typeof value === "string") {
2572
- return CONTENT_TYPE.parse(value).mediaType;
2573
- }
2574
- if (typeof value === "object") {
2575
- return value.mediaType;
2576
- }
2577
- return null;
2578
- },
2579
-
2580
- isJson: (value) => {
2581
- const mediaType = CONTENT_TYPE.asMediaType(value);
2582
- return (
2583
- mediaType === "application/json" ||
2584
- /^application\/\w+\+json$/.test(mediaType)
2585
- );
2586
- },
2587
-
2588
- isTextual: (value) => {
2589
- const mediaType = CONTENT_TYPE.asMediaType(value);
2590
- if (mediaType.startsWith("text/")) {
2591
- return true;
2592
- }
2593
- const mediaTypeInfo = mediaTypeInfos[mediaType];
2594
- if (mediaTypeInfo && mediaTypeInfo.isTextual) {
2595
- return true;
2596
- }
2597
- // catch things like application/manifest+json, application/importmap+json
2598
- if (/^application\/\w+\+json$/.test(mediaType)) {
2599
- return true;
2600
- }
2601
- return false;
2602
- },
2603
-
2604
- isBinary: (value) => !CONTENT_TYPE.isTextual(value),
2605
-
2606
- asFileExtension: (value) => {
2607
- const mediaType = CONTENT_TYPE.asMediaType(value);
2608
- const mediaTypeInfo = mediaTypeInfos[mediaType];
2609
- return mediaTypeInfo ? `.${mediaTypeInfo.extensions[0]}` : "";
2610
- },
2611
-
2612
- fromUrlExtension: (url) => {
2613
- const { pathname } = new URL(url);
2614
- const extensionWithDot = extname(pathname);
2615
- if (!extensionWithDot || extensionWithDot === ".") {
2616
- return "application/octet-stream";
2617
- }
2618
- const extension = extensionWithDot.slice(1);
2619
- const mediaTypeFound = Object.keys(mediaTypeInfos).find((mediaType) => {
2620
- const mediaTypeInfo = mediaTypeInfos[mediaType];
2621
- return (
2622
- mediaTypeInfo.extensions && mediaTypeInfo.extensions.includes(extension)
2623
- );
2624
- });
2625
- return mediaTypeFound || "application/octet-stream";
2626
- },
2627
- };
2628
-
2629
- const normalizeMediaType = (value) => {
2630
- if (value === "application/javascript") {
2631
- return "text/javascript";
2632
- }
2633
- return value;
2634
- };
2635
-
2636
2450
  process.platform === "win32";
2637
2451
 
2638
2452
  const ensureEmptyDirectory = async (source) => {
@@ -7116,6 +6930,192 @@ const PROCESS_TEARDOWN_EVENTS_MAP = {
7116
6930
  exit: STOP_REASON_PROCESS_EXIT,
7117
6931
  };
7118
6932
 
6933
+ const mediaTypeInfos = {
6934
+ "application/json": {
6935
+ extensions: ["json", "map"],
6936
+ isTextual: true,
6937
+ },
6938
+ "application/importmap+json": {
6939
+ extensions: ["importmap"],
6940
+ isTextual: true,
6941
+ },
6942
+ "application/manifest+json": {
6943
+ extensions: ["webmanifest"],
6944
+ isTextual: true,
6945
+ },
6946
+ "application/octet-stream": {},
6947
+ "application/pdf": {
6948
+ extensions: ["pdf"],
6949
+ },
6950
+ "application/xml": {
6951
+ extensions: ["xml"],
6952
+ },
6953
+ "application/x-gzip": {
6954
+ extensions: ["gz"],
6955
+ },
6956
+ "application/wasm": {
6957
+ extensions: ["wasm"],
6958
+ },
6959
+ "application/zip": {
6960
+ extensions: ["zip"],
6961
+ },
6962
+ "audio/basic": {
6963
+ extensions: ["au", "snd"],
6964
+ },
6965
+ "audio/mpeg": {
6966
+ extensions: ["mpga", "mp2", "mp2a", "mp3", "m2a", "m3a"],
6967
+ },
6968
+ "audio/midi": {
6969
+ extensions: ["midi", "mid", "kar", "rmi"],
6970
+ },
6971
+ "audio/mp4": {
6972
+ extensions: ["m4a", "mp4a"],
6973
+ },
6974
+ "audio/ogg": {
6975
+ extensions: ["oga", "ogg", "spx"],
6976
+ },
6977
+ "audio/webm": {
6978
+ extensions: ["weba"],
6979
+ },
6980
+ "audio/x-wav": {
6981
+ extensions: ["wav"],
6982
+ },
6983
+ "font/ttf": {
6984
+ extensions: ["ttf"],
6985
+ },
6986
+ "font/woff": {
6987
+ extensions: ["woff"],
6988
+ },
6989
+ "font/woff2": {
6990
+ extensions: ["woff2"],
6991
+ },
6992
+ "image/png": {
6993
+ extensions: ["png"],
6994
+ },
6995
+ "image/gif": {
6996
+ extensions: ["gif"],
6997
+ },
6998
+ "image/jpeg": {
6999
+ extensions: ["jpg"],
7000
+ },
7001
+ "image/svg+xml": {
7002
+ extensions: ["svg", "svgz"],
7003
+ isTextual: true,
7004
+ },
7005
+ "text/plain": {
7006
+ extensions: ["txt"],
7007
+ },
7008
+ "text/html": {
7009
+ extensions: ["html"],
7010
+ },
7011
+ "text/css": {
7012
+ extensions: ["css"],
7013
+ },
7014
+ "text/javascript": {
7015
+ extensions: ["js", "cjs", "mjs", "ts", "jsx", "tsx"],
7016
+ },
7017
+ "text/x-sass": {
7018
+ extensions: ["sass"],
7019
+ },
7020
+ "text/x-scss": {
7021
+ extensions: ["scss"],
7022
+ },
7023
+ "text/cache-manifest": {
7024
+ extensions: ["appcache"],
7025
+ },
7026
+ "video/mp4": {
7027
+ extensions: ["mp4", "mp4v", "mpg4"],
7028
+ },
7029
+ "video/mpeg": {
7030
+ extensions: ["mpeg", "mpg", "mpe", "m1v", "m2v"],
7031
+ },
7032
+ "video/ogg": {
7033
+ extensions: ["ogv"],
7034
+ },
7035
+ "video/webm": {
7036
+ extensions: ["webm"],
7037
+ },
7038
+ };
7039
+
7040
+ const CONTENT_TYPE = {
7041
+ parse: (string) => {
7042
+ const [mediaType, charset] = string.split(";");
7043
+ return { mediaType: normalizeMediaType(mediaType), charset };
7044
+ },
7045
+
7046
+ stringify: ({ mediaType, charset }) => {
7047
+ if (charset) {
7048
+ return `${mediaType};${charset}`;
7049
+ }
7050
+ return mediaType;
7051
+ },
7052
+
7053
+ asMediaType: (value) => {
7054
+ if (typeof value === "string") {
7055
+ return CONTENT_TYPE.parse(value).mediaType;
7056
+ }
7057
+ if (typeof value === "object") {
7058
+ return value.mediaType;
7059
+ }
7060
+ return null;
7061
+ },
7062
+
7063
+ isJson: (value) => {
7064
+ const mediaType = CONTENT_TYPE.asMediaType(value);
7065
+ return (
7066
+ mediaType === "application/json" ||
7067
+ /^application\/\w+\+json$/.test(mediaType)
7068
+ );
7069
+ },
7070
+
7071
+ isTextual: (value) => {
7072
+ const mediaType = CONTENT_TYPE.asMediaType(value);
7073
+ if (mediaType.startsWith("text/")) {
7074
+ return true;
7075
+ }
7076
+ const mediaTypeInfo = mediaTypeInfos[mediaType];
7077
+ if (mediaTypeInfo && mediaTypeInfo.isTextual) {
7078
+ return true;
7079
+ }
7080
+ // catch things like application/manifest+json, application/importmap+json
7081
+ if (/^application\/\w+\+json$/.test(mediaType)) {
7082
+ return true;
7083
+ }
7084
+ return false;
7085
+ },
7086
+
7087
+ isBinary: (value) => !CONTENT_TYPE.isTextual(value),
7088
+
7089
+ asFileExtension: (value) => {
7090
+ const mediaType = CONTENT_TYPE.asMediaType(value);
7091
+ const mediaTypeInfo = mediaTypeInfos[mediaType];
7092
+ return mediaTypeInfo ? `.${mediaTypeInfo.extensions[0]}` : "";
7093
+ },
7094
+
7095
+ fromUrlExtension: (url) => {
7096
+ const { pathname } = new URL(url);
7097
+ const extensionWithDot = extname(pathname);
7098
+ if (!extensionWithDot || extensionWithDot === ".") {
7099
+ return "application/octet-stream";
7100
+ }
7101
+ const extension = extensionWithDot.slice(1);
7102
+ const mediaTypeFound = Object.keys(mediaTypeInfos).find((mediaType) => {
7103
+ const mediaTypeInfo = mediaTypeInfos[mediaType];
7104
+ return (
7105
+ mediaTypeInfo.extensions && mediaTypeInfo.extensions.includes(extension)
7106
+ );
7107
+ });
7108
+ return mediaTypeFound || "application/octet-stream";
7109
+ },
7110
+ };
7111
+
7112
+ const normalizeMediaType = (value) => {
7113
+ if (value === "application/javascript") {
7114
+ return "text/javascript";
7115
+ }
7116
+ return value;
7117
+ };
7118
+
7119
7119
  const isFileSystemPath = (value) => {
7120
7120
  if (typeof value !== "string") {
7121
7121
  throw new TypeError(
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jsenv/core",
3
- "version": "38.3.9",
3
+ "version": "38.3.10",
4
4
  "description": "Tool to develop, test and build js projects",
5
5
  "license": "MIT",
6
6
  "author": {
@@ -63,7 +63,7 @@
63
63
  "@financial-times/polyfill-useragent-normaliser": "1.10.2",
64
64
  "@jsenv/abort": "4.2.4",
65
65
  "@jsenv/ast": "6.0.1",
66
- "@jsenv/filesystem": "4.5.0",
66
+ "@jsenv/filesystem": "4.5.1",
67
67
  "@jsenv/importmap": "1.2.1",
68
68
  "@jsenv/integrity": "0.0.1",
69
69
  "@jsenv/js-module-fallback": "1.3.9",
@@ -72,13 +72,13 @@
72
72
  "@jsenv/plugin-bundling": "2.6.1",
73
73
  "@jsenv/plugin-minification": "1.5.4",
74
74
  "@jsenv/plugin-supervisor": "1.4.0",
75
- "@jsenv/plugin-transpilation": "1.3.8",
76
- "@jsenv/runtime-compat": "1.2.0",
77
- "@jsenv/server": "15.1.7",
75
+ "@jsenv/plugin-transpilation": "1.3.9",
76
+ "@jsenv/runtime-compat": "1.2.1",
77
+ "@jsenv/server": "15.1.8",
78
78
  "@jsenv/sourcemap": "1.2.4",
79
79
  "@jsenv/url-meta": "8.2.0",
80
80
  "@jsenv/urls": "2.2.1",
81
- "@jsenv/utils": "2.0.1"
81
+ "@jsenv/utils": "2.1.0"
82
82
  },
83
83
  "devDependencies": {
84
84
  "@babel/eslint-parser": "7.23.3",