expose-kit 0.10.3 → 0.11.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.
package/README.md CHANGED
@@ -110,6 +110,8 @@ After `safe-scope`, combine common techniques like:
110
110
  After **each step**, run `parsable` and `remove-unused` again.
111
111
  (even if it's not frequent, we might overlook something broken)
112
112
 
113
+ The more you do it, the clearer it becomes.
114
+
113
115
  Expose Kit will also clearly indicate whether a **diff** exists, making inspection easy.
114
116
 
115
117
  Repeat this process, and the original code will gradually reveal itself.
@@ -324,6 +326,38 @@ Notes:
324
326
 
325
327
  ---
326
328
 
329
+ ### `expose remove-deadcode`
330
+
331
+ Remove unreachable branches and simplify conditional expressions.
332
+ ```js
333
+ if (true) {
334
+ a();
335
+ } else {
336
+ b();
337
+ }
338
+ // after
339
+ a();
340
+
341
+ const x = cond ? true : false;
342
+ // after
343
+ const x = !!cond;
344
+ ```
345
+ Example is [here](https://github.com/evex-dev/expose-kit/tree/main/commands/remove-deadcode/mocks).
346
+
347
+ ```bash
348
+ expose remove-deadcode path/to/file.js --output path/to/file.remove-deadcode.js
349
+ ```
350
+
351
+ Args:
352
+ - `--o, --output <file>`
353
+ Output file path
354
+
355
+ Notes:
356
+ - Only removes branches with literal/array/object tests.
357
+ - Simplifies ternaries when both branches are booleans.
358
+
359
+ ---
360
+
327
361
  ### `expose fn-inliner`
328
362
 
329
363
  Inline proxy function calls into expressions.
package/dist/index.js CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  // index.ts
4
4
  import { Command } from "commander";
5
- import { dirname as dirname11, join as join11 } from "path";
5
+ import { dirname as dirname12, join as join12 } from "path";
6
6
  import { fileURLToPath } from "url";
7
7
  import chalk4 from "chalk";
8
8
 
@@ -1780,7 +1780,7 @@ var remove_unused_default = createCommand((program3) => {
1780
1780
  );
1781
1781
  });
1782
1782
 
1783
- // commands/fn-inliner/index.ts
1783
+ // commands/remove-deadcode/index.ts
1784
1784
  import { readFileSync as readFileSync10, writeFileSync as writeFileSync9 } from "fs";
1785
1785
  import { basename as basename9, dirname as dirname9, extname as extname9, join as join9 } from "path";
1786
1786
  import { parse as parse10 } from "@babel/parser";
@@ -1792,24 +1792,185 @@ var walk = patchDefault(traverse9);
1792
1792
  var createDefaultOutputPath9 = (inputPath) => {
1793
1793
  const ext = extname9(inputPath);
1794
1794
  if (!ext) {
1795
- return `${inputPath}.fn-inliner.js`;
1795
+ return `${inputPath}.remove-deadcode.js`;
1796
1796
  }
1797
1797
  const base = basename9(inputPath, ext);
1798
- return join9(dirname9(inputPath), `${base}.fn-inliner${ext}`);
1798
+ return join9(dirname9(inputPath), `${base}.remove-deadcode${ext}`);
1799
+ };
1800
+ var isSemiLiteral = (node) => {
1801
+ return t8.isLiteral(node) || t8.isArrayExpression(node) || t8.isObjectExpression(node);
1802
+ };
1803
+ var isTruthy = (literal) => {
1804
+ if (t8.isBooleanLiteral(literal) || t8.isNumericLiteral(literal)) {
1805
+ return Boolean(literal.value);
1806
+ }
1807
+ if (t8.isStringLiteral(literal)) {
1808
+ return literal.value.length > 0;
1809
+ }
1810
+ if (t8.isNullLiteral(literal)) {
1811
+ return false;
1812
+ }
1813
+ if (t8.isBigIntLiteral(literal)) {
1814
+ return literal.value !== "0";
1815
+ }
1816
+ return true;
1817
+ };
1818
+ var replaceWithStatements = (path, statements) => {
1819
+ const parent = path.parentPath;
1820
+ if (parent?.isBlockStatement() || parent?.isProgram() || parent?.isSwitchCase()) {
1821
+ path.replaceWithMultiple(statements);
1822
+ return;
1823
+ }
1824
+ if (statements.length === 0) {
1825
+ path.remove();
1826
+ return;
1827
+ }
1828
+ if (statements.length === 1 && statements[0]) {
1829
+ path.replaceWith(statements[0]);
1830
+ return;
1831
+ }
1832
+ path.replaceWith(t8.blockStatement(statements));
1833
+ };
1834
+ var removeDeadCode = (code, filename) => {
1835
+ const ast = parse10(code, createParseOptions(filename));
1836
+ let changedCount = 0;
1837
+ walk(ast, {
1838
+ IfStatement(path) {
1839
+ if (!isSemiLiteral(path.node.test)) return;
1840
+ if (isTruthy(path.node.test)) {
1841
+ const statements = t8.isBlockStatement(path.node.consequent) ? path.node.consequent.body : [path.node.consequent];
1842
+ replaceWithStatements(path, statements);
1843
+ } else {
1844
+ if (path.node.alternate) {
1845
+ if (t8.isBlockStatement(path.node.alternate)) {
1846
+ replaceWithStatements(path, path.node.alternate.body);
1847
+ } else {
1848
+ replaceWithStatements(path, [path.node.alternate]);
1849
+ }
1850
+ } else {
1851
+ path.remove();
1852
+ }
1853
+ }
1854
+ changedCount += 1;
1855
+ },
1856
+ ConditionalExpression(path) {
1857
+ if (isSemiLiteral(path.node.test)) {
1858
+ const replacement = isTruthy(path.node.test) ? path.node.consequent : path.node.alternate;
1859
+ path.replaceWith(replacement);
1860
+ changedCount += 1;
1861
+ return;
1862
+ }
1863
+ if (t8.isBooleanLiteral(path.node.consequent) && t8.isBooleanLiteral(path.node.alternate)) {
1864
+ const consequent = path.node.consequent.value;
1865
+ const alternate = path.node.alternate.value;
1866
+ let replacement;
1867
+ if (consequent && !alternate) {
1868
+ replacement = t8.unaryExpression(
1869
+ "!",
1870
+ t8.unaryExpression("!", path.node.test)
1871
+ );
1872
+ } else if (!consequent && alternate) {
1873
+ replacement = t8.unaryExpression("!", path.node.test);
1874
+ } else if (consequent && alternate) {
1875
+ replacement = t8.sequenceExpression([
1876
+ path.node.test,
1877
+ t8.booleanLiteral(true)
1878
+ ]);
1879
+ } else {
1880
+ replacement = t8.sequenceExpression([
1881
+ path.node.test,
1882
+ t8.booleanLiteral(false)
1883
+ ]);
1884
+ }
1885
+ path.replaceWith(replacement);
1886
+ changedCount += 1;
1887
+ }
1888
+ }
1889
+ });
1890
+ return {
1891
+ code: patchDefault(generate9)(ast).code,
1892
+ changedCount
1893
+ };
1894
+ };
1895
+ var remove_deadcode_default = createCommand((program3) => {
1896
+ program3.command("remove-deadcode").description("Remove unreachable branches and simplify conditional expressions").argument("[file]", "The file to transform").option("--input, --file <file>", "The file to transform").option("--o, --output <file>", "Output file path").option("--unlimited", "Unlimited timeout").action(
1897
+ async (fileArgument, options) => {
1898
+ await timeout(
1899
+ async ({ finish }) => {
1900
+ const filename = fileArgument ?? options.file ?? await createPrompt("Enter the file path:");
1901
+ if (!filename) {
1902
+ showError("No file provided");
1903
+ return finish();
1904
+ }
1905
+ try {
1906
+ const fileContent = readFileSync10(filename, "utf8");
1907
+ const defaultOutputPath = createDefaultOutputPath9(filename);
1908
+ let outputPath = options.output;
1909
+ if (!outputPath) {
1910
+ const promptPath = (await createPrompt("Enter the output file path:"))?.trim();
1911
+ outputPath = promptPath || defaultOutputPath;
1912
+ }
1913
+ const loader = loading10("Removing dead code...").start();
1914
+ try {
1915
+ const { code: output, changedCount } = removeDeadCode(
1916
+ fileContent,
1917
+ filename
1918
+ );
1919
+ writeFileSync9(outputPath, output, "utf8");
1920
+ loader.succeed(
1921
+ `Saved remove-deadcode file to: ${outputPath} (${diff(fileContent, output).length} lines changed, ${changedCount} edits)`
1922
+ );
1923
+ return finish();
1924
+ } catch (error) {
1925
+ loader.fail("Failed to apply remove-deadcode transform");
1926
+ showError(
1927
+ `Error transforming file '${filename}': ${error instanceof Error ? error.message : "Unknown error"}`
1928
+ );
1929
+ return finish();
1930
+ }
1931
+ } catch (error) {
1932
+ showError(
1933
+ `Error reading file '${filename}': ${error instanceof Error ? error.message : "Unknown error"}`
1934
+ );
1935
+ return finish();
1936
+ }
1937
+ },
1938
+ options.unlimited ? null : 120 * 1e3
1939
+ );
1940
+ }
1941
+ );
1942
+ });
1943
+
1944
+ // commands/fn-inliner/index.ts
1945
+ import { readFileSync as readFileSync11, writeFileSync as writeFileSync10 } from "fs";
1946
+ import { basename as basename10, dirname as dirname10, extname as extname10, join as join10 } from "path";
1947
+ import { parse as parse11 } from "@babel/parser";
1948
+ import traverse10 from "@babel/traverse";
1949
+ import generate10 from "@babel/generator";
1950
+ import * as t9 from "@babel/types";
1951
+ import loading11 from "loading-cli";
1952
+ var walk2 = patchDefault(traverse10);
1953
+ var createDefaultOutputPath10 = (inputPath) => {
1954
+ const ext = extname10(inputPath);
1955
+ if (!ext) {
1956
+ return `${inputPath}.fn-inliner.js`;
1957
+ }
1958
+ const base = basename10(inputPath, ext);
1959
+ return join10(dirname10(inputPath), `${base}.fn-inliner${ext}`);
1799
1960
  };
1800
1961
  var isProxyFunctionExpression = (node) => {
1801
- return t8.isFunction(node) && node.params.every((param) => t8.isIdentifier(param)) && (t8.isBlockStatement(node.body) && node.body.body.length === 1 && t8.isReturnStatement(node.body.body[0]) && (node.body.body[0].argument === void 0 || t8.isExpression(node.body.body[0].argument) && isProxyValue(node.body.body[0].argument)) || t8.isArrowFunctionExpression(node) && t8.isExpression(node.body) && isProxyValue(node.body));
1962
+ return t9.isFunction(node) && node.params.every((param) => t9.isIdentifier(param)) && (t9.isBlockStatement(node.body) && node.body.body.length === 1 && t9.isReturnStatement(node.body.body[0]) && (node.body.body[0].argument === void 0 || t9.isExpression(node.body.body[0].argument) && isProxyValue(node.body.body[0].argument)) || t9.isArrowFunctionExpression(node) && t9.isExpression(node.body) && isProxyValue(node.body));
1802
1963
  };
1803
1964
  var isProxyValue = (node) => {
1804
- if (t8.isFunction(node) || t8.isBlockStatement(node) || t8.isSequenceExpression(node) || t8.isAssignmentExpression(node)) {
1965
+ if (t9.isFunction(node) || t9.isBlockStatement(node) || t9.isSequenceExpression(node) || t9.isAssignmentExpression(node)) {
1805
1966
  return false;
1806
1967
  }
1807
1968
  let isValid = true;
1808
- if (!t8.isExpression(node)) {
1969
+ if (!t9.isExpression(node)) {
1809
1970
  return false;
1810
1971
  }
1811
- const wrapper = t8.file(t8.program([t8.expressionStatement(node)]));
1812
- walk(wrapper, {
1972
+ const wrapper = t9.file(t9.program([t9.expressionStatement(node)]));
1973
+ walk2(wrapper, {
1813
1974
  "SequenceExpression|BlockStatement|Function|AssignmentExpression"(path) {
1814
1975
  isValid = false;
1815
1976
  path.stop();
@@ -1819,7 +1980,7 @@ var isProxyValue = (node) => {
1819
1980
  return isValid;
1820
1981
  };
1821
1982
  var copyExpression = (expression) => {
1822
- return t8.cloneNode(expression, true);
1983
+ return t9.cloneNode(expression, true);
1823
1984
  };
1824
1985
  var ProxyFunction = class {
1825
1986
  expression;
@@ -1827,7 +1988,7 @@ var ProxyFunction = class {
1827
1988
  this.expression = expression;
1828
1989
  }
1829
1990
  getReplacement(args) {
1830
- const expression = t8.isExpression(this.expression.body) ? copyExpression(this.expression.body) : this.expression.body.body[0].argument ? copyExpression(this.expression.body.body[0].argument) : t8.identifier("undefined");
1991
+ const expression = t9.isExpression(this.expression.body) ? copyExpression(this.expression.body) : this.expression.body.body[0].argument ? copyExpression(this.expression.body.body[0].argument) : t9.identifier("undefined");
1831
1992
  this.replaceParameters(expression, args);
1832
1993
  return expression;
1833
1994
  }
@@ -1835,7 +1996,7 @@ var ProxyFunction = class {
1835
1996
  const paramMap = new Map(
1836
1997
  this.expression.params.map((param, index) => [
1837
1998
  param.name,
1838
- args[index] ?? t8.identifier("undefined")
1999
+ args[index] ?? t9.identifier("undefined")
1839
2000
  ])
1840
2001
  );
1841
2002
  const pathsToReplace = [];
@@ -1860,10 +2021,10 @@ var ProxyFunction = class {
1860
2021
  }
1861
2022
  return false;
1862
2023
  };
1863
- const wrapper = t8.file(t8.program([t8.expressionStatement(expression)]));
1864
- walk(wrapper, {
2024
+ const wrapper = t9.file(t9.program([t9.expressionStatement(expression)]));
2025
+ walk2(wrapper, {
1865
2026
  enter(path) {
1866
- if (t8.isIdentifier(path.node) && !shouldSkipIdentifier(path) && paramMap.has(path.node.name)) {
2027
+ if (t9.isIdentifier(path.node) && !shouldSkipIdentifier(path) && paramMap.has(path.node.name)) {
1867
2028
  const replacement = paramMap.get(path.node.name);
1868
2029
  pathsToReplace.push([path, replacement]);
1869
2030
  }
@@ -1871,7 +2032,7 @@ var ProxyFunction = class {
1871
2032
  noScope: true
1872
2033
  });
1873
2034
  for (const [path, replacement] of pathsToReplace) {
1874
- path.replaceWith(t8.cloneNode(replacement, true));
2035
+ path.replaceWith(t9.cloneNode(replacement, true));
1875
2036
  }
1876
2037
  }
1877
2038
  };
@@ -1891,10 +2052,10 @@ var ProxyFunctionVariable = class extends ProxyFunction {
1891
2052
  const argumentNodes = path.parentPath.node.arguments;
1892
2053
  const args = [];
1893
2054
  for (const argument of argumentNodes) {
1894
- if (!t8.isExpression(argument)) {
2055
+ if (!t9.isExpression(argument)) {
1895
2056
  return false;
1896
2057
  }
1897
- args.push(t8.cloneNode(argument, true));
2058
+ args.push(t9.cloneNode(argument, true));
1898
2059
  }
1899
2060
  const expression = this.getReplacement(args);
1900
2061
  path.parentPath.replaceWith(expression);
@@ -1903,7 +2064,7 @@ var ProxyFunctionVariable = class extends ProxyFunction {
1903
2064
  };
1904
2065
  var collectProxyFunctions = (ast) => {
1905
2066
  const proxies = [];
1906
- walk(ast, {
2067
+ walk2(ast, {
1907
2068
  FunctionDeclaration(path) {
1908
2069
  if (!path.node.id) return;
1909
2070
  if (!isProxyFunctionExpression(path.node)) return;
@@ -1912,7 +2073,7 @@ var collectProxyFunctions = (ast) => {
1912
2073
  proxies.push(new ProxyFunctionVariable(binding, path.node));
1913
2074
  },
1914
2075
  VariableDeclarator(path) {
1915
- if (!t8.isIdentifier(path.node.id)) return;
2076
+ if (!t9.isIdentifier(path.node.id)) return;
1916
2077
  const init = path.node.init;
1917
2078
  if (!init || !isProxyFunctionExpression(init)) return;
1918
2079
  const binding = path.scope.getBinding(path.node.id.name);
@@ -1923,7 +2084,7 @@ var collectProxyFunctions = (ast) => {
1923
2084
  return proxies;
1924
2085
  };
1925
2086
  var inlineProxyFunctions = (code, filename) => {
1926
- const ast = parse10(code, createParseOptions(filename));
2087
+ const ast = parse11(code, createParseOptions(filename));
1927
2088
  const proxies = collectProxyFunctions(ast);
1928
2089
  let replacedCount = 0;
1929
2090
  for (const proxy of proxies) {
@@ -1935,7 +2096,7 @@ var inlineProxyFunctions = (code, filename) => {
1935
2096
  }
1936
2097
  }
1937
2098
  return {
1938
- code: patchDefault(generate9)(ast).code,
2099
+ code: patchDefault(generate10)(ast).code,
1939
2100
  replacedCount
1940
2101
  };
1941
2102
  };
@@ -1950,20 +2111,20 @@ var fn_inliner_default = createCommand((program3) => {
1950
2111
  return finish();
1951
2112
  }
1952
2113
  try {
1953
- const fileContent = readFileSync10(filename, "utf8");
1954
- const defaultOutputPath = createDefaultOutputPath9(filename);
2114
+ const fileContent = readFileSync11(filename, "utf8");
2115
+ const defaultOutputPath = createDefaultOutputPath10(filename);
1955
2116
  let outputPath = options.output;
1956
2117
  if (!outputPath) {
1957
2118
  const promptPath = (await createPrompt("Enter the output file path:"))?.trim();
1958
2119
  outputPath = promptPath || defaultOutputPath;
1959
2120
  }
1960
- const loader = loading10("Inlining proxy functions...").start();
2121
+ const loader = loading11("Inlining proxy functions...").start();
1961
2122
  try {
1962
2123
  const { code: output, replacedCount } = inlineProxyFunctions(
1963
2124
  fileContent,
1964
2125
  filename
1965
2126
  );
1966
- writeFileSync9(outputPath, output, "utf8");
2127
+ writeFileSync10(outputPath, output, "utf8");
1967
2128
  loader.succeed(
1968
2129
  `Saved fn-inliner file to: ${outputPath} (${diff(fileContent, output).length} lines changed, ${replacedCount} replacements)`
1969
2130
  );
@@ -1989,38 +2150,38 @@ var fn_inliner_default = createCommand((program3) => {
1989
2150
  });
1990
2151
 
1991
2152
  // commands/sequence-split/index.ts
1992
- import { readFileSync as readFileSync11, writeFileSync as writeFileSync10 } from "fs";
1993
- import { basename as basename10, dirname as dirname10, extname as extname10, join as join10 } from "path";
1994
- import { parse as parse11 } from "@babel/parser";
1995
- import traverse10 from "@babel/traverse";
1996
- import generate10 from "@babel/generator";
1997
- import * as t9 from "@babel/types";
1998
- import loading11 from "loading-cli";
1999
- var walk2 = patchDefault(traverse10);
2000
- var createDefaultOutputPath10 = (inputPath) => {
2001
- const ext = extname10(inputPath);
2153
+ import { readFileSync as readFileSync12, writeFileSync as writeFileSync11 } from "fs";
2154
+ import { basename as basename11, dirname as dirname11, extname as extname11, join as join11 } from "path";
2155
+ import { parse as parse12 } from "@babel/parser";
2156
+ import traverse11 from "@babel/traverse";
2157
+ import generate11 from "@babel/generator";
2158
+ import * as t10 from "@babel/types";
2159
+ import loading12 from "loading-cli";
2160
+ var walk3 = patchDefault(traverse11);
2161
+ var createDefaultOutputPath11 = (inputPath) => {
2162
+ const ext = extname11(inputPath);
2002
2163
  if (!ext) {
2003
2164
  return `${inputPath}.sequence-split.js`;
2004
2165
  }
2005
- const base = basename10(inputPath, ext);
2006
- return join10(dirname10(inputPath), `${base}.sequence-split${ext}`);
2166
+ const base = basename11(inputPath, ext);
2167
+ return join11(dirname11(inputPath), `${base}.sequence-split${ext}`);
2007
2168
  };
2008
2169
  var isExcluded = (node) => {
2009
- return t9.isIdentifier(node) && node.name === "eval";
2170
+ return t10.isIdentifier(node) && node.name === "eval";
2010
2171
  };
2011
2172
  var sequenceSplit = (code, filename) => {
2012
- const ast = parse11(code, createParseOptions(filename));
2173
+ const ast = parse12(code, createParseOptions(filename));
2013
2174
  let changedCount = 0;
2014
2175
  const markChanged = () => {
2015
2176
  changedCount += 1;
2016
2177
  };
2017
- walk2(ast, {
2178
+ walk3(ast, {
2018
2179
  ConditionalExpression(path) {
2019
2180
  if (!path.parentPath || !path.parentPath.isExpressionStatement()) return;
2020
- const replacement = t9.ifStatement(
2181
+ const replacement = t10.ifStatement(
2021
2182
  path.node.test,
2022
- t9.expressionStatement(path.node.consequent),
2023
- t9.expressionStatement(path.node.alternate)
2183
+ t10.expressionStatement(path.node.consequent),
2184
+ t10.expressionStatement(path.node.alternate)
2024
2185
  );
2025
2186
  if (path.parentPath.parentPath && path.parentPath.parentPath.key === "alternate" && path.parentPath.parentPath.isBlockStatement() && path.parentPath.parentPath.node.body.length === 1) {
2026
2187
  path.parentPath.parentPath.replaceWith(replacement);
@@ -2033,10 +2194,10 @@ var sequenceSplit = (code, filename) => {
2033
2194
  LogicalExpression(path) {
2034
2195
  if (!path.parentPath || !path.parentPath.isExpressionStatement()) return;
2035
2196
  if (path.node.operator !== "&&" && path.node.operator !== "||") return;
2036
- const test = path.node.operator === "&&" ? path.node.left : t9.unaryExpression("!", path.node.left);
2037
- const replacement = t9.ifStatement(
2197
+ const test = path.node.operator === "&&" ? path.node.left : t10.unaryExpression("!", path.node.left);
2198
+ const replacement = t10.ifStatement(
2038
2199
  test,
2039
- t9.expressionStatement(path.node.right)
2200
+ t10.expressionStatement(path.node.right)
2040
2201
  );
2041
2202
  if (path.parentPath.parentPath && path.parentPath.parentPath.key === "alternate" && path.parentPath.parentPath.isBlockStatement() && path.parentPath.parentPath.node.body.length === 1) {
2042
2203
  path.parentPath.parentPath.replaceWith(replacement);
@@ -2048,24 +2209,24 @@ var sequenceSplit = (code, filename) => {
2048
2209
  },
2049
2210
  "ForStatement|WhileStatement|DoWhileStatement"(path) {
2050
2211
  if (!path.isForStatement() && !path.isWhileStatement() && !path.isDoWhileStatement()) return;
2051
- if (t9.isBlockStatement(path.node.body)) return;
2052
- path.node.body = t9.blockStatement([path.node.body]);
2212
+ if (t10.isBlockStatement(path.node.body)) return;
2213
+ path.node.body = t10.blockStatement([path.node.body]);
2053
2214
  markChanged();
2054
2215
  },
2055
2216
  IfStatement(path) {
2056
- if (!t9.isBlockStatement(path.node.consequent)) {
2057
- path.node.consequent = t9.blockStatement([path.node.consequent]);
2217
+ if (!t10.isBlockStatement(path.node.consequent)) {
2218
+ path.node.consequent = t10.blockStatement([path.node.consequent]);
2058
2219
  markChanged();
2059
2220
  }
2060
- if (path.node.alternate && !t9.isBlockStatement(path.node.alternate) && !t9.isIfStatement(path.node.alternate)) {
2061
- path.node.alternate = t9.blockStatement([path.node.alternate]);
2221
+ if (path.node.alternate && !t10.isBlockStatement(path.node.alternate) && !t10.isIfStatement(path.node.alternate)) {
2222
+ path.node.alternate = t10.blockStatement([path.node.alternate]);
2062
2223
  markChanged();
2063
2224
  }
2064
2225
  },
2065
2226
  VariableDeclaration(path) {
2066
2227
  if (path.node.declarations.length <= 1) return;
2067
2228
  const replacements = path.node.declarations.map(
2068
- (declaration) => t9.variableDeclaration(path.node.kind, [declaration])
2229
+ (declaration) => t10.variableDeclaration(path.node.kind, [declaration])
2069
2230
  );
2070
2231
  if (path.parentPath?.isForStatement() && path.parentKey === "init") {
2071
2232
  const lastDeclaration = replacements.pop();
@@ -2086,7 +2247,7 @@ var sequenceSplit = (code, filename) => {
2086
2247
  return;
2087
2248
  }
2088
2249
  let outerPath = path;
2089
- while (!t9.isStatement(outerPath.node)) {
2250
+ while (!t10.isStatement(outerPath.node)) {
2090
2251
  const parent = outerPath.parentPath;
2091
2252
  if (!parent) return;
2092
2253
  if (parent.isConditionalExpression() && (outerPath.key === "consequent" || outerPath.key === "alternate") || parent.isLogicalExpression() && outerPath.key === "right" || parent.isForStatement() && (outerPath.key === "test" || outerPath.key === "update") || parent.isDoWhileStatement() && outerPath.key === "test" || parent.isArrowFunctionExpression() && outerPath.key === "body") {
@@ -2099,7 +2260,7 @@ var sequenceSplit = (code, filename) => {
2099
2260
  const firstExpressions = expressions.splice(0, expressions.length - 2);
2100
2261
  if (firstExpressions.length > 0) {
2101
2262
  const expressionStatements = firstExpressions.map(
2102
- (expression) => t9.expressionStatement(expression)
2263
+ (expression) => t10.expressionStatement(expression)
2103
2264
  );
2104
2265
  outerPath.insertBefore(expressionStatements);
2105
2266
  markChanged();
@@ -2107,7 +2268,7 @@ var sequenceSplit = (code, filename) => {
2107
2268
  } else {
2108
2269
  const finalExpression = expressions.splice(expressions.length - 1, 1)[0];
2109
2270
  const expressionStatements = expressions.map(
2110
- (expression) => t9.expressionStatement(expression)
2271
+ (expression) => t10.expressionStatement(expression)
2111
2272
  );
2112
2273
  outerPath.insertBefore(expressionStatements);
2113
2274
  if (finalExpression) {
@@ -2118,7 +2279,7 @@ var sequenceSplit = (code, filename) => {
2118
2279
  }
2119
2280
  });
2120
2281
  return {
2121
- code: patchDefault(generate10)(ast).code,
2282
+ code: patchDefault(generate11)(ast).code,
2122
2283
  changedCount
2123
2284
  };
2124
2285
  };
@@ -2133,20 +2294,20 @@ var sequence_split_default = createCommand((program3) => {
2133
2294
  return finish();
2134
2295
  }
2135
2296
  try {
2136
- const fileContent = readFileSync11(filename, "utf8");
2137
- const defaultOutputPath = createDefaultOutputPath10(filename);
2297
+ const fileContent = readFileSync12(filename, "utf8");
2298
+ const defaultOutputPath = createDefaultOutputPath11(filename);
2138
2299
  let outputPath = options.output;
2139
2300
  if (!outputPath) {
2140
2301
  const promptPath = (await createPrompt("Enter the output file path:"))?.trim();
2141
2302
  outputPath = promptPath || defaultOutputPath;
2142
2303
  }
2143
- const loader = loading11("Splitting sequences...").start();
2304
+ const loader = loading12("Splitting sequences...").start();
2144
2305
  try {
2145
2306
  const { code: output, changedCount } = sequenceSplit(
2146
2307
  fileContent,
2147
2308
  filename
2148
2309
  );
2149
- writeFileSync10(outputPath, output, "utf8");
2310
+ writeFileSync11(outputPath, output, "utf8");
2150
2311
  loader.succeed(
2151
2312
  `Saved sequence-split file to: ${outputPath} (${diff(fileContent, output).length} lines changed, ${changedCount} transforms)`
2152
2313
  );
@@ -2195,10 +2356,10 @@ var calmGradienrain = (text) => {
2195
2356
  const endHue = 300;
2196
2357
  const saturation = 0.45;
2197
2358
  const value = 0.8;
2198
- const ease = (t10) => t10 * t10 * (3 - 2 * t10);
2359
+ const ease = (t11) => t11 * t11 * (3 - 2 * t11);
2199
2360
  return text.split("").map((char, i) => {
2200
- const t10 = ease(i / Math.max(text.length - 1, 1));
2201
- const hue = startHue + (endHue - startHue) * t10;
2361
+ const t11 = ease(i / Math.max(text.length - 1, 1));
2362
+ const hue = startHue + (endHue - startHue) * t11;
2202
2363
  const c = value * saturation;
2203
2364
  const h = hue / 60;
2204
2365
  const x = c * (1 - Math.abs(h % 2 - 1));
@@ -2218,18 +2379,19 @@ var calmGradienrain = (text) => {
2218
2379
  }).join("");
2219
2380
  };
2220
2381
  var showCredit = (VERSION, update) => beautify`
2221
- ${calmGradienrain(`Expose Kit v${VERSION}`)} ${update ? `(Update available: v${update.latest})` : ""}
2382
+ ${calmGradienrain(`Expose Kit v${VERSION}`)} ${update && update.latest !== VERSION ? `(Update available: v${update.latest})` : ""}
2222
2383
  `;
2223
2384
 
2224
2385
  // index.ts
2225
- import { readFileSync as readFileSync12 } from "fs";
2386
+ import { readFileSync as readFileSync13 } from "fs";
2226
2387
  import updateNotifier from "update-notifier";
2227
2388
  var __filename = fileURLToPath(import.meta.url);
2228
- var __dirname = dirname11(__filename);
2229
- var pkg = JSON.parse(readFileSync12(join11(__dirname, "package.json"), "utf8"));
2389
+ var __dirname = dirname12(__filename);
2390
+ var pkg = JSON.parse(readFileSync13(join12(__dirname, "package.json"), "utf8"));
2230
2391
  var notifier = updateNotifier({
2231
2392
  pkg,
2232
- updateCheckInterval: 0
2393
+ updateCheckInterval: 1e3 * 60 * 60 * 24 * 3
2394
+ // 3 days
2233
2395
  });
2234
2396
  console.log(showCredit(pkg.version, notifier.update));
2235
2397
  console.log();
@@ -2248,6 +2410,7 @@ var commands = [
2248
2410
  pre_evaluate_default,
2249
2411
  remove_updater_default,
2250
2412
  remove_reassign_default,
2413
+ remove_deadcode_default,
2251
2414
  fn_inliner_default,
2252
2415
  remove_unused_default,
2253
2416
  sequence_split_default
package/dist/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "expose-kit",
3
- "version": "0.10.3",
3
+ "version": "0.11.0",
4
4
  "type": "module",
5
5
  "private": false,
6
6
  "author": "EdamAmex <edame8080@gmail.com> (https://github.com/EdamAme-x)",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "expose-kit",
3
- "version": "0.10.3",
3
+ "version": "0.11.0",
4
4
  "type": "module",
5
5
  "private": false,
6
6
  "author": "EdamAmex <edame8080@gmail.com> (https://github.com/EdamAme-x)",