@ludo.ninja/components 2.2.35 → 2.2.36

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 (37) hide show
  1. package/build/api/server-search/queries/useFetchFindAllTopEntitiesByName/index.d.ts +6 -6
  2. package/build/api/server-search/queries/useFetchFindAllTopEntitiesByName/index.js +4 -7
  3. package/build/components/search/searchSuggestions/index.d.ts +2 -2
  4. package/build/components/search/searchSuggestions/index.js +3 -45
  5. package/build/entities/asset/AssetMediasViews.js +6 -6
  6. package/build/entities/asset/builder.js +2 -2
  7. package/build/entities/asset/{assetMediasOpengraph.d.ts → getAssetMediasOpengraph.d.ts} +1 -1
  8. package/build/entities/asset/{assetMediasOpengraph.js → getAssetMediasOpengraph.js} +7 -7
  9. package/build/entities/asset/getAssetMiniatureUrl.d.ts +4 -0
  10. package/build/entities/asset/getAssetMiniatureUrl.js +37 -0
  11. package/build/entities/asset/types.d.ts +1 -1
  12. package/build/entities/collection/builder.d.ts +3 -0
  13. package/build/entities/collection/builder.js +31 -0
  14. package/build/entities/collection/types.d.ts +17 -0
  15. package/build/entities/collection/types.js +2 -0
  16. package/build/entities/creation/CreationMediaView.d.ts +4 -0
  17. package/build/entities/creation/CreationMediaView.js +46 -0
  18. package/build/entities/creation/builder.d.ts +3 -0
  19. package/build/entities/creation/builder.js +63 -0
  20. package/build/entities/creation/collectionCreationBuilder.d.ts +3 -0
  21. package/build/entities/creation/collectionCreationBuilder.js +25 -0
  22. package/build/entities/creation/types.d.ts +23 -0
  23. package/build/entities/creation/types.js +2 -0
  24. package/build/entities/gallery/builder.d.ts +3 -0
  25. package/build/entities/gallery/builder.js +35 -0
  26. package/build/entities/gallery/types.d.ts +18 -0
  27. package/build/entities/gallery/types.js +2 -0
  28. package/build/entities/labelCreationType/data.d.ts +3 -0
  29. package/build/entities/labelCreationType/data.js +36 -0
  30. package/build/entities/labelCreationType/types.d.ts +45 -0
  31. package/build/entities/labelCreationType/types.js +42 -0
  32. package/build/entities/media/builder.d.ts +4 -0
  33. package/build/entities/media/builder.js +11 -1
  34. package/build/entities/media/types.d.ts +1 -1
  35. package/build/entities/media/urls.d.ts +31 -0
  36. package/build/entities/media/urls.js +125 -0
  37. package/package.json +1 -1
