js-dev-tool 1.2.2 → 1.2.3

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/common/index.js CHANGED
@@ -9,6 +9,7 @@
9
9
  * @file js-dev-scripts/common/index.js
10
10
  */
11
11
  // @ts-check
12
+ "use strict";
12
13
  const fs = require("fs");
13
14
  const path = require("path");
14
15
  const rl = require("readline");
@@ -5,6 +5,7 @@
5
5
  // https://opensource.org/licenses/mit-license.php
6
6
  // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
7
7
  */
8
+ "use strict";
8
9
  /**
9
10
  * @file list-deps-of.js
10
11
  * @command node list-deps-of.mjs typescript-jsdoctag-completions-plugin
@@ -5,6 +5,7 @@
5
5
  https://opensource.org/licenses/mit-license.php
6
6
  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
7
7
  */
8
+ "use strict";
8
9
  /** [usage]
9
10
  > node -i
10
11
  let t = require("./extras/progress-sample");
package/index.js CHANGED
@@ -5,6 +5,7 @@
5
5
  https://opensource.org/licenses/mit-license.php
6
6
  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
7
7
  */
8
+ "use strict";
8
9
  const progress = require("./progress");
9
10
  const common = require("./common");
10
11
  const utils = require("./utils");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "js-dev-tool",
3
- "version": "1.2.2",
3
+ "version": "1.2.3",
4
4
  "bin": {
5
5
  "jstool": "tools.js"
6
6
  },
@@ -85,11 +85,11 @@
85
85
  "dependencies": {
86
86
  "colors.ts": "^1.0.20",
87
87
  "fflate": "^0.8.2",
88
- "literate-regex": "^0.5.1",
89
- "mini-semaphore": "^1.4.4",
88
+ "literate-regex": "^0.6.9",
89
+ "mini-semaphore": "^1.5.1",
90
90
  "replace": "^1.2.2",
91
- "rm-cstyle-cmts": "^3.3.26",
92
- "terser": "^5.44.1",
91
+ "rm-cstyle-cmts": "^3.4.2",
92
+ "terser": "^5.46.0",
93
93
  "tin-args": "^0.1.1"
94
94
  }
95
95
  }
package/progress/index.js CHANGED
@@ -6,6 +6,7 @@
6
6
  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
7
7
  */
8
8
  /// <reference path="./index.d.ts" preserve="true"/>
9
+ "use strict";
9
10
  const lib = require("../common");
