novvy-ads-react-native 1.0.0-beta.1

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 (149) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +210 -0
  3. package/android/build.gradle +84 -0
  4. package/android/gradle.properties +4 -0
  5. package/android/src/main/AndroidManifest.xml +4 -0
  6. package/android/src/main/java/ai/novvy/reactnative/NovvyAdContainerView.kt +63 -0
  7. package/android/src/main/java/ai/novvy/reactnative/NovvyAdsModule.kt +390 -0
  8. package/android/src/main/java/ai/novvy/reactnative/NovvyAdsPackage.kt +46 -0
  9. package/android/src/main/java/ai/novvy/reactnative/NovvyPauseAdViewManager.kt +68 -0
  10. package/android/src/main/java/ai/novvy/reactnative/NovvyScrollAdViewManager.kt +72 -0
  11. package/android/src/main/java/ai/novvy/reactnative/RnPlayerAdapter.kt +18 -0
  12. package/android/src/main/java/ai/novvy/reactnative/ViewReadyEvent.kt +26 -0
  13. package/app.plugin.js +4 -0
  14. package/ios/NovvyAds.mm +168 -0
  15. package/ios/NovvyAdsImpl.swift +409 -0
  16. package/ios/NovvyPauseAdView.mm +79 -0
  17. package/ios/NovvyScrollAdView.mm +80 -0
  18. package/ios/RnPlayerAdapter.swift +14 -0
  19. package/lib/commonjs/NovvyAds.js +87 -0
  20. package/lib/commonjs/NovvyAds.js.map +1 -0
  21. package/lib/commonjs/ads/NovvyAd.js +121 -0
  22. package/lib/commonjs/ads/NovvyAd.js.map +1 -0
  23. package/lib/commonjs/ads/NovvyEndAd.js +19 -0
  24. package/lib/commonjs/ads/NovvyEndAd.js.map +1 -0
  25. package/lib/commonjs/ads/NovvyFullScreenAd.js +49 -0
  26. package/lib/commonjs/ads/NovvyFullScreenAd.js.map +1 -0
  27. package/lib/commonjs/ads/NovvyInterstitialAd.js +19 -0
  28. package/lib/commonjs/ads/NovvyInterstitialAd.js.map +1 -0
  29. package/lib/commonjs/ads/NovvyMidAd.js +19 -0
  30. package/lib/commonjs/ads/NovvyMidAd.js.map +1 -0
  31. package/lib/commonjs/ads/NovvyPauseAd.js +116 -0
  32. package/lib/commonjs/ads/NovvyPauseAd.js.map +1 -0
  33. package/lib/commonjs/ads/NovvyRewardedAd.js +53 -0
  34. package/lib/commonjs/ads/NovvyRewardedAd.js.map +1 -0
  35. package/lib/commonjs/ads/NovvyScrollAd.js +136 -0
  36. package/lib/commonjs/ads/NovvyScrollAd.js.map +1 -0
  37. package/lib/commonjs/eventBus.js +60 -0
  38. package/lib/commonjs/eventBus.js.map +1 -0
  39. package/lib/commonjs/index.js +90 -0
  40. package/lib/commonjs/index.js.map +1 -0
  41. package/lib/commonjs/package.json +1 -0
  42. package/lib/commonjs/spec/NativeNovvyAds.js +27 -0
  43. package/lib/commonjs/spec/NativeNovvyAds.js.map +1 -0
  44. package/lib/commonjs/spec/NovvyPauseAdViewNativeComponent.js +16 -0
  45. package/lib/commonjs/spec/NovvyPauseAdViewNativeComponent.js.map +1 -0
  46. package/lib/commonjs/spec/NovvyScrollAdViewNativeComponent.js +17 -0
  47. package/lib/commonjs/spec/NovvyScrollAdViewNativeComponent.js.map +1 -0
  48. package/lib/commonjs/spec/codegen-event-emitter.d.js +2 -0
  49. package/lib/commonjs/spec/codegen-event-emitter.d.js.map +1 -0
  50. package/lib/commonjs/types.js +54 -0
  51. package/lib/commonjs/types.js.map +1 -0
  52. package/lib/commonjs/views/NovvyPauseAdView.js +76 -0
  53. package/lib/commonjs/views/NovvyPauseAdView.js.map +1 -0
  54. package/lib/commonjs/views/NovvyScrollAdView.js +63 -0
  55. package/lib/commonjs/views/NovvyScrollAdView.js.map +1 -0
  56. package/lib/module/NovvyAds.js +83 -0
  57. package/lib/module/NovvyAds.js.map +1 -0
  58. package/lib/module/ads/NovvyAd.js +117 -0
  59. package/lib/module/ads/NovvyAd.js.map +1 -0
  60. package/lib/module/ads/NovvyEndAd.js +15 -0
  61. package/lib/module/ads/NovvyEndAd.js.map +1 -0
  62. package/lib/module/ads/NovvyFullScreenAd.js +45 -0
  63. package/lib/module/ads/NovvyFullScreenAd.js.map +1 -0
  64. package/lib/module/ads/NovvyInterstitialAd.js +15 -0
  65. package/lib/module/ads/NovvyInterstitialAd.js.map +1 -0
  66. package/lib/module/ads/NovvyMidAd.js +15 -0
  67. package/lib/module/ads/NovvyMidAd.js.map +1 -0
  68. package/lib/module/ads/NovvyPauseAd.js +112 -0
  69. package/lib/module/ads/NovvyPauseAd.js.map +1 -0
  70. package/lib/module/ads/NovvyRewardedAd.js +49 -0
  71. package/lib/module/ads/NovvyRewardedAd.js.map +1 -0
  72. package/lib/module/ads/NovvyScrollAd.js +132 -0
  73. package/lib/module/ads/NovvyScrollAd.js.map +1 -0
  74. package/lib/module/eventBus.js +55 -0
  75. package/lib/module/eventBus.js.map +1 -0
  76. package/lib/module/index.js +22 -0
  77. package/lib/module/index.js.map +1 -0
  78. package/lib/module/package.json +1 -0
  79. package/lib/module/spec/NativeNovvyAds.js +28 -0
  80. package/lib/module/spec/NativeNovvyAds.js.map +1 -0
  81. package/lib/module/spec/NovvyPauseAdViewNativeComponent.js +13 -0
  82. package/lib/module/spec/NovvyPauseAdViewNativeComponent.js.map +1 -0
  83. package/lib/module/spec/NovvyScrollAdViewNativeComponent.js +14 -0
  84. package/lib/module/spec/NovvyScrollAdViewNativeComponent.js.map +1 -0
  85. package/lib/module/spec/codegen-event-emitter.d.js +2 -0
  86. package/lib/module/spec/codegen-event-emitter.d.js.map +1 -0
  87. package/lib/module/types.js +56 -0
  88. package/lib/module/types.js.map +1 -0
  89. package/lib/module/views/NovvyPauseAdView.js +70 -0
  90. package/lib/module/views/NovvyPauseAdView.js.map +1 -0
  91. package/lib/module/views/NovvyScrollAdView.js +57 -0
  92. package/lib/module/views/NovvyScrollAdView.js.map +1 -0
  93. package/lib/typescript/NovvyAds.d.ts +69 -0
  94. package/lib/typescript/NovvyAds.d.ts.map +1 -0
  95. package/lib/typescript/ads/NovvyAd.d.ts +57 -0
  96. package/lib/typescript/ads/NovvyAd.d.ts.map +1 -0
  97. package/lib/typescript/ads/NovvyEndAd.d.ts +7 -0
  98. package/lib/typescript/ads/NovvyEndAd.d.ts.map +1 -0
  99. package/lib/typescript/ads/NovvyFullScreenAd.d.ts +19 -0
  100. package/lib/typescript/ads/NovvyFullScreenAd.d.ts.map +1 -0
  101. package/lib/typescript/ads/NovvyInterstitialAd.d.ts +7 -0
  102. package/lib/typescript/ads/NovvyInterstitialAd.d.ts.map +1 -0
  103. package/lib/typescript/ads/NovvyMidAd.d.ts +7 -0
  104. package/lib/typescript/ads/NovvyMidAd.d.ts.map +1 -0
  105. package/lib/typescript/ads/NovvyPauseAd.d.ts +45 -0
  106. package/lib/typescript/ads/NovvyPauseAd.d.ts.map +1 -0
  107. package/lib/typescript/ads/NovvyRewardedAd.d.ts +19 -0
  108. package/lib/typescript/ads/NovvyRewardedAd.d.ts.map +1 -0
  109. package/lib/typescript/ads/NovvyScrollAd.d.ts +57 -0
  110. package/lib/typescript/ads/NovvyScrollAd.d.ts.map +1 -0
  111. package/lib/typescript/eventBus.d.ts +15 -0
  112. package/lib/typescript/eventBus.d.ts.map +1 -0
  113. package/lib/typescript/index.d.ts +15 -0
  114. package/lib/typescript/index.d.ts.map +1 -0
  115. package/lib/typescript/spec/NativeNovvyAds.d.ts +73 -0
  116. package/lib/typescript/spec/NativeNovvyAds.d.ts.map +1 -0
  117. package/lib/typescript/spec/NovvyPauseAdViewNativeComponent.d.ts +18 -0
  118. package/lib/typescript/spec/NovvyPauseAdViewNativeComponent.d.ts.map +1 -0
  119. package/lib/typescript/spec/NovvyScrollAdViewNativeComponent.d.ts +19 -0
  120. package/lib/typescript/spec/NovvyScrollAdViewNativeComponent.d.ts.map +1 -0
  121. package/lib/typescript/types.d.ts +77 -0
  122. package/lib/typescript/types.d.ts.map +1 -0
  123. package/lib/typescript/views/NovvyPauseAdView.d.ts +21 -0
  124. package/lib/typescript/views/NovvyPauseAdView.d.ts.map +1 -0
  125. package/lib/typescript/views/NovvyScrollAdView.d.ts +22 -0
  126. package/lib/typescript/views/NovvyScrollAdView.d.ts.map +1 -0
  127. package/novvy-ads-react-native.podspec +71 -0
  128. package/package.json +84 -0
  129. package/plugin/build/index.d.ts +11 -0
  130. package/plugin/build/index.js +53 -0
  131. package/react-native.config.js +7 -0
  132. package/src/NovvyAds.ts +98 -0
  133. package/src/ads/NovvyAd.ts +125 -0
  134. package/src/ads/NovvyEndAd.ts +13 -0
  135. package/src/ads/NovvyFullScreenAd.ts +46 -0
  136. package/src/ads/NovvyInterstitialAd.ts +13 -0
  137. package/src/ads/NovvyMidAd.ts +13 -0
  138. package/src/ads/NovvyPauseAd.ts +125 -0
  139. package/src/ads/NovvyRewardedAd.ts +49 -0
  140. package/src/ads/NovvyScrollAd.ts +138 -0
  141. package/src/eventBus.ts +59 -0
  142. package/src/index.tsx +29 -0
  143. package/src/spec/NativeNovvyAds.ts +134 -0
  144. package/src/spec/NovvyPauseAdViewNativeComponent.ts +20 -0
  145. package/src/spec/NovvyScrollAdViewNativeComponent.ts +21 -0
  146. package/src/spec/codegen-event-emitter.d.ts +10 -0
  147. package/src/types.ts +82 -0
  148. package/src/views/NovvyPauseAdView.tsx +80 -0
  149. package/src/views/NovvyScrollAdView.tsx +71 -0
