@behindthemusictree/app-kit 42.0.1 → 43.0.0
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/{app-error-ZuIP62i5.d.ts → app-error-Oq-kGLNi.d.ts} +7 -2
- package/dist/{app-error-codes-D5eYg7xR.d.ts → app-error-codes-CeSN2qun.d.ts} +3 -1
- package/dist/auth/index.cjs.map +1 -1
- package/dist/auth/index.d.ts +2 -2
- package/dist/auth/index.js +3 -3
- package/dist/{chunk-2TJEWD56.js → chunk-AKQYP4OQ.js} +2 -2
- package/dist/{chunk-MPTID5ZR.js → chunk-B6RTYACQ.js} +18 -1
- package/dist/chunk-B6RTYACQ.js.map +1 -0
- package/dist/{chunk-WHJNRJRZ.js → chunk-BYXCG7SI.js} +9 -17
- package/dist/chunk-BYXCG7SI.js.map +1 -0
- package/dist/{chunk-ZAS53EAW.js → chunk-FOSFVEVR.js} +13 -6
- package/dist/chunk-FOSFVEVR.js.map +1 -0
- package/dist/{chunk-3Y7RT7QF.js → chunk-FRL266U2.js} +2 -2
- package/dist/{chunk-MAKY4YBN.js → chunk-VS7A3CP7.js} +36 -2
- package/dist/chunk-VS7A3CP7.js.map +1 -0
- package/dist/{chunk-PZHKZHQY.js → chunk-ZLGTSPQM.js} +3 -3
- package/dist/genre-tree/index.cjs +34 -15
- package/dist/genre-tree/index.cjs.map +1 -1
- package/dist/genre-tree/index.d.ts +1 -1
- package/dist/genre-tree/index.js +5 -5
- package/dist/index.cjs +65 -16
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +3 -3
- package/dist/index.js +11 -7
- package/dist/player/index.cjs +35 -1
- package/dist/player/index.cjs.map +1 -1
- package/dist/player/index.d.ts +6 -1
- package/dist/player/index.js +1 -1
- package/dist/popup/index.cjs.map +1 -1
- package/dist/popup/index.d.ts +1 -1
- package/dist/popup/index.js +2 -2
- package/dist/transport/index.cjs +23 -14
- package/dist/transport/index.cjs.map +1 -1
- package/dist/transport/index.d.ts +5 -4
- package/dist/transport/index.js +7 -3
- package/dist/{useFetchWrapper-H0lO4wFO.d.ts → useFetchWrapper-BdHuoY_y.d.ts} +1 -1
- package/package.json +1 -1
- package/dist/chunk-MAKY4YBN.js.map +0 -1
- package/dist/chunk-MPTID5ZR.js.map +0 -1
- package/dist/chunk-WHJNRJRZ.js.map +0 -1
- package/dist/chunk-ZAS53EAW.js.map +0 -1
- /package/dist/{chunk-2TJEWD56.js.map → chunk-AKQYP4OQ.js.map} +0 -0
- /package/dist/{chunk-3Y7RT7QF.js.map → chunk-FRL266U2.js.map} +0 -0
- /package/dist/{chunk-PZHKZHQY.js.map → chunk-ZLGTSPQM.js.map} +0 -0
|
@@ -2,7 +2,7 @@ import * as _tanstack_react_query from '@tanstack/react-query';
|
|
|
2
2
|
import { QueryKey, InfiniteData } from '@tanstack/react-query';
|
|
3
3
|
import * as zod from 'zod';
|
|
4
4
|
import { z } from 'zod';
|
|
5
|
-
import { R as ResourceResult, S as Scope, u as useFetchWrapper } from '../useFetchWrapper-
|
|
5
|
+
import { R as ResourceResult, S as Scope, u as useFetchWrapper } from '../useFetchWrapper-BdHuoY_y.js';
|
|
6
6
|
import { c as GenreUuid, G as GenrePlaylistUuid } from '../ids-FmUQ8DVM.js';
|
|
7
7
|
export { A as ArtistUuid, a as ArtistUuidSchema, b as GenrePlaylistUuidSchema, d as GenreUuidSchema, S as SongUuid, e as SongUuidSchema, t as toArtistUuid, f as toGenreUuid, g as toSongUuid } from '../ids-FmUQ8DVM.js';
|
|
8
8
|
import * as react from 'react';
|
package/dist/genre-tree/index.js
CHANGED
|
@@ -127,11 +127,11 @@ import {
|
|
|
127
127
|
useTrackListSidebarVisibility,
|
|
128
128
|
useUpdateGenre,
|
|
129
129
|
useVisibleGenrePlaylists
|
|
130
|
-
} from "../chunk-
|
|
131
|
-
import "../chunk-
|
|
132
|
-
import "../chunk-
|
|
133
|
-
import "../chunk-
|
|
134
|
-
import "../chunk-
|
|
130
|
+
} from "../chunk-FOSFVEVR.js";
|
|
131
|
+
import "../chunk-BYXCG7SI.js";
|
|
132
|
+
import "../chunk-FRL266U2.js";
|
|
133
|
+
import "../chunk-B6RTYACQ.js";
|
|
134
|
+
import "../chunk-VS7A3CP7.js";
|
|
135
135
|
import "../chunk-W4QTTNNA.js";
|
|
136
136
|
import {
|
|
137
137
|
ArtistUuidSchema,
|
package/dist/index.cjs
CHANGED
|
@@ -21,6 +21,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
21
21
|
var src_exports = {};
|
|
22
22
|
__export(src_exports, {
|
|
23
23
|
ARTIST_LINK_KINDS: () => ARTIST_LINK_KINDS,
|
|
24
|
+
AUTH_DETAIL_ERROR_CODES: () => AUTH_DETAIL_ERROR_CODES,
|
|
24
25
|
AUTH_POPUP_TYPE: () => AUTH_POPUP_TYPE,
|
|
25
26
|
AlbumMinimumSchema: () => AlbumMinimumSchema,
|
|
26
27
|
AppError: () => AppError,
|
|
@@ -153,6 +154,7 @@ __export(src_exports, {
|
|
|
153
154
|
getSpotifyRequiredCached: () => getSpotifyRequiredCached,
|
|
154
155
|
hasMainstreamPopRoot: () => hasMainstreamPopRoot,
|
|
155
156
|
isNotFoundError: () => isNotFoundError,
|
|
157
|
+
isRetryableError: () => isRetryableError,
|
|
156
158
|
isSong: () => isSong,
|
|
157
159
|
isSongSearchResultPlayable: () => isSongSearchResultPlayable,
|
|
158
160
|
libraryEndpoints: () => libraryEndpoints,
|
|
@@ -273,6 +275,13 @@ var ErrorCode = /* @__PURE__ */ ((ErrorCode2) => {
|
|
|
273
275
|
ErrorCode2["BACKEND_INVALID_INPUT"] = "INP4220";
|
|
274
276
|
return ErrorCode2;
|
|
275
277
|
})(ErrorCode || {});
|
|
278
|
+
var AUTH_DETAIL_ERROR_CODES = [
|
|
279
|
+
"BAC4011" /* BACKEND_GOOGLE_OAUTH_CODE_INVALID_OR_EXPIRED */,
|
|
280
|
+
"BAC4012" /* BACKEND_SPOTIFY_USER_NOT_IN_ALLOWLIST */,
|
|
281
|
+
"BAC4013" /* BACKEND_SPOTIFY_AUTHENTICATION_ERROR */,
|
|
282
|
+
"BAC4014" /* BACKEND_GOOGLE_AUTHENTICATION_ERROR */,
|
|
283
|
+
"BAC4015" /* BACKEND_GOOGLE_OAUTH_MISCONFIGURED */
|
|
284
|
+
];
|
|
276
285
|
|
|
277
286
|
// src/transport/app-errors/app-error-messages.ts
|
|
278
287
|
var SPOTIFY_ACCESS_REQUEST_SUBJECT = "Spotify access request";
|
|
@@ -421,6 +430,14 @@ var ServiceError = class extends ConnectivityError {
|
|
|
421
430
|
}
|
|
422
431
|
};
|
|
423
432
|
var isNotFoundError = (error) => error instanceof BackendError && error.code === "BAC4040" /* BACKEND_NOT_FOUND */;
|
|
433
|
+
var isRetryableError = (error) => {
|
|
434
|
+
if (error instanceof AuthRequired || error instanceof ClientError || error instanceof BadRequestError) return false;
|
|
435
|
+
if (isNotFoundError(error)) return false;
|
|
436
|
+
if (error instanceof BackendError && AUTH_DETAIL_ERROR_CODES.includes(error.code)) return false;
|
|
437
|
+
if (error instanceof BackendError && (error.code === "BAC4030" /* BACKEND_FORBIDDEN */ || error.code === "BAC4031" /* BACKEND_SPOTIFY_AUTHORIZATION_REQUIRED */))
|
|
438
|
+
return false;
|
|
439
|
+
return true;
|
|
440
|
+
};
|
|
424
441
|
|
|
425
442
|
// src/transport/app-errors/app-error-factory.ts
|
|
426
443
|
function createAppErrorFromErrorCode(code, json) {
|
|
@@ -682,11 +699,8 @@ var fetchWrapper = async (url, requiresAuth, options = {}, accessToken, queryPar
|
|
|
682
699
|
} else {
|
|
683
700
|
appError = createNetworkOrBackendError(caughtError, finalUrl, backendBaseUrl);
|
|
684
701
|
}
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
const method = (finalOptions.method ?? "GET").toUpperCase();
|
|
688
|
-
if (method !== "GET" && method !== "HEAD") throw appError;
|
|
689
|
-
return null;
|
|
702
|
+
handleError?.(appError);
|
|
703
|
+
throw appError;
|
|
690
704
|
}
|
|
691
705
|
};
|
|
692
706
|
|
|
@@ -813,14 +827,7 @@ var useBackendRequest = (getBackendBaseUrl) => {
|
|
|
813
827
|
const { clearSession, session, sessionRestored } = useSession();
|
|
814
828
|
const handleError = (0, import_react3.useCallback)((error, isRead) => {
|
|
815
829
|
if (error instanceof ConnectivityError) {
|
|
816
|
-
|
|
817
|
-
"BAC4011" /* BACKEND_GOOGLE_OAUTH_CODE_INVALID_OR_EXPIRED */,
|
|
818
|
-
"BAC4012" /* BACKEND_SPOTIFY_USER_NOT_IN_ALLOWLIST */,
|
|
819
|
-
"BAC4013" /* BACKEND_SPOTIFY_AUTHENTICATION_ERROR */,
|
|
820
|
-
"BAC4014" /* BACKEND_GOOGLE_AUTHENTICATION_ERROR */,
|
|
821
|
-
"BAC4015" /* BACKEND_GOOGLE_OAUTH_MISCONFIGURED */
|
|
822
|
-
];
|
|
823
|
-
if (error instanceof BackendError && authDetailErrors.includes(error.code)) {
|
|
830
|
+
if (error instanceof BackendError && AUTH_DETAIL_ERROR_CODES.includes(error.code)) {
|
|
824
831
|
throw error;
|
|
825
832
|
}
|
|
826
833
|
if (isRead && isNotFoundError(error)) {
|
|
@@ -1067,7 +1074,7 @@ var PaginatedResponseSchema = (itemSchema) => import_zod3.z.object({
|
|
|
1067
1074
|
|
|
1068
1075
|
// src/transport/lib/resource-result.ts
|
|
1069
1076
|
var MAX_RESOURCE_ATTEMPTS = 3;
|
|
1070
|
-
var resourceRetry = (failureCount, error) =>
|
|
1077
|
+
var resourceRetry = (failureCount, error) => isRetryableError(error) && failureCount < MAX_RESOURCE_ATTEMPTS;
|
|
1071
1078
|
function toResourceResult({ id, isValidId, data, error, isPending }) {
|
|
1072
1079
|
if (id === null) return { status: "idle" };
|
|
1073
1080
|
if (!isValidId || isNotFoundError(error)) return { status: "not-found" };
|
|
@@ -1816,6 +1823,7 @@ function PlayerProvider({ children, loadTrack }) {
|
|
|
1816
1823
|
audio.volume = volume / 100;
|
|
1817
1824
|
audioElementRef.current = audio;
|
|
1818
1825
|
audio.addEventListener("loadedmetadata", () => {
|
|
1826
|
+
if (audioElementRef.current !== audio) return;
|
|
1819
1827
|
setDuration(audio.duration);
|
|
1820
1828
|
});
|
|
1821
1829
|
audio.addEventListener("timeupdate", () => {
|
|
@@ -1862,6 +1870,9 @@ function PlayerProvider({ children, loadTrack }) {
|
|
|
1862
1870
|
await new Promise((resolve) => {
|
|
1863
1871
|
const player = new YT.Player(mount, {
|
|
1864
1872
|
videoId: track.youtubeVideoId,
|
|
1873
|
+
// Without these the API defaults to a 640x390 iframe that overflows the surface.
|
|
1874
|
+
width: "100%",
|
|
1875
|
+
height: "100%",
|
|
1865
1876
|
playerVars: { autoplay: 1, controls: 0 },
|
|
1866
1877
|
events: {
|
|
1867
1878
|
onReady: () => {
|
|
@@ -1943,6 +1954,27 @@ function PlayerProvider({ children, loadTrack }) {
|
|
|
1943
1954
|
},
|
|
1944
1955
|
[loadTrack, loadAudioTrack, loadYoutubeTrack, playback.key]
|
|
1945
1956
|
);
|
|
1957
|
+
const stop = (0, import_react15.useCallback)(() => {
|
|
1958
|
+
generation.current++;
|
|
1959
|
+
terminal.current = true;
|
|
1960
|
+
currentTrackIdRef.current = null;
|
|
1961
|
+
currentTimeRef.current = 0;
|
|
1962
|
+
if (audioElementRef.current) {
|
|
1963
|
+
audioElementRef.current.pause();
|
|
1964
|
+
audioElementRef.current = null;
|
|
1965
|
+
}
|
|
1966
|
+
if (youtubePlayerRef.current) {
|
|
1967
|
+
youtubePlayerRef.current.destroy();
|
|
1968
|
+
youtubePlayerRef.current = null;
|
|
1969
|
+
}
|
|
1970
|
+
videoContainerRef.current?.replaceChildren();
|
|
1971
|
+
setPlayerTrackObject(null);
|
|
1972
|
+
setPlaybackConfirmedTrackId(null);
|
|
1973
|
+
setDuration(0);
|
|
1974
|
+
setIsLoading(false);
|
|
1975
|
+
setPlayState("STOPPED" /* STOPPED */);
|
|
1976
|
+
setIsPlaying(false);
|
|
1977
|
+
}, []);
|
|
1946
1978
|
const previousPlaybackKey = (0, import_react15.useRef)(playback.key);
|
|
1947
1979
|
(0, import_react15.useEffect)(() => {
|
|
1948
1980
|
if (previousPlaybackKey.current === playback.key) return;
|
|
@@ -2042,6 +2074,7 @@ function PlayerProvider({ children, loadTrack }) {
|
|
|
2042
2074
|
setPlayState,
|
|
2043
2075
|
handlePlayPauseAction,
|
|
2044
2076
|
loadTrackForPlayer,
|
|
2077
|
+
stop,
|
|
2045
2078
|
isLoading,
|
|
2046
2079
|
handleNextTrack,
|
|
2047
2080
|
handlePreviousTrack,
|
|
@@ -2061,6 +2094,7 @@ function PlayerProvider({ children, loadTrack }) {
|
|
|
2061
2094
|
isLoading,
|
|
2062
2095
|
handlePlayPauseAction,
|
|
2063
2096
|
loadTrackForPlayer,
|
|
2097
|
+
stop,
|
|
2064
2098
|
handleNextTrack,
|
|
2065
2099
|
handlePreviousTrack,
|
|
2066
2100
|
onTrackEnd,
|
|
@@ -2078,9 +2112,16 @@ function usePlayer() {
|
|
|
2078
2112
|
}
|
|
2079
2113
|
return context;
|
|
2080
2114
|
}
|
|
2115
|
+
var VIDEO_SURFACE_FILL_CLASSES = "relative overflow-hidden [&>iframe]:absolute [&>iframe]:inset-0 [&>iframe]:size-full";
|
|
2081
2116
|
function PlayerVideoSurface({ className }) {
|
|
2082
2117
|
const { videoContainerRef } = usePlayer();
|
|
2083
|
-
return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
2118
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
2119
|
+
"div",
|
|
2120
|
+
{
|
|
2121
|
+
ref: videoContainerRef,
|
|
2122
|
+
className: className ? `${VIDEO_SURFACE_FILL_CLASSES} ${className}` : VIDEO_SURFACE_FILL_CLASSES
|
|
2123
|
+
}
|
|
2124
|
+
);
|
|
2084
2125
|
}
|
|
2085
2126
|
function useCurrentTime() {
|
|
2086
2127
|
const { currentTimeRef } = usePlayer();
|
|
@@ -3708,7 +3749,13 @@ function TrackListProvider({
|
|
|
3708
3749
|
const endpoint = genrePlaylistEndpoints[scope].tracks(uuid);
|
|
3709
3750
|
if (scope === "me" && (selection || artistUuid)) throw new Error("Genre selections require reference scope");
|
|
3710
3751
|
const params = { page, pageSize: TRACKS_PAGE_SIZE, ...from && { from }, ...genreMusicQueryParams(selection), ...artistUuid && { artist: artistUuid } };
|
|
3711
|
-
|
|
3752
|
+
let response;
|
|
3753
|
+
try {
|
|
3754
|
+
response = await (page === 1 ? fetchLatest : fetchBound)(endpoint, true, scope === "me", {}, params, false, !!from);
|
|
3755
|
+
} catch (error) {
|
|
3756
|
+
if (error instanceof AppError && !from) throw new TracksFailureAlreadyReportedError();
|
|
3757
|
+
throw error;
|
|
3758
|
+
}
|
|
3712
3759
|
if (response === null && !from) throw new TracksFailureAlreadyReportedError();
|
|
3713
3760
|
const parsed = parseWithLog(pageSchema, response, "fetchGenrePlaylistTracksPage");
|
|
3714
3761
|
return {
|
|
@@ -4194,6 +4241,7 @@ function editGenreSongPages(data, edit) {
|
|
|
4194
4241
|
// Annotate the CommonJS export names for ESM import in node:
|
|
4195
4242
|
0 && (module.exports = {
|
|
4196
4243
|
ARTIST_LINK_KINDS,
|
|
4244
|
+
AUTH_DETAIL_ERROR_CODES,
|
|
4197
4245
|
AUTH_POPUP_TYPE,
|
|
4198
4246
|
AlbumMinimumSchema,
|
|
4199
4247
|
AppError,
|
|
@@ -4326,6 +4374,7 @@ function editGenreSongPages(data, edit) {
|
|
|
4326
4374
|
getSpotifyRequiredCached,
|
|
4327
4375
|
hasMainstreamPopRoot,
|
|
4328
4376
|
isNotFoundError,
|
|
4377
|
+
isRetryableError,
|
|
4329
4378
|
isSong,
|
|
4330
4379
|
isSongSearchResultPlayable,
|
|
4331
4380
|
libraryEndpoints,
|