Skip to content

Commit 5ec3acf

Browse files
mgurgelgithub-actions[bot]
authored andcommitted
Release build 8.2.0 [ci release]
1 parent 45b36e0 commit 5ec3acf

File tree

13 files changed

+390
-90
lines changed

13 files changed

+390
-90
lines changed

CHANGELOG.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
- support noUnusedParameters (#1579)
1+
- Enables Duck Player custom error on all platforms (#1535)

Sources/ContentScopeScripts/dist/pages/duckplayer/dist/index.js

Lines changed: 43 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2016,20 +2016,53 @@
20162016
* @param {{state: 'enabled' | 'disabled'}} [params.pip]
20172017
* @param {{state: 'enabled' | 'disabled'}} [params.autoplay]
20182018
* @param {{state: 'enabled' | 'disabled'}} [params.focusMode]
2019-
* @param {import("../types/duckplayer.js").InitialSetupResponse['settings']['customError']} [params.customError]
2019+
* @param {import("../types/duckplayer.js").DuckPlayerPageSettings['customError']} [params.customError]
20202020
*/
20212021
constructor({
20222022
platform = { name: "macos" },
20232023
pip = { state: "disabled" },
20242024
autoplay = { state: "enabled" },
20252025
focusMode = { state: "enabled" },
2026-
customError = { state: "disabled", signInRequiredSelector: "" }
2026+
customError = { state: "disabled", settings: {}, signInRequiredSelector: "" }
20272027
}) {
20282028
this.platform = platform;
20292029
this.pip = pip;
20302030
this.autoplay = autoplay;
20312031
this.focusMode = focusMode;
2032-
this.customError = customError;
2032+
this.customError = this.parseLegacyCustomError(customError);
2033+
}
2034+
/**
2035+
* Parses custom error settings so that both old and new schemas are accepted.
2036+
*
2037+
* Old schema:
2038+
* {
2039+
* state: "enabled",
2040+
* signInRequiredSelector: "div"
2041+
* }
2042+
*
2043+
* New schema:
2044+
* {
2045+
* state: "disabled",
2046+
* settings: {
2047+
* signInRequiredSelector: "div"
2048+
* }
2049+
* }
2050+
*
2051+
* @param {import("../types/duckplayer.js").DuckPlayerPageSettings['customError']} initialSettings
2052+
* @return {import("../types/duckplayer.js").CustomErrorSettings}
2053+
*/
2054+
parseLegacyCustomError(initialSettings) {
2055+
if (initialSettings?.state !== "enabled") {
2056+
return { state: "disabled" };
2057+
}
2058+
const { settings, signInRequiredSelector } = initialSettings;
2059+
return {
2060+
state: "enabled",
2061+
settings: {
2062+
...settings,
2063+
...signInRequiredSelector && { signInRequiredSelector }
2064+
}
2065+
};
20332066
}
20342067
/**
20352068
* @param {keyof import("../types/duckplayer.js").DuckPlayerPageSettings} named
@@ -3025,17 +3058,14 @@
30253058
}
30263059
const [error, setError] = h2(initialError);
30273060
const messaging2 = useMessaging();
3028-
const platformName = usePlatformName();
30293061
const setFocusMode = useSetFocusMode();
30303062
y2(() => {
30313063
const errorEventHandler = (event) => {
30323064
const eventError = event.detail?.error;
30333065
if (YOUTUBE_ERROR_IDS.includes(eventError) || eventError === null) {
30343066
if (eventError && eventError !== error) {
30353067
setFocusMode("paused");
3036-
if (platformName === "macos" || platformName === "ios") {
3037-
messaging2.reportYouTubeError({ error: eventError });
3038-
}
3068+
messaging2.reportYouTubeError({ error: eventError });
30393069
} else {
30403070
setFocusMode("enabled");
30413071
}
@@ -3055,10 +3085,10 @@
30553085
var ErrorDetection = class {
30563086
/** @type {HTMLIFrameElement} */
30573087
iframe;
3058-
/** @type {CustomErrorOptions} */
3088+
/** @type {CustomErrorSettings} */
30593089
options;
30603090
/**
3061-
* @param {CustomErrorOptions} options
3091+
* @param {CustomErrorSettings} options
30623092
*/
30633093
constructor(options) {
30643094
this.options = options;
@@ -3068,8 +3098,8 @@
30683098
*/
30693099
iframeDidLoad(iframe) {
30703100
this.iframe = iframe;
3071-
if (!this.options || !this.options.signInRequiredSelector) {
3072-
console.log("Missing Custom Error options");
3101+
if (this.options?.state !== "enabled") {
3102+
console.log("Error detection disabled");
30733103
return null;
30743104
}
30753105
const documentBody = iframe.contentWindow?.document?.body;
@@ -3135,7 +3165,8 @@
31353165
return YOUTUBE_ERRORS.noEmbed;
31363166
}
31373167
try {
3138-
if (this.options?.signInRequiredSelector && !!iframeWindow.document.querySelector(this.options.signInRequiredSelector)) {
3168+
const { settings } = this.options;
3169+
if (settings?.signInRequiredSelector && !!iframeWindow.document.querySelector(settings.signInRequiredSelector)) {
31393170
return YOUTUBE_ERRORS.signInRequired;
31403171
}
31413172
} catch (e3) {

Sources/ContentScopeScripts/dist/pages/duckplayer/index.html

Lines changed: 43 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3151,20 +3151,53 @@
31513151
* @param {{state: 'enabled' | 'disabled'}} [params.pip]
31523152
* @param {{state: 'enabled' | 'disabled'}} [params.autoplay]
31533153
* @param {{state: 'enabled' | 'disabled'}} [params.focusMode]
3154-
* @param {import("../types/duckplayer.js").InitialSetupResponse['settings']['customError']} [params.customError]
3154+
* @param {import("../types/duckplayer.js").DuckPlayerPageSettings['customError']} [params.customError]
31553155
*/
31563156
constructor({
31573157
platform = { name: "macos" },
31583158
pip = { state: "disabled" },
31593159
autoplay = { state: "enabled" },
31603160
focusMode = { state: "enabled" },
3161-
customError = { state: "disabled", signInRequiredSelector: "" }
3161+
customError = { state: "disabled", settings: {}, signInRequiredSelector: "" }
31623162
}) {
31633163
this.platform = platform;
31643164
this.pip = pip;
31653165
this.autoplay = autoplay;
31663166
this.focusMode = focusMode;
3167-
this.customError = customError;
3167+
this.customError = this.parseLegacyCustomError(customError);
3168+
}
3169+
/**
3170+
* Parses custom error settings so that both old and new schemas are accepted.
3171+
*
3172+
* Old schema:
3173+
* {
3174+
* state: "enabled",
3175+
* signInRequiredSelector: "div"
3176+
* }
3177+
*
3178+
* New schema:
3179+
* {
3180+
* state: "disabled",
3181+
* settings: {
3182+
* signInRequiredSelector: "div"
3183+
* }
3184+
* }
3185+
*
3186+
* @param {import("../types/duckplayer.js").DuckPlayerPageSettings['customError']} initialSettings
3187+
* @return {import("../types/duckplayer.js").CustomErrorSettings}
3188+
*/
3189+
parseLegacyCustomError(initialSettings) {
3190+
if (initialSettings?.state !== "enabled") {
3191+
return { state: "disabled" };
3192+
}
3193+
const { settings, signInRequiredSelector } = initialSettings;
3194+
return {
3195+
state: "enabled",
3196+
settings: {
3197+
...settings,
3198+
...signInRequiredSelector && { signInRequiredSelector }
3199+
}
3200+
};
31683201
}
31693202
/**
31703203
* @param {keyof import("../types/duckplayer.js").DuckPlayerPageSettings} named
@@ -4160,17 +4193,14 @@
41604193
}
41614194
const [error, setError] = h2(initialError);
41624195
const messaging2 = useMessaging();
4163-
const platformName = usePlatformName();
41644196
const setFocusMode = useSetFocusMode();
41654197
y2(() => {
41664198
const errorEventHandler = (event) => {
41674199
const eventError = event.detail?.error;
41684200
if (YOUTUBE_ERROR_IDS.includes(eventError) || eventError === null) {
41694201
if (eventError && eventError !== error) {
41704202
setFocusMode("paused");
4171-
if (platformName === "macos" || platformName === "ios") {
4172-
messaging2.reportYouTubeError({ error: eventError });
4173-
}
4203+
messaging2.reportYouTubeError({ error: eventError });
41744204
} else {
41754205
setFocusMode("enabled");
41764206
}
@@ -4190,10 +4220,10 @@
41904220
var ErrorDetection = class {
41914221
/** @type {HTMLIFrameElement} */
41924222
iframe;
4193-
/** @type {CustomErrorOptions} */
4223+
/** @type {CustomErrorSettings} */
41944224
options;
41954225
/**
4196-
* @param {CustomErrorOptions} options
4226+
* @param {CustomErrorSettings} options
41974227
*/
41984228
constructor(options) {
41994229
this.options = options;
@@ -4203,8 +4233,8 @@
42034233
*/
42044234
iframeDidLoad(iframe) {
42054235
this.iframe = iframe;
4206-
if (!this.options || !this.options.signInRequiredSelector) {
4207-
console.log("Missing Custom Error options");
4236+
if (this.options?.state !== "enabled") {
4237+
console.log("Error detection disabled");
42084238
return null;
42094239
}
42104240
const documentBody = iframe.contentWindow?.document?.body;
@@ -4270,7 +4300,8 @@
42704300
return YOUTUBE_ERRORS.noEmbed;
42714301
}
42724302
try {
4273-
if (this.options?.signInRequiredSelector && !!iframeWindow.document.querySelector(this.options.signInRequiredSelector)) {
4303+
const { settings } = this.options;
4304+
if (settings?.signInRequiredSelector && !!iframeWindow.document.querySelector(settings.signInRequiredSelector)) {
42744305
return YOUTUBE_ERRORS.signInRequired;
42754306
}
42764307
} catch (e3) {

build/android/pages/duckplayer/dist/index.js

Lines changed: 43 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2016,20 +2016,53 @@
20162016
* @param {{state: 'enabled' | 'disabled'}} [params.pip]
20172017
* @param {{state: 'enabled' | 'disabled'}} [params.autoplay]
20182018
* @param {{state: 'enabled' | 'disabled'}} [params.focusMode]
2019-
* @param {import("../types/duckplayer.js").InitialSetupResponse['settings']['customError']} [params.customError]
2019+
* @param {import("../types/duckplayer.js").DuckPlayerPageSettings['customError']} [params.customError]
20202020
*/
20212021
constructor({
20222022
platform = { name: "macos" },
20232023
pip = { state: "disabled" },
20242024
autoplay = { state: "enabled" },
20252025
focusMode = { state: "enabled" },
2026-
customError = { state: "disabled", signInRequiredSelector: "" }
2026+
customError = { state: "disabled", settings: {}, signInRequiredSelector: "" }
20272027
}) {
20282028
this.platform = platform;
20292029
this.pip = pip;
20302030
this.autoplay = autoplay;
20312031
this.focusMode = focusMode;
2032-
this.customError = customError;
2032+
this.customError = this.parseLegacyCustomError(customError);
2033+
}
2034+
/**
2035+
* Parses custom error settings so that both old and new schemas are accepted.
2036+
*
2037+
* Old schema:
2038+
* {
2039+
* state: "enabled",
2040+
* signInRequiredSelector: "div"
2041+
* }
2042+
*
2043+
* New schema:
2044+
* {
2045+
* state: "disabled",
2046+
* settings: {
2047+
* signInRequiredSelector: "div"
2048+
* }
2049+
* }
2050+
*
2051+
* @param {import("../types/duckplayer.js").DuckPlayerPageSettings['customError']} initialSettings
2052+
* @return {import("../types/duckplayer.js").CustomErrorSettings}
2053+
*/
2054+
parseLegacyCustomError(initialSettings) {
2055+
if (initialSettings?.state !== "enabled") {
2056+
return { state: "disabled" };
2057+
}
2058+
const { settings, signInRequiredSelector } = initialSettings;
2059+
return {
2060+
state: "enabled",
2061+
settings: {
2062+
...settings,
2063+
...signInRequiredSelector && { signInRequiredSelector }
2064+
}
2065+
};
20332066
}
20342067
/**
20352068
* @param {keyof import("../types/duckplayer.js").DuckPlayerPageSettings} named
@@ -3025,17 +3058,14 @@
30253058
}
30263059
const [error, setError] = h2(initialError);
30273060
const messaging2 = useMessaging();
3028-
const platformName = usePlatformName();
30293061
const setFocusMode = useSetFocusMode();
30303062
y2(() => {
30313063
const errorEventHandler = (event) => {
30323064
const eventError = event.detail?.error;
30333065
if (YOUTUBE_ERROR_IDS.includes(eventError) || eventError === null) {
30343066
if (eventError && eventError !== error) {
30353067
setFocusMode("paused");
3036-
if (platformName === "macos" || platformName === "ios") {
3037-
messaging2.reportYouTubeError({ error: eventError });
3038-
}
3068+
messaging2.reportYouTubeError({ error: eventError });
30393069
} else {
30403070
setFocusMode("enabled");
30413071
}
@@ -3055,10 +3085,10 @@
30553085
var ErrorDetection = class {
30563086
/** @type {HTMLIFrameElement} */
30573087
iframe;
3058-
/** @type {CustomErrorOptions} */
3088+
/** @type {CustomErrorSettings} */
30593089
options;
30603090
/**
3061-
* @param {CustomErrorOptions} options
3091+
* @param {CustomErrorSettings} options
30623092
*/
30633093
constructor(options) {
30643094
this.options = options;
@@ -3068,8 +3098,8 @@
30683098
*/
30693099
iframeDidLoad(iframe) {
30703100
this.iframe = iframe;
3071-
if (!this.options || !this.options.signInRequiredSelector) {
3072-
console.log("Missing Custom Error options");
3101+
if (this.options?.state !== "enabled") {
3102+
console.log("Error detection disabled");
30733103
return null;
30743104
}
30753105
const documentBody = iframe.contentWindow?.document?.body;
@@ -3135,7 +3165,8 @@
31353165
return YOUTUBE_ERRORS.noEmbed;
31363166
}
31373167
try {
3138-
if (this.options?.signInRequiredSelector && !!iframeWindow.document.querySelector(this.options.signInRequiredSelector)) {
3168+
const { settings } = this.options;
3169+
if (settings?.signInRequiredSelector && !!iframeWindow.document.querySelector(settings.signInRequiredSelector)) {
31393170
return YOUTUBE_ERRORS.signInRequired;
31403171
}
31413172
} catch (e3) {

0 commit comments

Comments
 (0)