miniread 1.98.1 → 1.99.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.
@@ -183,6 +183,10 @@ const manifestData = {
183
183
  notes: "Measured with baseline none: 0.00%.",
184
184
  evaluations: { "legacy:evaluation": { "evaluatedAt": "2026-01-25T20:05:17.827Z", "changedLines": 208, "durationSeconds": 0, "stableNames": 0, "diffSizePercent": 100 }, "claude-code-2.1.10:claude-code-2.1.11": { "diffSizePercent": 100, "evaluatedAt": "2026-01-25T23:22:33.139Z", "changedLines": 208, "durationSeconds": 54.654894917, "stableNames": 1358 } },
185
185
  },
186
+ "rename-map-by-id-variables": {
187
+ recommended: true,
188
+ evaluations: { "claude-code-2.1.10:claude-code-2.1.11": { "diffSizePercent": 100, "evaluatedAt": "2026-02-06T12:52:16.704Z", "changedLines": 6, "durationSeconds": 163.81482910900002, "stableNames": 1359 } },
189
+ },
186
190
  "rename-object-entries-parameters": {
187
191
  recommended: true,
188
192
  evaluations: { "claude-code-2.1.10:claude-code-2.1.11": { "diffSizePercent": 100, "evaluatedAt": "2026-02-06T17:39:17.299Z", "changedLines": 248, "durationSeconds": 215.530500649, "stableNames": 1358 } },
@@ -230,7 +234,7 @@ const manifestData = {
230
234
  },
231
235
  "rename-queue-traversal-variables": {
232
236
  recommended: true,
233
- evaluations: { "claude-code-2.1.10:claude-code-2.1.11": { "diffSizePercent": 100, "evaluatedAt": "2026-02-06T21:04:31.256Z", "changedLines": 38, "durationSeconds": 223.94200929, "stableNames": 1359 } },
237
+ evaluations: { "claude-code-2.1.10:claude-code-2.1.11": { "diffSizePercent": 100, "evaluatedAt": "2026-02-07T12:35:06.451Z", "changedLines": 38, "durationSeconds": 202.665566898, "stableNames": 1359 } },
234
238
  },
235
239
  "rename-range-parameters": {
236
240
  recommended: true,
@@ -457,6 +461,7 @@ export const recommendedTransformIds = [
457
461
  "rename-document-fragment-variables",
458
462
  "rename-object-keys-variables",
459
463
  "rename-object-keys-iterator-variables",
464
+ "rename-map-by-id-variables",
460
465
  "rename-object-property-value-variables",
461
466
  "rename-object-keys-reducer-parameters",
462
467
  "rename-object-entries-parameters",
@@ -38,6 +38,7 @@ import { renameIntervalIdsTransform } from "../rename-interval-ids/rename-interv
38
38
  import { renameInvalidParameterArgumentsTransform } from "../rename-invalid-parameter-arguments/rename-invalid-parameter-arguments-transform.js";
39
39
  import { renameLoopIndexVariablesV3Transform } from "../rename-loop-index-variables-v3/rename-loop-index-variables-v3-transform.js";
40
40
  import { renameLoopLengthVariablesTransform } from "../rename-loop-length-variables/rename-loop-length-variables-transform.js";
41
+ import { renameMapByIdVariablesTransform } from "../rename-map-by-id-variables/rename-map-by-id-variables-transform.js";
41
42
  import { renameObjectEntriesParametersTransform } from "../rename-object-entries-parameters/rename-object-entries-parameters-transform.js";
42
43
  import { renameObjectKeysIteratorVariablesTransform } from "../rename-object-keys-iterator-variables/rename-object-keys-iterator-variables-transform.js";
43
44
  import { renameObjectKeysReducerParametersTransform } from "../rename-object-keys-reducer-parameters/rename-object-keys-reducer-parameters-transform.js";
@@ -122,6 +123,7 @@ export const transformRegistry = {
122
123
  [renameInvalidParameterArgumentsTransform.id]: renameInvalidParameterArgumentsTransform,
123
124
  [renameLoopIndexVariablesV3Transform.id]: renameLoopIndexVariablesV3Transform,
124
125
  [renameLoopLengthVariablesTransform.id]: renameLoopLengthVariablesTransform,
126
+ [renameMapByIdVariablesTransform.id]: renameMapByIdVariablesTransform,
125
127
  [renameObjectEntriesParametersTransform.id]: renameObjectEntriesParametersTransform,
126
128
  [renameObjectKeysIteratorVariablesTransform.id]: renameObjectKeysIteratorVariablesTransform,
127
129
  [renameObjectKeysReducerParametersTransform.id]: renameObjectKeysReducerParametersTransform,
@@ -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", "stabilize-nested-bindings", "stabilize-deferred-top-level-bindings", "stabilize-deferred-stable-rhs", "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-awaiter-helper-functions", "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-platform-win32-flags", "rename-date-now-start-times", "rename-default-options-parameters-v3", "rename-deferred-resolve-parameters", "rename-deferred-resolve-parameters-v2", "rename-destructured-aliases", "rename-rest-parameters", "rename-rest-pop-callbacks", "rename-execfile-arguments", "rename-file-reader-variables", "rename-error-first-callback-parameters", "rename-error-first-callback-parameters-v2", "rename-error-variables", "rename-event-parameters", "rename-add-event-listener-parameters", "rename-http-server-parameters", "rename-fs-sync-variables", "rename-http-method-parameters", "rename-interval-ids", "rename-indexeddb-request-variables", "rename-loop-index-variables-v3", "rename-queue-traversal-variables", "rename-loop-length-variables", "rename-document-fragment-variables", "rename-object-keys-variables", "rename-object-keys-iterator-variables", "rename-object-property-value-variables", "rename-object-keys-reducer-parameters", "rename-object-entries-parameters", "rename-parameters-to-match-properties-v2", "rename-invalid-parameter-arguments", "rename-promise-executor-parameters-v2", "rename-range-parameters", "rename-read-file-lines", "rename-regex-builders", "rename-regex-source-parameters", "rename-search-parameters-variables", "rename-setstate-updater-parameters", "rename-file-extension-variables", "rename-string-split-variables-v2", "rename-this-aliases", "rename-timeout-promises", "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", "rename-zod-check-parameters", "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", "stabilize-nested-bindings", "stabilize-deferred-top-level-bindings", "stabilize-deferred-stable-rhs", "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-awaiter-helper-functions", "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-platform-win32-flags", "rename-date-now-start-times", "rename-default-options-parameters-v3", "rename-deferred-resolve-parameters", "rename-deferred-resolve-parameters-v2", "rename-destructured-aliases", "rename-rest-parameters", "rename-rest-pop-callbacks", "rename-execfile-arguments", "rename-file-reader-variables", "rename-error-first-callback-parameters", "rename-error-first-callback-parameters-v2", "rename-error-variables", "rename-event-parameters", "rename-add-event-listener-parameters", "rename-http-server-parameters", "rename-fs-sync-variables", "rename-http-method-parameters", "rename-interval-ids", "rename-indexeddb-request-variables", "rename-loop-index-variables-v3", "rename-queue-traversal-variables", "rename-loop-length-variables", "rename-document-fragment-variables", "rename-object-keys-variables", "rename-object-keys-iterator-variables", "rename-map-by-id-variables", "rename-object-property-value-variables", "rename-object-keys-reducer-parameters", "rename-object-entries-parameters", "rename-parameters-to-match-properties-v2", "rename-invalid-parameter-arguments", "rename-promise-executor-parameters-v2", "rename-range-parameters", "rename-read-file-lines", "rename-regex-builders", "rename-regex-source-parameters", "rename-search-parameters-variables", "rename-setstate-updater-parameters", "rename-file-extension-variables", "rename-string-split-variables-v2", "rename-this-aliases", "rename-timeout-promises", "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", "rename-zod-check-parameters", "simplify-boolean-negations", "simplify-string-trim", "split-variable-declarations", "use-optional-chaining", "use-object-property-shorthand", "use-object-shorthand", "replace-dynamic-require-eval"];
@@ -65,6 +65,7 @@ export const recommendedTransformOrder = [
65
65
  "rename-document-fragment-variables",
66
66
  "rename-object-keys-variables",
67
67
  "rename-object-keys-iterator-variables",
68
+ "rename-map-by-id-variables",
68
69
  "rename-object-property-value-variables",
69
70
  "rename-object-keys-reducer-parameters",
70
71
  "rename-object-entries-parameters",
@@ -0,0 +1,10 @@
1
+ import type { Binding, NodePath } from "@babel/traverse";
2
+ import type { Statement } from "@babel/types";
3
+ type MapByIdPattern = {
4
+ mapBinding: Binding;
5
+ itemBinding: Binding;
6
+ itemBaseName: string;
7
+ mapBaseName: string;
8
+ };
9
+ export declare const getMapByIdPattern: (statements: NodePath<Statement>[], index: number) => MapByIdPattern | undefined;
10
+ export {};
@@ -0,0 +1,112 @@
1
+ import * as t from "@babel/types";
2
+ import { isValidBindingIdentifier } from "../shared/is-valid-binding-identifier.js";
3
+ export const getMapByIdPattern = (statements, index) => {
4
+ const declarationPath = statements[index];
5
+ const loopPath = statements[index + 1];
6
+ const returnPath = statements[index + 2];
7
+ if (!declarationPath?.isVariableDeclaration() ||
8
+ !loopPath?.isForOfStatement() ||
9
+ !returnPath?.isReturnStatement()) {
10
+ return undefined;
11
+ }
12
+ const declaration = declarationPath.node;
13
+ if (declaration.declarations.length !== 1)
14
+ return undefined;
15
+ const declarator = declaration.declarations[0];
16
+ if (!declarator ||
17
+ !t.isIdentifier(declarator.id) ||
18
+ !declarator.init ||
19
+ !t.isNewExpression(declarator.init) ||
20
+ !t.isIdentifier(declarator.init.callee) ||
21
+ declarator.init.callee.name !== "Map") {
22
+ return undefined;
23
+ }
24
+ if (declarationPath.scope.getBinding("Map"))
25
+ return undefined;
26
+ const mapName = declarator.id.name;
27
+ const mapBinding = declarationPath.scope.getBinding(mapName);
28
+ if (mapBinding?.identifier !== declarator.id || !mapBinding.constant) {
29
+ return undefined;
30
+ }
31
+ const loopLeft = loopPath.node.left;
32
+ if (!t.isVariableDeclaration(loopLeft))
33
+ return undefined;
34
+ if (loopLeft.declarations.length !== 1)
35
+ return undefined;
36
+ const loopDeclarator = loopLeft.declarations[0];
37
+ if (!loopDeclarator ||
38
+ !t.isIdentifier(loopDeclarator.id) ||
39
+ loopDeclarator.init) {
40
+ return undefined;
41
+ }
42
+ const itemName = loopDeclarator.id.name;
43
+ const itemBinding = loopPath.scope.getBinding(itemName);
44
+ if (itemBinding?.identifier !== loopDeclarator.id || !itemBinding.constant) {
45
+ return undefined;
46
+ }
47
+ const loopBody = loopPath.node.body;
48
+ if (t.isBlockStatement(loopBody) && loopBody.body.length !== 1) {
49
+ return undefined;
50
+ }
51
+ const loopStatement = t.isBlockStatement(loopBody)
52
+ ? loopBody.body[0]
53
+ : loopBody;
54
+ if (!loopStatement || !t.isExpressionStatement(loopStatement)) {
55
+ return undefined;
56
+ }
57
+ if (!t.isCallExpression(loopStatement.expression)) {
58
+ return undefined;
59
+ }
60
+ const callExpression = loopStatement.expression;
61
+ if (!t.isMemberExpression(callExpression.callee) ||
62
+ !t.isIdentifier(callExpression.callee.object) ||
63
+ callExpression.callee.object.name !== mapName ||
64
+ callExpression.callee.computed ||
65
+ !t.isIdentifier(callExpression.callee.property) ||
66
+ callExpression.callee.property.name !== "set" ||
67
+ callExpression.arguments.length !== 2) {
68
+ return undefined;
69
+ }
70
+ const loopMapBinding = loopPath.scope.getBinding(callExpression.callee.object.name);
71
+ if (loopMapBinding !== mapBinding)
72
+ return undefined;
73
+ const [keyArgument, valueArgument] = callExpression.arguments;
74
+ if (!keyArgument ||
75
+ !valueArgument ||
76
+ !t.isMemberExpression(keyArgument) ||
77
+ keyArgument.computed ||
78
+ !t.isIdentifier(keyArgument.object) ||
79
+ !t.isIdentifier(keyArgument.property) ||
80
+ keyArgument.object.name !== itemName ||
81
+ !t.isIdentifier(valueArgument) ||
82
+ valueArgument.name !== itemName) {
83
+ return undefined;
84
+ }
85
+ const keyObjectBinding = loopPath.scope.getBinding(keyArgument.object.name);
86
+ const valueBinding = loopPath.scope.getBinding(valueArgument.name);
87
+ if (keyObjectBinding !== itemBinding || valueBinding !== itemBinding) {
88
+ return undefined;
89
+ }
90
+ const returnArgument = returnPath.node.argument;
91
+ if (!t.isIdentifier(returnArgument) || returnArgument.name !== mapName) {
92
+ return undefined;
93
+ }
94
+ const returnMapBinding = returnPath.scope.getBinding(returnArgument.name);
95
+ if (returnMapBinding !== mapBinding)
96
+ return undefined;
97
+ const propertyName = keyArgument.property.name;
98
+ // Intentionally require exact case-sensitive `Id` suffix to keep matching precise.
99
+ if (!propertyName.endsWith("Id"))
100
+ return undefined;
101
+ const itemBaseName = propertyName.slice(0, -2);
102
+ const mapBaseName = `${itemBaseName}ById`;
103
+ if (itemBaseName.length === 0 || !isValidBindingIdentifier(itemBaseName)) {
104
+ return undefined;
105
+ }
106
+ return {
107
+ mapBinding,
108
+ itemBinding,
109
+ itemBaseName,
110
+ mapBaseName,
111
+ };
112
+ };
@@ -0,0 +1,13 @@
1
+ {
2
+ "recommended": true,
3
+ "evaluations": {
4
+ "claude-code-2.1.10:claude-code-2.1.11": {
5
+ "diffSizePercent": 100,
6
+ "evaluatedAt": "2026-02-06T12:52:16.704Z",
7
+ "changedLines": 6,
8
+ "durationSeconds": 163.81482910900002,
9
+ "stableNames": 1359
10
+ }
11
+ },
12
+ "notes": ""
13
+ }
@@ -0,0 +1,2 @@
1
+ import { type Transform } from "../../core/types.js";
2
+ export declare const renameMapByIdVariablesTransform: Transform;
@@ -0,0 +1,59 @@
1
+ import { createRequire } from "node:module";
2
+ import { isStableRenamed, RenameGroup } from "../../core/stable-naming.js";
3
+ import { getFilesToProcess, } from "../../core/types.js";
4
+ import { hasDynamicNameLookup } from "../has-dynamic-name-lookup.js";
5
+ import { getMapByIdPattern } from "./get-map-by-id-pattern.js";
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
+ export const renameMapByIdVariablesTransform = {
10
+ id: "rename-map-by-id-variables",
11
+ description: "Renames simple Map builders keyed by *.Id properties to names like schemeById/scheme, using stable $-prefixed variants when available.",
12
+ scope: "file",
13
+ parallelizable: true,
14
+ transform(context) {
15
+ let nodesVisited = 0;
16
+ let transformationsApplied = 0;
17
+ for (const fileInfo of getFilesToProcess(context)) {
18
+ if (hasDynamicNameLookup(fileInfo.ast))
19
+ continue;
20
+ const group = new RenameGroup();
21
+ traverse(fileInfo.ast, {
22
+ Function(path) {
23
+ nodesVisited++;
24
+ const bodyPath = path.get("body");
25
+ if (!bodyPath.isBlockStatement())
26
+ return;
27
+ const statements = bodyPath.get("body");
28
+ if (statements.length < 3)
29
+ return;
30
+ for (let index = 0; index <= statements.length - 3; index++) {
31
+ const pattern = getMapByIdPattern(statements, index);
32
+ if (!pattern)
33
+ continue;
34
+ const mapCurrentName = pattern.mapBinding.identifier.name;
35
+ const itemCurrentName = pattern.itemBinding.identifier.name;
36
+ const mapIsStable = isStableRenamed(mapCurrentName);
37
+ const itemIsStable = isStableRenamed(itemCurrentName);
38
+ if (!mapIsStable) {
39
+ group.add({
40
+ scope: pattern.mapBinding.scope,
41
+ currentName: mapCurrentName,
42
+ baseName: pattern.mapBaseName,
43
+ });
44
+ }
45
+ if (!itemIsStable) {
46
+ group.add({
47
+ scope: pattern.itemBinding.scope,
48
+ currentName: itemCurrentName,
49
+ baseName: pattern.itemBaseName,
50
+ });
51
+ }
52
+ }
53
+ },
54
+ });
55
+ transformationsApplied += group.apply();
56
+ }
57
+ return Promise.resolve({ nodesVisited, transformationsApplied });
58
+ },
59
+ };
@@ -3,9 +3,9 @@
3
3
  "evaluations": {
4
4
  "claude-code-2.1.10:claude-code-2.1.11": {
5
5
  "diffSizePercent": 100,
6
- "evaluatedAt": "2026-02-06T21:04:31.256Z",
6
+ "evaluatedAt": "2026-02-07T12:35:06.451Z",
7
7
  "changedLines": 38,
8
- "durationSeconds": 223.94200929,
8
+ "durationSeconds": 202.665566898,
9
9
  "stableNames": 1359
10
10
  }
11
11
  }
@@ -104,17 +104,31 @@ const getQueueTraversalUsage = (path, arrayName, indexName) => {
104
104
  innerPath.skip();
105
105
  },
106
106
  MemberExpression(memberPath) {
107
+ if (hasIndexAccess && hasQueuePush) {
108
+ memberPath.stop();
109
+ return;
110
+ }
107
111
  if (hasIndexAccess)
108
112
  return;
109
113
  if (isQueueIndexAccess(memberPath, arrayName, indexName, arrayBinding, indexBinding)) {
110
114
  hasIndexAccess = true;
115
+ if (hasQueuePush) {
116
+ memberPath.stop();
117
+ }
111
118
  }
112
119
  },
113
120
  CallExpression(callPath) {
121
+ if (hasIndexAccess && hasQueuePush) {
122
+ callPath.stop();
123
+ return;
124
+ }
114
125
  if (hasQueuePush)
115
126
  return;
116
127
  if (isQueuePushCall(callPath, arrayName, arrayBinding)) {
117
128
  hasQueuePush = true;
129
+ if (hasIndexAccess) {
130
+ callPath.stop();
131
+ }
118
132
  }
119
133
  },
120
134
  });
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.98.1",
5
+ "version": "1.99.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",