@medialane/ui 0.402.0 → 0.403.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.
@@ -1,7 +1,7 @@
1
1
  import * as input_otp from 'input-otp';
2
2
  import * as React from 'react';
3
3
 
4
- declare const InputOTP: React.ForwardRefExoticComponent<(Omit<Omit<React.InputHTMLAttributes<HTMLInputElement>, "onChange" | "maxLength" | "value" | "textAlign" | "onComplete" | "pushPasswordManagerStrategy" | "pasteTransformer" | "containerClassName" | "noScriptCSSFallback"> & {
4
+ declare const InputOTP: React.ForwardRefExoticComponent<(Omit<Omit<React.InputHTMLAttributes<HTMLInputElement>, "onChange" | "value" | "maxLength" | "textAlign" | "onComplete" | "pushPasswordManagerStrategy" | "pasteTransformer" | "containerClassName" | "noScriptCSSFallback"> & {
5
5
  value?: string;
6
6
  onChange?: (newValue: string) => unknown;
7
7
  maxLength: number;
@@ -14,7 +14,7 @@ declare const InputOTP: React.ForwardRefExoticComponent<(Omit<Omit<React.InputHT
14
14
  } & {
15
15
  render: (props: input_otp.RenderProps) => React.ReactNode;
16
16
  children?: never;
17
- } & React.RefAttributes<HTMLInputElement>, "ref"> | Omit<Omit<React.InputHTMLAttributes<HTMLInputElement>, "onChange" | "maxLength" | "value" | "textAlign" | "onComplete" | "pushPasswordManagerStrategy" | "pasteTransformer" | "containerClassName" | "noScriptCSSFallback"> & {
17
+ } & React.RefAttributes<HTMLInputElement>, "ref"> | Omit<Omit<React.InputHTMLAttributes<HTMLInputElement>, "onChange" | "value" | "maxLength" | "textAlign" | "onComplete" | "pushPasswordManagerStrategy" | "pasteTransformer" | "containerClassName" | "noScriptCSSFallback"> & {
18
18
  value?: string;
19
19
  onChange?: (newValue: string) => unknown;
20
20
  maxLength: number;
@@ -1,7 +1,7 @@
1
1
  import * as input_otp from 'input-otp';
2
2
  import * as React from 'react';
3
3
 
4
- declare const InputOTP: React.ForwardRefExoticComponent<(Omit<Omit<React.InputHTMLAttributes<HTMLInputElement>, "onChange" | "maxLength" | "value" | "textAlign" | "onComplete" | "pushPasswordManagerStrategy" | "pasteTransformer" | "containerClassName" | "noScriptCSSFallback"> & {
4
+ declare const InputOTP: React.ForwardRefExoticComponent<(Omit<Omit<React.InputHTMLAttributes<HTMLInputElement>, "onChange" | "value" | "maxLength" | "textAlign" | "onComplete" | "pushPasswordManagerStrategy" | "pasteTransformer" | "containerClassName" | "noScriptCSSFallback"> & {
5
5
  value?: string;
6
6
  onChange?: (newValue: string) => unknown;
7
7
  maxLength: number;
@@ -14,7 +14,7 @@ declare const InputOTP: React.ForwardRefExoticComponent<(Omit<Omit<React.InputHT
14
14
  } & {
15
15
  render: (props: input_otp.RenderProps) => React.ReactNode;
16
16
  children?: never;
17
- } & React.RefAttributes<HTMLInputElement>, "ref"> | Omit<Omit<React.InputHTMLAttributes<HTMLInputElement>, "onChange" | "maxLength" | "value" | "textAlign" | "onComplete" | "pushPasswordManagerStrategy" | "pasteTransformer" | "containerClassName" | "noScriptCSSFallback"> & {
17
+ } & React.RefAttributes<HTMLInputElement>, "ref"> | Omit<Omit<React.InputHTMLAttributes<HTMLInputElement>, "onChange" | "value" | "maxLength" | "textAlign" | "onComplete" | "pushPasswordManagerStrategy" | "pasteTransformer" | "containerClassName" | "noScriptCSSFallback"> & {
18
18
  value?: string;
19
19
  onChange?: (newValue: string) => unknown;
20
20
  maxLength: number;
@@ -4,7 +4,7 @@ import { VariantProps } from 'class-variance-authority';
4
4
 
5
5
  declare const buttonVariants: (props?: ({
6
6
  variant?: "link" | "default" | "destructive" | "soft" | "secondary" | "ghost" | "tonal" | null | undefined;
7
- size?: "lg" | "sm" | "default" | "icon" | null | undefined;
7
+ size?: "default" | "icon" | "sm" | "lg" | null | undefined;
8
8
  } & class_variance_authority_types.ClassProp) | undefined) => string;
9
9
  interface ButtonProps extends React.ButtonHTMLAttributes<HTMLButtonElement>, VariantProps<typeof buttonVariants> {
10
10
  asChild?: boolean;
@@ -4,7 +4,7 @@ import { VariantProps } from 'class-variance-authority';
4
4
 
5
5
  declare const buttonVariants: (props?: ({
6
6
  variant?: "link" | "default" | "destructive" | "soft" | "secondary" | "ghost" | "tonal" | null | undefined;
7
- size?: "lg" | "sm" | "default" | "icon" | null | undefined;
7
+ size?: "default" | "icon" | "sm" | "lg" | null | undefined;
8
8
  } & class_variance_authority_types.ClassProp) | undefined) => string;
9
9
  interface ButtonProps extends React.ButtonHTMLAttributes<HTMLButtonElement>, VariantProps<typeof buttonVariants> {
10
10
  asChild?: boolean;
@@ -1,10 +1,10 @@
1
- import * as React from 'react';
2
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
2
+ import * as React from 'react';
3
3
  import { FastMintProps } from './types.cjs';
4
4
  import 'starknet';
5
5
  import '@medialane/sdk';
6
6
  import '@medialane/sdk/starknet';
7
7
 
8
- declare function FastMint(props: FastMintProps): string | number | bigint | boolean | react_jsx_runtime.JSX.Element | Iterable<React.ReactNode> | Promise<string | number | bigint | boolean | React.ReactPortal | React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | Iterable<React.ReactNode> | null | undefined> | null | undefined;
8
+ declare function FastMint(props: FastMintProps): string | number | bigint | boolean | Iterable<React.ReactNode> | Promise<string | number | bigint | boolean | React.ReactPortal | React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | Iterable<React.ReactNode> | null | undefined> | react_jsx_runtime.JSX.Element | null | undefined;
9
9
 
10
10
  export { FastMint };
@@ -1,10 +1,10 @@
1
- import * as React from 'react';
2
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
2
+ import * as React from 'react';
3
3
  import { FastMintProps } from './types.js';
4
4
  import 'starknet';
5
5
  import '@medialane/sdk';
6
6
  import '@medialane/sdk/starknet';
7
7
 
8
- declare function FastMint(props: FastMintProps): string | number | bigint | boolean | react_jsx_runtime.JSX.Element | Iterable<React.ReactNode> | Promise<string | number | bigint | boolean | React.ReactPortal | React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | Iterable<React.ReactNode> | null | undefined> | null | undefined;
8
+ declare function FastMint(props: FastMintProps): string | number | bigint | boolean | Iterable<React.ReactNode> | Promise<string | number | bigint | boolean | React.ReactPortal | React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | Iterable<React.ReactNode> | null | undefined> | react_jsx_runtime.JSX.Element | null | undefined;
9
9
 
10
10
  export { FastMint };
@@ -15,11 +15,11 @@ declare const editionMintSchema: z.ZodObject<{
15
15
  aiPolicy: z.ZodEnum<["Allowed", "Not Allowed", "Training Only"]>;
16
16
  royalty: z.ZodNumber;
17
17
  }, "strip", z.ZodTypeAny, {
18
- ipType: "Audio" | "Video" | "Art" | "Photography" | "NFT" | "RWA" | "Posts" | "Publications" | "Documents";
19
18
  name: string;
20
- value: string;
21
19
  derivatives: "Allowed" | "Not Allowed" | "Share-Alike";
20
+ value: string;
22
21
  recipient: string;
22
+ ipType: "Audio" | "Video" | "Art" | "Photography" | "NFT" | "RWA" | "Posts" | "Publications" | "Documents";
23
23
  licenseType: string;
24
24
  commercialUse: "Yes" | "No";
25
25
  attribution: "Required" | "Not Required";
@@ -29,11 +29,11 @@ declare const editionMintSchema: z.ZodObject<{
29
29
  description?: string | undefined;
30
30
  external_url?: string | undefined;
31
31
  }, {
32
- ipType: "Audio" | "Video" | "Art" | "Photography" | "NFT" | "RWA" | "Posts" | "Publications" | "Documents";
33
32
  name: string;
34
- value: string;
35
33
  derivatives: "Allowed" | "Not Allowed" | "Share-Alike";
34
+ value: string;
36
35
  recipient: string;
36
+ ipType: "Audio" | "Video" | "Art" | "Photography" | "NFT" | "RWA" | "Posts" | "Publications" | "Documents";
37
37
  licenseType: string;
38
38
  commercialUse: "Yes" | "No";
39
39
  attribution: "Required" | "Not Required";
@@ -15,11 +15,11 @@ declare const editionMintSchema: z.ZodObject<{
15
15
  aiPolicy: z.ZodEnum<["Allowed", "Not Allowed", "Training Only"]>;
16
16
  royalty: z.ZodNumber;
17
17
  }, "strip", z.ZodTypeAny, {
18
- ipType: "Audio" | "Video" | "Art" | "Photography" | "NFT" | "RWA" | "Posts" | "Publications" | "Documents";
19
18
  name: string;
20
- value: string;
21
19
  derivatives: "Allowed" | "Not Allowed" | "Share-Alike";
20
+ value: string;
22
21
  recipient: string;
22
+ ipType: "Audio" | "Video" | "Art" | "Photography" | "NFT" | "RWA" | "Posts" | "Publications" | "Documents";
23
23
  licenseType: string;
24
24
  commercialUse: "Yes" | "No";
25
25
  attribution: "Required" | "Not Required";
@@ -29,11 +29,11 @@ declare const editionMintSchema: z.ZodObject<{
29
29
  description?: string | undefined;
30
30
  external_url?: string | undefined;
31
31
  }, {
32
- ipType: "Audio" | "Video" | "Art" | "Photography" | "NFT" | "RWA" | "Posts" | "Publications" | "Documents";
33
32
  name: string;
34
- value: string;
35
33
  derivatives: "Allowed" | "Not Allowed" | "Share-Alike";
34
+ value: string;
36
35
  recipient: string;
36
+ ipType: "Audio" | "Video" | "Art" | "Photography" | "NFT" | "RWA" | "Posts" | "Publications" | "Documents";
37
37
  licenseType: string;
38
38
  commercialUse: "Yes" | "No";
39
39
  attribution: "Required" | "Not Required";
@@ -7,7 +7,7 @@ declare function useTokenBalance(symbol: string | null, holderAddress: string |
7
7
  rawBalance: bigint | null;
8
8
  isLoading: boolean;
9
9
  error: any;
10
- decimals: 6 | 8 | 18;
10
+ decimals: 8 | 6 | 18;
11
11
  };
12
12
  declare function hasSufficientBalance(rawBalance: bigint | null, requiredHuman: string, decimals: number): boolean | null;
13
13
 
@@ -7,7 +7,7 @@ declare function useTokenBalance(symbol: string | null, holderAddress: string |
7
7
  rawBalance: bigint | null;
8
8
  isLoading: boolean;
9
9
  error: any;
10
- decimals: 6 | 8 | 18;
10
+ decimals: 8 | 6 | 18;
11
11
  };
12
12
  declare function hasSufficientBalance(rawBalance: bigint | null, requiredHuman: string, decimals: number): boolean | null;
13
13
 
@@ -36,8 +36,7 @@ function isAddress(value) {
36
36
  return false;
37
37
  }
38
38
  }
39
- function createServerReads({ api, cache, backendUrl, absoluteUrl }) {
40
- const backendOrigin = new URL(backendUrl).origin;
39
+ function createServerReads({ api, cache }) {
41
40
  const expireSoon = cache(async () => null, ["failed-read"], { revalidate: FAILED_READ_REVALIDATE_SECONDS });
42
41
  function cached(name, read, revalidate = DETAIL_REVALIDATE_SECONDS) {
43
42
  const load = cache(
@@ -62,10 +61,7 @@ function createServerReads({ api, cache, backendUrl, absoluteUrl }) {
62
61
  }
63
62
  const atAddress = (read) => async (...args) => isAddress(args[0]) ? read(...args) : null;
64
63
  return {
65
- ipfsToHttpServer(uri) {
66
- const url = (0, import_ipfs.toAbsoluteImageUrl)(uri);
67
- return url.startsWith(`${backendOrigin}/`) ? absoluteUrl(`/api/img?url=${encodeURIComponent(url)}`) : url;
68
- },
64
+ ipfsToHttpServer: import_ipfs.toAbsoluteImageUrl,
69
65
  fetchTokenMeta: cached("token-meta", atAddress((contract, tokenId) => api().tokens.get(contract, tokenId))),
70
66
  fetchCollectionMeta: cached("collection-meta", atAddress((contract) => api().collections.get(contract))),
71
67
  fetchCollectionBySlug: cached("collection-by-slug", (slug) => api().collections.findBySlug(slug)),
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/utils/server-reads.ts"],"sourcesContent":["import { normalizeAddress, type ApiClient } from \"@medialane/sdk\";\nimport { toAbsoluteImageUrl } from \"./ipfs.js\";\n\nconst DETAIL_REVALIDATE_SECONDS = 300;\nconst LIST_REVALIDATE_SECONDS = 60;\nconst FAILED_READ_REVALIDATE_SECONDS = 1;\nconst ABSENT_STATUSES = new Set<unknown>([400, 404]);\n\nexport type ServerReadCache = <T extends (...args: any[]) => Promise<any>>(\n read: T,\n key: string[],\n options: { revalidate: number },\n) => T;\n\nexport interface ServerReadsOptions {\n api: () => ApiClient;\n cache: ServerReadCache;\n backendUrl: string;\n absoluteUrl: (path: string) => string;\n}\n\nconst isAbsent = (error: unknown) => ABSENT_STATUSES.has((error as { status?: unknown } | null)?.status);\n\nfunction isAddress(value: string): boolean {\n try {\n normalizeAddress(\"STARKNET\", value);\n return true;\n } catch {\n return false;\n }\n}\n\nexport function createServerReads({ api, cache, backendUrl, absoluteUrl }: ServerReadsOptions) {\n const backendOrigin = new URL(backendUrl).origin;\n const expireSoon = cache(async () => null, [\"failed-read\"], { revalidate: FAILED_READ_REVALIDATE_SECONDS });\n\n function cached<A extends (string | number)[], T>(\n name: string,\n read: (...args: A) => Promise<T>,\n revalidate = DETAIL_REVALIDATE_SECONDS,\n ): (...args: A) => Promise<T | null> {\n const load = cache(\n async (...args: A): Promise<T | null> => {\n try {\n return await read(...args);\n } catch (error) {\n if (isAbsent(error)) return null;\n throw error;\n }\n },\n [name],\n { revalidate },\n );\n return async (...args: A) => {\n try {\n return await load(...args);\n } catch {\n return expireSoon();\n }\n };\n }\n\n const atAddress = <A extends [string, ...(string | number)[]], T>(read: (...args: A) => Promise<T>) =>\n async (...args: A): Promise<T | null> => (isAddress(args[0]) ? read(...args) : null);\n\n return {\n ipfsToHttpServer(uri: string | null | undefined): string {\n const url = toAbsoluteImageUrl(uri);\n return url.startsWith(`${backendOrigin}/`) ? absoluteUrl(`/api/img?url=${encodeURIComponent(url)}`) : url;\n },\n fetchTokenMeta: cached(\"token-meta\", atAddress((contract: string, tokenId: string) => api().tokens.get(contract, tokenId))),\n fetchCollectionMeta: cached(\"collection-meta\", atAddress((contract: string) => api().collections.get(contract))),\n fetchCollectionBySlug: cached(\"collection-by-slug\", (slug: string) => api().collections.findBySlug(slug)),\n fetchDropMeta: cached(\"drop-meta\", atAddress((contract: string) => api().drops.find(contract))),\n fetchCoinMeta: cached(\"coin-meta\", atAddress((contract: string) => api().coins.get(contract))),\n fetchCreatorProfile: cached(\"creator-profile\", (username: string) => api().creators.findByUsername(username)),\n fetchFeaturedCollections: cached(\n \"featured-collections\",\n async (limit: number) =>\n (await api().collections.list({ page: 1, limit, sort: \"recent\", isFeatured: true, hideEmpty: true })).data,\n LIST_REVALIDATE_SECONDS,\n ),\n fetchActiveOrders: cached(\n \"active-orders\",\n async (limit: number) => (await api().orders.list({ status: \"ACTI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GAAG;AAClC,aAAO,IAAI,WAAW,GAAG,aAAa,GAAG,IAAI,YAAY,gBAAgB,mBAAmB,GAAG,CAAC,EAAE,IAAI;AAAA,IACxG;AAAA,IACA,gBAAgB,OAAO,cAAc,UAAU,CAAC,UAAkB,YAAoB,IAAI,EAAE,OAAO,IAAI,UAAU,OAAO,CAAC,CAAC;AAAA,IAC1H,qBAAqB,OAAO,mBAAmB,UAAU,CAAC,aAAqB,IAAI,EAAE,YAAY,IAAI,QAAQ,CAAC,CAAC;AAAA,IAC/G,uBAAuB,OAAO,sBAAsB,CAAC,SAAiB,IAAI,EAAE,YAAY,WAAW,IAAI,CAAC;AAAA,IACxG,eAAe,OAAO,aAAa,UAAU,CAAC,aAAqB,IAAI,EAAE,MAAM,KAAK,QAAQ,CAAC,CAAC;AAAA,IAC9F,eAAe,OAAO,aAAa,UAAU,CAAC,aAAqB,IAAI,EAAE,MAAM,IAAI,QAAQ,CAAC,CAAC;AAAA,IAC7F,qBAAqB,OAAO,mBAAmB,CAAC,aAAqB,IAAI,EAAE,SAAS,eAAe,QAAQ,CAAC;AAAA,IAC5G,0BAA0B;AAAA,MACxB;AAAA,MACA,OAAO,WACJ,MAAM,IAAI,EAAE,YAAY,KAAK,EAAE,MAAM,GAAG,OAAO,MAAM,UAAU,YAAY,MAAM,WAAW,KAAK,CAAC,GAAG;AAAA,MACxG;AAAA,IACF;AAAA,IACA,mBAAmB;AAAA,MACjB;AAAA,MACA,OAAO,WAAmB,MAAM,IAAI,EAAE,OAAO,KAAK,EAAE,QAAQ,UAAU,MAAM,UAAU,MAAM,GAAG,MAAM,CAAC,GAAG;AAAA,MACzG;AAAA,IACF;AAAA,EACF;AACF;","names":[]}
1
+ {"version":3,"sources":["../../src/utils/server-reads.ts"],"sourcesContent":["import { normalizeAddress, type ApiClient } from \"@medialane/sdk\";\nimport { toAbsoluteImageUrl } from \"./ipfs.js\";\n\nconst DETAIL_REVALIDATE_SECONDS = 300;\nconst LIST_REVALIDATE_SECONDS = 60;\nconst FAILED_READ_REVALIDATE_SECONDS = 1;\nconst ABSENT_STATUSES = new Set<unknown>([400, 404]);\n\nexport type ServerReadCache = <T extends (...args: any[]) => Promise<any>>(\n read: T,\n key: string[],\n options: { revalidate: number },\n) => T;\n\nexport interface ServerReadsOptions {\n api: () => ApiClient;\n cache: ServerReadCache;\n}\n\nconst isAbsent = (error: unknown) => ABSENT_STATUSES.has((error as { status?: unknown } | null)?.status);\n\nfunction isAddress(value: string): boolean {\n try {\n normalizeAddress(\"STARKNET\", value);\n return true;\n } catch {\n return false;\n }\n}\n\nexport function createServerReads({ api, cache }: ServerReadsOptions) {\n const expireSoon = cache(async () => null, [\"failed-read\"], { revalidate: FAILED_READ_REVALIDATE_SECONDS });\n\n function cached<A extends (string | number)[], T>(\n name: string,\n read: (...args: A) => Promise<T>,\n revalidate = DETAIL_REVALIDATE_SECONDS,\n ): (...args: A) => Promise<T | null> {\n const load = cache(\n async (...args: A): Promise<T | null> => {\n try {\n return await read(...args);\n } catch (error) {\n if (isAbsent(error)) return null;\n throw error;\n }\n },\n [name],\n { revalidate },\n );\n return async (...args: A) => {\n try {\n return await load(...args);\n } catch {\n return expireSoon();\n }\n };\n }\n\n const atAddress = <A extends [string, ...(string | number)[]], T>(read: (...args: A) => Promise<T>) =>\n async (...args: A): Promise<T | null> => (isAddress(args[0]) ? read(...args) : null);\n\n return {\n ipfsToHttpServer: toAbsoluteImageUrl,\n fetchTokenMeta: cached(\"token-meta\", atAddress((contract: string, tokenId: string) => api().tokens.get(contract, tokenId))),\n fetchCollectionMeta: cached(\"collection-meta\", atAddress((contract: string) => api().collections.get(contract))),\n fetchCollectionBySlug: cached(\"collection-by-slug\", (slug: string) => api().collections.findBySlug(slug)),\n fetchDropMeta: cached(\"drop-meta\", atAddress((contract: string) => api().drops.find(contract))),\n fetchCoinMeta: cached(\"coin-meta\", atAddress((contract: string) => api().coins.get(contract))),\n fetchCreatorProfile: cached(\"creator-profile\", (username: string) => api().creators.findByUsername(username)),\n fetchFeaturedCollections: cached(\n \"featured-collections\",\n async (limit: number) =>\n (await api().collections.list({ page: 1, limit, sort: \"recent\", isFeatured: true, hideEmpty: true })).data,\n LIST_REVALIDATE_SECONDS,\n ),\n fetchActiveOrders: cached(\n \"active-orders\",\n async (limit: number) => (await api().orders.list({ status: \"ACTIVE\", sort: \"recent\", page: 1, limit })).data,\n LIST_REVALIDATE_SECONDS,\n ),\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,iBAAiD;AACjD,kBAAmC;AAEnC,MAAM,4BAA4B;AAClC,MAAM,0BAA0B;AAChC,MAAM,iCAAiC;AACvC,MAAM,kBAAkB,oBAAI,IAAa,CAAC,KAAK,GAAG,CAAC;AAanD,MAAM,WAAW,CAAC,UAAmB,gBAAgB,IAAK,OAAuC,MAAM;AAEvG,SAAS,UAAU,OAAwB;AACzC,MAAI;AACF,qCAAiB,YAAY,KAAK;AAClC,WAAO;AAAA,EACT,QAAQ;AACN,WAAO;AAAA,EACT;AACF;AAEO,SAAS,kBAAkB,EAAE,KAAK,MAAM,GAAuB;AACpE,QAAM,aAAa,MAAM,YAAY,MAAM,CAAC,aAAa,GAAG,EAAE,YAAY,+BAA+B,CAAC;AAE1G,WAAS,OACP,MACA,MACA,aAAa,2BACsB;AACnC,UAAM,OAAO;AAAA,MACX,UAAU,SAA+B;AACvC,YAAI;AACF,iBAAO,MAAM,KAAK,GAAG,IAAI;AAAA,QAC3B,SAAS,OAAO;AACd,cAAI,SAAS,KAAK,EAAG,QAAO;AAC5B,gBAAM;AAAA,QACR;AAAA,MACF;AAAA,MACA,CAAC,IAAI;AAAA,MACL,EAAE,WAAW;AAAA,IACf;AACA,WAAO,UAAU,SAAY;AAC3B,UAAI;AACF,eAAO,MAAM,KAAK,GAAG,IAAI;AAAA,MAC3B,QAAQ;AACN,eAAO,WAAW;AAAA,MACpB;AAAA,IACF;AAAA,EACF;AAEA,QAAM,YAAY,CAAgD,SAChE,UAAU,SAAgC,UAAU,KAAK,CAAC,CAAC,IAAI,KAAK,GAAG,IAAI,IAAI;AAEjF,SAAO;AAAA,IACL,kBAAkB;AAAA,IAClB,gBAAgB,OAAO,cAAc,UAAU,CAAC,UAAkB,YAAoB,IAAI,EAAE,OAAO,IAAI,UAAU,OAAO,CAAC,CAAC;AAAA,IAC1H,qBAAqB,OAAO,mBAAmB,UAAU,CAAC,aAAqB,IAAI,EAAE,YAAY,IAAI,QAAQ,CAAC,CAAC;AAAA,IAC/G,uBAAuB,OAAO,sBAAsB,CAAC,SAAiB,IAAI,EAAE,YAAY,WAAW,IAAI,CAAC;AAAA,IACxG,eAAe,OAAO,aAAa,UAAU,CAAC,aAAqB,IAAI,EAAE,MAAM,KAAK,QAAQ,CAAC,CAAC;AAAA,IAC9F,eAAe,OAAO,aAAa,UAAU,CAAC,aAAqB,IAAI,EAAE,MAAM,IAAI,QAAQ,CAAC,CAAC;AAAA,IAC7F,qBAAqB,OAAO,mBAAmB,CAAC,aAAqB,IAAI,EAAE,SAAS,eAAe,QAAQ,CAAC;AAAA,IAC5G,0BAA0B;AAAA,MACxB;AAAA,MACA,OAAO,WACJ,MAAM,IAAI,EAAE,YAAY,KAAK,EAAE,MAAM,GAAG,OAAO,MAAM,UAAU,YAAY,MAAM,WAAW,KAAK,CAAC,GAAG;AAAA,MACxG;AAAA,IACF;AAAA,IACA,mBAAmB;AAAA,MACjB;AAAA,MACA,OAAO,WAAmB,MAAM,IAAI,EAAE,OAAO,KAAK,EAAE,QAAQ,UAAU,MAAM,UAAU,MAAM,GAAG,MAAM,CAAC,GAAG;AAAA,MACzG;AAAA,IACF;AAAA,EACF;AACF;","names":[]}
@@ -1,5 +1,6 @@
1
1
  import * as _medialane_sdk from '@medialane/sdk';
2
2
  import { ApiClient } from '@medialane/sdk';
3
+ import { toAbsoluteImageUrl } from './ipfs.cjs';
3
4
 
4
5
  type ServerReadCache = <T extends (...args: any[]) => Promise<any>>(read: T, key: string[], options: {
5
6
  revalidate: number;
@@ -7,11 +8,9 @@ type ServerReadCache = <T extends (...args: any[]) => Promise<any>>(read: T, key
7
8
  interface ServerReadsOptions {
8
9
  api: () => ApiClient;
9
10
  cache: ServerReadCache;
10
- backendUrl: string;
11
- absoluteUrl: (path: string) => string;
12
11
  }
13
- declare function createServerReads({ api, cache, backendUrl, absoluteUrl }: ServerReadsOptions): {
14
- ipfsToHttpServer(uri: string | null | undefined): string;
12
+ declare function createServerReads({ api, cache }: ServerReadsOptions): {
13
+ ipfsToHttpServer: typeof toAbsoluteImageUrl;
15
14
  fetchTokenMeta: (contract: string, tokenId: string) => Promise<{
16
15
  id: string;
17
16
  chain: string;
@@ -1,5 +1,6 @@
1
1
  import * as _medialane_sdk from '@medialane/sdk';
2
2
  import { ApiClient } from '@medialane/sdk';
3
+ import { toAbsoluteImageUrl } from './ipfs.js';
3
4
 
4
5
  type ServerReadCache = <T extends (...args: any[]) => Promise<any>>(read: T, key: string[], options: {
5
6
  revalidate: number;
@@ -7,11 +8,9 @@ type ServerReadCache = <T extends (...args: any[]) => Promise<any>>(read: T, key
7
8
  interface ServerReadsOptions {
8
9
  api: () => ApiClient;
9
10
  cache: ServerReadCache;
10
- backendUrl: string;
11
- absoluteUrl: (path: string) => string;
12
11
  }
13
- declare function createServerReads({ api, cache, backendUrl, absoluteUrl }: ServerReadsOptions): {
14
- ipfsToHttpServer(uri: string | null | undefined): string;
12
+ declare function createServerReads({ api, cache }: ServerReadsOptions): {
13
+ ipfsToHttpServer: typeof toAbsoluteImageUrl;
15
14
  fetchTokenMeta: (contract: string, tokenId: string) => Promise<{
16
15
  id: string;
17
16
  chain: string;
@@ -13,8 +13,7 @@ function isAddress(value) {
13
13
  return false;
14
14
  }
15
15
  }
16
- function createServerReads({ api, cache, backendUrl, absoluteUrl }) {
17
- const backendOrigin = new URL(backendUrl).origin;
16
+ function createServerReads({ api, cache }) {
18
17
  const expireSoon = cache(async () => null, ["failed-read"], { revalidate: FAILED_READ_REVALIDATE_SECONDS });
19
18
  function cached(name, read, revalidate = DETAIL_REVALIDATE_SECONDS) {
20
19
  const load = cache(
@@ -39,10 +38,7 @@ function createServerReads({ api, cache, backendUrl, absoluteUrl }) {
39
38
  }
40
39
  const atAddress = (read) => async (...args) => isAddress(args[0]) ? read(...args) : null;
41
40
  return {
42
- ipfsToHttpServer(uri) {
43
- const url = toAbsoluteImageUrl(uri);
44
- return url.startsWith(`${backendOrigin}/`) ? absoluteUrl(`/api/img?url=${encodeURIComponent(url)}`) : url;
45
- },
41
+ ipfsToHttpServer: toAbsoluteImageUrl,
46
42
  fetchTokenMeta: cached("token-meta", atAddress((contract, tokenId) => api().tokens.get(contract, tokenId))),
47
43
  fetchCollectionMeta: cached("collection-meta", atAddress((contract) => api().collections.get(contract))),
48
44
  fetchCollectionBySlug: cached("collection-by-slug", (slug) => api().collections.findBySlug(slug)),
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/utils/server-reads.ts"],"sourcesContent":["import { normalizeAddress, type ApiClient } from \"@medialane/sdk\";\nimport { toAbsoluteImageUrl } from \"./ipfs.js\";\n\nconst DETAIL_REVALIDATE_SECONDS = 300;\nconst LIST_REVALIDATE_SECONDS = 60;\nconst FAILED_READ_REVALIDATE_SECONDS = 1;\nconst ABSENT_STATUSES = new Set<unknown>([400, 404]);\n\nexport type ServerReadCache = <T extends (...args: any[]) => Promise<any>>(\n read: T,\n key: string[],\n options: { revalidate: number },\n) => T;\n\nexport interface ServerReadsOptions {\n api: () => ApiClient;\n cache: ServerReadCache;\n backendUrl: string;\n absoluteUrl: (path: string) => string;\n}\n\nconst isAbsent = (error: unknown) => ABSENT_STATUSES.has((error as { status?: unknown } | null)?.status);\n\nfunction isAddress(value: string): boolean {\n try {\n normalizeAddress(\"STARKNET\", value);\n return true;\n } catch {\n return false;\n }\n}\n\nexport function createServerReads({ api, cache, backendUrl, absoluteUrl }: ServerReadsOptions) {\n const backendOrigin = new URL(backendUrl).origin;\n const expireSoon = cache(async () => null, [\"failed-read\"], { revalidate: FAILED_READ_REVALIDATE_SECONDS });\n\n function cached<A extends (string | number)[], T>(\n name: string,\n read: (...args: A) => Promise<T>,\n revalidate = DETAIL_REVALIDATE_SECONDS,\n ): (...args: A) => Promise<T | null> {\n const load = cache(\n async (...args: A): Promise<T | null> => {\n try {\n return await read(...args);\n } catch (error) {\n if (isAbsent(error)) return null;\n throw error;\n }\n },\n [name],\n { revalidate },\n );\n return async (...args: A) => {\n try {\n return await load(...args);\n } catch {\n return expireSoon();\n }\n };\n }\n\n const atAddress = <A extends [string, ...(string | number)[]], T>(read: (...args: A) => Promise<T>) =>\n async (...args: A): Promise<T | null> => (isAddress(args[0]) ? read(...args) : null);\n\n return {\n ipfsToHttpServer(uri: string | null | undefined): string {\n const url = toAbsoluteImageUrl(uri);\n return url.startsWith(`${backendOrigin}/`) ? absoluteUrl(`/api/img?url=${encodeURIComponent(url)}`) : url;\n },\n fetchTokenMeta: cached(\"token-meta\", atAddress((contract: string, tokenId: string) => api().tokens.get(contract, tokenId))),\n fetchCollectionMeta: cached(\"collection-meta\", atAddress((contract: string) => api().collections.get(contract))),\n fetchCollectionBySlug: cached(\"collection-by-slug\", (slug: string) => api().collections.findBySlug(slug)),\n fetchDropMeta: cached(\"drop-meta\", atAddress((contract: string) => api().drops.find(contract))),\n fetchCoinMeta: cached(\"coin-meta\", atAddress((contract: string) => api().coins.get(contract))),\n fetchCreatorProfile: cached(\"creator-profile\", (username: string) => api().creators.findByUsername(username)),\n fetchFeaturedCollections: cached(\n \"featured-collections\",\n async (limit: number) =>\n (await api().collections.list({ page: 1, limit, sort: \"recent\", isFeatured: true, hideEmpty: true })).data,\n LIST_REVALIDATE_SECONDS,\n ),\n fetchActiveOrders: cached(\n \"active-orders\",\n async (limit: number) => (await api().orders.list({ status: \"ACTIVE\", sort: \"recent\", page: 1, limit })).data,\n LIST_REVALIDATE_SECONDS,\n ),\n };\n}\n"],"mappings":"AAAA,SAAS,wBAAwC;AACjD,SAAS,0BAA0B;AAE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kB,YAAoB,IAAI,EAAE,OAAO,IAAI,UAAU,OAAO,CAAC,CAAC;AAAA,IAC1H,qBAAqB,OAAO,mBAAmB,UAAU,CAAC,aAAqB,IAAI,EAAE,YAAY,IAAI,QAAQ,CAAC,CAAC;AAAA,IAC/G,uBAAuB,OAAO,sBAAsB,CAAC,SAAiB,IAAI,EAAE,YAAY,WAAW,IAAI,CAAC;AAAA,IACxG,eAAe,OAAO,aAAa,UAAU,CAAC,aAAqB,IAAI,EAAE,MAAM,KAAK,QAAQ,CAAC,CAAC;AAAA,IAC9F,eAAe,OAAO,aAAa,UAAU,CAAC,aAAqB,IAAI,EAAE,MAAM,IAAI,QAAQ,CAAC,CAAC;AAAA,IAC7F,qBAAqB,OAAO,mBAAmB,CAAC,aAAqB,IAAI,EAAE,SAAS,eAAe,QAAQ,CAAC;AAAA,IAC5G,0BAA0B;AAAA,MACxB;AAAA,MACA,OAAO,WACJ,MAAM,IAAI,EAAE,YAAY,KAAK,EAAE,MAAM,GAAG,OAAO,MAAM,UAAU,YAAY,MAAM,WAAW,KAAK,CAAC,GAAG;AAAA,MACxG;AAAA,IACF;AAAA,IACA,mBAAmB;AAAA,MACjB;AAAA,MACA,OAAO,WAAmB,MAAM,IAAI,EAAE,OAAO,KAAK,EAAE,QAAQ,UAAU,MAAM,UAAU,MAAM,GAAG,MAAM,CAAC,GAAG;AAAA,MACzG;AAAA,IACF;AAAA,EACF;AACF;","names":[]}
1
+ {"version":3,"sources":["../../src/utils/server-reads.ts"],"sourcesContent":["import { normalizeAddress, type ApiClient } from \"@medialane/sdk\";\nimport { toAbsoluteImageUrl } from \"./ipfs.js\";\n\nconst DETAIL_REVALIDATE_SECONDS = 300;\nconst LIST_REVALIDATE_SECONDS = 60;\nconst FAILED_READ_REVALIDATE_SECONDS = 1;\nconst ABSENT_STATUSES = new Set<unknown>([400, 404]);\n\nexport type ServerReadCache = <T extends (...args: any[]) => Promise<any>>(\n read: T,\n key: string[],\n options: { revalidate: number },\n) => T;\n\nexport interface ServerReadsOptions {\n api: () => ApiClient;\n cache: ServerReadCache;\n}\n\nconst isAbsent = (error: unknown) => ABSENT_STATUSES.has((error as { status?: unknown } | null)?.status);\n\nfunction isAddress(value: string): boolean {\n try {\n normalizeAddress(\"STARKNET\", value);\n return true;\n } catch {\n return false;\n }\n}\n\nexport function createServerReads({ api, cache }: ServerReadsOptions) {\n const expireSoon = cache(async () => null, [\"failed-read\"], { revalidate: FAILED_READ_REVALIDATE_SECONDS });\n\n function cached<A extends (string | number)[], T>(\n name: string,\n read: (...args: A) => Promise<T>,\n revalidate = DETAIL_REVALIDATE_SECONDS,\n ): (...args: A) => Promise<T | null> {\n const load = cache(\n async (...args: A): Promise<T | null> => {\n try {\n return await read(...args);\n } catch (error) {\n if (isAbsent(error)) return null;\n throw error;\n }\n },\n [name],\n { revalidate },\n );\n return async (...args: A) => {\n try {\n return await load(...args);\n } catch {\n return expireSoon();\n }\n };\n }\n\n const atAddress = <A extends [string, ...(string | number)[]], T>(read: (...args: A) => Promise<T>) =>\n async (...args: A): Promise<T | null> => (isAddress(args[0]) ? read(...args) : null);\n\n return {\n ipfsToHttpServer: toAbsoluteImageUrl,\n fetchTokenMeta: cached(\"token-meta\", atAddress((contract: string, tokenId: string) => api().tokens.get(contract, tokenId))),\n fetchCollectionMeta: cached(\"collection-meta\", atAddress((contract: string) => api().collections.get(contract))),\n fetchCollectionBySlug: cached(\"collection-by-slug\", (slug: string) => api().collections.findBySlug(slug)),\n fetchDropMeta: cached(\"drop-meta\", atAddress((contract: string) => api().drops.find(contract))),\n fetchCoinMeta: cached(\"coin-meta\", atAddress((contract: string) => api().coins.get(contract))),\n fetchCreatorProfile: cached(\"creator-profile\", (username: string) => api().creators.findByUsername(username)),\n fetchFeaturedCollections: cached(\n \"featured-collections\",\n async (limit: number) =>\n (await api().collections.list({ page: 1, limit, sort: \"recent\", isFeatured: true, hideEmpty: true })).data,\n LIST_REVALIDATE_SECONDS,\n ),\n fetchActiveOrders: cached(\n \"active-orders\",\n async (limit: number) => (await api().orders.list({ status: \"ACTIVE\", sort: \"recent\", page: 1, limit })).data,\n LIST_REVALIDATE_SECONDS,\n ),\n };\n}\n"],"mappings":"AAAA,SAAS,wBAAwC;AACjD,SAAS,0BAA0B;AAEnC,MAAM,4BAA4B;AAClC,MAAM,0BAA0B;AAChC,MAAM,iCAAiC;AACvC,MAAM,kBAAkB,oBAAI,IAAa,CAAC,KAAK,GAAG,CAAC;AAanD,MAAM,WAAW,CAAC,UAAmB,gBAAgB,IAAK,OAAuC,MAAM;AAEvG,SAAS,UAAU,OAAwB;AACzC,MAAI;AACF,qBAAiB,YAAY,KAAK;AAClC,WAAO;AAAA,EACT,QAAQ;AACN,WAAO;AAAA,EACT;AACF;AAEO,SAAS,kBAAkB,EAAE,KAAK,MAAM,GAAuB;AACpE,QAAM,aAAa,MAAM,YAAY,MAAM,CAAC,aAAa,GAAG,EAAE,YAAY,+BAA+B,CAAC;AAE1G,WAAS,OACP,MACA,MACA,aAAa,2BACsB;AACnC,UAAM,OAAO;AAAA,MACX,UAAU,SAA+B;AACvC,YAAI;AACF,iBAAO,MAAM,KAAK,GAAG,IAAI;AAAA,QAC3B,SAAS,OAAO;AACd,cAAI,SAAS,KAAK,EAAG,QAAO;AAC5B,gBAAM;AAAA,QACR;AAAA,MACF;AAAA,MACA,CAAC,IAAI;AAAA,MACL,EAAE,WAAW;AAAA,IACf;AACA,WAAO,UAAU,SAAY;AAC3B,UAAI;AACF,eAAO,MAAM,KAAK,GAAG,IAAI;AAAA,MAC3B,QAAQ;AACN,eAAO,WAAW;AAAA,MACpB;AAAA,IACF;AAAA,EACF;AAEA,QAAM,YAAY,CAAgD,SAChE,UAAU,SAAgC,UAAU,KAAK,CAAC,CAAC,IAAI,KAAK,GAAG,IAAI,IAAI;AAEjF,SAAO;AAAA,IACL,kBAAkB;AAAA,IAClB,gBAAgB,OAAO,cAAc,UAAU,CAAC,UAAkB,YAAoB,IAAI,EAAE,OAAO,IAAI,UAAU,OAAO,CAAC,CAAC;AAAA,IAC1H,qBAAqB,OAAO,mBAAmB,UAAU,CAAC,aAAqB,IAAI,EAAE,YAAY,IAAI,QAAQ,CAAC,CAAC;AAAA,IAC/G,uBAAuB,OAAO,sBAAsB,CAAC,SAAiB,IAAI,EAAE,YAAY,WAAW,IAAI,CAAC;AAAA,IACxG,eAAe,OAAO,aAAa,UAAU,CAAC,aAAqB,IAAI,EAAE,MAAM,KAAK,QAAQ,CAAC,CAAC;AAAA,IAC9F,eAAe,OAAO,aAAa,UAAU,CAAC,aAAqB,IAAI,EAAE,MAAM,IAAI,QAAQ,CAAC,CAAC;AAAA,IAC7F,qBAAqB,OAAO,mBAAmB,CAAC,aAAqB,IAAI,EAAE,SAAS,eAAe,QAAQ,CAAC;AAAA,IAC5G,0BAA0B;AAAA,MACxB;AAAA,MACA,OAAO,WACJ,MAAM,IAAI,EAAE,YAAY,KAAK,EAAE,MAAM,GAAG,OAAO,MAAM,UAAU,YAAY,MAAM,WAAW,KAAK,CAAC,GAAG;AAAA,MACxG;AAAA,IACF;AAAA,IACA,mBAAmB;AAAA,MACjB;AAAA,MACA,OAAO,WAAmB,MAAM,IAAI,EAAE,OAAO,KAAK,EAAE,QAAQ,UAAU,MAAM,UAAU,MAAM,GAAG,MAAM,CAAC,GAAG;AAAA,MACzG;AAAA,IACF;AAAA,EACF;AACF;","names":[]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@medialane/ui",
3
- "version": "0.402.0",
3
+ "version": "0.403.0",
4
4
  "description": "Shared UI components for Medialane apps",
5
5
  "type": "module",
6
6
  "sideEffects": false,