@flapsdk/vault-runtime 0.1.37 → 0.1.39-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.
Files changed (41) hide show
  1. package/README.md +11 -2
  2. package/{chunk-3X2K7YYU.js → chunk-3MVBV65H.js} +215 -74
  3. package/chunk-3MVBV65H.js.map +1 -0
  4. package/{chunk-22KTLOYH.js → chunk-FWYBGHBX.js} +17 -4
  5. package/chunk-FWYBGHBX.js.map +1 -0
  6. package/chunk-GY7YY67I.js +78 -0
  7. package/chunk-GY7YY67I.js.map +1 -0
  8. package/{chunk-SDCB3RJS.js → chunk-JJJSK6HF.js} +3 -3
  9. package/{chunk-SDCB3RJS.js.map → chunk-JJJSK6HF.js.map} +1 -1
  10. package/{chunk-HYBZWS6U.js → chunk-JW4MM24W.js} +90 -252
  11. package/chunk-JW4MM24W.js.map +1 -0
  12. package/chunk-QS475ZC7.js +583 -0
  13. package/chunk-QS475ZC7.js.map +1 -0
  14. package/{chunk-SRZFHGSO.js → chunk-WN4MIMCY.js} +3 -3
  15. package/{chunk-SRZFHGSO.js.map → chunk-WN4MIMCY.js.map} +1 -1
  16. package/host-client.d.mts +9 -2
  17. package/host-client.js +5 -6
  18. package/host.d.mts +5 -5
  19. package/host.js +7 -7
  20. package/{hostRuntimeConfig-DM6JjbeO.d.mts → hostRuntimeConfig-CKjug1-9.d.mts} +1 -1
  21. package/package.json +4 -3
  22. package/runtime-contract.json +5 -1
  23. package/sdk.d.mts +42 -4
  24. package/sdk.js +41 -9
  25. package/sdk.js.map +1 -1
  26. package/server.d.mts +3 -3
  27. package/server.js +4 -5
  28. package/server.js.map +1 -1
  29. package/{txError-vvvBIsa-.d.mts → txError-BTuW38It.d.mts} +15 -2
  30. package/{types-cyAEoeXa.d.mts → types-BolUPLIE.d.mts} +101 -2
  31. package/ui.d.mts +13 -2
  32. package/ui.js +2 -3
  33. package/chunk-22KTLOYH.js.map +0 -1
  34. package/chunk-27VBKY3J.js +0 -36
  35. package/chunk-27VBKY3J.js.map +0 -1
  36. package/chunk-3X2K7YYU.js.map +0 -1
  37. package/chunk-AGLB72HK.js +0 -61
  38. package/chunk-AGLB72HK.js.map +0 -1
  39. package/chunk-FUOBTZMQ.js +0 -47
  40. package/chunk-FUOBTZMQ.js.map +0 -1
  41. package/chunk-HYBZWS6U.js.map +0 -1
package/README.md CHANGED
@@ -6,7 +6,7 @@ Generated from `flap-vault-ui-template`.
6
6
 
7
7
  This package is the shared runtime surface that local preview, Artifact Workbench, and `flap.sh` should agree on.
8
8
 
9
- Package version: `0.1.37`. Source commit: `ad40bab7dfc976d20dd82050aeec17fef18a39b3`.
9
+ Package version: `0.1.39-next.0`. Source commit: `48bb8c2d7a6ef14278915d61b08b3c00b55d5fd6`.
10
10
 
11
11
  ## Exports
12
12
 
