@citolab/qti-components 7.20.2 → 7.20.3
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/cdn/index.global.js +1 -1
- package/cdn/index.js +81 -63
- package/dist/{chunk-5R3SZ6YB.js → chunk-VEPXXFFW.js} +70 -61
- package/dist/chunk-VEPXXFFW.js.map +1 -0
- package/dist/index.js +1 -1
- package/dist/interactions.js +1 -1
- package/package.json +6 -6
- package/dist/chunk-5R3SZ6YB.js.map +0 -1
|
@@ -1567,32 +1567,49 @@ window.CES = {
|
|
|
1567
1567
|
CES.load();
|
|
1568
1568
|
`;
|
|
1569
1569
|
var ciBootstrap = `
|
|
1570
|
-
|
|
1570
|
+
(function() {
|
|
1571
|
+
var blobUrlReceived = null;
|
|
1572
|
+
|
|
1573
|
+
const createIframe = () => {
|
|
1574
|
+
if (!blobUrlReceived || !document.body) return;
|
|
1575
|
+
var n = document.createElement('iframe');
|
|
1576
|
+
n.frameBorder = '0';
|
|
1577
|
+
n.scrolling = 'no';
|
|
1578
|
+
n.src = blobUrlReceived;
|
|
1579
|
+
n.style.width = '100%';
|
|
1580
|
+
n.style.height = '100%';
|
|
1581
|
+
document.body.appendChild(n);
|
|
1582
|
+
};
|
|
1583
|
+
|
|
1571
1584
|
const handleMessage = (event) => {
|
|
1572
1585
|
if (event.data.type === 'blobUrl') {
|
|
1573
|
-
|
|
1574
|
-
var n = document.createElement('iframe');
|
|
1575
|
-
n.frameBorder = '0';
|
|
1576
|
-
n.scrolling = 'no';
|
|
1577
|
-
n.src = blobUrl;
|
|
1578
|
-
n.style.width = '100%';
|
|
1579
|
-
n.style.height = '100%';
|
|
1580
|
-
document.body.appendChild(n);
|
|
1586
|
+
blobUrlReceived = event.data.data;
|
|
1581
1587
|
window.removeEventListener('message', handleMessage);
|
|
1588
|
+
createIframe();
|
|
1582
1589
|
}
|
|
1583
1590
|
};
|
|
1591
|
+
|
|
1584
1592
|
window.addEventListener('message', handleMessage);
|
|
1585
|
-
|
|
1586
|
-
|
|
1587
|
-
|
|
1588
|
-
w
|
|
1589
|
-
|
|
1590
|
-
w
|
|
1591
|
-
|
|
1592
|
-
|
|
1593
|
+
|
|
1594
|
+
// Wait for document ready before requesting blobUrl
|
|
1595
|
+
const requestBlobUrl = () => {
|
|
1596
|
+
let w = window.parent;
|
|
1597
|
+
while (w) {
|
|
1598
|
+
w.postMessage({ type: 'getBlobUrl' }, '*');
|
|
1599
|
+
if (w !== w.parent) {
|
|
1600
|
+
w = w.parent;
|
|
1601
|
+
} else {
|
|
1602
|
+
w = null;
|
|
1603
|
+
}
|
|
1593
1604
|
}
|
|
1605
|
+
};
|
|
1606
|
+
|
|
1607
|
+
if (document.readyState === 'loading') {
|
|
1608
|
+
document.addEventListener('DOMContentLoaded', requestBlobUrl);
|
|
1609
|
+
} else {
|
|
1610
|
+
requestBlobUrl();
|
|
1594
1611
|
}
|
|
1595
|
-
};
|
|
1612
|
+
})();
|
|
1596
1613
|
`;
|
|
1597
1614
|
var QtiCustomInteraction = class extends Interaction {
|
|
1598
1615
|
constructor() {
|
|
@@ -1673,17 +1690,12 @@ var QtiCustomInteraction = class extends Interaction {
|
|
|
1673
1690
|
}
|
|
1674
1691
|
const cssRef = this.manifest.style[0];
|
|
1675
1692
|
const baseCandidates = this.getBaseCandidates();
|
|
1676
|
-
console.debug("[qti-custom-interaction] manifest url", this._manifestUrl);
|
|
1677
|
-
console.debug("[qti-custom-interaction] base candidates", baseCandidates);
|
|
1678
|
-
console.debug("[qti-custom-interaction] refs", { cssRef, media: this.manifest.media });
|
|
1679
1693
|
const cssResolved = await this.resolveResourceWithFallback(cssRef, baseCandidates);
|
|
1680
1694
|
const cssUrl = cssResolved.url;
|
|
1681
1695
|
if (cssResolved.baseUrl && !this._resourceBaseUrl) {
|
|
1682
1696
|
this._resourceBaseUrl = cssResolved.baseUrl;
|
|
1683
1697
|
}
|
|
1684
|
-
console.debug("[qti-custom-interaction] css resolved", cssResolved);
|
|
1685
1698
|
const usesCES = true;
|
|
1686
|
-
console.debug("[qti-custom-interaction] using built-in ciBootstrap (skipping server bootstrap.js)");
|
|
1687
1699
|
if (usesCES) {
|
|
1688
1700
|
let indexUrl = "";
|
|
1689
1701
|
if (this.manifest.media && this.manifest.media.length > 0) {
|
|
@@ -1695,19 +1707,17 @@ var QtiCustomInteraction = class extends Interaction {
|
|
|
1695
1707
|
if (indexResolved.baseUrl && !this._resourceBaseUrl) {
|
|
1696
1708
|
this._resourceBaseUrl = indexResolved.baseUrl;
|
|
1697
1709
|
}
|
|
1698
|
-
console.debug("[qti-custom-interaction] index resolved (media)", {
|
|
1699
|
-
url: indexResolved.url,
|
|
1700
|
-
baseUrl: indexResolved.baseUrl,
|
|
1701
|
-
hasText: Boolean(indexResolved.text)
|
|
1702
|
-
});
|
|
1703
1710
|
if (indexResolved.text) {
|
|
1704
1711
|
let html = indexResolved.text;
|
|
1705
|
-
const
|
|
1706
|
-
|
|
1707
|
-
|
|
1708
|
-
|
|
1709
|
-
|
|
1710
|
-
|
|
1712
|
+
const alreadyModified = html.includes("postToParentWindows") || html.includes("window.CES");
|
|
1713
|
+
if (!alreadyModified) {
|
|
1714
|
+
const cesScript = "<script>" + registerCES + "</script>";
|
|
1715
|
+
const headIndex = html.indexOf("<head>");
|
|
1716
|
+
if (headIndex !== -1) {
|
|
1717
|
+
html = html.slice(0, headIndex + 6) + cesScript + html.slice(headIndex + 6);
|
|
1718
|
+
} else {
|
|
1719
|
+
html = cesScript + html;
|
|
1720
|
+
}
|
|
1711
1721
|
}
|
|
1712
1722
|
const blob = new Blob([html], { type: "text/html" });
|
|
1713
1723
|
this._contentBlobUrl = URL.createObjectURL(blob);
|
|
@@ -1723,19 +1733,17 @@ var QtiCustomInteraction = class extends Interaction {
|
|
|
1723
1733
|
if (indexResolved.baseUrl && !this._resourceBaseUrl) {
|
|
1724
1734
|
this._resourceBaseUrl = indexResolved.baseUrl;
|
|
1725
1735
|
}
|
|
1726
|
-
console.debug("[qti-custom-interaction] index resolved (fallback)", {
|
|
1727
|
-
url: indexResolved.url,
|
|
1728
|
-
baseUrl: indexResolved.baseUrl,
|
|
1729
|
-
hasText: Boolean(indexResolved.text)
|
|
1730
|
-
});
|
|
1731
1736
|
if (indexResolved.text) {
|
|
1732
1737
|
let html = indexResolved.text;
|
|
1733
|
-
const
|
|
1734
|
-
|
|
1735
|
-
|
|
1736
|
-
|
|
1737
|
-
|
|
1738
|
-
|
|
1738
|
+
const alreadyModified = html.includes("postToParentWindows") || html.includes("window.CES");
|
|
1739
|
+
if (!alreadyModified) {
|
|
1740
|
+
const cesScript = "<script>" + registerCES + "</script>";
|
|
1741
|
+
const headIndex = html.indexOf("<head>");
|
|
1742
|
+
if (headIndex !== -1) {
|
|
1743
|
+
html = html.slice(0, headIndex + 6) + cesScript + html.slice(headIndex + 6);
|
|
1744
|
+
} else {
|
|
1745
|
+
html = cesScript + html;
|
|
1746
|
+
}
|
|
1739
1747
|
}
|
|
1740
1748
|
const blob = new Blob([html], { type: "text/html" });
|
|
1741
1749
|
this._contentBlobUrl = URL.createObjectURL(blob);
|
|
@@ -1746,12 +1754,15 @@ var QtiCustomInteraction = class extends Interaction {
|
|
|
1746
1754
|
const indexResponse = await fetch(indexUrl);
|
|
1747
1755
|
if (indexResponse.ok) {
|
|
1748
1756
|
let html = await indexResponse.text();
|
|
1749
|
-
const
|
|
1750
|
-
|
|
1751
|
-
|
|
1752
|
-
|
|
1753
|
-
|
|
1754
|
-
|
|
1757
|
+
const alreadyModified = html.includes("postToParentWindows") || html.includes("window.CES");
|
|
1758
|
+
if (!alreadyModified) {
|
|
1759
|
+
const cesScript = "<script>" + registerCES + "</script>";
|
|
1760
|
+
const headIndex = html.indexOf("<head>");
|
|
1761
|
+
if (headIndex !== -1) {
|
|
1762
|
+
html = html.slice(0, headIndex + 6) + cesScript + html.slice(headIndex + 6);
|
|
1763
|
+
} else {
|
|
1764
|
+
html = cesScript + html;
|
|
1765
|
+
}
|
|
1755
1766
|
}
|
|
1756
1767
|
const blob = new Blob([html], { type: "text/html" });
|
|
1757
1768
|
this._contentBlobUrl = URL.createObjectURL(blob);
|
|
@@ -1764,10 +1775,9 @@ var QtiCustomInteraction = class extends Interaction {
|
|
|
1764
1775
|
}
|
|
1765
1776
|
}
|
|
1766
1777
|
const inlineScript = `<script>${ciBootstrap}</script>`;
|
|
1767
|
-
console.debug("[qti-custom-interaction] using ciBootstrap inline script");
|
|
1768
1778
|
window.addEventListener("message", this.handlePostMessage);
|
|
1769
|
-
|
|
1770
|
-
|
|
1779
|
+
const htmlContent = `
|
|
1780
|
+
<!DOCTYPE html>
|
|
1771
1781
|
<html>
|
|
1772
1782
|
<head>
|
|
1773
1783
|
${cssUrl ? `<link href='${cssUrl}' rel="stylesheet" />` : ""}
|
|
@@ -1775,8 +1785,8 @@ var QtiCustomInteraction = class extends Interaction {
|
|
|
1775
1785
|
</head>
|
|
1776
1786
|
<body></body>
|
|
1777
1787
|
</html>
|
|
1778
|
-
|
|
1779
|
-
|
|
1788
|
+
`;
|
|
1789
|
+
iframe.srcdoc = htmlContent;
|
|
1780
1790
|
}
|
|
1781
1791
|
getIFrames() {
|
|
1782
1792
|
const iframesInShadowRoot = this.shadowRoot.querySelectorAll("iframe");
|
|
@@ -1833,9 +1843,6 @@ var QtiCustomInteraction = class extends Interaction {
|
|
|
1833
1843
|
}
|
|
1834
1844
|
handlePostMessage(event) {
|
|
1835
1845
|
const { type, data } = event.data;
|
|
1836
|
-
if (type && type !== "setResponse") {
|
|
1837
|
-
console.debug("[qti-custom-interaction] postMessage", { type, data });
|
|
1838
|
-
}
|
|
1839
1846
|
switch (type) {
|
|
1840
1847
|
case "setResponse":
|
|
1841
1848
|
if (data === null || !(Array.isArray(data) && data.length === 1 && data[0] === "")) {
|
|
@@ -1850,6 +1857,9 @@ var QtiCustomInteraction = class extends Interaction {
|
|
|
1850
1857
|
case "getBlobUrl": {
|
|
1851
1858
|
if (this._contentBlobUrl) {
|
|
1852
1859
|
this.postToWindowAndIframes("blobUrl", this._contentBlobUrl);
|
|
1860
|
+
if (event.source && event.source !== window) {
|
|
1861
|
+
event.source.postMessage({ type: "blobUrl", data: this._contentBlobUrl }, "*");
|
|
1862
|
+
}
|
|
1853
1863
|
}
|
|
1854
1864
|
break;
|
|
1855
1865
|
}
|
|
@@ -1865,7 +1875,6 @@ var QtiCustomInteraction = class extends Interaction {
|
|
|
1865
1875
|
}
|
|
1866
1876
|
return new URL(media, baseUrl.endsWith("/") ? baseUrl : `${baseUrl}/`).toString();
|
|
1867
1877
|
});
|
|
1868
|
-
console.debug("[qti-custom-interaction] mediaData", mediaData);
|
|
1869
1878
|
this.postToWindowAndIframes("mediaData", mediaData);
|
|
1870
1879
|
break;
|
|
1871
1880
|
}
|
|
@@ -7295,4 +7304,4 @@ lit-html/node/directives/ref.js:
|
|
|
7295
7304
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
7296
7305
|
*)
|
|
7297
7306
|
*/
|
|
7298
|
-
//# sourceMappingURL=chunk-
|
|
7307
|
+
//# sourceMappingURL=chunk-VEPXXFFW.js.map
|