@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.
Files changed (141) hide show
  1. package/dist/components/asset-lightbox.cjs +66 -0
  2. package/dist/components/asset-lightbox.cjs.map +1 -0
  3. package/dist/components/asset-lightbox.d.cts +11 -0
  4. package/dist/components/asset-lightbox.d.ts +11 -0
  5. package/dist/components/asset-lightbox.js +42 -0
  6. package/dist/components/asset-lightbox.js.map +1 -0
  7. package/dist/components/club-owner-actions.cjs +56 -0
  8. package/dist/components/club-owner-actions.cjs.map +1 -0
  9. package/dist/components/club-owner-actions.d.cts +11 -0
  10. package/dist/components/club-owner-actions.d.ts +11 -0
  11. package/dist/components/club-owner-actions.js +22 -0
  12. package/dist/components/club-owner-actions.js.map +1 -0
  13. package/dist/components/collection-activity-tab.cjs +60 -0
  14. package/dist/components/collection-activity-tab.cjs.map +1 -0
  15. package/dist/components/collection-activity-tab.d.cts +10 -0
  16. package/dist/components/collection-activity-tab.d.ts +10 -0
  17. package/dist/components/collection-activity-tab.js +36 -0
  18. package/dist/components/collection-activity-tab.js.map +1 -0
  19. package/dist/components/collection-traits-tab.cjs +79 -0
  20. package/dist/components/collection-traits-tab.cjs.map +1 -0
  21. package/dist/components/collection-traits-tab.d.cts +10 -0
  22. package/dist/components/collection-traits-tab.d.ts +10 -0
  23. package/dist/components/collection-traits-tab.js +55 -0
  24. package/dist/components/collection-traits-tab.js.map +1 -0
  25. package/dist/components/create-form-primitives.cjs +61 -0
  26. package/dist/components/create-form-primitives.cjs.map +1 -0
  27. package/dist/components/create-form-primitives.d.cts +16 -0
  28. package/dist/components/create-form-primitives.d.ts +16 -0
  29. package/dist/components/create-form-primitives.js +36 -0
  30. package/dist/components/create-form-primitives.js.map +1 -0
  31. package/dist/components/creation-record.cjs +86 -0
  32. package/dist/components/creation-record.cjs.map +1 -0
  33. package/dist/components/creation-record.d.cts +14 -0
  34. package/dist/components/creation-record.d.ts +14 -0
  35. package/dist/components/creation-record.js +52 -0
  36. package/dist/components/creation-record.js.map +1 -0
  37. package/dist/components/creator-chip.cjs +58 -0
  38. package/dist/components/creator-chip.cjs.map +1 -0
  39. package/dist/components/creator-chip.d.cts +10 -0
  40. package/dist/components/creator-chip.d.ts +10 -0
  41. package/dist/components/creator-chip.js +24 -0
  42. package/dist/components/creator-chip.js.map +1 -0
  43. package/dist/components/creator-score-inline.cjs +52 -0
  44. package/dist/components/creator-score-inline.cjs.map +1 -0
  45. package/dist/components/creator-score-inline.d.cts +19 -0
  46. package/dist/components/creator-score-inline.d.ts +19 -0
  47. package/dist/components/creator-score-inline.js +18 -0
  48. package/dist/components/creator-score-inline.js.map +1 -0
  49. package/dist/components/dialog.d.cts +9 -9
  50. package/dist/components/dialog.d.ts +9 -9
  51. package/dist/components/ip-type-fields.cjs +307 -0
  52. package/dist/components/ip-type-fields.cjs.map +1 -0
  53. package/dist/components/ip-type-fields.d.cts +17 -0
  54. package/dist/components/ip-type-fields.d.ts +17 -0
  55. package/dist/components/ip-type-fields.js +293 -0
  56. package/dist/components/ip-type-fields.js.map +1 -0
  57. package/dist/components/json-ld.cjs +39 -0
  58. package/dist/components/json-ld.cjs.map +1 -0
  59. package/dist/components/json-ld.d.cts +8 -0
  60. package/dist/components/json-ld.d.ts +8 -0
  61. package/dist/components/json-ld.js +15 -0
  62. package/dist/components/json-ld.js.map +1 -0
  63. package/dist/components/nav-theme-toggle.cjs +66 -0
  64. package/dist/components/nav-theme-toggle.cjs.map +1 -0
  65. package/dist/components/nav-theme-toggle.d.cts +9 -0
  66. package/dist/components/nav-theme-toggle.d.ts +9 -0
  67. package/dist/components/nav-theme-toggle.js +42 -0
  68. package/dist/components/nav-theme-toggle.js.map +1 -0
  69. package/dist/components/order-sort-control.cjs +58 -0
  70. package/dist/components/order-sort-control.cjs.map +1 -0
  71. package/dist/components/order-sort-control.d.cts +13 -0
  72. package/dist/components/order-sort-control.d.ts +13 -0
  73. package/dist/components/order-sort-control.js +39 -0
  74. package/dist/components/order-sort-control.js.map +1 -0
  75. package/dist/components/portfolio-activity.cjs +117 -0
  76. package/dist/components/portfolio-activity.cjs.map +1 -0
  77. package/dist/components/portfolio-activity.d.cts +10 -0
  78. package/dist/components/portfolio-activity.d.ts +10 -0
  79. package/dist/components/portfolio-activity.js +93 -0
  80. package/dist/components/portfolio-activity.js.map +1 -0
  81. package/dist/components/price-history-chart.cjs +130 -0
  82. package/dist/components/price-history-chart.cjs.map +1 -0
  83. package/dist/components/price-history-chart.d.cts +9 -0
  84. package/dist/components/price-history-chart.d.ts +9 -0
  85. package/dist/components/price-history-chart.js +114 -0
  86. package/dist/components/price-history-chart.js.map +1 -0
  87. package/dist/components/sheet.cjs +160 -0
  88. package/dist/components/sheet.cjs.map +1 -0
  89. package/dist/components/sheet.d.cts +30 -0
  90. package/dist/components/sheet.d.ts +30 -0
  91. package/dist/components/sheet.js +117 -0
  92. package/dist/components/sheet.js.map +1 -0
  93. package/dist/components/textarea.cjs +57 -0
  94. package/dist/components/textarea.cjs.map +1 -0
  95. package/dist/components/textarea.d.cts +6 -0
  96. package/dist/components/textarea.d.ts +6 -0
  97. package/dist/components/textarea.js +23 -0
  98. package/dist/components/textarea.js.map +1 -0
  99. package/dist/index.cjs +110 -0
  100. package/dist/index.cjs.map +1 -1
  101. package/dist/index.d.cts +24 -2
  102. package/dist/index.d.ts +24 -2
  103. package/dist/index.js +88 -0
  104. package/dist/index.js.map +1 -1
  105. package/dist/utils/format-activity.cjs +143 -0
  106. package/dist/utils/format-activity.cjs.map +1 -0
  107. package/dist/utils/format-activity.d.cts +14 -0
  108. package/dist/utils/format-activity.d.ts +14 -0
  109. package/dist/utils/format-activity.js +116 -0
  110. package/dist/utils/format-activity.js.map +1 -0
  111. package/dist/utils/proxy-body.cjs +60 -0
  112. package/dist/utils/proxy-body.cjs.map +1 -0
  113. package/dist/utils/proxy-body.d.cts +22 -0
  114. package/dist/utils/proxy-body.d.ts +22 -0
  115. package/dist/utils/proxy-body.js +36 -0
  116. package/dist/utils/proxy-body.js.map +1 -0
  117. package/dist/utils/query-keys.cjs +80 -0
  118. package/dist/utils/query-keys.cjs.map +1 -0
  119. package/dist/utils/query-keys.d.cts +39 -0
  120. package/dist/utils/query-keys.d.ts +39 -0
  121. package/dist/utils/query-keys.js +54 -0
  122. package/dist/utils/query-keys.js.map +1 -0
  123. package/dist/utils/use-activities.cjs +68 -0
  124. package/dist/utils/use-activities.cjs.map +1 -0
  125. package/dist/utils/use-activities.d.cts +20 -0
  126. package/dist/utils/use-activities.d.ts +20 -0
  127. package/dist/utils/use-activities.js +33 -0
  128. package/dist/utils/use-activities.js.map +1 -0
  129. package/dist/utils/use-collections.cjs +113 -0
  130. package/dist/utils/use-collections.cjs.map +1 -0
  131. package/dist/utils/use-collections.d.cts +43 -0
  132. package/dist/utils/use-collections.d.ts +43 -0
  133. package/dist/utils/use-collections.js +75 -0
  134. package/dist/utils/use-collections.js.map +1 -0
  135. package/dist/utils/use-profiles.cjs +69 -0
  136. package/dist/utils/use-profiles.cjs.map +1 -0
  137. package/dist/utils/use-profiles.d.cts +18 -0
  138. package/dist/utils/use-profiles.d.ts +18 -0
  139. package/dist/utils/use-profiles.js +34 -0
  140. package/dist/utils/use-profiles.js.map +1 -0
  141. package/package.json +2 -2
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/utils/format-activity.ts"],"sourcesContent":["import type { ApiActivity, ApiOrder } from \"@medialane/sdk\";\nimport { assetHref } from \"@medialane/sdk\";\nimport { formatDisplayPrice } from \"./format.js\";\nimport { ipfsToHttp } from \"./ipfs.js\";\n\nexport interface FormattedEvent {\n title: string;\n description: string;\n image: string | null;\n href: string;\n}\n\nfunction short(addr: string): string {\n return addr.length > 10 ? `${addr.slice(0, 6)}…${addr.slice(-4)}` : addr;\n}\n\nfunction price(p?: { formatted?: string | null; currency?: string | null } | null): string | null {\n if (!p?.formatted) return null;\n return `${formatDisplayPrice(p.formatted)} ${p.currency}`;\n}\n\nexport function formatActivity(event: ApiActivity): FormattedEvent {\n const contract = event.nftContract ?? event.contractAddress ?? \"\";\n const tokenId = event.nftTokenId ?? event.tokenId ?? \"\";\n const href = contract && tokenId ? assetHref(\"STARKNET\", contract, tokenId) : \"/activities\";\n const raw = event.token?.image ?? null;\n const image = raw ? ipfsToHttp(raw) : null;\n const name = event.token?.name ?? (tokenId ? `#${tokenId}` : \"token\");\n const p = price(event.price);\n\n const actor =\n event.offerer ??\n event.fulfiller ??\n (event.type === \"mint\" ? event.to : event.from) ??\n null;\n const actorShort = actor ? short(actor) : null;\n\n switch (event.type) {\n case \"sale\":\n return {\n title: `${name} sold`,\n description: p\n ? `${p}${event.to ? ` to ${short(event.to)}` : \"\"}`\n : \"Sale confirmed\",\n image, href,\n };\n case \"listing\":\n return {\n title: `${name} listed`,\n description: p ? `Listed for ${p}` : \"New listing\",\n image, href,\n };\n case \"offer\":\n return {\n title: `Offer on ${name}`,\n description: p && actorShort ? `${p} from ${actorShort}` : p ?? \"New offer\",\n image, href,\n };\n case \"mint\":\n return {\n title: `${name} minted`,\n description: actorShort ? `By ${actorShort}` : \"New mint\",\n image, href,\n };\n case \"transfer\":\n return {\n title: `${name} transferred`,\n description:\n actorShort && event.to\n ? `${actorShort} → ${short(event.to)}`\n : \"Token transferred\",\n image, href,\n };\n case \"cancelled\":\n return {\n title: \"Listing cancelled\",\n description: name,\n image, href,\n };\n default:\n return { title: event.type ?? \"Activity\", description: name, image, href };\n }\n}\n\nexport function formatOrderNotification(order: ApiOrder): FormattedEvent {\n const name = order.token?.name ?? `#${order.consideration.identifier}`;\n const raw = order.token?.image ?? null;\n const image = raw ? ipfsToHttp(raw) : null;\n const href = assetHref(\"STARKNET\", order.consideration.token, order.consideration.identifier);\n const p = price(order.price);\n const from = short(order.offerer);\n\n return {\n title: `Offer on ${name}`,\n description: p ? `${p} from ${from}` : `From ${from}`,\n image,\n href,\n };\n}\n\nexport function formatOfferAcceptedNotification(order: ApiOrder): FormattedEvent {\n const name = order.token?.name ?? `#${order.nftTokenId}`;\n const raw = order.token?.image ?? null;\n const image = raw ? ipfsToHttp(raw) : null;\n const href = order.nftContract && order.nftTokenId\n ? assetHref(\"STARKNET\", order.nftContract, order.nftTokenId)\n : \"/portfolio/assets\";\n const p = price(order.price);\n\n return {\n title: `Your offer was accepted`,\n description: p ? `${name} · ${p}` : name,\n image,\n href,\n };\n}\n\nexport function formatAssetReceivedNotification(event: ApiActivity): FormattedEvent {\n const contract = event.nftContract ?? event.contractAddress ?? \"\";\n const tokenId = event.nftTokenId ?? event.tokenId ?? \"\";\n const href = contract && tokenId ? assetHref(\"STARKNET\", contract, tokenId) : \"/portfolio/assets\";\n const raw = event.token?.image ?? null;\n const image = raw ? ipfsToHttp(raw) : null;\n const name = event.token?.name ?? (tokenId ? `#${tokenId}` : \"an asset\");\n const from = event.from ? short(event.from) : null;\n\n return {\n title: `Asset received`,\n description: from ? `${name} from ${from}` : name,\n image,\n href,\n };\n}\n"],"mappings":"AACA,SAAS,iBAAiB;AAC1B,SAAS,0BAA0B;AACnC,SAAS,kBAAkB;AAS3B,SAAS,MAAM,MAAsB;AACnC,SAAO,KAAK,SAAS,KAAK,GAAG,KAAK,MAAM,GAAG,CAAC,CAAC,SAAI,KAAK,MAAM,EAAE,CAAC,KAAK;AACtE;AAEA,SAAS,MAAM,GAAmF;AAChG,MAAI,CAAC,GAAG,UAAW,QAAO;AAC1B,SAAO,GAAG,mBAAmB,EAAE,SAAS,CAAC,IAAI,EAAE,QAAQ;AACzD;AAEO,SAAS,eAAe,OAAoC;AACjE,QAAM,WAAW,MAAM,eAAe,MAAM,mBAAmB;AAC/D,QAAM,UAAW,MAAM,cAAc,MAAM,WAAW;AACtD,QAAM,OAAW,YAAY,UAAU,UAAU,YAAY,UAAU,OAAO,IAAI;AAClF,QAAM,MAAW,MAAM,OAAO,SAAS;AACvC,QAAM,QAAW,MAAM,WAAW,GAAG,IAAI;AACzC,QAAM,OAAW,MAAM,OAAO,SAAS,UAAU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AAO,GAAG,IAAI,SAAS,IAAI,KAAK;AAAA,IAC7C;AAAA,IACA;AAAA,EACF;AACF;","names":[]}
@@ -0,0 +1,60 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var proxy_body_exports = {};
20
+ __export(proxy_body_exports, {
21
+ readBodyWithCap: () => readBodyWithCap
22
+ });
23
+ module.exports = __toCommonJS(proxy_body_exports);
24
+ async function readBodyWithCap(upstream, maxBytes) {
25
+ const declaredLength = upstream.headers.get("content-length");
26
+ if (declaredLength) {
27
+ const n = Number.parseInt(declaredLength, 10);
28
+ if (Number.isFinite(n) && n > maxBytes) {
29
+ return { ok: false, status: 413, error: `Response exceeds size cap (${maxBytes} bytes)` };
30
+ }
31
+ }
32
+ if (!upstream.body) {
33
+ return { ok: false, status: 502, error: "Upstream returned no body" };
34
+ }
35
+ const reader = upstream.body.getReader();
36
+ const chunks = [];
37
+ let total = 0;
38
+ while (true) {
39
+ const { done, value } = await reader.read();
40
+ if (done) break;
41
+ total += value.byteLength;
42
+ if (total > maxBytes) {
43
+ await reader.cancel();
44
+ return { ok: false, status: 413, error: `Response exceeds size cap (${maxBytes} bytes)` };
45
+ }
46
+ chunks.push(value);
47
+ }
48
+ const body = new Uint8Array(total);
49
+ let offset = 0;
50
+ for (const chunk of chunks) {
51
+ body.set(chunk, offset);
52
+ offset += chunk.byteLength;
53
+ }
54
+ return { ok: true, body };
55
+ }
56
+ // Annotate the CommonJS export names for ESM import in node:
57
+ 0 && (module.exports = {
58
+ readBodyWithCap
59
+ });
60
+ //# sourceMappingURL=proxy-body.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/utils/proxy-body.ts"],"sourcesContent":["/**\n * Read an upstream `fetch` Response body into memory with a hard byte cap.\n *\n * `arrayBuffer()` buffers the whole body before any limit applies, so a public\n * proxy route (image, IPFS) can be made to pin server memory by pointing it at\n * a large file. This streams the body and aborts once `maxBytes` is crossed.\n * A `Content-Length` larger than the cap short-circuits before a byte is read\n * (advisory — some origins omit or lie, so the streaming guard is the real\n * limit). Shared by both apps' `/api/img` and `/api/ipfs` routes so the cap\n * can't drift between them.\n */\nexport type CappedBody =\n | { ok: true; body: Uint8Array<ArrayBuffer> }\n | { ok: false; status: 413 | 502; error: string };\n\nexport async function readBodyWithCap(upstream: Response, maxBytes: number): Promise<CappedBody> {\n const declaredLength = upstream.headers.get(\"content-length\");\n if (declaredLength) {\n const n = Number.parseInt(declaredLength, 10);\n if (Number.isFinite(n) && n > maxBytes) {\n return { ok: false, status: 413, error: `Response exceeds size cap (${maxBytes} bytes)` };\n }\n }\n\n if (!upstream.body) {\n return { ok: false, status: 502, error: \"Upstream returned no body\" };\n }\n\n const reader = upstream.body.getReader();\n const chunks: Uint8Array[] = [];\n let total = 0;\n while (true) {\n const { done, value } = await reader.read();\n if (done) break;\n total += value.byteLength;\n if (total > maxBytes) {\n await reader.cancel();\n return { ok: false, status: 413, error: `Response exceeds size cap (${maxBytes} bytes)` };\n }\n chunks.push(value);\n }\n\n const body = new Uint8Array(total) as Uint8Array<ArrayBuffer>;\n let offset = 0;\n for (const chunk of chunks) {\n body.set(chunk, offset);\n offset += chunk.byteLength;\n }\n return { ok: true, body };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAeA,eAAsB,gBAAgB,UAAoB,UAAuC;AAC/F,QAAM,iBAAiB,SAAS,QAAQ,IAAI,gBAAgB;AAC5D,MAAI,gBAAgB;AAClB,UAAM,IAAI,OAAO,SAAS,gBAAgB,EAAE;AAC5C,QAAI,OAAO,SAAS,CAAC,KAAK,IAAI,UAAU;AACtC,aAAO,EAAE,IAAI,OAAO,QAAQ,KAAK,OAAO,8BAA8B,QAAQ,UAAU;AAAA,IAC1F;AAAA,EACF;AAEA,MAAI,CAAC,SAAS,MAAM;AAClB,WAAO,EAAE,IAAI,OAAO,QAAQ,KAAK,OAAO,4BAA4B;AAAA,EACtE;AAEA,QAAM,SAAS,SAAS,KAAK,UAAU;AACvC,QAAM,SAAuB,CAAC;AAC9B,MAAI,QAAQ;AACZ,SAAO,MAAM;AACX,UAAM,EAAE,MAAM,MAAM,IAAI,MAAM,OAAO,KAAK;AAC1C,QAAI,KAAM;AACV,aAAS,MAAM;AACf,QAAI,QAAQ,UAAU;AACpB,YAAM,OAAO,OAAO;AACpB,aAAO,EAAE,IAAI,OAAO,QAAQ,KAAK,OAAO,8BAA8B,QAAQ,UAAU;AAAA,IAC1F;AACA,WAAO,KAAK,KAAK;AAAA,EACnB;AAEA,QAAM,OAAO,IAAI,WAAW,KAAK;AACjC,MAAI,SAAS;AACb,aAAW,SAAS,QAAQ;AAC1B,SAAK,IAAI,OAAO,MAAM;AACtB,cAAU,MAAM;AAAA,EAClB;AACA,SAAO,EAAE,IAAI,MAAM,KAAK;AAC1B;","names":[]}
@@ -0,0 +1,22 @@
1
+ /**
2
+ * Read an upstream `fetch` Response body into memory with a hard byte cap.
3
+ *
4
+ * `arrayBuffer()` buffers the whole body before any limit applies, so a public
5
+ * proxy route (image, IPFS) can be made to pin server memory by pointing it at
6
+ * a large file. This streams the body and aborts once `maxBytes` is crossed.
7
+ * A `Content-Length` larger than the cap short-circuits before a byte is read
8
+ * (advisory — some origins omit or lie, so the streaming guard is the real
9
+ * limit). Shared by both apps' `/api/img` and `/api/ipfs` routes so the cap
10
+ * can't drift between them.
11
+ */
12
+ type CappedBody = {
13
+ ok: true;
14
+ body: Uint8Array<ArrayBuffer>;
15
+ } | {
16
+ ok: false;
17
+ status: 413 | 502;
18
+ error: string;
19
+ };
20
+ declare function readBodyWithCap(upstream: Response, maxBytes: number): Promise<CappedBody>;
21
+
22
+ export { type CappedBody, readBodyWithCap };
@@ -0,0 +1,22 @@
1
+ /**
2
+ * Read an upstream `fetch` Response body into memory with a hard byte cap.
3
+ *
4
+ * `arrayBuffer()` buffers the whole body before any limit applies, so a public
5
+ * proxy route (image, IPFS) can be made to pin server memory by pointing it at
6
+ * a large file. This streams the body and aborts once `maxBytes` is crossed.
7
+ * A `Content-Length` larger than the cap short-circuits before a byte is read
8
+ * (advisory — some origins omit or lie, so the streaming guard is the real
9
+ * limit). Shared by both apps' `/api/img` and `/api/ipfs` routes so the cap
10
+ * can't drift between them.
11
+ */
12
+ type CappedBody = {
13
+ ok: true;
14
+ body: Uint8Array<ArrayBuffer>;
15
+ } | {
16
+ ok: false;
17
+ status: 413 | 502;
18
+ error: string;
19
+ };
20
+ declare function readBodyWithCap(upstream: Response, maxBytes: number): Promise<CappedBody>;
21
+
22
+ export { type CappedBody, readBodyWithCap };
@@ -0,0 +1,36 @@
1
+ async function readBodyWithCap(upstream, maxBytes) {
2
+ const declaredLength = upstream.headers.get("content-length");
3
+ if (declaredLength) {
4
+ const n = Number.parseInt(declaredLength, 10);
5
+ if (Number.isFinite(n) && n > maxBytes) {
6
+ return { ok: false, status: 413, error: `Response exceeds size cap (${maxBytes} bytes)` };
7
+ }
8
+ }
9
+ if (!upstream.body) {
10
+ return { ok: false, status: 502, error: "Upstream returned no body" };
11
+ }
12
+ const reader = upstream.body.getReader();
13
+ const chunks = [];
14
+ let total = 0;
15
+ while (true) {
16
+ const { done, value } = await reader.read();
17
+ if (done) break;
18
+ total += value.byteLength;
19
+ if (total > maxBytes) {
20
+ await reader.cancel();
21
+ return { ok: false, status: 413, error: `Response exceeds size cap (${maxBytes} bytes)` };
22
+ }
23
+ chunks.push(value);
24
+ }
25
+ const body = new Uint8Array(total);
26
+ let offset = 0;
27
+ for (const chunk of chunks) {
28
+ body.set(chunk, offset);
29
+ offset += chunk.byteLength;
30
+ }
31
+ return { ok: true, body };
32
+ }
33
+ export {
34
+ readBodyWithCap
35
+ };
36
+ //# sourceMappingURL=proxy-body.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/utils/proxy-body.ts"],"sourcesContent":["/**\n * Read an upstream `fetch` Response body into memory with a hard byte cap.\n *\n * `arrayBuffer()` buffers the whole body before any limit applies, so a public\n * proxy route (image, IPFS) can be made to pin server memory by pointing it at\n * a large file. This streams the body and aborts once `maxBytes` is crossed.\n * A `Content-Length` larger than the cap short-circuits before a byte is read\n * (advisory — some origins omit or lie, so the streaming guard is the real\n * limit). Shared by both apps' `/api/img` and `/api/ipfs` routes so the cap\n * can't drift between them.\n */\nexport type CappedBody =\n | { ok: true; body: Uint8Array<ArrayBuffer> }\n | { ok: false; status: 413 | 502; error: string };\n\nexport async function readBodyWithCap(upstream: Response, maxBytes: number): Promise<CappedBody> {\n const declaredLength = upstream.headers.get(\"content-length\");\n if (declaredLength) {\n const n = Number.parseInt(declaredLength, 10);\n if (Number.isFinite(n) && n > maxBytes) {\n return { ok: false, status: 413, error: `Response exceeds size cap (${maxBytes} bytes)` };\n }\n }\n\n if (!upstream.body) {\n return { ok: false, status: 502, error: \"Upstream returned no body\" };\n }\n\n const reader = upstream.body.getReader();\n const chunks: Uint8Array[] = [];\n let total = 0;\n while (true) {\n const { done, value } = await reader.read();\n if (done) break;\n total += value.byteLength;\n if (total > maxBytes) {\n await reader.cancel();\n return { ok: false, status: 413, error: `Response exceeds size cap (${maxBytes} bytes)` };\n }\n chunks.push(value);\n }\n\n const body = new Uint8Array(total) as Uint8Array<ArrayBuffer>;\n let offset = 0;\n for (const chunk of chunks) {\n body.set(chunk, offset);\n offset += chunk.byteLength;\n }\n return { ok: true, body };\n}\n"],"mappings":"AAeA,eAAsB,gBAAgB,UAAoB,UAAuC;AAC/F,QAAM,iBAAiB,SAAS,QAAQ,IAAI,gBAAgB;AAC5D,MAAI,gBAAgB;AAClB,UAAM,IAAI,OAAO,SAAS,gBAAgB,EAAE;AAC5C,QAAI,OAAO,SAAS,CAAC,KAAK,IAAI,UAAU;AACtC,aAAO,EAAE,IAAI,OAAO,QAAQ,KAAK,OAAO,8BAA8B,QAAQ,UAAU;AAAA,IAC1F;AAAA,EACF;AAEA,MAAI,CAAC,SAAS,MAAM;AAClB,WAAO,EAAE,IAAI,OAAO,QAAQ,KAAK,OAAO,4BAA4B;AAAA,EACtE;AAEA,QAAM,SAAS,SAAS,KAAK,UAAU;AACvC,QAAM,SAAuB,CAAC;AAC9B,MAAI,QAAQ;AACZ,SAAO,MAAM;AACX,UAAM,EAAE,MAAM,MAAM,IAAI,MAAM,OAAO,KAAK;AAC1C,QAAI,KAAM;AACV,aAAS,MAAM;AACf,QAAI,QAAQ,UAAU;AACpB,YAAM,OAAO,OAAO;AACpB,aAAO,EAAE,IAAI,OAAO,QAAQ,KAAK,OAAO,8BAA8B,QAAQ,UAAU;AAAA,IAC1F;AACA,WAAO,KAAK,KAAK;AAAA,EACnB;AAEA,QAAM,OAAO,IAAI,WAAW,KAAK;AACjC,MAAI,SAAS;AACb,aAAW,SAAS,QAAQ;AAC1B,SAAK,IAAI,OAAO,MAAM;AACtB,cAAU,MAAM;AAAA,EAClB;AACA,SAAO,EAAE,IAAI,MAAM,KAAK;AAC1B;","names":[]}
@@ -0,0 +1,80 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var query_keys_exports = {};
20
+ __export(query_keys_exports, {
21
+ QUERY_PREFIX: () => QUERY_PREFIX,
22
+ queryKeyPrefix: () => queryKeyPrefix,
23
+ queryKeys: () => queryKeys
24
+ });
25
+ module.exports = __toCommonJS(query_keys_exports);
26
+ const QUERY_PREFIX = {
27
+ orders: "orders",
28
+ order: "order",
29
+ listings: "listings",
30
+ userOrders: "user-orders",
31
+ counterOffers: "counter-offers",
32
+ floorListings: "floor-listings",
33
+ token: "token",
34
+ tokensOwned: "tokens-owned",
35
+ tokenHistory: "token-history",
36
+ collection: "collection",
37
+ collections: "collections",
38
+ collectionsOwner: "collections-owner",
39
+ collectionTokens: "collection-tokens",
40
+ userCollections: "user-collections",
41
+ profileCollection: "profile-collection"
42
+ };
43
+ function normalizePart(value) {
44
+ return value == null ? "" : String(value);
45
+ }
46
+ const queryKeys = {
47
+ orders: (query = {}) => JSON.stringify({ op: QUERY_PREFIX.orders, ...query }),
48
+ order: (orderHash) => `${QUERY_PREFIX.order}-${orderHash}`,
49
+ listings: (contract, tokenId) => `${QUERY_PREFIX.listings}-${contract}-${tokenId}`,
50
+ userOrders: (address) => `${QUERY_PREFIX.userOrders}-${address}`,
51
+ counterOffersByOrder: (orderHash) => `${QUERY_PREFIX.counterOffers}-${orderHash}`,
52
+ counterOffersBySeller: (sellerAddress) => `${QUERY_PREFIX.counterOffers}-seller-${sellerAddress}`,
53
+ floorListings: (contract, limit) => `${QUERY_PREFIX.floorListings}-${contract}-${limit}`,
54
+ token: (contract, tokenId) => `${QUERY_PREFIX.token}-${contract}-${tokenId}`,
55
+ tokensOwned: (address, page, limit) => `${QUERY_PREFIX.tokensOwned}-${address}-${page}-${limit}`,
56
+ tokenHistory: (contract, tokenId) => `${QUERY_PREFIX.tokenHistory}-${contract}-${tokenId}`,
57
+ collections: (page, limit, isFeatured, sort, hideEmpty, source) => [
58
+ QUERY_PREFIX.collections,
59
+ page,
60
+ limit,
61
+ normalizePart(isFeatured),
62
+ sort,
63
+ hideEmpty,
64
+ normalizePart(source)
65
+ ].join("-"),
66
+ collection: (contract) => `${QUERY_PREFIX.collection}-${contract}`,
67
+ collectionsOwner: (owner) => `${QUERY_PREFIX.collectionsOwner}-${owner}`,
68
+ collectionTokens: (contract, page, limit, sort) => `${QUERY_PREFIX.collectionTokens}-${contract}-${page}-${limit}-${sort}`,
69
+ userCollections: (address) => `${QUERY_PREFIX.userCollections}-${address}`
70
+ };
71
+ function queryKeyPrefix(prefix) {
72
+ return `${prefix}-`;
73
+ }
74
+ // Annotate the CommonJS export names for ESM import in node:
75
+ 0 && (module.exports = {
76
+ QUERY_PREFIX,
77
+ queryKeyPrefix,
78
+ queryKeys
79
+ });
80
+ //# sourceMappingURL=query-keys.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/utils/query-keys.ts"],"sourcesContent":["import type { ApiOrdersQuery } from \"@medialane/sdk\";\n\nexport const QUERY_PREFIX = {\n orders: \"orders\",\n order: \"order\",\n listings: \"listings\",\n userOrders: \"user-orders\",\n counterOffers: \"counter-offers\",\n floorListings: \"floor-listings\",\n token: \"token\",\n tokensOwned: \"tokens-owned\",\n tokenHistory: \"token-history\",\n collection: \"collection\",\n collections: \"collections\",\n collectionsOwner: \"collections-owner\",\n collectionTokens: \"collection-tokens\",\n userCollections: \"user-collections\",\n profileCollection: \"profile-collection\",\n} as const;\n\nfunction normalizePart(value: string | number | boolean | null | undefined) {\n return value == null ? \"\" : String(value);\n}\n\nexport const queryKeys = {\n orders: (query: ApiOrdersQuery = {}) => JSON.stringify({ op: QUERY_PREFIX.orders, ...query }),\n order: (orderHash: string) => `${QUERY_PREFIX.order}-${orderHash}`,\n listings: (contract: string, tokenId: string) => `${QUERY_PREFIX.listings}-${contract}-${tokenId}`,\n userOrders: (address: string) => `${QUERY_PREFIX.userOrders}-${address}`,\n counterOffersByOrder: (orderHash: string) => `${QUERY_PREFIX.counterOffers}-${orderHash}`,\n counterOffersBySeller: (sellerAddress: string) => `${QUERY_PREFIX.counterOffers}-seller-${sellerAddress}`,\n floorListings: (contract: string, limit: number) => `${QUERY_PREFIX.floorListings}-${contract}-${limit}`,\n token: (contract: string, tokenId: string) => `${QUERY_PREFIX.token}-${contract}-${tokenId}`,\n tokensOwned: (address: string, page: number, limit: number) =>\n `${QUERY_PREFIX.tokensOwned}-${address}-${page}-${limit}`,\n tokenHistory: (contract: string, tokenId: string) =>\n `${QUERY_PREFIX.tokenHistory}-${contract}-${tokenId}`,\n collections: (\n page: number,\n limit: number,\n isFeatured: boolean | undefined,\n sort: string,\n hideEmpty: boolean,\n source?: string\n ) =>\n [\n QUERY_PREFIX.collections,\n page,\n limit,\n normalizePart(isFeatured),\n sort,\n hideEmpty,\n normalizePart(source),\n ].join(\"-\"),\n collection: (contract: string) => `${QUERY_PREFIX.collection}-${contract}`,\n collectionsOwner: (owner: string) => `${QUERY_PREFIX.collectionsOwner}-${owner}`,\n collectionTokens: (contract: string, page: number, limit: number, sort: string) =>\n `${QUERY_PREFIX.collectionTokens}-${contract}-${page}-${limit}-${sort}`,\n userCollections: (address: string) => `${QUERY_PREFIX.userCollections}-${address}`,\n};\n\nexport function queryKeyPrefix(prefix: (typeof QUERY_PREFIX)[keyof typeof QUERY_PREFIX]) {\n return `${prefix}-`;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAEO,MAAM,eAAe;AAAA,EAC1B,QAAQ;AAAA,EACR,OAAO;AAAA,EACP,UAAU;AAAA,EACV,YA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,cAAc,MAAM;AAAA,EACtB,EAAE,KAAK,GAAG;AAAA,EACZ,YAAY,CAAC,aAAqB,GAAG,aAAa,UAAU,IAAI,QAAQ;AAAA,EACxE,kBAAkB,CAAC,UAAkB,GAAG,aAAa,gBAAgB,IAAI,KAAK;AAAA,EAC9E,kBAAkB,CAAC,UAAkB,MAAc,OAAe,SAChE,GAAG,aAAa,gBAAgB,IAAI,QAAQ,IAAI,IAAI,IAAI,KAAK,IAAI,IAAI;AAAA,EACvE,iBAAiB,CAAC,YAAoB,GAAG,aAAa,eAAe,IAAI,OAAO;AAClF;AAEO,SAAS,eAAe,QAA0D;AACvF,SAAO,GAAG,MAAM;AAClB;","names":[]}
@@ -0,0 +1,39 @@
1
+ import { ApiOrdersQuery } from '@medialane/sdk';
2
+
3
+ declare const QUERY_PREFIX: {
4
+ readonly orders: "orders";
5
+ readonly order: "order";
6
+ readonly listings: "listings";
7
+ readonly userOrders: "user-orders";
8
+ readonly counterOffers: "counter-offers";
9
+ readonly floorListings: "floor-listings";
10
+ readonly token: "token";
11
+ readonly tokensOwned: "tokens-owned";
12
+ readonly tokenHistory: "token-history";
13
+ readonly collection: "collection";
14
+ readonly collections: "collections";
15
+ readonly collectionsOwner: "collections-owner";
16
+ readonly collectionTokens: "collection-tokens";
17
+ readonly userCollections: "user-collections";
18
+ readonly profileCollection: "profile-collection";
19
+ };
20
+ declare const queryKeys: {
21
+ orders: (query?: ApiOrdersQuery) => string;
22
+ order: (orderHash: string) => string;
23
+ listings: (contract: string, tokenId: string) => string;
24
+ userOrders: (address: string) => string;
25
+ counterOffersByOrder: (orderHash: string) => string;
26
+ counterOffersBySeller: (sellerAddress: string) => string;
27
+ floorListings: (contract: string, limit: number) => string;
28
+ token: (contract: string, tokenId: string) => string;
29
+ tokensOwned: (address: string, page: number, limit: number) => string;
30
+ tokenHistory: (contract: string, tokenId: string) => string;
31
+ collections: (page: number, limit: number, isFeatured: boolean | undefined, sort: string, hideEmpty: boolean, source?: string) => string;
32
+ collection: (contract: string) => string;
33
+ collectionsOwner: (owner: string) => string;
34
+ collectionTokens: (contract: string, page: number, limit: number, sort: string) => string;
35
+ userCollections: (address: string) => string;
36
+ };
37
+ declare function queryKeyPrefix(prefix: (typeof QUERY_PREFIX)[keyof typeof QUERY_PREFIX]): string;
38
+
39
+ export { QUERY_PREFIX, queryKeyPrefix, queryKeys };
@@ -0,0 +1,39 @@
1
+ import { ApiOrdersQuery } from '@medialane/sdk';
2
+
3
+ declare const QUERY_PREFIX: {
4
+ readonly orders: "orders";
5
+ readonly order: "order";
6
+ readonly listings: "listings";
7
+ readonly userOrders: "user-orders";
8
+ readonly counterOffers: "counter-offers";
9
+ readonly floorListings: "floor-listings";
10
+ readonly token: "token";
11
+ readonly tokensOwned: "tokens-owned";
12
+ readonly tokenHistory: "token-history";
13
+ readonly collection: "collection";
14
+ readonly collections: "collections";
15
+ readonly collectionsOwner: "collections-owner";
16
+ readonly collectionTokens: "collection-tokens";
17
+ readonly userCollections: "user-collections";
18
+ readonly profileCollection: "profile-collection";
19
+ };
20
+ declare const queryKeys: {
21
+ orders: (query?: ApiOrdersQuery) => string;
22
+ order: (orderHash: string) => string;
23
+ listings: (contract: string, tokenId: string) => string;
24
+ userOrders: (address: string) => string;
25
+ counterOffersByOrder: (orderHash: string) => string;
26
+ counterOffersBySeller: (sellerAddress: string) => string;
27
+ floorListings: (contract: string, limit: number) => string;
28
+ token: (contract: string, tokenId: string) => string;
29
+ tokensOwned: (address: string, page: number, limit: number) => string;
30
+ tokenHistory: (contract: string, tokenId: string) => string;
31
+ collections: (page: number, limit: number, isFeatured: boolean | undefined, sort: string, hideEmpty: boolean, source?: string) => string;
32
+ collection: (contract: string) => string;
33
+ collectionsOwner: (owner: string) => string;
34
+ collectionTokens: (contract: string, page: number, limit: number, sort: string) => string;
35
+ userCollections: (address: string) => string;
36
+ };
37
+ declare function queryKeyPrefix(prefix: (typeof QUERY_PREFIX)[keyof typeof QUERY_PREFIX]): string;
38
+
39
+ export { QUERY_PREFIX, queryKeyPrefix, queryKeys };
@@ -0,0 +1,54 @@
1
+ const QUERY_PREFIX = {
2
+ orders: "orders",
3
+ order: "order",
4
+ listings: "listings",
5
+ userOrders: "user-orders",
6
+ counterOffers: "counter-offers",
7
+ floorListings: "floor-listings",
8
+ token: "token",
9
+ tokensOwned: "tokens-owned",
10
+ tokenHistory: "token-history",
11
+ collection: "collection",
12
+ collections: "collections",
13
+ collectionsOwner: "collections-owner",
14
+ collectionTokens: "collection-tokens",
15
+ userCollections: "user-collections",
16
+ profileCollection: "profile-collection"
17
+ };
18
+ function normalizePart(value) {
19
+ return value == null ? "" : String(value);
20
+ }
21
+ const queryKeys = {
22
+ orders: (query = {}) => JSON.stringify({ op: QUERY_PREFIX.orders, ...query }),
23
+ order: (orderHash) => `${QUERY_PREFIX.order}-${orderHash}`,
24
+ listings: (contract, tokenId) => `${QUERY_PREFIX.listings}-${contract}-${tokenId}`,
25
+ userOrders: (address) => `${QUERY_PREFIX.userOrders}-${address}`,
26
+ counterOffersByOrder: (orderHash) => `${QUERY_PREFIX.counterOffers}-${orderHash}`,
27
+ counterOffersBySeller: (sellerAddress) => `${QUERY_PREFIX.counterOffers}-seller-${sellerAddress}`,
28
+ floorListings: (contract, limit) => `${QUERY_PREFIX.floorListings}-${contract}-${limit}`,
29
+ token: (contract, tokenId) => `${QUERY_PREFIX.token}-${contract}-${tokenId}`,
30
+ tokensOwned: (address, page, limit) => `${QUERY_PREFIX.tokensOwned}-${address}-${page}-${limit}`,
31
+ tokenHistory: (contract, tokenId) => `${QUERY_PREFIX.tokenHistory}-${contract}-${tokenId}`,
32
+ collections: (page, limit, isFeatured, sort, hideEmpty, source) => [
33
+ QUERY_PREFIX.collections,
34
+ page,
35
+ limit,
36
+ normalizePart(isFeatured),
37
+ sort,
38
+ hideEmpty,
39
+ normalizePart(source)
40
+ ].join("-"),
41
+ collection: (contract) => `${QUERY_PREFIX.collection}-${contract}`,
42
+ collectionsOwner: (owner) => `${QUERY_PREFIX.collectionsOwner}-${owner}`,
43
+ collectionTokens: (contract, page, limit, sort) => `${QUERY_PREFIX.collectionTokens}-${contract}-${page}-${limit}-${sort}`,
44
+ userCollections: (address) => `${QUERY_PREFIX.userCollections}-${address}`
45
+ };
46
+ function queryKeyPrefix(prefix) {
47
+ return `${prefix}-`;
48
+ }
49
+ export {
50
+ QUERY_PREFIX,
51
+ queryKeyPrefix,
52
+ queryKeys
53
+ };
54
+ //# sourceMappingURL=query-keys.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/utils/query-keys.ts"],"sourcesContent":["import type { ApiOrdersQuery } from \"@medialane/sdk\";\n\nexport const QUERY_PREFIX = {\n orders: \"orders\",\n order: \"order\",\n listings: \"listings\",\n userOrders: \"user-orders\",\n counterOffers: \"counter-offers\",\n floorListings: \"floor-listings\",\n token: \"token\",\n tokensOwned: \"tokens-owned\",\n tokenHistory: \"token-history\",\n collection: \"collection\",\n collections: \"collections\",\n collectionsOwner: \"collections-owner\",\n collectionTokens: \"collection-tokens\",\n userCollections: \"user-collections\",\n profileCollection: \"profile-collection\",\n} as const;\n\nfunction normalizePart(value: string | number | boolean | null | undefined) {\n return value == null ? \"\" : String(value);\n}\n\nexport const queryKeys = {\n orders: (query: ApiOrdersQuery = {}) => JSON.stringify({ op: QUERY_PREFIX.orders, ...query }),\n order: (orderHash: string) => `${QUERY_PREFIX.order}-${orderHash}`,\n listings: (contract: string, tokenId: string) => `${QUERY_PREFIX.listings}-${contract}-${tokenId}`,\n userOrders: (address: string) => `${QUERY_PREFIX.userOrders}-${address}`,\n counterOffersByOrder: (orderHash: string) => `${QUERY_PREFIX.counterOffers}-${orderHash}`,\n counterOffersBySeller: (sellerAddress: string) => `${QUERY_PREFIX.counterOffers}-seller-${sellerAddress}`,\n floorListings: (contract: string, limit: number) => `${QUERY_PREFIX.floorListings}-${contract}-${limit}`,\n token: (contract: string, tokenId: string) => `${QUERY_PREFIX.token}-${contract}-${tokenId}`,\n tokensOwned: (address: string, page: number, limit: number) =>\n `${QUERY_PREFIX.tokensOwned}-${address}-${page}-${limit}`,\n tokenHistory: (contract: string, tokenId: string) =>\n `${QUERY_PREFIX.tokenHistory}-${contract}-${tokenId}`,\n collections: (\n page: number,\n limit: number,\n isFeatured: boolean | undefined,\n sort: string,\n hideEmpty: boolean,\n source?: string\n ) =>\n [\n QUERY_PREFIX.collections,\n page,\n limit,\n normalizePart(isFeatured),\n sort,\n hideEmpty,\n normalizePart(source),\n ].join(\"-\"),\n collection: (contract: string) => `${QUERY_PREFIX.collection}-${contract}`,\n collectionsOwner: (owner: string) => `${QUERY_PREFIX.collectionsOwner}-${owner}`,\n collectionTokens: (contract: string, page: number, limit: number, sort: string) =>\n `${QUERY_PREFIX.collectionTokens}-${contract}-${page}-${limit}-${sort}`,\n userCollections: (address: string) => `${QUERY_PREFIX.userCollections}-${address}`,\n};\n\nexport function queryKeyPrefix(prefix: (typeof QUERY_PREFIX)[keyof typeof QUERY_PREFIX]) {\n return `${prefix}-`;\n}\n"],"mappings":"AAEO,MAAM,eAAe;AAAA,EAC1B,QAAQ;AAAA,EACR,OAAO;AAAA,EACP,UAAU;AAAA,EACV,YAAY;AAAA,EACZ,eAAe;AAAA,EACf,eAAe;AAAA,EACf,OAAO;AAAA,EACP,aAAa;AAAA,EACb,cAAc;AAAA,EACd,YAAY;AAAA,EACZ,aAAa;AAAA,EACb,kBAAkB;AAAA,EAClB,kBAAkB;AAAA,EAClB,iBAAiB;AAAA,EACjB,mBAAmB;AACrB;AAEA,SAAS,cAAc,OAAqD;AAC1E,SAAO,SAAS,OAAO,KAAK,OAAO,KAAK;AAC1C;AAEO,MAAM,YAAY;AAAA,EACvB,QAAQ,CAAC,QAAwB,CAAC,MAAM,KAAK,UAAU,EAAE,IAAI,aAAa,QAAQ,GAAG,MAAM,CAAC;AAAA,EAC5F,OAAO,CAAC,cAAsB,GAAG,aAAa,KAAK,IAAI,SAAS;AAAA,EAChE,UAAU,CAAC,UAAkB,YAAoB,GAAG,a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
+ 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_activities_exports = {};
31
+ __export(use_activities_exports, {
32
+ useActivities: () => useActivities,
33
+ useActivitiesByAddress: () => useActivitiesByAddress
34
+ });
35
+ module.exports = __toCommonJS(use_activities_exports);
36
+ var import_swr = __toESM(require("swr"), 1);
37
+ var import_use_medialane_client = require("./use-medialane-client.js");
38
+ function useActivities(getClient, query = {}) {
39
+ const client = (0, import_use_medialane_client.useMedialaneClient)(getClient);
40
+ const key = JSON.stringify({ op: "activities", ...query });
41
+ const { data, error, isLoading, mutate } = (0, import_swr.default)(
42
+ key,
43
+ () => client.api.getActivities(query),
44
+ { revalidateOnFocus: false, refreshInterval: 3e4 }
45
+ );
46
+ return {
47
+ activities: data?.data ?? [],
48
+ meta: data?.meta,
49
+ isLoading,
50
+ error,
51
+ mutate
52
+ };
53
+ }
54
+ function useActivitiesByAddress(getClient, address) {
55
+ const client = (0, import_use_medialane_client.useMedialaneClient)(getClient);
56
+ const { data, error, isLoading, mutate } = (0, import_swr.default)(
57
+ address ? `activities-${address}` : null,
58
+ () => client.api.getActivitiesByAddress(address),
59
+ { revalidateOnFocus: false, refreshInterval: 3e4 }
60
+ );
61
+ return { activities: data?.data ?? [], isLoading, error, mutate };
62
+ }
63
+ // Annotate the CommonJS export names for ESM import in node:
64
+ 0 && (module.exports = {
65
+ useActivities,
66
+ useActivitiesByAddress
67
+ });
68
+ //# sourceMappingURL=use-activities.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/utils/use-activities.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 { ApiActivitiesQuery, ApiActivity, ApiResponse } from \"@medialane/sdk\";\n\nexport function useActivities(getClient: () => MedialaneClient, query: ApiActivitiesQuery = {}) {\n const client = useMedialaneClient(getClient);\n const key = JSON.stringify({ op: \"activities\", ...query });\n\n const { data, error, isLoading, mutate } = useSWR<ApiResponse<ApiActivity[]>>(\n key,\n () => client.api.getActivities(query),\n { revalidateOnFocus: false, refreshInterval: 30000 }\n );\n\n return {\n activities: data?.data ?? [],\n meta: data?.meta,\n isLoading,\n error,\n mutate,\n };\n}\n\nexport function useActivitiesByAddress(getClient: () => MedialaneClient, address: string | null) {\n const client = useMedialaneClient(getClient);\n\n const { data, error, isLoading, mutate } = useSWR(\n address ? `activities-${address}` : null,\n () => client.api.getActivitiesByAddress(address!),\n { revalidateOnFocus: false, refreshInterval: 30000 }\n );\n\n return { activities: data?.data ?? [], isLoading, error, mutate };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,iBAAmB;AACnB,kCAAmC;AAI5B,SAAS,cAAc,WAAkC,QAA4B,CAAC,GAAG;AAC9F,QAAM,aAAS,gDAAmB,SAAS;AAC3C,QAAM,MAAM,KAAK,UAAU,EAAE,IAAI,cAAc,GAAG,MAAM,CAAC;AAEzD,QAAM,EAAE,MAAM,OAAO,WAAW,OAAO,QAAI,WAAAA;AAAA,IACzC;AAAA,IACA,MAAM,OAAO,IAAI,cAAc,KAAK;AAAA,IACpC,EAAE,mBAAmB,OAAO,iBAAiB,IAAM;AAAA,EACrD;AAEA,SAAO;AAAA,IACL,YAAY,MAAM,QAAQ,CAAC;AAAA,IAC3B,MAAM,MAAM;AAAA,IACZ;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACF;AAEO,SAAS,uBAAuB,WAAkC,SAAwB;AAC/F,QAAM,aAAS,gDAAmB,SAAS;AAE3C,QAAM,EAAE,MAAM,OAAO,WAAW,OAAO,QAAI,WAAAA;AAAA,IACzC,UAAU,cAAc,OAAO,KAAK;AAAA,IACpC,MAAM,OAAO,IAAI,uBAAuB,OAAQ;AAAA,IAChD,EAAE,mBAAmB,OAAO,iBAAiB,IAAM;AAAA,EACrD;AAEA,SAAO,EAAE,YAAY,MAAM,QAAQ,CAAC,GAAG,WAAW,OAAO,OAAO;AAClE;","names":["useSWR"]}
@@ -0,0 +1,20 @@
1
+ import * as swr from 'swr';
2
+ import * as _medialane_sdk from '@medialane/sdk';
3
+ import { ApiActivitiesQuery, ApiActivity, ApiResponse } from '@medialane/sdk';
4
+ import { MedialaneClient } from '@medialane/sdk/starknet';
5
+
6
+ declare function useActivities(getClient: () => MedialaneClient, query?: ApiActivitiesQuery): {
7
+ activities: ApiActivity[];
8
+ meta: _medialane_sdk.ApiMeta | undefined;
9
+ isLoading: boolean;
10
+ error: any;
11
+ mutate: swr.KeyedMutator<ApiResponse<ApiActivity[]>>;
12
+ };
13
+ declare function useActivitiesByAddress(getClient: () => MedialaneClient, address: string | null): {
14
+ activities: ApiActivity[];
15
+ isLoading: boolean;
16
+ error: any;
17
+ mutate: swr.KeyedMutator<ApiResponse<ApiActivity[]>>;
18
+ };
19
+
20
+ export { useActivities, useActivitiesByAddress };
@@ -0,0 +1,20 @@
1
+ import * as swr from 'swr';
2
+ import * as _medialane_sdk from '@medialane/sdk';
3
+ import { ApiActivitiesQuery, ApiActivity, ApiResponse } from '@medialane/sdk';
4
+ import { MedialaneClient } from '@medialane/sdk/starknet';
5
+
6
+ declare function useActivities(getClient: () => MedialaneClient, query?: ApiActivitiesQuery): {
7
+ activities: ApiActivity[];
8
+ meta: _medialane_sdk.ApiMeta | undefined;
9
+ isLoading: boolean;
10
+ error: any;
11
+ mutate: swr.KeyedMutator<ApiResponse<ApiActivity[]>>;
12
+ };
13
+ declare function useActivitiesByAddress(getClient: () => MedialaneClient, address: string | null): {
14
+ activities: ApiActivity[];
15
+ isLoading: boolean;
16
+ error: any;
17
+ mutate: swr.KeyedMutator<ApiResponse<ApiActivity[]>>;
18
+ };
19
+
20
+ export { useActivities, useActivitiesByAddress };
@@ -0,0 +1,33 @@
1
+ "use client";
2
+ import useSWR from "swr";
3
+ import { useMedialaneClient } from "./use-medialane-client.js";
4
+ function useActivities(getClient, query = {}) {
5
+ const client = useMedialaneClient(getClient);
6
+ const key = JSON.stringify({ op: "activities", ...query });
7
+ const { data, error, isLoading, mutate } = useSWR(
8
+ key,
9
+ () => client.api.getActivities(query),
10
+ { revalidateOnFocus: false, refreshInterval: 3e4 }
11
+ );
12
+ return {
13
+ activities: data?.data ?? [],
14
+ meta: data?.meta,
15
+ isLoading,
16
+ error,
17
+ mutate
18
+ };
19
+ }
20
+ function useActivitiesByAddress(getClient, address) {
21
+ const client = useMedialaneClient(getClient);
22
+ const { data, error, isLoading, mutate } = useSWR(
23
+ address ? `activities-${address}` : null,
24
+ () => client.api.getActivitiesByAddress(address),
25
+ { revalidateOnFocus: false, refreshInterval: 3e4 }
26
+ );
27
+ return { activities: data?.data ?? [], isLoading, error, mutate };
28
+ }
29
+ export {
30
+ useActivities,
31
+ useActivitiesByAddress
32
+ };
33
+ //# sourceMappingURL=use-activities.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/utils/use-activities.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 { ApiActivitiesQuery, ApiActivity, ApiResponse } from \"@medialane/sdk\";\n\nexport function useActivities(getClient: () => MedialaneClient, query: ApiActivitiesQuery = {}) {\n const client = useMedialaneClient(getClient);\n const key = JSON.stringify({ op: \"activities\", ...query });\n\n const { data, error, isLoading, mutate } = useSWR<ApiResponse<ApiActivity[]>>(\n key,\n () => client.api.getActivities(query),\n { revalidateOnFocus: false, refreshInterval: 30000 }\n );\n\n return {\n activities: data?.data ?? [],\n meta: data?.meta,\n isLoading,\n error,\n mutate,\n };\n}\n\nexport function useActivitiesByAddress(getClient: () => MedialaneClient, address: string | null) {\n const client = useMedialaneClient(getClient);\n\n const { data, error, isLoading, mutate } = useSWR(\n address ? `activities-${address}` : null,\n () => client.api.getActivitiesByAddress(address!),\n { revalidateOnFocus: false, refreshInterval: 30000 }\n );\n\n return { activities: data?.data ?? [], isLoading, error, mutate };\n}\n"],"mappings":";AAEA,OAAO,YAAY;AACnB,SAAS,0BAA0B;AAI5B,SAAS,cAAc,WAAkC,QAA4B,CAAC,GAAG;AAC9F,QAAM,SAAS,mBAAmB,SAAS;AAC3C,QAAM,MAAM,KAAK,UAAU,EAAE,IAAI,cAAc,GAAG,MAAM,CAAC;AAEzD,QAAM,EAAE,MAAM,OAAO,WAAW,OAAO,IAAI;AAAA,IACzC;AAAA,IACA,MAAM,OAAO,IAAI,cAAc,KAAK;AAAA,IACpC,EAAE,mBAAmB,OAAO,iBAAiB,IAAM;AAAA,EACrD;AAEA,SAAO;AAAA,IACL,YAAY,MAAM,QAAQ,CAAC;AAAA,IAC3B,MAAM,MAAM;AAAA,IACZ;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACF;AAEO,SAAS,uBAAuB,WAAkC,SAAwB;AAC/F,QAAM,SAAS,mBAAmB,SAAS;AAE3C,QAAM,EAAE,MAAM,OAAO,WAAW,OAAO,IAAI;AAAA,IACzC,UAAU,cAAc,OAAO,KAAK;AAAA,IACpC,MAAM,OAAO,IAAI,uBAAuB,OAAQ;AAAA,IAChD,EAAE,mBAAmB,OAAO,iBAAiB,IAAM;AAAA,EACrD;AAEA,SAAO,EAAE,YAAY,MAAM,QAAQ,CAAC,GAAG,WAAW,OAAO,OAAO;AAClE;","names":[]}