@@ -17,6 +17,13 @@ Package version: `0.1.37`. Source commit: `ad40bab7dfc976d20dd82050aeec17fef18a3
17
17
 
18
18
  See `runtime-contract.json` for the machine-readable subpath contract.
19
19
 
20
+ ## Shared Vault UI and Mini App v2
21
+
22
+ The preview channel includes standalone App wallet operations through
23
+ `useFlapSdk({ chainId })` and the host-owned `CopyButton` from `./ui`.
24
+ Vault UI keeps `useFlapSdk()` and its token-bound context. Both use this one
25
+ package; existing token-bound Mini Apps remain compatible.
26
+
20
27
  ## Dynamic IPFS content
21
28
 
22
29
  Stable runtime `0.1.37` introduces `sdk.readIpfsText(cid, path?)`, which returns
@@ -27,7 +34,9 @@ The SDK exports `IPFS_CONTENT_VERSION = 1`; the runtime contract advertises
27
34
 
28
35
  Vault source keeps the `@/src/sdk` and `@/src/ui` authoring aliases. Obtain
29
36
  `sdk` with `useFlapSdk()`, then call the reader from an async effect or event
30
- handler. Import `IpfsText` and `IpfsImage` from the UI alias for rendering:
37
+ handler. Independent Mini App v2 uses `useFlapSdk({ chainId: 56 })`;
38
+ its chain SDK exposes the same reader and reviewed `readFsi` API.
39
+ Import `IpfsText` and `IpfsImage` from the UI alias for rendering:
31
40
 
32
41
  ```tsx
33
42
  const body = await sdk.readIpfsText(textCid);
@@ -1,9 +1,8 @@
1
1
  import { shortenAddress, isValidAddress, ZERO_ADDRESS } from './chunk-B4WKI3EW.js';
2
- import { isIpfsImageCid, resolveIpfsImageUrls, resolveIpfsImageUrl } from './chunk-27VBKY3J.js';
3
- import { getTaxVaultHostChainConfig } from './chunk-FUOBTZMQ.js';
4
- import * as React9 from 'react';
2
+ import { isIpfsImageCid, resolveIpfsImageUrls, getTaxVaultHostChainConfig, resolveIpfsImageUrl } from './chunk-GY7YY67I.js';
3
+ import * as React10 from 'react';
5
4
  import { createContext, useContext, useState, useEffect, useMemo, createElement } from 'react';
6
- import { Loader2, ExternalLink, AlertTriangle, CheckCircle2, Info, X, ShieldCheck, Play, Pause, VolumeX, Volume2, Maximize, SkipBack, ChevronLeft, ChevronRight, SkipForward } from 'lucide-react';
5
+ import { Loader2, ExternalLink, AlertTriangle, CheckCircle2, Info, Check, AlertCircle, Copy, X, ShieldCheck, Play, Pause, VolumeX, Volume2, Maximize, SkipBack, ChevronLeft, ChevronRight, SkipForward } from 'lucide-react';
7
6
  import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
8
7
  import { clsx } from 'clsx';
9
8
  import { twMerge } from 'tailwind-merge';
@@ -11,6 +10,45 @@ import { Slot } from '@radix-ui/react-slot';
11
10
  import { cva } from 'class-variance-authority';
12
11
  import { createPortal } from 'react-dom';
13
12
 
13
+ var RuntimeContext = createContext(null);
14
+ var MiniAppContext = createContext(null);
15
+ function useFlapSdk(options) {
16
+ const vault = useContext(RuntimeContext);
17
+ const app = useContext(MiniAppContext);
18
+ if (options) {
19
+ const runtime = app ?? vault;
20
+ if (!runtime) throw new Error("useFlapSdk requires a Flap runtime provider.");
21
+ return runtime.forChain(options.chainId);
22
+ }
23
+ if (vault && !app) return vault;
24
+ if (app) throw new Error("Independent Apps must select a network: useFlapSdk({ chainId }).");
25
+ throw new Error("useFlapSdk requires a Flap runtime provider.");
26
+ }
27
+ function useVaultContext() {
28
+ return useFlapSdk().context;
29
+ }
30
+ function useFlapI18n() {
31
+ const vault = useContext(RuntimeContext);
32
+ const app = useContext(MiniAppContext);
33
+ const runtime = app ?? vault;
34
+ if (!runtime) throw new Error("A Flap runtime provider is required.");
35
+ return runtime.i18n;
36
+ }
37
+ function useFlapNotify() {
38
+ const vault = useContext(RuntimeContext);
39
+ const app = useContext(MiniAppContext);
40
+ const runtime = app ?? vault;
41
+ if (!runtime) throw new Error("A Flap runtime provider is required.");
42
+ return runtime.notify;
43
+ }
44
+ function useFlapIpfsTextReader() {
45
+ const vault = useContext(RuntimeContext);
46
+ const app = useContext(MiniAppContext);
47
+ const runtime = app ?? vault;
48
+ if (!runtime) throw new Error("IPFS content requires a Flap runtime provider.");
49
+ return runtime.readIpfsText;
50
+ }
51
+
14
52
  // src/sdk/videoSession.ts
