repluggable-core 0.0.0-pr342.44 → 0.0.0-pr343.46

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 (39) hide show
  1. package/dist/debug/src/API.d.ts +1 -17
  2. package/dist/es/src/API.d.ts +1 -17
  3. package/dist/es/src/API.d.ts.map +1 -1
  4. package/dist/es/src/API.js.map +1 -1
  5. package/dist/es/src/appHost.d.ts.map +1 -1
  6. package/dist/es/src/appHost.js +5 -50
  7. package/dist/es/src/appHost.js.map +1 -1
  8. package/dist/es/src/appHostUtils.d.ts +0 -1
  9. package/dist/es/src/appHostUtils.d.ts.map +1 -1
  10. package/dist/es/src/appHostUtils.js +0 -3
  11. package/dist/es/src/appHostUtils.js.map +1 -1
  12. package/dist/es/test/appHost.spec.js +0 -483
  13. package/dist/es/test/appHost.spec.js.map +1 -1
  14. package/dist/es/testKit/mockPackage.d.ts +0 -1
  15. package/dist/es/testKit/mockPackage.d.ts.map +1 -1
  16. package/dist/es/testKit/mockPackage.js +0 -14
  17. package/dist/es/testKit/mockPackage.js.map +1 -1
  18. package/dist/src/API.d.ts +1 -17
  19. package/dist/src/API.d.ts.map +1 -1
  20. package/dist/src/API.js.map +1 -1
  21. package/dist/src/appHost.d.ts.map +1 -1
  22. package/dist/src/appHost.js +4 -49
  23. package/dist/src/appHost.js.map +1 -1
  24. package/dist/src/appHostUtils.d.ts +0 -1
  25. package/dist/src/appHostUtils.d.ts.map +1 -1
  26. package/dist/src/appHostUtils.js +1 -5
  27. package/dist/src/appHostUtils.js.map +1 -1
  28. package/dist/test/appHost.spec.js +0 -483
  29. package/dist/test/appHost.spec.js.map +1 -1
  30. package/dist/testKit/mockPackage.d.ts +0 -1
  31. package/dist/testKit/mockPackage.d.ts.map +1 -1
  32. package/dist/testKit/mockPackage.js +1 -15
  33. package/dist/testKit/mockPackage.js.map +1 -1
  34. package/package.json +1 -1
  35. package/src/API.ts +2 -18
  36. package/src/appHost.ts +6 -62
  37. package/src/appHostUtils.ts +0 -3
  38. package/test/appHost.spec.ts +0 -506
  39. package/testKit/mockPackage.ts +0 -15
@@ -12,7 +12,6 @@ import { createAppHost, mainViewSlotKey, stateSlotKey } from '../src/appHost';
12
12
  import { addMockShell, asyncLoadMockPackage, dependsOnMockPackageEntryPoint, emptyLoggerOptions, MockAPI, mockPackage, mockPackageWithPublicAPI, mockPackageWithSlot, MockPublicAPI, mockShellInitialState, mockShellStateKey, MockSlot } from '../testKit';
13
13
  import { AppHostAPI, AppHostServicesEntryPointName } from '../src/appHostServices';
14
14
  import { ConsoleHostLogger } from '../src/loggers';
15
- import { mockPackageWithColdDependency } from '../testKit/mockPackage';
16
15
  import { createCircularEntryPoints, createDirectCircularEntryPoints } from './appHost.mock';
17
16
  import { createSignalItemsDataStructure } from './createSignalItemsDataStructure';
18
17
  const testHostOptions = {
@@ -1538,487 +1537,5 @@ If the API is intended to be public, it should be declared as "public: true" in
1538
1537
  expect(itemsSpy).toBeCalledTimes(4);
1539
1538
  }));
1540
1539
  });
