castle-web-sdk 0.4.13 → 0.4.14
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/runtime.js +20 -0
- package/package.json +1 -1
package/dist/runtime.js
CHANGED
|
@@ -120,6 +120,26 @@ function initPlayCard() {
|
|
|
120
120
|
}
|
|
121
121
|
`;
|
|
122
122
|
document.head.appendChild(style);
|
|
123
|
+
// Mark whatever this turns into a card, the way `initCard` marks the one it
|
|
124
|
+
// creates. Anything looking for "the card" -- a capture cropping to it, in
|
|
125
|
+
// page or headless -- otherwise finds nothing here and has to guess at the
|
|
126
|
+
// viewport, which is not the same rectangle: standalone chrome insets the
|
|
127
|
+
// card, so a viewport shot carries a border the card does not have.
|
|
128
|
+
//
|
|
129
|
+
// Runs on a timer as well as now because `setup()` is called before a deck
|
|
130
|
+
// renders, so #root is usually still empty at this point; a deck that mounts
|
|
131
|
+
// later still gets its card marked.
|
|
132
|
+
function markCard() {
|
|
133
|
+
const el = document.querySelector("#root > *");
|
|
134
|
+
if (el)
|
|
135
|
+
el.dataset.castleCard = "";
|
|
136
|
+
}
|
|
137
|
+
markCard();
|
|
138
|
+
requestAnimationFrame(markCard);
|
|
139
|
+
new MutationObserver(markCard).observe(document.documentElement, {
|
|
140
|
+
childList: true,
|
|
141
|
+
subtree: true,
|
|
142
|
+
});
|
|
123
143
|
function resize() {
|
|
124
144
|
const { w, h } = computeCardSize();
|
|
125
145
|
document.documentElement.style.setProperty("--castle-card-w", w + "px");
|