@flamingo-stack/openframe-frontend-core 0.0.854 → 0.0.855
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/build/export-map.json +1 -1
- package/dist/{case-study-card-WP5Z234Q.cjs → case-study-card-6VAMNHLU.cjs} +8 -8
- package/dist/{chunk-FBANHIAG.cjs → chunk-2JCA7BRK.cjs} +19 -19
- package/dist/{chunk-7MOBD44H.cjs → chunk-2MCPK6AX.cjs} +28 -28
- package/dist/{chunk-GVHCQRUE.cjs → chunk-2P72KAG5.cjs} +23 -23
- package/dist/{chunk-YY3WP2YQ.cjs → chunk-3GJ75OUL.cjs} +183 -183
- package/dist/{chunk-FJXSKMQJ.cjs → chunk-4H3J57AN.cjs} +25 -25
- package/dist/{chunk-6GWRPW6B.cjs → chunk-5NK3FUHY.cjs} +4 -4
- package/dist/{chunk-DLTPSP5F.cjs → chunk-5TYG5JNB.cjs} +2 -2
- package/dist/{chunk-63ZV3UGG.cjs → chunk-65NMKAPQ.cjs} +12 -12
- package/dist/{chunk-IGVAPIEW.cjs → chunk-6C4OR4MZ.cjs} +2 -2
- package/dist/{chunk-GG466XFQ.cjs → chunk-6DMH4GXN.cjs} +30 -5
- package/dist/{chunk-S5P6CF5R.cjs → chunk-6VVQJU76.cjs} +54 -54
- package/dist/{chunk-2IJMHBOK.cjs → chunk-77GX573I.cjs} +9 -9
- package/dist/{chunk-D2XGRWPW.cjs → chunk-AOOHJLXS.cjs} +90 -90
- package/dist/{chunk-O3EKOXFZ.cjs → chunk-AYMY2VNB.cjs} +37 -43
- package/dist/{chunk-RMI6O3AE.cjs → chunk-BSPIGZCC.cjs} +36 -36
- package/dist/{chunk-JKBNK5U6.cjs → chunk-D6GEMVHD.cjs} +3 -3
- package/dist/{chunk-7J5NSWJG.cjs → chunk-DPNFI5XM.cjs} +100 -100
- package/dist/{chunk-TMPLHUUU.cjs → chunk-DTZ6KASI.cjs} +6 -6
- package/dist/{chunk-SSKMGH5O.cjs → chunk-DXVGGWLG.cjs} +10 -10
- package/dist/{chunk-5TXE7BXT.cjs → chunk-EOUEUYCQ.cjs} +54 -54
- package/dist/{chunk-EIHMPQRQ.cjs → chunk-ESGE7CUX.cjs} +14 -14
- package/dist/{chunk-ETZFBB7O.cjs → chunk-EXQSIX2I.cjs} +4 -4
- package/dist/{chunk-3WXHPD6N.cjs → chunk-F33EAPD2.cjs} +124 -124
- package/dist/{chunk-4SSJ3T3N.cjs → chunk-GK577ZLJ.cjs} +3 -13
- package/dist/{chunk-BAA3YCLT.cjs → chunk-GZYRDLJW.cjs} +103 -103
- package/dist/{chunk-VMAOZA2V.cjs → chunk-HML3JUXF.cjs} +324 -322
- package/dist/{chunk-4O5N5CGK.cjs → chunk-J3CFRGZ2.cjs} +17 -17
- package/dist/{chunk-LQDAB5V5.cjs → chunk-KZAQPRTA.cjs} +9 -11
- package/dist/{chunk-6DCUGIGU.cjs → chunk-LSLRJJFP.cjs} +2 -2
- package/dist/{chunk-ETQNMR2K.cjs → chunk-MINFN3IG.cjs} +8 -8
- package/dist/{chunk-ONYANAMA.cjs → chunk-MX52LZ6M.cjs} +6 -6
- package/dist/{chunk-OH5TXFRR.cjs → chunk-O4CPT3RK.cjs} +7 -7
- package/dist/{chunk-ZDPPNHA2.cjs → chunk-OTHQ2KQW.cjs} +3 -3
- package/dist/{chunk-5HMENXSR.cjs → chunk-PCQ2HKU3.cjs} +5 -5
- package/dist/{chunk-6XU3RCK3.cjs → chunk-QPHXYE5P.cjs} +27 -27
- package/dist/{chunk-UPQ4MAR7.cjs → chunk-QZXCUY36.cjs} +53 -53
- package/dist/{chunk-5OENPMRU.cjs → chunk-RIJU4HZ2.cjs} +51 -55
- package/dist/{chunk-KKFDRCQF.cjs → chunk-RY7INTYU.cjs} +14 -1
- package/dist/{chunk-GI3MMBP3.cjs → chunk-SQ7YHWEP.cjs} +228 -15
- package/dist/{chunk-ACPOJE32.cjs → chunk-STV6VJ3U.cjs} +21 -21
- package/dist/{chunk-QD727QFI.cjs → chunk-T54I5ZZY.cjs} +7 -7
- package/dist/{chunk-4LTLEUY5.cjs → chunk-TW5Y4D5I.cjs} +7 -7
- package/dist/{chunk-FX35L4Y6.cjs → chunk-XCQ5I27Z.cjs} +3 -3
- package/dist/{chunk-AZEO7HBB.cjs → chunk-Y44EF4JW.cjs} +2 -2
- package/dist/{chunk-KA3L6D5N.cjs → chunk-YSXVRTGT.cjs} +9 -12
- package/dist/{chunk-PRJZMZ3X.cjs → chunk-ZUGJLCYP.cjs} +678 -678
- package/dist/{chunk-H3GBPYPS.cjs → chunk-ZYAVIRQV.cjs} +25 -25
- package/dist/{cloud-tenants-5RNK4ZAT.cjs → cloud-tenants-2XFIDDGU.cjs} +28 -29
- package/dist/components/case-studies/index.cjs +44 -45
- package/dist/components/chat/chat-message-row.d.ts +1 -1
- package/dist/components/chat/chat-message-row.d.ts.map +1 -1
- package/dist/components/chat/chat-message-row.js +4 -4
- package/dist/components/chat/entity-cards/use-cover-image-fallback.d.ts +7 -13
- package/dist/components/chat/entity-cards/use-cover-image-fallback.d.ts.map +1 -1
- package/dist/components/chat/entity-cards/use-cover-image-fallback.js +2 -8
- package/dist/components/chat/hooks/use-chat-attachment-image-gallery.d.ts.map +1 -1
- package/dist/components/chat/hooks/use-chat-attachment-image-gallery.js +8 -4
- package/dist/components/chat/index.cjs +22 -23
- package/dist/components/contact/index.cjs +29 -30
- package/dist/components/docs/index.cjs +32 -33
- package/dist/components/embeds/index.cjs +29 -30
- package/dist/components/faq/index.cjs +30 -31
- package/dist/components/features/index.cjs +28 -29
- package/dist/components/help-center-pages/index.cjs +134 -135
- package/dist/components/index.cjs +112 -113
- package/dist/components/meeting-scheduler/index.cjs +102 -103
- package/dist/components/navigation/index.cjs +31 -32
- package/dist/components/onboarding-guides/index.cjs +31 -32
- package/dist/components/product-demo/index.cjs +39 -40
- package/dist/components/related-content/index.cjs +16 -17
- package/dist/components/tickets/index.cjs +35 -36
- package/dist/components/ui/entity-image.d.ts +1 -2
- package/dist/components/ui/entity-image.d.ts.map +1 -1
- package/dist/components/ui/entity-image.js +4 -8
- package/dist/components/ui/index.cjs +28 -29
- package/dist/components/ui/markdown/base-components.d.ts +0 -13
- package/dist/components/ui/markdown/base-components.d.ts.map +1 -1
- package/dist/components/ui/markdown/base-components.js +7 -7
- package/dist/components/ui/square-avatar.d.ts.map +1 -1
- package/dist/components/ui/square-avatar.js +3 -8
- package/dist/{devices-44O5PZOW.cjs → devices-O3DYGIZB.cjs} +29 -30
- package/dist/embed-shims/index.cjs +3 -2
- package/dist/embed-shims/next-image.cjs +3 -2
- package/dist/embed-shims/next-image.d.ts +2 -0
- package/dist/embed-shims/next-image.d.ts.map +1 -1
- package/dist/embed-shims/next-image.js +14 -4
- package/dist/{embeddable-chat-W3CLMGC3.cjs → embeddable-chat-QD7NFD2H.cjs} +100 -101
- package/dist/hooks/index.cjs +23 -16
- package/dist/hooks/index.d.ts +1 -0
- package/dist/hooks/index.d.ts.map +1 -1
- package/dist/hooks/index.js +1 -0
- package/dist/hooks/use-authed-asset-src.d.ts +77 -2
- package/dist/hooks/use-authed-asset-src.d.ts.map +1 -1
- package/dist/hooks/use-authed-asset-src.js +185 -73
- package/dist/hooks/use-authed-image-src.d.ts +11 -4
- package/dist/hooks/use-authed-image-src.d.ts.map +1 -1
- package/dist/hooks/use-authed-image-src.js +6 -2
- package/dist/hooks/use-image-fallback.d.ts +16 -0
- package/dist/hooks/use-image-fallback.d.ts.map +1 -0
- package/dist/hooks/use-image-fallback.js +14 -0
- package/dist/index.cjs +40 -36
- package/dist/{knowledge-UUU3WVO3.cjs → knowledge-K7AFNZNO.cjs} +29 -30
- package/dist/{logs-DFHNSODA.cjs → logs-MZ3BR2FR.cjs} +35 -36
- package/dist/{policies-RGFUGDBP.cjs → policies-XVKQ2W7S.cjs} +32 -33
- package/dist/{remote-session-U3H77HKR.cjs → remote-session-VOZJXDM4.cjs} +13 -14
- package/dist/{scripts-KOVO5DHW.cjs → scripts-IBPMBS6G.cjs} +35 -36
- package/dist/{software-update-4EKHVV5W.cjs → software-update-PXTANMAO.cjs} +32 -33
- package/dist/{tickets-board-YIFOVMDX.cjs → tickets-board-POYZS7BW.cjs} +16 -17
- package/dist/utils/app-origins.d.ts +3 -6
- package/dist/utils/app-origins.d.ts.map +1 -1
- package/dist/utils/app-origins.js +8 -1
- package/dist/utils/embed-authed-fetch.d.ts +46 -26
- package/dist/utils/embed-authed-fetch.d.ts.map +1 -1
- package/dist/utils/embed-authed-fetch.js +24 -8
- package/dist/utils/index.cjs +4 -1
- package/dist/{video-file-player-XMOB234V.cjs → video-file-player-RIOT24NT.cjs} +3 -4
- package/package.json +1 -1
- package/src/components/chat/chat-message-row.tsx +8 -7
- package/src/components/chat/entity-cards/use-cover-image-fallback.ts +8 -28
- package/src/components/chat/hooks/use-chat-attachment-image-gallery.tsx +19 -8
- package/src/components/ui/entity-image.tsx +4 -12
- package/src/components/ui/markdown/base-components.tsx +15 -20
- package/src/components/ui/square-avatar.tsx +5 -8
- package/src/embed-shims/next-image.tsx +34 -3
- package/src/hooks/index.ts +1 -0
- package/src/hooks/use-authed-asset-src.ts +323 -107
- package/src/hooks/use-authed-image-src.ts +15 -5
- package/src/hooks/use-image-fallback.ts +31 -0
- package/src/utils/app-origins.ts +12 -7
- package/src/utils/embed-authed-fetch.ts +71 -32
- package/dist/chunk-YSDB6HGQ.cjs +0 -102
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
* (e.g. `/api/profile/me`) keep using vanilla `fetch`.
|
|
21
21
|
*/
|
|
22
22
|
|
|
23
|
-
import { resolveAppOriginUrl } from './app-origins';
|
|
23
|
+
import { isPageOriginUrl, readAppOrigins, resolveAppOriginUrl } from './app-origins';
|
|
24
24
|
import { readRegisteredAdapter, writeRegisteredAdapter } from './embed-auth-adapter-registry';
|
|
25
25
|
import { applyProxyAuth } from './embed-proxy-auth-storage';
|
|
26
26
|
|
|
@@ -129,6 +129,27 @@ export interface EmbedAuthAdapter {
|
|
|
129
129
|
* remains the rule, this is the narrow exception.
|
|
130
130
|
*/
|
|
131
131
|
allowedOrigins?: string[];
|
|
132
|
+
/**
|
|
133
|
+
* Optional: where a picture or other asset URL found in the host's data actually lives. Every asset the lib
|
|
134
|
+
* loads natively (the boxed `Image`, and everything drawn through `useAuthedAsset`) passes its URL through
|
|
135
|
+
* this first. A backend path that the page's origin does not serve, such as `/images/user/1` stored on a
|
|
136
|
+
* record but served at `{gateway}/api/images/user/1`, then loads from the gateway on every host, including a
|
|
137
|
+
* native shell, whose page origin has no server behind it.
|
|
138
|
+
*
|
|
139
|
+
* Must be idempotent. It must return absolute URLs and `data:` / `blob:` URLs unchanged, and leave the host's
|
|
140
|
+
* own static assets alone. Omit it when every URL in the host's data is already loadable as it stands. A host
|
|
141
|
+
* that registers `next/image` with its optimizer on must allow the hosts this returns in its image config.
|
|
142
|
+
*/
|
|
143
|
+
resolveAssetUrl?: (url: string) => string;
|
|
144
|
+
/**
|
|
145
|
+
* Optional, side-effect-free: whether `getHeaders()` would carry an `Authorization` header now. Declaring it also
|
|
146
|
+
* says the host authenticates by header: a picture on an origin in `allowedOrigins` then waits for the credential
|
|
147
|
+
* (`assetLoadMode`'s `awaiting-credential`) instead of loading natively into a 401. The lib asks it for every
|
|
148
|
+
* mounted picture and right after every credential change, so a host whose `getHeaders` has per-call side effects
|
|
149
|
+
* needs it to keep classifying from counting as sending.
|
|
150
|
+
* Without it the lib reads `getHeaders()` and never waits.
|
|
151
|
+
*/
|
|
152
|
+
hasCredential?: () => boolean;
|
|
132
153
|
/**
|
|
133
154
|
* Optional: call `listener` whenever `getHeaders()` starts returning a NEW
|
|
134
155
|
* credential (a rotation the host ran on its own — e.g. a native shell's
|
|
@@ -189,39 +210,45 @@ export function subscribeEmbedCredentialChange(listener: () => void): () => void
|
|
|
189
210
|
}
|
|
190
211
|
|
|
191
212
|
/**
|
|
192
|
-
*
|
|
193
|
-
*
|
|
194
|
-
*
|
|
195
|
-
*
|
|
196
|
-
* can't carry custom headers, so a URL this returns `true` for must go
|
|
197
|
-
* through `embedAuthedFetch` → blob object-URL instead (see
|
|
198
|
-
* `useAuthedAssetSrc` / `useAuthedImageSrc`).
|
|
199
|
-
*
|
|
200
|
-
* The single signal is the registered adapter: when it supplies an
|
|
201
|
-
* `Authorization` header, the host authenticates by HEADER, so nothing the
|
|
202
|
-
* browser fetches on its own is authenticated. That holds for BOTH shapes a
|
|
203
|
-
* header-auth host takes:
|
|
204
|
-
*
|
|
205
|
-
* - a cross-origin gateway URL — sanctioned via `allowedOrigins` (native
|
|
206
|
-
* shells, whose page origin is `capacitor://` / `tauri://`);
|
|
207
|
-
* - a same-origin / relative reverse-proxy path (`/content/api/...`) —
|
|
208
|
-
* dev-ticket web, where the token lives in localStorage and there is NO
|
|
209
|
-
* session cookie to fall back on. This case used to be excluded on the
|
|
210
|
-
* assumption that same-origin implies "cookies work"; true for a cookie
|
|
211
|
-
* session, false for every header-auth host, which is exactly when this
|
|
212
|
-
* predicate is consulted at all.
|
|
213
|
+
* How the browser has to load an asset URL on this host. Native asset loads (`<img src>`, `<track src>`, CSS
|
|
214
|
+
* `background-image`) can't carry custom headers, so where the host authenticates by HEADER (its adapter has a
|
|
215
|
+
* credential: `hasCredential`, else an `Authorization` from `getHeaders`) nothing the browser fetches on its own is
|
|
216
|
+
* authenticated:
|
|
213
217
|
*
|
|
214
|
-
*
|
|
215
|
-
*
|
|
216
|
-
*
|
|
217
|
-
*
|
|
218
|
+
* - `native`: hand it to the element as it stands. Cookie-auth web (no credential), no adapter at all (the hub), a
|
|
219
|
+
* third-party origin the bearer does NOT belong to (public images: out of the token's reach by the same origin
|
|
220
|
+
* rules `embedAuthedFetch` enforces), or a non-http(s) URL (`data:`, `blob:`, a native shell's own bundle).
|
|
221
|
+
* - `bearer`: fetch it with the adapter's credential (`embedAuthedFetch`) and draw the blob. That covers both shapes
|
|
222
|
+
* a header-auth host takes: a cross-origin gateway sanctioned in `allowedOrigins` (native shells, whose page
|
|
223
|
+
* origin is `capacitor://` / `tauri://`), and a same-origin or relative reverse-proxy path (`/content/api/...`)
|
|
224
|
+
* on dev-ticket web, where the token lives in localStorage and there is NO session cookie to fall back on.
|
|
225
|
+
* - `awaiting-credential`: it lives on a gateway the host sanctioned in `allowedOrigins`, which only the bearer
|
|
226
|
+
* opens, and the host, which declared header auth (`hasCredential`), has no credential yet. A native shell
|
|
227
|
+
* renders before its tokens arrive: a native load at that moment is a guaranteed 401, so the caller waits for
|
|
228
|
+
* `subscribeEmbedCredentialChange` instead.
|
|
218
229
|
*/
|
|
219
|
-
export
|
|
220
|
-
|
|
230
|
+
export type AssetLoadMode = 'native' | 'bearer' | 'awaiting-credential';
|
|
231
|
+
|
|
232
|
+
/** `url`'s `AssetLoadMode` on this host now. Pass the URL after `resolveAssetUrl`. */
|
|
233
|
+
export function assetLoadMode(url: string): AssetLoadMode {
|
|
234
|
+
if (typeof window === 'undefined') return 'native';
|
|
221
235
|
const adapter = getRegisteredAuthAdapter();
|
|
222
|
-
if (!adapter
|
|
223
|
-
const
|
|
224
|
-
|
|
236
|
+
if (!adapter) return 'native';
|
|
237
|
+
const origins = readAppOrigins();
|
|
238
|
+
const target = resolveAppOriginUrl(url, origins);
|
|
239
|
+
if (!target || (target.protocol !== 'http:' && target.protocol !== 'https:')) return 'native';
|
|
240
|
+
if (!adapter.hasCredential) return adapter.getHeaders?.().Authorization !== undefined ? 'bearer' : 'native';
|
|
241
|
+
if (adapter.hasCredential()) return 'bearer';
|
|
242
|
+
// The page's own origin without a credential: cookie-auth web authenticates there by cookie, and a shell's http(s)
|
|
243
|
+
// page origin (`https://localhost`, `http://tauri.localhost`) is its own bundle. A header-auth web host lacks one
|
|
244
|
+
// there only while signed out, and its next credential change re-classifies the picture.
|
|
245
|
+
return isPageOriginUrl(target, origins) ? 'native' : 'awaiting-credential';
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
/** `url` where the host says it lives (`EmbedAuthAdapter.resolveAssetUrl`); unchanged when no host says. */
|
|
249
|
+
export function resolveAssetUrl(url: string): string {
|
|
250
|
+
const resolve = getRegisteredAuthAdapter()?.resolveAssetUrl;
|
|
251
|
+
return resolve ? resolve(url) : url;
|
|
225
252
|
}
|
|
226
253
|
|
|
227
254
|
/**
|
|
@@ -347,6 +374,16 @@ function dedupedRefresh(): Promise<boolean> {
|
|
|
347
374
|
return inFlightRefresh;
|
|
348
375
|
}
|
|
349
376
|
|
|
377
|
+
const answersAfterRefresh = new WeakSet<Response>();
|
|
378
|
+
|
|
379
|
+
/**
|
|
380
|
+
* Whether `response` answered the retry `embedAuthedFetch` sent after refreshing the credential: a 401 here is a
|
|
381
|
+
* refusal of a credential just issued, which another refresh will not lift.
|
|
382
|
+
*/
|
|
383
|
+
export function answeredAfterRefresh(response: Response): boolean {
|
|
384
|
+
return answersAfterRefresh.has(response);
|
|
385
|
+
}
|
|
386
|
+
|
|
350
387
|
/**
|
|
351
388
|
* Core fetch path: merge proxy-auth + adapter headers, issue the request,
|
|
352
389
|
* and — on a `401` with a refresh-capable adapter — refresh once and retry
|
|
@@ -406,7 +443,9 @@ async function fetchWithRefresh(
|
|
|
406
443
|
if (response.status === 401 && !isRetry && adapter?.refresh) {
|
|
407
444
|
const refreshed = await dedupedRefresh();
|
|
408
445
|
if (refreshed) {
|
|
409
|
-
|
|
446
|
+
const retried = await fetchWithRefresh(url, init, baseHeaders, true);
|
|
447
|
+
answersAfterRefresh.add(retried);
|
|
448
|
+
return retried;
|
|
410
449
|
}
|
|
411
450
|
}
|
|
412
451
|
|
package/dist/chunk-YSDB6HGQ.cjs
DELETED
|
@@ -1,102 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } }"use client";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
var _chunkGI3MMBP3cjs = require('./chunk-GI3MMBP3.cjs');
|
|
6
|
-
|
|
7
|
-
// src/hooks/ui/use-isomorphic-layout-effect.ts
|
|
8
|
-
var _react = require('react');
|
|
9
|
-
var useIsomorphicLayoutEffect = typeof window !== "undefined" ? _react.useLayoutEffect : _react.useEffect;
|
|
10
|
-
|
|
11
|
-
// src/hooks/use-authed-asset-src.ts
|
|
12
|
-
|
|
13
|
-
var resolvedCache = /* @__PURE__ */ new Map();
|
|
14
|
-
var inFlight = /* @__PURE__ */ new Map();
|
|
15
|
-
var cacheGeneration = 0;
|
|
16
|
-
var RELEASE_DELAY_MS = 6e4;
|
|
17
|
-
var refCounts = /* @__PURE__ */ new Map();
|
|
18
|
-
var releaseTimers = /* @__PURE__ */ new Map();
|
|
19
|
-
function scheduleRelease(src) {
|
|
20
|
-
clearTimeout(releaseTimers.get(src));
|
|
21
|
-
releaseTimers.set(
|
|
22
|
-
src,
|
|
23
|
-
setTimeout(() => {
|
|
24
|
-
releaseTimers.delete(src);
|
|
25
|
-
if (refCounts.has(src)) return;
|
|
26
|
-
const blobUrl = resolvedCache.get(src);
|
|
27
|
-
if (blobUrl) URL.revokeObjectURL(blobUrl);
|
|
28
|
-
resolvedCache.delete(src);
|
|
29
|
-
}, RELEASE_DELAY_MS)
|
|
30
|
-
);
|
|
31
|
-
}
|
|
32
|
-
function acquire(src) {
|
|
33
|
-
clearTimeout(releaseTimers.get(src));
|
|
34
|
-
releaseTimers.delete(src);
|
|
35
|
-
refCounts.set(src, (_nullishCoalesce(refCounts.get(src), () => ( 0))) + 1);
|
|
36
|
-
}
|
|
37
|
-
function release(src) {
|
|
38
|
-
const remaining = (_nullishCoalesce(refCounts.get(src), () => ( 1))) - 1;
|
|
39
|
-
if (remaining > 0) {
|
|
40
|
-
refCounts.set(src, remaining);
|
|
41
|
-
return;
|
|
42
|
-
}
|
|
43
|
-
refCounts.delete(src);
|
|
44
|
-
scheduleRelease(src);
|
|
45
|
-
}
|
|
46
|
-
function clearAuthedAssetCache() {
|
|
47
|
-
cacheGeneration++;
|
|
48
|
-
for (const url of resolvedCache.values()) URL.revokeObjectURL(url);
|
|
49
|
-
resolvedCache.clear();
|
|
50
|
-
inFlight.clear();
|
|
51
|
-
for (const timer of releaseTimers.values()) clearTimeout(timer);
|
|
52
|
-
releaseTimers.clear();
|
|
53
|
-
}
|
|
54
|
-
function fetchAsBlobUrl(src, accept) {
|
|
55
|
-
let pending = inFlight.get(src);
|
|
56
|
-
if (!pending) {
|
|
57
|
-
const startedGeneration = cacheGeneration;
|
|
58
|
-
pending = _chunkGI3MMBP3cjs.embedAuthedFetch.call(void 0, src, { headers: { Accept: accept } }).then(async (response) => {
|
|
59
|
-
if (!response.ok) throw new Error(`asset fetch failed: ${response.status}`);
|
|
60
|
-
const blobUrl = URL.createObjectURL(await response.blob());
|
|
61
|
-
if (startedGeneration === cacheGeneration) {
|
|
62
|
-
resolvedCache.set(src, blobUrl);
|
|
63
|
-
if (!refCounts.has(src)) scheduleRelease(src);
|
|
64
|
-
} else {
|
|
65
|
-
URL.revokeObjectURL(blobUrl);
|
|
66
|
-
}
|
|
67
|
-
}).finally(() => {
|
|
68
|
-
if (inFlight.get(src) === pending) inFlight.delete(src);
|
|
69
|
-
});
|
|
70
|
-
inFlight.set(src, pending);
|
|
71
|
-
}
|
|
72
|
-
return pending;
|
|
73
|
-
}
|
|
74
|
-
function useAuthedAssetSrc(src, accept = "*/*") {
|
|
75
|
-
const bearerSrc = src && _chunkGI3MMBP3cjs.needsBearerAssetFetch.call(void 0, src) ? src : null;
|
|
76
|
-
const [, rerender] = _react.useReducer.call(void 0, (c) => c + 1, 0);
|
|
77
|
-
useIsomorphicLayoutEffect(() => {
|
|
78
|
-
if (!bearerSrc) return void 0;
|
|
79
|
-
acquire(bearerSrc);
|
|
80
|
-
return () => release(bearerSrc);
|
|
81
|
-
}, [bearerSrc]);
|
|
82
|
-
_react.useEffect.call(void 0, () => {
|
|
83
|
-
if (!bearerSrc || resolvedCache.has(bearerSrc)) return void 0;
|
|
84
|
-
let cancelled = false;
|
|
85
|
-
fetchAsBlobUrl(bearerSrc, accept).catch(() => {
|
|
86
|
-
}).finally(() => {
|
|
87
|
-
if (!cancelled) rerender();
|
|
88
|
-
});
|
|
89
|
-
return () => {
|
|
90
|
-
cancelled = true;
|
|
91
|
-
};
|
|
92
|
-
}, [bearerSrc, accept]);
|
|
93
|
-
if (!src) return void 0;
|
|
94
|
-
if (!bearerSrc) return src;
|
|
95
|
-
return resolvedCache.get(bearerSrc);
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
exports.useIsomorphicLayoutEffect = useIsomorphicLayoutEffect; exports.clearAuthedAssetCache = clearAuthedAssetCache; exports.useAuthedAssetSrc = useAuthedAssetSrc;
|