@flapsdk/vault-runtime 0.1.36 → 0.1.38-next.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/{chunk-QLVWFL4T.js → chunk-44P2NRRZ.js} +96 -152
- package/chunk-44P2NRRZ.js.map +1 -0
- package/chunk-A3ER7XYN.js +408 -0
- package/chunk-A3ER7XYN.js.map +1 -0
- package/{chunk-22KTLOYH.js → chunk-FWYBGHBX.js} +17 -4
- package/chunk-FWYBGHBX.js.map +1 -0
- package/{chunk-IN34R3DY.js → chunk-JVOFLTLD.js} +207 -72
- package/chunk-JVOFLTLD.js.map +1 -0
- package/host-client.d.mts +9 -2
- package/host-client.js +3 -3
- package/host.d.mts +5 -5
- package/host.js +4 -4
- package/{hostRuntimeConfig-DAz-f577.d.mts → hostRuntimeConfig-DibvcxHE.d.mts} +1 -1
- package/{mpegts-536UQHCG.js → mpegts-J2J6JTD7.js} +6 -6
- package/{mpegts-536UQHCG.js.map → mpegts-J2J6JTD7.js.map} +1 -1
- package/package.json +4 -3
- package/runtime-contract.json +5 -1
- package/sdk.d.mts +40 -4
- package/sdk.js +38 -6
- package/sdk.js.map +1 -1
- package/server.d.mts +3 -3
- package/{txError-DmiNOh9R.d.mts → txError-OBuRV8xN.d.mts} +15 -2
- package/{types-BbjEsfiD.d.mts → types-DUZWZ3mC.d.mts} +98 -4
- package/ui.d.mts +13 -2
- package/ui.js +1 -1
- package/chunk-22KTLOYH.js.map +0 -1
- package/chunk-AGLB72HK.js +0 -61
- package/chunk-AGLB72HK.js.map +0 -1
- package/chunk-IN34R3DY.js.map +0 -1
- package/chunk-QLVWFL4T.js.map +0 -1
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { shortenAddress, isValidAddress, ZERO_ADDRESS } from './chunk-B4WKI3EW.js';
|
|
2
2
|
import { isIpfsImageCid, resolveIpfsImageUrls, resolveIpfsImageUrl } from './chunk-SAG36LUR.js';
|
|
3
3
|
import { getTaxVaultHostChainConfig } from './chunk-FUOBTZMQ.js';
|
|
4
|
-
import * as
|
|
4
|
+
import * as React9 from 'react';
|
|
5
5
|
import { createContext, useContext, useState, useEffect, useMemo } from 'react';
|
|
6
|
-
import { Loader2, ExternalLink, AlertTriangle, CheckCircle2, Info, X, ShieldCheck, Play, Pause, VolumeX, Volume2, Maximize, SkipBack, ChevronLeft, ChevronRight, SkipForward } from 'lucide-react';
|
|
6
|
+
import { Loader2, ExternalLink, AlertTriangle, CheckCircle2, Info, Check, AlertCircle, Copy, X, ShieldCheck, Play, Pause, VolumeX, Volume2, Maximize, SkipBack, ChevronLeft, ChevronRight, SkipForward } from 'lucide-react';
|
|
7
7
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
8
8
|
import { clsx } from 'clsx';
|
|
9
9
|
import { twMerge } from 'tailwind-merge';
|
|
@@ -11,6 +11,38 @@ import { Slot } from '@radix-ui/react-slot';
|
|
|
11
11
|
import { cva } from 'class-variance-authority';
|
|
12
12
|
import { createPortal } from 'react-dom';
|
|
13
13
|
|
|
14
|
+
var RuntimeContext = createContext(null);
|
|
15
|
+
var MiniAppContext = createContext(null);
|
|
16
|
+
function useFlapSdk(options) {
|
|
17
|
+
const vault = useContext(RuntimeContext);
|
|
18
|
+
const app = useContext(MiniAppContext);
|
|
19
|
+
if (options) {
|
|
20
|
+
const runtime = app ?? vault;
|
|
21
|
+
if (!runtime) throw new Error("useFlapSdk requires a Flap runtime provider.");
|
|
22
|
+
return runtime.forChain(options.chainId);
|
|
23
|
+
}
|
|
24
|
+
if (vault && !app) return vault;
|
|
25
|
+
if (app) throw new Error("Independent Apps must select a network: useFlapSdk({ chainId }).");
|
|
26
|
+
throw new Error("useFlapSdk requires a Flap runtime provider.");
|
|
27
|
+
}
|
|
28
|
+
function useVaultContext() {
|
|
29
|
+
return useFlapSdk().context;
|
|
30
|
+
}
|
|
31
|
+
function useFlapI18n() {
|
|
32
|
+
const vault = useContext(RuntimeContext);
|
|
33
|
+
const app = useContext(MiniAppContext);
|
|
34
|
+
const runtime = app ?? vault;
|
|
35
|
+
if (!runtime) throw new Error("A Flap runtime provider is required.");
|
|
36
|
+
return runtime.i18n;
|
|
37
|
+
}
|
|
38
|
+
function useFlapNotify() {
|
|
39
|
+
const vault = useContext(RuntimeContext);
|
|
40
|
+
const app = useContext(MiniAppContext);
|
|
41
|
+
const runtime = app ?? vault;
|
|
42
|
+
if (!runtime) throw new Error("A Flap runtime provider is required.");
|
|
43
|
+
return runtime.notify;
|
|
44
|
+
}
|
|
45
|
+
|
|
14
46
|
// src/sdk/videoSession.ts
|
|
15
47
|
var videoProviderAbi = [
|
|
16
48
|
{ type: "function", name: "getVideoSessionLength", stateMutability: "view", inputs: [{ name: "user", type: "address" }], outputs: [{ type: "uint256" }] },
|
|
@@ -66,21 +98,6 @@ async function readVideoSessionSlice(sdk, consumer, start, count) {
|
|
|
66
98
|
function createConsumerVideoSessionReader(sdk, consumer) {
|
|
67
99
|
return { readLength: () => readVideoSessionLength(sdk, consumer), readSlice: (start, count) => readVideoSessionSlice(sdk, consumer, start, count) };
|
|
68
100
|
}
|
|
69
|
-
var RuntimeContext = createContext(null);
|
|
70
|
-
function useFlapSdk() {
|
|
71
|
-
const sdk = useContext(RuntimeContext);
|
|
72
|
-
if (!sdk) throw new Error("useFlapSdk must be used within VaultRuntimeProvider.");
|
|
73
|
-
return sdk;
|
|
74
|
-
}
|
|
75
|
-
function useVaultContext() {
|
|
76
|
-
return useFlapSdk().context;
|
|
77
|
-
}
|
|
78
|
-
function useFlapI18n() {
|
|
79
|
-
return useFlapSdk().i18n;
|
|
80
|
-
}
|
|
81
|
-
function useFlapNotify() {
|
|
82
|
-
return useFlapSdk().notify;
|
|
83
|
-
}
|
|
84
101
|
function AddressLink({ address, explorerBaseUrl, label }) {
|
|
85
102
|
if (!address) return /* @__PURE__ */ jsx("span", { children: "-" });
|
|
86
103
|
const href = explorerBaseUrl ? `${explorerBaseUrl.replace(/\/$/, "")}/address/${address}` : void 0;
|
|
@@ -136,7 +153,7 @@ var buttonVariants = cva(
|
|
|
136
153
|
}
|
|
137
154
|
}
|
|
138
155
|
);
|
|
139
|
-
var Button =
|
|
156
|
+
var Button = React9.forwardRef(
|
|
140
157
|
({ className, variant, size, asChild = false, loading = false, disabled, children, ...props }, ref) => {
|
|
141
158
|
const Comp = asChild ? Slot : "button";
|
|
142
159
|
if (asChild) {
|
|
@@ -178,8 +195,8 @@ function normalizeBinanceImageUrl(value) {
|
|
|
178
195
|
}
|
|
179
196
|
}
|
|
180
197
|
function BinanceImage({ alt, src, fallback = null, className, onError, ...props }) {
|
|
181
|
-
const safeSrc =
|
|
182
|
-
const [failedSrc, setFailedSrc] =
|
|
198
|
+
const safeSrc = React9.useMemo(() => normalizeBinanceImageUrl(src), [src]);
|
|
199
|
+
const [failedSrc, setFailedSrc] = React9.useState(null);
|
|
183
200
|
const {
|
|
184
201
|
alt: _unsafeAlt,
|
|
185
202
|
decoding: _unsafeDecoding,
|
|
@@ -213,7 +230,7 @@ function BinanceImage({ alt, src, fallback = null, className, onError, ...props
|
|
|
213
230
|
)
|
|
214
231
|
);
|
|
215
232
|
}
|
|
216
|
-
var Card =
|
|
233
|
+
var Card = React9.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
|
|
217
234
|
"div",
|
|
218
235
|
{
|
|
219
236
|
"data-flap-ui": "card",
|
|
@@ -226,19 +243,19 @@ var Card = React8.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ j
|
|
|
226
243
|
}
|
|
227
244
|
));
|
|
228
245
|
Card.displayName = "Card";
|
|
229
|
-
var CardHeader =
|
|
246
|
+
var CardHeader = React9.forwardRef(
|
|
230
247
|
({ className, ...props }, ref) => /* @__PURE__ */ jsx("div", { "data-flap-ui": "card-header", ref, className: cn("flex flex-col gap-1.5 p-4 sm:p-5", className), ...props })
|
|
231
248
|
);
|
|
232
249
|
CardHeader.displayName = "CardHeader";
|
|
233
|
-
var CardTitle =
|
|
250
|
+
var CardTitle = React9.forwardRef(
|
|
234
251
|
({ className, ...props }, ref) => /* @__PURE__ */ jsx("h3", { "data-flap-ui": "card-title", ref, className: cn("text-base font-semibold uppercase leading-tight tracking-normal text-white sm:text-lg", className), ...props })
|
|
235
252
|
);
|
|
236
253
|
CardTitle.displayName = "CardTitle";
|
|
237
|
-
var CardDescription =
|
|
254
|
+
var CardDescription = React9.forwardRef(
|
|
238
255
|
({ className, ...props }, ref) => /* @__PURE__ */ jsx("p", { "data-flap-ui": "card-description", ref, className: cn("text-sm leading-6 text-[#84888C]", className), ...props })
|
|
239
256
|
);
|
|
240
257
|
CardDescription.displayName = "CardDescription";
|
|
241
|
-
var CardContent =
|
|
258
|
+
var CardContent = React9.forwardRef(
|
|
242
259
|
({ className, ...props }, ref) => /* @__PURE__ */ jsx("div", { "data-flap-ui": "card-content", ref, className: cn("p-4 pt-0 sm:p-5 sm:pt-0", className), ...props })
|
|
243
260
|
);
|
|
244
261
|
CardContent.displayName = "CardContent";
|
|
@@ -265,6 +282,124 @@ function Countdown({ targetTimeMs, fallback = "-" }) {
|
|
|
265
282
|
}, [fallback, now, targetTimeMs]);
|
|
266
283
|
return /* @__PURE__ */ jsx("span", { children: text });
|
|
267
284
|
}
|
|
285
|
+
|
|
286
|
+
// src/ui/copyButtonMessages.ts
|
|
287
|
+
var copyButtonMessages = {
|
|
288
|
+
en: { copy: "Copy", copying: "Copying\u2026", copied: "Copied", failed: "Could not copy. Select the text and copy it manually." },
|
|
289
|
+
zh: { copy: "\u590D\u5236", copying: "\u6B63\u5728\u590D\u5236\u2026", copied: "\u5DF2\u590D\u5236", failed: "\u590D\u5236\u5931\u8D25\uFF0C\u8BF7\u9009\u4E2D\u6587\u672C\u540E\u624B\u52A8\u590D\u5236\u3002" },
|
|
290
|
+
ko: { copy: "\uBCF5\uC0AC", copying: "\uBCF5\uC0AC \uC911\u2026", copied: "\uBCF5\uC0AC\uB428", failed: "\uBCF5\uC0AC\uD558\uC9C0 \uBABB\uD588\uC2B5\uB2C8\uB2E4. \uD14D\uC2A4\uD2B8\uB97C \uC120\uD0DD\uD558\uC5EC \uC9C1\uC811 \uBCF5\uC0AC\uD574 \uC8FC\uC138\uC694." }
|
|
291
|
+
};
|
|
292
|
+
function getCopyButtonMessages(locale) {
|
|
293
|
+
const language = locale.toLowerCase().split(/[-_]/)[0];
|
|
294
|
+
return copyButtonMessages[language === "zh" || language === "ko" ? language : "en"];
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
// src/ui/copyText.ts
|
|
298
|
+
function isCopyableText(value) {
|
|
299
|
+
return typeof value === "string" && value.trim().length > 0 && value.length <= 4096 && !value.includes("\0");
|
|
300
|
+
}
|
|
301
|
+
async function writeCopyText(value) {
|
|
302
|
+
if (!isCopyableText(value) || typeof document === "undefined") return false;
|
|
303
|
+
if (typeof navigator !== "undefined" && navigator.clipboard?.writeText) {
|
|
304
|
+
try {
|
|
305
|
+
await navigator.clipboard.writeText(value);
|
|
306
|
+
return true;
|
|
307
|
+
} catch {
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
const parent = document.fullscreenElement ?? document.body;
|
|
311
|
+
if (!parent || typeof document.execCommand !== "function") return false;
|
|
312
|
+
const active = document.activeElement;
|
|
313
|
+
const selection = document.getSelection();
|
|
314
|
+
const ranges = selection ? Array.from({ length: selection.rangeCount }, (_, i) => selection.getRangeAt(i).cloneRange()) : [];
|
|
315
|
+
const input = document.createElement("textarea");
|
|
316
|
+
input.value = value;
|
|
317
|
+
input.readOnly = true;
|
|
318
|
+
input.setAttribute("aria-hidden", "true");
|
|
319
|
+
Object.assign(input.style, { position: "fixed", left: "0", top: "0", width: "1px", height: "1px", opacity: "0", fontSize: "16px" });
|
|
320
|
+
parent.appendChild(input);
|
|
321
|
+
try {
|
|
322
|
+
input.focus({ preventScroll: true });
|
|
323
|
+
input.select();
|
|
324
|
+
input.setSelectionRange(0, value.length);
|
|
325
|
+
return document.execCommand("copy");
|
|
326
|
+
} catch {
|
|
327
|
+
return false;
|
|
328
|
+
} finally {
|
|
329
|
+
input.remove();
|
|
330
|
+
if (active instanceof HTMLElement && active.isConnected) active.focus({ preventScroll: true });
|
|
331
|
+
if (selection && ranges.length) {
|
|
332
|
+
selection.removeAllRanges();
|
|
333
|
+
for (const range of ranges) selection.addRange(range);
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
function CopyButton({ value, label, disabled = false, className }) {
|
|
338
|
+
const i18n = useFlapI18n();
|
|
339
|
+
const notify = useFlapNotify();
|
|
340
|
+
const defaults = getCopyButtonMessages(i18n.locale);
|
|
341
|
+
const text = Object.fromEntries(Object.entries(defaults).map(([key, fallback]) => [key, i18n.t(`flap.copy.${key}`, fallback)]));
|
|
342
|
+
const [result, setResult] = React9.useState({ value, status: "idle" });
|
|
343
|
+
const pending = React9.useRef(false);
|
|
344
|
+
const mounted = React9.useRef(false);
|
|
345
|
+
const timer = React9.useRef(void 0);
|
|
346
|
+
React9.useEffect(() => {
|
|
347
|
+
mounted.current = true;
|
|
348
|
+
return () => {
|
|
349
|
+
mounted.current = false;
|
|
350
|
+
clearTimeout(timer.current);
|
|
351
|
+
};
|
|
352
|
+
}, []);
|
|
353
|
+
const status = result.value === value ? result.status : "idle";
|
|
354
|
+
const accessibleLabel = status === "idle" ? label || text.copy : text[status === "failed" ? "failed" : status];
|
|
355
|
+
async function copy(event) {
|
|
356
|
+
event.preventDefault();
|
|
357
|
+
event.stopPropagation();
|
|
358
|
+
if (!(event.nativeEvent instanceof MouseEvent) || !event.nativeEvent.isTrusted || disabled || pending.current || !isCopyableText(value)) return;
|
|
359
|
+
pending.current = true;
|
|
360
|
+
clearTimeout(timer.current);
|
|
361
|
+
setResult({ value, status: "copying" });
|
|
362
|
+
let copied = false;
|
|
363
|
+
try {
|
|
364
|
+
copied = await writeCopyText(value);
|
|
365
|
+
} catch {
|
|
366
|
+
}
|
|
367
|
+
pending.current = false;
|
|
368
|
+
if (!mounted.current) return;
|
|
369
|
+
setResult({ value, status: copied ? "copied" : "failed" });
|
|
370
|
+
try {
|
|
371
|
+
if (copied) notify.success(text.copied);
|
|
372
|
+
else notify.error(text.failed);
|
|
373
|
+
} catch {
|
|
374
|
+
}
|
|
375
|
+
timer.current = setTimeout(() => {
|
|
376
|
+
if (mounted.current) setResult({ value, status: "idle" });
|
|
377
|
+
}, 2e3);
|
|
378
|
+
}
|
|
379
|
+
const Icon = status === "copying" ? Loader2 : status === "copied" ? Check : status === "failed" ? AlertCircle : Copy;
|
|
380
|
+
return /* @__PURE__ */ jsxs(
|
|
381
|
+
Button,
|
|
382
|
+
{
|
|
383
|
+
type: "button",
|
|
384
|
+
variant: "ghost",
|
|
385
|
+
size: label ? "sm" : "icon",
|
|
386
|
+
className: cn(!label && "h-8 w-8", className),
|
|
387
|
+
disabled: disabled || !isCopyableText(value),
|
|
388
|
+
"aria-disabled": disabled || pending.current || !isCopyableText(value),
|
|
389
|
+
"aria-label": accessibleLabel,
|
|
390
|
+
"aria-busy": status === "copying",
|
|
391
|
+
title: accessibleLabel,
|
|
392
|
+
onClick: copy,
|
|
393
|
+
"data-flap-ui": "copy-button",
|
|
394
|
+
"data-flap-copy-state": status,
|
|
395
|
+
children: [
|
|
396
|
+
/* @__PURE__ */ jsx(Icon, { "aria-hidden": "true", className: cn("h-4 w-4 shrink-0", status === "copying" && "animate-spin") }),
|
|
397
|
+
label ? /* @__PURE__ */ jsx("span", { children: status === "copied" ? text.copied : label }) : null,
|
|
398
|
+
/* @__PURE__ */ jsx("span", { className: "sr-only", role: "status", "aria-live": "polite", children: status === "idle" ? "" : accessibleLabel })
|
|
399
|
+
]
|
|
400
|
+
}
|
|
401
|
+
);
|
|
402
|
+
}
|
|
268
403
|
function DataRow({ label, value, detail, className }) {
|
|
269
404
|
return /* @__PURE__ */ jsxs("div", { className: cn("flex items-start justify-between gap-4 border-b border-white/8 py-3 last:border-0", className), children: [
|
|
270
405
|
/* @__PURE__ */ jsx("div", { className: "min-w-0 text-sm text-white/54", children: label }),
|
|
@@ -363,20 +498,20 @@ function WarningIcon({ className }) {
|
|
|
363
498
|
] });
|
|
364
499
|
}
|
|
365
500
|
function ExternalLink2({ url, children, locale, className, copy }) {
|
|
366
|
-
const [open, setOpen] =
|
|
367
|
-
const [acknowledged, setAcknowledged] =
|
|
368
|
-
const [mounted, setMounted] =
|
|
501
|
+
const [open, setOpen] = React9.useState(false);
|
|
502
|
+
const [acknowledged, setAcknowledged] = React9.useState(false);
|
|
503
|
+
const [mounted, setMounted] = React9.useState(false);
|
|
369
504
|
const text = { ...COPY[resolveLocale(locale)], ...copy };
|
|
370
|
-
const safeUrl =
|
|
505
|
+
const safeUrl = React9.useMemo(() => normalizeExternalUrl(url), [url]);
|
|
371
506
|
const canProceed = acknowledged && Boolean(safeUrl);
|
|
372
|
-
|
|
507
|
+
React9.useEffect(() => {
|
|
373
508
|
setMounted(true);
|
|
374
509
|
}, []);
|
|
375
|
-
const close =
|
|
510
|
+
const close = React9.useCallback(() => {
|
|
376
511
|
setOpen(false);
|
|
377
512
|
setAcknowledged(false);
|
|
378
513
|
}, []);
|
|
379
|
-
|
|
514
|
+
React9.useEffect(() => {
|
|
380
515
|
if (!open) return;
|
|
381
516
|
const onKey = (event) => {
|
|
382
517
|
if (event.key === "Escape") close();
|
|
@@ -526,7 +661,7 @@ function ExternalLink2({ url, children, locale, className, copy }) {
|
|
|
526
661
|
) : null
|
|
527
662
|
] });
|
|
528
663
|
}
|
|
529
|
-
var Input =
|
|
664
|
+
var Input = React9.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
|
|
530
665
|
"input",
|
|
531
666
|
{
|
|
532
667
|
"data-flap-ui": "input",
|
|
@@ -540,10 +675,10 @@ var Input = React8.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */
|
|
|
540
675
|
));
|
|
541
676
|
Input.displayName = "Input";
|
|
542
677
|
function IpfsImage({ alt, cid, path, validationPath, className, decoding = "async", loading = "lazy", onError, ...props }) {
|
|
543
|
-
const urls =
|
|
544
|
-
const [urlIndex, setUrlIndex] =
|
|
678
|
+
const urls = React9.useMemo(() => resolveIpfsImageUrls(cid, 56, path), [cid, path]);
|
|
679
|
+
const [urlIndex, setUrlIndex] = React9.useState(0);
|
|
545
680
|
const src = urls[urlIndex];
|
|
546
|
-
|
|
681
|
+
React9.useEffect(() => {
|
|
547
682
|
setUrlIndex(0);
|
|
548
683
|
}, [cid, path]);
|
|
549
684
|
if (!src) return null;
|
|
@@ -577,9 +712,9 @@ function IpfsBackground({ cid, className, imageClassName, overlayClassName, ...p
|
|
|
577
712
|
}
|
|
578
713
|
function NftMetadataImage({ alt, tokenId, fallback = null, className, decoding = "async", loading = "lazy", onError, ...props }) {
|
|
579
714
|
const sdk = useFlapSdk();
|
|
580
|
-
const [metadata, setMetadata] =
|
|
581
|
-
const [state, setState] =
|
|
582
|
-
|
|
715
|
+
const [metadata, setMetadata] = React9.useState(null);
|
|
716
|
+
const [state, setState] = React9.useState("loading");
|
|
717
|
+
React9.useEffect(() => {
|
|
583
718
|
let cancelled = false;
|
|
584
719
|
setState("loading");
|
|
585
720
|
setMetadata(null);
|
|
@@ -1439,38 +1574,38 @@ var clock = (seconds) => `${Math.floor(seconds / 60)}:${Math.floor(seconds % 60)
|
|
|
1439
1574
|
function ConsumerVideoSessionPlayer({ consumer, startClip = 0, label, fallback = null, className, autoPlay = false, muted = false }) {
|
|
1440
1575
|
const sdk = useFlapSdk();
|
|
1441
1576
|
const { chainId } = sdk.context;
|
|
1442
|
-
const readContractRef =
|
|
1577
|
+
const readContractRef = React9.useRef(sdk.readContract);
|
|
1443
1578
|
readContractRef.current = sdk.readContract;
|
|
1444
|
-
const reader =
|
|
1579
|
+
const reader = React9.useMemo(() => createConsumerVideoSessionReader({
|
|
1445
1580
|
context: { chainId },
|
|
1446
1581
|
readContract: (request) => readContractRef.current(request)
|
|
1447
1582
|
}, consumer), [chainId, consumer]);
|
|
1448
|
-
const sessionRef =
|
|
1449
|
-
const controllerRef =
|
|
1450
|
-
const videoRef =
|
|
1451
|
-
const frameRef =
|
|
1452
|
-
const playIntent =
|
|
1453
|
-
const autoPlayRef =
|
|
1583
|
+
const sessionRef = React9.useRef(null);
|
|
1584
|
+
const controllerRef = React9.useRef(null);
|
|
1585
|
+
const videoRef = React9.useRef(null);
|
|
1586
|
+
const frameRef = React9.useRef(null);
|
|
1587
|
+
const playIntent = React9.useRef(autoPlay);
|
|
1588
|
+
const autoPlayRef = React9.useRef(autoPlay);
|
|
1454
1589
|
autoPlayRef.current = autoPlay;
|
|
1455
|
-
const [snapshot, setSnapshot] =
|
|
1456
|
-
const [mediaState, setMediaState] =
|
|
1457
|
-
const [time, setTime] =
|
|
1458
|
-
const [paused, setPaused] =
|
|
1459
|
-
const [isMuted, setIsMuted] =
|
|
1460
|
-
const [volume, setVolume] =
|
|
1461
|
-
|
|
1590
|
+
const [snapshot, setSnapshot] = React9.useState(initialSnapshot);
|
|
1591
|
+
const [mediaState, setMediaState] = React9.useState("loading");
|
|
1592
|
+
const [time, setTime] = React9.useState(0);
|
|
1593
|
+
const [paused, setPaused] = React9.useState(true);
|
|
1594
|
+
const [isMuted, setIsMuted] = React9.useState(muted);
|
|
1595
|
+
const [volume, setVolume] = React9.useState(1);
|
|
1596
|
+
React9.useEffect(() => {
|
|
1462
1597
|
setIsMuted(muted);
|
|
1463
1598
|
}, [muted]);
|
|
1464
|
-
const [buffering, setBuffering] =
|
|
1465
|
-
const [page, setPage] =
|
|
1466
|
-
const [jump, setJump] =
|
|
1599
|
+
const [buffering, setBuffering] = React9.useState(false);
|
|
1600
|
+
const [page, setPage] = React9.useState(0);
|
|
1601
|
+
const [jump, setJump] = React9.useState("");
|
|
1467
1602
|
const position = videoClipPosition(snapshot.clips, time, snapshot.mediaStartPtsMs);
|
|
1468
1603
|
const duration = Number(snapshot.endPtsMs - snapshot.firstPtsMs) / 1e3;
|
|
1469
1604
|
const globalTime = Math.max(0, Math.min(duration, Number(snapshot.mediaStartPtsMs - snapshot.firstPtsMs) / 1e3 + time));
|
|
1470
1605
|
const activeIndex = position?.index ?? snapshot.start;
|
|
1471
1606
|
const strings = videoPlayerMessages[sdk.i18n.locale.split("-")[0]] ?? videoPlayerMessages.en;
|
|
1472
1607
|
const text = (key, params) => sdk.i18n.t(`runtime.video.${key}`, strings[key], params);
|
|
1473
|
-
|
|
1608
|
+
React9.useEffect(() => {
|
|
1474
1609
|
const session = new ConsumerVideoSession(reader, setSnapshot);
|
|
1475
1610
|
sessionRef.current = session;
|
|
1476
1611
|
setSnapshot(initialSnapshot);
|
|
@@ -1487,16 +1622,16 @@ function ConsumerVideoSessionPlayer({ consumer, startClip = 0, label, fallback =
|
|
|
1487
1622
|
sessionRef.current = null;
|
|
1488
1623
|
};
|
|
1489
1624
|
}, [reader, startClip]);
|
|
1490
|
-
|
|
1625
|
+
React9.useEffect(() => {
|
|
1491
1626
|
if (!videoRef.current) return;
|
|
1492
|
-
const controller = new VideoSessionController(videoRef.current, async () => (await import('./mpegts-
|
|
1627
|
+
const controller = new VideoSessionController(videoRef.current, async () => (await import('./mpegts-J2J6JTD7.js')).default, setMediaState);
|
|
1493
1628
|
controllerRef.current = controller;
|
|
1494
1629
|
return () => {
|
|
1495
1630
|
controller.dispose();
|
|
1496
1631
|
controllerRef.current = null;
|
|
1497
1632
|
};
|
|
1498
1633
|
}, []);
|
|
1499
|
-
|
|
1634
|
+
React9.useEffect(() => {
|
|
1500
1635
|
const controller = controllerRef.current;
|
|
1501
1636
|
const session = sessionRef.current;
|
|
1502
1637
|
if (!controller || !session) return;
|
|
@@ -1515,7 +1650,7 @@ function ConsumerVideoSessionPlayer({ consumer, startClip = 0, label, fallback =
|
|
|
1515
1650
|
playIntent: () => playIntent.current
|
|
1516
1651
|
}, snapshot.play, snapshot.resumeAt);
|
|
1517
1652
|
}, [snapshot.sessionId, snapshot.revision, snapshot.state]);
|
|
1518
|
-
|
|
1653
|
+
React9.useEffect(() => {
|
|
1519
1654
|
setPage(Math.floor(activeIndex / VIDEO_PICKER_PAGE_SIZE));
|
|
1520
1655
|
}, [activeIndex]);
|
|
1521
1656
|
const advance = () => {
|
|
@@ -1525,7 +1660,7 @@ function ConsumerVideoSessionPlayer({ consumer, startClip = 0, label, fallback =
|
|
|
1525
1660
|
void sessionRef.current?.advance(current.index);
|
|
1526
1661
|
}
|
|
1527
1662
|
};
|
|
1528
|
-
|
|
1663
|
+
React9.useEffect(() => {
|
|
1529
1664
|
const video = videoRef.current;
|
|
1530
1665
|
const current = videoClipPosition(snapshot.clips, video?.currentTime ?? 0, snapshot.mediaStartPtsMs);
|
|
1531
1666
|
if (video && current && (current.index >= snapshot.start + snapshot.clips.length - 2 || video.ended)) void sessionRef.current?.advance(current.index);
|
|
@@ -1749,13 +1884,13 @@ function VideoSessionPlayer(props) {
|
|
|
1749
1884
|
return "consumer" in props && props.consumer !== void 0 ? /* @__PURE__ */ jsx(ConsumerVideoSessionPlayer, { ...props }) : /* @__PURE__ */ jsx(VideoClipSessionPlayer, { ...props });
|
|
1750
1885
|
}
|
|
1751
1886
|
async function loadMpegts() {
|
|
1752
|
-
return (await import('./mpegts-
|
|
1887
|
+
return (await import('./mpegts-J2J6JTD7.js')).default;
|
|
1753
1888
|
}
|
|
1754
1889
|
function VideoClipSessionPlayer({ clips, label, fallback = null, className, autoPlay = false, muted = false }) {
|
|
1755
|
-
const videoRef =
|
|
1756
|
-
const controllerRef =
|
|
1757
|
-
const [state, setState] =
|
|
1758
|
-
|
|
1890
|
+
const videoRef = React9.useRef(null);
|
|
1891
|
+
const controllerRef = React9.useRef(null);
|
|
1892
|
+
const [state, setState] = React9.useState("loading");
|
|
1893
|
+
React9.useEffect(() => {
|
|
1759
1894
|
if (!videoRef.current) return;
|
|
1760
1895
|
const controller = new VideoSessionController(videoRef.current, loadMpegts, setState);
|
|
1761
1896
|
controllerRef.current = controller;
|
|
@@ -1764,7 +1899,7 @@ function VideoClipSessionPlayer({ clips, label, fallback = null, className, auto
|
|
|
1764
1899
|
controllerRef.current = null;
|
|
1765
1900
|
};
|
|
1766
1901
|
}, []);
|
|
1767
|
-
|
|
1902
|
+
React9.useEffect(() => {
|
|
1768
1903
|
void controllerRef.current?.update(clips, autoPlay);
|
|
1769
1904
|
}, [clips, autoPlay]);
|
|
1770
1905
|
const showVideo = state === "loading" || state === "ready";
|
|
@@ -1787,6 +1922,6 @@ function VideoClipSessionPlayer({ clips, label, fallback = null, className, auto
|
|
|
1787
1922
|
] });
|
|
1788
1923
|
}
|
|
1789
1924
|
|
|
1790
|
-
export { AddressLink, Alert, BinanceImage, Button, Card, CardContent, CardDescription, CardHeader, CardTitle, Countdown, DataRow, DetailTile, ExternalLink2 as ExternalLink, Input, IpfsBackground, IpfsImage, Metric, NftMetadataImage, ReviewedFrame, RuntimeContext, StatusBadge, TxButton, VaultBanner, VideoSessionPlayer, VideoSessionReadError, buttonVariants, createConsumerVideoSessionReader, readVideoSessionLength, readVideoSessionSlice, useFlapI18n, useFlapNotify, useFlapSdk, useVaultContext };
|
|
1791
|
-
//# sourceMappingURL=chunk-
|
|
1792
|
-
//# sourceMappingURL=chunk-
|
|
1925
|
+
export { AddressLink, Alert, BinanceImage, Button, Card, CardContent, CardDescription, CardHeader, CardTitle, CopyButton, Countdown, DataRow, DetailTile, ExternalLink2 as ExternalLink, Input, IpfsBackground, IpfsImage, Metric, MiniAppContext, NftMetadataImage, ReviewedFrame, RuntimeContext, StatusBadge, TxButton, VaultBanner, VideoSessionPlayer, VideoSessionReadError, buttonVariants, createConsumerVideoSessionReader, readVideoSessionLength, readVideoSessionSlice, useFlapI18n, useFlapNotify, useFlapSdk, useVaultContext };
|
|
1926
|
+
//# sourceMappingURL=chunk-JVOFLTLD.js.map
|
|
1927
|
+
//# sourceMappingURL=chunk-JVOFLTLD.js.map
|