@flapsdk/vault-runtime 0.1.38-next.0 → 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.
- package/README.md +54 -0
- package/{chunk-JVOFLTLD.js → chunk-3MVBV65H.js} +99 -69
- package/chunk-3MVBV65H.js.map +1 -0
- package/chunk-GY7YY67I.js +78 -0
- package/chunk-GY7YY67I.js.map +1 -0
- package/{chunk-SDCB3RJS.js → chunk-JJJSK6HF.js} +3 -3
- package/{chunk-SDCB3RJS.js.map → chunk-JJJSK6HF.js.map} +1 -1
- package/{chunk-44P2NRRZ.js → chunk-JW4MM24W.js} +22 -11
- package/chunk-JW4MM24W.js.map +1 -0
- package/{chunk-A3ER7XYN.js → chunk-QS475ZC7.js} +178 -3
- package/chunk-QS475ZC7.js.map +1 -0
- package/{chunk-PU7VEZWA.js → chunk-WN4MIMCY.js} +3 -3
- package/{chunk-PU7VEZWA.js.map → chunk-WN4MIMCY.js.map} +1 -1
- package/host-client.d.mts +1 -1
- package/host-client.js +5 -6
- package/host.d.mts +4 -4
- package/host.js +4 -4
- package/{hostRuntimeConfig-DibvcxHE.d.mts → hostRuntimeConfig-CKjug1-9.d.mts} +1 -1
- package/{mpegts-J2J6JTD7.js → mpegts-536UQHCG.js} +6 -6
- package/{mpegts-J2J6JTD7.js.map → mpegts-536UQHCG.js.map} +1 -1
- package/package.json +2 -2
- package/runtime-contract.json +3 -2
- package/sdk.d.mts +8 -4
- package/sdk.js +12 -11
- package/sdk.js.map +1 -1
- package/server.d.mts +3 -3
- package/server.js +4 -5
- package/server.js.map +1 -1
- package/{txError-OBuRV8xN.d.mts → txError-BTuW38It.d.mts} +1 -1
- package/{types-DUZWZ3mC.d.mts → types-BolUPLIE.d.mts} +7 -0
- package/ui.d.mts +13 -5
- package/ui.js +2 -3
- package/chunk-44P2NRRZ.js.map +0 -1
- package/chunk-A3ER7XYN.js.map +0 -1
- package/chunk-FUOBTZMQ.js +0 -47
- package/chunk-FUOBTZMQ.js.map +0 -1
- package/chunk-JVOFLTLD.js.map +0 -1
- package/chunk-SAG36LUR.js +0 -35
- package/chunk-SAG36LUR.js.map +0 -1
package/README.md
CHANGED
|
@@ -6,6 +6,8 @@ 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.39-next.0`. Source commit: `48bb8c2d7a6ef14278915d61b08b3c00b55d5fd6`.
|
|
10
|
+
|
|
9
11
|
## Exports
|
|
10
12
|
|
|
11
13
|
- `./sdk`: component-facing SDK hooks, helpers, types, and local oracle reader helper
|
|
@@ -14,3 +16,55 @@ This package is the shared runtime surface that local preview, Artifact Workbenc
|
|
|
14
16
|
- `./server`: server-side presentation, runtime oracle-registry helpers, controlled image/text upload handler, and the Vault V2 NFT metadata/media resolver
|
|
15
17
|
|
|
16
18
|
See `runtime-contract.json` for the machine-readable subpath contract.
|
|
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
|
+
|
|
27
|
+
## Dynamic IPFS content
|
|
28
|
+
|
|
29
|
+
Stable runtime `0.1.37` introduces `sdk.readIpfsText(cid, path?)`, which returns
|
|
30
|
+
UTF-8 text or JSON as a string, and `IpfsText` for escaped plain-text display.
|
|
31
|
+
`IpfsImage` accepts dynamic bare CIDs from FSI, contract state, or SDK uploads.
|
|
32
|
+
The SDK exports `IPFS_CONTENT_VERSION = 1`; the runtime contract advertises
|
|
33
|
+
`sdkFeatures.ipfsContent = 1`. Stable `0.1.36` lacks the text API/component.
|
|
34
|
+
|
|
35
|
+
Vault source keeps the `@/src/sdk` and `@/src/ui` authoring aliases. Obtain
|
|
36
|
+
`sdk` with `useFlapSdk()`, then call the reader from an async effect or event
|
|
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:
|
|
40
|
+
|
|
41
|
+
```tsx
|
|
42
|
+
const body = await sdk.readIpfsText(textCid);
|
|
43
|
+
// Parse JSON only if the application expects JSON content.
|
|
44
|
+
const post = JSON.parse(await sdk.readIpfsText(jsonCid));
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
```tsx
|
|
48
|
+
<IpfsText cid={item.textCid} fallback={i18n.t("contentLoading")} />
|
|
49
|
+
<IpfsImage cid={item.imageCid} alt={i18n.t("postImageAlt")} />
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
Use safe relative `path` values for directory CIDs, never a gateway URL or
|
|
53
|
+
`ipfs://` URI. The runtime controls gateways and validates every CID/path.
|
|
54
|
+
Text reads omit credentials/referrers, reject redirects and HTML responses,
|
|
55
|
+
enforce UTF-8 and a 256 KiB limit, and have an 8-second network/body deadline
|
|
56
|
+
after acquiring an active slot. Reads are deduplicated, cached and concurrency
|
|
57
|
+
limited. `IpfsText` does not interpret HTML or Markdown. Localize loading/error
|
|
58
|
+
and alt text, and paginate feeds. `IpfsBackground` remains static CID-only.
|
|
59
|
+
|
|
60
|
+
Dynamic content sources require human review. Upgrade Workbench and Flap hosts
|
|
61
|
+
to the published runtime and deploy Workbench's matching static checker before
|
|
62
|
+
accepting new components. Reads use platform gateways without a new host route;
|
|
63
|
+
uploads continue through the existing host-owned upload service. Automated
|
|
64
|
+
upload fixtures are mocked and do not verify live gateway availability.
|
|
65
|
+
|
|
66
|
+
Source documentation:
|
|
67
|
+
|
|
68
|
+
- [API guide](https://github.com/flap-sh/flap-vault-component-template/blob/main/docs/ipfs-content.md)
|
|
69
|
+
- [API 说明](https://github.com/flap-sh/flap-vault-component-template/blob/main/docs/ipfs-content.zh-CN.md)
|
|
70
|
+
- [Release and upgrade notes](https://github.com/flap-sh/flap-vault-component-template/blob/main/docs/releases/0.1.37.md)
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { shortenAddress, isValidAddress, ZERO_ADDRESS } from './chunk-B4WKI3EW.js';
|
|
2
|
-
import { isIpfsImageCid, resolveIpfsImageUrls, resolveIpfsImageUrl } from './chunk-
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import { createContext, useContext, useState, useEffect, useMemo } from 'react';
|
|
2
|
+
import { isIpfsImageCid, resolveIpfsImageUrls, getTaxVaultHostChainConfig, resolveIpfsImageUrl } from './chunk-GY7YY67I.js';
|
|
3
|
+
import * as React10 from 'react';
|
|
4
|
+
import { createContext, useContext, useState, useEffect, useMemo, createElement } from 'react';
|
|
6
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';
|
|
@@ -42,6 +41,13 @@ function useFlapNotify() {
|
|
|
42
41
|
if (!runtime) throw new Error("A Flap runtime provider is required.");
|
|
43
42
|
return runtime.notify;
|
|
44
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
|
+
}
|
|
45
51
|
|
|
46
52
|
// src/sdk/videoSession.ts
|
|
47
53
|
var videoProviderAbi = [
|
|
@@ -153,7 +159,7 @@ var buttonVariants = cva(
|
|
|
153
159
|
}
|
|
154
160
|
}
|
|
155
161
|
);
|
|
156
|
-
var Button =
|
|
162
|
+
var Button = React10.forwardRef(
|
|
157
163
|
({ className, variant, size, asChild = false, loading = false, disabled, children, ...props }, ref) => {
|
|
158
164
|
const Comp = asChild ? Slot : "button";
|
|
159
165
|
if (asChild) {
|
|
@@ -195,8 +201,8 @@ function normalizeBinanceImageUrl(value) {
|
|
|
195
201
|
}
|
|
196
202
|
}
|
|
197
203
|
function BinanceImage({ alt, src, fallback = null, className, onError, ...props }) {
|
|
198
|
-
const safeSrc =
|
|
199
|
-
const [failedSrc, setFailedSrc] =
|
|
204
|
+
const safeSrc = React10.useMemo(() => normalizeBinanceImageUrl(src), [src]);
|
|
205
|
+
const [failedSrc, setFailedSrc] = React10.useState(null);
|
|
200
206
|
const {
|
|
201
207
|
alt: _unsafeAlt,
|
|
202
208
|
decoding: _unsafeDecoding,
|
|
@@ -230,7 +236,7 @@ function BinanceImage({ alt, src, fallback = null, className, onError, ...props
|
|
|
230
236
|
)
|
|
231
237
|
);
|
|
232
238
|
}
|
|
233
|
-
var Card =
|
|
239
|
+
var Card = React10.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
|
|
234
240
|
"div",
|
|
235
241
|
{
|
|
236
242
|
"data-flap-ui": "card",
|
|
@@ -243,19 +249,19 @@ var Card = React9.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ j
|
|
|
243
249
|
}
|
|
244
250
|
));
|
|
245
251
|
Card.displayName = "Card";
|
|
246
|
-
var CardHeader =
|
|
252
|
+
var CardHeader = React10.forwardRef(
|
|
247
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 })
|
|
248
254
|
);
|
|
249
255
|
CardHeader.displayName = "CardHeader";
|
|
250
|
-
var CardTitle =
|
|
256
|
+
var CardTitle = React10.forwardRef(
|
|
251
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 })
|
|
252
258
|
);
|
|
253
259
|
CardTitle.displayName = "CardTitle";
|
|
254
|
-
var CardDescription =
|
|
260
|
+
var CardDescription = React10.forwardRef(
|
|
255
261
|
({ className, ...props }, ref) => /* @__PURE__ */ jsx("p", { "data-flap-ui": "card-description", ref, className: cn("text-sm leading-6 text-[#84888C]", className), ...props })
|
|
256
262
|
);
|
|
257
263
|
CardDescription.displayName = "CardDescription";
|
|
258
|
-
var CardContent =
|
|
264
|
+
var CardContent = React10.forwardRef(
|
|
259
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 })
|
|
260
266
|
);
|
|
261
267
|
CardContent.displayName = "CardContent";
|
|
@@ -339,11 +345,11 @@ function CopyButton({ value, label, disabled = false, className }) {
|
|
|
339
345
|
const notify = useFlapNotify();
|
|
340
346
|
const defaults = getCopyButtonMessages(i18n.locale);
|
|
341
347
|
const text = Object.fromEntries(Object.entries(defaults).map(([key, fallback]) => [key, i18n.t(`flap.copy.${key}`, fallback)]));
|
|
342
|
-
const [result, setResult] =
|
|
343
|
-
const pending =
|
|
344
|
-
const mounted =
|
|
345
|
-
const timer =
|
|
346
|
-
|
|
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(() => {
|
|
347
353
|
mounted.current = true;
|
|
348
354
|
return () => {
|
|
349
355
|
mounted.current = false;
|
|
@@ -498,20 +504,20 @@ function WarningIcon({ className }) {
|
|
|
498
504
|
] });
|
|
499
505
|
}
|
|
500
506
|
function ExternalLink2({ url, children, locale, className, copy }) {
|
|
501
|
-
const [open, setOpen] =
|
|
502
|
-
const [acknowledged, setAcknowledged] =
|
|
503
|
-
const [mounted, setMounted] =
|
|
507
|
+
const [open, setOpen] = React10.useState(false);
|
|
508
|
+
const [acknowledged, setAcknowledged] = React10.useState(false);
|
|
509
|
+
const [mounted, setMounted] = React10.useState(false);
|
|
504
510
|
const text = { ...COPY[resolveLocale(locale)], ...copy };
|
|
505
|
-
const safeUrl =
|
|
511
|
+
const safeUrl = React10.useMemo(() => normalizeExternalUrl(url), [url]);
|
|
506
512
|
const canProceed = acknowledged && Boolean(safeUrl);
|
|
507
|
-
|
|
513
|
+
React10.useEffect(() => {
|
|
508
514
|
setMounted(true);
|
|
509
515
|
}, []);
|
|
510
|
-
const close =
|
|
516
|
+
const close = React10.useCallback(() => {
|
|
511
517
|
setOpen(false);
|
|
512
518
|
setAcknowledged(false);
|
|
513
519
|
}, []);
|
|
514
|
-
|
|
520
|
+
React10.useEffect(() => {
|
|
515
521
|
if (!open) return;
|
|
516
522
|
const onKey = (event) => {
|
|
517
523
|
if (event.key === "Escape") close();
|
|
@@ -661,7 +667,7 @@ function ExternalLink2({ url, children, locale, className, copy }) {
|
|
|
661
667
|
) : null
|
|
662
668
|
] });
|
|
663
669
|
}
|
|
664
|
-
var Input =
|
|
670
|
+
var Input = React10.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
|
|
665
671
|
"input",
|
|
666
672
|
{
|
|
667
673
|
"data-flap-ui": "input",
|
|
@@ -675,26 +681,28 @@ var Input = React9.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */
|
|
|
675
681
|
));
|
|
676
682
|
Input.displayName = "Input";
|
|
677
683
|
function IpfsImage({ alt, cid, path, validationPath, className, decoding = "async", loading = "lazy", onError, ...props }) {
|
|
678
|
-
const urls =
|
|
679
|
-
const
|
|
684
|
+
const urls = React10.useMemo(() => resolveIpfsImageUrls(cid, 56, path), [cid, path]);
|
|
685
|
+
const resourceKey = urls.join("\n");
|
|
686
|
+
const [fallbackState, setFallbackState] = React10.useState({ key: resourceKey, index: 0 });
|
|
687
|
+
const urlIndex = fallbackState.key === resourceKey ? fallbackState.index : 0;
|
|
680
688
|
const src = urls[urlIndex];
|
|
681
|
-
|
|
682
|
-
setUrlIndex(0);
|
|
683
|
-
}, [cid, path]);
|
|
689
|
+
const { src: ignoredSrc, srcSet: ignoredSrcSet, dangerouslySetInnerHTML: ignoredHtml, ...safeProps } = props;
|
|
684
690
|
if (!src) return null;
|
|
685
691
|
return (
|
|
686
692
|
// eslint-disable-next-line @next/next/no-img-element -- IpfsImage owns CID-to-gateway fallback; next/image cannot represent this boundary.
|
|
687
|
-
/* @__PURE__ */
|
|
693
|
+
/* @__PURE__ */ createElement(
|
|
688
694
|
"img",
|
|
689
695
|
{
|
|
690
|
-
...
|
|
696
|
+
...safeProps,
|
|
697
|
+
key: resourceKey,
|
|
691
698
|
alt,
|
|
692
699
|
className: cn("block max-w-full", className),
|
|
693
700
|
decoding,
|
|
694
701
|
loading,
|
|
702
|
+
referrerPolicy: "no-referrer",
|
|
695
703
|
onError: (event) => {
|
|
696
704
|
if (urlIndex < urls.length - 1) {
|
|
697
|
-
|
|
705
|
+
setFallbackState({ key: resourceKey, index: Math.min(urlIndex + 1, urls.length - 1) });
|
|
698
706
|
return;
|
|
699
707
|
}
|
|
700
708
|
onError?.(event);
|
|
@@ -710,11 +718,33 @@ function IpfsBackground({ cid, className, imageClassName, overlayClassName, ...p
|
|
|
710
718
|
overlayClassName ? /* @__PURE__ */ jsx("div", { className: cn("absolute inset-0", overlayClassName) }) : null
|
|
711
719
|
] });
|
|
712
720
|
}
|
|
721
|
+
function IpfsText({ cid, path, fallback = null, className, ...props }) {
|
|
722
|
+
const readIpfsText = useFlapIpfsTextReader();
|
|
723
|
+
const key = JSON.stringify([typeof cid === "string" ? cid : null, typeof path === "string" ? path : null]);
|
|
724
|
+
const [result, setResult] = React10.useState();
|
|
725
|
+
React10.useEffect(() => {
|
|
726
|
+
let cancelled = false;
|
|
727
|
+
readIpfsText(cid, path).then(
|
|
728
|
+
(text) => {
|
|
729
|
+
if (!cancelled) setResult({ key, text, state: "ready" });
|
|
730
|
+
},
|
|
731
|
+
() => {
|
|
732
|
+
if (!cancelled) setResult({ key, state: "error" });
|
|
733
|
+
}
|
|
734
|
+
);
|
|
735
|
+
return () => {
|
|
736
|
+
cancelled = true;
|
|
737
|
+
};
|
|
738
|
+
}, [readIpfsText, cid, path, key]);
|
|
739
|
+
const current = result?.key === key ? result : void 0;
|
|
740
|
+
const { dangerouslySetInnerHTML: ignoredHtml, children: ignoredChildren, ...safeProps } = props;
|
|
741
|
+
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 });
|
|
742
|
+
}
|
|
713
743
|
function NftMetadataImage({ alt, tokenId, fallback = null, className, decoding = "async", loading = "lazy", onError, ...props }) {
|
|
714
744
|
const sdk = useFlapSdk();
|
|
715
|
-
const [metadata, setMetadata] =
|
|
716
|
-
const [state, setState] =
|
|
717
|
-
|
|
745
|
+
const [metadata, setMetadata] = React10.useState(null);
|
|
746
|
+
const [state, setState] = React10.useState("loading");
|
|
747
|
+
React10.useEffect(() => {
|
|
718
748
|
let cancelled = false;
|
|
719
749
|
setState("loading");
|
|
720
750
|
setMetadata(null);
|
|
@@ -1574,38 +1604,38 @@ var clock = (seconds) => `${Math.floor(seconds / 60)}:${Math.floor(seconds % 60)
|
|
|
1574
1604
|
function ConsumerVideoSessionPlayer({ consumer, startClip = 0, label, fallback = null, className, autoPlay = false, muted = false }) {
|
|
1575
1605
|
const sdk = useFlapSdk();
|
|
1576
1606
|
const { chainId } = sdk.context;
|
|
1577
|
-
const readContractRef =
|
|
1607
|
+
const readContractRef = React10.useRef(sdk.readContract);
|
|
1578
1608
|
readContractRef.current = sdk.readContract;
|
|
1579
|
-
const reader =
|
|
1609
|
+
const reader = React10.useMemo(() => createConsumerVideoSessionReader({
|
|
1580
1610
|
context: { chainId },
|
|
1581
1611
|
readContract: (request) => readContractRef.current(request)
|
|
1582
1612
|
}, consumer), [chainId, consumer]);
|
|
1583
|
-
const sessionRef =
|
|
1584
|
-
const controllerRef =
|
|
1585
|
-
const videoRef =
|
|
1586
|
-
const frameRef =
|
|
1587
|
-
const playIntent =
|
|
1588
|
-
const autoPlayRef =
|
|
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);
|
|
1589
1619
|
autoPlayRef.current = autoPlay;
|
|
1590
|
-
const [snapshot, setSnapshot] =
|
|
1591
|
-
const [mediaState, setMediaState] =
|
|
1592
|
-
const [time, setTime] =
|
|
1593
|
-
const [paused, setPaused] =
|
|
1594
|
-
const [isMuted, setIsMuted] =
|
|
1595
|
-
const [volume, setVolume] =
|
|
1596
|
-
|
|
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(() => {
|
|
1597
1627
|
setIsMuted(muted);
|
|
1598
1628
|
}, [muted]);
|
|
1599
|
-
const [buffering, setBuffering] =
|
|
1600
|
-
const [page, setPage] =
|
|
1601
|
-
const [jump, setJump] =
|
|
1629
|
+
const [buffering, setBuffering] = React10.useState(false);
|
|
1630
|
+
const [page, setPage] = React10.useState(0);
|
|
1631
|
+
const [jump, setJump] = React10.useState("");
|
|
1602
1632
|
const position = videoClipPosition(snapshot.clips, time, snapshot.mediaStartPtsMs);
|
|
1603
1633
|
const duration = Number(snapshot.endPtsMs - snapshot.firstPtsMs) / 1e3;
|
|
1604
1634
|
const globalTime = Math.max(0, Math.min(duration, Number(snapshot.mediaStartPtsMs - snapshot.firstPtsMs) / 1e3 + time));
|
|
1605
1635
|
const activeIndex = position?.index ?? snapshot.start;
|
|
1606
1636
|
const strings = videoPlayerMessages[sdk.i18n.locale.split("-")[0]] ?? videoPlayerMessages.en;
|
|
1607
1637
|
const text = (key, params) => sdk.i18n.t(`runtime.video.${key}`, strings[key], params);
|
|
1608
|
-
|
|
1638
|
+
React10.useEffect(() => {
|
|
1609
1639
|
const session = new ConsumerVideoSession(reader, setSnapshot);
|
|
1610
1640
|
sessionRef.current = session;
|
|
1611
1641
|
setSnapshot(initialSnapshot);
|
|
@@ -1622,16 +1652,16 @@ function ConsumerVideoSessionPlayer({ consumer, startClip = 0, label, fallback =
|
|
|
1622
1652
|
sessionRef.current = null;
|
|
1623
1653
|
};
|
|
1624
1654
|
}, [reader, startClip]);
|
|
1625
|
-
|
|
1655
|
+
React10.useEffect(() => {
|
|
1626
1656
|
if (!videoRef.current) return;
|
|
1627
|
-
const controller = new VideoSessionController(videoRef.current, async () => (await import('./mpegts-
|
|
1657
|
+
const controller = new VideoSessionController(videoRef.current, async () => (await import('./mpegts-536UQHCG.js')).default, setMediaState);
|
|
1628
1658
|
controllerRef.current = controller;
|
|
1629
1659
|
return () => {
|
|
1630
1660
|
controller.dispose();
|
|
1631
1661
|
controllerRef.current = null;
|
|
1632
1662
|
};
|
|
1633
1663
|
}, []);
|
|
1634
|
-
|
|
1664
|
+
React10.useEffect(() => {
|
|
1635
1665
|
const controller = controllerRef.current;
|
|
1636
1666
|
const session = sessionRef.current;
|
|
1637
1667
|
if (!controller || !session) return;
|
|
@@ -1650,7 +1680,7 @@ function ConsumerVideoSessionPlayer({ consumer, startClip = 0, label, fallback =
|
|
|
1650
1680
|
playIntent: () => playIntent.current
|
|
1651
1681
|
}, snapshot.play, snapshot.resumeAt);
|
|
1652
1682
|
}, [snapshot.sessionId, snapshot.revision, snapshot.state]);
|
|
1653
|
-
|
|
1683
|
+
React10.useEffect(() => {
|
|
1654
1684
|
setPage(Math.floor(activeIndex / VIDEO_PICKER_PAGE_SIZE));
|
|
1655
1685
|
}, [activeIndex]);
|
|
1656
1686
|
const advance = () => {
|
|
@@ -1660,7 +1690,7 @@ function ConsumerVideoSessionPlayer({ consumer, startClip = 0, label, fallback =
|
|
|
1660
1690
|
void sessionRef.current?.advance(current.index);
|
|
1661
1691
|
}
|
|
1662
1692
|
};
|
|
1663
|
-
|
|
1693
|
+
React10.useEffect(() => {
|
|
1664
1694
|
const video = videoRef.current;
|
|
1665
1695
|
const current = videoClipPosition(snapshot.clips, video?.currentTime ?? 0, snapshot.mediaStartPtsMs);
|
|
1666
1696
|
if (video && current && (current.index >= snapshot.start + snapshot.clips.length - 2 || video.ended)) void sessionRef.current?.advance(current.index);
|
|
@@ -1884,13 +1914,13 @@ function VideoSessionPlayer(props) {
|
|
|
1884
1914
|
return "consumer" in props && props.consumer !== void 0 ? /* @__PURE__ */ jsx(ConsumerVideoSessionPlayer, { ...props }) : /* @__PURE__ */ jsx(VideoClipSessionPlayer, { ...props });
|
|
1885
1915
|
}
|
|
1886
1916
|
async function loadMpegts() {
|
|
1887
|
-
return (await import('./mpegts-
|
|
1917
|
+
return (await import('./mpegts-536UQHCG.js')).default;
|
|
1888
1918
|
}
|
|
1889
1919
|
function VideoClipSessionPlayer({ clips, label, fallback = null, className, autoPlay = false, muted = false }) {
|
|
1890
|
-
const videoRef =
|
|
1891
|
-
const controllerRef =
|
|
1892
|
-
const [state, setState] =
|
|
1893
|
-
|
|
1920
|
+
const videoRef = React10.useRef(null);
|
|
1921
|
+
const controllerRef = React10.useRef(null);
|
|
1922
|
+
const [state, setState] = React10.useState("loading");
|
|
1923
|
+
React10.useEffect(() => {
|
|
1894
1924
|
if (!videoRef.current) return;
|
|
1895
1925
|
const controller = new VideoSessionController(videoRef.current, loadMpegts, setState);
|
|
1896
1926
|
controllerRef.current = controller;
|
|
@@ -1899,7 +1929,7 @@ function VideoClipSessionPlayer({ clips, label, fallback = null, className, auto
|
|
|
1899
1929
|
controllerRef.current = null;
|
|
1900
1930
|
};
|
|
1901
1931
|
}, []);
|
|
1902
|
-
|
|
1932
|
+
React10.useEffect(() => {
|
|
1903
1933
|
void controllerRef.current?.update(clips, autoPlay);
|
|
1904
1934
|
}, [clips, autoPlay]);
|
|
1905
1935
|
const showVideo = state === "loading" || state === "ready";
|
|
@@ -1922,6 +1952,6 @@ function VideoClipSessionPlayer({ clips, label, fallback = null, className, auto
|
|
|
1922
1952
|
] });
|
|
1923
1953
|
}
|
|
1924
1954
|
|
|
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-
|
|
1927
|
-
//# sourceMappingURL=chunk-
|
|
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
|