10
11
  const {
11
12
  checkENV,
@@ -6,6 +6,7 @@
6
6
  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
7
7
  */
8
8
  /// <reference path="./index.d.ts"/>
9
+ "use strict";
9
10
  const lib = require("../common");
10
11
  const checkENV = () => {
11
12
  const env = process.env;
@@ -5,6 +5,7 @@
5
5
  https://opensource.org/licenses/mit-license.php
6
6
  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
7
7
  */
8
+ "use strict";
8
9
  /**
9
10
  * @file random spinner
10
11
  * @author jeffy-g <hirotom1107@gmail.com>
package/progress/test.js CHANGED
@@ -5,6 +5,7 @@
5
5
  https://opensource.org/licenses/mit-license.php
6
6
  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
7
7
  */
8
+ "use strict";
8
9
  /** [usage]
9
10
  > node -i
10
11
  let t = require("./progress/test");
package/tool-lib/cjbm.js CHANGED
@@ -6,6 +6,7 @@
6
6
  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
7
7
  */
8
8
  /// <reference path="./tools.d.ts"/>
9
+ "use strict";
9
10
  // @ts-check
10
11
  /**
11
12
  * @file (C)onvert (J)S to (B)rowser (M)odule
@@ -56,7 +57,7 @@ const reImportExportDetection = compilePCREStyleRegExpLiteral(RE_TEXT);
56
57
  /**
57
58
  * @typedef {typeof reImportExportDetection} TImportExportDetectorRegex
58
59
  * @typedef {TImportExportDetectorRegex["types"]["exec"]} TImportExportDetectorRegexExecResult
59
- * @typedef {XRegex.StringReplacerFunction<TImportExportDetectorRegex>} TImportExportDetectRegexReplacer
60
+ * @typedef {XRegex.StringReplacerType<TImportExportDetectorRegex>} TImportExportDetectRegexReplacer
60
61
  */
61
62
  /**
62
63
  * Generates a replacer function to update import/export statements with a new file extension.
@@ -6,6 +6,7 @@
6
6
  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
7
7
  */
8
8
  /// <reference path="./tools.d.ts"/>
9
+ "use strict";
9
10
  // @ts-check
10
11
  /**
11
12
  * @file comment trick toggle
package/tool-lib/ps.js CHANGED
@@ -7,6 +7,7 @@
7
7
  */
8
8
  /// <reference path="./tools.d.ts"/>
9
9
  // @ts-check
10
+ "use strict";
10
11
  const DEBUG = 0;
11
12
  /** @type {(err: NodeJS.ErrnoException, cb: () => void) => void} */
12
13
  const handleError = (err, done) => {
package/tool-lib/rws.js CHANGED
@@ -7,6 +7,7 @@
7
7
  */
8
8
  /// <reference path="./tools.d.ts"/>
9
9
  // @ts-check
10
+ "use strict";
10
11
  /**
11
12
  * @file (R)ecord(W)ebpack(S)ize
12
13
  */
@@ -5,7 +5,7 @@
5
5
  https://opensource.org/licenses/mit-license.php
6
6
  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
7
7
  */
8
- /// <reference types="literate-regex"/>
8
+ /// <reference types="literate-regex/global"/>
9
9
  /**
10
10
  * @date 2023-10-25
11
11
  */
@@ -7,6 +7,7 @@
7
7
  */
8
8
  /// <reference path="./tools.d.ts"/>
9
9
  // @ts-check
10
+ "use strict";
10
11
  /**
11
12
  * @file zip compression task
12
13
  */
package/tools.js CHANGED
@@ -8,8 +8,10 @@
8
8
  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
9
9
  */
10
10
  // @ts-check
11
+ "use strict";
11
12
  const fs = require("fs");
12
13
  const path = require("path");
14
+ const rmc = require("rm-cstyle-cmts");
13
15
  /* utilities module by own. */
14
16
  const utils = require("./utils");
15
17
  // @ts-expect- error
@@ -203,14 +205,16 @@ const ToolFunctions = {
203
205
  rmc: {
204
206
  taskName: "rm-cstyle-cmts",
205
207
  fn() {
206
- const rmc = require("rm-cstyle-cmts");
208
+ rmc.reset();
207
209
  if (params.rmc4ts) {
208
210
  const keepBangLine = params.rmc4ts === "keepBangLine";
211
+ const reMultiLineChcker = /^\/\*(\*|!)\s|^\/\*(?!-).+\*\/$/;
212
+ const reSingleLineChecer = /^\/\/+!/;
209
213
  rmc.setListener(({ event, fragment }) => {
210
214
  if (event === /*EScannerEvent.MultiLineComment*/ 1) {
211
- return /^\/\*(\*|!)\s|^\/\*(?!-).+\*\/$/.test(fragment);
215
+ return reMultiLineChcker.test(fragment);
212
216
  } else if (keepBangLine && event === /*EScannerEvent.SingleLineComment*/0) {
213
- return /^\/\/+!/.test(fragment);
217
+ return reSingleLineChecer.test(fragment);
214
218
  }
215
219
  return false;
216
220
  });
@@ -220,7 +224,8 @@ const ToolFunctions = {
220
224
  processSources(
221
225
  /** @type {string} */ (this.taskName),
222
226
  (data) => {
223
- return rmc(data);
227
+ let result = rmc(data);
228
+ return preserveTsReferenceDirectives(result);
224
229
  },
225
230
  {
226
231
  bases: basePaths,
@@ -236,12 +241,45 @@ const ToolFunctions = {
236
241
  rmc4ts- for typescript source.
237
242
  keep comment that start with "/*" when "*/" end mark appears in same line.
238
243
  if start with "/*-" remove it
244
+ keep leading "/// <reference ...>" directives above a top-level "use strict" line in CJS emit.(2026/02/03)
239
245
  rmc4ts=keepBangLine (2025/12/24)
240
246
  - In addition to the "rmc4ts" processing, it also preserves line comments that start with "//!".
241
247
  `,
242
248
  },
243
249
  zip: require("./tool-lib/zip-task")(utils),
244
250
  };
251
+ /**
252
+ * Preserve TypeScript `/// <reference ...>` directives when a leading
253
+ * "use strict" line would otherwise push them below the directive zone
254
+ * after C-style comment stripping.
255
+ *
256
+ * It hoists any header reference directives back above "use strict" so the
257
+ * TypeScript compiler can still see them in CommonJS outputs.
258
+ *
259
+ * @param {string} jsSource - JavaScript source after comment removal.
260
+ * @param {true=} debug - Log when code is executed.
261
+ * @returns {string} Source with reference directives restored to the header.
262
+ * @date 2026/02/03 14:45:49
263
+ */
264
+ function preserveTsReferenceDirectives(jsSource, debug) {
265
+ const m = /^(["'])use strict\1;?[\r\n]/.exec(jsSource);
266
+ if (m) {
267
+ const usLen = m[0].length;
268
+ const usLine = jsSource.slice(m.index, usLen);
269
+ /** @type {string[]} */
270
+ const knownDirectives = [];
271
+ const reReferenceDirectiveChecker = /^\/\/\/\s*<reference.+[\r\n]/gm;
272
+ let purgedSource = jsSource.slice(usLen).replace(reReferenceDirectiveChecker, (match) => {
273
+ knownDirectives.push(match);
274
+ return "";
275
+ });
276
+ if (knownDirectives.length) {
277
+ debug && utils.log("preserveTsReferenceDirectives applied");
278
+ return knownDirectives.join("") + usLine + purgedSource;
279
+ }
280
+ }
281
+ return jsSource;
282
+ }
245
283
  /**
246
284
  * @param {TJSToolEntry} entry
247
285
  * @returns {entry is TJSToolEntry}
package/utils.js CHANGED
@@ -20,6 +20,7 @@
20
20
  /// <reference types="./basic-types"/>
21
21
  /// <reference types="./lib/zlibjs.d.ts"/>
22
22
  // @ts-check
23
+ "use strict";
23
24
  const fs = require("fs");
24
25
  const path = require("path");
25
26
  const lib = require("./common");