tnp-helpers 21.0.14 → 21.0.17

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.
@@ -1483,6 +1483,8 @@ var UtilsTypescript;
1483
1483
  return (void 0);
1484
1484
  }
1485
1485
  UtilsTypescript.transformFlatImports = transformFlatImports;
1486
+ //#endregion
1487
+ //#region clear require cache recursive
1486
1488
  UtilsTypescript.clearRequireCacheRecursive = (modulePath, seen = new Set()) => {
1487
1489
  /* */
1488
1490
  /* */
@@ -1500,6 +1502,242 @@ var UtilsTypescript;
1500
1502
  /* */
1501
1503
  return (void 0);
1502
1504
  };
1505
+ //#endregion
1506
+ //#region add or update import if not exists
1507
+ UtilsTypescript.addOrUpdateImportIfNotExists = (tsFileContent, identifiers, fromModule) => {
1508
+ const idents = Array.isArray(identifiers) ? identifiers : [identifiers];
1509
+ const impRegex = new RegExp(`${'imp' + 'ort'}\\s*\\{([^}]*)\\}\\s*from\\s*['"]${fromModule}['"];?`, 'm');
1510
+ const match = tsFileContent.match(impRegex);
1511
+ // ----------------------------------------------------
1512
+ // 1. Import exists → merge identifiers
1513
+ // ----------------------------------------------------
1514
+ if (match) {
1515
+ const existing = match[1]
1516
+ .split(',')
1517
+ .map(s => s.trim())
1518
+ .filter(Boolean);
1519
+ const merged = Array.from(new Set([...existing, ...idents])).sort();
1520
+ const updatedImport = `import { ${merged.join(', ')} } from '${fromModule}';`;
1521
+ return tsFileContent.replace(match[0], updatedImport);
1522
+ }
1523
+ // ----------------------------------------------------
1524
+ // 2. Import does NOT exist → insert into //#region imports
1525
+ // ----------------------------------------------------
1526
+ const newImport = `${'imp' + 'ort'} { ${idents.join(', ')} } from '${fromModule}';\n`;
1527
+ const regRegex = new RegExp(`\\/\\/\\#${'reg' + 'ion'} imports\\s*\\n([\\s\\S]*?)\\/\\/\\#${'endr' + 'egion'}`, 'm');
1528
+ const regionMatch = tsFileContent.match(regRegex);
1529
+ if (regionMatch) {
1530
+ const regStart = regionMatch.index + regionMatch[0].indexOf('\n') + 1;
1531
+ return (tsFileContent.slice(0, regStart) +
1532
+ newImport +
1533
+ tsFileContent.slice(regStart));
1534
+ }
1535
+ // ----------------------------------------------------
1536
+ // 3. Fallback → insert at very top (after 'use strict')
1537
+ // ----------------------------------------------------
1538
+ const useStrictMatch = tsFileContent.match(/^(['"])use strict\1;\s*/m);
1539
+ if (useStrictMatch) {
1540
+ const idx = useStrictMatch.index + useStrictMatch[0].length;
1541
+ return tsFileContent.slice(0, idx) + newImport + tsFileContent.slice(idx);
1542
+ }
1543
+ return newImport + tsFileContent;
1544
+ };
1545
+ //#endregion
1546
+ //#region migrate from ng modules to standalone v21
1547
+ UtilsTypescript.migrateFromNgModulesToStandaloneV21 = (tsFileContent, projectName) => {
1548
+ /* */
1549
+ /* */
1550
+ /* */
1551
+ /* */
1552
+ /* */
1553
+ /* */
1554
+ /* */
1555
+ /* */
1556
+ /* */
1557
+ /* */
1558
+ /* */
1559
+ /* */
1560
+ /* */
1561
+ /* */
1562
+ /* */
1563
+ /* */
1564
+ /* */
1565
+ /* */
1566
+ /* */
1567
+ /* */
1568
+ /* */
1569
+ /* */
1570
+ /* */
1571
+ /* */
1572
+ /* */
1573
+ /* */
1574
+ /* */
1575
+ /* */
1576
+ /* */
1577
+ /* */
1578
+ /* */
1579
+ /* */
1580
+ /* */
1581
+ /* */
1582
+ /* */
1583
+ /* */
1584
+ /* */
1585
+ /* */
1586
+ /* */
1587
+ /* */
1588
+ /* */
1589
+ /* */
1590
+ /* */
1591
+ /* */
1592
+ /* */
1593
+ /* */
1594
+ /* */
1595
+ /* */
1596
+ /* */
1597
+ /* */
1598
+ /* */
1599
+ /* */
1600
+ /* */
1601
+ /* */
1602
+ /* */
1603
+ /* */
1604
+ /* */
1605
+ /* */
1606
+ /* */
1607
+ /* */
1608
+ /* */
1609
+ /* */
1610
+ /* */
1611
+ /* */
1612
+ /* */
1613
+ /* */
1614
+ /* */
1615
+ /* */
1616
+ /* */
1617
+ /* */
1618
+ /* */
1619
+ /* */
1620
+ /* */
1621
+ /* */
1622
+ /* */
1623
+ /* */
1624
+ /* */
1625
+ /* */
1626
+ /* */
1627
+ /* */
1628
+ /* */
1629
+ /* */
1630
+ /* */
1631
+ /* */
1632
+ /* */
1633
+ /* */
1634
+ /* */
1635
+ /* */
1636
+ /* */
1637
+ /* */
1638
+ /* */
1639
+ /* */
1640
+ /* */
1641
+ /* */
1642
+ /* */
1643
+ /* */
1644
+ /* */
1645
+ /* */
1646
+ /* */
1647
+ /* */
1648
+ /* */
1649
+ /* */
1650
+ /* */
1651
+ /* */
1652
+ /* */
1653
+ /* */
1654
+ /* */
1655
+ /* */
1656
+ /* */
1657
+ /* */
1658
+ /* */
1659
+ /* */
1660
+ /* */
1661
+ /* */
1662
+ /* */
1663
+ /* */
1664
+ /* */
1665
+ /* */
1666
+ /* */
1667
+ /* */
1668
+ /* */
1669
+ /* */
1670
+ /* */
1671
+ /* */
1672
+ /* */
1673
+ /* */
1674
+ /* */
1675
+ /* */
1676
+ /* */
1677
+ /* */
1678
+ /* */
1679
+ /* */
1680
+ /* */
1681
+ /* */
1682
+ /* */
1683
+ /* */
1684
+ /* */
1685
+ /* */
1686
+ /* */
1687
+ /* */
1688
+ /* */
1689
+ /* */
1690
+ /* */
1691
+ /* */
1692
+ /* */
1693
+ /* */
1694
+ /* */
1695
+ /* */
1696
+ /* */
1697
+ /* */
1698
+ /* */
1699
+ /* */
1700
+ /* */
1701
+ /* */
1702
+ /* */
1703
+ /* */
1704
+ /* */
1705
+ /* */
1706
+ /* */
1707
+ /* */
1708
+ /* */
1709
+ /* */
1710
+ /* */
1711
+ /* */
1712
+ /* */
1713
+ /* */
1714
+ /* */
1715
+ /* */
1716
+ /* */
1717
+ /* */
1718
+ /* */
1719
+ /* */
1720
+ /* */
1721
+ /* */
1722
+ /* */
1723
+ /* */
1724
+ /* */
1725
+ /* */
1726
+ /* */
1727
+ /* */
1728
+ /* */
1729
+ /* */
1730
+ /* */
1731
+ /* */
1732
+ /* */
1733
+ /* */
1734
+ /* */
1735
+ /* */
1736
+ /* */
1737
+ /* */
1738
+ return (void 0);
1739
+ };
1740
+ //#endregion
1503
1741
  })(UtilsTypescript || (UtilsTypescript = {}));
1504
1742
  //#endregion
1505
1743
  //#region utils http
@@ -2983,6 +3221,72 @@ var UtilsFileSync;
2983
3221
  };
