beauticode-dsh 1.0.15 → 1.0.16
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/atmosphere.js +2 -2
- package/client.js +35 -6
- package/package.json +1 -1
package/atmosphere.js
CHANGED
|
@@ -92,8 +92,8 @@ html[data-bc-resolved-tone="light"][data-bc-gallery="true"] body{
|
|
|
92
92
|
}
|
|
93
93
|
html[data-bc-gallery="true"] #root{position:relative;z-index:1;background:transparent!important}
|
|
94
94
|
html[data-bc-gallery="true"] [class*="_fade"]{display:none!important}
|
|
95
|
-
html[data-bc-gallery="true"] #beauticode-bg-stage
|
|
96
|
-
html[data-bc-gallery="true"] #beauticode-bg-stage
|
|
95
|
+
html[data-bc-gallery="true"] #beauticode-bg-stage img,
|
|
96
|
+
html[data-bc-gallery="true"] #beauticode-bg-stage video{opacity:0!important}
|
|
97
97
|
html[data-bc-fish="true"] #root{opacity:0!important;visibility:hidden!important;pointer-events:none!important}
|
|
98
98
|
`;
|
|
99
99
|
return style;
|
package/client.js
CHANGED
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
const desiredModes = { fish: false, muted: true, tone: "auto" };
|
|
11
11
|
const IMAGE_LOAD_TIMEOUT_MS = 12_000;
|
|
12
12
|
const VIDEO_STARTUP_TIMEOUT_MS = 20_000;
|
|
13
|
+
const DSH_STRUCTURE_TIMEOUT_MS = 10_000;
|
|
13
14
|
const VIDEO_STABLE_FRAMES = 3;
|
|
14
15
|
const VIDEO_STABLE_PROGRESS_SEC = 0.18;
|
|
15
16
|
const CROSSFADE_MS = 180;
|
|
@@ -149,12 +150,39 @@ html[data-bc-fish="true"] #root{opacity:0!important;visibility:hidden!important;
|
|
|
149
150
|
* If the shell no longer exposes it, report a clear error through the
|
|
150
151
|
* render ack instead of silently painting a broken page.
|
|
151
152
|
*/
|
|
152
|
-
function dshStructureIssue() {
|
|
153
|
-
if (!document.getElementById("root")) {
|
|
154
|
-
return "DSH 页面结构不兼容:未找到 #root。";
|
|
155
|
-
}
|
|
156
|
-
return null;
|
|
157
|
-
}
|
|
153
|
+
function dshStructureIssue() {
|
|
154
|
+
if (!document.getElementById("root")) {
|
|
155
|
+
return "DSH 页面结构不兼容:未找到 #root。";
|
|
156
|
+
}
|
|
157
|
+
return null;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
function waitForDshStructure(signal, timeoutMs = DSH_STRUCTURE_TIMEOUT_MS) {
|
|
161
|
+
if (!dshStructureIssue()) return Promise.resolve();
|
|
162
|
+
return new Promise((resolve, reject) => {
|
|
163
|
+
let settled = false;
|
|
164
|
+
const startedAt = performance.now();
|
|
165
|
+
const finish = (error = null) => {
|
|
166
|
+
if (settled) return;
|
|
167
|
+
settled = true;
|
|
168
|
+
clearInterval(timer);
|
|
169
|
+
signal?.removeEventListener?.("abort", aborted);
|
|
170
|
+
if (error) reject(error);
|
|
171
|
+
else resolve();
|
|
172
|
+
};
|
|
173
|
+
const aborted = () => finish(abortError());
|
|
174
|
+
const timer = setInterval(() => {
|
|
175
|
+
const issue = dshStructureIssue();
|
|
176
|
+
if (!issue) {
|
|
177
|
+
finish();
|
|
178
|
+
} else if (performance.now() - startedAt >= timeoutMs) {
|
|
179
|
+
finish(new Error(issue));
|
|
180
|
+
}
|
|
181
|
+
}, 50);
|
|
182
|
+
signal?.addEventListener?.("abort", aborted, { once: true });
|
|
183
|
+
if (signal?.aborted) aborted();
|
|
184
|
+
});
|
|
185
|
+
}
|
|
158
186
|
|
|
159
187
|
function activeVideo() {
|
|
160
188
|
const video = currentSlot?.querySelector?.("video") ?? null;
|
|
@@ -793,6 +821,7 @@ html[data-bc-fish="true"] #root{opacity:0!important;visibility:hidden!important;
|
|
|
793
821
|
let candidate = null;
|
|
794
822
|
let committed = false;
|
|
795
823
|
try {
|
|
824
|
+
await waitForDshStructure(signal);
|
|
796
825
|
const image = await loadImage(payload.imageUrl, signal);
|
|
797
826
|
throwIfAborted(signal);
|
|
798
827
|
if (payload.media === "image") {
|