powered-ad-config 0.1.52 → 0.1.54
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 +32 -18
- package/dist/powered-ad-config.es.js +376 -356
- package/dist/powered-ad-config.umd.js +22 -10
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -32,27 +32,40 @@ In your fireplace project, you load from CDN first and fall back to npm import i
|
|
|
32
32
|
import poweredAdConfigNpm from 'powered-ad-config';
|
|
33
33
|
|
|
34
34
|
export async function loadAdConfig() {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
35
|
+
const expectedVersion = window.poweredAdConfigExpectedVersion || null;
|
|
36
|
+
const cdnUrl = new URL('https://cdn.jsdelivr.net/npm/powered-ad-config@latest/dist/powered-ad-config.umd.js');
|
|
37
|
+
|
|
38
|
+
cdnUrl.searchParams.set('v', expectedVersion || poweredAdConfigNpm.version || 'latest');
|
|
39
|
+
|
|
40
|
+
try {
|
|
41
|
+
await new Promise((resolve, reject) => {
|
|
42
|
+
const script = document.createElement('script');
|
|
43
|
+
// Intentionally using @latest so runtime always picks up newest published powered-ad-config release.
|
|
44
|
+
// Note: this can change behavior between deployments if a new version is published.
|
|
45
|
+
// The version query busts stale browser/ad-frame caches during validation.
|
|
46
|
+
script.src = cdnUrl.href;
|
|
47
|
+
script.onload = resolve;
|
|
48
|
+
script.onerror = reject;
|
|
49
|
+
document.head.appendChild(script);
|
|
50
|
+
});
|
|
50
51
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
console.
|
|
52
|
+
if (typeof window.poweredAdConfig === 'function') {
|
|
53
|
+
if (expectedVersion && window.poweredAdConfig.version !== expectedVersion) {
|
|
54
|
+
console.warn(
|
|
55
|
+
`[powered-ad-config] Stale CDN cache detected: loaded v${window.poweredAdConfig.version}, expected v${expectedVersion}. Falling back to bundled npm copy.`
|
|
56
|
+
);
|
|
54
57
|
return poweredAdConfigNpm;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
console.log(`CDN loaded successfully: v${window.poweredAdConfig.version || 'unknown'}`);
|
|
61
|
+
return window.poweredAdConfig;
|
|
55
62
|
}
|
|
63
|
+
|
|
64
|
+
throw new Error('poweredAdConfig global not available');
|
|
65
|
+
} catch (error) {
|
|
66
|
+
console.error('Failed to load from CDN, falling back to npm package:', error);
|
|
67
|
+
return poweredAdConfigNpm;
|
|
68
|
+
}
|
|
56
69
|
}
|
|
57
70
|
```
|
|
58
71
|
|
|
@@ -83,6 +96,7 @@ This pattern is useful when you want runtime fallback resilience while still bun
|
|
|
83
96
|
|
|
84
97
|
If you use `@latest`, runtime behavior can change between deployments as soon as a new package version is published.
|
|
85
98
|
If you need deterministic behavior, pin an explicit version in the CDN URL.
|
|
99
|
+
During QA, set `window.poweredAdConfigExpectedVersion = '0.1.53'` before calling `loadAdConfig()` or pin the exact package version so an already-cached ad iframe cannot silently keep executing an older `@latest` response.
|
|
86
100
|
|
|
87
101
|
## API
|
|
88
102
|
|