@medialane/ui 0.105.0 → 0.107.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/asset-lightbox.cjs +66 -0
- package/dist/components/asset-lightbox.cjs.map +1 -0
- package/dist/components/asset-lightbox.d.cts +11 -0
- package/dist/components/asset-lightbox.d.ts +11 -0
- package/dist/components/asset-lightbox.js +42 -0
- package/dist/components/asset-lightbox.js.map +1 -0
- package/dist/components/club-owner-actions.cjs +56 -0
- package/dist/components/club-owner-actions.cjs.map +1 -0
- package/dist/components/club-owner-actions.d.cts +11 -0
- package/dist/components/club-owner-actions.d.ts +11 -0
- package/dist/components/club-owner-actions.js +22 -0
- package/dist/components/club-owner-actions.js.map +1 -0
- package/dist/components/collection-activity-tab.cjs +60 -0
- package/dist/components/collection-activity-tab.cjs.map +1 -0
- package/dist/components/collection-activity-tab.d.cts +10 -0
- package/dist/components/collection-activity-tab.d.ts +10 -0
- package/dist/components/collection-activity-tab.js +36 -0
- package/dist/components/collection-activity-tab.js.map +1 -0
- package/dist/components/collection-traits-tab.cjs +79 -0
- package/dist/components/collection-traits-tab.cjs.map +1 -0
- package/dist/components/collection-traits-tab.d.cts +10 -0
- package/dist/components/collection-traits-tab.d.ts +10 -0
- package/dist/components/collection-traits-tab.js +55 -0
- package/dist/components/collection-traits-tab.js.map +1 -0
- package/dist/components/create-form-primitives.cjs +61 -0
- package/dist/components/create-form-primitives.cjs.map +1 -0
- package/dist/components/create-form-primitives.d.cts +16 -0
- package/dist/components/create-form-primitives.d.ts +16 -0
- package/dist/components/create-form-primitives.js +36 -0
- package/dist/components/create-form-primitives.js.map +1 -0
- package/dist/components/creation-record.cjs +86 -0
- package/dist/components/creation-record.cjs.map +1 -0
- package/dist/components/creation-record.d.cts +14 -0
- package/dist/components/creation-record.d.ts +14 -0
- package/dist/components/creation-record.js +52 -0
- package/dist/components/creation-record.js.map +1 -0
- package/dist/components/creator-chip.cjs +58 -0
- package/dist/components/creator-chip.cjs.map +1 -0
- package/dist/components/creator-chip.d.cts +10 -0
- package/dist/components/creator-chip.d.ts +10 -0
- package/dist/components/creator-chip.js +24 -0
- package/dist/components/creator-chip.js.map +1 -0
- package/dist/components/creator-score-inline.cjs +52 -0
- package/dist/components/creator-score-inline.cjs.map +1 -0
- package/dist/components/creator-score-inline.d.cts +19 -0
- package/dist/components/creator-score-inline.d.ts +19 -0
- package/dist/components/creator-score-inline.js +18 -0
- package/dist/components/creator-score-inline.js.map +1 -0
- package/dist/components/dialog.d.cts +9 -9
- package/dist/components/dialog.d.ts +9 -9
- package/dist/components/ip-type-fields.cjs +307 -0
- package/dist/components/ip-type-fields.cjs.map +1 -0
- package/dist/components/ip-type-fields.d.cts +17 -0
- package/dist/components/ip-type-fields.d.ts +17 -0
- package/dist/components/ip-type-fields.js +293 -0
- package/dist/components/ip-type-fields.js.map +1 -0
- package/dist/components/json-ld.cjs +39 -0
- package/dist/components/json-ld.cjs.map +1 -0
- package/dist/components/json-ld.d.cts +8 -0
- package/dist/components/json-ld.d.ts +8 -0
- package/dist/components/json-ld.js +15 -0
- package/dist/components/json-ld.js.map +1 -0
- package/dist/components/nav-theme-toggle.cjs +66 -0
- package/dist/components/nav-theme-toggle.cjs.map +1 -0
- package/dist/components/nav-theme-toggle.d.cts +9 -0
- package/dist/components/nav-theme-toggle.d.ts +9 -0
- package/dist/components/nav-theme-toggle.js +42 -0
- package/dist/components/nav-theme-toggle.js.map +1 -0
- package/dist/components/order-sort-control.cjs +58 -0
- package/dist/components/order-sort-control.cjs.map +1 -0
- package/dist/components/order-sort-control.d.cts +13 -0
- package/dist/components/order-sort-control.d.ts +13 -0
- package/dist/components/order-sort-control.js +39 -0
- package/dist/components/order-sort-control.js.map +1 -0
- package/dist/components/portfolio-activity.cjs +117 -0
- package/dist/components/portfolio-activity.cjs.map +1 -0
- package/dist/components/portfolio-activity.d.cts +10 -0
- package/dist/components/portfolio-activity.d.ts +10 -0
- package/dist/components/portfolio-activity.js +93 -0
- package/dist/components/portfolio-activity.js.map +1 -0
- package/dist/components/price-history-chart.cjs +130 -0
- package/dist/components/price-history-chart.cjs.map +1 -0
- package/dist/components/price-history-chart.d.cts +9 -0
- package/dist/components/price-history-chart.d.ts +9 -0
- package/dist/components/price-history-chart.js +114 -0
- package/dist/components/price-history-chart.js.map +1 -0
- package/dist/components/sheet.cjs +160 -0
- package/dist/components/sheet.cjs.map +1 -0
- package/dist/components/sheet.d.cts +30 -0
- package/dist/components/sheet.d.ts +30 -0
- package/dist/components/sheet.js +117 -0
- package/dist/components/sheet.js.map +1 -0
- package/dist/components/textarea.cjs +57 -0
- package/dist/components/textarea.cjs.map +1 -0
- package/dist/components/textarea.d.cts +6 -0
- package/dist/components/textarea.d.ts +6 -0
- package/dist/components/textarea.js +23 -0
- package/dist/components/textarea.js.map +1 -0
- package/dist/index.cjs +110 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +24 -2
- package/dist/index.d.ts +24 -2
- package/dist/index.js +88 -0
- package/dist/index.js.map +1 -1
- package/dist/utils/format-activity.cjs +143 -0
- package/dist/utils/format-activity.cjs.map +1 -0
- package/dist/utils/format-activity.d.cts +14 -0
- package/dist/utils/format-activity.d.ts +14 -0
- package/dist/utils/format-activity.js +116 -0
- package/dist/utils/format-activity.js.map +1 -0
- package/dist/utils/proxy-body.cjs +60 -0
- package/dist/utils/proxy-body.cjs.map +1 -0
- package/dist/utils/proxy-body.d.cts +22 -0
- package/dist/utils/proxy-body.d.ts +22 -0
- package/dist/utils/proxy-body.js +36 -0
- package/dist/utils/proxy-body.js.map +1 -0
- package/dist/utils/query-keys.cjs +80 -0
- package/dist/utils/query-keys.cjs.map +1 -0
- package/dist/utils/query-keys.d.cts +39 -0
- package/dist/utils/query-keys.d.ts +39 -0
- package/dist/utils/query-keys.js +54 -0
- package/dist/utils/query-keys.js.map +1 -0
- package/dist/utils/use-activities.cjs +68 -0
- package/dist/utils/use-activities.cjs.map +1 -0
- package/dist/utils/use-activities.d.cts +20 -0
- package/dist/utils/use-activities.d.ts +20 -0
- package/dist/utils/use-activities.js +33 -0
- package/dist/utils/use-activities.js.map +1 -0
- package/dist/utils/use-collections.cjs +113 -0
- package/dist/utils/use-collections.cjs.map +1 -0
- package/dist/utils/use-collections.d.cts +43 -0
- package/dist/utils/use-collections.d.ts +43 -0
- package/dist/utils/use-collections.js +75 -0
- package/dist/utils/use-collections.js.map +1 -0
- package/dist/utils/use-profiles.cjs +69 -0
- package/dist/utils/use-profiles.cjs.map +1 -0
- package/dist/utils/use-profiles.d.cts +18 -0
- package/dist/utils/use-profiles.d.ts +18 -0
- package/dist/utils/use-profiles.js +34 -0
- package/dist/utils/use-profiles.js.map +1 -0
- package/package.json +2 -2
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
"use client";
|
|
3
|
+
var __create = Object.create;
|
|
4
|
+
var __defProp = Object.defineProperty;
|
|
5
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
8
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
|
+
var __export = (target, all) => {
|
|
10
|
+
for (var name in all)
|
|
11
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
12
|
+
};
|
|
13
|
+
var __copyProps = (to, from, except, desc) => {
|
|
14
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
15
|
+
for (let key of __getOwnPropNames(from))
|
|
16
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
17
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
18
|
+
}
|
|
19
|
+
return to;
|
|
20
|
+
};
|
|
21
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
22
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
23
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
24
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
25
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
26
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
27
|
+
mod
|
|
28
|
+
));
|
|
29
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
30
|
+
var use_collections_exports = {};
|
|
31
|
+
__export(use_collections_exports, {
|
|
32
|
+
useCollection: () => useCollection,
|
|
33
|
+
useCollectionTokens: () => useCollectionTokens,
|
|
34
|
+
useCollections: () => useCollections,
|
|
35
|
+
useCollectionsByOwner: () => useCollectionsByOwner,
|
|
36
|
+
useNearbyCollectionTokens: () => useNearbyCollectionTokens
|
|
37
|
+
});
|
|
38
|
+
module.exports = __toCommonJS(use_collections_exports);
|
|
39
|
+
var import_swr = __toESM(require("swr"), 1);
|
|
40
|
+
var import_use_medialane_client = require("./use-medialane-client.js");
|
|
41
|
+
var import_query_keys = require("./query-keys.js");
|
|
42
|
+
function useCollections(getClient, page = 1, limit = 20, isFeatured, sort = "recent", hideEmpty = true, service) {
|
|
43
|
+
const client = (0, import_use_medialane_client.useMedialaneClient)(getClient);
|
|
44
|
+
const key = import_query_keys.queryKeys.collections(page, limit, isFeatured, sort, hideEmpty, service);
|
|
45
|
+
const { data, error, isLoading, mutate } = (0, import_swr.default)(
|
|
46
|
+
key,
|
|
47
|
+
async () => {
|
|
48
|
+
const res = await client.api.getCollections(page, limit, isFeatured, sort, service);
|
|
49
|
+
return hideEmpty ? { ...res, data: res.data.filter((collection) => (collection.totalSupply ?? 0) > 0) } : res;
|
|
50
|
+
},
|
|
51
|
+
{ revalidateOnFocus: false }
|
|
52
|
+
);
|
|
53
|
+
return {
|
|
54
|
+
collections: data?.data ?? [],
|
|
55
|
+
meta: data?.meta,
|
|
56
|
+
isLoading,
|
|
57
|
+
error,
|
|
58
|
+
mutate
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
function useCollection(getClient, contract) {
|
|
62
|
+
const client = (0, import_use_medialane_client.useMedialaneClient)(getClient);
|
|
63
|
+
const { data, error, isLoading } = (0, import_swr.default)(
|
|
64
|
+
contract ? import_query_keys.queryKeys.collection(contract) : null,
|
|
65
|
+
() => client.api.getCollection(contract),
|
|
66
|
+
{ revalidateOnFocus: false }
|
|
67
|
+
);
|
|
68
|
+
return { collection: data?.data ?? null, isLoading, error };
|
|
69
|
+
}
|
|
70
|
+
function useCollectionsByOwner(getClient, owner) {
|
|
71
|
+
const client = (0, import_use_medialane_client.useMedialaneClient)(getClient);
|
|
72
|
+
const { data, error, isLoading, mutate } = (0, import_swr.default)(
|
|
73
|
+
owner ? import_query_keys.queryKeys.collectionsOwner(owner) : null,
|
|
74
|
+
() => client.api.getCollectionsByOwner(owner),
|
|
75
|
+
{ revalidateOnFocus: false, refreshInterval: 6e4 }
|
|
76
|
+
);
|
|
77
|
+
return { collections: data?.data ?? [], isLoading, error, mutate };
|
|
78
|
+
}
|
|
79
|
+
function useCollectionTokens(getClient, contract, page = 1, limit = 24, sort = "recent") {
|
|
80
|
+
const client = (0, import_use_medialane_client.useMedialaneClient)(getClient);
|
|
81
|
+
const { data, error, isLoading, mutate } = (0, import_swr.default)(
|
|
82
|
+
contract ? import_query_keys.queryKeys.collectionTokens(contract, page, limit, sort) : null,
|
|
83
|
+
() => client.api.getCollectionTokens(contract, page, limit, sort),
|
|
84
|
+
{ revalidateOnFocus: false }
|
|
85
|
+
);
|
|
86
|
+
return { tokens: data?.data ?? [], meta: data?.meta, isLoading, error, mutate };
|
|
87
|
+
}
|
|
88
|
+
function pickNearbyTokens(tokens, currentTokenId, count) {
|
|
89
|
+
if (!currentTokenId) return tokens.slice(0, count);
|
|
90
|
+
const idx = tokens.findIndex((t) => String(t.tokenId) === String(currentTokenId));
|
|
91
|
+
if (idx === -1) return tokens.slice(0, count);
|
|
92
|
+
const picked = [];
|
|
93
|
+
let after = idx + 1;
|
|
94
|
+
let before = idx - 1;
|
|
95
|
+
while (picked.length < count && (after < tokens.length || before >= 0)) {
|
|
96
|
+
if (after < tokens.length) picked.push(tokens[after++]);
|
|
97
|
+
if (picked.length < count && before >= 0) picked.push(tokens[before--]);
|
|
98
|
+
}
|
|
99
|
+
return picked.sort((a, b) => Number(a.tokenId) - Number(b.tokenId));
|
|
100
|
+
}
|
|
101
|
+
function useNearbyCollectionTokens(getClient, contract, currentTokenId, count = 4, poolSize = 60) {
|
|
102
|
+
const { tokens, isLoading, error } = useCollectionTokens(getClient, contract, 1, poolSize, "oldest");
|
|
103
|
+
return { tokens: pickNearbyTokens(tokens, currentTokenId, count), isLoading, error };
|
|
104
|
+
}
|
|
105
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
106
|
+
0 && (module.exports = {
|
|
107
|
+
useCollection,
|
|
108
|
+
useCollectionTokens,
|
|
109
|
+
useCollections,
|
|
110
|
+
useCollectionsByOwner,
|
|
111
|
+
useNearbyCollectionTokens
|
|
112
|
+
});
|
|
113
|
+
//# sourceMappingURL=use-collections.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/utils/use-collections.ts"],"sourcesContent":["\"use client\";\n\nimport useSWR from \"swr\";\nimport { useMedialaneClient } from \"./use-medialane-client.js\";\nimport type { MedialaneClient } from \"@medialane/sdk/starknet\";\nimport type { ApiCollection, ApiResponse, CollectionTokensSort } from \"@medialane/sdk\";\nimport { queryKeys } from \"./query-keys.js\";\n\nexport type CollectionSort = \"recent\" | \"supply\" | \"floor\" | \"volume\" | \"name\";\n\nexport function useCollections(\n getClient: () => MedialaneClient,\n page = 1,\n limit = 20,\n isFeatured?: boolean,\n sort: CollectionSort = \"recent\",\n hideEmpty = true,\n service?: string\n) {\n const client = useMedialaneClient(getClient);\n const key = queryKeys.collections(page, limit, isFeatured, sort, hideEmpty, service);\n\n const { data, error, isLoading, mutate } = useSWR<ApiResponse<ApiCollection[]>>(\n key,\n async () => {\n const res = await client.api.getCollections(page, limit, isFeatured, sort, service);\n return hideEmpty\n ? { ...res, data: res.data.filter((collection) => (collection.totalSupply ?? 0) > 0) }\n : res;\n },\n { revalidateOnFocus: false }\n );\n\n return {\n collections: data?.data ?? [],\n meta: data?.meta,\n isLoading,\n error,\n mutate,\n };\n}\n\nexport function useCollection(getClient: () => MedialaneClient, contract: string | null) {\n const client = useMedialaneClient(getClient);\n\n const { data, error, isLoading } = useSWR(\n contract ? queryKeys.collection(contract) : null,\n () => client.api.getCollection(contract!),\n { revalidateOnFocus: false }\n );\n\n return { collection: data?.data ?? null, isLoading, error };\n}\n\nexport function useCollectionsByOwner(getClient: () => MedialaneClient, owner: string | null) {\n const client = useMedialaneClient(getClient);\n\n const { data, error, isLoading, mutate } = useSWR(\n owner ? queryKeys.collectionsOwner(owner) : null,\n () => client.api.getCollectionsByOwner(owner!),\n { revalidateOnFocus: false, refreshInterval: 60_000 }\n );\n\n return { collections: data?.data ?? [], isLoading, error, mutate };\n}\n\nexport function useCollectionTokens(\n getClient: () => MedialaneClient,\n contract: string | null,\n page = 1,\n limit = 24,\n sort: CollectionTokensSort = \"recent\"\n) {\n const client = useMedialaneClient(getClient);\n\n const { data, error, isLoading, mutate } = useSWR(\n contract ? queryKeys.collectionTokens(contract, page, limit, sort) : null,\n () => client.api.getCollectionTokens(contract!, page, limit, sort),\n { revalidateOnFocus: false }\n );\n\n return { tokens: data?.data ?? [], meta: data?.meta, isLoading, error, mutate };\n}\n\n/** From a token list ordered by tokenId (ascending), picks up to `count`\n * tokens surrounding `currentTokenId` — the ones after it first, then the\n * ones before, backfilling from whichever side has room near a collection\n * edge. Returned in ascending tokenId order for a natural \"keep browsing\"\n * feel. Falls back to the first `count` tokens when the current one isn't\n * in the fetched page (e.g. a collection larger than the pool). */\nfunction pickNearbyTokens<T extends { tokenId: string }>(\n tokens: T[],\n currentTokenId: string | null,\n count: number\n): T[] {\n if (!currentTokenId) return tokens.slice(0, count);\n const idx = tokens.findIndex((t) => String(t.tokenId) === String(currentTokenId));\n if (idx === -1) return tokens.slice(0, count);\n\n const picked: T[] = [];\n let after = idx + 1;\n let before = idx - 1;\n while (picked.length < count && (after < tokens.length || before >= 0)) {\n if (after < tokens.length) picked.push(tokens[after++]);\n if (picked.length < count && before >= 0) picked.push(tokens[before--]);\n }\n return picked.sort((a, b) => Number(a.tokenId) - Number(b.tokenId));\n}\n\n/** Asset-page \"more from this collection\" strip — tokens near `currentTokenId`\n * by id, not just whatever minted most recently (which can be anywhere in a\n * large collection and feel unrelated to the piece being viewed). Pulls a\n * bounded pool sorted `oldest` (ascending mint order, i.e. tokenId order for\n * every Medialane-issued collection) and windows around the current token. */\nexport function useNearbyCollectionTokens(\n getClient: () => MedialaneClient,\n contract: string | null,\n currentTokenId: string | null,\n count = 4,\n poolSize = 60\n) {\n const { tokens, isLoading, error } = useCollectionTokens(getClient, contract, 1, poolSize, \"oldest\");\n return { tokens: pickNearbyTokens(tokens, currentTokenId, count), isLoading, error };\n}\n"],"mappings":"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","names":["useSWR"]}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import * as swr from 'swr';
|
|
2
|
+
import * as _medialane_sdk from '@medialane/sdk';
|
|
3
|
+
import { ApiCollection, CollectionTokensSort, ApiResponse } from '@medialane/sdk';
|
|
4
|
+
import { MedialaneClient } from '@medialane/sdk/starknet';
|
|
5
|
+
|
|
6
|
+
type CollectionSort = "recent" | "supply" | "floor" | "volume" | "name";
|
|
7
|
+
declare function useCollections(getClient: () => MedialaneClient, page?: number, limit?: number, isFeatured?: boolean, sort?: CollectionSort, hideEmpty?: boolean, service?: string): {
|
|
8
|
+
collections: ApiCollection[];
|
|
9
|
+
meta: _medialane_sdk.ApiMeta | undefined;
|
|
10
|
+
isLoading: boolean;
|
|
11
|
+
error: any;
|
|
12
|
+
mutate: swr.KeyedMutator<ApiResponse<ApiCollection[]>>;
|
|
13
|
+
};
|
|
14
|
+
declare function useCollection(getClient: () => MedialaneClient, contract: string | null): {
|
|
15
|
+
collection: ApiCollection | null;
|
|
16
|
+
isLoading: boolean;
|
|
17
|
+
error: any;
|
|
18
|
+
};
|
|
19
|
+
declare function useCollectionsByOwner(getClient: () => MedialaneClient, owner: string | null): {
|
|
20
|
+
collections: ApiCollection[];
|
|
21
|
+
isLoading: boolean;
|
|
22
|
+
error: any;
|
|
23
|
+
mutate: swr.KeyedMutator<ApiResponse<ApiCollection[]>>;
|
|
24
|
+
};
|
|
25
|
+
declare function useCollectionTokens(getClient: () => MedialaneClient, contract: string | null, page?: number, limit?: number, sort?: CollectionTokensSort): {
|
|
26
|
+
tokens: _medialane_sdk.ApiToken[];
|
|
27
|
+
meta: _medialane_sdk.ApiMeta | undefined;
|
|
28
|
+
isLoading: boolean;
|
|
29
|
+
error: any;
|
|
30
|
+
mutate: swr.KeyedMutator<ApiResponse<_medialane_sdk.ApiToken[]>>;
|
|
31
|
+
};
|
|
32
|
+
/** Asset-page "more from this collection" strip — tokens near `currentTokenId`
|
|
33
|
+
* by id, not just whatever minted most recently (which can be anywhere in a
|
|
34
|
+
* large collection and feel unrelated to the piece being viewed). Pulls a
|
|
35
|
+
* bounded pool sorted `oldest` (ascending mint order, i.e. tokenId order for
|
|
36
|
+
* every Medialane-issued collection) and windows around the current token. */
|
|
37
|
+
declare function useNearbyCollectionTokens(getClient: () => MedialaneClient, contract: string | null, currentTokenId: string | null, count?: number, poolSize?: number): {
|
|
38
|
+
tokens: _medialane_sdk.ApiToken[];
|
|
39
|
+
isLoading: boolean;
|
|
40
|
+
error: any;
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
export { type CollectionSort, useCollection, useCollectionTokens, useCollections, useCollectionsByOwner, useNearbyCollectionTokens };
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import * as swr from 'swr';
|
|
2
|
+
import * as _medialane_sdk from '@medialane/sdk';
|
|
3
|
+
import { ApiCollection, CollectionTokensSort, ApiResponse } from '@medialane/sdk';
|
|
4
|
+
import { MedialaneClient } from '@medialane/sdk/starknet';
|
|
5
|
+
|
|
6
|
+
type CollectionSort = "recent" | "supply" | "floor" | "volume" | "name";
|
|
7
|
+
declare function useCollections(getClient: () => MedialaneClient, page?: number, limit?: number, isFeatured?: boolean, sort?: CollectionSort, hideEmpty?: boolean, service?: string): {
|
|
8
|
+
collections: ApiCollection[];
|
|
9
|
+
meta: _medialane_sdk.ApiMeta | undefined;
|
|
10
|
+
isLoading: boolean;
|
|
11
|
+
error: any;
|
|
12
|
+
mutate: swr.KeyedMutator<ApiResponse<ApiCollection[]>>;
|
|
13
|
+
};
|
|
14
|
+
declare function useCollection(getClient: () => MedialaneClient, contract: string | null): {
|
|
15
|
+
collection: ApiCollection | null;
|
|
16
|
+
isLoading: boolean;
|
|
17
|
+
error: any;
|
|
18
|
+
};
|
|
19
|
+
declare function useCollectionsByOwner(getClient: () => MedialaneClient, owner: string | null): {
|
|
20
|
+
collections: ApiCollection[];
|
|
21
|
+
isLoading: boolean;
|
|
22
|
+
error: any;
|
|
23
|
+
mutate: swr.KeyedMutator<ApiResponse<ApiCollection[]>>;
|
|
24
|
+
};
|
|
25
|
+
declare function useCollectionTokens(getClient: () => MedialaneClient, contract: string | null, page?: number, limit?: number, sort?: CollectionTokensSort): {
|
|
26
|
+
tokens: _medialane_sdk.ApiToken[];
|
|
27
|
+
meta: _medialane_sdk.ApiMeta | undefined;
|
|
28
|
+
isLoading: boolean;
|
|
29
|
+
error: any;
|
|
30
|
+
mutate: swr.KeyedMutator<ApiResponse<_medialane_sdk.ApiToken[]>>;
|
|
31
|
+
};
|
|
32
|
+
/** Asset-page "more from this collection" strip — tokens near `currentTokenId`
|
|
33
|
+
* by id, not just whatever minted most recently (which can be anywhere in a
|
|
34
|
+
* large collection and feel unrelated to the piece being viewed). Pulls a
|
|
35
|
+
* bounded pool sorted `oldest` (ascending mint order, i.e. tokenId order for
|
|
36
|
+
* every Medialane-issued collection) and windows around the current token. */
|
|
37
|
+
declare function useNearbyCollectionTokens(getClient: () => MedialaneClient, contract: string | null, currentTokenId: string | null, count?: number, poolSize?: number): {
|
|
38
|
+
tokens: _medialane_sdk.ApiToken[];
|
|
39
|
+
isLoading: boolean;
|
|
40
|
+
error: any;
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
export { type CollectionSort, useCollection, useCollectionTokens, useCollections, useCollectionsByOwner, useNearbyCollectionTokens };
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import useSWR from "swr";
|
|
3
|
+
import { useMedialaneClient } from "./use-medialane-client.js";
|
|
4
|
+
import { queryKeys } from "./query-keys.js";
|
|
5
|
+
function useCollections(getClient, page = 1, limit = 20, isFeatured, sort = "recent", hideEmpty = true, service) {
|
|
6
|
+
const client = useMedialaneClient(getClient);
|
|
7
|
+
const key = queryKeys.collections(page, limit, isFeatured, sort, hideEmpty, service);
|
|
8
|
+
const { data, error, isLoading, mutate } = useSWR(
|
|
9
|
+
key,
|
|
10
|
+
async () => {
|
|
11
|
+
const res = await client.api.getCollections(page, limit, isFeatured, sort, service);
|
|
12
|
+
return hideEmpty ? { ...res, data: res.data.filter((collection) => (collection.totalSupply ?? 0) > 0) } : res;
|
|
13
|
+
},
|
|
14
|
+
{ revalidateOnFocus: false }
|
|
15
|
+
);
|
|
16
|
+
return {
|
|
17
|
+
collections: data?.data ?? [],
|
|
18
|
+
meta: data?.meta,
|
|
19
|
+
isLoading,
|
|
20
|
+
error,
|
|
21
|
+
mutate
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
function useCollection(getClient, contract) {
|
|
25
|
+
const client = useMedialaneClient(getClient);
|
|
26
|
+
const { data, error, isLoading } = useSWR(
|
|
27
|
+
contract ? queryKeys.collection(contract) : null,
|
|
28
|
+
() => client.api.getCollection(contract),
|
|
29
|
+
{ revalidateOnFocus: false }
|
|
30
|
+
);
|
|
31
|
+
return { collection: data?.data ?? null, isLoading, error };
|
|
32
|
+
}
|
|
33
|
+
function useCollectionsByOwner(getClient, owner) {
|
|
34
|
+
const client = useMedialaneClient(getClient);
|
|
35
|
+
const { data, error, isLoading, mutate } = useSWR(
|
|
36
|
+
owner ? queryKeys.collectionsOwner(owner) : null,
|
|
37
|
+
() => client.api.getCollectionsByOwner(owner),
|
|
38
|
+
{ revalidateOnFocus: false, refreshInterval: 6e4 }
|
|
39
|
+
);
|
|
40
|
+
return { collections: data?.data ?? [], isLoading, error, mutate };
|
|
41
|
+
}
|
|
42
|
+
function useCollectionTokens(getClient, contract, page = 1, limit = 24, sort = "recent") {
|
|
43
|
+
const client = useMedialaneClient(getClient);
|
|
44
|
+
const { data, error, isLoading, mutate } = useSWR(
|
|
45
|
+
contract ? queryKeys.collectionTokens(contract, page, limit, sort) : null,
|
|
46
|
+
() => client.api.getCollectionTokens(contract, page, limit, sort),
|
|
47
|
+
{ revalidateOnFocus: false }
|
|
48
|
+
);
|
|
49
|
+
return { tokens: data?.data ?? [], meta: data?.meta, isLoading, error, mutate };
|
|
50
|
+
}
|
|
51
|
+
function pickNearbyTokens(tokens, currentTokenId, count) {
|
|
52
|
+
if (!currentTokenId) return tokens.slice(0, count);
|
|
53
|
+
const idx = tokens.findIndex((t) => String(t.tokenId) === String(currentTokenId));
|
|
54
|
+
if (idx === -1) return tokens.slice(0, count);
|
|
55
|
+
const picked = [];
|
|
56
|
+
let after = idx + 1;
|
|
57
|
+
let before = idx - 1;
|
|
58
|
+
while (picked.length < count && (after < tokens.length || before >= 0)) {
|
|
59
|
+
if (after < tokens.length) picked.push(tokens[after++]);
|
|
60
|
+
if (picked.length < count && before >= 0) picked.push(tokens[before--]);
|
|
61
|
+
}
|
|
62
|
+
return picked.sort((a, b) => Number(a.tokenId) - Number(b.tokenId));
|
|
63
|
+
}
|
|
64
|
+
function useNearbyCollectionTokens(getClient, contract, currentTokenId, count = 4, poolSize = 60) {
|
|
65
|
+
const { tokens, isLoading, error } = useCollectionTokens(getClient, contract, 1, poolSize, "oldest");
|
|
66
|
+
return { tokens: pickNearbyTokens(tokens, currentTokenId, count), isLoading, error };
|
|
67
|
+
}
|
|
68
|
+
export {
|
|
69
|
+
useCollection,
|
|
70
|
+
useCollectionTokens,
|
|
71
|
+
useCollections,
|
|
72
|
+
useCollectionsByOwner,
|
|
73
|
+
useNearbyCollectionTokens
|
|
74
|
+
};
|
|
75
|
+
//# sourceMappingURL=use-collections.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/utils/use-collections.ts"],"sourcesContent":["\"use client\";\n\nimport useSWR from \"swr\";\nimport { useMedialaneClient } from \"./use-medialane-client.js\";\nimport type { MedialaneClient } from \"@medialane/sdk/starknet\";\nimport type { ApiCollection, ApiResponse, CollectionTokensSort } from \"@medialane/sdk\";\nimport { queryKeys } from \"./query-keys.js\";\n\nexport type CollectionSort = \"recent\" | \"supply\" | \"floor\" | \"volume\" | \"name\";\n\nexport function useCollections(\n getClient: () => MedialaneClient,\n page = 1,\n limit = 20,\n isFeatured?: boolean,\n sort: CollectionSort = \"recent\",\n hideEmpty = true,\n service?: string\n) {\n const client = useMedialaneClient(getClient);\n const key = queryKeys.collections(page, limit, isFeatured, sort, hideEmpty, service);\n\n const { data, error, isLoading, mutate } = useSWR<ApiResponse<ApiCollection[]>>(\n key,\n async () => {\n const res = await client.api.getCollections(page, limit, isFeatured, sort, service);\n return hideEmpty\n ? { ...res, data: res.data.filter((collection) => (collection.totalSupply ?? 0) > 0) }\n : res;\n },\n { revalidateOnFocus: false }\n );\n\n return {\n collections: data?.data ?? [],\n meta: data?.meta,\n isLoading,\n error,\n mutate,\n };\n}\n\nexport function useCollection(getClient: () => MedialaneClient, contract: string | null) {\n const client = useMedialaneClient(getClient);\n\n const { data, error, isLoading } = useSWR(\n contract ? queryKeys.collection(contract) : null,\n () => client.api.getCollection(contract!),\n { revalidateOnFocus: false }\n );\n\n return { collection: data?.data ?? null, isLoading, error };\n}\n\nexport function useCollectionsByOwner(getClient: () => MedialaneClient, owner: string | null) {\n const client = useMedialaneClient(getClient);\n\n const { data, error, isLoading, mutate } = useSWR(\n owner ? queryKeys.collectionsOwner(owner) : null,\n () => client.api.getCollectionsByOwner(owner!),\n { revalidateOnFocus: false, refreshInterval: 60_000 }\n );\n\n return { collections: data?.data ?? [], isLoading, error, mutate };\n}\n\nexport function useCollectionTokens(\n getClient: () => MedialaneClient,\n contract: string | null,\n page = 1,\n limit = 24,\n sort: CollectionTokensSort = \"recent\"\n) {\n const client = useMedialaneClient(getClient);\n\n const { data, error, isLoading, mutate } = useSWR(\n contract ? queryKeys.collectionTokens(contract, page, limit, sort) : null,\n () => client.api.getCollectionTokens(contract!, page, limit, sort),\n { revalidateOnFocus: false }\n );\n\n return { tokens: data?.data ?? [], meta: data?.meta, isLoading, error, mutate };\n}\n\n/** From a token list ordered by tokenId (ascending), picks up to `count`\n * tokens surrounding `currentTokenId` — the ones after it first, then the\n * ones before, backfilling from whichever side has room near a collection\n * edge. Returned in ascending tokenId order for a natural \"keep browsing\"\n * feel. Falls back to the first `count` tokens when the current one isn't\n * in the fetched page (e.g. a collection larger than the pool). */\nfunction pickNearbyTokens<T extends { tokenId: string }>(\n tokens: T[],\n currentTokenId: string | null,\n count: number\n): T[] {\n if (!currentTokenId) return tokens.slice(0, count);\n const idx = tokens.findIndex((t) => String(t.tokenId) === String(currentTokenId));\n if (idx === -1) return tokens.slice(0, count);\n\n const picked: T[] = [];\n let after = idx + 1;\n let before = idx - 1;\n while (picked.length < count && (after < tokens.length || before >= 0)) {\n if (after < tokens.length) picked.push(tokens[after++]);\n if (picked.length < count && before >= 0) picked.push(tokens[before--]);\n }\n return picked.sort((a, b) => Number(a.tokenId) - Number(b.tokenId));\n}\n\n/** Asset-page \"more from this collection\" strip — tokens near `currentTokenId`\n * by id, not just whatever minted most recently (which can be anywhere in a\n * large collection and feel unrelated to the piece being viewed). Pulls a\n * bounded pool sorted `oldest` (ascending mint order, i.e. tokenId order for\n * every Medialane-issued collection) and windows around the current token. */\nexport function useNearbyCollectionTokens(\n getClient: () => MedialaneClient,\n contract: string | null,\n currentTokenId: string | null,\n count = 4,\n poolSize = 60\n) {\n const { tokens, isLoading, error } = useCollectionTokens(getClient, contract, 1, poolSize, \"oldest\");\n return { tokens: pickNearbyTokens(tokens, currentTokenId, count), isLoading, error };\n}\n"],"mappings":"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","names":[]}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
"use client";
|
|
3
|
+
var __create = Object.create;
|
|
4
|
+
var __defProp = Object.defineProperty;
|
|
5
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
8
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
|
+
var __export = (target, all) => {
|
|
10
|
+
for (var name in all)
|
|
11
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
12
|
+
};
|
|
13
|
+
var __copyProps = (to, from, except, desc) => {
|
|
14
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
15
|
+
for (let key of __getOwnPropNames(from))
|
|
16
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
17
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
18
|
+
}
|
|
19
|
+
return to;
|
|
20
|
+
};
|
|
21
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
22
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
23
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
24
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
25
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
26
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
27
|
+
mod
|
|
28
|
+
));
|
|
29
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
30
|
+
var use_profiles_exports = {};
|
|
31
|
+
__export(use_profiles_exports, {
|
|
32
|
+
useCollectionProfile: () => useCollectionProfile,
|
|
33
|
+
useCreatorProfile: () => useCreatorProfile
|
|
34
|
+
});
|
|
35
|
+
module.exports = __toCommonJS(use_profiles_exports);
|
|
36
|
+
var import_swr = __toESM(require("swr"), 1);
|
|
37
|
+
function useCollectionProfile(getClient, contractAddress) {
|
|
38
|
+
const { data, error, isLoading, mutate } = (0, import_swr.default)(
|
|
39
|
+
contractAddress ? `profile-collection-${contractAddress}` : null,
|
|
40
|
+
() => getClient().api.getCollectionProfile(contractAddress),
|
|
41
|
+
{ revalidateOnFocus: false }
|
|
42
|
+
);
|
|
43
|
+
return { profile: data ?? null, isLoading, error, mutate };
|
|
44
|
+
}
|
|
45
|
+
function useCreatorProfile(getClient, walletAddress) {
|
|
46
|
+
const { data, error, isLoading, mutate } = (0, import_swr.default)(
|
|
47
|
+
walletAddress ? `profile-creator-${walletAddress}` : null,
|
|
48
|
+
async () => {
|
|
49
|
+
try {
|
|
50
|
+
return await getClient().api.getCreatorProfile(walletAddress);
|
|
51
|
+
} catch (e) {
|
|
52
|
+
const msg = e instanceof Error ? e.message : "";
|
|
53
|
+
const status = e?.status;
|
|
54
|
+
if (msg.includes("404") || msg.includes("Not Found") || status === 404) {
|
|
55
|
+
return null;
|
|
56
|
+
}
|
|
57
|
+
throw e;
|
|
58
|
+
}
|
|
59
|
+
},
|
|
60
|
+
{ revalidateOnFocus: false, revalidateOnMount: true }
|
|
61
|
+
);
|
|
62
|
+
return { profile: data ?? null, isLoading, error, mutate };
|
|
63
|
+
}
|
|
64
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
65
|
+
0 && (module.exports = {
|
|
66
|
+
useCollectionProfile,
|
|
67
|
+
useCreatorProfile
|
|
68
|
+
});
|
|
69
|
+
//# sourceMappingURL=use-profiles.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/utils/use-profiles.ts"],"sourcesContent":["\"use client\";\n\nimport useSWR from \"swr\";\nimport type { MedialaneClient } from \"@medialane/sdk/starknet\";\n\nexport function useCollectionProfile(getClient: () => MedialaneClient, contractAddress: string | undefined) {\n const { data, error, isLoading, mutate } = useSWR(\n contractAddress ? `profile-collection-${contractAddress}` : null,\n () => getClient().api.getCollectionProfile(contractAddress!),\n { revalidateOnFocus: false }\n );\n return { profile: data ?? null, isLoading, error, mutate };\n}\n\nexport function useCreatorProfile(getClient: () => MedialaneClient, walletAddress: string | undefined) {\n const { data, error, isLoading, mutate } = useSWR(\n walletAddress ? `profile-creator-${walletAddress}` : null,\n async () => {\n try {\n return await getClient().api.getCreatorProfile(walletAddress!);\n } catch (e: unknown) {\n // 404 means no profile yet — return null instead of throwing so the\n // global SWR error toast is not triggered and the form stays editable.\n const msg = e instanceof Error ? e.message : \"\";\n const status = (e as { status?: number })?.status;\n if (msg.includes(\"404\") || msg.includes(\"Not Found\") || status === 404) {\n return null;\n }\n throw e;\n }\n },\n { revalidateOnFocus: false, revalidateOnMount: true }\n );\n return { profile: data ?? null, isLoading, error, mutate };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,iBAAmB;AAGZ,SAAS,qBAAqB,WAAkC,iBAAqC;AAC1G,QAAM,EAAE,MAAM,OAAO,WAAW,OAAO,QAAI,WAAAA;AAAA,IACzC,kBAAkB,sBAAsB,eAAe,KAAK;AAAA,IAC5D,MAAM,UAAU,EAAE,IAAI,qBAAqB,eAAgB;AAAA,IAC3D,EAAE,mBAAmB,MAAM;AAAA,EAC7B;AACA,SAAO,EAAE,SAAS,QAAQ,MAAM,WAAW,OAAO,OAAO;AAC3D;AAEO,SAAS,kBAAkB,WAAkC,eAAmC;AACrG,QAAM,EAAE,MAAM,OAAO,WAAW,OAAO,QAAI,WAAAA;AAAA,IACzC,gBAAgB,mBAAmB,aAAa,KAAK;AAAA,IACrD,YAAY;AACV,UAAI;AACF,eAAO,MAAM,UAAU,EAAE,IAAI,kBAAkB,aAAc;AAAA,MAC/D,SAAS,GAAY;AAGnB,cAAM,MAAM,aAAa,QAAQ,EAAE,UAAU;AAC7C,cAAM,SAAU,GAA2B;AAC3C,YAAI,IAAI,SAAS,KAAK,KAAK,IAAI,SAAS,WAAW,KAAK,WAAW,KAAK;AACtE,iBAAO;AAAA,QACT;AACA,cAAM;AAAA,MACR;AAAA,IACF;AAAA,IACA,EAAE,mBAAmB,OAAO,mBAAmB,KAAK;AAAA,EACtD;AACA,SAAO,EAAE,SAAS,QAAQ,MAAM,WAAW,OAAO,OAAO;AAC3D;","names":["useSWR"]}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import * as swr from 'swr';
|
|
2
|
+
import * as _medialane_sdk from '@medialane/sdk';
|
|
3
|
+
import { MedialaneClient } from '@medialane/sdk/starknet';
|
|
4
|
+
|
|
5
|
+
declare function useCollectionProfile(getClient: () => MedialaneClient, contractAddress: string | undefined): {
|
|
6
|
+
profile: _medialane_sdk.ApiCollectionProfile | null;
|
|
7
|
+
isLoading: boolean;
|
|
8
|
+
error: any;
|
|
9
|
+
mutate: swr.KeyedMutator<_medialane_sdk.ApiCollectionProfile | null>;
|
|
10
|
+
};
|
|
11
|
+
declare function useCreatorProfile(getClient: () => MedialaneClient, walletAddress: string | undefined): {
|
|
12
|
+
profile: _medialane_sdk.ApiCreatorProfile | null;
|
|
13
|
+
isLoading: boolean;
|
|
14
|
+
error: any;
|
|
15
|
+
mutate: swr.KeyedMutator<_medialane_sdk.ApiCreatorProfile | null>;
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
export { useCollectionProfile, useCreatorProfile };
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import * as swr from 'swr';
|
|
2
|
+
import * as _medialane_sdk from '@medialane/sdk';
|
|
3
|
+
import { MedialaneClient } from '@medialane/sdk/starknet';
|
|
4
|
+
|
|
5
|
+
declare function useCollectionProfile(getClient: () => MedialaneClient, contractAddress: string | undefined): {
|
|
6
|
+
profile: _medialane_sdk.ApiCollectionProfile | null;
|
|
7
|
+
isLoading: boolean;
|
|
8
|
+
error: any;
|
|
9
|
+
mutate: swr.KeyedMutator<_medialane_sdk.ApiCollectionProfile | null>;
|
|
10
|
+
};
|
|
11
|
+
declare function useCreatorProfile(getClient: () => MedialaneClient, walletAddress: string | undefined): {
|
|
12
|
+
profile: _medialane_sdk.ApiCreatorProfile | null;
|
|
13
|
+
isLoading: boolean;
|
|
14
|
+
error: any;
|
|
15
|
+
mutate: swr.KeyedMutator<_medialane_sdk.ApiCreatorProfile | null>;
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
export { useCollectionProfile, useCreatorProfile };
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import useSWR from "swr";
|
|
3
|
+
function useCollectionProfile(getClient, contractAddress) {
|
|
4
|
+
const { data, error, isLoading, mutate } = useSWR(
|
|
5
|
+
contractAddress ? `profile-collection-${contractAddress}` : null,
|
|
6
|
+
() => getClient().api.getCollectionProfile(contractAddress),
|
|
7
|
+
{ revalidateOnFocus: false }
|
|
8
|
+
);
|
|
9
|
+
return { profile: data ?? null, isLoading, error, mutate };
|
|
10
|
+
}
|
|
11
|
+
function useCreatorProfile(getClient, walletAddress) {
|
|
12
|
+
const { data, error, isLoading, mutate } = useSWR(
|
|
13
|
+
walletAddress ? `profile-creator-${walletAddress}` : null,
|
|
14
|
+
async () => {
|
|
15
|
+
try {
|
|
16
|
+
return await getClient().api.getCreatorProfile(walletAddress);
|
|
17
|
+
} catch (e) {
|
|
18
|
+
const msg = e instanceof Error ? e.message : "";
|
|
19
|
+
const status = e?.status;
|
|
20
|
+
if (msg.includes("404") || msg.includes("Not Found") || status === 404) {
|
|
21
|
+
return null;
|
|
22
|
+
}
|
|
23
|
+
throw e;
|
|
24
|
+
}
|
|
25
|
+
},
|
|
26
|
+
{ revalidateOnFocus: false, revalidateOnMount: true }
|
|
27
|
+
);
|
|
28
|
+
return { profile: data ?? null, isLoading, error, mutate };
|
|
29
|
+
}
|
|
30
|
+
export {
|
|
31
|
+
useCollectionProfile,
|
|
32
|
+
useCreatorProfile
|
|
33
|
+
};
|
|
34
|
+
//# sourceMappingURL=use-profiles.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/utils/use-profiles.ts"],"sourcesContent":["\"use client\";\n\nimport useSWR from \"swr\";\nimport type { MedialaneClient } from \"@medialane/sdk/starknet\";\n\nexport function useCollectionProfile(getClient: () => MedialaneClient, contractAddress: string | undefined) {\n const { data, error, isLoading, mutate } = useSWR(\n contractAddress ? `profile-collection-${contractAddress}` : null,\n () => getClient().api.getCollectionProfile(contractAddress!),\n { revalidateOnFocus: false }\n );\n return { profile: data ?? null, isLoading, error, mutate };\n}\n\nexport function useCreatorProfile(getClient: () => MedialaneClient, walletAddress: string | undefined) {\n const { data, error, isLoading, mutate } = useSWR(\n walletAddress ? `profile-creator-${walletAddress}` : null,\n async () => {\n try {\n return await getClient().api.getCreatorProfile(walletAddress!);\n } catch (e: unknown) {\n // 404 means no profile yet — return null instead of throwing so the\n // global SWR error toast is not triggered and the form stays editable.\n const msg = e instanceof Error ? e.message : \"\";\n const status = (e as { status?: number })?.status;\n if (msg.includes(\"404\") || msg.includes(\"Not Found\") || status === 404) {\n return null;\n }\n throw e;\n }\n },\n { revalidateOnFocus: false, revalidateOnMount: true }\n );\n return { profile: data ?? null, isLoading, error, mutate };\n}\n"],"mappings":";AAEA,OAAO,YAAY;AAGZ,SAAS,qBAAqB,WAAkC,iBAAqC;AAC1G,QAAM,EAAE,MAAM,OAAO,WAAW,OAAO,IAAI;AAAA,IACzC,kBAAkB,sBAAsB,eAAe,KAAK;AAAA,IAC5D,MAAM,UAAU,EAAE,IAAI,qBAAqB,eAAgB;AAAA,IAC3D,EAAE,mBAAmB,MAAM;AAAA,EAC7B;AACA,SAAO,EAAE,SAAS,QAAQ,MAAM,WAAW,OAAO,OAAO;AAC3D;AAEO,SAAS,kBAAkB,WAAkC,eAAmC;AACrG,QAAM,EAAE,MAAM,OAAO,WAAW,OAAO,IAAI;AAAA,IACzC,gBAAgB,mBAAmB,aAAa,KAAK;AAAA,IACrD,YAAY;AACV,UAAI;AACF,eAAO,MAAM,UAAU,EAAE,IAAI,kBAAkB,aAAc;AAAA,MAC/D,SAAS,GAAY;AAGnB,cAAM,MAAM,aAAa,QAAQ,EAAE,UAAU;AAC7C,cAAM,SAAU,GAA2B;AAC3C,YAAI,IAAI,SAAS,KAAK,KAAK,IAAI,SAAS,WAAW,KAAK,WAAW,KAAK;AACtE,iBAAO;AAAA,QACT;AACA,cAAM;AAAA,MACR;AAAA,IACF;AAAA,IACA,EAAE,mBAAmB,OAAO,mBAAmB,KAAK;AAAA,EACtD;AACA,SAAO,EAAE,SAAS,QAAQ,MAAM,WAAW,OAAO,OAAO;AAC3D;","names":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@medialane/ui",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.107.0",
|
|
4
4
|
"description": "Shared UI components for Medialane apps",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -76,7 +76,7 @@
|
|
|
76
76
|
"tailwind-merge": ">=2.0.0"
|
|
77
77
|
},
|
|
78
78
|
"devDependencies": {
|
|
79
|
-
"@medialane/sdk": "0.
|
|
79
|
+
"@medialane/sdk": "0.85.4",
|
|
80
80
|
"@radix-ui/react-checkbox": "^1.3.8",
|
|
81
81
|
"@radix-ui/react-collapsible": "^1.1.17",
|
|
82
82
|
"@radix-ui/react-dialog": "^1.1.20",
|