remote-components 0.0.38 → 0.0.40
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/dist/html/host.cjs +78 -0
- package/dist/html/host.cjs.map +1 -1
- package/dist/html/host.js +78 -0
- package/dist/html/host.js.map +1 -1
- package/dist/internal/next/remote/render-server.cjs +5 -2
- package/dist/internal/next/remote/render-server.cjs.map +1 -1
- package/dist/internal/next/remote/render-server.d.ts +13 -0
- package/dist/internal/next/remote/render-server.js +5 -2
- package/dist/internal/next/remote/render-server.js.map +1 -1
- package/dist/next/host/client/index.cjs +41 -2
- package/dist/next/host/client/index.cjs.map +1 -1
- package/dist/next/host/client/index.d.ts +13 -0
- package/dist/next/host/client/index.js +41 -2
- package/dist/next/host/client/index.js.map +1 -1
- package/dist/react/index.cjs +41 -2
- package/dist/react/index.cjs.map +1 -1
- package/dist/react/index.d.ts +14 -1
- package/dist/react/index.js +41 -2
- package/dist/react/index.js.map +1 -1
- package/package.json +9 -9
package/dist/html/host.cjs
CHANGED
|
@@ -1448,6 +1448,8 @@ if (typeof HTMLElement !== "undefined") {
|
|
|
1448
1448
|
isLoading = false;
|
|
1449
1449
|
prevIsRemoteComponent = false;
|
|
1450
1450
|
prevUrl;
|
|
1451
|
+
prevSrc = null;
|
|
1452
|
+
prevName;
|
|
1451
1453
|
root = null;
|
|
1452
1454
|
reactRoot;
|
|
1453
1455
|
additionalHeaders;
|
|
@@ -1462,6 +1464,16 @@ if (typeof HTMLElement !== "undefined") {
|
|
|
1462
1464
|
if (this.getAttribute("src")) {
|
|
1463
1465
|
this.load().catch((e) => {
|
|
1464
1466
|
console.error(e);
|
|
1467
|
+
const errorEvent = new Event("error", {
|
|
1468
|
+
bubbles: true,
|
|
1469
|
+
composed: true
|
|
1470
|
+
});
|
|
1471
|
+
Object.assign(errorEvent, {
|
|
1472
|
+
error: e,
|
|
1473
|
+
src: this.getAttribute("src")
|
|
1474
|
+
});
|
|
1475
|
+
this.dispatchEvent(errorEvent);
|
|
1476
|
+
this.isLoading = false;
|
|
1465
1477
|
});
|
|
1466
1478
|
}
|
|
1467
1479
|
} else if (name === "mode" && oldValue !== newValue && this.root) {
|
|
@@ -1474,6 +1486,15 @@ if (typeof HTMLElement !== "undefined") {
|
|
|
1474
1486
|
this.root = newRoot;
|
|
1475
1487
|
this.load().catch((e) => {
|
|
1476
1488
|
console.error(e);
|
|
1489
|
+
const errorEvent = new Event("error", {
|
|
1490
|
+
bubbles: true,
|
|
1491
|
+
composed: true
|
|
1492
|
+
});
|
|
1493
|
+
Object.assign(errorEvent, {
|
|
1494
|
+
error: e,
|
|
1495
|
+
src: this.getAttribute("src")
|
|
1496
|
+
});
|
|
1497
|
+
this.dispatchEvent(errorEvent);
|
|
1477
1498
|
});
|
|
1478
1499
|
}
|
|
1479
1500
|
}
|
|
@@ -1508,10 +1529,25 @@ if (typeof HTMLElement !== "undefined") {
|
|
|
1508
1529
|
if (this.hasAttribute("src") || this.querySelector("div#__REMOTE_COMPONENT__") || this.hasAttribute("data-ssr")) {
|
|
1509
1530
|
this.load().catch((e) => {
|
|
1510
1531
|
console.error(e);
|
|
1532
|
+
const errorEvent = new Event("error", {
|
|
1533
|
+
bubbles: true,
|
|
1534
|
+
composed: true
|
|
1535
|
+
});
|
|
1536
|
+
Object.assign(errorEvent, {
|
|
1537
|
+
error: e,
|
|
1538
|
+
src: this.getAttribute("src")
|
|
1539
|
+
});
|
|
1540
|
+
this.dispatchEvent(errorEvent);
|
|
1511
1541
|
});
|
|
1512
1542
|
}
|
|
1513
1543
|
this.isLoading = true;
|
|
1514
1544
|
const src = this.getAttribute("src");
|
|
1545
|
+
const beforeLoadEvent = new Event("beforeload", {
|
|
1546
|
+
bubbles: true,
|
|
1547
|
+
composed: true
|
|
1548
|
+
});
|
|
1549
|
+
Object.assign(beforeLoadEvent, { src });
|
|
1550
|
+
this.dispatchEvent(beforeLoadEvent);
|
|
1515
1551
|
const remoteComponentChild = this.querySelector("div#__REMOTE_COMPONENT__") || this.querySelector("div[data-bundle][data-route]");
|
|
1516
1552
|
if (!src && !remoteComponentChild) {
|
|
1517
1553
|
throw new RemoteComponentsError('"src" attribute is required');
|
|
@@ -1646,8 +1682,23 @@ if (typeof HTMLElement !== "undefined") {
|
|
|
1646
1682
|
}
|
|
1647
1683
|
this.root.innerHTML = "";
|
|
1648
1684
|
}
|
|
1685
|
+
if (this.prevSrc !== null) {
|
|
1686
|
+
const changeEvent = new Event("change", {
|
|
1687
|
+
bubbles: true,
|
|
1688
|
+
composed: true
|
|
1689
|
+
});
|
|
1690
|
+
Object.assign(changeEvent, {
|
|
1691
|
+
previousSrc: this.prevSrc,
|
|
1692
|
+
nextSrc: src,
|
|
1693
|
+
previousName: this.prevName,
|
|
1694
|
+
nextName: this.name
|
|
1695
|
+
});
|
|
1696
|
+
this.dispatchEvent(changeEvent);
|
|
1697
|
+
}
|
|
1649
1698
|
this.prevUrl = url ?? new URL(location.href);
|
|
1650
1699
|
this.prevIsRemoteComponent = isRemoteComponent;
|
|
1700
|
+
this.prevSrc = src;
|
|
1701
|
+
this.prevName = this.name;
|
|
1651
1702
|
const removable = Array.from(this.childNodes);
|
|
1652
1703
|
const links = doc.querySelectorAll("link[href]");
|
|
1653
1704
|
const remoteComponentSrc = this.getAttribute("src");
|
|
@@ -1866,6 +1917,12 @@ if (typeof HTMLElement !== "undefined") {
|
|
|
1866
1917
|
});
|
|
1867
1918
|
}
|
|
1868
1919
|
this.isLoading = false;
|
|
1920
|
+
const loadEvent = new Event("load", {
|
|
1921
|
+
bubbles: true,
|
|
1922
|
+
composed: true
|
|
1923
|
+
});
|
|
1924
|
+
Object.assign(loadEvent, { src: this.getAttribute("src") });
|
|
1925
|
+
this.dispatchEvent(loadEvent);
|
|
1869
1926
|
}, [initial, name]);
|
|
1870
1927
|
return Component;
|
|
1871
1928
|
};
|
|
@@ -1913,6 +1970,14 @@ if (typeof HTMLElement !== "undefined") {
|
|
|
1913
1970
|
});
|
|
1914
1971
|
}
|
|
1915
1972
|
remoteComponent.isLoading = false;
|
|
1973
|
+
const loadEvent = new Event("load", {
|
|
1974
|
+
bubbles: true,
|
|
1975
|
+
composed: true
|
|
1976
|
+
});
|
|
1977
|
+
Object.assign(loadEvent, {
|
|
1978
|
+
src: remoteComponent.getAttribute("src")
|
|
1979
|
+
});
|
|
1980
|
+
remoteComponent.dispatchEvent(loadEvent);
|
|
1916
1981
|
}, [initial, remoteComponent]);
|
|
1917
1982
|
return NextApp ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(NextApp, { Component: NextComponent, ...nextData.props }) : /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(NextComponent, { ...nextData.props });
|
|
1918
1983
|
})(App, Component, this);
|
|
@@ -1952,6 +2017,19 @@ if (typeof HTMLElement !== "undefined") {
|
|
|
1952
2017
|
}
|
|
1953
2018
|
})
|
|
1954
2019
|
);
|
|
2020
|
+
const loadEvent = new Event("load", {
|
|
2021
|
+
bubbles: true,
|
|
2022
|
+
composed: true
|
|
2023
|
+
});
|
|
2024
|
+
Object.assign(loadEvent, { src: this.getAttribute("src") });
|
|
2025
|
+
this.dispatchEvent(loadEvent);
|
|
2026
|
+
} else {
|
|
2027
|
+
const loadEvent = new Event("load", {
|
|
2028
|
+
bubbles: true,
|
|
2029
|
+
composed: true
|
|
2030
|
+
});
|
|
2031
|
+
Object.assign(loadEvent, { src: this.getAttribute("src") });
|
|
2032
|
+
this.dispatchEvent(loadEvent);
|
|
1955
2033
|
}
|
|
1956
2034
|
this.isLoading = false;
|
|
1957
2035
|
}
|