@jsenv/core 39.8.0 → 39.9.0

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.
@@ -118,17 +118,29 @@ if (
118
118
  }
119
119
 
120
120
  function envForceColor() {
121
- if ('FORCE_COLOR' in env) {
122
- if (env.FORCE_COLOR === 'true') {
123
- return 1;
124
- }
121
+ if (!('FORCE_COLOR' in env)) {
122
+ return;
123
+ }
125
124
 
126
- if (env.FORCE_COLOR === 'false') {
127
- return 0;
128
- }
125
+ if (env.FORCE_COLOR === 'true') {
126
+ return 1;
127
+ }
128
+
129
+ if (env.FORCE_COLOR === 'false') {
130
+ return 0;
131
+ }
132
+
133
+ if (env.FORCE_COLOR.length === 0) {
134
+ return 1;
135
+ }
136
+
137
+ const level = Math.min(Number.parseInt(env.FORCE_COLOR, 10), 3);
129
138
 
130
- return env.FORCE_COLOR.length === 0 ? 1 : Math.min(Number.parseInt(env.FORCE_COLOR, 10), 3);
139
+ if (![0, 1, 2, 3].includes(level)) {
140
+ return;
131
141
  }
142
+
143
+ return level;
132
144
  }
133
145
 
134
146
  function translateLevel(level) {
@@ -199,11 +211,11 @@ function _supportsColor(haveStream, {streamIsTTY, sniffFlags = true} = {}) {
199
211
  }
200
212
 
201
213
  if ('CI' in env) {
202
- if ('GITHUB_ACTIONS' in env || 'GITEA_ACTIONS' in env) {
214
+ if (['GITHUB_ACTIONS', 'GITEA_ACTIONS', 'CIRCLECI'].some(key => key in env)) {
203
215
  return 3;
204
216
  }
205
217
 
206
- if (['TRAVIS', 'CIRCLECI', 'APPVEYOR', 'GITLAB_CI', 'BUILDKITE', 'DRONE'].some(sign => sign in env) || env.CI_NAME === 'codeship') {
218
+ if (['TRAVIS', 'APPVEYOR', 'GITLAB_CI', 'BUILDKITE', 'DRONE'].some(sign => sign in env) || env.CI_NAME === 'codeship') {
207
219
  return 1;
208
220
  }
209
221
 
@@ -4650,7 +4662,8 @@ const registerDirectoryLifecycle = (
4650
4662
  }
4651
4663
  };
4652
4664
 
4653
- readdirSync(new URL(sourceUrl)).forEach((entry) => {
4665
+ const entries = readdirSync(new URL(sourceUrl));
4666
+ for (const entry of entries) {
4654
4667
  const entryUrl = new URL(entry, sourceUrl).href;
4655
4668
  const entryInfo = readEntryInfo(entryUrl);
4656
4669
  if (entryInfo.type !== null && entryInfo.patternValue) {
@@ -4658,7 +4671,7 @@ const registerDirectoryLifecycle = (
4658
4671
  notify: notifyExistent,
4659
4672
  });
4660
4673
  }
4661
- });
4674
+ }
4662
4675
  if (debug) {
4663
4676
  const relativeUrls = Array.from(infoMap.keys());
4664
4677
  if (relativeUrls.length === 0) {
@@ -4692,11 +4705,11 @@ const shouldCallUpdated = (entryInfo) => {
4692
4705
  if (!stat.atimeMs) {
4693
4706
  return true;
4694
4707
  }
4695
- if (stat.atimeMs < stat.mtimeMs) {
4708
+ if (stat.atimeMs <= stat.mtimeMs) {
4696
4709
  return true;
4697
4710
  }
4698
- if (isLinux && stat.mtimeMs <= previousInfo.stat.mtimeMs) {
4699
- return false;
4711
+ if (stat.mtimeMs !== previousInfo.stat.mtimeMs) {
4712
+ return true;
4700
4713
  }
4701
4714
  return true;
4702
4715
  };
@@ -4730,6 +4743,10 @@ const fileSystemPathToDirectoryRelativeUrlAndFilename = (path) => {
4730
4743
  };
4731
4744
  };
4732
4745
 
4746
+ process.platform === "darwin";
4747
+ process.platform === "linux";
4748
+ process.platform === "freebsd";
4749
+
4733
4750
  /*
4734
4751
  * - Buffer documentation on Node.js
4735
4752
  * https://nodejs.org/docs/latest-v13.x/api/buffer.html
@@ -13991,6 +14008,19 @@ const createUrlInfo = (url, context) => {
13991
14008
  reference.next = referenceWithoutSearchParam;
13992
14009
  return referenceWithoutSearchParam.urlInfo;
13993
14010
  };
14011
+ urlInfo.onRemoved = () => {
14012
+ urlInfo.kitchen.urlInfoTransformer.resetContent(urlInfo);
14013
+ urlInfo.referenceToOthersSet.forEach((referenceToOther) => {
14014
+ referenceToOther.remove();
14015
+ });
14016
+ if (urlInfo.searchParams.size > 0) {
14017
+ const urlWithoutSearch = asUrlWithoutSearch(urlInfo.url);
14018
+ const urlInfoWithoutSearch = urlInfo.graph.getUrlInfo(urlWithoutSearch);
14019
+ if (urlInfoWithoutSearch) {
14020
+ urlInfoWithoutSearch.searchParamVariantSet.delete(urlInfo);
14021
+ }
14022
+ }
14023
+ };
13994
14024
  urlInfo.onModified = ({ modifiedTimestamp = Date.now() } = {}) => {
13995
14025
  const visitedSet = new Set();
13996
14026
  const considerModified = (urlInfo) => {
@@ -14027,21 +14057,6 @@ const createUrlInfo = (url, context) => {
14027
14057
  );
14028
14058
  };
14029
14059
 
14030
- // not used for now
14031
- // urlInfo.deleteFromGraph = () => {
14032
- // urlInfo.kitchen.urlInfoTransformer.resetContent(urlInfo);
14033
- // urlInfo.graph.urlInfoMap.delete(url);
14034
- // urlInfo.referenceToOthersSet.forEach((referenceToOther) => {
14035
- // referenceToOther.remove();
14036
- // });
14037
- // if (urlInfo.searchParams.size > 0) {
14038
- // const urlWithoutSearch = asUrlWithoutSearch(urlInfo.url);
14039
- // const urlInfoWithoutSearch = urlInfo.graph.getUrlInfo(urlWithoutSearch);
14040
- // if (urlInfoWithoutSearch) {
14041
- // urlInfoWithoutSearch.searchParamVariantSet.delete(urlInfo);
14042
- // }
14043
- // }
14044
- // };
14045
14060
  urlInfo.cook = (customContext) => {
14046
14061
  return urlInfo.context.cook(urlInfo, customContext);
14047
14062
  };
@@ -23793,10 +23808,14 @@ const startDevServer = async ({
23793
23808
  sourceDirectoryUrl,
23794
23809
  );
23795
23810
  let kitchen;
23796
- clientFileChangeEventEmitter.on(({ url }) => {
23811
+ clientFileChangeEventEmitter.on(({ url, event }) => {
23797
23812
  const urlInfo = kitchen.graph.getUrlInfo(url);
23798
23813
  if (urlInfo) {
23799
- urlInfo.onModified();
23814
+ if (event === "removed") {
23815
+ urlInfo.onRemoved();
23816
+ } else {
23817
+ urlInfo.onModified();
23818
+ }
23800
23819
  }
23801
23820
  });
23802
23821
  const clientRuntimeCompat = { [runtimeName]: runtimeVersion };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jsenv/core",
3
- "version": "39.8.0",
3
+ "version": "39.9.0",
4
4
  "description": "Tool to develop, test and build js projects",
5
5
  "license": "MIT",
6
6
  "author": {
@@ -70,19 +70,19 @@
70
70
  "@financial-times/polyfill-useragent-normaliser": "1.10.2",
71
71
  "@jsenv/abort": "4.3.0",
72
72
  "@jsenv/ast": "6.4.1",
73
- "@jsenv/filesystem": "4.12.0",
73
+ "@jsenv/filesystem": "4.13.0",
74
74
  "@jsenv/humanize": "1.2.8",
75
75
  "@jsenv/importmap": "1.2.1",
76
76
  "@jsenv/integrity": "0.0.2",
77
- "@jsenv/js-module-fallback": "1.3.53",
77
+ "@jsenv/js-module-fallback": "1.3.54",
78
78
  "@jsenv/node-esm-resolution": "1.0.6",
79
- "@jsenv/plugin-bundling": "2.7.20",
79
+ "@jsenv/plugin-bundling": "2.7.21",
80
80
  "@jsenv/plugin-minification": "1.5.12",
81
- "@jsenv/plugin-supervisor": "1.6.0",
82
- "@jsenv/plugin-transpilation": "1.4.88",
81
+ "@jsenv/plugin-supervisor": "1.6.1",
82
+ "@jsenv/plugin-transpilation": "1.4.89",
83
83
  "@jsenv/runtime-compat": "1.3.1",
84
84
  "@jsenv/server": "15.3.3",
85
- "@jsenv/sourcemap": "1.2.28",
85
+ "@jsenv/sourcemap": "1.2.29",
86
86
  "@jsenv/url-meta": "8.5.2",
87
87
  "@jsenv/urls": "2.5.4",
88
88
  "@jsenv/utils": "2.1.2",
@@ -108,7 +108,7 @@
108
108
  "@playwright/browser-firefox": "1.49.1",
109
109
  "@playwright/browser-webkit": "1.49.1",
110
110
  "babel-plugin-transform-async-to-promises": "0.8.18",
111
- "eslint": "9.16.0",
111
+ "eslint": "9.17.0",
112
112
  "open": "10.1.0",
113
113
  "playwright": "1.49.1",
114
114
  "prettier": "3.4.2",
@@ -237,10 +237,14 @@ export const startDevServer = async ({
237
237
  sourceDirectoryUrl,
238
238
  );
239
239
  let kitchen;
240
- clientFileChangeEventEmitter.on(({ url }) => {
240
+ clientFileChangeEventEmitter.on(({ url, event }) => {
241
241
  const urlInfo = kitchen.graph.getUrlInfo(url);
242
242
  if (urlInfo) {
243
- urlInfo.onModified();
243
+ if (event === "removed") {
244
+ urlInfo.onRemoved();
245
+ } else {
246
+ urlInfo.onModified();
247
+ }
244
248
  }
245
249
  });
246
250
  const clientRuntimeCompat = { [runtimeName]: runtimeVersion };
@@ -356,6 +356,19 @@ const createUrlInfo = (url, context) => {
356
356
  reference.next = referenceWithoutSearchParam;
357
357
  return referenceWithoutSearchParam.urlInfo;
358
358
  };
359
+ urlInfo.onRemoved = () => {
360
+ urlInfo.kitchen.urlInfoTransformer.resetContent(urlInfo);
361
+ urlInfo.referenceToOthersSet.forEach((referenceToOther) => {
362
+ referenceToOther.remove();
363
+ });
364
+ if (urlInfo.searchParams.size > 0) {
365
+ const urlWithoutSearch = asUrlWithoutSearch(urlInfo.url);
366
+ const urlInfoWithoutSearch = urlInfo.graph.getUrlInfo(urlWithoutSearch);
367
+ if (urlInfoWithoutSearch) {
368
+ urlInfoWithoutSearch.searchParamVariantSet.delete(urlInfo);
369
+ }
370
+ }
371
+ };
359
372
  urlInfo.onModified = ({ modifiedTimestamp = Date.now() } = {}) => {
360
373
  const visitedSet = new Set();
361
374
  const considerModified = (urlInfo) => {
@@ -392,21 +405,6 @@ const createUrlInfo = (url, context) => {
392
405
  );
393
406
  };
394
407
 
395
- // not used for now
396
- // urlInfo.deleteFromGraph = () => {
397
- // urlInfo.kitchen.urlInfoTransformer.resetContent(urlInfo);
398
- // urlInfo.graph.urlInfoMap.delete(url);
399
- // urlInfo.referenceToOthersSet.forEach((referenceToOther) => {
400
- // referenceToOther.remove();
401
- // });
402
- // if (urlInfo.searchParams.size > 0) {
403
- // const urlWithoutSearch = asUrlWithoutSearch(urlInfo.url);
404
- // const urlInfoWithoutSearch = urlInfo.graph.getUrlInfo(urlWithoutSearch);
405
- // if (urlInfoWithoutSearch) {
406
- // urlInfoWithoutSearch.searchParamVariantSet.delete(urlInfo);
407
- // }
408
- // }
409
- // };
410
408
  urlInfo.cook = (customContext) => {
411
409
  return urlInfo.context.cook(urlInfo, customContext);
412
410
  };