From e19eea4fb217d949351425e99c4370ed83b7ba98 Mon Sep 17 00:00:00 2001 From: Fara Woolf Date: Tue, 12 Dec 2023 11:49:49 -0600 Subject: [PATCH] feat: html video and audio inscription types, closes #4077 and #3556 --- scripts/generate-manifest.js | 11 ++++-- .../_collectible-types/collectible-audio.tsx | 19 ++++++++++ .../_collectible-types/collectible-iframe.tsx | 35 +++++++++++++++++ .../_collectible-types/collectible-image.tsx | 4 +- .../collectible-placeholder.layout.tsx | 19 ++++++++++ .../components/bitcoin/inscription.tsx | 38 +++++++++++++++---- .../components/collectible-hover.tsx | 15 ++++++-- .../components/collectible-item.layout.tsx | 2 +- .../components/image-unavailable.tsx | 23 +++++------ .../bitcoin/ordinals/inscription.hooks.ts | 29 +++++++++++++- src/app/ui/components/icons/audio-icon.tsx | 23 +++++++++++ src/app/ui/components/iframe.tsx | 34 +++++++++++++++++ src/shared/models/inscription.model.ts | 37 +++++++++++++++++- 13 files changed, 254 insertions(+), 35 deletions(-) create mode 100644 src/app/features/collectibles/components/_collectible-types/collectible-audio.tsx create mode 100644 src/app/features/collectibles/components/_collectible-types/collectible-iframe.tsx create mode 100644 src/app/features/collectibles/components/_collectible-types/collectible-placeholder.layout.tsx create mode 100644 src/app/ui/components/icons/audio-icon.tsx create mode 100644 src/app/ui/components/iframe.tsx diff --git a/scripts/generate-manifest.js b/scripts/generate-manifest.js index 877d5ef8b6c..498eac28e6a 100644 --- a/scripts/generate-manifest.js +++ b/scripts/generate-manifest.js @@ -30,10 +30,15 @@ const environmentIcons = { }, }; +const devCsp = + "script-src 'self' 'wasm-unsafe-eval'; object-src 'self'; frame-src https://ordinals.com/; frame-ancestors 'none';"; + +const prodCsp = `default-src 'none'; connect-src *; style-src 'unsafe-inline'; img-src 'self' data: https:; script-src 'self' 'wasm-unsafe-eval'; object-src 'none'; frame-src https://ordinals.com/; frame-ancestors 'none';`; + const contentSecurityPolicyEnvironment = { - development: - "script-src 'self' 'wasm-unsafe-eval'; object-src 'self'; frame-src 'none'; frame-ancestors 'none';", - production: `default-src 'none'; connect-src *; style-src 'unsafe-inline'; img-src 'self' data: https:; script-src 'self' 'wasm-unsafe-eval'; object-src 'none'; frame-src 'none'; frame-ancestors 'none';`, + testing: prodCsp, + development: devCsp, + production: prodCsp, }; const defaultIconEnvironment = { diff --git a/src/app/features/collectibles/components/_collectible-types/collectible-audio.tsx b/src/app/features/collectibles/components/_collectible-types/collectible-audio.tsx new file mode 100644 index 00000000000..3688d5b3037 --- /dev/null +++ b/src/app/features/collectibles/components/_collectible-types/collectible-audio.tsx @@ -0,0 +1,19 @@ +import { ReactNode } from 'react'; + +import { AudioIcon } from '@app/ui/components/icons/audio-icon'; + +import { CollectibleItemLayout, CollectibleItemLayoutProps } from '../collectible-item.layout'; +import { CollectiblePlaceholderLayout } from './collectible-placeholder.layout'; + +interface CollectibleAudioProps extends Omit { + icon: ReactNode; +} +export function CollectibleAudio({ icon, ...props }: CollectibleAudioProps) { + return ( + + + + + + ); +} diff --git a/src/app/features/collectibles/components/_collectible-types/collectible-iframe.tsx b/src/app/features/collectibles/components/_collectible-types/collectible-iframe.tsx new file mode 100644 index 00000000000..4b413b68dda --- /dev/null +++ b/src/app/features/collectibles/components/_collectible-types/collectible-iframe.tsx @@ -0,0 +1,35 @@ +import { ReactNode, useState } from 'react'; + +import { Iframe } from '@app/ui/components/iframe'; + +import { CollectibleItemLayout, CollectibleItemLayoutProps } from '../collectible-item.layout'; +import { ImageUnavailable } from '../image-unavailable'; + +interface CollectibleIframeProps extends Omit { + icon: ReactNode; + src: string; +} +export function CollectibleIframe({ icon, src, ...props }: CollectibleIframeProps) { + const [isError, setIsError] = useState(false); + + if (isError) + return ( + + + + ); + + return ( + +