@adspacedotfun/sdk 0.1.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/README.md +52 -0
- package/dist/campaign-8I-L9KNW.js +319 -0
- package/dist/campaign-8I-L9KNW.js.map +1 -0
- package/dist/campaign-D-02mKGw.cjs +2 -0
- package/dist/campaign-D-02mKGw.cjs.map +1 -0
- package/dist/core/client.d.ts +63 -0
- package/dist/core/client.d.ts.map +1 -0
- package/dist/core/config.d.ts +57 -0
- package/dist/core/config.d.ts.map +1 -0
- package/dist/core/contracts.d.ts +167 -0
- package/dist/core/contracts.d.ts.map +1 -0
- package/dist/core/index.d.ts +8 -0
- package/dist/core/index.d.ts.map +1 -0
- package/dist/core/types.d.ts +89 -0
- package/dist/core/types.d.ts.map +1 -0
- package/dist/core/utils/campaign.d.ts +22 -0
- package/dist/core/utils/campaign.d.ts.map +1 -0
- package/dist/core/utils/index.d.ts +3 -0
- package/dist/core/utils/index.d.ts.map +1 -0
- package/dist/core/utils/ipfs.d.ts +13 -0
- package/dist/core/utils/ipfs.d.ts.map +1 -0
- package/dist/index.cjs +2 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +18 -0
- package/dist/index.js.map +1 -0
- package/dist/react/components/AdWidget.d.ts +49 -0
- package/dist/react/components/AdWidget.d.ts.map +1 -0
- package/dist/react/components/index.d.ts +3 -0
- package/dist/react/components/index.d.ts.map +1 -0
- package/dist/react/context.d.ts +39 -0
- package/dist/react/context.d.ts.map +1 -0
- package/dist/react/hooks/index.d.ts +3 -0
- package/dist/react/hooks/index.d.ts.map +1 -0
- package/dist/react/hooks/useActiveAd.d.ts +41 -0
- package/dist/react/hooks/useActiveAd.d.ts.map +1 -0
- package/dist/react/index.d.ts +7 -0
- package/dist/react/index.d.ts.map +1 -0
- package/dist/react.cjs +2 -0
- package/dist/react.cjs.map +1 -0
- package/dist/react.d.ts +8 -0
- package/dist/react.d.ts.map +1 -0
- package/dist/react.js +167 -0
- package/dist/react.js.map +1 -0
- package/dist/vue/components/AdWidget.vue.d.ts +41 -0
- package/dist/vue/components/AdWidget.vue.d.ts.map +1 -0
- package/dist/vue/components/index.d.ts +2 -0
- package/dist/vue/components/index.d.ts.map +1 -0
- package/dist/vue/composables/index.d.ts +3 -0
- package/dist/vue/composables/index.d.ts.map +1 -0
- package/dist/vue/composables/useActiveAd.d.ts +38 -0
- package/dist/vue/composables/useActiveAd.d.ts.map +1 -0
- package/dist/vue/index.d.ts +6 -0
- package/dist/vue/index.d.ts.map +1 -0
- package/dist/vue/plugin.d.ts +32 -0
- package/dist/vue/plugin.d.ts.map +1 -0
- package/dist/vue.cjs +2 -0
- package/dist/vue.cjs.map +1 -0
- package/dist/vue.d.ts +7 -0
- package/dist/vue.d.ts.map +1 -0
- package/dist/vue.js +140 -0
- package/dist/vue.js.map +1 -0
- package/package.json +102 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/core/config.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B,4CAA4C;IAC5C,OAAO,EAAE,MAAM,CAAC;IAChB,kCAAkC;IAClC,IAAI,EAAE,MAAM,CAAC;IACb,uBAAuB;IACvB,MAAM,EAAE,MAAM,CAAC;IACf,oCAAoC;IACpC,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC,sCAAsC;IACtC,cAAc,EAAE,MAAM,CAAC;IACvB,6CAA6C;IAC7C,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,8CAA8C;IAC9C,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED;;GAEG;AACH,MAAM,WAAW,UAAU;IACzB,+BAA+B;IAC/B,OAAO,EAAE,MAAM,CAAC;IAChB,wBAAwB;IACxB,gBAAgB,CAAC,EAAE,MAAM,EAAE,CAAC;CAC7B;AAED;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B,4BAA4B;IAC5B,OAAO,EAAE,aAAa,CAAC;IACvB,yBAAyB;IACzB,SAAS,EAAE,iBAAiB,CAAC;IAC7B,yBAAyB;IACzB,IAAI,CAAC,EAAE,UAAU,CAAC;IAClB,+DAA+D;IAC/D,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,2BAA2B;IAC3B,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB;AAED;;GAEG;AACH,eAAO,MAAM,cAAc,EAAE,aAsB5B,CAAC;AAEF;;GAEG;AACH,wBAAgB,YAAY,CAAC,UAAU,EAAE,OAAO,CAAC,aAAa,CAAC,GAAG,aAAa,CAiB9E"}
|
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ABI for AdSpaceManager contract - only the functions needed for the SDK
|
|
3
|
+
*/
|
|
4
|
+
export declare const AD_SPACE_MANAGER_ABI: readonly [{
|
|
5
|
+
readonly inputs: readonly [{
|
|
6
|
+
readonly internalType: "uint256";
|
|
7
|
+
readonly name: "spaceId";
|
|
8
|
+
readonly type: "uint256";
|
|
9
|
+
}];
|
|
10
|
+
readonly name: "getActiveAdImage";
|
|
11
|
+
readonly outputs: readonly [{
|
|
12
|
+
readonly internalType: "string";
|
|
13
|
+
readonly name: "imageLink";
|
|
14
|
+
readonly type: "string";
|
|
15
|
+
}, {
|
|
16
|
+
readonly internalType: "string";
|
|
17
|
+
readonly name: "advertiserSiteLink";
|
|
18
|
+
readonly type: "string";
|
|
19
|
+
}, {
|
|
20
|
+
readonly internalType: "uint256";
|
|
21
|
+
readonly name: "campaignId";
|
|
22
|
+
readonly type: "uint256";
|
|
23
|
+
}];
|
|
24
|
+
readonly stateMutability: "view";
|
|
25
|
+
readonly type: "function";
|
|
26
|
+
}, {
|
|
27
|
+
readonly inputs: readonly [{
|
|
28
|
+
readonly internalType: "uint256";
|
|
29
|
+
readonly name: "spaceId";
|
|
30
|
+
readonly type: "uint256";
|
|
31
|
+
}];
|
|
32
|
+
readonly name: "getAdSpace";
|
|
33
|
+
readonly outputs: readonly [{
|
|
34
|
+
readonly components: readonly [{
|
|
35
|
+
readonly internalType: "uint256";
|
|
36
|
+
readonly name: "id";
|
|
37
|
+
readonly type: "uint256";
|
|
38
|
+
}, {
|
|
39
|
+
readonly internalType: "uint256";
|
|
40
|
+
readonly name: "tokenId";
|
|
41
|
+
readonly type: "uint256";
|
|
42
|
+
}, {
|
|
43
|
+
readonly internalType: "string";
|
|
44
|
+
readonly name: "dimensions";
|
|
45
|
+
readonly type: "string";
|
|
46
|
+
}, {
|
|
47
|
+
readonly internalType: "uint256";
|
|
48
|
+
readonly name: "pricePerHour";
|
|
49
|
+
readonly type: "uint256";
|
|
50
|
+
}, {
|
|
51
|
+
readonly internalType: "string";
|
|
52
|
+
readonly name: "siteLink";
|
|
53
|
+
readonly type: "string";
|
|
54
|
+
}, {
|
|
55
|
+
readonly internalType: "uint256";
|
|
56
|
+
readonly name: "instalments";
|
|
57
|
+
readonly type: "uint256";
|
|
58
|
+
}, {
|
|
59
|
+
readonly internalType: "string";
|
|
60
|
+
readonly name: "defaultAdLink";
|
|
61
|
+
readonly type: "string";
|
|
62
|
+
}, {
|
|
63
|
+
readonly internalType: "string";
|
|
64
|
+
readonly name: "adSpaceName";
|
|
65
|
+
readonly type: "string";
|
|
66
|
+
}, {
|
|
67
|
+
readonly internalType: "address";
|
|
68
|
+
readonly name: "publisher";
|
|
69
|
+
readonly type: "address";
|
|
70
|
+
}, {
|
|
71
|
+
readonly internalType: "bool";
|
|
72
|
+
readonly name: "isActive";
|
|
73
|
+
readonly type: "bool";
|
|
74
|
+
}];
|
|
75
|
+
readonly internalType: "struct AdSpaceManager.AdSpace";
|
|
76
|
+
readonly name: "";
|
|
77
|
+
readonly type: "tuple";
|
|
78
|
+
}];
|
|
79
|
+
readonly stateMutability: "view";
|
|
80
|
+
readonly type: "function";
|
|
81
|
+
}, {
|
|
82
|
+
readonly inputs: readonly [{
|
|
83
|
+
readonly internalType: "uint256";
|
|
84
|
+
readonly name: "campaignId";
|
|
85
|
+
readonly type: "uint256";
|
|
86
|
+
}];
|
|
87
|
+
readonly name: "getCampaign";
|
|
88
|
+
readonly outputs: readonly [{
|
|
89
|
+
readonly components: readonly [{
|
|
90
|
+
readonly internalType: "uint256";
|
|
91
|
+
readonly name: "id";
|
|
92
|
+
readonly type: "uint256";
|
|
93
|
+
}, {
|
|
94
|
+
readonly internalType: "uint256";
|
|
95
|
+
readonly name: "tokenId";
|
|
96
|
+
readonly type: "uint256";
|
|
97
|
+
}, {
|
|
98
|
+
readonly internalType: "uint256";
|
|
99
|
+
readonly name: "spaceId";
|
|
100
|
+
readonly type: "uint256";
|
|
101
|
+
}, {
|
|
102
|
+
readonly internalType: "uint256";
|
|
103
|
+
readonly name: "spaceTokenId";
|
|
104
|
+
readonly type: "uint256";
|
|
105
|
+
}, {
|
|
106
|
+
readonly internalType: "string";
|
|
107
|
+
readonly name: "imageLink";
|
|
108
|
+
readonly type: "string";
|
|
109
|
+
}, {
|
|
110
|
+
readonly internalType: "string";
|
|
111
|
+
readonly name: "advertiserSiteLink";
|
|
112
|
+
readonly type: "string";
|
|
113
|
+
}, {
|
|
114
|
+
readonly internalType: "string";
|
|
115
|
+
readonly name: "metadataURI";
|
|
116
|
+
readonly type: "string";
|
|
117
|
+
}, {
|
|
118
|
+
readonly internalType: "uint256";
|
|
119
|
+
readonly name: "startTime";
|
|
120
|
+
readonly type: "uint256";
|
|
121
|
+
}, {
|
|
122
|
+
readonly internalType: "uint256";
|
|
123
|
+
readonly name: "endTime";
|
|
124
|
+
readonly type: "uint256";
|
|
125
|
+
}, {
|
|
126
|
+
readonly internalType: "address";
|
|
127
|
+
readonly name: "tokenAddress";
|
|
128
|
+
readonly type: "address";
|
|
129
|
+
}, {
|
|
130
|
+
readonly internalType: "uint256";
|
|
131
|
+
readonly name: "totalAmount";
|
|
132
|
+
readonly type: "uint256";
|
|
133
|
+
}, {
|
|
134
|
+
readonly internalType: "uint256";
|
|
135
|
+
readonly name: "amountSettled";
|
|
136
|
+
readonly type: "uint256";
|
|
137
|
+
}, {
|
|
138
|
+
readonly internalType: "address";
|
|
139
|
+
readonly name: "advertiser";
|
|
140
|
+
readonly type: "address";
|
|
141
|
+
}, {
|
|
142
|
+
readonly internalType: "enum AdSpaceManager.CampaignStatus";
|
|
143
|
+
readonly name: "status";
|
|
144
|
+
readonly type: "uint8";
|
|
145
|
+
}];
|
|
146
|
+
readonly internalType: "struct AdSpaceManager.Campaign";
|
|
147
|
+
readonly name: "";
|
|
148
|
+
readonly type: "tuple";
|
|
149
|
+
}];
|
|
150
|
+
readonly stateMutability: "view";
|
|
151
|
+
readonly type: "function";
|
|
152
|
+
}, {
|
|
153
|
+
readonly inputs: readonly [{
|
|
154
|
+
readonly internalType: "uint256";
|
|
155
|
+
readonly name: "spaceId";
|
|
156
|
+
readonly type: "uint256";
|
|
157
|
+
}];
|
|
158
|
+
readonly name: "getSpaceCampaigns";
|
|
159
|
+
readonly outputs: readonly [{
|
|
160
|
+
readonly internalType: "uint256[]";
|
|
161
|
+
readonly name: "";
|
|
162
|
+
readonly type: "uint256[]";
|
|
163
|
+
}];
|
|
164
|
+
readonly stateMutability: "view";
|
|
165
|
+
readonly type: "function";
|
|
166
|
+
}];
|
|
167
|
+
//# sourceMappingURL=contracts.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"contracts.d.ts","sourceRoot":"","sources":["../../src/core/contracts.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,eAAO,MAAM,oBAAoB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAyEvB,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export { AdSpaceClient, createAdSpaceClient } from './client';
|
|
2
|
+
export { DEFAULT_CONFIG, createConfig } from './config';
|
|
3
|
+
export type { AdSpaceConfig, NetworkConfig, ContractAddresses, IPFSConfig, } from './config';
|
|
4
|
+
export { CampaignStatus } from './types';
|
|
5
|
+
export type { ActiveAd, AdSpace, Campaign, AdWidgetOptions, FetchActiveAdOptions, } from './types';
|
|
6
|
+
export { AD_SPACE_MANAGER_ABI } from './contracts';
|
|
7
|
+
export * from './utils';
|
|
8
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/core/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAC;AAC9D,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AACxD,YAAY,EACV,aAAa,EACb,aAAa,EACb,iBAAiB,EACjB,UAAU,GACX,MAAM,UAAU,CAAC;AAClB,OAAO,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AACzC,YAAY,EACV,QAAQ,EACR,OAAO,EACP,QAAQ,EACR,eAAe,EACf,oBAAoB,GACrB,MAAM,SAAS,CAAC;AACjB,OAAO,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AACnD,cAAc,SAAS,CAAC"}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Campaign status enum (matches on-chain enum)
|
|
3
|
+
*/
|
|
4
|
+
export declare enum CampaignStatus {
|
|
5
|
+
Pending = 0,
|
|
6
|
+
Approved = 1,
|
|
7
|
+
Active = 2,
|
|
8
|
+
Completed = 3,
|
|
9
|
+
Rejected = 4,
|
|
10
|
+
Cancelled = 5
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Ad space data structure
|
|
14
|
+
*/
|
|
15
|
+
export interface AdSpace {
|
|
16
|
+
id: string;
|
|
17
|
+
tokenId: string;
|
|
18
|
+
dimensions: string;
|
|
19
|
+
pricePerHour: bigint;
|
|
20
|
+
siteLink: string;
|
|
21
|
+
instalments: number;
|
|
22
|
+
defaultAdLink: string;
|
|
23
|
+
adSpaceName: string;
|
|
24
|
+
publisher: string;
|
|
25
|
+
isActive: boolean;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Campaign data structure
|
|
29
|
+
*/
|
|
30
|
+
export interface Campaign {
|
|
31
|
+
id: string;
|
|
32
|
+
tokenId: string;
|
|
33
|
+
spaceId: string;
|
|
34
|
+
spaceTokenId: string;
|
|
35
|
+
imageLink: string;
|
|
36
|
+
advertiserSiteLink: string;
|
|
37
|
+
metadataURI: string;
|
|
38
|
+
startTime: number;
|
|
39
|
+
endTime: number;
|
|
40
|
+
tokenAddress: string;
|
|
41
|
+
totalAmount: bigint;
|
|
42
|
+
amountSettled: bigint;
|
|
43
|
+
advertiser: string;
|
|
44
|
+
status: CampaignStatus;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Active ad data returned from getActiveAdImage
|
|
48
|
+
*/
|
|
49
|
+
export interface ActiveAd {
|
|
50
|
+
/** Raw IPFS link */
|
|
51
|
+
imageLink: string;
|
|
52
|
+
/** Resolved HTTP URL */
|
|
53
|
+
imageUrl: string;
|
|
54
|
+
/** Advertiser's website link */
|
|
55
|
+
advertiserSiteLink: string;
|
|
56
|
+
/** Campaign ID (0 if default ad) */
|
|
57
|
+
campaignId: string;
|
|
58
|
+
/** True if showing default ad (no active campaign) */
|
|
59
|
+
isDefault: boolean;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Options for fetching active ad
|
|
63
|
+
*/
|
|
64
|
+
export interface FetchActiveAdOptions {
|
|
65
|
+
/** Space ID to fetch ad for */
|
|
66
|
+
spaceId: number;
|
|
67
|
+
/** Custom IPFS gateway (optional) */
|
|
68
|
+
ipfsGateway?: string;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Ad widget display options
|
|
72
|
+
*/
|
|
73
|
+
export interface AdWidgetOptions {
|
|
74
|
+
/** Space ID to display */
|
|
75
|
+
spaceId: number;
|
|
76
|
+
/** Container width */
|
|
77
|
+
width?: string;
|
|
78
|
+
/** Container height */
|
|
79
|
+
height?: string;
|
|
80
|
+
/** Auto-refresh interval (seconds, 0 to disable) */
|
|
81
|
+
refreshInterval?: number;
|
|
82
|
+
/** Callback when ad loads */
|
|
83
|
+
onLoad?: (ad: ActiveAd) => void;
|
|
84
|
+
/** Callback on error */
|
|
85
|
+
onError?: (error: Error) => void;
|
|
86
|
+
/** Callback on ad click */
|
|
87
|
+
onClick?: (ad: ActiveAd) => void;
|
|
88
|
+
}
|
|
89
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/core/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,oBAAY,cAAc;IACxB,OAAO,IAAI;IACX,QAAQ,IAAI;IACZ,MAAM,IAAI;IACV,SAAS,IAAI;IACb,QAAQ,IAAI;IACZ,SAAS,IAAI;CACd;AAED;;GAEG;AACH,MAAM,WAAW,OAAO;IACtB,EAAE,EAAE,MAAM,CAAC;IACX,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,MAAM,CAAC;IACnB,YAAY,EAAE,MAAM,CAAC;IACrB,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,EAAE,MAAM,CAAC;IACpB,aAAa,EAAE,MAAM,CAAC;IACtB,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,OAAO,CAAC;CACnB;AAED;;GAEG;AACH,MAAM,WAAW,QAAQ;IACvB,EAAE,EAAE,MAAM,CAAC;IACX,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;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C"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { CampaignStatus } from '../types';
|
|
2
|
+
/**
|
|
3
|
+
* Checks if a campaign should be considered active based on timestamps
|
|
4
|
+
*/
|
|
5
|
+
export declare function isCampaignActive(status: CampaignStatus, startTime: number, endTime: number, currentTimestamp?: number): boolean;
|
|
6
|
+
/**
|
|
7
|
+
* Gets the effective display status for a campaign
|
|
8
|
+
*/
|
|
9
|
+
export declare function getEffectiveCampaignStatus(status: CampaignStatus, startTime: number, endTime: number, currentTimestamp?: number): CampaignStatus;
|
|
10
|
+
/**
|
|
11
|
+
* Gets human-readable status label
|
|
12
|
+
*/
|
|
13
|
+
export declare function getCampaignStatusLabel(status: CampaignStatus): string;
|
|
14
|
+
/**
|
|
15
|
+
* Calculates remaining time for a campaign
|
|
16
|
+
*/
|
|
17
|
+
export declare function getCampaignTimeRemaining(endTime: number, currentTimestamp?: number): number;
|
|
18
|
+
/**
|
|
19
|
+
* Formats duration in seconds to human-readable string
|
|
20
|
+
*/
|
|
21
|
+
export declare function formatDuration(seconds: number): string;
|
|
22
|
+
//# sourceMappingURL=campaign.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"campaign.d.ts","sourceRoot":"","sources":["../../../src/core/utils/campaign.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAE1C;;GAEG;AACH,wBAAgB,gBAAgB,CAC9B,MAAM,EAAE,cAAc,EACtB,SAAS,EAAE,MAAM,EACjB,OAAO,EAAE,MAAM,EACf,gBAAgB,CAAC,EAAE,MAAM,GACxB,OAAO,CAQT;AAED;;GAEG;AACH,wBAAgB,0BAA0B,CACxC,MAAM,EAAE,cAAc,EACtB,SAAS,EAAE,MAAM,EACjB,OAAO,EAAE,MAAM,EACf,gBAAgB,CAAC,EAAE,MAAM,GACxB,cAAc,CAchB;AAED;;GAEG;AACH,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,cAAc,GAAG,MAAM,CAUrE;AAED;;GAEG;AACH,wBAAgB,wBAAwB,CACtC,OAAO,EAAE,MAAM,EACf,gBAAgB,CAAC,EAAE,MAAM,GACxB,MAAM,CAGR;AAED;;GAEG;AACH,wBAAgB,cAAc,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAetD"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/core/utils/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,cAAc,EACd,UAAU,EACV,eAAe,GAChB,MAAM,QAAQ,CAAC;AAEhB,OAAO,EACL,gBAAgB,EAChB,0BAA0B,EAC1B,sBAAsB,EACtB,wBAAwB,EACxB,cAAc,GACf,MAAM,YAAY,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Resolves an IPFS URI to an HTTP URL
|
|
3
|
+
*/
|
|
4
|
+
export declare function resolveIPFSUrl(ipfsUri: string, gateway?: string): string;
|
|
5
|
+
/**
|
|
6
|
+
* Extracts CID from an IPFS URI or URL
|
|
7
|
+
*/
|
|
8
|
+
export declare function extractCID(ipfsUri: string): string;
|
|
9
|
+
/**
|
|
10
|
+
* Checks if a string is a valid IPFS reference
|
|
11
|
+
*/
|
|
12
|
+
export declare function isIPFSReference(value: string): boolean;
|
|
13
|
+
//# sourceMappingURL=ipfs.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ipfs.d.ts","sourceRoot":"","sources":["../../../src/core/utils/ipfs.ts"],"names":[],"mappings":"AAKA;;GAEG;AACH,wBAAgB,cAAc,CAC5B,OAAO,EAAE,MAAM,EACf,OAAO,GAAE,MAAwB,GAChC,MAAM,CA0BR;AAED;;GAEG;AACH,wBAAgB,UAAU,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAqBlD;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAUtD"}
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./campaign-D-02mKGw.cjs");exports.AD_SPACE_MANAGER_ABI=e.AD_SPACE_MANAGER_ABI;exports.AdSpaceClient=e.AdSpaceClient;exports.CampaignStatus=e.CampaignStatus;exports.DEFAULT_CONFIG=e.DEFAULT_CONFIG;exports.createAdSpaceClient=e.createAdSpaceClient;exports.createConfig=e.createConfig;exports.extractCID=e.extractCID;exports.formatDuration=e.formatDuration;exports.getCampaignStatusLabel=e.getCampaignStatusLabel;exports.getCampaignTimeRemaining=e.getCampaignTimeRemaining;exports.getEffectiveCampaignStatus=e.getEffectiveCampaignStatus;exports.isCampaignActive=e.isCampaignActive;exports.isIPFSReference=e.isIPFSReference;exports.resolveIPFSUrl=e.resolveIPFSUrl;
|
|
2
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export { AdSpaceClient, createAdSpaceClient } from './core/client';
|
|
2
|
+
export { DEFAULT_CONFIG, createConfig } from './core/config';
|
|
3
|
+
export type { AdSpaceConfig, NetworkConfig, ContractAddresses, IPFSConfig, } from './core/config';
|
|
4
|
+
export { CampaignStatus } from './core/types';
|
|
5
|
+
export type { ActiveAd, AdSpace, Campaign, AdWidgetOptions, FetchActiveAdOptions, } from './core/types';
|
|
6
|
+
export { resolveIPFSUrl, extractCID, isIPFSReference, isCampaignActive, getEffectiveCampaignStatus, getCampaignStatusLabel, getCampaignTimeRemaining, formatDuration, } from './core/utils';
|
|
7
|
+
export { AD_SPACE_MANAGER_ABI } from './core/contracts';
|
|
8
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AACnE,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAC7D,YAAY,EACV,aAAa,EACb,aAAa,EACb,iBAAiB,EACjB,UAAU,GACX,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAC9C,YAAY,EACV,QAAQ,EACR,OAAO,EACP,QAAQ,EACR,eAAe,EACf,oBAAoB,GACrB,MAAM,cAAc,CAAC;AAGtB,OAAO,EACL,cAAc,EACd,UAAU,EACV,eAAe,EACf,gBAAgB,EAChB,0BAA0B,EAC1B,sBAAsB,EACtB,wBAAwB,EACxB,cAAc,GACf,MAAM,cAAc,CAAC;AAGtB,OAAO,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { A as s, a as t, C as i, D as n, c as C, b as g, e as r, f as A, g as c, d as m, h as p, i as S, j as f, r as o } from "./campaign-8I-L9KNW.js";
|
|
2
|
+
export {
|
|
3
|
+
s as AD_SPACE_MANAGER_ABI,
|
|
4
|
+
t as AdSpaceClient,
|
|
5
|
+
i as CampaignStatus,
|
|
6
|
+
n as DEFAULT_CONFIG,
|
|
7
|
+
C as createAdSpaceClient,
|
|
8
|
+
g as createConfig,
|
|
9
|
+
r as extractCID,
|
|
10
|
+
A as formatDuration,
|
|
11
|
+
c as getCampaignStatusLabel,
|
|
12
|
+
m as getCampaignTimeRemaining,
|
|
13
|
+
p as getEffectiveCampaignStatus,
|
|
14
|
+
S as isCampaignActive,
|
|
15
|
+
f as isIPFSReference,
|
|
16
|
+
o as resolveIPFSUrl
|
|
17
|
+
};
|
|
18
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { default as React, CSSProperties } from 'react';
|
|
2
|
+
import { ActiveAd } from '../../core/types';
|
|
3
|
+
export interface AdWidgetProps {
|
|
4
|
+
/** Space ID to display ads for */
|
|
5
|
+
spaceId: number;
|
|
6
|
+
/** Container width (CSS value) */
|
|
7
|
+
width?: string;
|
|
8
|
+
/** Container height (CSS value) */
|
|
9
|
+
height?: string;
|
|
10
|
+
/** Refresh interval in seconds (0 to disable) */
|
|
11
|
+
refreshInterval?: number;
|
|
12
|
+
/** Custom CSS class name */
|
|
13
|
+
className?: string;
|
|
14
|
+
/** Custom inline styles */
|
|
15
|
+
style?: CSSProperties;
|
|
16
|
+
/** Loading component */
|
|
17
|
+
loadingComponent?: React.ReactNode;
|
|
18
|
+
/** Error component */
|
|
19
|
+
errorComponent?: React.ReactNode | ((error: Error) => React.ReactNode);
|
|
20
|
+
/** Empty state component */
|
|
21
|
+
emptyComponent?: React.ReactNode;
|
|
22
|
+
/** Callback when ad loads */
|
|
23
|
+
onLoad?: (ad: ActiveAd) => void;
|
|
24
|
+
/** Callback on error */
|
|
25
|
+
onError?: (error: Error) => void;
|
|
26
|
+
/** Callback on ad click */
|
|
27
|
+
onClick?: (ad: ActiveAd, event: React.MouseEvent) => void;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Pre-built Ad Widget component
|
|
31
|
+
*
|
|
32
|
+
* @example
|
|
33
|
+
* ```tsx
|
|
34
|
+
* import { AdWidget } from '@adspace/sdk/react';
|
|
35
|
+
*
|
|
36
|
+
* function MyPage() {
|
|
37
|
+
* return (
|
|
38
|
+
* <AdWidget
|
|
39
|
+
* spaceId={1}
|
|
40
|
+
* width="300px"
|
|
41
|
+
* height="250px"
|
|
42
|
+
* refreshInterval={30}
|
|
43
|
+
* />
|
|
44
|
+
* );
|
|
45
|
+
* }
|
|
46
|
+
* ```
|
|
47
|
+
*/
|
|
48
|
+
export declare function AdWidget({ spaceId, width, height, refreshInterval, className, style, loadingComponent, errorComponent, emptyComponent, onLoad, onError, onClick, }: AdWidgetProps): import("react/jsx-runtime").JSX.Element;
|
|
49
|
+
//# sourceMappingURL=AdWidget.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AdWidget.d.ts","sourceRoot":"","sources":["../../../src/react/components/AdWidget.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAE7C,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAE5C,MAAM,WAAW,aAAa;IAC5B,kCAAkC;IAClC,OAAO,EAAE,MAAM,CAAC;IAChB,kCAAkC;IAClC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,mCAAmC;IACnC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,iDAAiD;IACjD,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,4BAA4B;IAC5B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,2BAA2B;IAC3B,KAAK,CAAC,EAAE,aAAa,CAAC;IACtB,wBAAwB;IACxB,gBAAgB,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IACnC,sBAAsB;IACtB,cAAc,CAAC,EAAE,KAAK,CAAC,SAAS,GAAG,CAAC,CAAC,KAAK,EAAE,KAAK,KAAK,KAAK,CAAC,SAAS,CAAC,CAAC;IACvE,4BAA4B;IAC5B,cAAc,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IACjC,6BAA6B;IAC7B,MAAM,CAAC,EAAE,CAAC,EAAE,EAAE,QAAQ,KAAK,IAAI,CAAC;IAChC,wBAAwB;IACxB,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;IACjC,2BAA2B;IAC3B,OAAO,CAAC,EAAE,CAAC,EAAE,EAAE,QAAQ,EAAE,KAAK,EAAE,KAAK,CAAC,UAAU,KAAK,IAAI,CAAC;CAC3D;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,QAAQ,CAAC,EACvB,OAAO,EACP,KAAc,EACd,MAAe,EACf,eAAoB,EACpB,SAAS,EACT,KAAK,EACL,gBAAgB,EAChB,cAAc,EACd,cAAc,EACd,MAAM,EACN,OAAO,EACP,OAAO,GACR,EAAE,aAAa,2CAmHf"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/react/components/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,YAAY,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
import { AdSpaceClient } from '../core/client';
|
|
3
|
+
import { AdSpaceConfig } from '../core/config';
|
|
4
|
+
interface AdSpaceContextValue {
|
|
5
|
+
client: AdSpaceClient;
|
|
6
|
+
config: AdSpaceConfig;
|
|
7
|
+
}
|
|
8
|
+
export interface AdSpaceProviderProps {
|
|
9
|
+
children: ReactNode;
|
|
10
|
+
config?: Partial<AdSpaceConfig>;
|
|
11
|
+
client?: AdSpaceClient;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* AdSpace Provider for React applications
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* ```tsx
|
|
18
|
+
* import { AdSpaceProvider } from '@adspace/sdk/react';
|
|
19
|
+
*
|
|
20
|
+
* function App() {
|
|
21
|
+
* return (
|
|
22
|
+
* <AdSpaceProvider config={{ network: { rpcUrl: '...' } }}>
|
|
23
|
+
* <MyComponent />
|
|
24
|
+
* </AdSpaceProvider>
|
|
25
|
+
* );
|
|
26
|
+
* }
|
|
27
|
+
* ```
|
|
28
|
+
*/
|
|
29
|
+
export declare function AdSpaceProvider({ children, config, client: providedClient, }: AdSpaceProviderProps): import("react/jsx-runtime").JSX.Element;
|
|
30
|
+
/**
|
|
31
|
+
* Hook to access AdSpace context
|
|
32
|
+
*/
|
|
33
|
+
export declare function useAdSpaceContext(): AdSpaceContextValue;
|
|
34
|
+
/**
|
|
35
|
+
* Hook to access the AdSpace client directly
|
|
36
|
+
*/
|
|
37
|
+
export declare function useAdSpaceClient(): AdSpaceClient;
|
|
38
|
+
export {};
|
|
39
|
+
//# sourceMappingURL=context.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../src/react/context.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAsC,SAAS,EAAE,MAAM,OAAO,CAAC;AACtE,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAC/C,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAE/C,UAAU,mBAAmB;IAC3B,MAAM,EAAE,aAAa,CAAC;IACtB,MAAM,EAAE,aAAa,CAAC;CACvB;AAID,MAAM,WAAW,oBAAoB;IACnC,QAAQ,EAAE,SAAS,CAAC;IACpB,MAAM,CAAC,EAAE,OAAO,CAAC,aAAa,CAAC,CAAC;IAChC,MAAM,CAAC,EAAE,aAAa,CAAC;CACxB;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,eAAe,CAAC,EAC9B,QAAQ,EACR,MAAW,EACX,MAAM,EAAE,cAAc,GACvB,EAAE,oBAAoB,2CAgBtB;AAED;;GAEG;AACH,wBAAgB,iBAAiB,IAAI,mBAAmB,CAMvD;AAED;;GAEG;AACH,wBAAgB,gBAAgB,IAAI,aAAa,CAGhD"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/react/hooks/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,YAAY,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { ActiveAd } from '../../core/types';
|
|
2
|
+
export interface UseActiveAdOptions {
|
|
3
|
+
/** Polling interval in seconds (0 to disable) */
|
|
4
|
+
refreshInterval?: number;
|
|
5
|
+
/** Callback when ad loads successfully */
|
|
6
|
+
onLoad?: (ad: ActiveAd) => void;
|
|
7
|
+
/** Callback on error */
|
|
8
|
+
onError?: (error: Error) => void;
|
|
9
|
+
/** Whether to fetch immediately on mount */
|
|
10
|
+
enabled?: boolean;
|
|
11
|
+
}
|
|
12
|
+
export interface UseActiveAdResult {
|
|
13
|
+
ad: ActiveAd | null;
|
|
14
|
+
isLoading: boolean;
|
|
15
|
+
error: Error | null;
|
|
16
|
+
refresh: () => Promise<void>;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Hook to fetch and display the active ad for a space
|
|
20
|
+
*
|
|
21
|
+
* @example
|
|
22
|
+
* ```tsx
|
|
23
|
+
* function AdDisplay({ spaceId }: { spaceId: number }) {
|
|
24
|
+
* const { ad, isLoading, error } = useActiveAd(spaceId, {
|
|
25
|
+
* refreshInterval: 30
|
|
26
|
+
* });
|
|
27
|
+
*
|
|
28
|
+
* if (isLoading) return <div>Loading...</div>;
|
|
29
|
+
* if (error) return <div>Error: {error.message}</div>;
|
|
30
|
+
* if (!ad) return <div>No ad available</div>;
|
|
31
|
+
*
|
|
32
|
+
* return (
|
|
33
|
+
* <a href={ad.advertiserSiteLink} target="_blank">
|
|
34
|
+
* <img src={ad.imageUrl} alt="Advertisement" />
|
|
35
|
+
* </a>
|
|
36
|
+
* );
|
|
37
|
+
* }
|
|
38
|
+
* ```
|
|
39
|
+
*/
|
|
40
|
+
export declare function useActiveAd(spaceId: number, options?: UseActiveAdOptions): UseActiveAdResult;
|
|
41
|
+
//# sourceMappingURL=useActiveAd.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useActiveAd.d.ts","sourceRoot":"","sources":["../../../src/react/hooks/useActiveAd.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAE5C,MAAM,WAAW,kBAAkB;IACjC,iDAAiD;IACjD,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,0CAA0C;IAC1C,MAAM,CAAC,EAAE,CAAC,EAAE,EAAE,QAAQ,KAAK,IAAI,CAAC;IAChC,wBAAwB;IACxB,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;IACjC,4CAA4C;IAC5C,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAED,MAAM,WAAW,iBAAiB;IAChC,EAAE,EAAE,QAAQ,GAAG,IAAI,CAAC;IACpB,SAAS,EAAE,OAAO,CAAC;IACnB,KAAK,EAAE,KAAK,GAAG,IAAI,CAAC;IACpB,OAAO,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;CAC9B;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,WAAW,CACzB,OAAO,EAAE,MAAM,EACf,OAAO,GAAE,kBAAuB,GAC/B,iBAAiB,CAsDnB"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export { AdSpaceProvider, useAdSpaceContext, useAdSpaceClient, } from './context';
|
|
2
|
+
export type { AdSpaceProviderProps } from './context';
|
|
3
|
+
export { useActiveAd } from './hooks';
|
|
4
|
+
export type { UseActiveAdOptions, UseActiveAdResult } from './hooks';
|
|
5
|
+
export { AdWidget } from './components';
|
|
6
|
+
export type { AdWidgetProps } from './components';
|
|
7
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/react/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,eAAe,EACf,iBAAiB,EACjB,gBAAgB,GACjB,MAAM,WAAW,CAAC;AACnB,YAAY,EAAE,oBAAoB,EAAE,MAAM,WAAW,CAAC;AAEtD,OAAO,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AACtC,YAAY,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAErE,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AACxC,YAAY,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC"}
|
package/dist/react.cjs
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./campaign-D-02mKGw.cjs"),r=require("react/jsx-runtime"),a=require("react"),x=a.createContext(null);function E({children:n,config:d={},client:c}){const o=a.useMemo(()=>c||new e.AdSpaceClient(d),[c,JSON.stringify(d)]),s=a.useMemo(()=>({client:o,config:o.getConfig()}),[o]);return r.jsx(x.Provider,{value:s,children:n})}function m(){const n=a.useContext(x);if(!n)throw new Error("useAdSpaceContext must be used within AdSpaceProvider");return n}function y(){const{client:n}=m();return n}function I(n,d={}){const c=y(),[o,s]=a.useState(null),[h,C]=a.useState(!0),[g,p]=a.useState(null),A=a.useRef(),{refreshInterval:S=0,onLoad:u,onError:i,enabled:f=!0}=d,l=a.useCallback(async()=>{if(f)try{C(!0),p(null);const t=await c.getActiveAd(n);s(t),t&&u&&u(t)}catch(t){const v=t instanceof Error?t:new Error(String(t));p(v),i&&i(v)}finally{C(!1)}},[c,n,u,i,f]);return a.useEffect(()=>(l(),S>0&&f&&(A.current=setInterval(l,S*1e3)),()=>{A.current&&clearInterval(A.current)}),[l,S,f]),{ad:o,isLoading:h,error:g,refresh:l}}function b({spaceId:n,width:d="100%",height:c="auto",refreshInterval:o=30,className:s,style:h,loadingComponent:C,errorComponent:g,emptyComponent:p,onLoad:A,onError:S,onClick:u}){const{ad:i,isLoading:f,error:l}=I(n,{refreshInterval:o,onLoad:A,onError:S}),t={width:d,height:c,minHeight:c==="auto"?"100px":c,overflow:"hidden",position:"relative",...h},v=j=>{i&&u&&u(i,j)};return f&&!i?r.jsx("div",{className:s,style:t,children:C||r.jsx("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",height:"100%",color:"#666"},children:"Loading..."})}):l?r.jsx("div",{className:s,style:t,children:typeof g=="function"?g(l):g||r.jsx("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",height:"100%",color:"#f00"},children:"Failed to load ad"})}):i?r.jsx("div",{className:s,style:t,children:r.jsx("a",{href:i.advertiserSiteLink||"#",target:"_blank",rel:"noopener noreferrer",onClick:v,style:{display:"block",width:"100%",height:"100%",textDecoration:"none"},children:r.jsx("img",{src:i.imageUrl,alt:"Advertisement",style:{width:"100%",height:"auto",display:"block",maxWidth:"100%"}})})}):r.jsx("div",{className:s,style:t,children:p||r.jsx("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",height:"100%",color:"#999"},children:"No ad available"})})}exports.AD_SPACE_MANAGER_ABI=e.AD_SPACE_MANAGER_ABI;exports.AdSpaceClient=e.AdSpaceClient;exports.CampaignStatus=e.CampaignStatus;exports.DEFAULT_CONFIG=e.DEFAULT_CONFIG;exports.createAdSpaceClient=e.createAdSpaceClient;exports.createConfig=e.createConfig;exports.extractCID=e.extractCID;exports.formatDuration=e.formatDuration;exports.getCampaignStatusLabel=e.getCampaignStatusLabel;exports.getCampaignTimeRemaining=e.getCampaignTimeRemaining;exports.getEffectiveCampaignStatus=e.getEffectiveCampaignStatus;exports.isCampaignActive=e.isCampaignActive;exports.isIPFSReference=e.isIPFSReference;exports.resolveIPFSUrl=e.resolveIPFSUrl;exports.AdSpaceProvider=E;exports.AdWidget=b;exports.useActiveAd=I;exports.useAdSpaceClient=y;exports.useAdSpaceContext=m;
|
|
2
|
+
//# sourceMappingURL=react.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"react.cjs","sources":["../src/react/context.tsx","../src/react/hooks/useActiveAd.ts","../src/react/components/AdWidget.tsx"],"sourcesContent":["import { createContext, useContext, useMemo, ReactNode } from 'react';\nimport { AdSpaceClient } from '../core/client';\nimport { AdSpaceConfig } from '../core/config';\n\ninterface AdSpaceContextValue {\n client: AdSpaceClient;\n config: AdSpaceConfig;\n}\n\nconst AdSpaceContext = createContext<AdSpaceContextValue | null>(null);\n\nexport interface AdSpaceProviderProps {\n children: ReactNode;\n config?: Partial<AdSpaceConfig>;\n client?: AdSpaceClient;\n}\n\n/**\n * AdSpace Provider for React applications\n *\n * @example\n * ```tsx\n * import { AdSpaceProvider } from '@adspace/sdk/react';\n *\n * function App() {\n * return (\n * <AdSpaceProvider config={{ network: { rpcUrl: '...' } }}>\n * <MyComponent />\n * </AdSpaceProvider>\n * );\n * }\n * ```\n */\nexport function AdSpaceProvider({\n children,\n config = {},\n client: providedClient,\n}: AdSpaceProviderProps) {\n const client = useMemo(\n () => providedClient || new AdSpaceClient(config),\n [providedClient, JSON.stringify(config)]\n );\n\n const value = useMemo(\n () => ({ client, config: client.getConfig() }),\n [client]\n );\n\n return (\n <AdSpaceContext.Provider value={value}>\n {children}\n </AdSpaceContext.Provider>\n );\n}\n\n/**\n * Hook to access AdSpace context\n */\nexport function useAdSpaceContext(): AdSpaceContextValue {\n const context = useContext(AdSpaceContext);\n if (!context) {\n throw new Error('useAdSpaceContext must be used within AdSpaceProvider');\n }\n return context;\n}\n\n/**\n * Hook to access the AdSpace client directly\n */\nexport function useAdSpaceClient(): AdSpaceClient {\n const { client } = useAdSpaceContext();\n return client;\n}\n","import { useState, useEffect, useCallback, useRef } from 'react';\nimport { useAdSpaceClient } from '../context';\nimport { ActiveAd } from '../../core/types';\n\nexport interface UseActiveAdOptions {\n /** Polling interval in seconds (0 to disable) */\n refreshInterval?: number;\n /** Callback when ad loads successfully */\n onLoad?: (ad: ActiveAd) => void;\n /** Callback on error */\n onError?: (error: Error) => void;\n /** Whether to fetch immediately on mount */\n enabled?: boolean;\n}\n\nexport interface UseActiveAdResult {\n ad: ActiveAd | null;\n isLoading: boolean;\n error: Error | null;\n refresh: () => Promise<void>;\n}\n\n/**\n * Hook to fetch and display the active ad for a space\n *\n * @example\n * ```tsx\n * function AdDisplay({ spaceId }: { spaceId: number }) {\n * const { ad, isLoading, error } = useActiveAd(spaceId, {\n * refreshInterval: 30\n * });\n *\n * if (isLoading) return <div>Loading...</div>;\n * if (error) return <div>Error: {error.message}</div>;\n * if (!ad) return <div>No ad available</div>;\n *\n * return (\n * <a href={ad.advertiserSiteLink} target=\"_blank\">\n * <img src={ad.imageUrl} alt=\"Advertisement\" />\n * </a>\n * );\n * }\n * ```\n */\nexport function useActiveAd(\n spaceId: number,\n options: UseActiveAdOptions = {}\n): UseActiveAdResult {\n const client = useAdSpaceClient();\n const [ad, setAd] = useState<ActiveAd | null>(null);\n const [isLoading, setIsLoading] = useState(true);\n const [error, setError] = useState<Error | null>(null);\n const intervalRef = useRef<ReturnType<typeof setInterval>>();\n\n const { refreshInterval = 0, onLoad, onError, enabled = true } = options;\n\n const fetchAd = useCallback(async () => {\n if (!enabled) return;\n\n try {\n setIsLoading(true);\n setError(null);\n\n const activeAd = await client.getActiveAd(spaceId);\n setAd(activeAd);\n\n if (activeAd && onLoad) {\n onLoad(activeAd);\n }\n } catch (err) {\n const error = err instanceof Error ? err : new Error(String(err));\n setError(error);\n if (onError) {\n onError(error);\n }\n } finally {\n setIsLoading(false);\n }\n }, [client, spaceId, onLoad, onError, enabled]);\n\n // Initial fetch and polling setup\n useEffect(() => {\n fetchAd();\n\n if (refreshInterval > 0 && enabled) {\n intervalRef.current = setInterval(fetchAd, refreshInterval * 1000);\n }\n\n return () => {\n if (intervalRef.current) {\n clearInterval(intervalRef.current);\n }\n };\n }, [fetchAd, refreshInterval, enabled]);\n\n return {\n ad,\n isLoading,\n error,\n refresh: fetchAd,\n };\n}\n","import React, { CSSProperties } from 'react';\nimport { useActiveAd } from '../hooks/useActiveAd';\nimport { ActiveAd } from '../../core/types';\n\nexport interface AdWidgetProps {\n /** Space ID to display ads for */\n spaceId: number;\n /** Container width (CSS value) */\n width?: string;\n /** Container height (CSS value) */\n height?: string;\n /** Refresh interval in seconds (0 to disable) */\n refreshInterval?: number;\n /** Custom CSS class name */\n className?: string;\n /** Custom inline styles */\n style?: CSSProperties;\n /** Loading component */\n loadingComponent?: React.ReactNode;\n /** Error component */\n errorComponent?: React.ReactNode | ((error: Error) => React.ReactNode);\n /** Empty state component */\n emptyComponent?: React.ReactNode;\n /** Callback when ad loads */\n onLoad?: (ad: ActiveAd) => void;\n /** Callback on error */\n onError?: (error: Error) => void;\n /** Callback on ad click */\n onClick?: (ad: ActiveAd, event: React.MouseEvent) => void;\n}\n\n/**\n * Pre-built Ad Widget component\n *\n * @example\n * ```tsx\n * import { AdWidget } from '@adspace/sdk/react';\n *\n * function MyPage() {\n * return (\n * <AdWidget\n * spaceId={1}\n * width=\"300px\"\n * height=\"250px\"\n * refreshInterval={30}\n * />\n * );\n * }\n * ```\n */\nexport function AdWidget({\n spaceId,\n width = '100%',\n height = 'auto',\n refreshInterval = 30,\n className,\n style,\n loadingComponent,\n errorComponent,\n emptyComponent,\n onLoad,\n onError,\n onClick,\n}: AdWidgetProps) {\n const { ad, isLoading, error } = useActiveAd(spaceId, {\n refreshInterval,\n onLoad,\n onError,\n });\n\n const containerStyle: CSSProperties = {\n width,\n height,\n minHeight: height === 'auto' ? '100px' : height,\n overflow: 'hidden',\n position: 'relative',\n ...style,\n };\n\n const handleClick = (event: React.MouseEvent) => {\n if (ad && onClick) {\n onClick(ad, event);\n }\n };\n\n // Loading state\n if (isLoading && !ad) {\n return (\n <div className={className} style={containerStyle}>\n {loadingComponent || (\n <div\n style={{\n display: 'flex',\n alignItems: 'center',\n justifyContent: 'center',\n height: '100%',\n color: '#666',\n }}\n >\n Loading...\n </div>\n )}\n </div>\n );\n }\n\n // Error state\n if (error) {\n return (\n <div className={className} style={containerStyle}>\n {typeof errorComponent === 'function'\n ? errorComponent(error)\n : errorComponent || (\n <div\n style={{\n display: 'flex',\n alignItems: 'center',\n justifyContent: 'center',\n height: '100%',\n color: '#f00',\n }}\n >\n Failed to load ad\n </div>\n )}\n </div>\n );\n }\n\n // Empty state\n if (!ad) {\n return (\n <div className={className} style={containerStyle}>\n {emptyComponent || (\n <div\n style={{\n display: 'flex',\n alignItems: 'center',\n justifyContent: 'center',\n height: '100%',\n color: '#999',\n }}\n >\n No ad available\n </div>\n )}\n </div>\n );\n }\n\n // Ad display\n return (\n <div className={className} style={containerStyle}>\n <a\n href={ad.advertiserSiteLink || '#'}\n target=\"_blank\"\n rel=\"noopener noreferrer\"\n onClick={handleClick}\n style={{\n display: 'block',\n width: '100%',\n height: '100%',\n textDecoration: 'none',\n }}\n >\n <img\n src={ad.imageUrl}\n alt=\"Advertisement\"\n style={{\n width: '100%',\n height: 'auto',\n display: 'block',\n maxWidth: '100%',\n }}\n />\n </a>\n </div>\n );\n}\n"],"names":["AdSpaceContext","createContext","AdSpaceProvider","children","config","providedClient","client","useMemo","AdSpaceClient","value","jsx","useAdSpaceContext","context","useContext","useAdSpaceClient","useActiveAd","spaceId","options","ad","setAd","useState","isLoading","setIsLoading","error","setError","intervalRef","useRef","refreshInterval","onLoad","onError","enabled","fetchAd","useCallback","activeAd","err","useEffect","AdWidget","width","height","className","style","loadingComponent","errorComponent","emptyComponent","onClick","containerStyle","handleClick","event"],"mappings":"6KASMA,EAAiBC,EAAAA,cAA0C,IAAI,EAwB9D,SAASC,EAAgB,CAC9B,SAAAC,EACA,OAAAC,EAAS,CAAA,EACT,OAAQC,CACV,EAAyB,CACvB,MAAMC,EAASC,EAAAA,QACb,IAAMF,GAAkB,IAAIG,EAAAA,cAAcJ,CAAM,EAChD,CAACC,EAAgB,KAAK,UAAUD,CAAM,CAAC,CAAA,EAGnCK,EAAQF,EAAAA,QACZ,KAAO,CAAE,OAAAD,EAAQ,OAAQA,EAAO,WAAU,GAC1C,CAACA,CAAM,CAAA,EAGT,OACEI,EAAAA,IAACV,EAAe,SAAf,CAAwB,MAAAS,EACtB,SAAAN,CAAA,CACH,CAEJ,C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,eAAgB,MAAA,EAGlB,SAAApC,EAAAA,IAAC,MAAA,CACC,IAAKQ,EAAG,SACR,IAAI,gBACJ,MAAO,CACL,MAAO,OACP,OAAQ,OACR,QAAS,QACT,SAAU,MAAA,CACZ,CAAA,CACF,CAAA,EAEJ,EA5CER,EAAAA,IAAC,MAAA,CAAI,UAAA6B,EAAsB,MAAOM,EAC/B,SAAAF,GACCjC,EAAAA,IAAC,MAAA,CACC,MAAO,CACL,QAAS,OACT,WAAY,SACZ,eAAgB,SAChB,OAAQ,OACR,MAAO,MAAA,EAEV,SAAA,iBAAA,CAAA,EAIL,CAgCN"}
|
package/dist/react.d.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export * from './index';
|
|
2
|
+
export { AdSpaceProvider, useAdSpaceContext, useAdSpaceClient, } from './react/context';
|
|
3
|
+
export type { AdSpaceProviderProps } from './react/context';
|
|
4
|
+
export { useActiveAd } from './react/hooks';
|
|
5
|
+
export type { UseActiveAdOptions, UseActiveAdResult } from './react/hooks';
|
|
6
|
+
export { AdWidget } from './react/components';
|
|
7
|
+
export type { AdWidgetProps } from './react/components';
|
|
8
|
+
//# sourceMappingURL=react.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"react.d.ts","sourceRoot":"","sources":["../src/react.ts"],"names":[],"mappings":"AACA,cAAc,SAAS,CAAC;AAGxB,OAAO,EACL,eAAe,EACf,iBAAiB,EACjB,gBAAgB,GACjB,MAAM,iBAAiB,CAAC;AACzB,YAAY,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAC;AAE5D,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,YAAY,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAE3E,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAC9C,YAAY,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC"}
|