@thead-vantage/react 2.23.0 → 2.24.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@thead-vantage/react",
3
- "version": "2.23.0",
3
+ "version": "2.24.0",
4
4
  "description": "React components and utilities for TheAd Vantage ad platform integration",
5
5
  "main": "./src/index.ts",
6
6
  "module": "./src/index.ts",
@@ -253,14 +253,6 @@ export function AdBanner({
253
253
  height={ad.height || 250}
254
254
  className="rounded"
255
255
  unoptimized
256
- onError={(e) => {
257
- // If the logo fails to load (e.g., not in public folder when installed from npm),
258
- // try loading from CDN
259
- if (ad.id === 'thead-vantage-fallback' && ad.contentUrl === '/TheAd-Vantage-Logo.png') {
260
- const target = e.target as HTMLImageElement;
261
- target.src = 'https://www.thead-vantage.com/assets/TheAd-Vantage-Logo.png';
262
- }
263
- }}
264
256
  />
265
257
  ) : (
266
258
  <div className="flex items-center justify-center bg-gray-200 dark:bg-gray-700 rounded" style={{ width: ad.width || 300, height: ad.height || 250 }}>
@@ -3,28 +3,50 @@
3
3
  *
4
4
  * Provides fallback assets that work both in the library and when installed from npm.
5
5
  *
6
- * Note: When the library is installed from npm, the public folder isn't available.
7
- * The logo is loaded from a CDN URL that works in all environments.
6
+ * The logo is imported as a module so it gets bundled with the library.
7
+ * Next.js will process this import and create a URL that works in consuming applications.
8
8
  */
9
9
 
10
+ // Import the logo image - Next.js will process this and bundle it
11
+ // When the library is used in other Next.js apps, the image will be available
12
+ import theadVantageLogoSrc from '../assets/TheAd-Vantage-Logo.png';
13
+
10
14
  /**
11
15
  * Get the URL for the TheAd Vantage logo fallback ad
12
16
  *
13
- * Uses a CDN URL that works when the library is installed from npm.
14
- * For local development of the library itself, it will try the public folder first.
17
+ * Uses the imported image module. Next.js processes image imports and creates
18
+ * a URL that points to the bundled asset. This works when the library is installed
19
+ * from npm because the image is included in the library bundle.
15
20
  */
16
21
  export function getTheadVantageLogoUrl(): string {
17
- // Check if we're in the library's own development environment
18
- // (where the public folder exists)
19
- if (typeof window !== 'undefined') {
20
- // Try public folder first (works in library's own dev environment)
21
- // This will 404 when installed from npm, but that's okay - the Image component will handle it
22
- // and we can add error handling if needed
23
- return '/TheAd-Vantage-Logo.png';
22
+ // Next.js processes image imports and returns either:
23
+ // - A string URL (in some configurations)
24
+ // - An object with src, width, height properties (typical Next.js behavior)
25
+
26
+ if (typeof theadVantageLogoSrc === 'string') {
27
+ return theadVantageLogoSrc;
28
+ }
29
+
30
+ // Next.js Image import typically returns an object with src property
31
+ if (typeof theadVantageLogoSrc === 'object' && theadVantageLogoSrc !== null) {
32
+ // Check for src property (Next.js ImageStaticImport type)
33
+ if ('src' in theadVantageLogoSrc) {
34
+ return (theadVantageLogoSrc as { src: string }).src;
35
+ }
36
+ // Some bundlers might return the object directly with a default export
37
+ if ('default' in theadVantageLogoSrc) {
38
+ const defaultExport = (theadVantageLogoSrc as { default: string | { src: string } }).default;
39
+ if (typeof defaultExport === 'string') {
40
+ return defaultExport;
41
+ }
42
+ if (typeof defaultExport === 'object' && defaultExport !== null && 'src' in defaultExport) {
43
+ return (defaultExport as { src: string }).src;
44
+ }
45
+ }
24
46
  }
25
47
 
26
- // Server-side: return public folder path
27
- return '/TheAd-Vantage-Logo.png';
48
+ // Fallback to CDN if import doesn't work as expected
49
+ return 'https://www.thead-vantage.com/assets/TheAd-Vantage-Logo.png';
28
50
  }
29
51
 
30
52
  /**