@playcraft/adsdk 1.0.13 → 1.0.14-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.
package/dist/index.js CHANGED
@@ -24,8 +24,7 @@ __export(index_exports, {
24
24
  hideWechatGuide: () => hideWechatGuide,
25
25
  removeWechatGuide: () => removeWechatGuide,
26
26
  sdk: () => sdk,
27
- showWechatGuide: () => showWechatGuide,
28
- tracking: () => tracking
27
+ showWechatGuide: () => showWechatGuide
29
28
  });
30
29
  module.exports = __toCommonJS(index_exports);
31
30
 
@@ -188,275 +187,23 @@ function ensureProtocol() {
188
187
  }
189
188
  }
190
189
 
191
- // src/tracking.ts
192
- function getCurrentAdNetwork(adNetwork) {
193
- const network = adNetwork || (typeof AD_NETWORK !== "undefined" ? AD_NETWORK : "");
194
- const supportedNetworks = ["bigabid", "inmobi", "applovin"];
195
- if (supportedNetworks.includes(network)) {
196
- return network;
197
- }
198
- return null;
199
- }
200
- function trackURL(url) {
201
- if (url) {
202
- const trackingPixel = new Image();
203
- trackingPixel.src = url;
204
- }
205
- }
206
- function trackBigabidEvent(event) {
207
- console.log(" trackBigabidEvent", event);
208
- if (window.BIGABID_BIDTIMEMACROS && window.BIGABID_BIDTIMEMACROS[event]) {
209
- trackURL(window.BIGABID_BIDTIMEMACROS[event]);
210
- }
211
- }
212
- function trackInMobiEvent(event) {
213
- console.log(" trackInMobiEvent", event);
214
- if (window.INMOBI_DSPMACROS && window.INMOBI_DSPMACROS[event]) {
215
- trackURL(window.INMOBI_DSPMACROS[event]);
216
- }
217
- }
218
- function trackApplovinEvent(event) {
219
- console.log(" trackApplovinEvent", event);
220
- if (typeof window.ALPlayableAnalytics !== "undefined") {
221
- window.ALPlayableAnalytics.trackEvent(event);
222
- }
223
- }
224
- var bigabidCompleteTriggered = false;
225
- function trackBigabidComplete() {
226
- if (!bigabidCompleteTriggered) {
227
- trackBigabidEvent("complete");
228
- bigabidCompleteTriggered = true;
229
- }
230
- }
231
- var inmobiTimers = [];
232
- function startInMobiDurationTracking() {
233
- const durations = [5, 10, 15, 20, 25, 30];
234
- for (const sec of durations) {
235
- const timer = setTimeout(() => trackInMobiEvent(`Spent_${sec}_Seconds`), sec * 1e3);
236
- inmobiTimers.push(timer);
237
- }
238
- }
239
- function clearInMobiDurationTracking() {
240
- for (const timer of inmobiTimers) {
241
- clearTimeout(timer);
242
- }
243
- inmobiTimers = [];
244
- }
245
- var totalInteractions = 0;
246
- var progressMilestones = [];
247
- function setTotalInteractions(total) {
248
- totalInteractions = total;
249
- }
250
- function initProgressMilestones(adNetwork) {
251
- if (totalInteractions <= 0) return;
252
- const network = getCurrentAdNetwork(adNetwork);
253
- if (!network) return;
254
- if (network === "applovin") {
255
- progressMilestones = [
256
- { percent: 25, triggered: false, callback: () => trackApplovinEvent("CHALLENGE_PASS_25") },
257
- { percent: 50, triggered: false, callback: () => trackApplovinEvent("CHALLENGE_PASS_50") },
258
- { percent: 75, triggered: false, callback: () => trackApplovinEvent("CHALLENGE_PASS_75") },
259
- { percent: 100, triggered: false, callback: () => _trackChallengeSuccess(adNetwork) }
260
- ];
261
- } else if (network === "bigabid") {
262
- progressMilestones = [
263
- { percent: 100, triggered: false, callback: () => _trackChallengeSuccess(adNetwork) }
264
- ];
265
- }
266
- }
267
- function checkInteractionProgress(currentInteractions) {
268
- if (totalInteractions <= 0 || progressMilestones.length === 0) return;
269
- const currentPercent = currentInteractions / totalInteractions * 100;
270
- for (const milestone of progressMilestones) {
271
- if (!milestone.triggered && currentPercent >= milestone.percent) {
272
- milestone.triggered = true;
273
- milestone.callback();
274
- }
275
- }
276
- }
277
- function _onInit(adNetwork) {
278
- initProgressMilestones(adNetwork);
279
- const network = getCurrentAdNetwork(adNetwork);
280
- if (!network) return;
281
- if (network === "bigabid") {
282
- trackBigabidEvent("mraid_viewable");
283
- }
284
- if (network === "inmobi") {
285
- trackInMobiEvent("Ad_Load_Start");
286
- }
287
- if (network === "applovin") {
288
- trackApplovinEvent("LOADING");
289
- }
290
- }
291
- function _onStart(adNetwork) {
292
- const network = getCurrentAdNetwork(adNetwork);
293
- if (!network) return;
294
- if (network === "bigabid") {
295
- trackBigabidEvent("game_viewable");
296
- }
297
- if (network === "inmobi") {
298
- trackInMobiEvent("Ad_Viewable");
299
- startInMobiDurationTracking();
300
- }
301
- if (network === "applovin") {
302
- trackApplovinEvent("LOADED");
303
- }
304
- }
305
- function _onInteractive(adNetwork) {
306
- const network = getCurrentAdNetwork(adNetwork);
307
- if (!network) return;
308
- if (network === "applovin") {
309
- trackApplovinEvent("DISPLAYED");
310
- }
311
- }
312
- function _onInteraction(adNetwork) {
313
- const network = getCurrentAdNetwork(adNetwork);
314
- if (!network) return;
315
- if (network === "bigabid") {
316
- trackBigabidEvent("engagement");
317
- }
318
- if (network === "inmobi") {
319
- trackInMobiEvent("First_Engagement");
320
- }
321
- if (network === "applovin") {
322
- trackApplovinEvent("CHALLENGE_STARTED");
323
- }
324
- }
325
- function _onSuccess(successCount) {
326
- checkInteractionProgress(successCount);
327
- }
328
- function _onFinish(adNetwork) {
329
- const network = getCurrentAdNetwork(adNetwork);
330
- if (!network) return;
331
- if (network === "bigabid") {
332
- trackBigabidComplete();
333
- }
334
- if (network === "inmobi") {
335
- trackInMobiEvent("Gameplay_Complete");
336
- clearInMobiDurationTracking();
337
- }
338
- if (network === "applovin") {
339
- trackApplovinEvent("ENDCARD_SHOWN");
340
- }
341
- }
342
- function _onInstall(adNetwork) {
343
- const network = getCurrentAdNetwork(adNetwork);
344
- if (!network) return;
345
- if (network === "bigabid") {
346
- trackBigabidEvent("click");
347
- }
348
- if (network === "inmobi") {
349
- trackInMobiEvent("DSP_Click");
350
- clearInMobiDurationTracking();
351
- }
352
- if (network === "applovin") {
353
- trackApplovinEvent("CTA_CLICKED");
354
- }
355
- }
356
- function _onRetry(adNetwork) {
357
- const network = getCurrentAdNetwork(adNetwork);
358
- if (!network) return;
359
- if (network === "applovin") {
360
- trackApplovinEvent("CHALLENGE_RETRY");
361
- }
362
- }
363
- function _trackChallengeSuccess(adNetwork) {
364
- const network = getCurrentAdNetwork(adNetwork);
365
- if (!network) return;
366
- if (network === "applovin") {
367
- trackApplovinEvent("CHALLENGE_SOLVED");
368
- }
369
- if (network === "bigabid") {
370
- trackBigabidComplete();
371
- }
372
- if (network === "inmobi") {
373
- trackInMobiEvent("Gameplay_Complete");
374
- }
375
- }
376
- function _trackChallengeFailed(adNetwork) {
377
- const network = getCurrentAdNetwork(adNetwork);
378
- if (!network) return;
379
- if (network === "applovin") {
380
- trackApplovinEvent("CHALLENGE_FAILED");
381
- }
382
- }
383
- var tracking = {
384
- /**
385
- * SDK 初始化开始
386
- * @param adNetwork - 可选的广告渠道名称
387
- */
388
- onInit: _onInit,
389
- /**
390
- * 游戏资源加载完成
391
- * @param adNetwork - 可选的广告渠道名称
392
- */
393
- onStart: _onStart,
394
- /**
395
- * 主场景就绪,用户可交互
396
- * @param adNetwork - 可选的广告渠道名称
397
- */
398
- onInteractive: _onInteractive,
399
- /**
400
- * 首次交互
401
- * @param adNetwork - 可选的广告渠道名称
402
- */
403
- onInteraction: _onInteraction,
404
- /**
405
- * 成功计数(用于进度百分比追踪)
406
- * @param successCount - 当前成功次数
407
- */
408
- onSuccess: _onSuccess,
409
- /**
410
- * 游戏结束
411
- * @param adNetwork - 可选的广告渠道名称
412
- */
413
- onFinish: _onFinish,
414
- /**
415
- * 点击安装
416
- * @param adNetwork - 可选的广告渠道名称
417
- */
418
- onInstall: _onInstall,
419
- /**
420
- * 重试游戏
421
- * @param adNetwork - 可选的广告渠道名称
422
- */
423
- onRetry: _onRetry,
424
- /**
425
- * 设置交互总数(用于进度百分比计算)
426
- * @param total - 交互总数
427
- */
428
- setTotalInteractions,
429
- /**
430
- * 检查交互进度
431
- * @param currentInteractions - 当前交互次数
432
- */
433
- checkInteractionProgress,
434
- /**
435
- * 触发游戏成功事件
436
- * @param adNetwork - 可选的广告渠道名称
437
- */
438
- trackChallengeSuccess: _trackChallengeSuccess,
439
- /**
440
- * 触发游戏失败事件
441
- * @param adNetwork - 可选的广告渠道名称
442
- */
443
- trackChallengeFailed: _trackChallengeFailed
444
- };
445
-
446
190
  // src/tracking-init.ts