@@ -1,7 +1,7 @@
1
- import { ApolloClient, NormalizedCacheObject } from '@apollo/client';
2
- import { searchSchema } from '@ludo.ninja/api';
3
- import { ProfileEntity } from '@ludo.ninja/core';
4
- import AssetEntity from '../../../../dto/AssetSearchEntity';
1
+ import { TAsset } from '../../../../entities/asset/types';
2
+ import { ApolloClient, NormalizedCacheObject } from "@apollo/client";
3
+ import { searchSchema } from "@ludo.ninja/api";
4
+ import { ProfileEntity } from "@ludo.ninja/core";
5
5
  export declare const prefetchFindAllTopEntitiesByName: ({ name, pageSize }: searchSchema.IQueryFindAllTopEntitiesByNameArgs, apolloClient: ApolloClient<NormalizedCacheObject>) => Promise<import("@apollo/client").ApolloQueryResult<any> | {
6
6
  data: {
7
7
  findAllTopEntitiesByName: null;
@@ -16,7 +16,7 @@ export declare const useFetchFindAllTopEntitiesByName: () => {
16
16
  pageSize: number;
17
17
  }>>>;
18
18
  topEntities: {
19
- assets: AssetEntity[];
19
+ assets: TAsset[];
20
20
  collections: searchSchema.ICollection[];
21
21
  profiles: ProfileEntity[];
22
22
  } | null;
@@ -32,7 +32,7 @@ declare const _default: {
32
32
  pageSize: number;
33
33
  }>>>;
34
34
  topEntities: {
35
- assets: AssetEntity[];
35
+ assets: TAsset[];
36
36
  collections: searchSchema.ICollection[];
37
37
  profiles: ProfileEntity[];
38
38
  } | null;
@@ -1,20 +1,17 @@
1
1
  "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
2
  Object.defineProperty(exports, "__esModule", { value: true });
6
3
  exports.useFetchFindAllTopEntitiesByName = exports.prefetchFindAllTopEntitiesByName = void 0;
7
- const react_1 = require("react");
4
+ const builder_1 = require("../../../../entities/asset/builder");
8
5
  const api_1 = require("@ludo.ninja/api");
9
6
  const core_1 = require("@ludo.ninja/core");
10
- const AssetSearchEntity_1 = __importDefault(require("../../../../dto/AssetSearchEntity"));
7
+ const react_1 = require("react");
11
8
  const prefetchFindAllTopEntitiesByName = ({ name, pageSize }, apolloClient) => {
12
9
  return apolloClient
13
10
  .query({
14
11
  query: api_1.searchSchema.FindAllTopEntitiesByNameDocument,
15
12
  context: { uri: api_1.hosts.serverSearchHost },
16
13
  variables: { name, pageSize },
17
- fetchPolicy: 'network-only',
14
+ fetchPolicy: "network-only",
18
15
  })
19
16
  .catch(() => {
20
17
  return {
@@ -30,7 +27,7 @@ const useFetchFindAllTopEntitiesByName = () => {
30
27
  uri: api_1.hosts.searchHost,
31
28
  },
32
29
  onCompleted: ({ findAllTopEntitiesByName }) => {
33
- const assets = findAllTopEntitiesByName.assets.map((asset) => new AssetSearchEntity_1.default(asset)) || [];
30
+ const assets = findAllTopEntitiesByName.assets.map((asset) => (0, builder_1.buildAsset)(asset)) || [];
34
31
  const profiles = findAllTopEntitiesByName.profiles.map((profile) => new core_1.ProfileEntity(profile)) || [];
35
32
  setTopEntities({
36
33
  assets,
@@ -1,9 +1,9 @@
1
- import AssetSearchEntity from '../../../dto/AssetSearchEntity';
1
+ import { TAsset } from '../../../entities/asset/types';
2
2
  import { collectionsSchema as schema } from "@ludo.ninja/api";
3
3
  import { ProfileEntity } from "@ludo.ninja/core";
4
4
  import React from "react";
5
5
  interface Props {
6
- assets: AssetSearchEntity[];
6
+ assets: TAsset[];
7
7
  profiles: ProfileEntity[];
8
8
  collections: schema.ICollection[];
9
9
  searchTerm: string;
@@ -10,11 +10,10 @@ const searchSuggestionsItem_1 = __importDefault(require("./searchSuggestionsItem
10
10
  const searchSuggestionsItemSkeleton_1 = require("./searchSuggestionsItem/searchSuggestionsItemSkeleton");
11
11
  const searchSuggestionsNotFound_1 = __importDefault(require("./searchSuggestionsNotFound"));
12
12
  const ItemType_1 = require("../../../dto/common/ItemType");
13
- const Urls_1 = require("../../../dto/common/Media/Urls");
13
+ const getAssetMiniatureUrl_1 = require("../../../entities/asset/getAssetMiniatureUrl");
14
14
  const env_1 = require("../../../store/env");
15
15
  const ScreenWidth_1 = require("../../../styles/ScreenWidth");
16
16
  const Badge_1 = __importDefault(require("../../../system/Badge"));
17
- const _3d_1 = require("../../../utils/3d");
18
17
  const constants_1 = require("@ludo.ninja/core/build/constants");
19
18
  const ludoDomains_1 = require("@ludo.ninja/core/build/ludoDomains");
20
19
  const _4k_1 = require("@ludo.ninja/ui/build/utils/4k");
@@ -73,11 +72,8 @@ const StyledSearchSuggestions = styled_components_1.default.div `
73
72
  // Components
74
73
  const SearchSuggestions = ({ searchTerm, assets, profiles, collections, isLoading }) => {
75
74
  const isNotFound = !assets?.length && !profiles?.length && !collections?.length;
76
- const { getMediaENVDomain, getVideoENVDomain, getAudioENVDomain, NEXT_PUBLIC_STATIC_DOMAIN, NEXT_PUBLIC_ENV_VALUE } = (0, env_1.useEnvStore)((state) => ({
75
+ const { getMediaENVDomain, NEXT_PUBLIC_ENV_VALUE } = (0, env_1.useEnvStore)((state) => ({
77
76
  getMediaENVDomain: state.getMediaDomain,
78
- getVideoENVDomain: state.getVideoDomain,
79
- getAudioENVDomain: state.getAudioDomain,
80
- NEXT_PUBLIC_STATIC_DOMAIN: state.NEXT_PUBLIC_STATIC_DOMAIN,
81
77
  NEXT_PUBLIC_ENV_VALUE: state.NEXT_PUBLIC_ENV_VALUE,
82
78
  }));
83
79
  return ((0, jsx_runtime_1.jsx)(StyledSearchSuggestions, { children: (0, jsx_runtime_1.jsxs)("div", { className: "content", children: [isLoading && (0, jsx_runtime_1.jsx)(searchSuggestionsItemSkeleton_1.SearchSuggestionsItemsSkeleton, {}), !isLoading &&
@@ -86,45 +82,7 @@ const SearchSuggestions = ({ searchTerm, assets, profiles, collections, isLoadin
86
82
  ? [
87
83
  {
88
84
  caption: "NFTs",
89
- children: assets.map((asset) => {
90
- // if (
91
- // asset?.getName()?.toLowerCase() ===
92
- // 'Concerto Para Piano e Pandemia May 5, 2021 at 3pm GMT +1'.toLowerCase()
93
- // ) {
94
- // console.log(
95
- // 'asset?.getAssetMedias()',
96
- // asset?.getAssetMedias()
97
- // );
98
- // console.log('asset', asset);
99
- // }
100
- const currentMedia = asset?.getAssetMedias()[0];
101
- // console.log('currentMedia', currentMedia);
102
- let miniatureUrl = "";
103
- const mimeType = currentMedia?.mimeType;
104
- if (mimeType?.includes("video")) {
105
- miniatureUrl = (0, Urls_1.isExternalMediaVideo)(currentMedia?.previewUrl || null, getVideoENVDomain);
106
- }
107
- if (mimeType?.includes("audio")) {
108
- miniatureUrl = (0, Urls_1.isExternalMediaAudio)(currentMedia?.previewUrl || null, getAudioENVDomain);
109
- }
110
- if ((0, _3d_1.isObject3D)({
111
- media: currentMedia?.url,
112
- mimeType: currentMedia?.mimeType,
113
- })) {
114
- // todo: add for 3d preview
115
- // miniatureUrl = isExternalMediaAudio(
116
- // currentMedia?.previewUrl || null
117
- // );
118
- miniatureUrl = `${constants_1.staticLink}/public/noContent/noContentObject.svg`;
119
- }
120
- if (!miniatureUrl) {
121
- // image and screenshots
122
- miniatureUrl = (0, Urls_1.getAssetImage)(currentMedia?.url, `${constants_1.staticLink}/public/noContent/noContent.svg`, Urls_1.mediaSizes.small, NEXT_PUBLIC_STATIC_DOMAIN);
123
- }
124
- return ((0, jsx_runtime_1.jsx)(searchSuggestionsItem_1.default, { name: asset?.getName(), link: `${ludoDomains_1.ludoDomains[NEXT_PUBLIC_ENV_VALUE]["asset"]}${asset
125
- .getAssetLink()
126
- .replace(`${ItemType_1.LabelKeys.asset}/`, "")}`, imgUrl: miniatureUrl, searchTerm: searchTerm }, `${asset?.getAssetId()}.${Math.random()}`));
127
- }),
85
+ children: assets.map((asset) => ((0, jsx_runtime_1.jsx)(searchSuggestionsItem_1.default, { name: asset?.name, link: `${ludoDomains_1.ludoDomains[NEXT_PUBLIC_ENV_VALUE]["asset"]}${asset.assetLink.replace(`${ItemType_1.LabelKeys.asset}/`, "")}`, imgUrl: (0, getAssetMiniatureUrl_1.getAssetMiniatureUrl)({ asset }), searchTerm: searchTerm }, `${asset?.assetId}.${Math.random()}`))),
128
86
  },
129
87
  ]
130
88
  : []),
@@ -8,9 +8,9 @@ const jsx_runtime_1 = require("react/jsx-runtime");
8
8
  const assetPage_1 = require("../../components/assetPage");
9
9
  const AssetImage_1 = __importDefault(require("../../components/assetPage/media/AssetImage"));
10
10
  const AssetImage_2 = __importDefault(require("../../components/assetPage/media/AssetImage"));
11
- const Urls_1 = require("../../dto/common/Media/Urls");
12
11
  const getMediaVariant_1 = require("../media/getMediaVariant");
13
12
  const types_1 = require("../media/types");
13
+ const urls_1 = require("../media/urls");
14
14
  const env_1 = require("../../store/env");
15
15
  const constants_1 = require("@ludo.ninja/core/build/constants");
16
16
  const AssetMediasViews = ({ medias }) => {
@@ -30,25 +30,25 @@ const AssetMediasViews = ({ medias }) => {
30
30
  case types_1.EMediaVariants.other:
31
31
  return (0, jsx_runtime_1.jsx)(AssetOtherMediaView, { media: media });
32
32
  default:
33
- return ((0, jsx_runtime_1.jsx)(AssetImage_2.default, { alt: media.alt, imageUrl: "/noContent/noContent.svg", errorImg: "/noContent/noContent.svg" }));
33
+ return ((0, jsx_runtime_1.jsx)(AssetImage_2.default, { alt: media.alt, imageUrl: `${constants_1.staticLink}/public/noContent/noContent.svg`, errorImg: `${constants_1.staticLink}/public/noContent/noContent.svg` }));
34
34
  }
35
35
  });
36
36
  };
37
37
  exports.AssetMediasViews = AssetMediasViews;
38
38
  const AssetImageMediaView = ({ media, isScreenshot }) => {
39
39
  const NEXT_PUBLIC_STATIC_DOMAIN = (0, env_1.useEnvStore)((state) => state.NEXT_PUBLIC_STATIC_DOMAIN);
40
- return ((0, jsx_runtime_1.jsx)(AssetImage_1.default, { alt: media.alt, imageUrl: (0, Urls_1.isExternalMediaImage)(media.media, Urls_1.mediaSizes.regular, NEXT_PUBLIC_STATIC_DOMAIN), errorImg: `${constants_1.staticLink}/public/noContent/noContent.svg`, originalUrl: media.originalUrl, isScreenshot: isScreenshot }));
40
+ return ((0, jsx_runtime_1.jsx)(AssetImage_1.default, { alt: media.alt, imageUrl: (0, urls_1.isExternalMediaImage)(media.media, urls_1.mediaSizes.regular, NEXT_PUBLIC_STATIC_DOMAIN), errorImg: `${constants_1.staticLink}/public/noContent/noContent.svg`, originalUrl: media.originalUrl, isScreenshot: isScreenshot }));
41
41
  };
42
42
  const AssetAudioMediaView = ({ media }) => {
43
43
  const getAudioENVDomain = (0, env_1.useEnvStore)((state) => state.getAudioDomain);
44
- return ((0, jsx_runtime_1.jsx)(assetPage_1.AudioVideoPlayer, { playerType: "audio", poster: null, src: (0, Urls_1.isExternalMediaAudio)(media.media, getAudioENVDomain) }));
44
+ return ((0, jsx_runtime_1.jsx)(assetPage_1.AudioVideoPlayer, { playerType: "audio", poster: null, src: (0, urls_1.isExternalMediaAudio)(media.media, getAudioENVDomain) }));
45
45
  };
46
46
  const AssetVideoMediaView = ({ media }) => {
47
47
  const getVideoENVDomain = (0, env_1.useEnvStore)((state) => state.getVideoDomain);
48
- return ((0, jsx_runtime_1.jsx)(assetPage_1.AudioVideoPlayer, { playerType: "video", poster: null, src: (0, Urls_1.isExternalMediaVideo)(media.media, getVideoENVDomain) }));
48
+ return ((0, jsx_runtime_1.jsx)(assetPage_1.AudioVideoPlayer, { playerType: "video", poster: null, src: (0, urls_1.isExternalMediaVideo)(media.media, getVideoENVDomain) }));
49
49
  };
50
50
  const AssetOtherMediaView = ({ media }) => {
51
51
  const NEXT_PUBLIC_STATIC_DOMAIN = (0, env_1.useEnvStore)((state) => state.NEXT_PUBLIC_STATIC_DOMAIN);
52
- const mediaUrl = (0, Urls_1.isExternalMediaImage)(media.media, Urls_1.mediaSizes.regular, NEXT_PUBLIC_STATIC_DOMAIN);
52
+ const mediaUrl = (0, urls_1.isExternalMediaImage)(media.media, urls_1.mediaSizes.regular, NEXT_PUBLIC_STATIC_DOMAIN);
53
53
  return ((0, jsx_runtime_1.jsx)(AssetImage_2.default, { alt: media.alt, imageUrl: mediaUrl, errorImg: `${constants_1.staticLink}/public/noContent/noContent.svg`, originalUrl: media.originalUrl ?? mediaUrl }));
54
54
  };
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.buildAsset = void 0;
4
- const ItemType_1 = require("../../dto/common/ItemType");
4
+ const types_1 = require("../labelCreationType/types");
5
5
  const builder_1 = require("../media/builder");
6
6
  const core_1 = require("@ludo.ninja/core");
7
7
  const utils_1 = require("@ludo.ninja/utils");
@@ -16,7 +16,7 @@ const buildAsset = (asset) => {
16
16
  })) || [],
17
17
  ownersProfiles: (asset.ownersProfiles || []),
18
18
  ownersAddresses: (asset.ownersAddresses || null),
19
- itemType: ItemType_1.LabelKeys.asset,
19
+ itemType: types_1.LabelKeys.asset,
20
20
  address: asset.address,
21
21
  tokenId: asset.tokenId,
22
22
  name: asset.name,
@@ -1,5 +1,5 @@
1
1
  import { TAsset } from './types';
2
- export declare const assetMediasOpengraph: ({ medias, alt }: {
2
+ export declare const getAssetMediasOpengraph: ({ medias, alt }: {
3
3
  medias: TAsset["medias"];
4
4
  alt: string;
5
5
  }) => import("react/jsx-runtime").JSX.Element | null;
@@ -1,14 +1,14 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.assetMediasOpengraph = void 0;
3
+ exports.getAssetMediasOpengraph = void 0;
4
4
  const jsx_runtime_1 = require("react/jsx-runtime");
5
- const Urls_1 = require("../../dto/common/Media/Urls");
6
5
  const getMediaVariant_1 = require("../media/getMediaVariant");
7
6
  const types_1 = require("../media/types");
7
+ const urls_1 = require("../media/urls");
8
8
  const env_1 = require("../../store/env");
9
9
  // render as function (bug in next js for next/head)
10
10
  // export as function, don't use as Component
11
- const assetMediasOpengraph = ({ medias, alt }) => {
11
+ const getAssetMediasOpengraph = ({ medias, alt }) => {
12
12
  const { NEXT_PUBLIC_STATIC_DOMAIN, getAudioDomain, getVideoDomain } = (0, env_1.useEnvStore)((state) => ({
13
13
  NEXT_PUBLIC_STATIC_DOMAIN: state.NEXT_PUBLIC_STATIC_DOMAIN,
14
14
  getAudioDomain: state.getAudioDomain,
@@ -20,9 +20,9 @@ const assetMediasOpengraph = ({ medias, alt }) => {
20
20
  const mediaVariant = (0, getMediaVariant_1.getMediaVariant)({ media });
21
21
  switch (mediaVariant) {
22
22
  case types_1.EMediaVariants.audio:
23
- return (0, jsx_runtime_1.jsx)("meta", { property: "og:audio", content: (0, Urls_1.isExternalMediaAudio)(media.media, getAudioDomain) });
23
+ return (0, jsx_runtime_1.jsx)("meta", { property: "og:audio", content: (0, urls_1.isExternalMediaAudio)(media.media, getAudioDomain) });
24
24
  case types_1.EMediaVariants.video:
25
- const url = (0, Urls_1.isExternalMediaVideo)(media.media, getVideoDomain);
25
+ const url = (0, urls_1.isExternalMediaVideo)(media.media, getVideoDomain);
26
26
  return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("meta", { property: "og:video", content: url }), (0, jsx_runtime_1.jsx)("meta", { property: "og:video:secure_url", content: url }), (0, jsx_runtime_1.jsx)("meta", { property: "og:video:type", content: "application/x-shockwave-flash" }), (0, jsx_runtime_1.jsx)("meta", { property: "og:image", content: url }), (0, jsx_runtime_1.jsx)("meta", { property: "\u201Dog:image:width\u201D", content: "1280" }), (0, jsx_runtime_1.jsx)("meta", { property: "\u201Dog:image:height\u201D", content: "720" })] }));
27
27
  case types_1.EMediaVariants.object3d:
28
28
  //todo: add preview url
@@ -32,8 +32,8 @@ const assetMediasOpengraph = ({ medias, alt }) => {
32
32
  case types_1.EMediaVariants.other:
33
33
  case types_1.EMediaVariants.screenshot:
34
34
  default:
35
- const urlDefault = (0, Urls_1.isExternalMediaImage)(media.media, Urls_1.mediaSizes.regular, NEXT_PUBLIC_STATIC_DOMAIN);
35
+ const urlDefault = (0, urls_1.isExternalMediaImage)(media.media, urls_1.mediaSizes.regular, NEXT_PUBLIC_STATIC_DOMAIN);
36
36
  return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("meta", { property: "og:image", content: urlDefault }), (0, jsx_runtime_1.jsx)("meta", { property: "og:image:alt", content: alt }), (0, jsx_runtime_1.jsx)("meta", { name: "twitter:image", content: urlDefault }), (0, jsx_runtime_1.jsx)("meta", { property: "twitter:image:alt", content: alt })] }));
37
37
  }
38
38
  };
39
- exports.assetMediasOpengraph = assetMediasOpengraph;
39
+ exports.getAssetMediasOpengraph = getAssetMediasOpengraph;
@@ -0,0 +1,4 @@
1
+ import { TAsset } from './types';
2
+ export declare const getAssetMiniatureUrl: ({ asset }: {
3
+ asset: TAsset;
4
+ }) => string;
@@ -0,0 +1,37 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getAssetMiniatureUrl = void 0;
4
+ const getMediaVariant_1 = require("../media/getMediaVariant");
5
+ const types_1 = require("../media/types");
6
+ const urls_1 = require("../media/urls");
7
+ const env_1 = require("../../store/env");
8
+ const constants_1 = require("@ludo.ninja/core/build/constants");
9
+ const getAssetMiniatureUrl = ({ asset }) => {
10
+ const { NEXT_PUBLIC_STATIC_DOMAIN, getAudioDomain, getVideoDomain } = (0, env_1.useEnvStore)((state) => ({
11
+ NEXT_PUBLIC_STATIC_DOMAIN: state.NEXT_PUBLIC_STATIC_DOMAIN,
12
+ getAudioDomain: state.getAudioDomain,
13
+ getVideoDomain: state.getVideoDomain,
14
+ }));
15
+ const media = asset.medias[0];
16
+ if (!media)
17
+ return `${constants_1.staticLink}/public/noContent/noContent.svg`;
18
+ const mediaVariant = (0, getMediaVariant_1.getMediaVariant)({ media });
19
+ switch (mediaVariant) {
20
+ case types_1.EMediaVariants.audio:
21
+ return (0, urls_1.isExternalMediaAudio)(media.previewUrl || null, getAudioDomain);
22
+ case types_1.EMediaVariants.video:
23
+ return (0, urls_1.isExternalMediaVideo)(media.previewUrl || null, getVideoDomain);
24
+ case types_1.EMediaVariants.object3d:
25
+ // todo: add for 3d preview
26
+ // miniatureUrl = isExternalMediaAudio(
27
+ // currentMedia?.previewUrl || null
28
+ // );
29
+ return `${constants_1.staticLink}/public/noContent/noContentObject.svg`;
30
+ case types_1.EMediaVariants.image:
31
+ case types_1.EMediaVariants.other:
32
+ case types_1.EMediaVariants.screenshot:
33
+ default:
34
+ return (0, urls_1.isExternalMediaImage)(media.media, urls_1.mediaSizes.small, NEXT_PUBLIC_STATIC_DOMAIN);
35
+ }
36
+ };
37
+ exports.getAssetMiniatureUrl = getAssetMiniatureUrl;
@@ -1,4 +1,4 @@
1
- import { LabelKeys } from '../../dto/common/ItemType';
1
+ import { LabelKeys } from '../labelCreationType/types';
2
2
  import { IMedia } from '../media/types';
3
3
  import assetSchema, { IAsset, IProfile, IAttribute } from "@ludo.ninja/api/build/graphql_tools/__generated__/assetsHost/schema";
4
4
  import { BlockChainEntity, MarketPlaceEntity } from "@ludo.ninja/core";
@@ -0,0 +1,3 @@
1
+ import { TCollection } from './types';
2
+ import { collectionsSchema } from "@ludo.ninja/api";
3
+ export declare const buildCollection: (collection: collectionsSchema.ICollection) => TCollection;
@@ -0,0 +1,31 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.buildCollection = void 0;
4
+ const core_1 = require("@ludo.ninja/core");
5
+ const buildCollection = (collection) => {
6
+ const newCollection = {
7
+ collectionTitle: collection.collectionTitle || null,
8
+ collectionId: collection.collectionId,
9
+ collectionItems: collection.items || 0,
10
+ owners: collection.owners || 0,
11
+ creatorsProfiles: collection.creatorsProfiles
12
+ ? collection.creatorsProfiles.map((profile) => new core_1.ProfileEntity(profile))
13
+ : null,
14
+ contractAddress: collection.contractAddress || null,
15
+ collectionMarkets: collection.collectionMarkets?.map((market) => new core_1.MarketPlaceEntity({
16
+ marketName: market?.marketName,
17
+ marketUrl: market?.marketUrl,
18
+ marketId: market?.marketUrl,
19
+ })) || [],
20
+ creatorsAddresses: (collection.creatorsAddresses || []),
21
+ blockchain: new core_1.BlockChainEntity(collection.blockchain),
22
+ rank: collection.rank ? Math.round(collection.rank) : 0,
23
+ likes: collection.likes || 0,
24
+ liked: !!collection.liked,
25
+ };
26
+ return {
27
+ ...newCollection,
28
+ creationLink: `/${newCollection.collectionId}/${newCollection.collectionId}`,
29
+ };
30
+ };
31
+ exports.buildCollection = buildCollection;
@@ -0,0 +1,17 @@
1
+ import { LabelKeys } from '../labelCreationType/types';
2
+ import { BlockChainEntity, MarketPlaceEntity, ProfileEntity } from "@ludo.ninja/core";
3
+ export type TCollection = {
4
+ collectionTitle: string | null;
5
+ collectionId: LabelKeys;
6
+ collectionItems: number;
7
+ owners: number;
8
+ creatorsProfiles: ProfileEntity[] | null;
9
+ contractAddress: string | null;
10
+ collectionMarkets: MarketPlaceEntity[];
11
+ creatorsAddresses: string[];
12
+ blockchain: BlockChainEntity;
13
+ rank: number;
14
+ likes: number;
15
+ liked: boolean;
16
+ creationLink: string;
17
+ };
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,4 @@
1
+ import { IMedia } from '../media/types';
2
+ export declare const CreationMediaView: ({ media }: {
3
+ media: IMedia;
4
+ }) => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,46 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.CreationMediaView = void 0;
7
+ const jsx_runtime_1 = require("react/jsx-runtime");
8
+ const getMediaVariant_1 = require("../media/getMediaVariant");
9
+ const types_1 = require("../media/types");
10
+ const urls_1 = require("../media/urls");
11
+ const env_1 = require("../../store/env");
12
+ const CardAudio_1 = __importDefault(require("../../system/Cards/CardMedia/CardAudio"));
13
+ const CardImage_1 = __importDefault(require("../../system/Cards/CardMedia/CardImage"));
14
+ const CardVideo_1 = __importDefault(require("../../system/Cards/CardMedia/CardVideo"));
15
+ const constants_1 = require("@ludo.ninja/core/build/constants");
16
+ const CreationMediaView = ({ media }) => {
17
+ const mediaVariant = (0, getMediaVariant_1.getMediaVariant)({ media });
18
+ switch (mediaVariant) {
19
+ case types_1.EMediaVariants.other:
20
+ case types_1.EMediaVariants.screenshot:
21
+ case types_1.EMediaVariants.image:
22
+ return (0, jsx_runtime_1.jsx)(ImageMediaView, { media: media });
23
+ case types_1.EMediaVariants.audio:
24
+ return (0, jsx_runtime_1.jsx)(AudioMediaView, { media: media });
25
+ case types_1.EMediaVariants.video:
26
+ return (0, jsx_runtime_1.jsx)(VideoMediaView, { media: media });
27
+ case types_1.EMediaVariants.object3d:
28
+ //todo: add previewUrl 3d
29
+ return ((0, jsx_runtime_1.jsx)(CardImage_1.default, { alt: media.alt, imgSrc: `${constants_1.staticLink}/public/noContent/noContentObject.svg`, errorImg: `${constants_1.staticLink}/public/noContent/noContentObject.svg` }));
30
+ default:
31
+ return ((0, jsx_runtime_1.jsx)(CardImage_1.default, { alt: media.alt, imgSrc: `${constants_1.staticLink}/public/noContent/noContent.svg`, errorImg: `${constants_1.staticLink}/public/noContent/noContent.svg` }));
32
+ }
33
+ };
34
+ exports.CreationMediaView = CreationMediaView;
35
+ const ImageMediaView = ({ media }) => {
36
+ const NEXT_PUBLIC_STATIC_DOMAIN = (0, env_1.useEnvStore)((state) => state.NEXT_PUBLIC_STATIC_DOMAIN);
37
+ return ((0, jsx_runtime_1.jsx)(CardImage_1.default, { alt: media.alt, imgSrc: (0, urls_1.isExternalMediaImage)(media.media, urls_1.mediaSizes.small, NEXT_PUBLIC_STATIC_DOMAIN), errorImg: `${constants_1.staticLink}/public/noContent/noContent.svg` }));
38
+ };
39
+ const AudioMediaView = ({ media }) => {
40
+ const getAudioENVDomain = (0, env_1.useEnvStore)((state) => state.getAudioDomain);
41
+ return ((0, jsx_runtime_1.jsx)(CardAudio_1.default, { alt: media.alt, audioSrc: (0, urls_1.isExternalMediaAudio)(media.media, getAudioENVDomain), imgSrc: `${constants_1.staticLink}/public/noContent/noContentAudio.svg`, errorImg: `${constants_1.staticLink}/public/noContent/noContentAudio.svg` }));
42
+ };
43
+ const VideoMediaView = ({ media }) => {
44
+ const getVideoENVDomain = (0, env_1.useEnvStore)((state) => state.getVideoDomain);
45
+ return ((0, jsx_runtime_1.jsx)(CardVideo_1.default, { alt: media.alt, videoSrc: (0, urls_1.isExternalMediaVideo)(media.media, getVideoENVDomain), errorImg: `${constants_1.staticLink}/public/noContent/noContent.svg` }));
46
+ };
@@ -0,0 +1,3 @@
1
+ import { TCreation } from './types';
2
+ import { searchSchema as schema } from "@ludo.ninja/api";
3
+ export declare const buildCreation: (creation: schema.ICreation) => TCreation;
@@ -0,0 +1,63 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.buildCreation = void 0;
7
+ const data_1 = __importDefault(require("../labelCreationType/data"));
8
+ const types_1 = require("../labelCreationType/types");
9
+ const builder_1 = require("../media/builder");
10
+ const core_1 = require("@ludo.ninja/core");
11
+ const buildCreation = (creation) => {
12
+ const newCreation = {
13
+ itemId: creation.itemId || "",
14
+ id: creation.id || "",
15
+ itemType: creation.itemType,
16
+ blockchain: new core_1.BlockChainEntity(creation.blockchain),
17
+ address: creation.address || "",
18
+ tokenId: creation.tokenId || "",
19
+ // creatorsProfiles : creation.creatorsProfiles,
20
+ // ownersAddresses : creation.ownersAddresses,
21
+ // ownersProfiles : creation.ownersProfiles,
22
+ originalUrls: creation.originalUrls ? creation.originalUrls : null,
23
+ rank: creation.rank ? Math.round(creation.rank) : 0,
24
+ likes: creation.likes || 0,
25
+ isLiked: !!creation.liked,
26
+ name: creation.name || null,
27
+ creatorsAddresses: creation.creatorsAddresses ? creation.creatorsAddresses : null,
28
+ };
29
+ return {
30
+ ...newCreation,
31
+ creationId: `${newCreation.itemType}.${newCreation.itemId}`,
32
+ creationLink: (() => {
33
+ if (newCreation.itemType === types_1.LabelKeys.asset) {
34
+ const blockChainPrivateLabel = newCreation.blockchain.getBlockChainPrivateLabel();
35
+ const link = `/${newCreation.itemType}/${blockChainPrivateLabel}`;
36
+ if (blockChainPrivateLabel === core_1.BlockChainKeys.elrond) {
37
+ return `/${link}/${newCreation.id}`;
38
+ }
39
+ if (blockChainPrivateLabel === core_1.BlockChainKeys.solana) {
40
+ return `/${link}/${newCreation.tokenId}`;
41
+ }
42
+ return `/${link}/${newCreation.address}/${newCreation.tokenId}`;
43
+ }
44
+ return `/${newCreation.itemType}/${newCreation.itemId}`;
45
+ })(),
46
+ label: data_1.default[newCreation.itemType],
47
+ media: (0, builder_1.createCreationMedia)({ creation }),
48
+ creatorAddress: newCreation.creatorsAddresses ? newCreation.creatorsAddresses[0] : null,
49
+ getCuttedSecondName: (isMobileView) => {
50
+ // todo: remove this method from usage, replace to css text-overflow:ellipsis
51
+ if (!newCreation.name)
52
+ return null;
53
+ return isMobileView
54
+ ? newCreation.name && newCreation.name.length >= 20
55
+ ? newCreation.name.substring(0, 22).concat("...")
56
+ : newCreation.name
57
+ : newCreation.name && newCreation.name.length >= 11
58
+ ? newCreation.name?.substring(0, 13).concat("...")
59
+ : newCreation.name;
60
+ },
61
+ };
62
+ };
63
+ exports.buildCreation = buildCreation;
@@ -0,0 +1,3 @@
1
+ import { LabelKeys } from '../labelCreationType/types';
2
+ import { collectionsSchema as schema } from "@ludo.ninja/api";
3
+ export declare const buildCollectionCreation: (creation: schema.ICollectionAsset, type?: LabelKeys) => import("./types").TCreation;
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.buildCollectionCreation = void 0;
4
+ const builder_1 = require("./builder");
5
+ const types_1 = require("../labelCreationType/types");
6
+ const utils_1 = require("@ludo.ninja/utils");
7
+ const buildCollectionCreation = (creation, type) => (0, builder_1.buildCreation)({
8
+ itemId: creation.collectionId || "",
9
+ id: creation.id || "",
10
+ itemType: type ?? types_1.LabelKeys.asset,
11
+ blockchain: creation.blockchain,
12
+ address: creation.address,
13
+ tokenId: creation.tokenId,
14
+ originalUrls: creation.originalUrls
15
+ ? creation.originalUrls.map((el) => (0, utils_1.checkGltfUrl)(el || ""))
16
+ : null,
17
+ rank: creation.rank,
18
+ likes: creation.likes,
19
+ liked: creation.liked,
20
+ name: creation.name,
21
+ creatorsAddresses: creation.creatorsAddresses,
22
+ media: creation?.medias?.[0]?.url || null,
23
+ mimeType: creation?.medias?.[0]?.mimeType,
24
+ });
25
+ exports.buildCollectionCreation = buildCollectionCreation;
@@ -0,0 +1,23 @@
1
+ import { LabelKeys, LabelType } from '../labelCreationType/types';
2
+ import { IMedia } from '../media/types';
3
+ import { BlockChainEntity } from "@ludo.ninja/core";
4
+ export type TCreation = {
5
+ itemId: string;
6
+ id: string;
7
+ itemType: LabelKeys;
8
+ blockchain: BlockChainEntity;
9
+ address: string;
10
+ tokenId: string;
11
+ originalUrls: string[] | null;
12
+ rank: number;
13
+ likes: number;
14
+ isLiked: boolean;
15
+ name: string | null;
16
+ creatorsAddresses: string[] | null;
17
+ creatorAddress: string | null;
18
+ creationId: string;
19
+ creationLink: string;
20
+ label: LabelType;
21
+ media: IMedia;
22
+ getCuttedSecondName: (isMobileView: boolean) => string;
23
+ };
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,3 @@
1
+ import { TGallery } from './types';
2
+ import { galleriesSchema } from "@ludo.ninja/api";
3
+ export declare const buildGallery: (gallery: galleriesSchema.IGalleryV2) => TGallery;
@@ -0,0 +1,35 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.buildGallery = void 0;
7
+ const data_1 = __importDefault(require("../../dto/common/ItemType/data"));
8
+ const core_1 = require("@ludo.ninja/core");
9
+ const buildGallery = (gallery) => {
10
+ const newGallery = {
11
+ galleryId: gallery.galleryId,
12
+ galleryType: gallery.galleryType,
13
+ description: gallery.description || "",
14
+ banner: gallery.banner || null,
15
+ profile: new core_1.ProfileEntity({
16
+ userpic: gallery.userpic,
17
+ username: gallery.username,
18
+ userId: gallery.userId,
19
+ }),
20
+ name: gallery.name,
21
+ username: gallery.username || "",
22
+ userpic: gallery.userpic || "",
23
+ itemsCount: gallery.items ? `${gallery.items > 1 ? `${gallery.items} items` : `${gallery.items} item`}` : "0 items",
24
+ userWallets: (gallery.userWallets || []),
25
+ creationIds: (gallery.creationIds || []),
26
+ };
27
+ return {
28
+ ...newGallery,
29
+ label: data_1.default[newGallery.galleryType],
30
+ creationLink: gallery.galleryType === "likelist"
31
+ ? `/favorites/${gallery.galleryId}`
32
+ : `/${gallery.galleryType}/${gallery.galleryId}`,
33
+ };
34
+ };
35
+ exports.buildGallery = buildGallery;
@@ -0,0 +1,18 @@
1
+ import { LabelKeys, LabelType } from '../labelCreationType/types';
2
+ import { galleriesSchema } from "@ludo.ninja/api";
3
+ import { ProfileEntity } from "@ludo.ninja/core";
4
+ export type TGallery = {
5
+ galleryId: string;
6
+ galleryType: LabelKeys;
7
+ description: string;
8
+ banner: string | null;
9
+ profile: ProfileEntity;
10
+ name: string;
11
+ username: string;
12
+ userpic: string;
13
+ itemsCount: string;
14
+ userWallets: galleriesSchema.IWallet[];
15
+ creationIds: string[];
16
+ label: LabelType;
17
+ creationLink: string;
18
+ };
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,3 @@
1
+ import { LabelItem } from "./types";
2
+ declare const labelsData: LabelItem;
3
+ export default labelsData;
@@ -0,0 +1,36 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const types_1 = require("./types");
4
+ const labelsData = {
5
+ [types_1.LabelKeys.asset]: {
6
+ backgroundColor: types_1.LabelBackground.asset,
7
+ color: types_1.LabelColor.asset,
8
+ text: types_1.LabelText.asset,
9
+ },
10
+ [types_1.LabelKeys.collection]: {
11
+ backgroundColor: types_1.LabelBackground.collection,
12
+ color: types_1.LabelColor.collection,
13
+ text: types_1.LabelText.collection,
14
+ },
15
+ [types_1.LabelKeys.gallery]: {
16
+ backgroundColor: types_1.LabelBackground.gallery,
17
+ color: types_1.LabelColor.gallery,
18
+ text: types_1.LabelText.gallery,
19
+ },
20
+ [types_1.LabelKeys.favorites]: {
21
+ backgroundColor: types_1.LabelBackground.favorites,
22
+ color: types_1.LabelColor.favorites,
23
+ text: types_1.LabelText.favorites,
24
+ },
25
+ [types_1.LabelKeys.likelist]: {
26
+ backgroundColor: types_1.LabelBackground.likelist,
27
+ color: types_1.LabelColor.likelist,
28
+ text: types_1.LabelText.likelist,
29
+ },
30
+ [types_1.LabelKeys.opportunity]: {
31
+ backgroundColor: types_1.LabelBackground.opportunity,
32
+ color: types_1.LabelColor.opportunity,
33
+ text: types_1.LabelText.opportunity,
34
+ },
35
+ };
36
+ exports.default = labelsData;
@@ -0,0 +1,45 @@
1
+ declare enum LabelKeys {
2
+ asset = "asset",
3
+ collection = "collection",
4
+ gallery = "gallery",
5
+ favorites = "favorites",
6
+ likelist = "likelist",
7
+ opportunity = "opportunity"
8
+ }
9
+ declare enum LabelBackground {
10
+ asset = "#F3D6FD",
11
+ collection = "#CDE4FF",
12
+ event = "#CDF8D9",
13
+ gallery = "#FFDFCD",
14
+ favorites = "#CDCFF8",
15
+ likelist = "#CDCFF8",
16
+ opportunity = "#CDF8D9"
17
+ }
18
+ declare enum LabelColor {
19
+ asset = "#9177B1",
20
+ collection = "#6E86C3",
21
+ event = "#77B179",
22
+ gallery = "#B19077",
23
+ favorites = "#7779B1",
24
+ likelist = "#7779B1",
25
+ opportunity = "#77B179"
26
+ }
27
+ declare enum LabelText {
28
+ asset = "nft",
29
+ collection = "collection",
30
+ event = "event",
31
+ gallery = "gallery",
32
+ favorites = "favorites",
33
+ likelist = "liked",
34
+ opportunity = "opportunity"
35
+ }
36
+ type LabelType = {
37
+ backgroundColor: LabelBackground;
38
+ text: LabelText;
39
+ color: LabelColor;
40
+ };
41
+ type LabelItem = {
42
+ [key in LabelKeys]: LabelType;
43
+ };
44
+ export { LabelBackground, LabelText, LabelColor, LabelKeys };
45
+ export type { LabelItem, LabelType };
@@ -0,0 +1,42 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.LabelKeys = exports.LabelColor = exports.LabelText = exports.LabelBackground = void 0;
4
+ var LabelKeys;
5
+ (function (LabelKeys) {
6
+ LabelKeys["asset"] = "asset";
7
+ LabelKeys["collection"] = "collection";
8
+ LabelKeys["gallery"] = "gallery";
9
+ LabelKeys["favorites"] = "favorites";
10
+ LabelKeys["likelist"] = "likelist";
11
+ LabelKeys["opportunity"] = "opportunity";
12
+ })(LabelKeys || (exports.LabelKeys = LabelKeys = {}));
13
+ var LabelBackground;
14
+ (function (LabelBackground) {
15
+ LabelBackground["asset"] = "#F3D6FD";
16
+ LabelBackground["collection"] = "#CDE4FF";
17
+ LabelBackground["event"] = "#CDF8D9";
18
+ LabelBackground["gallery"] = "#FFDFCD";
19
+ LabelBackground["favorites"] = "#CDCFF8";
20
+ LabelBackground["likelist"] = "#CDCFF8";
21
+ LabelBackground["opportunity"] = "#CDF8D9";
22
+ })(LabelBackground || (exports.LabelBackground = LabelBackground = {}));
23
+ var LabelColor;
24
+ (function (LabelColor) {
25
+ LabelColor["asset"] = "#9177B1";
26
+ LabelColor["collection"] = "#6E86C3";
27
+ LabelColor["event"] = "#77B179";
28
+ LabelColor["gallery"] = "#B19077";
29
+ LabelColor["favorites"] = "#7779B1";
30
+ LabelColor["likelist"] = "#7779B1";
31
+ LabelColor["opportunity"] = "#77B179";
32
+ })(LabelColor || (exports.LabelColor = LabelColor = {}));
33
+ var LabelText;
34
+ (function (LabelText) {
35
+ LabelText["asset"] = "nft";
36
+ LabelText["collection"] = "collection";
37
+ LabelText["event"] = "event";
38
+ LabelText["gallery"] = "gallery";
39
+ LabelText["favorites"] = "favorites";
40
+ LabelText["likelist"] = "liked";
41
+ LabelText["opportunity"] = "opportunity";
42
+ })(LabelText || (exports.LabelText = LabelText = {}));
@@ -1,7 +1,11 @@
1
1
  import { IMedia } from './types';
2
2
  import assetSchema from "@ludo.ninja/api/build/graphql_tools/__generated__/assetsHost/schema";
3
+ import searchSchema from "@ludo.ninja/api/build/graphql_tools/__generated__/searchHost/schema";
3
4
  export declare const createMedia: (media: IMedia) => IMedia;
4
5
  export declare const createAssetMedia: ({ media, asset }: {
5
6
  media: assetSchema.IMedia;
6
7
  asset: assetSchema.IAsset;
7
8
  }) => IMedia;
9
+ export declare const createCreationMedia: ({ creation }: {
10
+ creation: searchSchema.ICreation;
11
+ }) => IMedia;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.createAssetMedia = exports.createMedia = void 0;
3
+ exports.createCreationMedia = exports.createAssetMedia = exports.createMedia = void 0;
4
4
  const utils_1 = require("@ludo.ninja/utils");
5
5
  const createMedia = (media) => ({
6
6
  ...media,
@@ -17,3 +17,13 @@ const createAssetMedia = ({ media, asset }) => (0, exports.createMedia)({
17
17
  originalMime: media?.originalMime || null,
18
18
  });
19
19
  exports.createAssetMedia = createAssetMedia;
20
+ const createCreationMedia = ({ creation }) => (0, exports.createMedia)({
21
+ media: creation?.media || creation?.originalUrls?.[0] || "",
22
+ nsfw: null,
23
+ mimeType: creation?.mimeType || null,
24
+ previewUrl: null,
25
+ originalUrl: creation?.originalUrls?.[0] || null,
26
+ alt: `${creation.name || ""} ${creation.address || ""}`,
27
+ originalMime: null,
28
+ });
29
+ exports.createCreationMedia = createCreationMedia;
@@ -2,7 +2,7 @@ export interface IMedia {
2
2
  media: string;
3
3
  mimeType: null | string;
4
4
  nsfw: number | null;
5
- previewUrl: string[] | null;
5
+ previewUrl: string | null;
6
6
  originalUrl?: string | null;
7
7
  alt: string;
8
8
  originalMime: null | string;
@@ -0,0 +1,31 @@
1
+ export declare enum mediaSizes {
2
+ small = "252",
3
+ regular = "510"
4
+ }
5
+ export declare const getUserPicImage: (getMediaDomain: (env?: string) => string, userPic: string, fallbackImage: string, dimensions?: {
6
+ w: number;
7
+ h: number;
8
+ }) => string;
9
+ export declare const getAssetImage: (media: string | null | undefined, fallbackImage: string, dimension: mediaSizes, NEXT_PUBLIC_STATIC_DOMAIN: string) => string;
10
+ export declare const getGalleryBannerImage: (getMediaDomain: (env?: string) => string, galleryId: string | null | undefined, fallbackImage: string, dimensions?: {
11
+ w: number;
12
+ h: number;
13
+ }) => string;
14
+ export declare const getAssetVideoOrigins: (getVideoENVDomain: (env?: string) => string, media: string | null | undefined, fallbackImage: string) => string;
15
+ export declare const getAssetAudioOrigins: (getAudioENVDomain: (env?: string) => string, media: string | null | undefined, fallbackImage: string) => string;
16
+ export declare const getAssetVideoPreviews: (getMediaDomain: (env?: string) => string, assetId: string | null | undefined, fallbackImage: string, dimensions?: {
17
+ w: number;
18
+ h: number;
19
+ }) => string;
20
+ export declare const getAssetObjectOrigins: (getMediaDomain: (env?: string) => string, assetId: string | null | undefined, fallbackImage: string, dimensions?: {
21
+ w: number;
22
+ h: number;
23
+ }) => string;
24
+ export declare const getAssetObjectPreviews: (getMediaDomain: (env?: string) => string, assetId: string | null | undefined, fallbackImage: string, dimensions?: {
25
+ w: number;
26
+ h: number;
27
+ }) => string;
28
+ export declare const isExternalMediaImage: (media: string | null, mediaSize: mediaSizes, NEXT_PUBLIC_STATIC_DOMAIN: string) => string;
29
+ export declare const isExternalMediaVideo: (media: string | null, getVideoENVDomain: (env?: string) => string) => string;
30
+ export declare const isExternalMediaAudio: (media: string | null, getAudioENVDomain: (env?: string) => string) => string;
31
+ export declare const isExternalMediaObject: (media: string | null, getMediaDomain: (env?: string) => string) => string;
@@ -0,0 +1,125 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isExternalMediaObject = exports.isExternalMediaAudio = exports.isExternalMediaVideo = exports.isExternalMediaImage = exports.getAssetObjectPreviews = exports.getAssetObjectOrigins = exports.getAssetVideoPreviews = exports.getAssetAudioOrigins = exports.getAssetVideoOrigins = exports.getGalleryBannerImage = exports.getAssetImage = exports.getUserPicImage = exports.mediaSizes = void 0;
4
+ const constants_1 = require("@ludo.ninja/core/build/constants");
5
+ const utils_1 = require("@ludo.ninja/utils");
6
+ var mediaType;
7
+ (function (mediaType) {
8
+ mediaType["ASSETS"] = "assets/";
9
+ mediaType["USER_PICKS"] = "userpics/";
10
+ mediaType["GALLERY_BANNERS"] = "gallery-banners/";
11
+ })(mediaType || (mediaType = {}));
12
+ var mediaFoldersType;
13
+ (function (mediaFoldersType) {
14
+ mediaFoldersType["IMAGES"] = "images/";
15
+ mediaFoldersType["VIDEOS"] = "videos/";
16
+ mediaFoldersType["OBJECT"] = "models/";
17
+ })(mediaFoldersType || (mediaFoldersType = {}));
18
+ var mediaObjectsFoldersType;
19
+ (function (mediaObjectsFoldersType) {
20
+ mediaObjectsFoldersType["ORIGINS"] = "origins/";
21
+ mediaObjectsFoldersType["PREVIEWS"] = "previews/";
22
+ })(mediaObjectsFoldersType || (mediaObjectsFoldersType = {}));
23
+ var mediaVideosFoldersType;
24
+ (function (mediaVideosFoldersType) {
25
+ mediaVideosFoldersType["ORIGINS"] = "origins/";
26
+ mediaVideosFoldersType["PREVIEWS"] = "previews/";
27
+ })(mediaVideosFoldersType || (mediaVideosFoldersType = {}));
28
+ var mediaSizes;
29
+ (function (mediaSizes) {
30
+ mediaSizes["small"] = "252";
31
+ mediaSizes["regular"] = "510";
32
+ })(mediaSizes || (exports.mediaSizes = mediaSizes = {}));
33
+ const getUserPicImage = (getMediaDomain, userPic, fallbackImage, dimensions) => {
34
+ if (!userPic) {
35
+ return fallbackImage;
36
+ }
37
+ return `${getMediaDomain()}/${mediaType.USER_PICKS}${userPic}${getDimensions(dimensions)}`;
38
+ };
39
+ exports.getUserPicImage = getUserPicImage;
40
+ const getDimensions = (dimensions) => {
41
+ return dimensions ? `?d=${dimensions.w}x${dimensions.h}` : "";
42
+ };
43
+ const getAssetImage = (media, fallbackImage, dimension, NEXT_PUBLIC_STATIC_DOMAIN) => {
44
+ if (!media) {
45
+ return fallbackImage;
46
+ }
47
+ return `https://${dimension}.${NEXT_PUBLIC_STATIC_DOMAIN}/assets/images/${media}`;
48
+ };
49
+ exports.getAssetImage = getAssetImage;
50
+ const getGalleryBannerImage = (getMediaDomain, galleryId, fallbackImage, dimensions) => {
51
+ if (!galleryId) {
52
+ return fallbackImage;
53
+ }
54
+ return `${getMediaDomain()}/${mediaType.GALLERY_BANNERS}${galleryId}${getDimensions(dimensions)}`;
55
+ };
56
+ exports.getGalleryBannerImage = getGalleryBannerImage;
57
+ const getAssetVideoOrigins = (getVideoENVDomain, media, fallbackImage) => {
58
+ if (!media) {
59
+ return fallbackImage;
60
+ }
61
+ return `${getVideoENVDomain()}/${media}`;
62
+ };
63
+ exports.getAssetVideoOrigins = getAssetVideoOrigins;
64
+ const getAssetAudioOrigins = (getAudioENVDomain, media, fallbackImage) => {
65
+ if (!media) {
66
+ return fallbackImage;
67
+ }
68
+ return `${getAudioENVDomain()}/${media}`;
69
+ };
70
+ exports.getAssetAudioOrigins = getAssetAudioOrigins;
71
+ const getAssetVideoPreviews = (getMediaDomain, assetId, fallbackImage, dimensions) => {
72
+ if (!assetId) {
73
+ return fallbackImage;
74
+ }
75
+ return `${getMediaDomain()}/${mediaType.ASSETS}${mediaFoldersType.VIDEOS}${mediaVideosFoldersType.PREVIEWS}${assetId}${getDimensions(dimensions)}`;
76
+ };
77
+ exports.getAssetVideoPreviews = getAssetVideoPreviews;
78
+ const getAssetObjectOrigins = (getMediaDomain, assetId, fallbackImage, dimensions) => {
79
+ if (!assetId) {
80
+ return fallbackImage;
81
+ }
82
+ return `${getMediaDomain()}/${mediaType.ASSETS}${mediaFoldersType.OBJECT}${mediaObjectsFoldersType.ORIGINS}${assetId}${getDimensions(dimensions)}`;
83
+ };
84
+ exports.getAssetObjectOrigins = getAssetObjectOrigins;
85
+ const getAssetObjectPreviews = (getMediaDomain, assetId, fallbackImage, dimensions) => {
86
+ if (!assetId) {
87
+ return fallbackImage;
88
+ }
89
+ return `${getMediaDomain()}/${mediaType.ASSETS}${mediaFoldersType.OBJECT}${mediaObjectsFoldersType.PREVIEWS}${assetId}${getDimensions(dimensions)}`;
90
+ };
91
+ exports.getAssetObjectPreviews = getAssetObjectPreviews;
92
+ const isExternalMediaImage = (media, mediaSize, NEXT_PUBLIC_STATIC_DOMAIN) => {
93
+ if (media == null || !media.length)
94
+ return `${constants_1.staticLink}/public/noContent/noContent.svg`;
95
+ if (media.includes("base64"))
96
+ return media;
97
+ if (media.includes("https" || "http"))
98
+ return (0, utils_1.checkGltfUrl)(media);
99
+ return (0, exports.getAssetImage)(media, `${constants_1.staticLink}/public/noContent/noContent.svg`, mediaSize, NEXT_PUBLIC_STATIC_DOMAIN);
100
+ };
101
+ exports.isExternalMediaImage = isExternalMediaImage;
102
+ const isExternalMediaVideo = (media, getVideoENVDomain) => {
103
+ if (media == null)
104
+ return `${constants_1.staticLink}/public/noContent/noContent.svg`;
105
+ if (media.includes("https" || "http"))
106
+ return (0, utils_1.checkGltfUrl)(media);
107
+ return (0, exports.getAssetVideoOrigins)(getVideoENVDomain, media, `${constants_1.staticLink}/public/noContent/noContent.svg`);
108
+ };
109
+ exports.isExternalMediaVideo = isExternalMediaVideo;
110
+ const isExternalMediaAudio = (media, getAudioENVDomain) => {
111
+ if (media == null)
112
+ return `${constants_1.staticLink}/public/noContent/noContentAudio.svg`;
113
+ if (media.includes("https" || "http"))
114
+ return (0, utils_1.checkGltfUrl)(media);
115
+ return (0, exports.getAssetAudioOrigins)(getAudioENVDomain, media, `${constants_1.staticLink}/public/noContent/noContentAudio.svg`);
116
+ };
117
+ exports.isExternalMediaAudio = isExternalMediaAudio;
118
+ const isExternalMediaObject = (media, getMediaDomain) => {
119
+ if (media == null)
120
+ return `${constants_1.staticLink}/public/noContent/noContentObject.svg`;
121
+ if (media.includes("https" || "http"))
122
+ return (0, utils_1.checkGltfUrl)(media);
123
+ return (0, exports.getAssetObjectOrigins)(getMediaDomain, media, `${constants_1.staticLink}/public/noContent/noContentObject.svg`);
124
+ };
125
+ exports.isExternalMediaObject = isExternalMediaObject;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ludo.ninja/components",
3
- "version": "2.2.35",
3
+ "version": "2.2.36",
4
4
  "private": false,
5
5
  "main": "build/index.js",
6
6
  "types": "build/index.d.ts",