15
53
  var videoProviderAbi = [
16
54
  { type: "function", name: "getVideoSessionLength", stateMutability: "view", inputs: [{ name: "user", type: "address" }], outputs: [{ type: "uint256" }] },
@@ -66,21 +104,6 @@ async function readVideoSessionSlice(sdk, consumer, start, count) {
66
104
  function createConsumerVideoSessionReader(sdk, consumer) {
67
105
  return { readLength: () => readVideoSessionLength(sdk, consumer), readSlice: (start, count) => readVideoSessionSlice(sdk, consumer, start, count) };
68
106
  }
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
107
  function AddressLink({ address, explorerBaseUrl, label }) {
85
108
  if (!address) return /* @__PURE__ */ jsx("span", { children: "-" });
86
109
  const href = explorerBaseUrl ? `${explorerBaseUrl.replace(/\/$/, "")}/address/${address}` : void 0;
@@ -136,7 +159,7 @@ var buttonVariants = cva(
136
159
  }
137
160
  }
138
161
  );
139
- var Button = React9.forwardRef(
162
+ var Button = React10.forwardRef(
140
163
  ({ className, variant, size, asChild = false, loading = false, disabled, children, ...props }, ref) => {
141
164
  const Comp = asChild ? Slot : "button";
142
165
  if (asChild) {
@@ -178,8 +201,8 @@ function normalizeBinanceImageUrl(value) {
178
201
  }
179
202
  }
180
203
  function BinanceImage({ alt, src, fallback = null, className, onError, ...props }) {
181
- const safeSrc = React9.useMemo(() => normalizeBinanceImageUrl(src), [src]);
182
- const [failedSrc, setFailedSrc] = React9.useState(null);
204
+ const safeSrc = React10.useMemo(() => normalizeBinanceImageUrl(src), [src]);
205
+ const [failedSrc, setFailedSrc] = React10.useState(null);
183
206
  const {
184
207
  alt: _unsafeAlt,
185
208
  decoding: _unsafeDecoding,
@@ -213,7 +236,7 @@ function BinanceImage({ alt, src, fallback = null, className, onError, ...props
213
236
  )
214
237
  );
215
238
  }
216
- var Card = React9.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
239
+ var Card = React10.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
217
240
  "div",
218
241
  {
219
242
  "data-flap-ui": "card",
@@ -226,19 +249,19 @@ var Card = React9.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ j
226
249
  }
227
250
  ));
228
251
  Card.displayName = "Card";
229
- var CardHeader = React9.forwardRef(
252
+ var CardHeader = React10.forwardRef(
230
253
  ({ 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
254
  );
232
255
  CardHeader.displayName = "CardHeader";
233
- var CardTitle = React9.forwardRef(
256
+ var CardTitle = React10.forwardRef(
234
257
  ({ 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
258
  );
236
259
  CardTitle.displayName = "CardTitle";
237
- var CardDescription = React9.forwardRef(
260
+ var CardDescription = React10.forwardRef(
238
261
  ({ className, ...props }, ref) => /* @__PURE__ */ jsx("p", { "data-flap-ui": "card-description", ref, className: cn("text-sm leading-6 text-[#84888C]", className), ...props })
239
262
  );
240
263
  CardDescription.displayName = "CardDescription";
241
- var CardContent = React9.forwardRef(
264
+ var CardContent = React10.forwardRef(
242
265
  ({ 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
266
  );
244
267
  CardContent.displayName = "CardContent";
@@ -265,6 +288,124 @@ function Countdown({ targetTimeMs, fallback = "-" }) {
265
288
  }, [fallback, now, targetTimeMs]);
266
289
  return /* @__PURE__ */ jsx("span", { children: text });
267
290
  }
291
+
292
+ // src/ui/copyButtonMessages.ts
293
+ var copyButtonMessages = {
294
+ en: { copy: "Copy", copying: "Copying\u2026", copied: "Copied", failed: "Could not copy. Select the text and copy it manually." },
295
+ 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" },
296
+ 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." }
297
+ };
298
+ function getCopyButtonMessages(locale) {
299
+ const language = locale.toLowerCase().split(/[-_]/)[0];
300
+ return copyButtonMessages[language === "zh" || language === "ko" ? language : "en"];
301
+ }
302
+
303
+ // src/ui/copyText.ts
304
+ function isCopyableText(value) {
305
+ return typeof value === "string" && value.trim().length > 0 && value.length <= 4096 && !value.includes("\0");
306
+ }
307
+ async function writeCopyText(value) {
308
+ if (!isCopyableText(value) || typeof document === "undefined") return false;
309
+ if (typeof navigator !== "undefined" && navigator.clipboard?.writeText) {
310
+ try {
311
+ await navigator.clipboard.writeText(value);
312
+ return true;
313
+ } catch {
314
+ }
315
+ }
316
+ const parent = document.fullscreenElement ?? document.body;
317
+ if (!parent || typeof document.execCommand !== "function") return false;
318
+ const active = document.activeElement;
319
+ const selection = document.getSelection();
320
+ const ranges = selection ? Array.from({ length: selection.rangeCount }, (_, i) => selection.getRangeAt(i).cloneRange()) : [];
321
+ const input = document.createElement("textarea");
322
+ input.value = value;
323
+ input.readOnly = true;
324
+ input.setAttribute("aria-hidden", "true");
325
+ Object.assign(input.style, { position: "fixed", left: "0", top: "0", width: "1px", height: "1px", opacity: "0", fontSize: "16px" });
326
+ parent.appendChild(input);
327
+ try {
328
+ input.focus({ preventScroll: true });
329
+ input.select();
330
+ input.setSelectionRange(0, value.length);
331
+ return document.execCommand("copy");
332
+ } catch {
333
+ return false;
334
+ } finally {
335
+ input.remove();
336
+ if (active instanceof HTMLElement && active.isConnected) active.focus({ preventScroll: true });
337
+ if (selection && ranges.length) {
338
+ selection.removeAllRanges();
339
+ for (const range of ranges) selection.addRange(range);
340
+ }
341
+ }
342
+ }
343
+ function CopyButton({ value, label, disabled = false, className }) {
344
+ const i18n = useFlapI18n();
345
+ const notify = useFlapNotify();
346
+ const defaults = getCopyButtonMessages(i18n.locale);
347
+ const text = Object.fromEntries(Object.entries(defaults).map(([key, fallback]) => [key, i18n.t(`flap.copy.${key}`, fallback)]));
348
+ const [result, setResult] = React10.useState({ value, status: "idle" });
349
+ const pending = React10.useRef(false);
350
+ const mounted = React10.useRef(false);
351
+ const timer = React10.useRef(void 0);
352
+ React10.useEffect(() => {
353
+ mounted.current = true;
354
+ return () => {
355
+ mounted.current = false;
356
+ clearTimeout(timer.current);
357
+ };
358
+ }, []);
359
+ const status = result.value === value ? result.status : "idle";
360
+ const accessibleLabel = status === "idle" ? label || text.copy : text[status === "failed" ? "failed" : status];
361
+ async function copy(event) {
362
+ event.preventDefault();
363
+ event.stopPropagation();
364
+ if (!(event.nativeEvent instanceof MouseEvent) || !event.nativeEvent.isTrusted || disabled || pending.current || !isCopyableText(value)) return;
365
+ pending.current = true;
366
+ clearTimeout(timer.current);
367
+ setResult({ value, status: "copying" });
368
+ let copied = false;
369
+ try {
370
+ copied = await writeCopyText(value);
371
+ } catch {
372
+ }
373
+ pending.current = false;
374
+ if (!mounted.current) return;
375
+ setResult({ value, status: copied ? "copied" : "failed" });
376
+ try {
377
+ if (copied) notify.success(text.copied);
378
+ else notify.error(text.failed);
379
+ } catch {
380
+ }
381
+ timer.current = setTimeout(() => {
382
+ if (mounted.current) setResult({ value, status: "idle" });
383
+ }, 2e3);
384
+ }
385
+ const Icon = status === "copying" ? Loader2 : status === "copied" ? Check : status === "failed" ? AlertCircle : Copy;
386
+ return /* @__PURE__ */ jsxs(
387
+ Button,
388
+ {
389
+ type: "button",
390
+ variant: "ghost",
391
+ size: label ? "sm" : "icon",
392
+ className: cn(!label && "h-8 w-8", className),
393
+ disabled: disabled || !isCopyableText(value),
394
+ "aria-disabled": disabled || pending.current || !isCopyableText(value),
395
+ "aria-label": accessibleLabel,
396
+ "aria-busy": status === "copying",
397
+ title: accessibleLabel,
398
+ onClick: copy,
399
+ "data-flap-ui": "copy-button",
400
+ "data-flap-copy-state": status,
401
+ children: [
402
+ /* @__PURE__ */ jsx(Icon, { "aria-hidden": "true", className: cn("h-4 w-4 shrink-0", status === "copying" && "animate-spin") }),
403
+ label ? /* @__PURE__ */ jsx("span", { children: status === "copied" ? text.copied : label }) : null,
404
+ /* @__PURE__ */ jsx("span", { className: "sr-only", role: "status", "aria-live": "polite", children: status === "idle" ? "" : accessibleLabel })
405
+ ]
406
+ }
407
+ );
408
+ }
268
409
  function DataRow({ label, value, detail, className }) {
269
410
  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
411
  /* @__PURE__ */ jsx("div", { className: "min-w-0 text-sm text-white/54", children: label }),
@@ -363,20 +504,20 @@ function WarningIcon({ className }) {
363
504
  ] });
364
505
  }
365
506
  function ExternalLink2({ url, children, locale, className, copy }) {
366
- const [open, setOpen] = React9.useState(false);
367
- const [acknowledged, setAcknowledged] = React9.useState(false);
368
- const [mounted, setMounted] = React9.useState(false);
507
+ const [open, setOpen] = React10.useState(false);
508
+ const [acknowledged, setAcknowledged] = React10.useState(false);
509
+ const [mounted, setMounted] = React10.useState(false);
369
510
  const text = { ...COPY[resolveLocale(locale)], ...copy };
370
- const safeUrl = React9.useMemo(() => normalizeExternalUrl(url), [url]);
511
+ const safeUrl = React10.useMemo(() => normalizeExternalUrl(url), [url]);
371
512
  const canProceed = acknowledged && Boolean(safeUrl);
372
- React9.useEffect(() => {
513
+ React10.useEffect(() => {
373
514
  setMounted(true);
374
515
  }, []);
375
- const close = React9.useCallback(() => {
516
+ const close = React10.useCallback(() => {
376
517
  setOpen(false);
377
518
  setAcknowledged(false);
378
519
  }, []);
379
- React9.useEffect(() => {
520
+ React10.useEffect(() => {
380
521
  if (!open) return;
381
522
  const onKey = (event) => {
382
523
  if (event.key === "Escape") close();
@@ -526,7 +667,7 @@ function ExternalLink2({ url, children, locale, className, copy }) {
526
667
  ) : null
527
668
  ] });
528
669
  }
529
- var Input = React9.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
670
+ var Input = React10.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
530
671
  "input",
531
672
  {
532
673
  "data-flap-ui": "input",
@@ -540,9 +681,9 @@ var Input = React9.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */
540
681
  ));
541
682
  Input.displayName = "Input";
542
683
  function IpfsImage({ alt, cid, path, validationPath, className, decoding = "async", loading = "lazy", onError, ...props }) {
543
- const urls = React9.useMemo(() => resolveIpfsImageUrls(cid, 56, path), [cid, path]);
684
+ const urls = React10.useMemo(() => resolveIpfsImageUrls(cid, 56, path), [cid, path]);
544
685
  const resourceKey = urls.join("\n");
545
- const [fallbackState, setFallbackState] = React9.useState({ key: resourceKey, index: 0 });
686
+ const [fallbackState, setFallbackState] = React10.useState({ key: resourceKey, index: 0 });
546
687
  const urlIndex = fallbackState.key === resourceKey ? fallbackState.index : 0;
547
688
  const src = urls[urlIndex];
548
689
  const { src: ignoredSrc, srcSet: ignoredSrcSet, dangerouslySetInnerHTML: ignoredHtml, ...safeProps } = props;
@@ -578,10 +719,10 @@ function IpfsBackground({ cid, className, imageClassName, overlayClassName, ...p
578
719
  ] });
579
720
  }
580
721
  function IpfsText({ cid, path, fallback = null, className, ...props }) {
581
- const { readIpfsText } = useFlapSdk();
722
+ const readIpfsText = useFlapIpfsTextReader();
582
723
  const key = JSON.stringify([typeof cid === "string" ? cid : null, typeof path === "string" ? path : null]);
583
- const [result, setResult] = React9.useState();
584
- React9.useEffect(() => {
724
+ const [result, setResult] = React10.useState();
725
+ React10.useEffect(() => {
585
726
  let cancelled = false;
586
727
  readIpfsText(cid, path).then(
587
728
  (text) => {
@@ -601,9 +742,9 @@ function IpfsText({ cid, path, fallback = null, className, ...props }) {
601
742
  }
602
743
  function NftMetadataImage({ alt, tokenId, fallback = null, className, decoding = "async", loading = "lazy", onError, ...props }) {
603
744
  const sdk = useFlapSdk();
604
- const [metadata, setMetadata] = React9.useState(null);
605
- const [state, setState] = React9.useState("loading");
606
- React9.useEffect(() => {
745
+ const [metadata, setMetadata] = React10.useState(null);
746
+ const [state, setState] = React10.useState("loading");
747
+ React10.useEffect(() => {
607
748
  let cancelled = false;
608
749
  setState("loading");
609
750
  setMetadata(null);
@@ -1463,38 +1604,38 @@ var clock = (seconds) => `${Math.floor(seconds / 60)}:${Math.floor(seconds % 60)
1463
1604
  function ConsumerVideoSessionPlayer({ consumer, startClip = 0, label, fallback = null, className, autoPlay = false, muted = false }) {
1464
1605
  const sdk = useFlapSdk();
1465
1606
  const { chainId } = sdk.context;
1466
- const readContractRef = React9.useRef(sdk.readContract);
1607
+ const readContractRef = React10.useRef(sdk.readContract);
1467
1608
  readContractRef.current = sdk.readContract;
1468
- const reader = React9.useMemo(() => createConsumerVideoSessionReader({
1609
+ const reader = React10.useMemo(() => createConsumerVideoSessionReader({
1469
1610
  context: { chainId },
1470
1611
  readContract: (request) => readContractRef.current(request)
1471
1612
  }, consumer), [chainId, consumer]);
1472
- const sessionRef = React9.useRef(null);
1473
- const controllerRef = React9.useRef(null);
1474
- const videoRef = React9.useRef(null);
1475
- const frameRef = React9.useRef(null);
1476
- const playIntent = React9.useRef(autoPlay);
1477
- const autoPlayRef = React9.useRef(autoPlay);
1613
+ const sessionRef = React10.useRef(null);
1614
+ const controllerRef = React10.useRef(null);
1615
+ const videoRef = React10.useRef(null);
1616
+ const frameRef = React10.useRef(null);
1617
+ const playIntent = React10.useRef(autoPlay);
1618
+ const autoPlayRef = React10.useRef(autoPlay);
1478
1619
  autoPlayRef.current = autoPlay;
1479
- const [snapshot, setSnapshot] = React9.useState(initialSnapshot);
1480
- const [mediaState, setMediaState] = React9.useState("loading");
1481
- const [time, setTime] = React9.useState(0);
1482
- const [paused, setPaused] = React9.useState(true);
1483
- const [isMuted, setIsMuted] = React9.useState(muted);
1484
- const [volume, setVolume] = React9.useState(1);
1485
- React9.useEffect(() => {
1620
+ const [snapshot, setSnapshot] = React10.useState(initialSnapshot);
1621
+ const [mediaState, setMediaState] = React10.useState("loading");
1622
+ const [time, setTime] = React10.useState(0);
1623
+ const [paused, setPaused] = React10.useState(true);
1624
+ const [isMuted, setIsMuted] = React10.useState(muted);
1625
+ const [volume, setVolume] = React10.useState(1);
1626
+ React10.useEffect(() => {
1486
1627
  setIsMuted(muted);
1487
1628
  }, [muted]);
1488
- const [buffering, setBuffering] = React9.useState(false);
1489
- const [page, setPage] = React9.useState(0);
1490
- const [jump, setJump] = React9.useState("");
1629
+ const [buffering, setBuffering] = React10.useState(false);
1630
+ const [page, setPage] = React10.useState(0);
1631
+ const [jump, setJump] = React10.useState("");
1491
1632
  const position = videoClipPosition(snapshot.clips, time, snapshot.mediaStartPtsMs);
1492
1633
  const duration = Number(snapshot.endPtsMs - snapshot.firstPtsMs) / 1e3;
1493
1634
  const globalTime = Math.max(0, Math.min(duration, Number(snapshot.mediaStartPtsMs - snapshot.firstPtsMs) / 1e3 + time));
1494
1635
  const activeIndex = position?.index ?? snapshot.start;
1495
1636
  const strings = videoPlayerMessages[sdk.i18n.locale.split("-")[0]] ?? videoPlayerMessages.en;
1496
1637
  const text = (key, params) => sdk.i18n.t(`runtime.video.${key}`, strings[key], params);
1497
- React9.useEffect(() => {
1638
+ React10.useEffect(() => {
1498
1639
  const session = new ConsumerVideoSession(reader, setSnapshot);
1499
1640
  sessionRef.current = session;
1500
1641
  setSnapshot(initialSnapshot);
@@ -1511,7 +1652,7 @@ function ConsumerVideoSessionPlayer({ consumer, startClip = 0, label, fallback =
1511
1652
  sessionRef.current = null;
1512
1653
  };
1513
1654
  }, [reader, startClip]);
1514
- React9.useEffect(() => {
1655
+ React10.useEffect(() => {
1515
1656
  if (!videoRef.current) return;
1516
1657
  const controller = new VideoSessionController(videoRef.current, async () => (await import('./mpegts-536UQHCG.js')).default, setMediaState);
1517
1658
  controllerRef.current = controller;
@@ -1520,7 +1661,7 @@ function ConsumerVideoSessionPlayer({ consumer, startClip = 0, label, fallback =
1520
1661
  controllerRef.current = null;
1521
1662
  };
1522
1663
  }, []);
1523
- React9.useEffect(() => {
1664
+ React10.useEffect(() => {
1524
1665
  const controller = controllerRef.current;
1525
1666
  const session = sessionRef.current;
1526
1667
  if (!controller || !session) return;
@@ -1539,7 +1680,7 @@ function ConsumerVideoSessionPlayer({ consumer, startClip = 0, label, fallback =
1539
1680
  playIntent: () => playIntent.current
1540
1681
  }, snapshot.play, snapshot.resumeAt);
1541
1682
  }, [snapshot.sessionId, snapshot.revision, snapshot.state]);
1542
- React9.useEffect(() => {
1683
+ React10.useEffect(() => {
1543
1684
  setPage(Math.floor(activeIndex / VIDEO_PICKER_PAGE_SIZE));
1544
1685
  }, [activeIndex]);
1545
1686
  const advance = () => {
@@ -1549,7 +1690,7 @@ function ConsumerVideoSessionPlayer({ consumer, startClip = 0, label, fallback =
1549
1690
  void sessionRef.current?.advance(current.index);
1550
1691
  }
1551
1692
  };
1552
- React9.useEffect(() => {
1693
+ React10.useEffect(() => {
1553
1694
  const video = videoRef.current;
1554
1695
  const current = videoClipPosition(snapshot.clips, video?.currentTime ?? 0, snapshot.mediaStartPtsMs);
1555
1696
  if (video && current && (current.index >= snapshot.start + snapshot.clips.length - 2 || video.ended)) void sessionRef.current?.advance(current.index);
@@ -1776,10 +1917,10 @@ async function loadMpegts() {
1776
1917
  return (await import('./mpegts-536UQHCG.js')).default;
1777
1918
  }
1778
1919
  function VideoClipSessionPlayer({ clips, label, fallback = null, className, autoPlay = false, muted = false }) {
1779
- const videoRef = React9.useRef(null);
1780
- const controllerRef = React9.useRef(null);
1781
- const [state, setState] = React9.useState("loading");
1782
- React9.useEffect(() => {
1920
+ const videoRef = React10.useRef(null);
1921
+ const controllerRef = React10.useRef(null);
1922
+ const [state, setState] = React10.useState("loading");
1923
+ React10.useEffect(() => {
1783
1924
  if (!videoRef.current) return;
1784
1925
  const controller = new VideoSessionController(videoRef.current, loadMpegts, setState);
1785
1926
  controllerRef.current = controller;
@@ -1788,7 +1929,7 @@ function VideoClipSessionPlayer({ clips, label, fallback = null, className, auto
1788
1929
  controllerRef.current = null;
1789
1930
  };
1790
1931
  }, []);
1791
- React9.useEffect(() => {
1932
+ React10.useEffect(() => {
1792
1933
  void controllerRef.current?.update(clips, autoPlay);
1793
1934
  }, [clips, autoPlay]);
1794
1935
  const showVideo = state === "loading" || state === "ready";
@@ -1811,6 +1952,6 @@ function VideoClipSessionPlayer({ clips, label, fallback = null, className, auto
1811
1952
  ] });
1812
1953
  }
1813
1954
 
1814
- export { AddressLink, Alert, BinanceImage, Button, Card, CardContent, CardDescription, CardHeader, CardTitle, Countdown, DataRow, DetailTile, ExternalLink2 as ExternalLink, Input, IpfsBackground, IpfsImage, IpfsText, Metric, NftMetadataImage, ReviewedFrame, RuntimeContext, StatusBadge, TxButton, VaultBanner, VideoSessionPlayer, VideoSessionReadError, buttonVariants, createConsumerVideoSessionReader, readVideoSessionLength, readVideoSessionSlice, useFlapI18n, useFlapNotify, useFlapSdk, useVaultContext };
1815
- //# sourceMappingURL=chunk-3X2K7YYU.js.map
1816
- //# sourceMappingURL=chunk-3X2K7YYU.js.map
1955
+ export { AddressLink, Alert, BinanceImage, Button, Card, CardContent, CardDescription, CardHeader, CardTitle, CopyButton, Countdown, DataRow, DetailTile, ExternalLink2 as ExternalLink, Input, IpfsBackground, IpfsImage, IpfsText, Metric, MiniAppContext, NftMetadataImage, ReviewedFrame, RuntimeContext, StatusBadge, TxButton, VaultBanner, VideoSessionPlayer, VideoSessionReadError, buttonVariants, createConsumerVideoSessionReader, readVideoSessionLength, readVideoSessionSlice, useFlapI18n, useFlapNotify, useFlapSdk, useVaultContext };
1956
+ //# sourceMappingURL=chunk-3MVBV65H.js.map
1957
+ //# sourceMappingURL=chunk-3MVBV65H.js.map