@shell-shock/preset-script 0.1.2 → 0.2.1

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.
Files changed (46) hide show
  1. package/README.md +2 -2
  2. package/dist/components/bin-entry.cjs +15 -6
  3. package/dist/components/bin-entry.cjs.map +1 -1
  4. package/dist/components/bin-entry.d.cts +3 -3
  5. package/dist/components/bin-entry.d.cts.map +1 -1
  6. package/dist/components/bin-entry.d.mts +3 -3
  7. package/dist/components/bin-entry.d.mts.map +1 -1
  8. package/dist/components/bin-entry.mjs +15 -6
  9. package/dist/components/bin-entry.mjs.map +1 -1
  10. package/dist/components/command-router.cjs +61 -38
  11. package/dist/components/command-router.cjs.map +1 -1
  12. package/dist/components/command-router.d.cts.map +1 -1
  13. package/dist/components/command-router.d.mts.map +1 -1
  14. package/dist/components/command-router.mjs +61 -38
  15. package/dist/components/command-router.mjs.map +1 -1
  16. package/dist/components/console-builtin.cjs +74 -51
  17. package/dist/components/console-builtin.cjs.map +1 -1
  18. package/dist/components/console-builtin.d.cts.map +1 -1
  19. package/dist/components/console-builtin.d.mts.map +1 -1
  20. package/dist/components/console-builtin.mjs +74 -51
  21. package/dist/components/console-builtin.mjs.map +1 -1
  22. package/dist/components/help.cjs +33 -21
  23. package/dist/components/help.cjs.map +1 -1
  24. package/dist/components/help.d.cts +16 -8
  25. package/dist/components/help.d.cts.map +1 -1
  26. package/dist/components/help.d.mts +19 -11
  27. package/dist/components/help.d.mts.map +1 -1
  28. package/dist/components/help.mjs +34 -22
  29. package/dist/components/help.mjs.map +1 -1
  30. package/dist/components/index.cjs +1 -1
  31. package/dist/components/index.d.cts +3 -3
  32. package/dist/components/index.d.mts +3 -3
  33. package/dist/components/index.mjs +2 -2
  34. package/dist/components/utils-builtin.d.mts +7 -7
  35. package/dist/components/virtual-command-entry.cjs +8 -1
  36. package/dist/components/virtual-command-entry.cjs.map +1 -1
  37. package/dist/components/virtual-command-entry.mjs +8 -1
  38. package/dist/components/virtual-command-entry.mjs.map +1 -1
  39. package/dist/index.cjs +94 -71
  40. package/dist/index.cjs.map +1 -1
  41. package/dist/index.d.cts.map +1 -1
  42. package/dist/index.d.mts.map +1 -1
  43. package/dist/index.mjs +95 -72
  44. package/dist/index.mjs.map +1 -1
  45. package/dist/types/plugin.d.cts.map +1 -1
  46. package/package.json +10 -10
