@smoud/playable-sdk 1.0.0 → 1.0.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.
package/dist/esm/index.js CHANGED
@@ -220,10 +220,10 @@ function startDapiProtocol() {
220
220
  if ("dapi" !== AD_PROTOCOL) return;
221
221
  if (!isProtocolInitialized) {
222
222
  dapi.removeEventListener("ready", startDapiProtocol);
223
- var isAudioEnabled = !!dapi.getAudioVolume();
223
+ dapi.getAudioVolume();
224
224
  dapi.addEventListener("audioVolumeChange", function(volume) {
225
- var isAudioEnabled2 = !!volume;
226
- if (isAudioEnabled2) {
225
+ var isAudioEnabled = !!volume;
226
+ if (isAudioEnabled) {
227
227
  changeVolume(sdk.volume);
228
228
  } else {
229
229
  changeVolume(0);
@@ -320,17 +320,17 @@ var _sdk = class _sdk {
320
320
  /**
321
321
  * Initializes the SDK and sets up protocol-specific handlers.
322
322
  * This must be called as earlier as possible.
323
- *
323
+ *
324
324
  * @param callback Optional function called when ad container is ready
325
325
  * @example
326
326
  * // Basic initialization
327
327
  * sdk.init();
328
- *
328
+ *
329
329
  * // Initialization with callback
330
330
  * sdk.init((width, height) => {
331
331
  * new App(width, height)
332
332
  * });
333
- *
333
+ *
334
334
  * @fires init When initialization starts
335
335
  * @fires boot When the ad begins booting
336
336
  * @fires ready When Ad Network is ready and playable ad can be initialized
@@ -358,11 +358,11 @@ var _sdk = class _sdk {
358
358
  /**
359
359
  * Starts the playable ad experience.
360
360
  * Should be called after all resources are loaded and first frame is rendered.
361
- *
361
+ *
362
362
  * @example
363
363
  * // Call just after all resources are preloaded and first frame is rendered
364
364
  * sdk.start();
365
- *
365
+ *
366
366
  * @fires start When the playable ad starts
367
367
  * @fires resize When the ad container is initially sized
368
368
  */
@@ -379,7 +379,7 @@ var _sdk = class _sdk {
379
379
  if ("tapjoy" === AD_NETWORK && isTapjoy()) {
380
380
  window.TJ_API.setPlayableBuild({
381
381
  orientation: this.isLandscape ? "landscape" : "portrait",
382
- buildID: __BUILD_ID__
382
+ buildID: BUILD_HASH
383
383
  });
384
384
  }
385
385
  _sdk.resize();
@@ -388,11 +388,11 @@ var _sdk = class _sdk {
388
388
  /**
389
389
  * Marks the playable ad as finished.
390
390
  * This triggers network-specific completion handlers.
391
- *
391
+ *
392
392
  * @example
393
393
  * // Call when game/experience is complete
394
394
  * sdk.finish();
395
- *
395
+ *
396
396
  * @fires finish When the playable ad is marked as finished
397
397
  */
398
398
  static finish() {
@@ -409,11 +409,11 @@ var _sdk = class _sdk {
409
409
  /**
410
410
  * Triggers a retry/restart of the playable ad.
411
411
  * Behavior varies by ad network.
412
- *
412
+ *
413
413
  * @example
414
414
  * // Allow user to try again
415
415
  * retryButton.onclick = () => sdk.retry();
416
- *
416
+ *
417
417
  * @fires retry When a retry is triggered
418
418
  */
419
419
  static retry() {
@@ -427,11 +427,11 @@ var _sdk = class _sdk {
427
427
  /**
428
428
  * Triggers the install/download action for the advertised app.
429
429
  * Handles different store opening methods across ad networks.
430
- *
430
+ *
431
431
  * @example
432
432
  * // Call when user wants to install
433
433
  * installButton.onclick = () => sdk.install();
434
- *
434
+ *
435
435
  * @fires finish If the ad hasn't been marked as finished
436
436
  * @fires install When the install action is triggered
437
437
  */
@@ -456,7 +456,7 @@ var _sdk = class _sdk {
456
456
  }, 500);
457
457
  emitEvent("install");
458
458
  if ("mraid" === AD_PROTOCOL && isMraid()) {
459
- mraid.openStoreUrl ? mraid.openStoreUrl() : mraid.open(destinationUrl);
459
+ mraid.open(destinationUrl);
460
460
  } else if ("dapi" === AD_PROTOCOL && isDapi()) {
461
461
  dapi.openStoreUrl();
462
462
  } else if ("nucleo" === AD_PROTOCOL && isNucleo()) {
@@ -480,10 +480,10 @@ var _sdk = class _sdk {
480
480
  /**
481
481
  * Trigger force resize event
482
482
  * Useful when container size changes need to be manually propagated.
483
- *
483
+ *
484
484
  * @example
485
485
  * sdk.resize();
486
- *
486
+ *
487
487
  * @fires resize With current maxWidth and maxHeight
488
488
  */
489
489
  static resize() {
@@ -491,11 +491,11 @@ var _sdk = class _sdk {
491
491
  }
492
492
  /**
493
493
  * Forces the playable ad into a paused state.
494
- *
494
+ *
495
495
  * @example
496
496
  * // Pause the experience
497
497
  * pauseButton.onclick = () => sdk.pause();
498
- *
498
+ *
499
499
  * @fires pause When the ad enters paused state
500
500
  */
501
501
  static pause() {
@@ -507,11 +507,11 @@ var _sdk = class _sdk {
507
507
  /**
508
508
  * Resumes the playable ad from a forced pause state.
509
509
  * Only works if the ad was paused via sdk.pause().
510
- *
510
+ *
511
511
  * @example
512
512
  * // Resume from pause
513
513
  * resumeButton.onclick = () => sdk.resume();
514
- *
514
+ *
515
515
  * @fires resume When the ad resumes from pause
516
516
  */
517
517
  static resume() {
@@ -522,17 +522,17 @@ var _sdk = class _sdk {
522
522
  }
523
523
  /**
524
524
  * Registers an event listener.
525
- *
525
+ *
526
526
  * @param event Name of the event to listen for
527
527
  * @param fn Callback function to execute when event occurs
528
528
  * @param context Optional 'this' context for the callback
529
- *
529
+ *
530
530
  * @example
531
531
  * // Listen for user interactions
532
532
  * sdk.on('interaction', (count) => {
533
533
  * console.log(`User interaction #${count}`);
534
534
  * });
535
- *
535
+ *
536
536
  * // Listen for resize with context
537
537
  * sdk.on('resize', function(width, height) {
538
538
  * this.updateLayout(width, height);
@@ -543,11 +543,11 @@ var _sdk = class _sdk {
543
543
  }
544
544
  /**
545
545
  * Registers a one-time event listener that removes itself after execution.
546
- *
546
+ *
547
547
  * @param event Name of the event to listen for
548
548
  * @param fn Callback function to execute when event occurs
549
549
  * @param context Optional 'this' context for the callback
550
- *
550
+ *
551
551
  * @example
552
552
  * // Listen for first interaction only
553
553
  * sdk.once('interaction', () => {
@@ -559,16 +559,16 @@ var _sdk = class _sdk {
559
559
  }
560
560
  /**
561
561
  * Removes an event listener.
562
- *
562
+ *
563
563
  * @param event Name of the event to stop listening for
564
564
  * @param fn Optional callback function to remove (if not provided, removes all listeners for the event)
565
565
  * @param context Optional 'this' context to match when removing
566
- *
566
+ *
567
567
  * @example
568
568
  * // Remove specific listener
569
569
  * const handler = () => console.log('Interaction');
570
570
  * sdk.off('interaction', handler);
571
- *
571
+ *
572
572
  * // Remove all listeners for an event
573
573
  * sdk.off('interaction');
574
574
  */
@@ -577,7 +577,7 @@ var _sdk = class _sdk {
577
577
  }
578
578
  };
579
579
  /** Current version of the SDK */
580
- _sdk.version = "1.0.0";
580
+ _sdk.version = "1.0.1";
581
581
  /** Current maximum width of the playable ad container in pixels */
582
582
  _sdk.maxWidth = Math.floor(window.innerWidth);
583
583
  /** Current maximum height of the playable ad container in pixels */
@@ -222,10 +222,10 @@
222
222
  if ("dapi" !== AD_PROTOCOL) return;
223
223
  if (!isProtocolInitialized) {
224
224
  dapi.removeEventListener("ready", startDapiProtocol);
225
- var isAudioEnabled = !!dapi.getAudioVolume();
225
+ dapi.getAudioVolume();
226
226
  dapi.addEventListener("audioVolumeChange", function(volume) {
227
- var isAudioEnabled2 = !!volume;
228
- if (isAudioEnabled2) {
227
+ var isAudioEnabled = !!volume;
228
+ if (isAudioEnabled) {
229
229
  changeVolume(sdk.volume);
230
230
  } else {
231
231
  changeVolume(0);
@@ -322,17 +322,17 @@
322
322
  /**
323
323
  * Initializes the SDK and sets up protocol-specific handlers.
324
324
  * This must be called as earlier as possible.
325
- *
325
+ *
326
326
  * @param callback Optional function called when ad container is ready
327
327
  * @example
328
328
  * // Basic initialization
329
329
  * sdk.init();
330
- *
330
+ *
331
331
  * // Initialization with callback
332
332
  * sdk.init((width, height) => {
333
333
  * new App(width, height)
334
334
  * });
335
- *
335
+ *
336
336
  * @fires init When initialization starts
337
337
  * @fires boot When the ad begins booting
338
338
  * @fires ready When Ad Network is ready and playable ad can be initialized
@@ -360,11 +360,11 @@
360
360
  /**
361
361
  * Starts the playable ad experience.
362
362
  * Should be called after all resources are loaded and first frame is rendered.
363
- *
363
+ *
364
364
  * @example
365
365
  * // Call just after all resources are preloaded and first frame is rendered
366
366
  * sdk.start();
367
- *
367
+ *
368
368
  * @fires start When the playable ad starts
369
369
  * @fires resize When the ad container is initially sized
370
370
  */
@@ -381,7 +381,7 @@
381
381
  if ("tapjoy" === AD_NETWORK && isTapjoy()) {
382
382
  window.TJ_API.setPlayableBuild({
383
383
  orientation: this.isLandscape ? "landscape" : "portrait",
384
- buildID: __BUILD_ID__
384
+ buildID: BUILD_HASH
385
385
  });
386
386
  }
387
387
  _sdk.resize();
@@ -390,11 +390,11 @@
390
390
  /**
391
391
  * Marks the playable ad as finished.
392
392
  * This triggers network-specific completion handlers.
393
- *
393
+ *
394
394
  * @example
395
395
  * // Call when game/experience is complete
396
396
  * sdk.finish();
397
- *
397
+ *
398
398
  * @fires finish When the playable ad is marked as finished
399
399
  */
400
400
  static finish() {
@@ -411,11 +411,11 @@
411
411
  /**
412
412
  * Triggers a retry/restart of the playable ad.
413
413
  * Behavior varies by ad network.
414
- *
414
+ *
415
415
  * @example
416
416
  * // Allow user to try again
417
417
  * retryButton.onclick = () => sdk.retry();
418
- *
418
+ *
419
419
  * @fires retry When a retry is triggered
420
420
  */
421
421
  static retry() {
@@ -429,11 +429,11 @@
429
429
  /**
430
430
  * Triggers the install/download action for the advertised app.
431
431
  * Handles different store opening methods across ad networks.
432
- *
432
+ *
433
433
  * @example
434
434
  * // Call when user wants to install
435
435
  * installButton.onclick = () => sdk.install();
436
- *
436
+ *
437
437
  * @fires finish If the ad hasn't been marked as finished
438
438
  * @fires install When the install action is triggered
439
439
  */
@@ -458,7 +458,7 @@
458
458
  }, 500);
459
459
  emitEvent("install");
460
460
  if ("mraid" === AD_PROTOCOL && isMraid()) {
461
- mraid.openStoreUrl ? mraid.openStoreUrl() : mraid.open(destinationUrl);
461
+ mraid.open(destinationUrl);
462
462
  } else if ("dapi" === AD_PROTOCOL && isDapi()) {
463
463
  dapi.openStoreUrl();
464
464
  } else if ("nucleo" === AD_PROTOCOL && isNucleo()) {
@@ -482,10 +482,10 @@
482
482
  /**
483
483
  * Trigger force resize event
484
484
  * Useful when container size changes need to be manually propagated.
485
- *
485
+ *
486
486
  * @example
487
487
  * sdk.resize();
488
- *
488
+ *
489
489
  * @fires resize With current maxWidth and maxHeight
490
490
  */
491
491
  static resize() {
@@ -493,11 +493,11 @@
493
493
  }
494
494
  /**
495
495
  * Forces the playable ad into a paused state.
496
- *
496
+ *
497
497
  * @example
498
498
  * // Pause the experience
499
499
  * pauseButton.onclick = () => sdk.pause();
500
- *
500
+ *
501
501
  * @fires pause When the ad enters paused state
502
502
  */
503
503
  static pause() {
@@ -509,11 +509,11 @@
509
509
  /**
510
510
  * Resumes the playable ad from a forced pause state.
511
511
  * Only works if the ad was paused via sdk.pause().
512
- *
512
+ *
513
513
  * @example
514
514
  * // Resume from pause
515
515
  * resumeButton.onclick = () => sdk.resume();
516
- *
516
+ *
517
517
  * @fires resume When the ad resumes from pause
518
518
  */
519
519
  static resume() {
@@ -524,17 +524,17 @@
524
524
  }
525
525
  /**
526
526
  * Registers an event listener.
527
- *
527
+ *
528
528
  * @param event Name of the event to listen for
529
529
  * @param fn Callback function to execute when event occurs
530
530
  * @param context Optional 'this' context for the callback
531
- *
531
+ *
532
532
  * @example
533
533
  * // Listen for user interactions
534
534
  * sdk.on('interaction', (count) => {
535
535
  * console.log(`User interaction #${count}`);
536
536
  * });
537
- *
537
+ *
538
538
  * // Listen for resize with context
539
539
  * sdk.on('resize', function(width, height) {
540
540
  * this.updateLayout(width, height);
@@ -545,11 +545,11 @@
545
545
  }
546
546
  /**
547
547
  * Registers a one-time event listener that removes itself after execution.
548
- *
548
+ *
549
549
  * @param event Name of the event to listen for
550
550
  * @param fn Callback function to execute when event occurs
551
551
  * @param context Optional 'this' context for the callback
552
- *
552
+ *
553
553
  * @example
554
554
  * // Listen for first interaction only
555
555
  * sdk.once('interaction', () => {
@@ -561,16 +561,16 @@
561
561
  }
562
562
  /**
563
563
  * Removes an event listener.
564
- *
564
+ *
565
565
  * @param event Name of the event to stop listening for
566
566
  * @param fn Optional callback function to remove (if not provided, removes all listeners for the event)
567
567
  * @param context Optional 'this' context to match when removing
568
- *
568
+ *
569
569
  * @example
570
570
  * // Remove specific listener
571
571
  * const handler = () => console.log('Interaction');
572
572
  * sdk.off('interaction', handler);
573
- *
573
+ *
574
574
  * // Remove all listeners for an event
575
575
  * sdk.off('interaction');
576
576
  */
@@ -579,7 +579,7 @@
579
579
  }
580
580
  };
581
581
  /** Current version of the SDK */
582
- _sdk.version = "1.0.0";
582
+ _sdk.version = "1.0.1";
583
583
  /** Current maximum width of the playable ad container in pixels */
584
584
  _sdk.maxWidth = Math.floor(window.innerWidth);
585
585
  /** Current maximum height of the playable ad container in pixels */
package/dist/index.js CHANGED
@@ -247,10 +247,10 @@ function startDapiProtocol() {
247
247
  if ("dapi" !== AD_PROTOCOL) return;
248
248
  if (!isProtocolInitialized) {
249
249
  dapi.removeEventListener("ready", startDapiProtocol);
250
- var isAudioEnabled = !!dapi.getAudioVolume();
250
+ dapi.getAudioVolume();
251
251
  dapi.addEventListener("audioVolumeChange", function(volume) {
252
- var isAudioEnabled2 = !!volume;
253
- if (isAudioEnabled2) {
252
+ var isAudioEnabled = !!volume;
253
+ if (isAudioEnabled) {
254
254
  changeVolume(sdk.volume);
255
255
  } else {
256
256
  changeVolume(0);
@@ -347,17 +347,17 @@ var _sdk = class _sdk {
347
347
  /**
348
348
  * Initializes the SDK and sets up protocol-specific handlers.
349
349
  * This must be called as earlier as possible.
350
- *
350
+ *
351
351
  * @param callback Optional function called when ad container is ready
352
352
  * @example
353
353
  * // Basic initialization
354
354
  * sdk.init();
355
- *
355
+ *
356
356
  * // Initialization with callback
357
357
  * sdk.init((width, height) => {
358
358
  * new App(width, height)
359
359
  * });
360
- *
360
+ *
361
361
  * @fires init When initialization starts
362
362
  * @fires boot When the ad begins booting
363
363
  * @fires ready When Ad Network is ready and playable ad can be initialized
@@ -385,11 +385,11 @@ var _sdk = class _sdk {
385
385
  /**
386
386
  * Starts the playable ad experience.
387
387
  * Should be called after all resources are loaded and first frame is rendered.
388
- *
388
+ *
389
389
  * @example
390
390
  * // Call just after all resources are preloaded and first frame is rendered
391
391
  * sdk.start();
392
- *
392
+ *
393
393
  * @fires start When the playable ad starts
394
394
  * @fires resize When the ad container is initially sized
395
395
  */
@@ -406,7 +406,7 @@ var _sdk = class _sdk {
406
406
  if ("tapjoy" === AD_NETWORK && isTapjoy()) {
407
407
  window.TJ_API.setPlayableBuild({
408
408
  orientation: this.isLandscape ? "landscape" : "portrait",
409
- buildID: __BUILD_ID__
409
+ buildID: BUILD_HASH
410
410
  });
411
411
  }
412
412
  _sdk.resize();
@@ -415,11 +415,11 @@ var _sdk = class _sdk {
415
415
  /**
416
416
  * Marks the playable ad as finished.
417
417
  * This triggers network-specific completion handlers.
418
- *
418
+ *
419
419
  * @example
420
420
  * // Call when game/experience is complete
421
421
  * sdk.finish();
422
- *
422
+ *
423
423
  * @fires finish When the playable ad is marked as finished
424
424
  */
425
425
  static finish() {
@@ -436,11 +436,11 @@ var _sdk = class _sdk {
436
436
  /**
437
437
  * Triggers a retry/restart of the playable ad.
438
438
  * Behavior varies by ad network.
439
- *
439
+ *
440
440
  * @example
441
441
  * // Allow user to try again
442
442
  * retryButton.onclick = () => sdk.retry();
443
- *
443
+ *
444
444
  * @fires retry When a retry is triggered
445
445
  */
446
446
  static retry() {
@@ -454,11 +454,11 @@ var _sdk = class _sdk {
454
454
  /**
455
455
  * Triggers the install/download action for the advertised app.
456
456
  * Handles different store opening methods across ad networks.
457
- *
457
+ *
458
458
  * @example
459
459
  * // Call when user wants to install
460
460
  * installButton.onclick = () => sdk.install();
461
- *
461
+ *
462
462
  * @fires finish If the ad hasn't been marked as finished
463
463
  * @fires install When the install action is triggered
464
464
  */
@@ -483,7 +483,7 @@ var _sdk = class _sdk {
483
483
  }, 500);
484
484
  emitEvent("install");
485
485
  if ("mraid" === AD_PROTOCOL && isMraid()) {
486
- mraid.openStoreUrl ? mraid.openStoreUrl() : mraid.open(destinationUrl);
486
+ mraid.open(destinationUrl);
487
487
  } else if ("dapi" === AD_PROTOCOL && isDapi()) {
488
488
  dapi.openStoreUrl();
489
489
  } else if ("nucleo" === AD_PROTOCOL && isNucleo()) {
@@ -507,10 +507,10 @@ var _sdk = class _sdk {
507
507
  /**
508
508
  * Trigger force resize event
509
509
  * Useful when container size changes need to be manually propagated.
510
- *
510
+ *
511
511
  * @example
512
512
  * sdk.resize();
513
- *
513
+ *
514
514
  * @fires resize With current maxWidth and maxHeight
515
515
  */
516
516
  static resize() {
@@ -518,11 +518,11 @@ var _sdk = class _sdk {
518
518
  }
519
519
  /**
520
520
  * Forces the playable ad into a paused state.
521
- *
521
+ *
522
522
  * @example
523
523
  * // Pause the experience
524
524
  * pauseButton.onclick = () => sdk.pause();
525
- *
525
+ *
526
526
  * @fires pause When the ad enters paused state
527
527
  */
528
528
  static pause() {
@@ -534,11 +534,11 @@ var _sdk = class _sdk {
534
534
  /**
535
535
  * Resumes the playable ad from a forced pause state.
536
536
  * Only works if the ad was paused via sdk.pause().
537
- *
537
+ *
538
538
  * @example
539
539
  * // Resume from pause
540
540
  * resumeButton.onclick = () => sdk.resume();
541
- *
541
+ *
542
542
  * @fires resume When the ad resumes from pause
543
543
  */
544
544
  static resume() {
@@ -549,17 +549,17 @@ var _sdk = class _sdk {
549
549
  }
550
550
  /**
551
551
  * Registers an event listener.
552
- *
552
+ *
553
553
  * @param event Name of the event to listen for
554
554
  * @param fn Callback function to execute when event occurs
555
555
  * @param context Optional 'this' context for the callback
556
- *
556
+ *
557
557
  * @example
558
558
  * // Listen for user interactions
559
559
  * sdk.on('interaction', (count) => {
560
560
  * console.log(`User interaction #${count}`);
561
561
  * });
562
- *
562
+ *
563
563
  * // Listen for resize with context
564
564
  * sdk.on('resize', function(width, height) {
565
565
  * this.updateLayout(width, height);
@@ -570,11 +570,11 @@ var _sdk = class _sdk {
570
570
  }
571
571
  /**
572
572
  * Registers a one-time event listener that removes itself after execution.
573
- *
573
+ *
574
574
  * @param event Name of the event to listen for
575
575
  * @param fn Callback function to execute when event occurs
576
576
  * @param context Optional 'this' context for the callback
577
- *
577
+ *
578
578
  * @example
579
579
  * // Listen for first interaction only
580
580
  * sdk.once('interaction', () => {
@@ -586,16 +586,16 @@ var _sdk = class _sdk {
586
586
  }
587
587
  /**
588
588
  * Removes an event listener.
589
- *
589
+ *
590
590
  * @param event Name of the event to stop listening for
591
591
  * @param fn Optional callback function to remove (if not provided, removes all listeners for the event)
592
592
  * @param context Optional 'this' context to match when removing
593
- *
593
+ *
594
594
  * @example
595
595
  * // Remove specific listener
596
596
  * const handler = () => console.log('Interaction');
597
597
  * sdk.off('interaction', handler);
598
- *
598
+ *
599
599
  * // Remove all listeners for an event
600
600
  * sdk.off('interaction');
601
601
  */
@@ -604,7 +604,7 @@ var _sdk = class _sdk {
604
604
  }
605
605
  };
606
606
  /** Current version of the SDK */
607
- _sdk.version = "1.0.0";
607
+ _sdk.version = "1.0.1";
608
608
  /** Current maximum width of the playable ad container in pixels */
609
609
  _sdk.maxWidth = Math.floor(window.innerWidth);
610
610
  /** Current maximum height of the playable ad container in pixels */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@smoud/playable-sdk",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
4
4
  "description": "It's unified Playable SDK that supports MRAID, Google, Facebook, Vungle, and many more Ad Networks, simplifying playable ad development with a standardized interface for seamless cross-network compatibility.",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/esm/index.js",
@@ -21,7 +21,8 @@
21
21
  ],
22
22
  "scripts": {
23
23
  "build": "npx tsup src/index.ts --format esm,cjs,iife --out-dir dist --legacy-output --dts --clean",
24
- "test": "jest"
24
+ "test": "jest",
25
+ "publish": "npm run test && npm run build && npm publish --access public"
25
26
  },
26
27
  "author": "Smoud",
27
28
  "license": "MIT",