1541
- describe('Cold Dependencies', () => {
1542
- it('should allow entry point to load without waiting for cold dependencies', () => __awaiter(void 0, void 0, void 0, function* () {
1543
- const host = createAppHost([], testHostOptions);
1544
- host.addShells([mockPackageWithColdDependency]);
1545
- expect(host.hasShell(mockPackageWithColdDependency.name)).toBe(true);
1546
- }));
1547
- it('should return false for hasAPI when cold dependency is not ready', () => __awaiter(void 0, void 0, void 0, function* () {
1548
- const host = createAppHost([], testHostOptions);
1549
- host.addShells([mockPackageWithColdDependency]);
1550
- expect(host.hasAPI(MockAPI)).toBe(false);
1551
- }));
1552
- it('should throw when accessing cold dependency that is not ready', () => __awaiter(void 0, void 0, void 0, function* () {
1553
- const host = createAppHost([], testHostOptions);
1554
- host.addShells([mockPackageWithColdDependency]);
1555
- expect(() => host.getAPI(MockAPI)).toThrow();
1556
- }));
1557
- it('should throw when accessing cold dependency during entry point attach', () => __awaiter(void 0, void 0, void 0, function* () {
1558
- const coldDependencyEntryPoint = {
1559
- name: 'COLD_DEPENDENCY_ENTRY_POINT',
1560
- getColdDependencyAPIs() {
1561
- return [MockAPI];
1562
- },
1563
- declareAPIs() {
1564
- return [MockPublicAPI];
1565
- },
1566
- attach(shell) {
1567
- shell.contributeAPI(MockPublicAPI, () => {
1568
- const mockAPI = shell.getAPI(MockAPI);
1569
- return {
1570
- stubTrue: () => mockAPI.stubTrue()
1571
- };
1572
- });
1573
- }
1574
- };
1575
- const host = createAppHost([], testHostOptions);
1576
- expect(() => host.addShells([coldDependencyEntryPoint])).toThrow();
1577
- }));
1578
- it('should throw when accessing cold dependency during entry point extend', () => __awaiter(void 0, void 0, void 0, function* () {
1579
- const coldDependencyEntryPoint = {
1580
- name: 'COLD_DEPENDENCY_ENTRY_POINT',
1581
- getColdDependencyAPIs() {
1582
- return [MockAPI];
1583
- },
1584
- extend(shell) {
1585
- shell.getAPI(MockAPI).stubTrue();
1586
- }
1587
- };
1588
- const host = createAppHost([], testHostOptions);
1589
- expect(() => host.addShells([coldDependencyEntryPoint])).toThrow();
1590
- }));
1591
- it('should allow accessing cold dependency via getAPI after initialization completes', () => __awaiter(void 0, void 0, void 0, function* () {
1592
- const host = createAppHost([mockPackage], testHostOptions);
1593
- const shell = addMockShell(host, {
1594
- getColdDependencyAPIs: () => [MockAPI]
1595
- });
1596
- expect(() => shell.getAPI(MockAPI)).not.toThrow();
1597
- expect(shell.getAPI(MockAPI).stubTrue()).toBe(true);
1598
- }));
1599
- describe('getColdAPI', () => {
1600
- it('should allow using getColdAPI inside contributeAPI factory', () => __awaiter(void 0, void 0, void 0, function* () {
1601
- // Problem: You can't call getAPI(coldDep) inside contributeAPI factory because init hasn't completed
1602
- // Solution: getColdAPI returns a lazy wrapper that defers resolution until the method is actually called
1603
- const host = createAppHost([mockPackage], testHostOptions);
1604
- addMockShell(host, {
1605
- getColdDependencyAPIs: () => [MockAPI],
1606
- declareAPIs: () => [MockPublicAPI],
1607
- attach(shell) {
1608
- const mockAPI = shell.getColdAPI(MockAPI);
1609
- shell.contributeAPI(MockPublicAPI, () => ({
1610
- stubTrue: () => mockAPI.get().stubTrue()
1611
- }));
1612
- }
1613
- });
1614
- expect(host.getAPI(MockPublicAPI).stubTrue()).toBe(true);
1615
- }));
1616
- it('should resolve cold dependency when get() is called after initialization', () => __awaiter(void 0, void 0, void 0, function* () {
1617
- const host = createAppHost([mockPackage], testHostOptions);
1618
- const shell = addMockShell(host, {
1619
- getColdDependencyAPIs: () => [MockAPI]
1620
- });
1621
- const lazyAPI = shell.getColdAPI(MockAPI);
1622
- expect(lazyAPI.get().stubTrue()).toBe(true);
1623
- }));
1624
- it('should throw when get() is called and cold dependency is not ready', () => __awaiter(void 0, void 0, void 0, function* () {
1625
- const host = createAppHost([], testHostOptions);
1626
- const shell = addMockShell(host, {
1627
- getColdDependencyAPIs: () => [MockAPI]
1628
- });
1629
- const lazyAPI = shell.getColdAPI(MockAPI);
1630
- expect(() => lazyAPI.get()).toThrow();
1631
- }));
1632
- it('should cache the API after first get() call', () => __awaiter(void 0, void 0, void 0, function* () {
1633
- const host = createAppHost([mockPackage], testHostOptions);
1634
- const shell = addMockShell(host, {
1635
- getColdDependencyAPIs: () => [MockAPI]
1636
- });
1637
- const lazyAPI = shell.getColdAPI(MockAPI);
1638
- const first = lazyAPI.get();
1639
- const second = lazyAPI.get();
1640
- expect(first).toBe(second);
1641
- }));
1642
- });
1643
- describe('Cyclic Cold Dependencies', () => {
1644
- it('should load entry point with cyclic cold dependencies', () => __awaiter(void 0, void 0, void 0, function* () {
1645
- /**
1646
- * (A)───cold───>(B)
1647
- * ^ │
1648
- * │ │
1649
- * └────cold─────┘
1650
- *
1651
- * A declares APIA, has cold dep on APIB
1652
- * B declares APIB, has cold dep on APIA
1653
- */
1654
- const APIA = { name: 'API_A' };
1655
- const APIB = { name: 'API_B' };
1656
- const declaringAWithColdDepOnB = {
1657
- name: 'ENTRY_POINT_A',
1658
- getColdDependencyAPIs() {
1659
- return [APIB];
1660
- },
1661
- declareAPIs() {
1662
- return [APIA];
1663
- },
1664
- attach(shell) {
1665
- shell.contributeAPI(APIA, () => ({
1666
- stubTrue: () => true
1667
- }));
1668
- }
1669
- };
1670
- const declaringBWithColdDepOnA = {
1671
- name: 'ENTRY_POINT_B',
1672
- getColdDependencyAPIs() {
1673
- return [APIA];
1674
- },
1675
- declareAPIs() {
1676
- return [APIB];
1677
- },
1678
- attach(shell) {
1679
- shell.contributeAPI(APIB, () => ({
1680
- stubTrue: () => true
1681
- }));
1682
- }
1683
- };
1684
- const host = createAppHost([declaringAWithColdDepOnB, declaringBWithColdDepOnA], testHostOptions);
1685
- expect(host.hasShell(declaringAWithColdDepOnB.name)).toBe(true);
1686
- expect(host.hasShell(declaringBWithColdDepOnA.name)).toBe(true);
1687
- }));
1688
- it('should load entry points with cyclic cold and regular dependencies', () => __awaiter(void 0, void 0, void 0, function* () {
1689
- /**
1690
- * (A)───cold───>(B)───cold───>(C)
1691
- * ^ │
1692
- * │ │
1693
- * └─────────regular────────────┘
1694
- *
1695
- * A declares APIA, has cold dep on APIB
1696
- * B declares APIB, has cold dep on APIC
1697
- * C declares APIC, has regular dep on APIA
1698
- */
1699
- const APIA = { name: 'API_A' };
1700
- const APIB = { name: 'API_B' };
1701
- const APIC = { name: 'API_C' };
1702
- const declaringA = {
1703
- name: 'ENTRY_POINT_A',
1704
- getColdDependencyAPIs() {
1705
- return [APIB];
1706
- },
1707
- declareAPIs() {
1708
- return [APIA];
1709
- },
1710
- attach(shell) {
1711
- shell.contributeAPI(APIA, () => ({
1712
- stubTrue: () => true
1713
- }));
1714
- }
1715
- };
1716
- const declaringB = {
1717
- name: 'ENTRY_POINT_B',
1718
- getColdDependencyAPIs() {
1719
- return [APIC];
1720
- },
1721
- declareAPIs() {
1722
- return [APIB];
1723
- },
1724
- attach(shell) {
1725
- shell.contributeAPI(APIB, () => ({
1726
- stubTrue: () => true
1727
- }));
1728
- }
1729
- };
1730
- const declaringC = {
1731
- name: 'ENTRY_POINT_C',
1732
- getDependencyAPIs() {
1733
- return [APIA];
1734
- },
1735
- declareAPIs() {
1736
- return [APIC];
1737
- },
1738
- attach(shell) {
1739
- shell.contributeAPI(APIC, () => ({
1740
- stubTrue: () => true
1741
- }));
1742
- }
1743
- };
1744
- const host = createAppHost([declaringA, declaringB, declaringC], testHostOptions);
1745
- expect(host.hasShell(declaringA.name)).toBe(true);
1746
- expect(host.hasShell(declaringB.name)).toBe(true);
1747
- expect(host.hasShell(declaringC.name)).toBe(true);
1748
- }));
1749
- });
1750
- describe('Cold dependency promotion', () => {
1751
- it('should promote transitive cold dependencies to regular dependencies when there is a real direct dependency', () => __awaiter(void 0, void 0, void 0, function* () {
1752
- const APIA = { name: 'API_A' };
1753
- const APIB = { name: 'API_B' };
1754
- const APIC = { name: 'API_C' };
1755
- const declaringA = {
1756
- name: 'ENTRY_POINT_A',
1757
- declareAPIs() {
1758
- return [APIA];
1759
- },
1760
- attach(shell) {
1761
- shell.contributeAPI(APIA, () => ({
1762
- stubTrue: () => true
1763
- }));
1764
- }
1765
- };
1766
- const declaringBWithColdDepOnA = {
1767
- name: 'ENTRY_POINT_B',
1768
- getColdDependencyAPIs() {
1769
- return [APIA];
1770
- },
1771
- declareAPIs() {
1772
- return [APIB];
1773
- },
1774
- attach(shell) {
1775
- shell.contributeAPI(APIB, () => ({
1776
- stubTrue: () => true
1777
- }));
1778
- }
1779
- };
1780
- const declaringCWithRegularDepOnB = {
1781
- name: 'ENTRY_POINT_C',
1782
- getDependencyAPIs() {
1783
- return [APIB];
1784
- },
1785
- declareAPIs() {
1786
- return [APIC];
1787
- },
1788
- attach(shell) {
1789
- shell.contributeAPI(APIC, () => ({
1790
- stubTrue: () => true
1791
- }));
1792
- }
1793
- };
1794
- // no APIA in the host
1795
- const host = createAppHost([declaringBWithColdDepOnA, declaringCWithRegularDepOnB], testHostOptions);
1796
- expect(host.hasShell(declaringBWithColdDepOnA.name)).toBe(true);
1797
- expect(host.hasShell(declaringCWithRegularDepOnB.name)).toBe(false);
1798
- yield host.addShells([declaringA]);
1799
- expect(host.hasShell(declaringCWithRegularDepOnB.name)).toBe(true);
1800
- }));
1801
- it('should promote cold dependencies from unready entry points added in previous batches', () => __awaiter(void 0, void 0, void 0, function* () {
1802
- const APIA = { name: 'API_A' };
1803
- const APIB = { name: 'API_B' };
1804
- const APIC = { name: 'API_C' };
1805
- const APIX = { name: 'API_X' };
1806
- // B declares APIB, depends on APIX (keeps B unready), has cold dep on APIA
1807
- const declaringB = {
1808
- name: 'ENTRY_POINT_B',
1809
- getDependencyAPIs() {
1810
- return [APIX];
1811
- },
1812
- getColdDependencyAPIs() {
1813
- return [APIA];
1814
- },
1815
- declareAPIs() {
1816
- return [APIB];
1817
- },
1818
- attach(shell) {
1819
- shell.contributeAPI(APIB, () => ({ stubTrue: () => true }));
1820
- }
1821
- };
1822
- // C depends on APIB (from unready B)
1823
- const declaringC = {
1824
- name: 'ENTRY_POINT_C',
1825
- getDependencyAPIs() {
1826
- return [APIB];
1827
- },
1828
- declareAPIs() {
1829
- return [APIC];
1830
- },
1831
- attach(shell) {
1832
- shell.contributeAPI(APIC, () => ({ stubTrue: () => true }));
1833
- }
1834
- };
1835
- const declaringA = {
1836
- name: 'ENTRY_POINT_A',
1837
- declareAPIs() {
1838
- return [APIA];
1839
- },
1840
- attach(shell) {
1841
- shell.contributeAPI(APIA, () => ({ stubTrue: () => true }));
1842
- }
1843
- };
1844
- const declaringX = {
1845
- name: 'ENTRY_POINT_X',
1846
- declareAPIs() {
1847
- return [APIX];
1848
- },
1849
- attach(shell) {
1850
- shell.contributeAPI(APIX, () => ({ stubTrue: () => true }));
1851
- }
1852
- };
1853
- const host = createAppHost([], testHostOptions);
1854
- // Batch 1: Add B (stays unready - needs APIX)
1855
- yield host.addShells([declaringB]);
1856
- expect(host.hasShell(declaringB.name)).toBe(false);
1857
- // Batch 2: Add C (depends on APIB from unready B)
1858
- // Even though B is unready, C's effective deps should include B's cold dep on APIA
1859
- yield host.addShells([declaringC]);
1860
- expect(host.hasShell(declaringC.name)).toBe(false);
1861
- // Add X only (provides APIX for B)
1862
- // B can now load and contribute APIB
1863
- // But C should still wait because B's cold dep (APIA) is promoted to C
1864
- yield host.addShells([declaringX]);
1865
- expect(host.hasShell(declaringB.name)).toBe(true);
1866
- expect(host.hasShell(declaringC.name)).toBe(false);
1867
- // Add A (provides APIA)
1868
- yield host.addShells([declaringA]);
1869
- expect(host.hasShell(declaringC.name)).toBe(true);
1870
- }));
1871
- it('should promote cold dependencies through deep regular dependency chains', () => __awaiter(void 0, void 0, void 0, function* () {
1872
- /**
1873
- * (A)───regular───>(B)───regular───>(C)───regular───>(D)
1874
- * │
1875
- * cold
1876
- * │
1877
- * v
1878
- * (E)
1879
- *
1880
- * A depends on B, B depends on C, C depends on D, D has cold dep on E
1881
- * A should wait for E (cold dep promoted through entire chain)
1882
- */
1883
- const APIA = { name: 'API_A' };
1884
- const APIB = { name: 'API_B' };
1885
- const APIC = { name: 'API_C' };
1886
- const APID = { name: 'API_D' };
1887
- const APIE = { name: 'API_E' };
1888
- const declaringE = {
1889
- name: 'ENTRY_POINT_E',
1890
- declareAPIs() {
1891
- return [APIE];
1892
- },
1893
- attach(shell) {
1894
- shell.contributeAPI(APIE, () => ({ stubTrue: () => true }));
1895
- }
1896
- };
1897
- const declaringD = {
1898
- name: 'ENTRY_POINT_D',
1899
- getColdDependencyAPIs() {
1900
- return [APIE];
1901
- },
1902
- declareAPIs() {
1903
- return [APID];
1904
- },
1905
- attach(shell) {
1906
- shell.contributeAPI(APID, () => ({ stubTrue: () => true }));
1907
- }
1908
- };
1909
- const declaringC = {
1910
- name: 'ENTRY_POINT_C',
1911
- getDependencyAPIs() {
1912
- return [APID];
1913
- },
1914
- declareAPIs() {
1915
- return [APIC];
1916
- },
1917
- attach(shell) {
1918
- shell.contributeAPI(APIC, () => ({ stubTrue: () => true }));
1919
- }
1920
- };
1921
- const declaringB = {
1922
- name: 'ENTRY_POINT_B',
1923
- getDependencyAPIs() {
1924
- return [APIC];
1925
- },
1926
- declareAPIs() {
1927
- return [APIB];
1928
- },
1929
- attach(shell) {
1930
- shell.contributeAPI(APIB, () => ({ stubTrue: () => true }));
1931
- }
1932
- };
1933
- const declaringA = {
1934
- name: 'ENTRY_POINT_A',
1935
- getDependencyAPIs() {
1936
- return [APIB];
1937
- },
1938
- declareAPIs() {
1939
- return [APIA];
1940
- },
1941
- attach(shell) {
1942
- shell.contributeAPI(APIA, () => ({ stubTrue: () => true }));
1943
- }
1944
- };
1945
- // Without E, D loads (cold dep doesn't block), but A, B, C should wait
1946
- const host = createAppHost([declaringA, declaringB, declaringC, declaringD], testHostOptions);
1947
- expect(host.hasShell(declaringD.name)).toBe(true);
1948
- expect(host.hasShell(declaringC.name)).toBe(false);
1949
- expect(host.hasShell(declaringB.name)).toBe(false);
1950
- expect(host.hasShell(declaringA.name)).toBe(false);
1951
- // Add E, now everyone can load
1952
- yield host.addShells([declaringE]);
1953
- expect(host.hasShell(declaringC.name)).toBe(true);
1954
- expect(host.hasShell(declaringB.name)).toBe(true);
1955
- expect(host.hasShell(declaringA.name)).toBe(true);
1956
- }));
1957
- });
1958
- it('should not promote transitive cold dependencies to regular dependencies when there is no real direct dependency', () => __awaiter(void 0, void 0, void 0, function* () {
1959
- const APIA = { name: 'API_A' };
1960
- const APIB = { name: 'API_B' };
1961
- const APIC = { name: 'API_C' };
1962
- const APID = { name: 'API_D' };
1963
- const declaringA = {
1964
- name: 'ENTRY_POINT_A',
1965
- declareAPIs() {
1966
- return [APIA];
1967
- },
1968
- attach(shell) {
1969
- shell.contributeAPI(APIA, () => ({
1970
- stubTrue: () => true
1971
- }));
1972
- }
1973
- };
1974
- const declaringBWithColdDepOnA = {
1975
- name: 'ENTRY_POINT_B',
1976
- getColdDependencyAPIs() {
1977
- return [APIA];
1978
- },
1979
- declareAPIs() {
1980
- return [APIB];
1981
- },
1982
- attach(shell) {
1983
- shell.contributeAPI(APIB, () => ({
1984
- stubTrue: () => true
1985
- }));
1986
- }
1987
- };
1988
- const declaringCWithRegularDepOnB = {
1989
- name: 'ENTRY_POINT_C',
1990
- getDependencyAPIs() {
1991
- return [APIB];
1992
- },
1993
- declareAPIs() {
1994
- return [APIC];
1995
- },
1996
- attach(shell) {
1997
- shell.contributeAPI(APIC, () => ({
1998
- stubTrue: () => true
1999
- }));
2000
- }
2001
- };
2002
- const declaringDWithColdDepOnC = {
2003
- name: 'ENTRY_POINT_D',
2004
- getColdDependencyAPIs() {
2005
- return [APIC];
2006
- },
2007
- declareAPIs() {
2008
- return [APID];
2009
- },
2010
- attach(shell) {
2011
- shell.contributeAPI(APID, () => ({
2012
- stubTrue: () => true
2013
- }));
2014
- }
2015
- };
2016
- const host = createAppHost([declaringBWithColdDepOnA, declaringCWithRegularDepOnB, declaringDWithColdDepOnC], testHostOptions);
2017
- expect(host.hasShell(declaringDWithColdDepOnC.name)).toBe(true);
2018
- expect(host.hasShell(declaringCWithRegularDepOnB.name)).toBe(false);
2019
- yield host.addShells([declaringA]);
2020
- expect(host.hasShell(declaringCWithRegularDepOnB.name)).toBe(true);
2021
- }));
2022
- });
2023
1540
  });
2024
1541
  //# sourceMappingURL=appHost.spec.js.map