@@ -1 +1 @@
1
- {"version":3,"file":"console-builtin.d.cts","names":[],"sources":["../../src/components/console-builtin.tsx"],"sourcesContent":[],"mappings":";;;;;;;;AA8EA;AA47BgB,iBA57BA,iBAAA,CAAA,CA47B4B,EA57BX,QA47BW;AAuJ5C;;;AAA8C,iBAvJ9B,4BAAA,CAAA,CAuJ8B,EAvJF,QAuJE;AAYnC,KAZC,+BAAA,GAAkC,OAYnC,CAXT,IAWS,CAXJ,wBAWI,EAAA,YAAA,CAAA,CAAA,GAAA;EAGA,IAAA,EAAA,SAAA,GAAA,MAAA,GAAA,MAAA,GAAA,OAAA,GAAA,SAAA,GAAA,MAAA,GAAA,QAAA,GAAA,OAAA;EAAQ,OAAA,EAHR,mBAGQ;EAMH,aAAA,EAAA,KAAA,GAAA,MAA0B,GAAA,MAAA,GACjC,OAAA,GAAA,OAAA;EAoGO,WAAA,EAAA,MAAgB;EA4EhB,MAAA,CAAA,EAvLL,QAuLK;AAmChB,CAAA;AAoFA;AA0FA;AAQA;AAycgB,iBAn1BA,0BAAA,CAm1Bc,KAAA,EAl1BrB,+BAk1BqB,CAAA,EAl1BU,QAk1BV;;;;iBA9uBd,gBAAA,CAAA,GAAgB;;;;iBA4EhB,4BAAA,CAAA,GAA4B;;;;iBAmC5B,0BAAA,CAAA,GAA0B;;;;iBAoF1B,uBAAA,CAAA,GAAuB;;;;KA0F3B,6BAAA,GAAgC,KAC1C;;;;iBAOc,wBAAA,QAAgC,gCAA6B;;;;iBAyc7D,cAAA,CAAA,GAAc"}
1
+ {"version":3,"file":"console-builtin.d.cts","names":[],"sources":["../../src/components/console-builtin.tsx"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A,EAj3BrB,+BAi3BqB,CAAA,EAj3BU,QAi3BV;;;;iBA7wBd,gBAAA,CAAA,GAAgB;;;;iBA4EhB,4BAAA,CAAA,GAA4B;;;;iBAmC5B,0BAAA,CAAA,GAA0B;;;;iBAsF1B,uBAAA,CAAA,GAAuB;;;;KA0F3B,6BAAA,GAAgC,KAC1C;;;;iBAOc,wBAAA,QAAgC,gCAA6B;;;;iBAse7D,cAAA,CAAA,GAAc"}
@@ -983,7 +983,7 @@ function WriteLineFunctionDeclaration() {
983
983
  } else {
984
984
  const index = [" ", "/", "\\\\", ".", ",", "-", ":", "|", "@", "+"].reduce((ret, split) => {
985
985
  let current = ret;
986
- while (stripAnsi(line).indexOf(split, current + 1) !== -1 && stripAnsi(line).indexOf(split, current + 1) <= maxLength) {
986
+ while (stripAnsi(line).indexOf(split, current + 1) !== -1 && stripAnsi(line).indexOf(split, current + 1) <= maxLength && (!/.*\\([^)]*$/.test(stripAnsi(line).slice(0, line.indexOf(split, current + 1))) || !/^[^(]*\\).*/.test(stripAnsi(line).slice(line.indexOf(split, current + 1) + 1)) || stripAnsi(line).slice(line.indexOf(split, current + 1) + 1).replace(/^.*\\)/, "").indexOf(split) !== -1)) {
987
987
  current = line.indexOf(split, current + 1);
988
988
  }
989
989
 
@@ -1301,6 +1301,7 @@ function DividerFunctionDeclaration() {
1301
1301
  type: "number",
1302
1302
  doc: "The width of the divider line. If not specified, the divider will span the full width of the console, minus the padding."
1303
1303
  }),
1304
+ createIntrinsic("hbr", {}),
1304
1305
  createComponent(TSDoc, {
1305
1306
  heading: "The border of the divider line. Can be 'primary', 'secondary', 'tertiary', or 'none'. If not specified, the default border style will be used.",
1306
1307
  get children() {
@@ -1308,7 +1309,7 @@ function DividerFunctionDeclaration() {
1308
1309
  get type() {
1309
1310
  return ReflectionKind.string;
1310
1311
  },
1311
- defaultValue: "\"primary\""
1312
+ defaultValue: "primary"
1312
1313
  })];
1313
1314
  }
1314
1315
  }),
@@ -1318,6 +1319,7 @@ function DividerFunctionDeclaration() {
1318
1319
  type: "\"primary\" | \"secondary\" | \"tertiary\"",
1319
1320
  doc: "The border style/color of the divider line. Can be 'primary', 'secondary', 'tertiary', or 'none'. If not specified, the default border style will be used."
1320
1321
  }),
1322
+ createIntrinsic("hbr", {}),
1321
1323
  createComponent(TSDoc, {
1322
1324
  heading: "Padding to apply to the line",
1323
1325
  get children() {
@@ -1359,11 +1361,11 @@ function DividerFunctionDeclaration() {
1359
1361
  optional: false
1360
1362
  }],
1361
1363
  get children() {
1362
- return code`const padding = options.padding ?? ${theme.padding.app * 4};
1364
+ return code`const padding = options.padding ?? ${Math.max(theme.padding.app, 1) * 4};
1363
1365
  const width = options.width ?? (process.stdout.columns - (Math.max(padding, 0) * 2));
1364
1366
  const border = options.border === "tertiary" ? colors.border.app.divider.tertiary("${theme.borderStyles.app.divider.tertiary.top}") : options.border === "secondary" ? colors.border.app.divider.secondary("${theme.borderStyles.app.divider.secondary.top}") : colors.border.app.divider.primary("${theme.borderStyles.app.divider.primary.top}");
1365
1367
 
1366
- writeLine(" ".repeat(padding) + border.repeat(Math.max(width / ${theme.borderStyles.app.divider.primary.top.length ?? 1}, 0)));
1368
+ writeLine(" ".repeat(Math.max(padding - ${theme.padding.app}, 0)) + border.repeat(Math.max(width / ${theme.borderStyles.app.divider.primary.top.length ?? 1}, 0)));
1367
1369
  `;
1368
1370
  }
1369
1371
  })
@@ -1456,7 +1458,7 @@ function TableFunctionDeclaration(props) {
1456
1458
  get type() {
1457
1459
  return ReflectionKind.property;
1458
1460
  },
1459
- defaultValue: "\"primary\""
1461
+ defaultValue: "primary"
1460
1462
  })
1461
1463
  ];
1462
1464
  }
@@ -1500,7 +1502,7 @@ function TableFunctionDeclaration(props) {
1500
1502
  get type() {
1501
1503
  return ReflectionKind.property;
1502
1504
  },
1503
- defaultValue: "\"left\""
1505
+ defaultValue: "left"
1504
1506
  })
1505
1507
  ];
1506
1508
  }
@@ -1822,14 +1824,17 @@ let colWidths = [] as number[];
1822
1824
  let rowDims = [] as Dimensions[];
1823
1825
 
1824
1826
  const calculateRowDimensions = () => {
1827
+ colWidths = [];
1825
1828
  return cells.reduce((dims, row) => {
1826
- dims.push(row.reduce((dim, cell) => {
1827
- if (cell.width > dim.width) {
1828
- dim.width = cell.width;
1829
- }
1829
+ dims.push(row.reduce((dim, cell, index) => {
1830
+ dim.width += cell.width;
1830
1831
  if (cell.height > dim.height) {
1831
1832
  dim.height = cell.height;
1832
1833
  }
1834
+ if (!colWidths[index] || cell.width > colWidths[index]!) {
1835
+ colWidths[index] = cell.width;
1836
+ }
1837
+
1833
1838
  return dim;
1834
1839
  }, { width: 0, height: 0 } as Dimensions));
1835
1840
 
@@ -1837,14 +1842,13 @@ const calculateRowDimensions = () => {
1837
1842
  }, [] as Dimensions[]);
1838
1843
  }
1839
1844
 
1840
- const maxWidth = Math.max(process.stdout.columns - ${Math.max(theme.padding.app, 0) * 2}, 0);
1841
- rowDims = calculateRowDimensions();
1842
-
1843
1845
  let recalculate!: boolean;
1844
1846
  do {
1845
1847
  recalculate = false;
1846
- rowDims.map((row, rowIndex) => {
1847
- if (row.width > maxWidth) {
1848
+ rowDims = calculateRowDimensions();
1849
+
1850
+ rowDims.forEach((row, rowIndex) => {
1851
+ if (!recalculate && row.width > Math.max(process.stdout.columns - ${Math.max(theme.padding.app, 0) * 2}, 0)) {
1848
1852
  const cell = cells[rowIndex]!.reduce((largestCell, cell) => {
1849
1853
  if (cell.width > largestCell.width) {
1850
1854
  return cell;
@@ -1854,7 +1858,7 @@ do {
1854
1858
 
1855
1859
  const lines = splitText(
1856
1860
  cell.value,
1857
- maxWidth - row.width - cell.width
1861
+ Math.max(process.stdout.columns - ${Math.max(theme.padding.app, 0) * 2} - (row.width - (cell.width - cell.padding * 2)), 0)
1858
1862
  );
1859
1863
 
1860
1864
  cell.value = lines.join("\\n");
@@ -1865,49 +1869,68 @@ do {
1865
1869
  }
1866
1870
  });
1867
1871
 
1868
- if (recalculate) {
1869
- rowDims = calculateRowDimensions();
1872
+ if (!recalculate && colWidths.reduce((a, b) => a + b, 0) > Math.max(process.stdout.columns - ${Math.max(theme.padding.app, 0) * 2}, 0)) {
1873
+ let colIndex = 0;
1874
+ const cell = cells.reduce((ret, row) => {
1875
+ return row.reduce((largest, current, i) => {
1876
+ if (largest.width < current.width) {
1877
+ colIndex = i;
1878
+ return current;
1879
+ }
1880
+ return largest;
1881
+ }, ret);
1882
+ }, cells[0]![0]!);
1883
+
1884
+ const lines = splitText(
1885
+ cell.value,
1886
+ Math.max(process.stdout.columns - ${Math.max(theme.padding.app, 0) * 2} - (colWidths.filter((_, i) => i !== colIndex).reduce((a, b) => a + b, 0)) - cell.padding * 2), 0)
1887
+ );
1888
+
1889
+ cell.value = lines.join("\\n");
1890
+ cell.height = lines.length;
1891
+ cell.width = Math.max(...lines.map(line => stripAnsi(line).length)) + cell.padding * 2;
1892
+
1893
+ recalculate = true;
1870
1894
  }
1871
1895
  } while (recalculate);
1872
1896
 
1873
- rowDims.map((row, rowIndex) => {
1874
- cells[rowIndex]!.forEach(cell => {
1875
- cell.height = row.height;
1876
- });
1877
- });
1878
-
1879
1897
  // Render table
1880
- cells.forEach(row => {
1881
- let line = "";
1898
+ cells.forEach((row, rowIndex) => {
1899
+ const outputs = [] as string[][];
1882
1900
  row.forEach((cell, colIndex) => {
1883
- const cellContent = cell.value;
1884
- let paddedContent = "";
1885
- const totalPadding = cell.padding * 2;
1886
- const contentLength = stripAnsi(cellContent).length;
1887
- const totalWidth = colWidths[colIndex] ?? contentLength + totalPadding;
1888
-
1889
- switch (cell.align) {
1890
- case "right":
1891
- paddedContent = " ".repeat(totalWidth - contentLength - totalPadding) + cellContent + " ".repeat(totalPadding);
1892
- break;
1893
- case "center":
1894
- const leftPadding = Math.floor((totalWidth - contentLength - totalPadding) / 2);
1895
- const rightPadding = totalWidth - contentLength - totalPadding - leftPadding;
1896
- paddedContent = " ".repeat(leftPadding) + cellContent + " ".repeat(rightPadding + totalPadding);
1897
- break;
1898
- case "left":
1899
- default:
1900
- paddedContent = " ".repeat(totalPadding) + cellContent + " ".repeat(totalWidth - contentLength - totalPadding);
1901
- break;
1901
+ const lines = cell.value.split("\\n");
1902
+ while (lines.length < rowDims[rowIndex]!.height) {
1903
+ lines.push("");
1902
1904
  }
1903
1905
 
1904
- line += cell.border.left + paddedContent;
1905
- if (colIndex === row.length - 1) {
1906
- line += paddedContent + cell.border.right;
1907
- }
1906
+ outputs.push(lines.map(line => {
1907
+ let paddedContent = "";
1908
+ switch (cell.align) {
1909
+ case "right":
1910
+ paddedContent = " ".repeat(Math.max(colWidths[colIndex] - stripAnsi(line).length - cell.padding, 0)) + line + " ".repeat(cell.padding);
1911
+ break;
1912
+ case "center":
1913
+ const leftPadding = Math.floor((colWidths[colIndex] - stripAnsi(line).length - cell.padding) / 2);
1914
+ const rightPadding = colWidths[colIndex] - stripAnsi(line).length - leftPadding;
1915
+ paddedContent = " ".repeat(leftPadding) + line + " ".repeat(rightPadding);
1916
+ break;
1917
+ case "left":
1918
+ default:
1919
+ paddedContent = " ".repeat(cell.padding) + line + " ".repeat(Math.max(colWidths[colIndex] - stripAnsi(line).length - cell.padding, 0));
1920
+ break;
1921
+ }
1922
+
1923
+ if (colIndex === row.length - 1) {
1924
+ return cell.border.left + paddedContent + cell.border.right;
1925
+ } else {
1926
+ return cell.border.left + paddedContent;
1927
+ }
1928
+ }));
1908
1929
  });
1909
1930
 
1910
- writeLine(line);
1931
+ for (let index = 0; index < rowDims[rowIndex]!.height; index++) {
1932
+ writeLine(outputs.map(output => output[index] ?? "").join(""));
1933
+ }
1911
1934
  });
1912
1935
  `)
1913
1936
  ];
@@ -2004,7 +2027,7 @@ function ConsoleBuiltin() {
2004
2027
  description: "verbose",
2005
2028
  get prefix() {
2006
2029
  return createComponent(IfStatement, {
2007
- condition: code`!(isDevelopment || isDebug || env.LOG_LEVEL === "debug" || hasFlag(["verbose", "verbose=true", "verbose=always", "debug", "debug=true", "debug=always"]))`,
2030
+ condition: code`!(isDevelopment || isDebug || env.LOG_LEVEL === "debug" || hasFlag(["verbose", "verbose=true", "verbose=always"]))`,
2008
2031
  children: code`return; `
2009
2032
  });
2010
2033
  }