miniread 1.60.1 → 1.62.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.
@@ -108,6 +108,10 @@ const manifestData = {
108
108
  notes: "Auto-added by evaluation script. Measured with baseline none: 0.09%.",
109
109
  evaluations: { "legacy:evaluation": { "evaluatedAt": "2026-01-25T19:59:48.188Z", "changedLines": 38927, "durationSeconds": 0, "stableNames": 0, "diffSizePercent": 97.80020410477378 }, "claude-code-2.1.10:claude-code-2.1.11": { "diffSizePercent": 97.80020410477378, "evaluatedAt": "2026-01-25T23:15:44.243Z", "changedLines": 38927, "durationSeconds": 76.61873741599999, "stableNames": 4505 } },
110
110
  },
111
+ "rename-document-fragment-variables": {
112
+ recommended: true,
113
+ evaluations: { "claude-code-2.1.10:claude-code-2.1.11": { "diffSizePercent": 100, "evaluatedAt": "2026-02-02T22:12:52.993Z", "changedLines": 20, "durationSeconds": 207.34089557, "stableNames": 1358 } },
114
+ },
111
115
  "rename-error-first-callback-parameters": {
112
116
  recommended: true,
113
117
  notes: "Measured with baseline none: 0.00%.",
@@ -244,6 +248,10 @@ const manifestData = {
244
248
  notes: "Measured with baseline none: 0.00%. Added to recommended for readability.",
245
249
  evaluations: { "legacy:evaluation": { "evaluatedAt": "2026-01-25T20:13:48.297Z", "changedLines": 154, "durationSeconds": 0, "stableNames": 0, "diffSizePercent": 99.99622028196697 }, "claude-code-2.1.10:claude-code-2.1.11": { "diffSizePercent": 99.99622028196697, "evaluatedAt": "2026-01-25T23:31:54.696Z", "changedLines": 154, "durationSeconds": 53.15604825, "stableNames": 1358 } },
246
250
  },
251
+ "rename-to-buffer-results": {
252
+ recommended: true,
253
+ evaluations: { "claude-code-2.1.10:claude-code-2.1.11": { "diffSizePercent": 100, "evaluatedAt": "2026-02-04T13:06:29.691Z", "changedLines": 56, "durationSeconds": 171.52518661899998, "stableNames": 1359 } },
254
+ },
247
255
  "rename-typeof-variables": {
248
256
  recommended: true,
249
257
  evaluations: { "legacy:evaluation": { "evaluatedAt": "2026-01-25T20:14:40.653Z", "changedLines": 372, "durationSeconds": 0, "stableNames": 0, "diffSizePercent": 100 }, "claude-code-2.1.10:claude-code-2.1.11": { "diffSizePercent": 100, "evaluatedAt": "2026-01-25T23:32:45.594Z", "changedLines": 372, "durationSeconds": 48.026398584, "stableNames": 1358 } },
@@ -353,6 +361,7 @@ export const recommendedTransformIds = [
353
361
  "rename-asap-wrappers",
354
362
  "rename-awaiter-parameters",
355
363
  "rename-buffer-variables",
364
+ "rename-to-buffer-results",
356
365
  "rename-catch-parameters",
357
366
  "rename-promise-catch-parameters",
358
367
  "rename-char-code-at",
@@ -370,6 +379,7 @@ export const recommendedTransformIds = [
370
379
  "rename-interval-ids",
371
380
  "rename-loop-index-variables-v3",
372
381
  "rename-loop-length-variables",
382
+ "rename-document-fragment-variables",
373
383
  "rename-object-keys-variables",
374
384
  "rename-parameters-to-match-properties-v2",
375
385
  "rename-promise-executor-parameters-v2",
@@ -21,6 +21,7 @@ import { renameDateNowStartTimesTransform } from "../rename-date-now-start-times
21
21
  import { renameDefaultOptionsParametersTransform } from "../rename-default-options-parameters/rename-default-options-parameters-transform.js";
22
22
  import { renameDeferredResolveParametersTransform } from "../rename-deferred-resolve-parameters/rename-deferred-resolve-parameters-transform.js";
23
23
  import { renameDestructuredAliasesTransform } from "../rename-destructured-aliases/rename-destructured-aliases-transform.js";
24
+ import { renameDocumentFragmentVariablesTransform } from "../rename-document-fragment-variables/rename-document-fragment-variables-transform.js";
24
25
  import { renameErrorFirstCallbackParametersTransform } from "../rename-error-first-callback-parameters/rename-error-first-callback-parameters-transform.js";
25
26
  import { renameErrorVariablesTransform } from "../rename-error-variables/rename-error-variables-transform.js";
26
27
  import { renameEventParametersTransform } from "../rename-event-parameters/rename-event-parameters-transform.js";
@@ -48,6 +49,7 @@ import { renameStringSplitVariablesTransform } from "../rename-string-split-vari
48
49
  import { renameThisAliasesTransform } from "../rename-this-aliases/rename-this-aliases-transform.js";
49
50
  import { renameTimeoutDurationParametersTransform } from "../rename-timeout-duration-parameters/rename-timeout-duration-parameters-transform.js";
50
51
  import { renameTimeoutIdsTransform } from "../rename-timeout-ids/rename-timeout-ids-transform.js";
52
+ import { renameToBufferResultsTransform } from "../rename-to-buffer-results/rename-to-buffer-results-transform.js";
51
53
  import { renameTypeofVariablesTransform } from "../rename-typeof-variables/rename-typeof-variables-transform.js";
52
54
  import { renameTypescriptHelperAliasesTransform } from "../rename-typescript-helper-aliases/rename-typescript-helper-aliases-transform.js";
53
55
  import { renameUint8arrayConcatVariablesTransform } from "../rename-uint8array-concat-variables/rename-uint8array-concat-variables-transform.js";
@@ -87,6 +89,7 @@ export const transformRegistry = {
87
89
  [renameDefaultOptionsParametersTransform.id]: renameDefaultOptionsParametersTransform,
88
90
  [renameDeferredResolveParametersTransform.id]: renameDeferredResolveParametersTransform,
89
91
  [renameDestructuredAliasesTransform.id]: renameDestructuredAliasesTransform,
92
+ [renameDocumentFragmentVariablesTransform.id]: renameDocumentFragmentVariablesTransform,
90
93
  [renameErrorFirstCallbackParametersTransform.id]: renameErrorFirstCallbackParametersTransform,
91
94
  [renameErrorVariablesTransform.id]: renameErrorVariablesTransform,
92
95
  [renameEventParametersTransform.id]: renameEventParametersTransform,
@@ -114,6 +117,7 @@ export const transformRegistry = {
114
117
  [renameThisAliasesTransform.id]: renameThisAliasesTransform,
115
118
  [renameTimeoutDurationParametersTransform.id]: renameTimeoutDurationParametersTransform,
116
119
  [renameTimeoutIdsTransform.id]: renameTimeoutIdsTransform,
120
+ [renameToBufferResultsTransform.id]: renameToBufferResultsTransform,
117
121
  [renameTypeofVariablesTransform.id]: renameTypeofVariablesTransform,
118
122
  [renameTypescriptHelperAliasesTransform.id]: renameTypescriptHelperAliasesTransform,
119
123
  [renameUint8arrayConcatVariablesTransform.id]: renameUint8arrayConcatVariablesTransform,
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "recommended": {
3
- "diffSizePercent": 78.49401564414286,
4
- "notes": "Measured with baseline none: 78.49% of original diff."
3
+ "diffSizePercent": 78.49967015361418,
4
+ "notes": "Measured with baseline none: 78.50% of original diff. Stats re-evaluated against updated sources (Feb 2026)."
5
5
  }
6
6
  }
@@ -4,4 +4,4 @@
4
4
  * This lets us tune transform interactions intentionally instead of relying on
5
5
  * alphabetical ID sorting.
6
6
  */
7
- export declare const recommendedTransformOrder: readonly ["stabilize-top-level-bindings", "expand-boolean-literals", "expand-sequence-expressions-v5", "expand-special-number-literals", "expand-typeof-undefined-comparisons", "expand-undefined-literals", "remove-redundant-else", "rename-arguments-length-flags", "rename-asap-wrappers", "rename-awaiter-parameters", "rename-buffer-variables", "rename-catch-parameters", "rename-promise-catch-parameters", "rename-char-code-at", "rename-charcode-variables-v2", "rename-client-aliases", "rename-comparison-flags", "rename-date-now-start-times", "rename-default-options-parameters", "rename-deferred-resolve-parameters", "rename-destructured-aliases", "rename-error-first-callback-parameters", "rename-error-variables", "rename-event-parameters", "rename-fs-sync-variables", "rename-interval-ids", "rename-loop-index-variables-v3", "rename-loop-length-variables", "rename-object-keys-variables", "rename-parameters-to-match-properties-v2", "rename-promise-executor-parameters-v2", "rename-range-parameters", "rename-read-file-lines", "rename-regex-builders", "rename-rest-parameters", "rename-search-parameters-variables", "rename-string-split-variables", "rename-this-aliases", "rename-timeout-ids", "rename-typeof-variables", "rename-typescript-helper-aliases", "rename-uint8array-concat-variables", "rename-url-parameters", "rename-url-variables", "rename-use-reference-guards-v2", "rename-use-reference-sets", "rename-worker-handles", "simplify-boolean-negations", "simplify-string-trim", "split-variable-declarations", "use-optional-chaining", "use-object-property-shorthand", "use-object-shorthand", "replace-dynamic-require-eval"];
7
+ export declare const recommendedTransformOrder: readonly ["stabilize-top-level-bindings", "expand-boolean-literals", "expand-sequence-expressions-v5", "expand-special-number-literals", "expand-typeof-undefined-comparisons", "expand-undefined-literals", "remove-redundant-else", "rename-arguments-length-flags", "rename-asap-wrappers", "rename-awaiter-parameters", "rename-buffer-variables", "rename-to-buffer-results", "rename-catch-parameters", "rename-promise-catch-parameters", "rename-char-code-at", "rename-charcode-variables-v2", "rename-client-aliases", "rename-comparison-flags", "rename-date-now-start-times", "rename-default-options-parameters", "rename-deferred-resolve-parameters", "rename-destructured-aliases", "rename-error-first-callback-parameters", "rename-error-variables", "rename-event-parameters", "rename-fs-sync-variables", "rename-interval-ids", "rename-loop-index-variables-v3", "rename-loop-length-variables", "rename-document-fragment-variables", "rename-object-keys-variables", "rename-parameters-to-match-properties-v2", "rename-promise-executor-parameters-v2", "rename-range-parameters", "rename-read-file-lines", "rename-regex-builders", "rename-rest-parameters", "rename-search-parameters-variables", "rename-string-split-variables", "rename-this-aliases", "rename-timeout-ids", "rename-typeof-variables", "rename-typescript-helper-aliases", "rename-uint8array-concat-variables", "rename-url-parameters", "rename-url-variables", "rename-use-reference-guards-v2", "rename-use-reference-sets", "rename-worker-handles", "simplify-boolean-negations", "simplify-string-trim", "split-variable-declarations", "use-optional-chaining", "use-object-property-shorthand", "use-object-shorthand", "replace-dynamic-require-eval"];
@@ -18,6 +18,7 @@ export const recommendedTransformOrder = [
18
18
  "rename-asap-wrappers",
19
19
  "rename-awaiter-parameters",
20
20
  "rename-buffer-variables",
21
+ "rename-to-buffer-results",
21
22
  "rename-catch-parameters",
22
23
  "rename-promise-catch-parameters",
23
24
  "rename-char-code-at",
@@ -38,6 +39,7 @@ export const recommendedTransformOrder = [
38
39
  "rename-interval-ids",
39
40
  "rename-loop-index-variables-v3",
40
41
  "rename-loop-length-variables",
42
+ "rename-document-fragment-variables",
41
43
  "rename-object-keys-variables",
42
44
  "rename-parameters-to-match-properties-v2",
43
45
  "rename-promise-executor-parameters-v2",
@@ -0,0 +1,12 @@
1
+ {
2
+ "recommended": true,
3
+ "evaluations": {
4
+ "claude-code-2.1.10:claude-code-2.1.11": {
5
+ "diffSizePercent": 100,
6
+ "evaluatedAt": "2026-02-02T22:12:52.993Z",
7
+ "changedLines": 20,
8
+ "durationSeconds": 207.34089557,
9
+ "stableNames": 1358
10
+ }
11
+ }
12
+ }
@@ -0,0 +1,2 @@
1
+ import { type Transform } from "../../core/types.js";
2
+ export declare const renameDocumentFragmentVariablesTransform: Transform;
@@ -0,0 +1,84 @@
1
+ import { createRequire } from "node:module";
2
+ import { collectExportedNames } from "../../core/collect-exported-names.js";
3
+ import { isStableRenamed, RenameGroup } from "../../core/stable-naming.js";
4
+ import { getFilesToProcess, } from "../../core/types.js";
5
+ import * as t from "@babel/types";
6
+ const require = createRequire(import.meta.url);
7
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
8
+ const traverse = require("@babel/traverse").default;
9
+ const BASE_NAME = "documentFragment";
10
+ const METHOD_NAME = "createDocumentFragment";
11
+ const isCreateDocumentFragmentCall = (init) => {
12
+ if (!init)
13
+ return false;
14
+ if (init.type !== "CallExpression" && init.type !== "OptionalCallExpression")
15
+ return false;
16
+ if (init.arguments.length > 0)
17
+ return false;
18
+ if (init.callee.type !== "MemberExpression" &&
19
+ init.callee.type !== "OptionalMemberExpression")
20
+ return false;
21
+ if (init.callee.computed) {
22
+ if (t.isStringLiteral(init.callee.property) &&
23
+ init.callee.property.value === METHOD_NAME) {
24
+ return true;
25
+ }
26
+ if (t.isTemplateLiteral(init.callee.property) &&
27
+ init.callee.property.expressions.length === 0 &&
28
+ init.callee.property.quasis.length === 1) {
29
+ const quasi = init.callee.property.quasis[0];
30
+ return quasi?.value.cooked === METHOD_NAME;
31
+ }
32
+ return false;
33
+ }
34
+ return (init.callee.property.type === "Identifier" &&
35
+ init.callee.property.name === METHOD_NAME);
36
+ };
37
+ const getDocumentFragmentIdentifier = (declarator) => {
38
+ if (declarator.id.type !== "Identifier")
39
+ return undefined;
40
+ if (!isCreateDocumentFragmentCall(declarator.init))
41
+ return undefined;
42
+ return declarator.id;
43
+ };
44
+ export const renameDocumentFragmentVariablesTransform = {
45
+ id: "rename-document-fragment-variables",
46
+ description: "Renames variables assigned from createDocumentFragment() to a stable $documentFragment (or suffixed variant when needed) when unique in scope, otherwise uses readable documentFragment/documentFragment2/...",
47
+ scope: "file",
48
+ parallelizable: true,
49
+ transform(context) {
50
+ let nodesVisited = 0;
51
+ let transformationsApplied = 0;
52
+ for (const fileInfo of getFilesToProcess(context)) {
53
+ const group = new RenameGroup();
54
+ const exportedNames = collectExportedNames(fileInfo.ast.program);
55
+ traverse(fileInfo.ast, {
56
+ VariableDeclarator(path) {
57
+ nodesVisited++;
58
+ const identifier = getDocumentFragmentIdentifier(path.node);
59
+ if (!identifier)
60
+ return;
61
+ if (isStableRenamed(identifier.name))
62
+ return;
63
+ const currentName = identifier.name;
64
+ const binding = path.scope.getBinding(identifier.name);
65
+ if (!binding)
66
+ return;
67
+ if (!binding.constant)
68
+ return;
69
+ if (binding.scope.block.type === "Program" &&
70
+ exportedNames.has(currentName)) {
71
+ return;
72
+ }
73
+ group.add({
74
+ scope: binding.scope,
75
+ currentName,
76
+ baseName: BASE_NAME,
77
+ });
78
+ },
79
+ });
80
+ transformationsApplied += group.apply();
81
+ }
82
+ return Promise.resolve({ nodesVisited, transformationsApplied });
83
+ },
84
+ };
@@ -0,0 +1,12 @@
1
+ {
2
+ "recommended": true,
3
+ "evaluations": {
4
+ "claude-code-2.1.10:claude-code-2.1.11": {
5
+ "diffSizePercent": 100,
6
+ "evaluatedAt": "2026-02-04T13:06:29.691Z",
7
+ "changedLines": 56,
8
+ "durationSeconds": 171.52518661899998,
9
+ "stableNames": 1359
10
+ }
11
+ }
12
+ }
@@ -0,0 +1,2 @@
1
+ import { type Transform } from "../../core/types.js";
2
+ export declare const renameToBufferResultsTransform: Transform;
@@ -0,0 +1,83 @@
1
+ import { createRequire } from "node:module";
2
+ import { RenameGroup, isStableRenamed } from "../../core/stable-naming.js";
3
+ import { getFilesToProcess, } from "../../core/types.js";
4
+ const require = createRequire(import.meta.url);
5
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
6
+ const traverse = require("@babel/traverse").default;
7
+ const isToBufferCall = (callee) => {
8
+ if (callee.type !== "MemberExpression" &&
9
+ callee.type !== "OptionalMemberExpression") {
10
+ return false;
11
+ }
12
+ if (callee.computed) {
13
+ if (callee.property.type === "StringLiteral") {
14
+ return callee.property.value === "toBuffer";
15
+ }
16
+ if (callee.property.type === "TemplateLiteral" &&
17
+ callee.property.expressions.length === 0 &&
18
+ callee.property.quasis.length === 1) {
19
+ const quasi = callee.property.quasis[0];
20
+ return quasi?.value.cooked === "toBuffer";
21
+ }
22
+ return false;
23
+ }
24
+ return (callee.property.type === "Identifier" && callee.property.name === "toBuffer");
25
+ };
26
+ export const renameToBufferResultsTransform = {
27
+ id: "rename-to-buffer-results",
28
+ description: "Renames variables assigned from toBuffer() results to buffer",
29
+ scope: "file",
30
+ parallelizable: true,
31
+ transform(context) {
32
+ let nodesVisited = 0;
33
+ let transformationsApplied = 0;
34
+ for (const fileInfo of getFilesToProcess(context)) {
35
+ const renameGroup = new RenameGroup();
36
+ traverse(fileInfo.ast, {
37
+ VariableDeclarator(path) {
38
+ nodesVisited++;
39
+ const { id, init } = path.node;
40
+ if (!init || id.type !== "Identifier") {
41
+ return;
42
+ }
43
+ let callExpression;
44
+ if (init.type === "CallExpression" ||
45
+ init.type === "OptionalCallExpression") {
46
+ callExpression = init;
47
+ }
48
+ else if (init.type === "AwaitExpression") {
49
+ if (init.argument.type !== "CallExpression" &&
50
+ init.argument.type !== "OptionalCallExpression") {
51
+ return;
52
+ }
53
+ callExpression = init.argument;
54
+ }
55
+ else {
56
+ return;
57
+ }
58
+ if (!isToBufferCall(callExpression.callee)) {
59
+ return;
60
+ }
61
+ const currentName = id.name;
62
+ if (isStableRenamed(currentName)) {
63
+ return;
64
+ }
65
+ if (currentName.toLowerCase().includes("buffer")) {
66
+ return;
67
+ }
68
+ const binding = path.scope.getBinding(currentName);
69
+ if (!binding?.constant) {
70
+ return;
71
+ }
72
+ renameGroup.add({
73
+ scope: path.scope,
74
+ currentName,
75
+ baseName: "buffer",
76
+ });
77
+ },
78
+ });
79
+ transformationsApplied += renameGroup.apply();
80
+ }
81
+ return Promise.resolve({ nodesVisited, transformationsApplied });
82
+ },
83
+ };
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "miniread",
3
3
  "author": "Łukasz Jerciński",
4
4
  "license": "MIT",
5
- "version": "1.60.1",
5
+ "version": "1.62.0",
6
6
  "description": "Transform minified JavaScript/TypeScript into a more readable form using deterministic AST-based transforms.",
7
7
  "repository": {
8
8
  "type": "git",