2984
3222
  //#endregion
2985
3223
  })(UtilsFileSync || (UtilsFileSync = {}));
3224
+ var UtilsClipboard;
3225
+ (function (UtilsClipboard) {
3226
+ UtilsClipboard.copyText = async (textToCopy) => {
3227
+ /* */
3228
+ /* */
3229
+ /* */
3230
+ /* */
3231
+ /* */
3232
+ /* */
3233
+ /* */
3234
+ //#region @browser
3235
+ if (typeof navigator !== 'undefined') {
3236
+ // Preferred modern API
3237
+ if (navigator.clipboard?.writeText) {
3238
+ await navigator.clipboard.writeText(textToCopy);
3239
+ return;
3240
+ }
3241
+ // Fallback (older browsers / restricted permissions)
3242
+ const textarea = document.createElement('textarea');
3243
+ textarea.value = textToCopy;
3244
+ textarea.style.position = 'fixed';
3245
+ textarea.style.opacity = '0';
3246
+ document.body.appendChild(textarea);
3247
+ textarea.focus();
3248
+ textarea.select();
3249
+ try {
3250
+ document.execCommand('copy');
3251
+ }
3252
+ finally {
3253
+ document.body.removeChild(textarea);
3254
+ }
3255
+ }
3256
+ //#endregion
3257
+ };
3258
+ UtilsClipboard.pasteText = async () => {
3259
+ /* */
3260
+ /* */
3261
+ /* */
3262
+ /* */
3263
+ /* */
3264
+ /* */
3265
+ /* */
3266
+ //#region @browser
3267
+ if (typeof navigator !== 'undefined') {
3268
+ // Preferred modern API
3269
+ if (navigator.clipboard?.readText) {
3270
+ return await navigator.clipboard.readText();
3271
+ }
3272
+ // Fallback (best-effort)
3273
+ const textarea = document.createElement('textarea');
3274
+ textarea.style.position = 'fixed';
3275
+ textarea.style.opacity = '0';
3276
+ document.body.appendChild(textarea);
3277
+ textarea.focus();
3278
+ try {
3279
+ document.execCommand('paste');
3280
+ return textarea.value;
3281
+ }
3282
+ finally {
3283
+ document.body.removeChild(textarea);
3284
+ }
3285
+ }
3286
+ //#endregion
3287
+ return '';
3288
+ };
3289
+ })(UtilsClipboard || (UtilsClipboard = {}));
2986
3290
 