@@ -0,0 +1,83 @@
1
+ "use strict";
2
+
3
+ import { sha256 } from 'js-sha256';
4
+ import { Native } from './eventBus';
5
+ /**
6
+ * SDK entry point for Novvy Ads.
7
+ *
8
+ * A **thin** surface — it only wraps the native SDK's top-level entry (init +
9
+ * user/content context + email hashing). Ads themselves are created and driven
10
+ * directly through their classes ({@link NovvyInterstitialAd},
11
+ * {@link NovvyRewardedAd}, {@link NovvyMidAd}, {@link NovvyEndAd},
12
+ * {@link NovvyScrollAd}, {@link NovvyPauseAd}); the host owns each instance and
13
+ * wires its per-ad callbacks. Mirrors the Flutter plugin's `NovvyAds`.
14
+ *
15
+ * ```ts
16
+ * // 1. Initialize once at app startup (optionally with a user profile).
17
+ * const ok = await NovvyAds.initialize({
18
+ * appId: '...', endpoint: '...', apiKey: '...',
19
+ * userContext: { userId: '...', isPaidUser: true },
20
+ * });
21
+ *
22
+ * // 2. Set / refresh content context (and user profile if not set above).
23
+ * NovvyAds.setContentContext({ seriesName: '...', episodeNumber: 1 });
24
+ *
25
+ * // 3. Create an ad, wire callbacks, load & show.
26
+ * const ad = new NovvyRewardedAd('...');
27
+ * let earned = false;
28
+ * ad.onAdLoaded = () => ad.show();
29
+ * ad.onUserEarnedReward = () => { earned = true; };
30
+ * ad.onAdDismissed = () => { if (earned) grantReward(); };
31
+ * ad.onAdFailedToLoad = () => {};
32
+ * ad.load();
33
+ * ```
34
+ */
35
+ export const NovvyAds = {
36
+ /**
37
+ * Initialize the Novvy SDK. Must be called before creating any ads.
38
+ *
39
+ * Resolves with the native init-complete signal — `true` on success, `false`
40
+ * if initialization failed. May be called again (e.g. after login/logout);
41
+ * the native SDK handles re-initialization idempotently.
42
+ *
43
+ * @param userContext optional user-targeting context applied at init time
44
+ * (equivalent to calling {@link setUserContext} right after).
45
+ */
46
+ async initialize(options) {
47
+ try {
48
+ return await Native.initialize(options.appId, options.endpoint, options.apiKey, options.userContext ?? null);
49
+ } catch {
50
+ return false;
51
+ }
52
+ },
53
+ /**
54
+ * Hashes an email address using SHA-256 for privacy compliance. Use before
55
+ * passing an email to {@link NovvyUserContext.hashedEmail}. Pure JS — mirrors
56
+ * the native SDK's `helperHashEmail()`.
57
+ */
58
+ helperHashEmail(email) {
59
+ return sha256(email.trim().toLowerCase());
60
+ },
61
+ /** Replaces the entire user context (null fields clear existing values). */
62
+ setUserContext(context) {
63
+ Native.setUserContext(context);
64
+ },
65
+ /** Incrementally merges user context fields (null fields preserve existing values). */
66
+ updateUserContext(partial) {
67
+ Native.updateUserContext(partial);
68
+ },
69
+ /**
70
+ * Replaces the entire content context (null fields clear existing values).
71
+ *
72
+ * Call before each `load()` / `attach()` in drama scenarios — the backend
73
+ * needs the current series/episode or it returns no fill.
74
+ */
75
+ setContentContext(context) {
76
+ Native.setContentContext(context);
77
+ },
78
+ /** Incrementally merges content context fields (null fields preserve existing values). */
79
+ updateContentContext(partial) {
80
+ Native.updateContentContext(partial);
81
+ }
82
+ };
83
+ //# sourceMappingURL=NovvyAds.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["sha256","Native","NovvyAds","initialize","options","appId","endpoint","apiKey","userContext","helperHashEmail","email","trim","toLowerCase","setUserContext","context","updateUserContext","partial","setContentContext","updateContentContext"],"sourceRoot":"../../src","sources":["NovvyAds.ts"],"mappings":";;AAAA,SAASA,MAAM,QAAQ,WAAW;AAElC,SAASC,MAAM,QAAQ,YAAY;AAGnC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,QAAQ,GAAG;EACtB;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;EACE,MAAMC,UAAUA,CAACC,OAKhB,EAAoB;IACnB,IAAI;MACF,OAAO,MAAMH,MAAM,CAACE,UAAU,CAC5BC,OAAO,CAACC,KAAK,EACbD,OAAO,CAACE,QAAQ,EAChBF,OAAO,CAACG,MAAM,EACdH,OAAO,CAACI,WAAW,IAAI,IACzB,CAAC;IACH,CAAC,CAAC,MAAM;MACN,OAAO,KAAK;IACd;EACF,CAAC;EAED;AACF;AACA;AACA;AACA;EACEC,eAAeA,CAACC,KAAa,EAAU;IACrC,OAAOV,MAAM,CAACU,KAAK,CAACC,IAAI,CAAC,CAAC,CAACC,WAAW,CAAC,CAAC,CAAC;EAC3C,CAAC;EAED;EACAC,cAAcA,CAACC,OAAyB,EAAQ;IAC9Cb,MAAM,CAACY,cAAc,CAACC,OAAO,CAAC;EAChC,CAAC;EAED;EACAC,iBAAiBA,CAACC,OAAyB,EAAQ;IACjDf,MAAM,CAACc,iBAAiB,CAACC,OAAO,CAAC;EACnC,CAAC;EAED;AACF;AACA;AACA;AACA;AACA;EACEC,iBAAiBA,CAACH,OAA4B,EAAQ;IACpDb,MAAM,CAACgB,iBAAiB,CAACH,OAAO,CAAC;EACnC,CAAC;EAED;EACAI,oBAAoBA,CAACF,OAA4B,EAAQ;IACvDf,MAAM,CAACiB,oBAAoB,CAACF,OAAO,CAAC;EACtC;AACF,CAAC","ignoreList":[]}
@@ -0,0 +1,117 @@
1
+ "use strict";
2
+
3
+ import { Native, subscribe } from '../eventBus';
4
+ import { NovvyAdEvent } from '../types';
5
+
6
+ /**
7
+ * Base class for all Novvy ad types.
8
+ *
9
+ * Mirrors the Flutter plugin's `NovvyAd` (lib/novvy_ads_plugin.dart).
10
+ * Instances are owned by the host: keep a reference alive until the ad
11
+ * completes (`onAdDismissed` / `onAdHidden`) and then call {@link destroy}.
12
+ */
13
+ export class NovvyAd {
14
+ _isReady = false;
15
+ _disposed = false;
16
+ _unsubscribe = null;
17
+
18
+ /** Called when the ad has loaded successfully. */
19
+
20
+ /** Called when the ad fails to load / request. */
21
+
22
+ constructor(adUnitId) {
23
+ this.adUnitId = adUnitId;
24
+ this._adObjectId = NovvyAd._generateUniqueId();
25
+ }
26
+
27
+ /** The unique object ID for this ad instance. */
28
+ get adObjectId() {
29
+ return this._adObjectId;
30
+ }
31
+
32
+ /** Whether the ad is loaded and ready to show. */
33
+ get isReady() {
34
+ return this._isReady;
35
+ }
36
+
37
+ /**
38
+ * Subscribes to this ad's native event stream (filtered by object ID).
39
+ * Idempotent.
40
+ */
41
+ _subscribe() {
42
+ if (this._unsubscribe) {
43
+ return;
44
+ }
45
+ this._unsubscribe = subscribe(this._adObjectId, event => this._handleInternalEvent(event));
46
+ }
47
+
48
+ /**
49
+ * Loads the ad. Not used by {@link NovvyPauseAd} (realtime, no load step).
50
+ *
51
+ * Callback-driven: the outcome is delivered via {@link onAdLoaded} /
52
+ * {@link onAdFailedToLoad}.
53
+ */
54
+ load() {
55
+ if (this._isReady || this._disposed) {
56
+ return;
57
+ }
58
+ this._subscribe();
59
+ try {
60
+ this._loadNative();
61
+ } catch (e) {
62
+ this.onAdFailedToLoad?.(String(e));
63
+ this.destroy();
64
+ }
65
+ }
66
+
67
+ /** Releases the ad resources. Idempotent. */
68
+ destroy() {
69
+ if (this._disposed) {
70
+ return;
71
+ }
72
+ this._disposed = true;
73
+ this._unsubscribe?.();
74
+ this._unsubscribe = null;
75
+ Native.disposeAd(this._adObjectId);
76
+ }
77
+
78
+ // Abstract members
79
+
80
+ /**
81
+ * Shared handling of the common load / fail transitions.
82
+ * Returns true if the event was consumed here.
83
+ */
84
+ _handleCommonLoad(event) {
85
+ switch (event.event) {
86
+ case NovvyAdEvent.Loaded:
87
+ this._isReady = true;
88
+ this.onAdLoaded?.();
89
+ return true;
90
+ case NovvyAdEvent.FailedToLoad:
91
+ this._isReady = false;
92
+ this.onAdFailedToLoad?.(event.error ?? 'Unknown error');
93
+ this.destroy();
94
+ return true;
95
+ default:
96
+ return false;
97
+ }
98
+ }
99
+
100
+ /**
101
+ * Monotonically increasing per-process counter guaranteeing `adObjectId`
102
+ * uniqueness even when many ads are constructed within the same millisecond
103
+ * (e.g. batch-preloading feed items in a synchronous loop). `Date.now()` has
104
+ * only millisecond resolution, so timestamp + random alone left a real
105
+ * (~1/10000 per pair) collision window; a colliding id would cross-wire two
106
+ * ads' event streams. The counter closes that window; the timestamp/random
107
+ * still disambiguate ids across separate app launches.
108
+ */
109
+ static _counter = 0;
110
+ static _generateUniqueId() {
111
+ const timestamp = Date.now();
112
+ const random = Math.floor(Math.random() * 10000);
113
+ const seq = NovvyAd._counter++;
114
+ return `ad_${timestamp}_${random}_${seq}`;
115
+ }
116
+ }
117
+ //# sourceMappingURL=NovvyAd.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["Native","subscribe","NovvyAdEvent","NovvyAd","_isReady","_disposed","_unsubscribe","constructor","adUnitId","_adObjectId","_generateUniqueId","adObjectId","isReady","_subscribe","event","_handleInternalEvent","load","_loadNative","e","onAdFailedToLoad","String","destroy","disposeAd","_handleCommonLoad","Loaded","onAdLoaded","FailedToLoad","error","_counter","timestamp","Date","now","random","Math","floor","seq"],"sourceRoot":"../../../src","sources":["ads/NovvyAd.ts"],"mappings":";;AAAA,SAASA,MAAM,EAAEC,SAAS,QAAQ,aAAa;AAE/C,SAASC,YAAY,QAAQ,UAAU;;AAEvC;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAeC,OAAO,CAAC;EAIlBC,QAAQ,GAAG,KAAK;EAChBC,SAAS,GAAG,KAAK;EAEnBC,YAAY,GAAwB,IAAI;;EAEhD;;EAEA;;EAGAC,WAAWA,CAACC,QAAgB,EAAE;IAC5B,IAAI,CAACA,QAAQ,GAAGA,QAAQ;IACxB,IAAI,CAACC,WAAW,GAAGN,OAAO,CAACO,iBAAiB,CAAC,CAAC;EAChD;;EAEA;EACA,IAAIC,UAAUA,CAAA,EAAW;IACvB,OAAO,IAAI,CAACF,WAAW;EACzB;;EAEA;EACA,IAAIG,OAAOA,CAAA,EAAY;IACrB,OAAO,IAAI,CAACR,QAAQ;EACtB;;EAEA;AACF;AACA;AACA;EACYS,UAAUA,CAAA,EAAS;IAC3B,IAAI,IAAI,CAACP,YAAY,EAAE;MACrB;IACF;IACA,IAAI,CAACA,YAAY,GAAGL,SAAS,CAAC,IAAI,CAACQ,WAAW,EAAGK,KAAK,IACpD,IAAI,CAACC,oBAAoB,CAACD,KAAK,CACjC,CAAC;EACH;;EAEA;AACF;AACA;AACA;AACA;AACA;EACEE,IAAIA,CAAA,EAAS;IACX,IAAI,IAAI,CAACZ,QAAQ,IAAI,IAAI,CAACC,SAAS,EAAE;MACnC;IACF;IACA,IAAI,CAACQ,UAAU,CAAC,CAAC;IACjB,IAAI;MACF,IAAI,CAACI,WAAW,CAAC,CAAC;IACpB,CAAC,CAAC,OAAOC,CAAC,EAAE;MACV,IAAI,CAACC,gBAAgB,GAAGC,MAAM,CAACF,CAAC,CAAC,CAAC;MAClC,IAAI,CAACG,OAAO,CAAC,CAAC;IAChB;EACF;;EAEA;EACAA,OAAOA,CAAA,EAAS;IACd,IAAI,IAAI,CAAChB,SAAS,EAAE;MAClB;IACF;IACA,IAAI,CAACA,SAAS,GAAG,IAAI;IACrB,IAAI,CAACC,YAAY,GAAG,CAAC;IACrB,IAAI,CAACA,YAAY,GAAG,IAAI;IACxBN,MAAM,CAACsB,SAAS,CAAC,IAAI,CAACb,WAAW,CAAC;EACpC;;EAEA;;EAIA;AACF;AACA;AACA;EACYc,iBAAiBA,CAACT,KAAoB,EAAW;IACzD,QAAQA,KAAK,CAACA,KAAK;MACjB,KAAKZ,YAAY,CAACsB,MAAM;QACtB,IAAI,CAACpB,QAAQ,GAAG,IAAI;QACpB,IAAI,CAACqB,UAAU,GAAG,CAAC;QACnB,OAAO,IAAI;MACb,KAAKvB,YAAY,CAACwB,YAAY;QAC5B,IAAI,CAACtB,QAAQ,GAAG,KAAK;QACrB,IAAI,CAACe,gBAAgB,GAAGL,KAAK,CAACa,KAAK,IAAI,eAAe,CAAC;QACvD,IAAI,CAACN,OAAO,CAAC,CAAC;QACd,OAAO,IAAI;MACb;QACE,OAAO,KAAK;IAChB;EACF;;EAEA;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;EACE,OAAeO,QAAQ,GAAG,CAAC;EAE3B,OAAelB,iBAAiBA,CAAA,EAAW;IACzC,MAAMmB,SAAS,GAAGC,IAAI,CAACC,GAAG,CAAC,CAAC;IAC5B,MAAMC,MAAM,GAAGC,IAAI,CAACC,KAAK,CAACD,IAAI,CAACD,MAAM,CAAC,CAAC,GAAG,KAAK,CAAC;IAChD,MAAMG,GAAG,GAAGhC,OAAO,CAACyB,QAAQ,EAAE;IAC9B,OAAO,MAAMC,SAAS,IAAIG,MAAM,IAAIG,GAAG,EAAE;EAC3C;AACF","ignoreList":[]}
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+
3
+ import { NovvyFullScreenAd } from './NovvyFullScreenAd';
4
+
5
+ /** An end-roll (full-screen) ad, shown after an episode finishes. */
6
+ export class NovvyEndAd extends NovvyFullScreenAd {
7
+ _loadNative() {
8
+ this.native.loadEndAd(this.adUnitId, this.adObjectId);
9
+ }
10
+ show() {
11
+ this._assertReady();
12
+ this.native.showEndAd(this.adObjectId);
13
+ }
14
+ }
15
+ //# sourceMappingURL=NovvyEndAd.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["NovvyFullScreenAd","NovvyEndAd","_loadNative","native","loadEndAd","adUnitId","adObjectId","show","_assertReady","showEndAd"],"sourceRoot":"../../../src","sources":["ads/NovvyEndAd.ts"],"mappings":";;AAAA,SAASA,iBAAiB,QAAQ,qBAAqB;;AAEvD;AACA,OAAO,MAAMC,UAAU,SAASD,iBAAiB,CAAC;EACtCE,WAAWA,CAAA,EAAS;IAC5B,IAAI,CAACC,MAAM,CAACC,SAAS,CAAC,IAAI,CAACC,QAAQ,EAAE,IAAI,CAACC,UAAU,CAAC;EACvD;EAEAC,IAAIA,CAAA,EAAS;IACX,IAAI,CAACC,YAAY,CAAC,CAAC;IACnB,IAAI,CAACL,MAAM,CAACM,SAAS,CAAC,IAAI,CAACH,UAAU,CAAC;EACxC;AACF","ignoreList":[]}
@@ -0,0 +1,45 @@
1
+ "use strict";
2
+
3
+ import { Native } from '../eventBus';
4
+ import { NovvyAdEvent } from '../types';
5
+ import { NovvyAd } from './NovvyAd';
6
+
7
+ /**
8
+ * Base for full-screen ads that follow load → show → dismissed.
9
+ * Mirrors the Flutter plugin's `_NovvyFullScreenAd`.
10
+ */
11
+ export class NovvyFullScreenAd extends NovvyAd {
12
+ /** Called when the ad is displayed. */
13
+
14
+ /** Called when the ad is dismissed (closed) by the user. */
15
+
16
+ /** Shows the ad. Must be called after it has loaded. */
17
+
18
+ _handleInternalEvent(event) {
19
+ if (this._handleCommonLoad(event)) {
20
+ return;
21
+ }
22
+ switch (event.event) {
23
+ case NovvyAdEvent.Showed:
24
+ this.onAdShowed?.();
25
+ break;
26
+ case NovvyAdEvent.Dismissed:
27
+ this.onAdDismissed?.();
28
+ this.destroy();
29
+ break;
30
+ default:
31
+ break;
32
+ }
33
+ }
34
+ _assertReady() {
35
+ if (!this._isReady) {
36
+ throw new Error('Ad must be loaded before showing.');
37
+ }
38
+ }
39
+
40
+ /** Uses the module accessor in subclasses. */
41
+ get native() {
42
+ return Native;
43
+ }
44
+ }
45
+ //# sourceMappingURL=NovvyFullScreenAd.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["Native","NovvyAdEvent","NovvyAd","NovvyFullScreenAd","_handleInternalEvent","event","_handleCommonLoad","Showed","onAdShowed","Dismissed","onAdDismissed","destroy","_assertReady","_isReady","Error","native"],"sourceRoot":"../../../src","sources":["ads/NovvyFullScreenAd.ts"],"mappings":";;AAAA,SAASA,MAAM,QAAQ,aAAa;AAEpC,SAASC,YAAY,QAAQ,UAAU;AACvC,SAASC,OAAO,QAAQ,WAAW;;AAEnC;AACA;AACA;AACA;AACA,OAAO,MAAeC,iBAAiB,SAASD,OAAO,CAAC;EACtD;;EAEA;;EAGA;;EAGUE,oBAAoBA,CAACC,KAAoB,EAAQ;IACzD,IAAI,IAAI,CAACC,iBAAiB,CAACD,KAAK,CAAC,EAAE;MACjC;IACF;IACA,QAAQA,KAAK,CAACA,KAAK;MACjB,KAAKJ,YAAY,CAACM,MAAM;QACtB,IAAI,CAACC,UAAU,GAAG,CAAC;QACnB;MACF,KAAKP,YAAY,CAACQ,SAAS;QACzB,IAAI,CAACC,aAAa,GAAG,CAAC;QACtB,IAAI,CAACC,OAAO,CAAC,CAAC;QACd;MACF;QACE;IACJ;EACF;EAEUC,YAAYA,CAAA,EAAS;IAC7B,IAAI,CAAC,IAAI,CAACC,QAAQ,EAAE;MAClB,MAAM,IAAIC,KAAK,CAAC,mCAAmC,CAAC;IACtD;EACF;;EAEA;EACA,IAAcC,MAAMA,CAAA,EAAG;IACrB,OAAOf,MAAM;EACf;AACF","ignoreList":[]}
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+
3
+ import { NovvyFullScreenAd } from './NovvyFullScreenAd';
4
+
5
+ /** An interstitial (full-screen) ad. */
6
+ export class NovvyInterstitialAd extends NovvyFullScreenAd {
7
+ _loadNative() {
8
+ this.native.loadInterstitialAd(this.adUnitId, this.adObjectId);
9
+ }
10
+ show() {
11
+ this._assertReady();
12
+ this.native.showInterstitialAd(this.adObjectId);
13
+ }
14
+ }
15
+ //# sourceMappingURL=NovvyInterstitialAd.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["NovvyFullScreenAd","NovvyInterstitialAd","_loadNative","native","loadInterstitialAd","adUnitId","adObjectId","show","_assertReady","showInterstitialAd"],"sourceRoot":"../../../src","sources":["ads/NovvyInterstitialAd.ts"],"mappings":";;AAAA,SAASA,iBAAiB,QAAQ,qBAAqB;;AAEvD;AACA,OAAO,MAAMC,mBAAmB,SAASD,iBAAiB,CAAC;EAC/CE,WAAWA,CAAA,EAAS;IAC5B,IAAI,CAACC,MAAM,CAACC,kBAAkB,CAAC,IAAI,CAACC,QAAQ,EAAE,IAAI,CAACC,UAAU,CAAC;EAChE;EAEAC,IAAIA,CAAA,EAAS;IACX,IAAI,CAACC,YAAY,CAAC,CAAC;IACnB,IAAI,CAACL,MAAM,CAACM,kBAAkB,CAAC,IAAI,CAACH,UAAU,CAAC;EACjD;AACF","ignoreList":[]}
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+
3
+ import { NovvyFullScreenAd } from './NovvyFullScreenAd';
4
+
5
+ /** A mid-roll (full-screen) ad, shown at an in-episode break. */
6
+ export class NovvyMidAd extends NovvyFullScreenAd {
7
+ _loadNative() {
8
+ this.native.loadMidAd(this.adUnitId, this.adObjectId);
9
+ }
10
+ show() {
11
+ this._assertReady();
12
+ this.native.showMidAd(this.adObjectId);
13
+ }
14
+ }
15
+ //# sourceMappingURL=NovvyMidAd.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["NovvyFullScreenAd","NovvyMidAd","_loadNative","native","loadMidAd","adUnitId","adObjectId","show","_assertReady","showMidAd"],"sourceRoot":"../../../src","sources":["ads/NovvyMidAd.ts"],"mappings":";;AAAA,SAASA,iBAAiB,QAAQ,qBAAqB;;AAEvD;AACA,OAAO,MAAMC,UAAU,SAASD,iBAAiB,CAAC;EACtCE,WAAWA,CAAA,EAAS;IAC5B,IAAI,CAACC,MAAM,CAACC,SAAS,CAAC,IAAI,CAACC,QAAQ,EAAE,IAAI,CAACC,UAAU,CAAC;EACvD;EAEAC,IAAIA,CAAA,EAAS;IACX,IAAI,CAACC,YAAY,CAAC,CAAC;IACnB,IAAI,CAACL,MAAM,CAACM,SAAS,CAAC,IAAI,CAACH,UAAU,CAAC;EACxC;AACF","ignoreList":[]}
@@ -0,0 +1,112 @@
1
+ "use strict";
2
+
3
+ import { Native } from '../eventBus';
4
+ import { NovvyAdEvent } from '../types';
5
+ import { NovvyAd } from './NovvyAd';
6
+
7
+ /** Interval at which player state is pushed to native (mirrors Flutter's 500ms Timer). */
8
+ const PLAYER_PUSH_INTERVAL_MS = 500;
9
+
10
+ /**
11
+ * A realtime pause card (fixed 260×90) shown while the player is paused.
12
+ *
13
+ * Unlike other ads there is **no** {@link load} step: embedding
14
+ * `<NovvyPauseAdView>` issues the request immediately via {@link attach}.
15
+ * Show it the moment playback is paused and {@link destroy} on resume
16
+ * ({@link onAdHidden}). Mirrors the Flutter plugin's `NovvyPauseAd`.
17
+ */
18
+ export class NovvyPauseAd extends NovvyAd {
19
+ /** The Fabric component name used by `<NovvyPauseAdView>`. */
20
+ static viewType = 'NovvyPauseAdView';
21
+ /** Pause card width in logical pixels (matches native SDK). */
22
+ static cardWidth = 260;
23
+ /** Pause card height in logical pixels (matches native SDK). */
24
+ static cardHeight = 90;
25
+
26
+ /** Called when the pause card is shown. */
27
+
28
+ /** Called when the card is hidden (playback resumed). */
29
+
30
+ /**
31
+ * Called when the native card's shown state changes, so a view can toggle
32
+ * touch passthrough / opacity (mirrors Flutter's `shownNotifier`).
33
+ */
34
+
35
+ _player = null;
36
+ _timer = null;
37
+ _loadNative() {
38
+ throw new Error('NovvyPauseAd has no load step; use attach().');
39
+ }
40
+
41
+ /**
42
+ * Attach the pause ad and issue the request in realtime.
43
+ *
44
+ * The player's current state is read once and sent with the request; a
45
+ * 500ms timer then keeps pushing state so the SDK can detect resumption.
46
+ */
47
+ attach(player) {
48
+ if (this._disposed) {
49
+ return;
50
+ }
51
+ this._player = player;
52
+ this._subscribe();
53
+ Native.attachPauseAd(this.adUnitId, this.adObjectId, player.currentPositionMs, player.isPlaying);
54
+ this._startPlayerTimer();
55
+ }
56
+
57
+ /** Detach the pause ad and stop pushing player state. */
58
+ detach() {
59
+ this._stopPlayerTimer();
60
+ this._player = null;
61
+ Native.detachPauseAd(this.adObjectId);
62
+ }
63
+ destroy() {
64
+ if (this._disposed) {
65
+ return;
66
+ }
67
+ this._stopPlayerTimer();
68
+ this._player = null;
69
+ super.destroy();
70
+ }
71
+ _startPlayerTimer() {
72
+ this._stopPlayerTimer();
73
+ this._timer = setInterval(() => {
74
+ const player = this._player;
75
+ if (!player) {
76
+ return;
77
+ }
78
+ Native.updatePauseAdPlayerState(this.adObjectId, player.currentPositionMs, player.isPlaying);
79
+ }, PLAYER_PUSH_INTERVAL_MS);
80
+ }
81
+ _stopPlayerTimer() {
82
+ if (this._timer) {
83
+ clearInterval(this._timer);
84
+ this._timer = null;
85
+ }
86
+ }
87
+ _handleInternalEvent(event) {
88
+ switch (event.event) {
89
+ case NovvyAdEvent.FailedToLoad:
90
+ this.onAdFailedToLoad?.(event.error ?? 'Unknown error');
91
+ // Stops the player timer + unsubscribes before releasing native —
92
+ // avoids a leaked 500ms push loop on failure.
93
+ this.destroy();
94
+ break;
95
+ case NovvyAdEvent.Showed:
96
+ if (!this._disposed) {
97
+ this.onShownChanged?.(true);
98
+ }
99
+ this.onAdShowed?.();
100
+ break;
101
+ case NovvyAdEvent.Hidden:
102
+ if (!this._disposed) {
103
+ this.onShownChanged?.(false);
104
+ }
105
+ this.onAdHidden?.();
106
+ break;
107
+ default:
108
+ break;
109
+ }
110
+ }
111
+ }
112
+ //# sourceMappingURL=NovvyPauseAd.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["Native","NovvyAdEvent","NovvyAd","PLAYER_PUSH_INTERVAL_MS","NovvyPauseAd","viewType","cardWidth","cardHeight","_player","_timer","_loadNative","Error","attach","player","_disposed","_subscribe","attachPauseAd","adUnitId","adObjectId","currentPositionMs","isPlaying","_startPlayerTimer","detach","_stopPlayerTimer","detachPauseAd","destroy","setInterval","updatePauseAdPlayerState","clearInterval","_handleInternalEvent","event","FailedToLoad","onAdFailedToLoad","error","Showed","onShownChanged","onAdShowed","Hidden","onAdHidden"],"sourceRoot":"../../../src","sources":["ads/NovvyPauseAd.ts"],"mappings":";;AAAA,SAASA,MAAM,QAAQ,aAAa;AAEpC,SAASC,YAAY,QAAiC,UAAU;AAChE,SAASC,OAAO,QAAQ,WAAW;;AAEnC;AACA,MAAMC,uBAAuB,GAAG,GAAG;;AAEnC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,YAAY,SAASF,OAAO,CAAC;EACxC;EACA,OAAgBG,QAAQ,GAAG,kBAAkB;EAC7C;EACA,OAAgBC,SAAS,GAAG,GAAG;EAC/B;EACA,OAAgBC,UAAU,GAAG,EAAE;;EAE/B;;EAEA;;EAEA;AACF;AACA;AACA;;EAGUC,OAAO,GAA8B,IAAI;EACzCC,MAAM,GAA0C,IAAI;EAElDC,WAAWA,CAAA,EAAU;IAC7B,MAAM,IAAIC,KAAK,CAAC,8CAA8C,CAAC;EACjE;;EAEA;AACF;AACA;AACA;AACA;AACA;EACEC,MAAMA,CAACC,MAA0B,EAAQ;IACvC,IAAI,IAAI,CAACC,SAAS,EAAE;MAClB;IACF;IACA,IAAI,CAACN,OAAO,GAAGK,MAAM;IACrB,IAAI,CAACE,UAAU,CAAC,CAAC;IACjBf,MAAM,CAACgB,aAAa,CAClB,IAAI,CAACC,QAAQ,EACb,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YAAY,CAACiC,MAAM;QACtB,IAAI,CAAC,IAAI,CAACpB,SAAS,EAAE;UACnB,IAAI,CAACqB,cAAc,GAAG,IAAI,CAAC;QAC7B;QACA,IAAI,CAACC,UAAU,GAAG,CAAC;QACnB;MACF,KAAKnC,YAAY,CAACoC,MAAM;QACtB,IAAI,CAAC,IAAI,CAACvB,SAAS,EAAE;UACnB,IAAI,CAACqB,cAAc,GAAG,KAAK,CAAC;QAC9B;QACA,IAAI,CAACG,UAAU,GAAG,CAAC;QACnB;MACF;QACE;IACJ;EACF;AACF","ignoreList":[]}
@@ -0,0 +1,49 @@
1
+ "use strict";
2
+
3
+ import { Native } from '../eventBus';
4
+ import { NovvyAdEvent } from '../types';
5
+ import { NovvyAd } from './NovvyAd';
6
+
7
+ /** A rewarded video ad. */
8
+ export class NovvyRewardedAd extends NovvyAd {
9
+ /** Called when the ad is displayed. */
10
+
11
+ /** Called when the ad is dismissed by the user. */
12
+
13
+ /**
14
+ * Called once when the user earns the reward. No reward payload — the native
15
+ * SDKs deliver a parameterless signal (grant the host's own reward).
16
+ */
17
+
18
+ _loadNative() {
19
+ Native.loadRewardedAd(this.adUnitId, this.adObjectId);
20
+ }
21
+
22
+ /** Shows the rewarded video ad. Must be called after it has loaded. */
23
+ show() {
24
+ if (!this._isReady) {
25
+ throw new Error('Ad must be loaded before showing.');
26
+ }
27
+ Native.showRewardedAd(this.adObjectId);
28
+ }
29
+ _handleInternalEvent(event) {
30
+ if (this._handleCommonLoad(event)) {
31
+ return;
32
+ }
33
+ switch (event.event) {
34
+ case NovvyAdEvent.Showed:
35
+ this.onAdShowed?.();
36
+ break;
37
+ case NovvyAdEvent.EarnedReward:
38
+ this.onUserEarnedReward?.();
39
+ break;
40
+ case NovvyAdEvent.Dismissed:
41
+ this.onAdDismissed?.();
42
+ this.destroy();
43
+ break;
44
+ default:
45
+ break;
46
+ }
47
+ }
48
+ }
49
+ //# sourceMappingURL=NovvyRewardedAd.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["Native","NovvyAdEvent","NovvyAd","NovvyRewardedAd","_loadNative","loadRewardedAd","adUnitId","adObjectId","show","_isReady","Error","showRewardedAd","_handleInternalEvent","event","_handleCommonLoad","Showed","onAdShowed","EarnedReward","onUserEarnedReward","Dismissed","onAdDismissed","destroy"],"sourceRoot":"../../../src","sources":["ads/NovvyRewardedAd.ts"],"mappings":";;AAAA,SAASA,MAAM,QAAQ,aAAa;AAEpC,SAASC,YAAY,QAAQ,UAAU;AACvC,SAASC,OAAO,QAAQ,WAAW;;AAEnC;AACA,OAAO,MAAMC,eAAe,SAASD,OAAO,CAAC;EAC3C;;EAEA;;EAEA;AACF;AACA;AACA;;EAGYE,WAAWA,CAAA,EAAS;IAC5BJ,MAAM,CAACK,cAAc,CAAC,IAAI,CAACC,QAAQ,EAAE,IAAI,CAACC,UAAU,CAAC;EACvD;;EAEA;EACAC,IAAIA,CAAA,EAAS;IACX,IAAI,CAAC,IAAI,CAACC,QAAQ,EAAE;MAClB,MAAM,IAAIC,KAAK,CAAC,mCAAmC,CAAC;IACtD;IACAV,MAAM,CAACW,cAAc,CAAC,IAAI,CAACJ,UAAU,CAAC;EACxC;EAEUK,oBAAoBA,CAACC,KAAoB,EAAQ;IACzD,IAAI,IAAI,CAACC,iBAAiB,CAACD,KAAK,CAAC,EAAE;MACjC;IACF;IACA,QAAQA,KAAK,CAACA,KAAK;MACjB,KAAKZ,YAAY,CAACc,MAAM;QACtB,IAAI,CAACC,UAAU,GAAG,CAAC;QACnB;MACF,KAAKf,YAAY,CAACgB,YAAY;QAC5B,IAAI,CAACC,kBAAkB,GAAG,CAAC;QAC3B;MACF,KAAKjB,YAAY,CAACkB,SAAS;QACzB,IAAI,CAACC,aAAa,GAAG,CAAC;QACtB,IAAI,CAACC,OAAO,CAAC,CAAC;QACd;MACF;QACE;IACJ;EACF;AACF","ignoreList":[]}
@@ -0,0 +1,132 @@
1
+ "use strict";
2
+
3
+ import { Native } from '../eventBus';
4
+ import { NovvyAdEvent } from '../types';
5
+ import { NovvyAd } from './NovvyAd';
6
+
7
+ /**
8
+ * A scroll ad that renders as a native view inserted into a scrollable list.
9
+ *
10
+ * Lifecycle: {@link load} → embed `<NovvyScrollAdView>` → {@link setPlaying} as
11
+ * it enters / leaves the viewport → {@link destroy}. Attach/detach are driven
12
+ * by the `<NovvyScrollAdView>` component's mount lifecycle.
13
+ */
14
+ export class NovvyScrollAd extends NovvyAd {
15
+ /** The Fabric component name used by `<NovvyScrollAdView>`. */
16
+ static viewType = 'NovvyScrollAdView';
17
+
18
+ /**
19
+ * Optional override for the episode number used in the bid request. When
20
+ * non-null, takes precedence over the value set via
21
+ * {@link NovvyAds.setContentContext}.
22
+ */
23
+
24
+ /** Called when the ad becomes visible in the viewport. */
25
+
26
+ /** Called when the ad is hidden / removed from the viewport. */
27
+
28
+ /**
29
+ * Called every second during playback with the remaining seconds
30
+ * (0 = user can swipe past the ad).
31
+ */
32
+
33
+ constructor(adUnitId, episodeNumber) {
34
+ super(adUnitId);
35
+ this.episodeNumber = episodeNumber;
36
+ }
37
+
38
+ // ── Attach coordination ────────────────────────────────────────────────
39
+ //
40
+ // The native SCROLL contract is strictly two-stage: `load()` must resolve the
41
+ // creative BEFORE `attach()` — the native engine drops an early attach with a
42
+ // "not ready" log and never retries (see NovvyPlacementAd.attach). But the two
43
+ // triggers here are independent: `load()` is host-driven and network-bound,
44
+ // while the native container becomes available on the view's `onViewReady`
45
+ // (local, fast). View-ready therefore almost always beats `loaded`, so a naive
46
+ // "attach on view-ready" fires too early, silently no-ops, and the slot stays
47
+ // on its black placeholder for every creative type.
48
+ //
49
+ // We instead attach only once BOTH signals have arrived (whichever is last),
50
+ // and buffer the host's play intent so it survives being set before attach and
51
+ // is re-applied across detach/re-attach (scroll off- and back on-screen).
52
+ _viewReady = false;
53
+ _attached = false;
54
+ /** Last play intent from the host; (re)applied on each attach. */
55
+ _playing = false;
56
+ _durationSeconds = null;
57
+ _useDefaultSwipeOverlay = true;
58
+ _loadNative() {
59
+ Native.loadScrollAd(this.adUnitId, this.adObjectId, this.episodeNumber ?? null);
60
+ }
61
+
62
+ /**
63
+ * Signals that the native container is ready (fired automatically by
64
+ * `<NovvyScrollAdView>` on `onViewReady`). Records the attach params and
65
+ * mounts the ad once it has also finished loading.
66
+ */
67
+ attach(durationSeconds, useDefaultSwipeOverlay = true) {
68
+ this._durationSeconds = durationSeconds ?? null;
69
+ this._useDefaultSwipeOverlay = useDefaultSwipeOverlay;
70
+ this._viewReady = true;
71
+ this._maybeAttach();
72
+ }
73
+
74
+ /** Detach the scroll ad from its container. */
75
+ detach() {
76
+ this._viewReady = false;
77
+ this._attached = false;
78
+ Native.detachScrollAd(this.adObjectId);
79
+ }
80
+
81
+ /**
82
+ * Set the playing state. Call `setPlaying(true)` when the item scrolls into
83
+ * the viewport and `setPlaying(false)` when it scrolls out. Safe to call
84
+ * before the ad has attached — the intent is buffered and applied on attach.
85
+ */
86
+ setPlaying(playing) {
87
+ this._playing = playing;
88
+ if (this._attached) {
89
+ Native.setScrollAdPlaying(this.adObjectId, playing);
90
+ }
91
+ }
92
+
93
+ /**
94
+ * Attach once the ad is loaded AND the native view is ready — the native
95
+ * engine requires load-before-attach and does not retry, so we gate on both.
96
+ */
97
+ _maybeAttach() {
98
+ if (this._attached || this._disposed || !this._isReady || !this._viewReady) {
99
+ return;
100
+ }
101
+ Native.attachScrollAd(this.adObjectId, this._durationSeconds, this._useDefaultSwipeOverlay);
102
+ this._attached = true;
103
+ // Re-apply the buffered play intent now that a native host exists.
104
+ if (this._playing) {
105
+ Native.setScrollAdPlaying(this.adObjectId, true);
106
+ }
107
+ }
108
+ _handleInternalEvent(event) {
109
+ if (this._handleCommonLoad(event)) {
110
+ // `loaded` may arrive after the view is already ready; attach now that
111
+ // the native engine has the creative (after any onAdLoaded → setPlaying).
112
+ if (event.event === NovvyAdEvent.Loaded) {
113
+ this._maybeAttach();
114
+ }
115
+ return;
116
+ }
117
+ switch (event.event) {
118
+ case NovvyAdEvent.Showed:
119
+ this.onAdShowed?.();
120
+ break;
121
+ case NovvyAdEvent.Hidden:
122
+ this.onAdHidden?.();
123
+ break;
124
+ case NovvyAdEvent.PlaybackTick:
125
+ this.onAdPlaybackTick?.(event.remainingSeconds ?? 0);
126
+ break;
127
+ default:
128
+ break;
129
+ }
130
+ }
131
+ }
132
+ //# sourceMappingURL=NovvyScrollAd.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["Native","NovvyAdEvent","NovvyAd","NovvyScrollAd","viewType","constructor","adUnitId","episodeNumber","_viewReady","_attached","_playing","_durationSeconds","_useDefaultSwipeOverlay","_loadNative","loadScrollAd","adObjectId","attach","durationSeconds","useDefaultSwipeOverlay","_maybeAttach","detach","detachScrollAd","setPlaying","playing","setScrollAdPlaying","_disposed","_isReady","attachScrollAd","_handleInternalEvent","event","_handleCommonLoad","Loaded","Showed","onAdShowed","Hidden","onAdHidden","PlaybackTick","onAdPlaybackTick","remainingSeconds"],"sourceRoot":"../../../src","sources":["ads/NovvyScrollAd.ts"],"mappings":";;AAAA,SAASA,MAAM,QAAQ,aAAa;AAEpC,SAASC,YAAY,QAAQ,UAAU;AACvC,SAASC,OAAO,QAAQ,WAAW;;AAEnC;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,aAAa,SAASD,OAAO,CAAC;EACzC;EACA,OAAgBE,QAAQ,GAAG,mBAAmB;;EAE9C;AACF;AACA;AACA;AACA;;EAGE;;EAEA;;EAEA;AACF;AACA;AACA;;EAGEC,WAAWA,CAACC,QAAgB,EAAEC,aAA6B,EAAE;IAC3D,KAAK,CAACD,QAAQ,CAAC;IACf,IAAI,CAACC,aAAa,GAAGA,aAAa;EACpC;;EAEA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACQC,UAAU,GAAG,KAAK;EAClBC,SAAS,GAAG,KAAK;EACzB;EACQC,QAAQ,GAAG,KAAK;EAChBC,gBAAgB,GAAkB,IAAI;EACt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