@octane-xplat/ads 0.18.0 → 0.19.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 CHANGED
@@ -1,25 +1,49 @@
1
- # `@octane-xplat/ads`
1
+ # @octane-xplat/ads
2
+
3
+ Show Google AdMob banners and fullscreen ads in an iOS or Android app.
4
+ Web and desktop report `supported: false`.
5
+
6
+ ## Show a banner
7
+
8
+ Install in an existing Xplat app:
2
9
 
3
10
  ```sh
4
- pnpm add @octane-xplat/ads
11
+ bun add @octane-xplat/ads
5
12
  ```
6
13
 
7
- Google AdMob — `<BannerAd>` plus interstitial, rewarded, and
8
- rewarded-interstitial formats through `@nativescript/google-mobile-ads`.
9
- Mirrors `react-native-google-mobile-ads` naming (Expo's ads packages are
10
- deprecated). Consent (UMP/ATT) stays in the permissions seam.
14
+ Before launching, configure the AdMob **app ID** in the native host:
15
+ `GADApplicationIdentifier` in `App_Resources/iOS/Info.plist`, or
16
+ `com.google.android.gms.ads.APPLICATION_ID` in the Android manifest's
17
+ application metadata. An app ID identifies the app; an **ad unit ID** identifies
18
+ an ad placement. Follow the [NativeScript plugin setup](https://docs.nativescript.org/plugins/google-mobile-ads)
19
+ for the remaining platform and consent configuration. Installing the package
20
+ does not complete that setup.
11
21
 
12
- ```tsx
13
- import { ads, BannerAd } from '@octane-xplat/ads'
22
+ Finish the app's consent flow before initializing ads. For iOS tracking, see
23
+ [tracking authorization](../tracking-transparency/README.md) and request from an
24
+ explicit app action. An unavailable ATT gate on another platform is not app
25
+ consent. Initialize once after that flow:
14
26
 
15
- await ads.initialize()
27
+ ```ts
28
+ import { ads } from '@octane-xplat/ads'
16
29
 
17
- <BannerAd adUnitId="ca-app-pub-3940256099942544/6300978111" size="anchoredAdaptive" />
30
+ if (ads.supported) await ads.initialize()
31
+ ```
32
+
33
+ Render this component from a phone screen after initialization. Supply an ad
34
+ unit for the current platform; use your provider's test unit while developing:
35
+
36
+ ```tsx
37
+ import { BannerAd } from '@octane-xplat/ads'
18
38
 
19
- const rewarded = ads.createRewardedAd('ca-app-pub-3940256099942544/5224354917')
20
- rewarded.onAdEvent((e) => e.type === 'earned_reward' && grant(e.reward))
21
- rewarded.load(); rewarded.show()
39
+ export function SponsorBanner({ adUnitId }: { adUnitId: string }) {
40
+ return <BannerAd adUnitId={adUnitId} size="anchoredAdaptive" />
41
+ }
22
42
  ```
23
43
 
24
- Web/desktop report `supported: false` (AdSense is a different product).
25
- `createAppOpenAd` throws — upstream ships no AppOpenAd wrapper.
44
+ A test banner should appear after loading. If it does not, check app ID,
45
+ ad unit platform, SDK errors, and network access before trying a production ad.
46
+ Fullscreen ads have a separate load lifecycle: wait for a loaded event before
47
+ showing one. The package does not wrap AppOpenAd; calling that factory throws.
48
+ See the [public contracts](https://github.com/octane-xplat/octane-xplat/blob/main/packages/ads/src/types.ts)
49
+ for the available formats and events.
package/package.json CHANGED
@@ -1,96 +1,89 @@
1
1
  {
2
- "name": "@octane-xplat/ads",
3
- "version": "0.18.0",
4
- "description": "Google AdMob ads for Octane xplat — banner, interstitial, rewarded, app-open via @nativescript/google-mobile-ads",
5
- "keywords": [
6
- "android",
7
- "cross-platform",
8
- "nativescript",
9
- "octane",
10
- "xplat",
11
- "ads",
12
- "admob",
13
- "monetization"
14
- ],
15
- "homepage": "https://github.com/octane-xplat/octane-xplat/tree/main/packages/ads",
16
- "license": "MIT",
17
- "repository": {
18
- "type": "git",
19
- "url": "https://github.com/octane-xplat/octane-xplat",
20
- "directory": "packages/ads"
21
- },
22
- "files": [
23
- "src",
24
- "platforms",
25
- "types",
26
- "!src/**/*.test.*",
27
- "!src/**/*.spec.*"
28
- ],
29
- "type": "module",
30
- "exports": {
31
- ".": {
32
- "macos": {
33
- "types": "./types/generated/index.macos.d.ts",
34
- "default": "./src/index.macos.ts"
35
- },
36
- "web": {
37
- "types": "./types/generated/index.web.d.ts",
38
- "default": "./src/index.web.ts"
39
- },
40
- "native": {
41
- "types": "./types/generated/index.d.ts",
42
- "default": "./src/index.ts"
43
- },
44
- "types": "./types/generated/index.d.ts",
45
- "default": "./src/index.ts"
46
- },
47
- "./*": {
48
- "types": "./types/generated/*.d.ts",
49
- "default": "./src/*"
50
- },
51
- "./*.ts": {
52
- "types": "./types/generated/*.d.ts",
53
- "default": "./src/*.ts"
54
- }
55
- },
56
- "publishConfig": {
57
- "access": "public"
58
- },
59
- "devDependencies": {
60
- "@nativescript-community/octane": "0.2.5",
61
- "@nativescript/core": "9.1.3",
62
- "@nativescript/types": "9.1.4",
63
- "@tsrx/typescript-plugin": "0.4.11",
64
- "octane": "0.14.0",
65
- "tsrx-typegen": "0.4.0",
66
- "typescript": "5.9.3"
67
- },
68
- "peerDependencies": {
69
- "@nativescript-community/octane": ">=0.2.1 <1",
70
- "@nativescript/core": ">=9.1.0 <10",
71
- "octane": ">=0.6.3 <1"
72
- },
73
- "peerDependenciesMeta": {
74
- "@nativescript-community/octane": {
75
- "optional": true
76
- },
77
- "@nativescript/core": {
78
- "optional": true
79
- }
80
- },
81
- "nativescript": {
82
- "platforms": {
83
- "android": "9.1.0",
84
- "ios": "9.1.0"
85
- }
86
- },
87
- "dependencies": {
88
- "@nativescript/google-mobile-ads": "5.0.4",
89
- "@octane-xplat/platform": "0.18.0"
90
- },
91
- "scripts": {
92
- "typegen": "tsrx-typegen --target octane",
93
- "pack:check": "tsrx-typegen --pack-check",
94
- "typecheck": "node ../../scripts/typecheck.ts"
95
- }
96
- }
2
+ "name": "@octane-xplat/ads",
3
+ "version": "0.19.0",
4
+ "description": "Google AdMob ads for Octane xplat — banner, interstitial, rewarded, app-open via @nativescript/google-mobile-ads",
5
+ "keywords": [
6
+ "android",
7
+ "cross-platform",
8
+ "nativescript",
9
+ "octane",
10
+ "xplat",
11
+ "ads",
12
+ "admob",
13
+ "monetization"
14
+ ],
15
+ "homepage": "https://github.com/octane-xplat/octane-xplat/tree/main/packages/ads",
16
+ "license": "MIT",
17
+ "repository": {
18
+ "type": "git",
19
+ "url": "https://github.com/octane-xplat/octane-xplat",
20
+ "directory": "packages/ads"
21
+ },
22
+ "files": [
23
+ "src",
24
+ "platforms",
25
+ "types",
26
+ "!src/**/*.test.*",
27
+ "!src/**/*.spec.*"
28
+ ],
29
+ "type": "module",
30
+ "exports": {
31
+ ".": {
32
+ "types": "./types/generated/index.d.ts",
33
+ "macos": "./src/index.macos.ts",
34
+ "web": "./src/index.web.ts",
35
+ "native": "./src/index.ts",
36
+ "default": "./src/index.ts"
37
+ },
38
+ "./*": {
39
+ "types": "./types/generated/*.d.ts",
40
+ "default": "./src/*"
41
+ },
42
+ "./*.ts": {
43
+ "types": "./types/generated/*.d.ts",
44
+ "default": "./src/*.ts"
45
+ }
46
+ },
47
+ "publishConfig": {
48
+ "access": "public"
49
+ },
50
+ "scripts": {
51
+ "typegen": "tsrx-typegen --target octane",
52
+ "prepack": "bun run typegen && tsrx-typegen --pack-check",
53
+ "pack:check": "tsrx-typegen --pack-check",
54
+ "typecheck": "node ../../scripts/typecheck.ts"
55
+ },
56
+ "devDependencies": {
57
+ "@nativescript-community/octane": "0.2.5",
58
+ "@nativescript/core": "9.1.3",
59
+ "@nativescript/types": "9.1.4",
60
+ "@tsrx/typescript-plugin": "0.4.11",
61
+ "octane": "0.16.3",
62
+ "tsrx-typegen": "0.5.0",
63
+ "typescript": "5.9.3"
64
+ },
65
+ "peerDependencies": {
66
+ "@nativescript-community/octane": ">=0.2.1 <1",
67
+ "@nativescript/core": ">=9.1.0 <10",
68
+ "octane": ">=0.6.3 <1"
69
+ },
70
+ "peerDependenciesMeta": {
71
+ "@nativescript-community/octane": {
72
+ "optional": true
73
+ },
74
+ "@nativescript/core": {
75
+ "optional": true
76
+ }
77
+ },
78
+ "nativescript": {
79
+ "platforms": {
80
+ "android": "9.1.0",
81
+ "ios": "9.1.0"
82
+ }
83
+ },
84
+ "dependencies": {
85
+ "@nativescript/google-mobile-ads": "5.0.4",
86
+ "@octane-xplat/jsx": "0.19.0",
87
+ "@octane-xplat/platform": "0.19.0"
88
+ }
89
+ }
@@ -0,0 +1,17 @@
1
+ /** @jsxImportSource @octane-xplat/jsx */
2
+ // Banner ad — AppKit stub. AdMob has no desktop product; renders nothing and
3
+ // reports once via onAdEvent error, matching the web leaf's honest contract.
4
+ import { useEffect } from 'octane'
5
+ import type { BannerAdProps } from './props'
6
+ import type { JSX } from 'octane/jsx-runtime'
7
+
8
+ export function BannerAd(props: BannerAdProps): JSX.Element @{
9
+ useEffect(() => {
10
+ props.onAdEvent?.({
11
+ type: 'error',
12
+ error: new Error('unsupported: AdMob is not available on macOS'),
13
+ })
14
+ }, [])
15
+
16
+ <masonview style={props.style} className={props.className} />
17
+ }
package/src/BannerAd.tsrx CHANGED
@@ -1,4 +1,4 @@
1
- /** @jsxImportSource @nativescript-community/octane */
1
+ /** @jsxImportSource @octane-xplat/jsx */
2
2
  import { useEffect, useCallback, useRef } from 'octane'
3
3
  import { isAndroid } from '@nativescript/core'
4
4
  import { registerElement } from '@nativescript-community/octane'
@@ -14,12 +14,13 @@ const SIZES: Record<string, any> = {
14
14
  fullBanner: () => (BannerAdSize as any).FULL_BANNER,
15
15
  leaderboard: () => (BannerAdSize as any).LEADERBOARD,
16
16
  adaptiveBanner: () => (BannerAdSize as any).getCurrentOrientationAnchoredAdaptiveBannerAdSize?.(),
17
- anchoredAdaptive: () => (BannerAdSize as any).getCurrentOrientationAnchoredAdaptiveBannerAdSize?.(),
17
+ anchoredAdaptive: () =>
18
+ (BannerAdSize as any).getCurrentOrientationAnchoredAdaptiveBannerAdSize?.(),
18
19
  fluid: () => (BannerAdSize as any).FLUID,
19
20
  }
20
21
 
21
22
  /** AdMob banner — the plugin view owns its own load() on mount. */
22
- export function BannerAd(props: BannerAdProps) @{
23
+ export function BannerAd(props: BannerAdProps): unknown @{
23
24
  const host = useRef<any>(null)
24
25
  const bindHost = useCallback((v: any) => {
25
26
  host.current = v
@@ -30,11 +31,13 @@ export function BannerAd(props: BannerAdProps) @{
30
31
  if (!v) {
31
32
  return
32
33
  }
34
+
33
35
  if (props.onAdEvent) {
34
36
  v.onAdEvent((type: any, error?: any, data?: any) =>
35
37
  props.onAdEvent?.({ type: String(type) as any, error, reward: data }),
36
38
  )
37
39
  }
40
+
38
41
  const bag = isAndroid ? props.android : props.ios
39
42
  if (bag) {
40
43
  Object.assign(v, bag)
@@ -48,5 +51,10 @@ export function BannerAd(props: BannerAdProps) @{
48
51
  }
49
52
  }, [props.size])
50
53
 
51
- <xplatbannerad ref={bindHost} unitId={props.adUnitId} style={props.style} className={props.className} />
54
+ <xplatbannerad
55
+ ref={bindHost}
56
+ unitId={props.adUnitId}
57
+ style={props.style}
58
+ className={props.className}
59
+ />
52
60
  }
@@ -1,11 +1,16 @@
1
+ /** @jsxImportSource @octane-xplat/jsx/dom */
1
2
  // Banner ad — web leaf. AdMob has no web product (AdSense is a different
2
3
  // integration); renders nothing and reports once via onAdEvent error.
3
4
  import { useEffect } from 'octane'
4
5
  import type { BannerAdProps } from './props'
6
+ import type { JSX } from 'octane/jsx-runtime'
5
7
 
6
- export function BannerAd(props: BannerAdProps) @{
8
+ export function BannerAd(props: BannerAdProps): JSX.Element @{
7
9
  useEffect(() => {
8
- props.onAdEvent?.({ type: 'error', error: new Error('unsupported: AdMob is not available on web') })
10
+ props.onAdEvent?.({
11
+ type: 'error',
12
+ error: new Error('unsupported: AdMob is not available on web'),
13
+ })
9
14
  }, [])
10
15
 
11
16
  <div style={props.style} className={props.className} />
package/src/ads.macos.ts CHANGED
@@ -1 +1,17 @@
1
- export { ads } from './ads.web'
1
+ // Ads — AppKit leaf. AdMob has no desktop product and the `.web` source is a
2
+ // macOS bundle boundary violation, so this leaf is an explicit unsupported
3
+ // facade rather than a re-export (see the §3 services decisions).
4
+ import type { Ads } from './types'
5
+
6
+ const unsupported = () => {
7
+ throw new Error('unsupported: AdMob is not available on macOS')
8
+ }
9
+
10
+ export const ads: Ads = {
11
+ supported: false,
12
+ initialize: async () => {},
13
+ createInterstitial: unsupported,
14
+ createRewardedAd: unsupported,
15
+ createRewardedInterstitialAd: unsupported,
16
+ createAppOpenAd: unsupported,
17
+ }
package/src/ads.ts CHANGED
@@ -1,6 +1,12 @@
1
1
  // Ads — native leaf over @nativescript/google-mobile-ads. Banner lives in
2
2
  // BannerAd.tsrx (a view); this service owns SDK init + fullscreen formats.
3
- import { InterstitialAd, MobileAds, RewardedAd, RewardedInterstitialAd } from '@nativescript/google-mobile-ads'
3
+ import {
4
+ InterstitialAd,
5
+ MobileAds,
6
+ RewardedAd,
7
+ RewardedInterstitialAd,
8
+ } from '@nativescript/google-mobile-ads'
9
+
4
10
  import type { AdEventListener, Ads, LoadedAd } from './types'
5
11
 
6
12
  const EVENT: Record<string, string> = {
@@ -15,9 +21,15 @@ const EVENT: Record<string, string> = {
15
21
  error: 'error',
16
22
  }
17
23
 
18
- function wrap<T extends { adUnitId: string; loaded: boolean; load(): void; onAdEvent(l: any): void; show(o?: any): void }>(
19
- ad: T,
20
- ): LoadedAd {
24
+ function wrap<
25
+ T extends {
26
+ adUnitId: string
27
+ loaded: boolean
28
+ load(): void
29
+ onAdEvent(l: any): void
30
+ show(o?: any): void
31
+ },
32
+ >(ad: T): LoadedAd {
21
33
  return {
22
34
  adUnitId: ad.adUnitId,
23
35
  get loaded() {
@@ -36,6 +48,7 @@ function wrap<T extends { adUnitId: string; loaded: boolean; load(): void; onAdE
36
48
  }
37
49
  }
38
50
 
51
+ /** Google Mobile Ads service — see Ads for the contract. */
39
52
  export const ads: Ads = {
40
53
  supported: true,
41
54
 
package/src/ads.web.ts CHANGED
@@ -2,8 +2,11 @@
2
2
  // supported: false rather than fake parity.
3
3
  import type { Ads } from './types'
4
4
 
5
- const unsupported = () => { throw new Error('unsupported: AdMob is not available on web') }
5
+ const unsupported = () => {
6
+ throw new Error('unsupported: AdMob is not available on web')
7
+ }
6
8
 
9
+ /** Google Mobile Ads service — see Ads for the contract. */
7
10
  export const ads: Ads = {
8
11
  supported: false,
9
12
  initialize: async () => {},
@@ -1,4 +1,4 @@
1
1
  export * from './types'
2
2
  export * from './props'
3
3
  export { ads } from './ads.macos'
4
- export { BannerAd } from './BannerAd.web.tsrx'
4
+ export { BannerAd } from './BannerAd.macos.tsrx'
@@ -1,8 +1,7 @@
1
- import { BannerAd } from '@nativescript/google-mobile-ads'
2
- import type { Attributes } from '@nativescript-community/octane/intrinsics'
1
+ import type { Attributes } from '@octane-xplat/jsx/intrinsics'
3
2
 
4
- declare module '@nativescript-community/octane/intrinsics' {
5
- interface NativeScriptElements {
6
- xplatbannerad: Attributes<typeof BannerAd>
3
+ declare module '@octane-xplat/jsx/intrinsics' {
4
+ interface NativeElements<TElement> {
5
+ xplatbannerad: Attributes<TElement, { unitId?: string }>
7
6
  }
8
7
  }
package/src/props.ts CHANGED
@@ -4,13 +4,22 @@ import type { AdEventListener, BannerAdSizeType } from './types'
4
4
  * in the permissions seam; requestOptions carries request-level flags
5
5
  * (tagForChildDirectedTreatment etc.) straight through to the SDK. */
6
6
  export interface BannerAdProps {
7
+ /** Class list applied to the banner container. */
7
8
  className?: any
9
+ /** Inline style (string CSS or object). */
8
10
  style?: any
11
+ /** Console ad-unit id for this banner slot. */
9
12
  adUnitId: string
13
+ /** Banner format — 'anchoredAdaptive' resolves a device-fitting height. */
10
14
  size?: BannerAdSizeType
15
+ /** Request-level flags forwarded to the ad request (e.g. test-device ids). */
11
16
  requestOptions?: Record<string, unknown>
17
+ /** Lifecycle listener for this banner. */
12
18
  onAdEvent?: AdEventListener
19
+ /** Platform escape hatches, applied after the shared props. */
13
20
  ios?: Record<string, any>
21
+ /** Platform escape hatch — same bag contract as `ios`. */
14
22
  android?: Record<string, any>
23
+ /** Platform escape hatch — same bag contract as `ios`. */
15
24
  web?: Record<string, any>
16
25
  }
package/src/types.ts CHANGED
@@ -1,3 +1,5 @@
1
+ /** Ad lifecycle event kinds — Google Mobile Ads event vocabulary normalized
2
+ * to shared spellings. */
1
3
  export type AdEventType =
2
4
  | 'loaded'
3
5
  | 'failed_to_load'
@@ -8,22 +10,36 @@ export type AdEventType =
8
10
  | 'earned_reward'
9
11
  | 'error'
10
12
 
13
+ /** One ad lifecycle event delivered to a LoadedAd listener. */
11
14
  export interface AdEvent {
15
+ /** Which lifecycle transition fired. */
12
16
  type: AdEventType
17
+ /** The underlying error for 'failed_to_load'/'error'. */
13
18
  error?: Error
19
+ /** Earned reward payload for 'earned_reward' (rewarded formats only). */
14
20
  reward?: { amount: number; type: string }
15
21
  }
16
22
 
23
+ /** Callback for ad lifecycle events. */
17
24
  export type AdEventListener = (event: AdEvent) => void
18
25
 
26
+ /** Handle for a created fullscreen/rewarded ad — load() then show().
27
+ * Fullscreen ads are one-shot: after 'closed', create a new one. */
19
28
  export interface LoadedAd {
29
+ /** Console ad-unit id this ad belongs to. */
20
30
  readonly adUnitId: string
31
+ /** True once 'loaded' has fired and show() can present. */
21
32
  readonly loaded: boolean
33
+ /** Request the ad content. */
22
34
  load(): void
35
+ /** Attach a lifecycle listener (loaded/opened/closed/…). */
23
36
  onAdEvent(listener: AdEventListener): void
37
+ /** Present the ad once loaded. */
24
38
  show(options?: Record<string, unknown>): void
25
39
  }
26
40
 
41
+ /** Banner format vocabulary — GAM/AdMob size spellings including the
42
+ * adaptive anchored variants that resolve to real heights per device. */
27
43
  export type BannerAdSizeType =
28
44
  | 'banner'
29
45
  | 'largeBanner'
@@ -34,13 +50,19 @@ export type BannerAdSizeType =
34
50
  | 'anchoredAdaptive'
35
51
  | 'fluid'
36
52
 
53
+ /** Google Mobile Ads façade; `supported` is false on non-mobile leaves. */
37
54
  export interface Ads {
55
+ /** Google Mobile Ads SDK exists on this leaf (false off mobile). */
38
56
  readonly supported: boolean
39
57
  /** Initialize the Google Mobile Ads SDK — call once at app start. */
40
58
  initialize(): Promise<void>
59
+ /** Create a fullscreen interstitial ad — call load() then show() on the handle. */
41
60
  createInterstitial(adUnitId: string, requestOptions?: Record<string, unknown>): LoadedAd
61
+ /** Create a rewarded video ad — call load() then show() on the handle. */
42
62
  createRewardedAd(adUnitId: string, requestOptions?: Record<string, unknown>): LoadedAd
63
+ /** Create a rewarded interstitial ad — call load() then show() on the handle. */
43
64
  createRewardedInterstitialAd(adUnitId: string, requestOptions?: Record<string, unknown>): LoadedAd
65
+ /** Create a app-open ad — call load() then show() on the handle. */
44
66
  createAppOpenAd(adUnitId: string, requestOptions?: Record<string, unknown>): LoadedAd
45
67
  }
46
68
 
@@ -2,6 +2,7 @@
2
2
  "version": 1,
3
3
  "files": [
4
4
  "BannerAd.d.ts",
5
+ "BannerAd.macos.d.ts",
5
6
  "BannerAd.web.d.ts",
6
7
  "ads.d.ts",
7
8
  "ads.linux.d.ts",
@@ -0,0 +1,3 @@
1
+ import type { BannerAdProps } from './props.js';
2
+ import type { JSX } from 'octane/jsx-runtime';
3
+ export declare function BannerAd(props: BannerAdProps): JSX.Element;
@@ -1,2 +1,3 @@
1
1
  import type { BannerAdProps } from './props.js';
2
- export declare function BannerAd(props: BannerAdProps): import("octane/jsx-runtime").JSX.Element;
2
+ import type { JSX } from 'octane/jsx-runtime';
3
+ export declare function BannerAd(props: BannerAdProps): JSX.Element;
@@ -1,2 +1,3 @@
1
1
  import type { Ads } from './types.js';
2
+ /** Google Mobile Ads service — see Ads for the contract. */
2
3
  export declare const ads: Ads;
@@ -1 +1,2 @@
1
- export { ads } from './ads.web.js';
1
+ import type { Ads } from './types.js';
2
+ export declare const ads: Ads;
@@ -1,2 +1,3 @@
1
1
  import type { Ads } from './types.js';
2
+ /** Google Mobile Ads service — see Ads for the contract. */
2
3
  export declare const ads: Ads;
@@ -1,4 +1,4 @@
1
1
  export * from './types.js';
2
2
  export * from './props.js';
3
3
  export { ads } from './ads.macos.js';
4
- export { BannerAd } from './BannerAd.web.js';
4
+ export { BannerAd } from './BannerAd.macos.js';
@@ -1,8 +1,7 @@
1
- import { BannerAd } from '@nativescript/google-mobile-ads'
2
- import type { Attributes } from '@nativescript-community/octane/intrinsics'
1
+ import type { Attributes } from '@octane-xplat/jsx/intrinsics'
3
2
 
4
- declare module '@nativescript-community/octane/intrinsics' {
5
- interface NativeScriptElements {
6
- xplatbannerad: Attributes<typeof BannerAd>
3
+ declare module '@octane-xplat/jsx/intrinsics' {
4
+ interface NativeElements<TElement> {
5
+ xplatbannerad: Attributes<TElement, { unitId?: string }>
7
6
  }
8
7
  }
@@ -3,13 +3,22 @@ import type { AdEventListener, BannerAdSizeType } from './types.js';
3
3
  * in the permissions seam; requestOptions carries request-level flags
4
4
  * (tagForChildDirectedTreatment etc.) straight through to the SDK. */
5
5
  export interface BannerAdProps {
6
+ /** Class list applied to the banner container. */
6
7
  className?: any;
8
+ /** Inline style (string CSS or object). */
7
9
  style?: any;
10
+ /** Console ad-unit id for this banner slot. */
8
11
  adUnitId: string;
12
+ /** Banner format — 'anchoredAdaptive' resolves a device-fitting height. */
9
13
  size?: BannerAdSizeType;
14
+ /** Request-level flags forwarded to the ad request (e.g. test-device ids). */
10
15
  requestOptions?: Record<string, unknown>;
16
+ /** Lifecycle listener for this banner. */
11
17
  onAdEvent?: AdEventListener;
18
+ /** Platform escape hatches, applied after the shared props. */
12
19
  ios?: Record<string, any>;
20
+ /** Platform escape hatch — same bag contract as `ios`. */
13
21
  android?: Record<string, any>;
22
+ /** Platform escape hatch — same bag contract as `ios`. */
14
23
  web?: Record<string, any>;
15
24
  }
@@ -1,28 +1,50 @@
1
+ /** Ad lifecycle event kinds — Google Mobile Ads event vocabulary normalized
2
+ * to shared spellings. */
1
3
  export type AdEventType = 'loaded' | 'failed_to_load' | 'opened' | 'closed' | 'clicked' | 'impression' | 'earned_reward' | 'error';
4
+ /** One ad lifecycle event delivered to a LoadedAd listener. */
2
5
  export interface AdEvent {
6
+ /** Which lifecycle transition fired. */
3
7
  type: AdEventType;
8
+ /** The underlying error for 'failed_to_load'/'error'. */
4
9
  error?: Error;
10
+ /** Earned reward payload for 'earned_reward' (rewarded formats only). */
5
11
  reward?: {
6
12
  amount: number;
7
13
  type: string;
8
14
  };
9
15
  }
16
+ /** Callback for ad lifecycle events. */
10
17
  export type AdEventListener = (event: AdEvent) => void;
18
+ /** Handle for a created fullscreen/rewarded ad — load() then show().
19
+ * Fullscreen ads are one-shot: after 'closed', create a new one. */
11
20
  export interface LoadedAd {
21
+ /** Console ad-unit id this ad belongs to. */
12
22
  readonly adUnitId: string;
23
+ /** True once 'loaded' has fired and show() can present. */
13
24
  readonly loaded: boolean;
25
+ /** Request the ad content. */
14
26
  load(): void;
27
+ /** Attach a lifecycle listener (loaded/opened/closed/…). */
15
28
  onAdEvent(listener: AdEventListener): void;
29
+ /** Present the ad once loaded. */
16
30
  show(options?: Record<string, unknown>): void;
17
31
  }
32
+ /** Banner format vocabulary — GAM/AdMob size spellings including the
33
+ * adaptive anchored variants that resolve to real heights per device. */
18
34
  export type BannerAdSizeType = 'banner' | 'largeBanner' | 'mediumRectangle' | 'fullBanner' | 'leaderboard' | 'adaptiveBanner' | 'anchoredAdaptive' | 'fluid';
35
+ /** Google Mobile Ads façade; `supported` is false on non-mobile leaves. */
19
36
  export interface Ads {
37
+ /** Google Mobile Ads SDK exists on this leaf (false off mobile). */
20
38
  readonly supported: boolean;
21
39
  /** Initialize the Google Mobile Ads SDK — call once at app start. */
22
40
  initialize(): Promise<void>;
41
+ /** Create a fullscreen interstitial ad — call load() then show() on the handle. */
23
42
  createInterstitial(adUnitId: string, requestOptions?: Record<string, unknown>): LoadedAd;
43
+ /** Create a rewarded video ad — call load() then show() on the handle. */
24
44
  createRewardedAd(adUnitId: string, requestOptions?: Record<string, unknown>): LoadedAd;
45
+ /** Create a rewarded interstitial ad — call load() then show() on the handle. */
25
46
  createRewardedInterstitialAd(adUnitId: string, requestOptions?: Record<string, unknown>): LoadedAd;
47
+ /** Create a app-open ad — call load() then show() on the handle. */
26
48
  createAppOpenAd(adUnitId: string, requestOptions?: Record<string, unknown>): LoadedAd;
27
49
  }
28
50
  export declare const ads: Ads;
package/LICENSE DELETED
@@ -1,21 +0,0 @@
1
- The MIT License (MIT)
2
-
3
- Copyright (c) 2026 Alec Larson
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in
13
- all copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
- THE SOFTWARE.