2987
3291
  class HelpersArrayObj {
2988
3292
  from(s) {
@@ -7644,7 +7948,7 @@ const PROJECT_NPM_NAME = 'tnp-helpers';
7644
7948
  /**
7645
7949
  * Autogenerated by current cli tool. Use *tnp release* to bump version.
7646
7950
  */
7647
- const CURRENT_PACKAGE_VERSION = '21.0.14';
7951
+ const CURRENT_PACKAGE_VERSION = '21.0.17';
7648
7952
  // THIS FILE IS GENERATED - DO NOT MODIFY
7649
7953
 
7650
7954
  //#endregion
@@ -8548,6 +8852,7 @@ class BaseProject {
8548
8852
  /* */
8549
8853
  /* */
8550
8854
  /* */
8855
+ /* */
8551
8856
  return (void 0);
8552
8857
  }
8553
8858
  //#endregion
@@ -20707,5 +21012,5 @@ const Helpers = HelpersTaon.Instance;
20707
21012
  * Generated bundle index. Do not edit.
20708
21013
  */
20709
21014
 
20710
- export { BaseCLiWorkerStartMode, BaseCLiWorkerStartParams, BaseCliMethodOptions, BaseCliWorker, BaseCliWorkerConfig, BaseCliWorkerConfigGetContextOptions, BaseCliWorkerTerminalUI, BaseCliWorkerUtils, BaseCommandLineFeature, BaseCompilerForProject, BaseDebounceCompilerForProject, BaseFeatureForProject, BaseFileFoldersOperations, BaseGit, BaseGlobalCommandLine, BaseIgnoreHideHelpers, BaseJsonFileReader, BaseLibraryBuild, BaseLinkedProjects, BaseLinter, BaseNodeModules, BaseNpmHelpers, BasePackageJson, BaseProcessManger, BaseProject, BaseProjectResolver, BaseProjectTypeArr, BaseQuickFixes, BaseReleaseProcess, BaseVscodeHelpers, CommandConfig, CommandProcess, CommandProcessState, CommitData, CoreAngularProject, CoreProject, CoreTypescriptProject, Helpers, HelpersAngular, LinkedPorjectsConfig, LinkedProject, PackageJsonDependencyObjArr, Port, PortStatusArr, PortsWorker, ProgressData, TaonBaseCliWorkerController, TaonPortsController, UtilsDocker, UtilsFileSync, UtilsHttp, UtilsJava, UtilsMd, UtilsNpm, UtilsPasswords, UtilsQuickFixes, UtilsTaonWorker, UtilsTypescript, UtilsVSCode, UtilsZip, UtilsZipBrowser, executeCommand, getBaseCliWorkerDatabaseConfig };
21015
+ export { BaseCLiWorkerStartMode, BaseCLiWorkerStartParams, BaseCliMethodOptions, BaseCliWorker, BaseCliWorkerConfig, BaseCliWorkerConfigGetContextOptions, BaseCliWorkerTerminalUI, BaseCliWorkerUtils, BaseCommandLineFeature, BaseCompilerForProject, BaseDebounceCompilerForProject, BaseFeatureForProject, BaseFileFoldersOperations, BaseGit, BaseGlobalCommandLine, BaseIgnoreHideHelpers, BaseJsonFileReader, BaseLibraryBuild, BaseLinkedProjects, BaseLinter, BaseNodeModules, BaseNpmHelpers, BasePackageJson, BaseProcessManger, BaseProject, BaseProjectResolver, BaseProjectTypeArr, BaseQuickFixes, BaseReleaseProcess, BaseVscodeHelpers, CommandConfig, CommandProcess, CommandProcessState, CommitData, CoreAngularProject, CoreProject, CoreTypescriptProject, Helpers, HelpersAngular, LinkedPorjectsConfig, LinkedProject, PackageJsonDependencyObjArr, Port, PortStatusArr, PortsWorker, ProgressData, TaonBaseCliWorkerController, TaonPortsController, UtilsClipboard, UtilsDocker, UtilsFileSync, UtilsHttp, UtilsJava, UtilsMd, UtilsNpm, UtilsPasswords, UtilsQuickFixes, UtilsTaonWorker, UtilsTypescript, UtilsVSCode, UtilsZip, UtilsZipBrowser, executeCommand, getBaseCliWorkerDatabaseConfig };
20711
21016
  //# sourceMappingURL=tnp-helpers-browser.mjs.map