191
+ var import_ads_tracking = require("@playcraft/ads-tracking");
447
192
  function initTrackingProtocols() {
448
193
  const supportedNetworks = ["bigabid", "inmobi", "applovin"];
449
194
  if (!supportedNetworks.includes(AD_NETWORK)) {
450
195
  return;
451
196
  }
452
- sdk.once("init", tracking.onInit);
453
- sdk.once("start", tracking.onStart);
454
- sdk.once("interactive", tracking.onInteractive);
455
- sdk.once("interaction", tracking.onInteraction);
456
- sdk.on("success", tracking.onSuccess);
457
- sdk.once("finish", tracking.onFinish);
458
- sdk.on("install", tracking.onInstall);
459
- sdk.once("retry", tracking.onRetry);
197
+ sdk.once("playcraftInit", import_ads_tracking.tracking.onPlaycraftTrackingInit);
198
+ sdk.once("playcraftStart", import_ads_tracking.tracking.onPlaycraftTrackingLoading);
199
+ sdk.once("playcraftInteractive", import_ads_tracking.tracking.onPlaycraftTrackingLoaded);
200
+ sdk.on("playcraftChallengeStart", import_ads_tracking.tracking.onPlaycraftChallengeStart);
201
+ sdk.on("playcraftChallengeProgress", import_ads_tracking.tracking.onPlaycraftChallengeProgress);
202
+ sdk.once("playcraftFinish", import_ads_tracking.tracking.onPlaycraftChallengeFinish);
203
+ sdk.on("playcraftInstall", import_ads_tracking.tracking.onPlaycraftInstall);
204
+ sdk.once("playcraftRetry", import_ads_tracking.tracking.onPlaycraftRetry);
205
+ sdk.on("playcraftChallengeSuccess", import_ads_tracking.tracking.onPlaycraftChallengeSuccess);
206
+ sdk.on("playcraftChallengeFailed", import_ads_tracking.tracking.onPlaycraftChallengeFailed);
460
207
  }
