@flapsdk/vault-runtime 0.1.37 → 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/README.md +0 -45
- package/{chunk-HYBZWS6U.js → chunk-44P2NRRZ.js} +94 -267
- 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-3X2K7YYU.js → chunk-JVOFLTLD.js} +165 -54
- package/chunk-JVOFLTLD.js.map +1 -0
- package/{chunk-SRZFHGSO.js → chunk-PU7VEZWA.js} +3 -3
- package/{chunk-SRZFHGSO.js.map → chunk-PU7VEZWA.js.map} +1 -1
- package/{chunk-27VBKY3J.js → chunk-SAG36LUR.js} +3 -4
- package/chunk-SAG36LUR.js.map +1 -0
- package/host-client.d.mts +9 -2
- package/host-client.js +5 -5
- package/host.d.mts +5 -5
- package/host.js +4 -4
- package/{hostRuntimeConfig-DM6JjbeO.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 +6 -3
- package/sdk.d.mts +40 -6
- package/sdk.js +40 -9
- package/sdk.js.map +1 -1
- package/server.d.mts +3 -3
- package/server.js +2 -2
- package/{txError-vvvBIsa-.d.mts → txError-OBuRV8xN.d.mts} +15 -2
- package/{types-cyAEoeXa.d.mts → types-DUZWZ3mC.d.mts} +98 -6
- package/ui.d.mts +16 -13
- package/ui.js +2 -2
- package/chunk-22KTLOYH.js.map +0 -1
- package/chunk-27VBKY3J.js.map +0 -1
- package/chunk-3X2K7YYU.js.map +0 -1
- package/chunk-AGLB72HK.js +0 -61
- package/chunk-AGLB72HK.js.map +0 -1
- package/chunk-HYBZWS6U.js.map +0 -1
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { shortenAddress, isValidAddress, ZERO_ADDRESS } from './chunk-B4WKI3EW.js';
|
|
2
|
-
import { isIpfsImageCid, resolveIpfsImageUrls, resolveIpfsImageUrl } from './chunk-
|
|
2
|
+
import { isIpfsImageCid, resolveIpfsImageUrls, resolveIpfsImageUrl } from './chunk-SAG36LUR.js';
|
|
3
3
|
import { getTaxVaultHostChainConfig } from './chunk-FUOBTZMQ.js';
|
|
4
4
|
import * as React9 from 'react';
|
|
5
|
-
import { createContext, useContext, useState, useEffect, useMemo
|
|
6
|
-
import { Loader2, ExternalLink, AlertTriangle, CheckCircle2, Info, X, ShieldCheck, Play, Pause, VolumeX, Volume2, Maximize, SkipBack, ChevronLeft, ChevronRight, SkipForward } from 'lucide-react';
|
|
5
|
+
import { createContext, useContext, useState, useEffect, useMemo } from '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;
|
|
@@ -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 }),
|
|
@@ -541,27 +676,25 @@ var Input = React9.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */
|
|
|
541
676
|
Input.displayName = "Input";
|
|
542
677
|
function IpfsImage({ alt, cid, path, validationPath, className, decoding = "async", loading = "lazy", onError, ...props }) {
|
|
543
678
|
const urls = React9.useMemo(() => resolveIpfsImageUrls(cid, 56, path), [cid, path]);
|
|
544
|
-
const
|
|
545
|
-
const [fallbackState, setFallbackState] = React9.useState({ key: resourceKey, index: 0 });
|
|
546
|
-
const urlIndex = fallbackState.key === resourceKey ? fallbackState.index : 0;
|
|
679
|
+
const [urlIndex, setUrlIndex] = React9.useState(0);
|
|
547
680
|
const src = urls[urlIndex];
|
|
548
|
-
|
|
681
|
+
React9.useEffect(() => {
|
|
682
|
+
setUrlIndex(0);
|
|
683
|
+
}, [cid, path]);
|
|
549
684
|
if (!src) return null;
|
|
550
685
|
return (
|
|
551
686
|
// eslint-disable-next-line @next/next/no-img-element -- IpfsImage owns CID-to-gateway fallback; next/image cannot represent this boundary.
|
|
552
|
-
/* @__PURE__ */
|
|
687
|
+
/* @__PURE__ */ jsx(
|
|
553
688
|
"img",
|
|
554
689
|
{
|
|
555
|
-
...
|
|
556
|
-
key: resourceKey,
|
|
690
|
+
...props,
|
|
557
691
|
alt,
|
|
558
692
|
className: cn("block max-w-full", className),
|
|
559
693
|
decoding,
|
|
560
694
|
loading,
|
|
561
|
-
referrerPolicy: "no-referrer",
|
|
562
695
|
onError: (event) => {
|
|
563
696
|
if (urlIndex < urls.length - 1) {
|
|
564
|
-
|
|
697
|
+
setUrlIndex((index) => Math.min(index + 1, urls.length - 1));
|
|
565
698
|
return;
|
|
566
699
|
}
|
|
567
700
|
onError?.(event);
|
|
@@ -577,28 +710,6 @@ function IpfsBackground({ cid, className, imageClassName, overlayClassName, ...p
|
|
|
577
710
|
overlayClassName ? /* @__PURE__ */ jsx("div", { className: cn("absolute inset-0", overlayClassName) }) : null
|
|
578
711
|
] });
|
|
579
712
|
}
|
|
580
|
-
function IpfsText({ cid, path, fallback = null, className, ...props }) {
|
|
581
|
-
const { readIpfsText } = useFlapSdk();
|
|
582
|
-
const key = JSON.stringify([typeof cid === "string" ? cid : null, typeof path === "string" ? path : null]);
|
|
583
|
-
const [result, setResult] = React9.useState();
|
|
584
|
-
React9.useEffect(() => {
|
|
585
|
-
let cancelled = false;
|
|
586
|
-
readIpfsText(cid, path).then(
|
|
587
|
-
(text) => {
|
|
588
|
-
if (!cancelled) setResult({ key, text, state: "ready" });
|
|
589
|
-
},
|
|
590
|
-
() => {
|
|
591
|
-
if (!cancelled) setResult({ key, state: "error" });
|
|
592
|
-
}
|
|
593
|
-
);
|
|
594
|
-
return () => {
|
|
595
|
-
cancelled = true;
|
|
596
|
-
};
|
|
597
|
-
}, [readIpfsText, cid, path, key]);
|
|
598
|
-
const current = result?.key === key ? result : void 0;
|
|
599
|
-
const { dangerouslySetInnerHTML: ignoredHtml, children: ignoredChildren, ...safeProps } = props;
|
|
600
|
-
return /* @__PURE__ */ jsx("span", { ...safeProps, className: cn("whitespace-pre-wrap break-words", className), "data-flap-ipfs-text-state": current?.state ?? "loading", children: current?.state === "ready" ? current.text : fallback });
|
|
601
|
-
}
|
|
602
713
|
function NftMetadataImage({ alt, tokenId, fallback = null, className, decoding = "async", loading = "lazy", onError, ...props }) {
|
|
603
714
|
const sdk = useFlapSdk();
|
|
604
715
|
const [metadata, setMetadata] = React9.useState(null);
|
|
@@ -1513,7 +1624,7 @@ function ConsumerVideoSessionPlayer({ consumer, startClip = 0, label, fallback =
|
|
|
1513
1624
|
}, [reader, startClip]);
|
|
1514
1625
|
React9.useEffect(() => {
|
|
1515
1626
|
if (!videoRef.current) return;
|
|
1516
|
-
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);
|
|
1517
1628
|
controllerRef.current = controller;
|
|
1518
1629
|
return () => {
|
|
1519
1630
|
controller.dispose();
|
|
@@ -1773,7 +1884,7 @@ function VideoSessionPlayer(props) {
|
|
|
1773
1884
|
return "consumer" in props && props.consumer !== void 0 ? /* @__PURE__ */ jsx(ConsumerVideoSessionPlayer, { ...props }) : /* @__PURE__ */ jsx(VideoClipSessionPlayer, { ...props });
|
|
1774
1885
|
}
|
|
1775
1886
|
async function loadMpegts() {
|
|
1776
|
-
return (await import('./mpegts-
|
|
1887
|
+
return (await import('./mpegts-J2J6JTD7.js')).default;
|
|
1777
1888
|
}
|
|
1778
1889
|
function VideoClipSessionPlayer({ clips, label, fallback = null, className, autoPlay = false, muted = false }) {
|
|
1779
1890
|
const videoRef = React9.useRef(null);
|
|
@@ -1811,6 +1922,6 @@ function VideoClipSessionPlayer({ clips, label, fallback = null, className, auto
|
|
|
1811
1922
|
] });
|
|
1812
1923
|
}
|
|
1813
1924
|
|
|
1814
|
-
export { AddressLink, Alert, BinanceImage, Button, Card, CardContent, CardDescription, CardHeader, CardTitle, Countdown, DataRow, DetailTile, ExternalLink2 as ExternalLink, Input, IpfsBackground, IpfsImage,
|
|
1815
|
-
//# sourceMappingURL=chunk-
|
|
1816
|
-
//# 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
|