@flapsdk/vault-runtime 0.1.36 → 0.1.37

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 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.37`. Source commit: `ad40bab7dfc976d20dd82050aeec17fef18a39b3`.
10
+
9
11
  ## Exports
10
12
 
11
13
  - `./sdk`: component-facing SDK hooks, helpers, types, and local oracle reader helper
@@ -14,3 +16,46 @@ 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
+ ## Dynamic IPFS content
21
+
22
+ Stable runtime `0.1.37` introduces `sdk.readIpfsText(cid, path?)`, which returns
23
+ UTF-8 text or JSON as a string, and `IpfsText` for escaped plain-text display.
24
+ `IpfsImage` accepts dynamic bare CIDs from FSI, contract state, or SDK uploads.
25
+ The SDK exports `IPFS_CONTENT_VERSION = 1`; the runtime contract advertises
26
+ `sdkFeatures.ipfsContent = 1`. Stable `0.1.36` lacks the text API/component.
27
+
28
+ Vault source keeps the `@/src/sdk` and `@/src/ui` authoring aliases. Obtain
29
+ `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:
31
+
32
+ ```tsx
33
+ const body = await sdk.readIpfsText(textCid);
34
+ // Parse JSON only if the application expects JSON content.
35
+ const post = JSON.parse(await sdk.readIpfsText(jsonCid));
36
+ ```
37
+
38
+ ```tsx
39
+ <IpfsText cid={item.textCid} fallback={i18n.t("contentLoading")} />
40
+ <IpfsImage cid={item.imageCid} alt={i18n.t("postImageAlt")} />
41
+ ```
42
+
43
+ Use safe relative `path` values for directory CIDs, never a gateway URL or
44
+ `ipfs://` URI. The runtime controls gateways and validates every CID/path.
45
+ Text reads omit credentials/referrers, reject redirects and HTML responses,
46
+ enforce UTF-8 and a 256 KiB limit, and have an 8-second network/body deadline
47
+ after acquiring an active slot. Reads are deduplicated, cached and concurrency
48
+ limited. `IpfsText` does not interpret HTML or Markdown. Localize loading/error
49
+ and alt text, and paginate feeds. `IpfsBackground` remains static CID-only.
50
+
51
+ Dynamic content sources require human review. Upgrade Workbench and Flap hosts
52
+ to the published runtime and deploy Workbench's matching static checker before
53
+ accepting new components. Reads use platform gateways without a new host route;
54
+ uploads continue through the existing host-owned upload service. Automated
55
+ upload fixtures are mocked and do not verify live gateway availability.
56
+
57
+ Source documentation:
58
+
59
+ - [API guide](https://github.com/flap-sh/flap-vault-component-template/blob/main/docs/ipfs-content.md)
60
+ - [API 说明](https://github.com/flap-sh/flap-vault-component-template/blob/main/docs/ipfs-content.zh-CN.md)
61
+ - [Release and upgrade notes](https://github.com/flap-sh/flap-vault-component-template/blob/main/docs/releases/0.1.37.md)
@@ -6,10 +6,11 @@ var IPFS_IMAGE_GATEWAYS = ["https://flap.mypinata.cloud", "https://magenta-naval
6
6
  var CID_RE = /^(?:Qm[1-9A-HJ-NP-Za-km-z]{44}|b[a-z2-7]{20,})$/;
7
7
  var PATH_SEGMENT_RE = /^[A-Za-z0-9._~-]+$/;
8
8
  function isIpfsImageCid(value) {
9
- return CID_RE.test(value.trim());
9
+ return typeof value === "string" && value.length <= 128 && CID_RE.test(value.trim());
10
10
  }
11
11
  function normalizeIpfsImagePath(value) {
12
12
  if (value === void 0) return "";
13
+ if (typeof value !== "string") return void 0;
13
14
  const trimmed = value.trim();
14
15
  if (!trimmed || trimmed.length > 512 || trimmed.startsWith("/") || trimmed.endsWith("/")) return void 0;
15
16
  const segments = trimmed.split("/");
@@ -31,5 +32,5 @@ function resolveIpfsImageUrls(cid, chainId = 56, path) {
31
32
  }
32
33
 
33
34
  export { isIpfsImageCid, normalizeIpfsImagePath, resolveIpfsImageUrl, resolveIpfsImageUrls };
34
- //# sourceMappingURL=chunk-SAG36LUR.js.map
35
- //# sourceMappingURL=chunk-SAG36LUR.js.map
35
+ //# sourceMappingURL=chunk-27VBKY3J.js.map
36
+ //# sourceMappingURL=chunk-27VBKY3J.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/sdk/ipfsImage.ts"],"names":[],"mappings":";;;AAEA,IAAM,0BAAA,GAA6B,6BAAA;AACnC,IAAM,mBAAA,GAAsB,CAAC,6BAAA,EAA+B,kDAAkD,CAAA;AAC9G,IAAM,MAAA,GAAS,iDAAA;AACf,IAAM,eAAA,GAAkB,oBAAA;AAEjB,SAAS,eAAe,KAAA,EAAe;AAC5C,EAAA,OAAO,OAAO,KAAA,KAAU,QAAA,IAAY,KAAA,CAAM,MAAA,IAAU,OAAO,MAAA,CAAO,IAAA,CAAK,KAAA,CAAM,IAAA,EAAM,CAAA;AACrF;AAEO,SAAS,uBAAuB,KAAA,EAA2B;AAChE,EAAA,IAAI,KAAA,KAAU,QAAW,OAAO,EAAA;AAChC,EAAA,IAAI,OAAO,KAAA,KAAU,QAAA,EAAU,OAAO,MAAA;AACtC,EAAA,MAAM,OAAA,GAAU,MAAM,IAAA,EAAK;AAC3B,EAAA,IAAI,CAAC,OAAA,IAAW,OAAA,CAAQ,MAAA,GAAS,GAAA,IAAO,OAAA,CAAQ,UAAA,CAAW,GAAG,CAAA,IAAK,OAAA,CAAQ,QAAA,CAAS,GAAG,GAAG,OAAO,MAAA;AACjG,EAAA,MAAM,QAAA,GAAW,OAAA,CAAQ,KAAA,CAAM,GAAG,CAAA;AAClC,EAAA,IAAI,SAAS,IAAA,CAAK,CAAC,OAAA,KAAY,CAAC,WAAW,OAAA,KAAY,GAAA,IAAO,OAAA,KAAY,IAAA,IAAQ,CAAC,eAAA,CAAgB,IAAA,CAAK,OAAO,CAAC,GAAG,OAAO,MAAA;AAC1H,EAAA,OAAO,QAAA,CAAS,KAAK,GAAG,CAAA;AAC1B;AAEO,SAAS,mBAAA,CAAoB,GAAA,EAAa,OAAA,GAAU,EAAA,EAAI,IAAA,EAAe;AAC5E,EAAA,MAAM,cAAA,GAAiB,uBAAuB,IAAI,CAAA;AAClD,EAAA,IAAI,CAAC,cAAA,CAAe,GAAG,CAAA,IAAK,cAAA,KAAmB,QAAW,OAAO,MAAA;AACjE,EAAA,MAAM,OAAA,GAAA,CAAW,2BAA2B,OAAO,CAAA,EAAG,eAAe,0BAAA,EAA4B,OAAA,CAAQ,QAAQ,EAAE,CAAA;AACnH,EAAA,OAAO,CAAA,EAAG,OAAO,CAAA,MAAA,EAAS,GAAA,CAAI,IAAA,EAAM,CAAA,EAAG,cAAA,GAAiB,CAAA,CAAA,EAAI,cAAc,CAAA,CAAA,GAAK,EAAE,CAAA,CAAA;AACnF;AAEO,SAAS,oBAAA,CAAqB,GAAA,EAAa,OAAA,GAAU,EAAA,EAAI,IAAA,EAAe;AAC7E,EAAA,MAAM,cAAA,GAAiB,uBAAuB,IAAI,CAAA;AAClD,EAAA,IAAI,CAAC,cAAA,CAAe,GAAG,KAAK,cAAA,KAAmB,MAAA,SAAkB,EAAC;AAClE,EAAA,MAAM,SAAA,GAAA,CAAa,2BAA2B,OAAO,CAAA,EAAG,eAAe,0BAAA,EAA4B,OAAA,CAAQ,QAAQ,EAAE,CAAA;AACrH,EAAA,MAAM,QAAA,GAAW,CAAC,SAAA,EAAW,GAAG,mBAAA,CAAoB,GAAA,CAAI,CAAC,OAAA,KAAY,OAAA,CAAQ,OAAA,CAAQ,MAAA,EAAQ,EAAE,CAAC,CAAC,CAAA;AACjG,EAAA,OAAO,CAAC,GAAG,IAAI,GAAA,CAAI,QAAQ,CAAC,CAAA,CAAE,GAAA,CAAI,CAAC,OAAA,KAAY,CAAA,EAAG,OAAO,CAAA,MAAA,EAAS,GAAA,CAAI,MAAM,CAAA,EAAG,iBAAiB,CAAA,CAAA,EAAI,cAAc,CAAA,CAAA,GAAK,EAAE,CAAA,CAAE,CAAA;AAC7H","file":"chunk-27VBKY3J.js","sourcesContent":["import { getTaxVaultHostChainConfig } from \"./hostRuntimeConfig\";\n\nconst DEFAULT_IPFS_IMAGE_GATEWAY = \"https://flap.mypinata.cloud\";\nconst IPFS_IMAGE_GATEWAYS = [\"https://flap.mypinata.cloud\", \"https://magenta-naval-penguin-822.mypinata.cloud\"] as const;\nconst CID_RE = /^(?:Qm[1-9A-HJ-NP-Za-km-z]{44}|b[a-z2-7]{20,})$/;\nconst PATH_SEGMENT_RE = /^[A-Za-z0-9._~-]+$/;\n\nexport function isIpfsImageCid(value: string) {\n return typeof value === \"string\" && value.length <= 128 && CID_RE.test(value.trim());\n}\n\nexport function normalizeIpfsImagePath(value: string | undefined) {\n if (value === undefined) return \"\";\n if (typeof value !== \"string\") return undefined;\n const trimmed = value.trim();\n if (!trimmed || trimmed.length > 512 || trimmed.startsWith(\"/\") || trimmed.endsWith(\"/\")) return undefined;\n const segments = trimmed.split(\"/\");\n if (segments.some((segment) => !segment || segment === \".\" || segment === \"..\" || !PATH_SEGMENT_RE.test(segment))) return undefined;\n return segments.join(\"/\");\n}\n\nexport function resolveIpfsImageUrl(cid: string, chainId = 56, path?: string) {\n const normalizedPath = normalizeIpfsImagePath(path);\n if (!isIpfsImageCid(cid) || normalizedPath === undefined) return undefined;\n const gateway = (getTaxVaultHostChainConfig(chainId)?.ipfsGateway ?? DEFAULT_IPFS_IMAGE_GATEWAY).replace(/\\/+$/, \"\");\n return `${gateway}/ipfs/${cid.trim()}${normalizedPath ? `/${normalizedPath}` : \"\"}`;\n}\n\nexport function resolveIpfsImageUrls(cid: string, chainId = 56, path?: string) {\n const normalizedPath = normalizeIpfsImagePath(path);\n if (!isIpfsImageCid(cid) || normalizedPath === undefined) return [];\n const preferred = (getTaxVaultHostChainConfig(chainId)?.ipfsGateway ?? DEFAULT_IPFS_IMAGE_GATEWAY).replace(/\\/+$/, \"\");\n const gateways = [preferred, ...IPFS_IMAGE_GATEWAYS.map((gateway) => gateway.replace(/\\/+$/, \"\"))];\n return [...new Set(gateways)].map((gateway) => `${gateway}/ipfs/${cid.trim()}${normalizedPath ? `/${normalizedPath}` : \"\"}`);\n}\n"]}
@@ -1,8 +1,8 @@
1
1
  import { shortenAddress, isValidAddress, ZERO_ADDRESS } from './chunk-B4WKI3EW.js';
2
- import { isIpfsImageCid, resolveIpfsImageUrls, resolveIpfsImageUrl } from './chunk-SAG36LUR.js';
2
+ import { isIpfsImageCid, resolveIpfsImageUrls, resolveIpfsImageUrl } from './chunk-27VBKY3J.js';
3
3
  import { getTaxVaultHostChainConfig } from './chunk-FUOBTZMQ.js';
4
- import * as React8 from 'react';
5
- import { createContext, useContext, useState, useEffect, useMemo } from 'react';
4
+ import * as React9 from 'react';
5
+ import { createContext, useContext, useState, useEffect, useMemo, createElement } from 'react';
6
6
  import { Loader2, ExternalLink, AlertTriangle, CheckCircle2, Info, 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';
@@ -136,7 +136,7 @@ var buttonVariants = cva(
136
136
  }
137
137
  }
138
138
  );
139
- var Button = React8.forwardRef(
139
+ var Button = React9.forwardRef(
140
140
  ({ className, variant, size, asChild = false, loading = false, disabled, children, ...props }, ref) => {
141
141
  const Comp = asChild ? Slot : "button";
142
142
  if (asChild) {
@@ -178,8 +178,8 @@ function normalizeBinanceImageUrl(value) {
178
178
  }
179
179
  }
180
180
  function BinanceImage({ alt, src, fallback = null, className, onError, ...props }) {
181
- const safeSrc = React8.useMemo(() => normalizeBinanceImageUrl(src), [src]);
182
- const [failedSrc, setFailedSrc] = React8.useState(null);
181
+ const safeSrc = React9.useMemo(() => normalizeBinanceImageUrl(src), [src]);
182
+ const [failedSrc, setFailedSrc] = React9.useState(null);
183
183
  const {
184
184
  alt: _unsafeAlt,
185
185
  decoding: _unsafeDecoding,
@@ -213,7 +213,7 @@ function BinanceImage({ alt, src, fallback = null, className, onError, ...props
213
213
  )
214
214
  );
215
215
  }
216
- var Card = React8.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
216
+ var Card = React9.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
217
217
  "div",
218
218
  {
219
219
  "data-flap-ui": "card",
@@ -226,19 +226,19 @@ var Card = React8.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ j
226
226
  }
227
227
  ));
228
228
  Card.displayName = "Card";
229
- var CardHeader = React8.forwardRef(
229
+ var CardHeader = React9.forwardRef(
230
230
  ({ 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
231
  );
232
232
  CardHeader.displayName = "CardHeader";
233
- var CardTitle = React8.forwardRef(
233
+ var CardTitle = React9.forwardRef(
234
234
  ({ 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
235
  );
236
236
  CardTitle.displayName = "CardTitle";
237
- var CardDescription = React8.forwardRef(
237
+ var CardDescription = React9.forwardRef(
238
238
  ({ className, ...props }, ref) => /* @__PURE__ */ jsx("p", { "data-flap-ui": "card-description", ref, className: cn("text-sm leading-6 text-[#84888C]", className), ...props })
239
239
  );
240
240
  CardDescription.displayName = "CardDescription";
241
- var CardContent = React8.forwardRef(
241
+ var CardContent = React9.forwardRef(
242
242
  ({ 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
243
  );
244
244
  CardContent.displayName = "CardContent";
@@ -363,20 +363,20 @@ function WarningIcon({ className }) {
363
363
  ] });
364
364
  }
365
365
  function ExternalLink2({ url, children, locale, className, copy }) {
366
- const [open, setOpen] = React8.useState(false);
367
- const [acknowledged, setAcknowledged] = React8.useState(false);
368
- const [mounted, setMounted] = React8.useState(false);
366
+ const [open, setOpen] = React9.useState(false);
367
+ const [acknowledged, setAcknowledged] = React9.useState(false);
368
+ const [mounted, setMounted] = React9.useState(false);
369
369
  const text = { ...COPY[resolveLocale(locale)], ...copy };
370
- const safeUrl = React8.useMemo(() => normalizeExternalUrl(url), [url]);
370
+ const safeUrl = React9.useMemo(() => normalizeExternalUrl(url), [url]);
371
371
  const canProceed = acknowledged && Boolean(safeUrl);
372
- React8.useEffect(() => {
372
+ React9.useEffect(() => {
373
373
  setMounted(true);
374
374
  }, []);
375
- const close = React8.useCallback(() => {
375
+ const close = React9.useCallback(() => {
376
376
  setOpen(false);
377
377
  setAcknowledged(false);
378
378
  }, []);
379
- React8.useEffect(() => {
379
+ React9.useEffect(() => {
380
380
  if (!open) return;
381
381
  const onKey = (event) => {
382
382
  if (event.key === "Escape") close();
@@ -526,7 +526,7 @@ function ExternalLink2({ url, children, locale, className, copy }) {
526
526
  ) : null
527
527
  ] });
528
528
  }
529
- var Input = React8.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
529
+ var Input = React9.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
530
530
  "input",
531
531
  {
532
532
  "data-flap-ui": "input",
@@ -540,26 +540,28 @@ var Input = React8.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */
540
540
  ));
541
541
  Input.displayName = "Input";
542
542
  function IpfsImage({ alt, cid, path, validationPath, className, decoding = "async", loading = "lazy", onError, ...props }) {
543
- const urls = React8.useMemo(() => resolveIpfsImageUrls(cid, 56, path), [cid, path]);
544
- const [urlIndex, setUrlIndex] = React8.useState(0);
543
+ const urls = React9.useMemo(() => resolveIpfsImageUrls(cid, 56, path), [cid, path]);
544
+ const resourceKey = urls.join("\n");
545
+ const [fallbackState, setFallbackState] = React9.useState({ key: resourceKey, index: 0 });
546
+ const urlIndex = fallbackState.key === resourceKey ? fallbackState.index : 0;
545
547
  const src = urls[urlIndex];
546
- React8.useEffect(() => {
547
- setUrlIndex(0);
548
- }, [cid, path]);
548
+ const { src: ignoredSrc, srcSet: ignoredSrcSet, dangerouslySetInnerHTML: ignoredHtml, ...safeProps } = props;
549
549
  if (!src) return null;
550
550
  return (
551
551
  // eslint-disable-next-line @next/next/no-img-element -- IpfsImage owns CID-to-gateway fallback; next/image cannot represent this boundary.
552
- /* @__PURE__ */ jsx(
552
+ /* @__PURE__ */ createElement(
553
553
  "img",
554
554
  {
555
- ...props,
555
+ ...safeProps,
556
+ key: resourceKey,
556
557
  alt,
557
558
  className: cn("block max-w-full", className),
558
559
  decoding,
559
560
  loading,
561
+ referrerPolicy: "no-referrer",
560
562
  onError: (event) => {
561
563
  if (urlIndex < urls.length - 1) {
562
- setUrlIndex((index) => Math.min(index + 1, urls.length - 1));
564
+ setFallbackState({ key: resourceKey, index: Math.min(urlIndex + 1, urls.length - 1) });
563
565
  return;
564
566
  }
565
567
  onError?.(event);
@@ -575,11 +577,33 @@ function IpfsBackground({ cid, className, imageClassName, overlayClassName, ...p
575
577
  overlayClassName ? /* @__PURE__ */ jsx("div", { className: cn("absolute inset-0", overlayClassName) }) : null
576
578
  ] });
577
579
  }
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
+ }
578
602
  function NftMetadataImage({ alt, tokenId, fallback = null, className, decoding = "async", loading = "lazy", onError, ...props }) {
579
603
  const sdk = useFlapSdk();
580
- const [metadata, setMetadata] = React8.useState(null);
581
- const [state, setState] = React8.useState("loading");
582
- React8.useEffect(() => {
604
+ const [metadata, setMetadata] = React9.useState(null);
605
+ const [state, setState] = React9.useState("loading");
606
+ React9.useEffect(() => {
583
607
  let cancelled = false;
584
608
  setState("loading");
585
609
  setMetadata(null);
@@ -1439,38 +1463,38 @@ var clock = (seconds) => `${Math.floor(seconds / 60)}:${Math.floor(seconds % 60)
1439
1463
  function ConsumerVideoSessionPlayer({ consumer, startClip = 0, label, fallback = null, className, autoPlay = false, muted = false }) {
1440
1464
  const sdk = useFlapSdk();
1441
1465
  const { chainId } = sdk.context;
1442
- const readContractRef = React8.useRef(sdk.readContract);
1466
+ const readContractRef = React9.useRef(sdk.readContract);
1443
1467
  readContractRef.current = sdk.readContract;
1444
- const reader = React8.useMemo(() => createConsumerVideoSessionReader({
1468
+ const reader = React9.useMemo(() => createConsumerVideoSessionReader({
1445
1469
  context: { chainId },
1446
1470
  readContract: (request) => readContractRef.current(request)
1447
1471
  }, consumer), [chainId, consumer]);
1448
- const sessionRef = React8.useRef(null);
1449
- const controllerRef = React8.useRef(null);
1450
- const videoRef = React8.useRef(null);
1451
- const frameRef = React8.useRef(null);
1452
- const playIntent = React8.useRef(autoPlay);
1453
- const autoPlayRef = React8.useRef(autoPlay);
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);
1454
1478
  autoPlayRef.current = autoPlay;
1455
- const [snapshot, setSnapshot] = React8.useState(initialSnapshot);
1456
- const [mediaState, setMediaState] = React8.useState("loading");
1457
- const [time, setTime] = React8.useState(0);
1458
- const [paused, setPaused] = React8.useState(true);
1459
- const [isMuted, setIsMuted] = React8.useState(muted);
1460
- const [volume, setVolume] = React8.useState(1);
1461
- React8.useEffect(() => {
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(() => {
1462
1486
  setIsMuted(muted);
1463
1487
  }, [muted]);
1464
- const [buffering, setBuffering] = React8.useState(false);
1465
- const [page, setPage] = React8.useState(0);
1466
- const [jump, setJump] = React8.useState("");
1488
+ const [buffering, setBuffering] = React9.useState(false);
1489
+ const [page, setPage] = React9.useState(0);
1490
+ const [jump, setJump] = React9.useState("");
1467
1491
  const position = videoClipPosition(snapshot.clips, time, snapshot.mediaStartPtsMs);
1468
1492
  const duration = Number(snapshot.endPtsMs - snapshot.firstPtsMs) / 1e3;
1469
1493
  const globalTime = Math.max(0, Math.min(duration, Number(snapshot.mediaStartPtsMs - snapshot.firstPtsMs) / 1e3 + time));
1470
1494
  const activeIndex = position?.index ?? snapshot.start;
1471
1495
  const strings = videoPlayerMessages[sdk.i18n.locale.split("-")[0]] ?? videoPlayerMessages.en;
1472
1496
  const text = (key, params) => sdk.i18n.t(`runtime.video.${key}`, strings[key], params);
1473
- React8.useEffect(() => {
1497
+ React9.useEffect(() => {
1474
1498
  const session = new ConsumerVideoSession(reader, setSnapshot);
1475
1499
  sessionRef.current = session;
1476
1500
  setSnapshot(initialSnapshot);
@@ -1487,7 +1511,7 @@ function ConsumerVideoSessionPlayer({ consumer, startClip = 0, label, fallback =
1487
1511
  sessionRef.current = null;
1488
1512
  };
1489
1513
  }, [reader, startClip]);
1490
- React8.useEffect(() => {
1514
+ React9.useEffect(() => {
1491
1515
  if (!videoRef.current) return;
1492
1516
  const controller = new VideoSessionController(videoRef.current, async () => (await import('./mpegts-536UQHCG.js')).default, setMediaState);
1493
1517
  controllerRef.current = controller;
@@ -1496,7 +1520,7 @@ function ConsumerVideoSessionPlayer({ consumer, startClip = 0, label, fallback =
1496
1520
  controllerRef.current = null;
1497
1521
  };
1498
1522
  }, []);
1499
- React8.useEffect(() => {
1523
+ React9.useEffect(() => {
1500
1524
  const controller = controllerRef.current;
1501
1525
  const session = sessionRef.current;
1502
1526
  if (!controller || !session) return;
@@ -1515,7 +1539,7 @@ function ConsumerVideoSessionPlayer({ consumer, startClip = 0, label, fallback =
1515
1539
  playIntent: () => playIntent.current
1516
1540
  }, snapshot.play, snapshot.resumeAt);
1517
1541
  }, [snapshot.sessionId, snapshot.revision, snapshot.state]);
1518
- React8.useEffect(() => {
1542
+ React9.useEffect(() => {
1519
1543
  setPage(Math.floor(activeIndex / VIDEO_PICKER_PAGE_SIZE));
1520
1544
  }, [activeIndex]);
1521
1545
  const advance = () => {
@@ -1525,7 +1549,7 @@ function ConsumerVideoSessionPlayer({ consumer, startClip = 0, label, fallback =
1525
1549
  void sessionRef.current?.advance(current.index);
1526
1550
  }
1527
1551
  };
1528
- React8.useEffect(() => {
1552
+ React9.useEffect(() => {
1529
1553
  const video = videoRef.current;
1530
1554
  const current = videoClipPosition(snapshot.clips, video?.currentTime ?? 0, snapshot.mediaStartPtsMs);
1531
1555
  if (video && current && (current.index >= snapshot.start + snapshot.clips.length - 2 || video.ended)) void sessionRef.current?.advance(current.index);
@@ -1752,10 +1776,10 @@ async function loadMpegts() {
1752
1776
  return (await import('./mpegts-536UQHCG.js')).default;
1753
1777
  }
1754
1778
  function VideoClipSessionPlayer({ clips, label, fallback = null, className, autoPlay = false, muted = false }) {
1755
- const videoRef = React8.useRef(null);
1756
- const controllerRef = React8.useRef(null);
1757
- const [state, setState] = React8.useState("loading");
1758
- React8.useEffect(() => {
1779
+ const videoRef = React9.useRef(null);
1780
+ const controllerRef = React9.useRef(null);
1781
+ const [state, setState] = React9.useState("loading");
1782
+ React9.useEffect(() => {
1759
1783
  if (!videoRef.current) return;
1760
1784
  const controller = new VideoSessionController(videoRef.current, loadMpegts, setState);
1761
1785
  controllerRef.current = controller;
@@ -1764,7 +1788,7 @@ function VideoClipSessionPlayer({ clips, label, fallback = null, className, auto
1764
1788
  controllerRef.current = null;
1765
1789
  };
1766
1790
  }, []);
1767
- React8.useEffect(() => {
1791
+ React9.useEffect(() => {
1768
1792
  void controllerRef.current?.update(clips, autoPlay);
1769
1793
  }, [clips, autoPlay]);
1770
1794
  const showVideo = state === "loading" || state === "ready";
@@ -1787,6 +1811,6 @@ function VideoClipSessionPlayer({ clips, label, fallback = null, className, auto
1787
1811
  ] });
1788
1812
  }
1789
1813
 
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-IN34R3DY.js.map
1792
- //# sourceMappingURL=chunk-IN34R3DY.js.map
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