461
208
 
462
209
  // src/assets/images.ts
@@ -802,16 +549,16 @@ var initCallback = () => {
802
549
  };
803
550
  function bootAd() {
804
551
  if (sdk.isReady) return;
805
- emitEvent("init");
552
+ emitEvent("playcraftInit");
806
553
  document.body.oncontextmenu = function() {
807
554
  return false;
808
555
  };
809
556
  initCallback(sdk.maxWidth, sdk.maxHeight);
810
- emitEvent("ready");
557
+ emitEvent("playcraftReady");
811
558
  sdk.isReady = true;
812
559
  }
813
560
  function fireVolumeChange(value) {
814
- emitEvent("volume", value);
561
+ emitEvent("playcraftVolume", value);
815
562
  }
816
563
  function changeVolume(value) {
817
564
  sdk.volume = value;
@@ -824,13 +571,13 @@ function handleVolumeChange(value) {
824
571
  function handlePause() {
825
572
  changeVolume(0);
826
573
  sdk.isPaused = true;
827
- emitEvent("pause");
574
+ emitEvent("playcraftPause");
828
575
  }
829
576
  function handleResume() {
830
577
  if (isForcePaused) return;
831
578
  changeVolume(actualVolume);
832
579
  sdk.isPaused = false;
833
- emitEvent("resume");
580
+ emitEvent("playcraftResume");
834
581
  }
835
582
  function fireResizeEvent(width, height) {
836
583
  handleResize(width, height);
@@ -1013,7 +760,7 @@ function startDefaultProtocol() {
1013
760
  const tapjoyApi = {
1014
761
  skipAd: function() {
1015
762
  try {
1016
- sdk.finish();
763
+ sdk.playcraftFinish();
1017
764
  } catch (e) {
1018
765
  console.warn("Could not skip ad! | " + e);
1019
766
  }
@@ -1032,7 +779,7 @@ function handleResize(width, height) {
1032
779
  sdk.maxWidth = Math.floor(width || window.innerWidth);
1033
780
  sdk.maxHeight = Math.floor(height || window.innerHeight);
1034
781
  sdk.isLandscape = sdk.maxWidth > sdk.maxHeight;
1035
- emitEvent("resize", sdk.maxWidth, sdk.maxHeight);
782
+ emitEvent("playcraftResize", sdk.maxWidth, sdk.maxHeight);
1036
783
  }
1037
784
  var isListeningToTouchEvents = false;
1038
785
  var isTouchEventRegistered = false;
@@ -1042,7 +789,7 @@ function onUserInteraction(event) {
1042
789
  }
1043
790
  if (isListeningToTouchEvents && event instanceof MouseEvent) return;
1044
791
  sdk.interactions += 1;
1045
- emitEvent("interaction", sdk.interactions);
792
+ emitEvent("playcraftInteraction", sdk.interactions);
1046
793
  }
1047
794
  function registerTouchHandlers() {
1048
795
  if (!isTouchEventRegistered) {
@@ -1126,35 +873,21 @@ var _sdk = class _sdk {
1126
873
  * This must be called as earlier as possible.
1127
874
  *
1128
875
  * @param callback Optional function called when ad container is ready
1129
- * @param options Optional configuration options
1130
- * @param options.totalSuccessCount Total number of successful actions expected for progress tracking.
1131
- * When set, the SDK will track success progress as a percentage and trigger
1132
- * channel-specific milestone events (e.g., AppLovin: CHALLENGE_PASS_25/50/75, CHALLENGE_SOLVED).
1133
- * Different channels monitor different percentage thresholds independently.
1134
- * Set to 0 or omit to disable progress tracking.
1135
876
  * @example
1136
877
  * // Basic initialization
1137
- * sdk.init();
878
+ * sdk.playcraftInit();
1138
879
  *
1139
880
  * // Initialization with callback
1140
- * sdk.init((width, height) => {
881
+ * sdk.playcraftInit((width, height) => {
1141
882
  * new App(width, height)
1142
883
  * });
1143
884
  *
1144
- * // Initialization with success count progress tracking
1145
- * sdk.init((width, height) => {
1146
- * new App(width, height)
1147
- * }, { totalSuccessCount: 20 });
1148
- *
1149
- * @fires loading When SDK initialization starts
1150
- * @fires loaded When game instance is created and ready to load resources
885
+ * @fires playcraftInit When SDK initialization starts
886
+ * @fires playcraftReady When game instance is created and ready to load resources
1151
887
  */
1152
- static init(callback, options) {
888
+ static playcraftInit(callback) {
1153
889
  if (isSDKInitialized) return;
1154
890
  if (callback) initCallback = callback;
1155
- if ((options == null ? void 0 : options.totalSuccessCount) && options.totalSuccessCount > 0) {
1156
- tracking.setTotalInteractions(options.totalSuccessCount);
1157
- }
1158
891
  initTrackingProtocols();
1159
892
  document.readyState === "loading" ? window.addEventListener("DOMContentLoaded", initSDK) : initSDK();
1160
893
  isSDKInitialized = true;
@@ -1164,25 +897,24 @@ var _sdk = class _sdk {
1164
897
  * Should be called after all resources are loaded and first frame is rendered.
1165
898
  *
1166
899
  * @example
1167
- * // Call just after all resources are preloaded and first frame is rendered
1168
- * sdk.start();
900
+ * sdk.playcraftStart();
1169
901
  *
1170
- * @fires start When the playable ad starts
1171
- * @fires resize When the ad container is initially sized
902
+ * @fires playcraftStart When the playable ad starts
903
+ * @fires playcraftResize When the ad container is initially sized
1172
904
  */
1173
- static start() {
905
+ static playcraftStart() {
1174
906
  if (_sdk.isStarted) return;
1175
907
  _sdk.isStarted = true;
1176
- emitEvent("start");
908
+ emitEvent("playcraftStart");
1177
909
  registerTouchHandlers();
1178
910
  if ("mintegral" === AD_NETWORK && isMintegral()) {
1179
- _sdk.resize();
911
+ _sdk.playcraftResize();
1180
912
  handlePause();
1181
913
  window.gameReady && window.gameReady();
1182
914
  } else if ("bigoads" === AD_NETWORK && isBigoAds()) {
1183
915
  window.BGY_MRAID && window.BGY_MRAID.gameReady && window.BGY_MRAID.gameReady();
1184
916
  fireVolumeChange(_sdk.volume);
1185
- _sdk.resize();
917
+ _sdk.playcraftResize();
1186
918
  } else {
1187
919
  if ("tapjoy" === AD_NETWORK && isTapjoy()) {
1188
920
  window.TJ_API.setPlayableBuild({
@@ -1191,7 +923,7 @@ var _sdk = class _sdk {
1191
923
  });
1192
924
  }
1193
925
  fireVolumeChange(_sdk.volume);
1194
- _sdk.resize();
926
+ _sdk.playcraftResize();
1195
927
  }
1196
928
  }
1197
929
  /**
@@ -1199,28 +931,39 @@ var _sdk = class _sdk {
1199
931
  * Should be called at the end of your main game scene's create() method.
1200
932
  *
1201
933
  * @example
1202
- * // In Phaser MainScene.create()
1203
934
  * create() {
1204
935
  * // ... all initialization code ...
1205
- * sdk.interactive();
936
+ * sdk.playcraftInteractive();
1206
937
  * }
1207
938
  *
1208
- * @fires interactive When the main scene is ready for user interaction
939
+ * @fires playcraftInteractive When the main scene is ready for user interaction
1209
940
  */
1210
- static interactive() {
1211
- emitEvent("interactive");
941
+ static playcraftInteractive() {
942
+ emitEvent("playcraftInteractive");
943
+ }
944
+ /**
945
+ * Marks the challenge as started.
946
+ * Should be called by business logic when the user actually starts playing.
947
+ *
948
+ * @example
949
+ * onFirstClick() {
950
+ * sdk.playcraftChallengeStart();
951
+ * }
952
+ *
953
+ * @fires playcraftChallengeStart When the challenge starts
954
+ */
955
+ static playcraftChallengeStart() {
956
+ emitEvent("playcraftChallengeStart");
1212
957
  }
1213
958
  /**
1214
959
  * Marks the playable ad as finished.
1215
- * This triggers network-specific completion handlers.
1216
960
  *
1217
961
  * @example
1218
- * // Call when game/experience is complete
1219
- * sdk.finish();
962
+ * sdk.playcraftFinish();
1220
963
  *
1221
- * @fires finish When the playable ad is marked as finished
964
+ * @fires playcraftFinish When the playable ad is marked as finished
1222
965
  */
1223
- static finish() {
966
+ static playcraftFinish() {
1224
967
  _sdk.isFinished = true;
1225
968
  if ("tapjoy" === AD_NETWORK && isTapjoy()) {
1226
969
  finishTapjoy();
@@ -1240,38 +983,34 @@ var _sdk = class _sdk {
1240
983
  console.warn("Could not call mraid.close():", e);
1241
984
  }
1242
985
  }
1243
- emitEvent("finish");
986
+ emitEvent("playcraftFinish");
1244
987
  }
1245
988
  /**
1246
989
  * Triggers a retry/restart of the playable ad.
1247
- * Behavior varies by ad network.
1248
990
  *
1249
991
  * @example
1250
- * // Allow user to try again
1251
- * retryButton.onclick = () => sdk.retry();
992
+ * retryButton.onclick = () => sdk.playcraftRetry();
1252
993
  *
1253
- * @fires retry When a retry is triggered
994
+ * @fires playcraftRetry When a retry is triggered
1254
995
  */
1255
- static retry() {
996
+ static playcraftRetry() {
1256
997
  if ("mintegral" === AD_NETWORK && isMintegral()) {
1257
998
  } else if ("nucleo" === AD_PROTOCOL && isNucleo()) {
1258
999
  NUC.trigger.tryAgain();
1259
1000
  }
1260
- emitEvent("retry");
1001
+ emitEvent("playcraftRetry");
1261
1002
  }
1262
1003
  /**
1263
1004
  * Triggers the install/download action for the advertised app.
1264
- * Handles different store opening methods across ad networks.
1265
1005
  *
1266
1006
  * @example
1267
- * // Call when user wants to install
1268
- * installButton.onclick = () => sdk.install();
1007
+ * installButton.onclick = () => sdk.playcraftInstall();
1269
1008
  *
1270
- * @fires finish If the ad hasn't been marked as finished
1271
- * @fires install When the install action is triggered
1009
+ * @fires playcraftFinish If the ad hasn't been marked as finished
1010
+ * @fires playcraftInstall When the install action is triggered
1272
1011
  */
1273
- static install(params) {
1274
- console.log("[SDK] install() called, interactions:", _sdk.interactions, "isFinished:", _sdk.isFinished, "isInstallClicked:", isInstallClicked);
1012
+ static playcraftInstall(params) {
1013
+ console.log("[SDK] playcraftInstall() called, interactions:", _sdk.interactions, "isFinished:", _sdk.isFinished, "isInstallClicked:", isInstallClicked);
1275
1014
  if (_sdk.interactions < 1 && isDisableFirstClickToOpenApp()) {
1276
1015
  console.log("[SDK] \u9996\u6B21\u70B9\u51FB\u4FDD\u62A4\uFF0C\u76F4\u63A5\u8FD4\u56DE");
1277
1016
  return;
@@ -1281,23 +1020,23 @@ var _sdk = class _sdk {
1281
1020
  return;
1282
1021
  }
1283
1022
  const timeout = setTimeout(function() {
1284
- _sdk.install();
1023
+ _sdk.playcraftInstall();
1285
1024
  clearTimeout(timeout);
1286
1025
  }, params.timeout || 3e3);
1287
1026
  return;
1288
1027
  }
1289
1028
  if (!_sdk.isFinished) {
1290
- console.log("[SDK] \u9996\u6B21\u6267\u884C install\uFF0C\u89E6\u53D1 finish \u4E8B\u4EF6");
1029
+ console.log("[SDK] \u9996\u6B21\u6267\u884C playcraftInstall\uFF0C\u89E6\u53D1 playcraftFinish \u4E8B\u4EF6");
1291
1030
  _sdk.isFinished = true;
1292
1031
  let timeout = 0;
1293
1032
  if ("tapjoy" === AD_NETWORK && isTapjoy()) {
1294
1033
  finishTapjoy();
1295
1034
  timeout = 300;
1296
1035
  }
1297
- emitEvent("finish");
1036
+ emitEvent("playcraftFinish");
1298
1037
  setTimeout(function() {
1299
- console.log("[SDK] \u5F02\u6B65\u9012\u5F52\u8C03\u7528 install()");
1300
- _sdk.install();
1038
+ console.log("[SDK] \u5F02\u6B65\u9012\u5F52\u8C03\u7528 playcraftInstall()");
1039
+ _sdk.playcraftInstall();
1301
1040
  }, timeout);
1302
1041
  return;
1303
1042
  }
@@ -1310,7 +1049,7 @@ var _sdk = class _sdk {
1310
1049
  isInstallClicked = false;
1311
1050
  console.log("[SDK] \u9632\u6296\u89E3\u9501");
1312
1051
  }, 500);
1313
- emitEvent("install");
1052
+ emitEvent("playcraftInstall");
1314
1053
  console.log("Ad_Protocal: ", AD_PROTOCOL);
1315
1054
  if ("mraid" === AD_PROTOCOL && isMraid()) {
1316
1055
  try {
@@ -1374,39 +1113,30 @@ var _sdk = class _sdk {
1374
1113
  }
1375
1114
  /**
1376
1115
  * Trigger force resize event
1377
- * Useful when container size changes need to be manually propagated.
1378
1116
  *
1379
1117
  * @example
1380
- * sdk.resize();
1118
+ * sdk.playcraftResize();
1381
1119
  *
1382
- * @fires resize With current maxWidth and maxHeight
1120
+ * @fires playcraftResize With current maxWidth and maxHeight
1383
1121
  */
1384
- static resize() {
1122
+ static playcraftResize() {
1385
1123
  handleResize(_sdk.maxWidth, _sdk.maxHeight);
1386
1124
  }
1387
1125
  /**
1388
- * Records successful game actions (e.g., successful match, level clear).
1389
- * This should be called by game logic when a meaningful success occurs.
1390
- * This count is used for progress tracking (e.g., AppLovin milestone events).
1126
+ * Records playable ad challenge progress (0-100).
1127
+ * Triggers channel-specific milestone events based on the progress value.
1128
+ * Milestones are not re-triggered once fired.
1129
+ *
1130
+ * @param percent Progress percentage (0-100)
1391
1131
  *
1392
- * @param count Optional success count to add (default: 1)
1393
- *
1394
1132
  * @example
1395
- * // Record single success when match completes
1396
- * onMatchSuccess() {
1397
- * sdk.recordSuccessCount();
1398
- * }
1399
- *
1400
- * // Record multiple successes at once
1401
- * onComboMatch(comboCount) {
1402
- * sdk.recordSuccessCount(comboCount);
1403
- * }
1133
+ * // Report 50% progress
1134
+ * sdk.recordPlaycraftChallengeProgress(50);
1404
1135
  *
1405
- * @fires success With updated success count (triggers progress tracking)
1136
+ * @fires playcraftChallengeProgress With the progress percentage value
1406
1137
  */
1407
- static recordSuccessCount(count = 1) {
1408
- _sdk.successCount += count;
1409
- emitEvent("success", _sdk.successCount);
1138
+ static recordPlaycraftChallengeProgress(percent) {
1139
+ emitEvent("playcraftChallengeProgress", percent);
1410
1140
  }
1411
1141
  /**
1412
1142
  * Records a game success/completion event.
@@ -1416,13 +1146,12 @@ var _sdk = class _sdk {
1416
1146
  * - InMobi: Gameplay_Complete
1417
1147
  *
1418
1148
  * @example
1419
- * // When player completes the level
1420
1149
  * onLevelComplete() {
1421
- * sdk.recordSuccess();
1150
+ * sdk.playcraftRecordSuccess();
1422
1151
  * }
1423
1152
  */
1424
- static recordSuccess() {
1425
- tracking.trackChallengeSuccess();
1153
+ static playcraftRecordSuccess() {
1154
+ emitEvent("playcraftChallengeSuccess");
1426
1155
  }
1427
1156
  /**
1428
1157
  * Records a game failure event.
@@ -1430,24 +1159,22 @@ var _sdk = class _sdk {
1430
1159
  * - AppLovin: CHALLENGE_FAILED
1431
1160
  *
1432
1161
  * @example
1433
- * // When player fails the level
1434
1162
  * onLevelFailed() {
1435
- * sdk.recordFailed();
1163
+ * sdk.playcraftRecordFailed();
1436
1164
  * }
1437
1165
  */
1438
- static recordFailed() {
1439
- tracking.trackChallengeFailed();
1166
+ static playcraftRecordFailed() {
1167
+ emitEvent("playcraftChallengeFailed");
1440
1168
  }
1441
1169
  /**
1442
1170
  * Forces the playable ad into a paused state.
1443
1171
  *
1444
1172
  * @example
1445
- * // Pause the experience
1446
- * pauseButton.onclick = () => sdk.pause();
1173
+ * pauseButton.onclick = () => sdk.playcraftPause();
1447
1174
  *
1448
- * @fires pause When the ad enters paused state
1175
+ * @fires playcraftPause When the ad enters paused state
1449
1176
  */
1450
- static pause() {
1177
+ static playcraftPause() {
1451
1178
  if (!isForcePaused) {
1452
1179
  isForcePaused = true;
1453
1180
  handlePause();
@@ -1455,15 +1182,13 @@ var _sdk = class _sdk {
1455
1182
  }
1456
1183
  /**
1457
1184
  * Resumes the playable ad from a forced pause state.
1458
- * Only works if the ad was paused via sdk.pause().
1459
1185
  *
1460
1186
  * @example
1461
- * // Resume from pause
1462
- * resumeButton.onclick = () => sdk.resume();
1187
+ * resumeButton.onclick = () => sdk.playcraftResume();
1463
1188
  *
1464
- * @fires resume When the ad resumes from pause
1189
+ * @fires playcraftResume When the ad resumes from pause
1465
1190
  */
1466
- static resume() {
1191
+ static playcraftResume() {
1467
1192
  if (isForcePaused) {
1468
1193
  isForcePaused = false;
1469
1194
  handleResume();
@@ -1477,15 +1202,9 @@ var _sdk = class _sdk {
1477
1202
  * @param context Optional 'this' context for the callback
1478
1203
  *
1479
1204
  * @example
1480
- * // Listen for user interactions
1481
- * sdk.on('interaction', (count) => {
1205
+ * sdk.on('playcraftInteraction', (count) => {
1482
1206
  * console.log(`User interaction #${count}`);
1483
1207
  * });
1484
- *
1485
- * // Listen for resize with context
1486
- * sdk.on('resize', function(width, height) {
1487
- * this.updateLayout(width, height);
1488
- * }, gameInstance);
1489
1208
  */
1490
1209
  static on(event, fn, context) {
1491
1210
  onEvent(event, fn, context);
@@ -1498,8 +1217,7 @@ var _sdk = class _sdk {
1498
1217
  * @param context Optional 'this' context for the callback
1499
1218
  *
1500
1219
  * @example
1501
- * // Listen for first interaction only
1502
- * sdk.once('interaction', () => {
1220
+ * sdk.once('playcraftInteraction', () => {
1503
1221
  * console.log('First user interaction occurred!');
1504
1222
  * });
1505
1223
  */
@@ -1510,22 +1228,16 @@ var _sdk = class _sdk {
1510
1228
  * Removes an event listener.
1511
1229
  *
1512
1230
  * @param event Name of the event to stop listening for
1513
- * @param fn Optional callback function to remove (if not provided, removes all listeners for the event)
1231
+ * @param fn Optional callback function to remove
1514
1232
  * @param context Optional 'this' context to match when removing
1515
1233
  *
1516
1234
  * @example
1517
- * // Remove specific listener
1518
- * const handler = () => console.log('Interaction');
1519
- * sdk.off('interaction', handler);
1520
- *
1521
- * // Remove all listeners for an event
1522
- * sdk.off('interaction');
1235
+ * sdk.off('playcraftInteraction', handler);
1523
1236
  */
1524
1237
  static off(event, fn, context) {
1525
1238
  offEvent(event, fn, context);
1526
1239
  }
1527
1240
  /**
1528
- *
1529
1241
  * @returns 当前渠道
1530
1242
  */
1531
1243
  static getCurChannel() {
@@ -1573,7 +1285,7 @@ var _sdk = class _sdk {
1573
1285
  }
1574
1286
  };
1575
1287
  /** Current version of the SDK */
1576
- _sdk.version = "1.0.13";
1288
+ _sdk.version = "1.0.14-beta.1";
1577
1289
  /** Current maximum width of the playable ad container in pixels */
1578
1290
  _sdk.maxWidth = Math.floor(window.innerWidth);
1579
1291
  /** Current maximum height of the playable ad container in pixels */
@@ -1592,10 +1304,6 @@ _sdk.isFinished = false;
1592
1304
  _sdk.volume = actualVolume;
1593
1305
  /** Number of user interactions with the playable ad (auto-incremented on each touch/click) */
1594
1306
  _sdk.interactions = 0;
1595
- /** Number of successful game actions (e.g., successful matches, level clears).
1596
- * Controlled by calling sdk.recordSuccessCount(), NOT auto-incremented.
1597
- */
1598
- _sdk.successCount = 0;
1599
1307
  var sdk = _sdk;
1600
1308
  window["console"].log(
1601
1309
  `%c @playcraft/adsdk %c v${sdk.version} `,
@@ -1608,6 +1316,5 @@ window.PlayableSDK = sdk;
1608
1316
  hideWechatGuide,
1609
1317
  removeWechatGuide,
1610
1318
  sdk,
1611
- showWechatGuide,
1612
- tracking
1319
+ showWechatGuide
1613
1320
  });