@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/esm/index.js CHANGED
@@ -157,275 +157,23 @@ function ensureProtocol() {
157
157
  }
158
158
  }
159
159
 
160
- // src/tracking.ts
161
- function getCurrentAdNetwork(adNetwork) {
162
- const network = adNetwork || (typeof AD_NETWORK !== "undefined" ? AD_NETWORK : "");
163
- const supportedNetworks = ["bigabid", "inmobi", "applovin"];
164
- if (supportedNetworks.includes(network)) {
165
- return network;
166
- }
167
- return null;
168
- }
169
- function trackURL(url) {
170
- if (url) {
171
- const trackingPixel = new Image();
172
- trackingPixel.src = url;
173
- }
174
- }
175
- function trackBigabidEvent(event) {
176
- console.log(" trackBigabidEvent", event);
177
- if (window.BIGABID_BIDTIMEMACROS && window.BIGABID_BIDTIMEMACROS[event]) {
178
- trackURL(window.BIGABID_BIDTIMEMACROS[event]);
179
- }
180
- }
181
- function trackInMobiEvent(event) {
182
- console.log(" trackInMobiEvent", event);
183
- if (window.INMOBI_DSPMACROS && window.INMOBI_DSPMACROS[event]) {
184
- trackURL(window.INMOBI_DSPMACROS[event]);
185
- }
186
- }
187
- function trackApplovinEvent(event) {
188
- console.log(" trackApplovinEvent", event);
189
- if (typeof window.ALPlayableAnalytics !== "undefined") {
190
- window.ALPlayableAnalytics.trackEvent(event);
191
- }
192
- }
193
- var bigabidCompleteTriggered = false;
194
- function trackBigabidComplete() {
195
- if (!bigabidCompleteTriggered) {
196
- trackBigabidEvent("complete");
197
- bigabidCompleteTriggered = true;
198
- }
199
- }
200
- var inmobiTimers = [];
201
- function startInMobiDurationTracking() {
202
- const durations = [5, 10, 15, 20, 25, 30];
203
- for (const sec of durations) {
204
- const timer = setTimeout(() => trackInMobiEvent(`Spent_${sec}_Seconds`), sec * 1e3);
205
- inmobiTimers.push(timer);
206
- }
207
- }
208
- function clearInMobiDurationTracking() {
209
- for (const timer of inmobiTimers) {
210
- clearTimeout(timer);
211
- }
212
- inmobiTimers = [];
213
- }
214
- var totalInteractions = 0;
215
- var progressMilestones = [];
216
- function setTotalInteractions(total) {
217
- totalInteractions = total;
218
- }
219
- function initProgressMilestones(adNetwork) {
220
- if (totalInteractions <= 0) return;
221
- const network = getCurrentAdNetwork(adNetwork);
222
- if (!network) return;
223
- if (network === "applovin") {
224
- progressMilestones = [
225
- { percent: 25, triggered: false, callback: () => trackApplovinEvent("CHALLENGE_PASS_25") },
226
- { percent: 50, triggered: false, callback: () => trackApplovinEvent("CHALLENGE_PASS_50") },
227
- { percent: 75, triggered: false, callback: () => trackApplovinEvent("CHALLENGE_PASS_75") },
228
- { percent: 100, triggered: false, callback: () => _trackChallengeSuccess(adNetwork) }
229
- ];
230
- } else if (network === "bigabid") {
231
- progressMilestones = [
232
- { percent: 100, triggered: false, callback: () => _trackChallengeSuccess(adNetwork) }
233
- ];
234
- }
235
- }
236
- function checkInteractionProgress(currentInteractions) {
237
- if (totalInteractions <= 0 || progressMilestones.length === 0) return;
238
- const currentPercent = currentInteractions / totalInteractions * 100;
239
- for (const milestone of progressMilestones) {
240
- if (!milestone.triggered && currentPercent >= milestone.percent) {
241
- milestone.triggered = true;
242
- milestone.callback();
243
- }
244
- }
245
- }
246
- function _onInit(adNetwork) {
247
- initProgressMilestones(adNetwork);
248
- const network = getCurrentAdNetwork(adNetwork);
249
- if (!network) return;
250
- if (network === "bigabid") {
251
- trackBigabidEvent("mraid_viewable");
252
- }
253
- if (network === "inmobi") {
254
- trackInMobiEvent("Ad_Load_Start");
255
- }
256
- if (network === "applovin") {
257
- trackApplovinEvent("LOADING");
258
- }
259
- }
260
- function _onStart(adNetwork) {
261
- const network = getCurrentAdNetwork(adNetwork);
262
- if (!network) return;
263
- if (network === "bigabid") {
264
- trackBigabidEvent("game_viewable");
265
- }
266
- if (network === "inmobi") {
267
- trackInMobiEvent("Ad_Viewable");
268
- startInMobiDurationTracking();
269
- }
270
- if (network === "applovin") {
271
- trackApplovinEvent("LOADED");
272
- }
273
- }
274
- function _onInteractive(adNetwork) {
275
- const network = getCurrentAdNetwork(adNetwork);
276
- if (!network) return;
277
- if (network === "applovin") {
278
- trackApplovinEvent("DISPLAYED");
279
- }
280
- }
281
- function _onInteraction(adNetwork) {
282
- const network = getCurrentAdNetwork(adNetwork);
283
- if (!network) return;
284
- if (network === "bigabid") {
285
- trackBigabidEvent("engagement");
286
- }
287
- if (network === "inmobi") {
288
- trackInMobiEvent("First_Engagement");
289
- }
290
- if (network === "applovin") {
291
- trackApplovinEvent("CHALLENGE_STARTED");
292
- }
293
- }
294
- function _onSuccess(successCount) {
295
- checkInteractionProgress(successCount);
296
- }
297
- function _onFinish(adNetwork) {
298
- const network = getCurrentAdNetwork(adNetwork);
299
- if (!network) return;
300
- if (network === "bigabid") {
301
- trackBigabidComplete();
302
- }
303
- if (network === "inmobi") {
304
- trackInMobiEvent("Gameplay_Complete");
305
- clearInMobiDurationTracking();
306
- }
307
- if (network === "applovin") {
308
- trackApplovinEvent("ENDCARD_SHOWN");
309
- }
310
- }
311
- function _onInstall(adNetwork) {
312
- const network = getCurrentAdNetwork(adNetwork);
313
- if (!network) return;
314
- if (network === "bigabid") {
315
- trackBigabidEvent("click");
316
- }
317
- if (network === "inmobi") {
318
- trackInMobiEvent("DSP_Click");
319
- clearInMobiDurationTracking();
320
- }
321
- if (network === "applovin") {
322
- trackApplovinEvent("CTA_CLICKED");
323
- }
324
- }
325
- function _onRetry(adNetwork) {
326
- const network = getCurrentAdNetwork(adNetwork);
327
- if (!network) return;
328
- if (network === "applovin") {
329
- trackApplovinEvent("CHALLENGE_RETRY");
330
- }
331
- }
332
- function _trackChallengeSuccess(adNetwork) {
333
- const network = getCurrentAdNetwork(adNetwork);
334
- if (!network) return;
335
- if (network === "applovin") {
336
- trackApplovinEvent("CHALLENGE_SOLVED");
337
- }
338
- if (network === "bigabid") {
339
- trackBigabidComplete();
340
- }
341
- if (network === "inmobi") {
342
- trackInMobiEvent("Gameplay_Complete");
343
- }
344
- }
345
- function _trackChallengeFailed(adNetwork) {
346
- const network = getCurrentAdNetwork(adNetwork);
347
- if (!network) return;
348
- if (network === "applovin") {
349
- trackApplovinEvent("CHALLENGE_FAILED");
350
- }
351
- }
352
- var tracking = {
353
- /**
354
- * SDK 初始化开始
355
- * @param adNetwork - 可选的广告渠道名称
356
- */
357
- onInit: _onInit,
358
- /**
359
- * 游戏资源加载完成
360
- * @param adNetwork - 可选的广告渠道名称
361
- */
362
- onStart: _onStart,
363
- /**
364
- * 主场景就绪,用户可交互
365
- * @param adNetwork - 可选的广告渠道名称
366
- */
367
- onInteractive: _onInteractive,
368
- /**
369
- * 首次交互
370
- * @param adNetwork - 可选的广告渠道名称
371
- */
372
- onInteraction: _onInteraction,
373
- /**
374
- * 成功计数(用于进度百分比追踪)
375
- * @param successCount - 当前成功次数
376
- */
377
- onSuccess: _onSuccess,
378
- /**
379
- * 游戏结束
380
- * @param adNetwork - 可选的广告渠道名称
381
- */
382
- onFinish: _onFinish,
383
- /**
384
- * 点击安装
385
- * @param adNetwork - 可选的广告渠道名称
386
- */
387
- onInstall: _onInstall,
388
- /**
389
- * 重试游戏
390
- * @param adNetwork - 可选的广告渠道名称
391
- */
392
- onRetry: _onRetry,
393
- /**
394
- * 设置交互总数(用于进度百分比计算)
395
- * @param total - 交互总数
396
- */
397
- setTotalInteractions,
398
- /**
399
- * 检查交互进度
400
- * @param currentInteractions - 当前交互次数
401
- */
402
- checkInteractionProgress,
403
- /**
404
- * 触发游戏成功事件
405
- * @param adNetwork - 可选的广告渠道名称
406
- */
407
- trackChallengeSuccess: _trackChallengeSuccess,
408
- /**
409
- * 触发游戏失败事件
410
- * @param adNetwork - 可选的广告渠道名称
411
- */
412
- trackChallengeFailed: _trackChallengeFailed
413
- };
414
-
415
160
  // src/tracking-init.ts
161
+ import { tracking } from "@playcraft/ads-tracking";
416
162
  function initTrackingProtocols() {
417
163
  const supportedNetworks = ["bigabid", "inmobi", "applovin"];
418
164
  if (!supportedNetworks.includes(AD_NETWORK)) {
419
165
  return;
420
166
  }
421
- sdk.once("init", tracking.onInit);
422
- sdk.once("start", tracking.onStart);
423
- sdk.once("interactive", tracking.onInteractive);
424
- sdk.once("interaction", tracking.onInteraction);
425
- sdk.on("success", tracking.onSuccess);
426
- sdk.once("finish", tracking.onFinish);
427
- sdk.on("install", tracking.onInstall);
428
- sdk.once("retry", tracking.onRetry);
167
+ sdk.once("playcraftInit", tracking.onPlaycraftTrackingInit);
168
+ sdk.once("playcraftStart", tracking.onPlaycraftTrackingLoading);
169
+ sdk.once("playcraftInteractive", tracking.onPlaycraftTrackingLoaded);
170
+ sdk.on("playcraftChallengeStart", tracking.onPlaycraftChallengeStart);
171
+ sdk.on("playcraftChallengeProgress", tracking.onPlaycraftChallengeProgress);
172
+ sdk.once("playcraftFinish", tracking.onPlaycraftChallengeFinish);
173
+ sdk.on("playcraftInstall", tracking.onPlaycraftInstall);
174
+ sdk.once("playcraftRetry", tracking.onPlaycraftRetry);
175
+ sdk.on("playcraftChallengeSuccess", tracking.onPlaycraftChallengeSuccess);
176
+ sdk.on("playcraftChallengeFailed", tracking.onPlaycraftChallengeFailed);
429
177
  }
430
178
 
431
179
  // src/assets/images.ts
@@ -771,16 +519,16 @@ var initCallback = () => {
771
519
  };
772
520
  function bootAd() {
773
521
  if (sdk.isReady) return;
774
- emitEvent("init");
522
+ emitEvent("playcraftInit");
775
523
  document.body.oncontextmenu = function() {
776
524
  return false;
777
525
  };
778
526
  initCallback(sdk.maxWidth, sdk.maxHeight);
779
- emitEvent("ready");
527
+ emitEvent("playcraftReady");
780
528
  sdk.isReady = true;
781
529
  }
782
530
  function fireVolumeChange(value) {
783
- emitEvent("volume", value);
531
+ emitEvent("playcraftVolume", value);
784
532
  }
785
533
  function changeVolume(value) {
786
534
  sdk.volume = value;
@@ -793,13 +541,13 @@ function handleVolumeChange(value) {
793
541
  function handlePause() {
794
542
  changeVolume(0);
795
543
  sdk.isPaused = true;
796
- emitEvent("pause");
544
+ emitEvent("playcraftPause");
797
545
  }
798
546
  function handleResume() {
799
547
  if (isForcePaused) return;
800
548
  changeVolume(actualVolume);
801
549
  sdk.isPaused = false;
802
- emitEvent("resume");
550
+ emitEvent("playcraftResume");
803
551
  }
804
552
  function fireResizeEvent(width, height) {
805
553
  handleResize(width, height);
@@ -982,7 +730,7 @@ function startDefaultProtocol() {
982
730
  const tapjoyApi = {
983
731
  skipAd: function() {
984
732
  try {
985
- sdk.finish();
733
+ sdk.playcraftFinish();
986
734
  } catch (e) {
987
735
  console.warn("Could not skip ad! | " + e);
988
736
  }
@@ -1001,7 +749,7 @@ function handleResize(width, height) {
1001
749
  sdk.maxWidth = Math.floor(width || window.innerWidth);
1002
750
  sdk.maxHeight = Math.floor(height || window.innerHeight);
1003
751
  sdk.isLandscape = sdk.maxWidth > sdk.maxHeight;
1004
- emitEvent("resize", sdk.maxWidth, sdk.maxHeight);
752
+ emitEvent("playcraftResize", sdk.maxWidth, sdk.maxHeight);
1005
753
  }
1006
754
  var isListeningToTouchEvents = false;
1007
755
  var isTouchEventRegistered = false;
@@ -1011,7 +759,7 @@ function onUserInteraction(event) {
1011
759
  }
1012
760
  if (isListeningToTouchEvents && event instanceof MouseEvent) return;
1013
761
  sdk.interactions += 1;
1014
- emitEvent("interaction", sdk.interactions);
762
+ emitEvent("playcraftInteraction", sdk.interactions);
1015
763
  }
1016
764
  function registerTouchHandlers() {
1017
765
  if (!isTouchEventRegistered) {
@@ -1095,35 +843,21 @@ var _sdk = class _sdk {
1095
843
  * This must be called as earlier as possible.
1096
844
  *
1097
845
  * @param callback Optional function called when ad container is ready
1098
- * @param options Optional configuration options
1099
- * @param options.totalSuccessCount Total number of successful actions expected for progress tracking.
1100
- * When set, the SDK will track success progress as a percentage and trigger
1101
- * channel-specific milestone events (e.g., AppLovin: CHALLENGE_PASS_25/50/75, CHALLENGE_SOLVED).
1102
- * Different channels monitor different percentage thresholds independently.
1103
- * Set to 0 or omit to disable progress tracking.
1104
846
  * @example
1105
847
  * // Basic initialization
1106
- * sdk.init();
848
+ * sdk.playcraftInit();
1107
849
  *
1108
850
  * // Initialization with callback
1109
- * sdk.init((width, height) => {
851
+ * sdk.playcraftInit((width, height) => {
1110
852
  * new App(width, height)
1111
853
  * });
1112
854
  *
1113
- * // Initialization with success count progress tracking
1114
- * sdk.init((width, height) => {
1115
- * new App(width, height)
1116
- * }, { totalSuccessCount: 20 });
1117
- *
1118
- * @fires loading When SDK initialization starts
1119
- * @fires loaded When game instance is created and ready to load resources
855
+ * @fires playcraftInit When SDK initialization starts
856
+ * @fires playcraftReady When game instance is created and ready to load resources
1120
857
  */
1121
- static init(callback, options) {
858
+ static playcraftInit(callback) {
1122
859
  if (isSDKInitialized) return;
1123
860
  if (callback) initCallback = callback;
1124
- if ((options == null ? void 0 : options.totalSuccessCount) && options.totalSuccessCount > 0) {
1125
- tracking.setTotalInteractions(options.totalSuccessCount);
1126
- }
1127
861
  initTrackingProtocols();
1128
862
  document.readyState === "loading" ? window.addEventListener("DOMContentLoaded", initSDK) : initSDK();
1129
863
  isSDKInitialized = true;
@@ -1133,25 +867,24 @@ var _sdk = class _sdk {
1133
867
  * Should be called after all resources are loaded and first frame is rendered.
1134
868
  *
1135
869
  * @example
1136
- * // Call just after all resources are preloaded and first frame is rendered
1137
- * sdk.start();
870
+ * sdk.playcraftStart();
1138
871
  *
1139
- * @fires start When the playable ad starts
1140
- * @fires resize When the ad container is initially sized
872
+ * @fires playcraftStart When the playable ad starts
873
+ * @fires playcraftResize When the ad container is initially sized
1141
874
  */
1142
- static start() {
875
+ static playcraftStart() {
1143
876
  if (_sdk.isStarted) return;
1144
877
  _sdk.isStarted = true;
1145
- emitEvent("start");
878
+ emitEvent("playcraftStart");
1146
879
  registerTouchHandlers();
1147
880
  if ("mintegral" === AD_NETWORK && isMintegral()) {
1148
- _sdk.resize();
881
+ _sdk.playcraftResize();
1149
882
  handlePause();
1150
883
  window.gameReady && window.gameReady();
1151
884
  } else if ("bigoads" === AD_NETWORK && isBigoAds()) {
1152
885
  window.BGY_MRAID && window.BGY_MRAID.gameReady && window.BGY_MRAID.gameReady();
1153
886
  fireVolumeChange(_sdk.volume);
1154
- _sdk.resize();
887
+ _sdk.playcraftResize();
1155
888
  } else {
1156
889
  if ("tapjoy" === AD_NETWORK && isTapjoy()) {
1157
890
  window.TJ_API.setPlayableBuild({
@@ -1160,7 +893,7 @@ var _sdk = class _sdk {
1160
893
  });
1161
894
  }
1162
895
  fireVolumeChange(_sdk.volume);
1163
- _sdk.resize();
896
+ _sdk.playcraftResize();
1164
897
  }
1165
898
  }
1166
899
  /**
@@ -1168,28 +901,39 @@ var _sdk = class _sdk {
1168
901
  * Should be called at the end of your main game scene's create() method.
1169
902
  *
1170
903
  * @example
1171
- * // In Phaser MainScene.create()
1172
904
  * create() {
1173
905
  * // ... all initialization code ...
1174
- * sdk.interactive();
906
+ * sdk.playcraftInteractive();
1175
907
  * }
1176
908
  *
1177
- * @fires interactive When the main scene is ready for user interaction
909
+ * @fires playcraftInteractive When the main scene is ready for user interaction
1178
910
  */
1179
- static interactive() {
1180
- emitEvent("interactive");
911
+ static playcraftInteractive() {
912
+ emitEvent("playcraftInteractive");
913
+ }
914
+ /**
915
+ * Marks the challenge as started.
916
+ * Should be called by business logic when the user actually starts playing.
917
+ *
918
+ * @example
919
+ * onFirstClick() {
920
+ * sdk.playcraftChallengeStart();
921
+ * }
922
+ *
923
+ * @fires playcraftChallengeStart When the challenge starts
924
+ */
925
+ static playcraftChallengeStart() {
926
+ emitEvent("playcraftChallengeStart");
1181
927
  }
1182
928
  /**
1183
929
  * Marks the playable ad as finished.
1184
- * This triggers network-specific completion handlers.
1185
930
  *
1186
931
  * @example
1187
- * // Call when game/experience is complete
1188
- * sdk.finish();
932
+ * sdk.playcraftFinish();
1189
933
  *
1190
- * @fires finish When the playable ad is marked as finished
934
+ * @fires playcraftFinish When the playable ad is marked as finished
1191
935
  */
1192
- static finish() {
936
+ static playcraftFinish() {
1193
937
  _sdk.isFinished = true;
1194
938
  if ("tapjoy" === AD_NETWORK && isTapjoy()) {
1195
939
  finishTapjoy();
@@ -1209,38 +953,34 @@ var _sdk = class _sdk {
1209
953
  console.warn("Could not call mraid.close():", e);
1210
954
  }
1211
955
  }
1212
- emitEvent("finish");
956
+ emitEvent("playcraftFinish");
1213
957
  }
1214
958
  /**
1215
959
  * Triggers a retry/restart of the playable ad.
1216
- * Behavior varies by ad network.
1217
960
  *
1218
961
  * @example
1219
- * // Allow user to try again
1220
- * retryButton.onclick = () => sdk.retry();
962
+ * retryButton.onclick = () => sdk.playcraftRetry();
1221
963
  *
1222
- * @fires retry When a retry is triggered
964
+ * @fires playcraftRetry When a retry is triggered
1223
965
  */
1224
- static retry() {
966
+ static playcraftRetry() {
1225
967
  if ("mintegral" === AD_NETWORK && isMintegral()) {
1226
968
  } else if ("nucleo" === AD_PROTOCOL && isNucleo()) {
1227
969
  NUC.trigger.tryAgain();
1228
970
  }
1229
- emitEvent("retry");
971
+ emitEvent("playcraftRetry");
1230
972
  }
1231
973
  /**
1232
974
  * Triggers the install/download action for the advertised app.
1233
- * Handles different store opening methods across ad networks.
1234
975
  *
1235
976
  * @example
1236
- * // Call when user wants to install
1237
- * installButton.onclick = () => sdk.install();
977
+ * installButton.onclick = () => sdk.playcraftInstall();
1238
978
  *
1239
- * @fires finish If the ad hasn't been marked as finished
1240
- * @fires install When the install action is triggered
979
+ * @fires playcraftFinish If the ad hasn't been marked as finished
980
+ * @fires playcraftInstall When the install action is triggered
1241
981
  */
1242
- static install(params) {
1243
- console.log("[SDK] install() called, interactions:", _sdk.interactions, "isFinished:", _sdk.isFinished, "isInstallClicked:", isInstallClicked);
982
+ static playcraftInstall(params) {
983
+ console.log("[SDK] playcraftInstall() called, interactions:", _sdk.interactions, "isFinished:", _sdk.isFinished, "isInstallClicked:", isInstallClicked);
1244
984
  if (_sdk.interactions < 1 && isDisableFirstClickToOpenApp()) {
1245
985
  console.log("[SDK] \u9996\u6B21\u70B9\u51FB\u4FDD\u62A4\uFF0C\u76F4\u63A5\u8FD4\u56DE");
1246
986
  return;
@@ -1250,23 +990,23 @@ var _sdk = class _sdk {
1250
990
  return;
1251
991
  }
1252
992
  const timeout = setTimeout(function() {
1253
- _sdk.install();
993
+ _sdk.playcraftInstall();
1254
994
  clearTimeout(timeout);
1255
995
  }, params.timeout || 3e3);
1256
996
  return;
1257
997
  }
1258
998
  if (!_sdk.isFinished) {
1259
- console.log("[SDK] \u9996\u6B21\u6267\u884C install\uFF0C\u89E6\u53D1 finish \u4E8B\u4EF6");
999
+ console.log("[SDK] \u9996\u6B21\u6267\u884C playcraftInstall\uFF0C\u89E6\u53D1 playcraftFinish \u4E8B\u4EF6");
1260
1000
  _sdk.isFinished = true;
1261
1001
  let timeout = 0;
1262
1002
  if ("tapjoy" === AD_NETWORK && isTapjoy()) {
1263
1003
  finishTapjoy();
1264
1004
  timeout = 300;
1265
1005
  }
1266
- emitEvent("finish");
1006
+ emitEvent("playcraftFinish");
1267
1007
  setTimeout(function() {
1268
- console.log("[SDK] \u5F02\u6B65\u9012\u5F52\u8C03\u7528 install()");
1269
- _sdk.install();
1008
+ console.log("[SDK] \u5F02\u6B65\u9012\u5F52\u8C03\u7528 playcraftInstall()");
1009
+ _sdk.playcraftInstall();
1270
1010
  }, timeout);
1271
1011
  return;
1272
1012
  }
@@ -1279,7 +1019,7 @@ var _sdk = class _sdk {
1279
1019
  isInstallClicked = false;
1280
1020
  console.log("[SDK] \u9632\u6296\u89E3\u9501");
1281
1021
  }, 500);
1282
- emitEvent("install");
1022
+ emitEvent("playcraftInstall");
1283
1023
  console.log("Ad_Protocal: ", AD_PROTOCOL);
1284
1024
  if ("mraid" === AD_PROTOCOL && isMraid()) {
1285
1025
  try {
@@ -1343,39 +1083,30 @@ var _sdk = class _sdk {
1343
1083
  }
1344
1084
  /**
1345
1085
  * Trigger force resize event
1346
- * Useful when container size changes need to be manually propagated.
1347
1086
  *
1348
1087
  * @example
1349
- * sdk.resize();
1088
+ * sdk.playcraftResize();
1350
1089
  *
1351
- * @fires resize With current maxWidth and maxHeight
1090
+ * @fires playcraftResize With current maxWidth and maxHeight
1352
1091
  */
1353
- static resize() {
1092
+ static playcraftResize() {
1354
1093
  handleResize(_sdk.maxWidth, _sdk.maxHeight);
1355
1094
  }
1356
1095
  /**
1357
- * Records successful game actions (e.g., successful match, level clear).
1358
- * This should be called by game logic when a meaningful success occurs.
1359
- * This count is used for progress tracking (e.g., AppLovin milestone events).
1096
+ * Records playable ad challenge progress (0-100).
1097
+ * Triggers channel-specific milestone events based on the progress value.
1098
+ * Milestones are not re-triggered once fired.
1099
+ *
1100
+ * @param percent Progress percentage (0-100)
1360
1101
  *
1361
- * @param count Optional success count to add (default: 1)
1362
- *
1363
1102
  * @example
1364
- * // Record single success when match completes
1365
- * onMatchSuccess() {
1366
- * sdk.recordSuccessCount();
1367
- * }
1368
- *
1369
- * // Record multiple successes at once
1370
- * onComboMatch(comboCount) {
1371
- * sdk.recordSuccessCount(comboCount);
1372
- * }
1103
+ * // Report 50% progress
1104
+ * sdk.recordPlaycraftChallengeProgress(50);
1373
1105
  *
1374
- * @fires success With updated success count (triggers progress tracking)
1106
+ * @fires playcraftChallengeProgress With the progress percentage value
1375
1107
  */
1376
- static recordSuccessCount(count = 1) {
1377
- _sdk.successCount += count;
1378
- emitEvent("success", _sdk.successCount);
1108
+ static recordPlaycraftChallengeProgress(percent) {
1109
+ emitEvent("playcraftChallengeProgress", percent);
1379
1110
  }
1380
1111
  /**
1381
1112
  * Records a game success/completion event.
@@ -1385,13 +1116,12 @@ var _sdk = class _sdk {
1385
1116
  * - InMobi: Gameplay_Complete
1386
1117
  *
1387
1118
  * @example
1388
- * // When player completes the level
1389
1119
  * onLevelComplete() {
1390
- * sdk.recordSuccess();
1120
+ * sdk.playcraftRecordSuccess();
1391
1121
  * }
1392
1122
  */
1393
- static recordSuccess() {
1394
- tracking.trackChallengeSuccess();
1123
+ static playcraftRecordSuccess() {
1124
+ emitEvent("playcraftChallengeSuccess");
1395
1125
  }
1396
1126
  /**
1397
1127
  * Records a game failure event.
@@ -1399,24 +1129,22 @@ var _sdk = class _sdk {
1399
1129
  * - AppLovin: CHALLENGE_FAILED
1400
1130
  *
1401
1131
  * @example
1402
- * // When player fails the level
1403
1132
  * onLevelFailed() {
1404
- * sdk.recordFailed();
1133
+ * sdk.playcraftRecordFailed();
1405
1134
  * }
1406
1135
  */
1407
- static recordFailed() {
1408
- tracking.trackChallengeFailed();
1136
+ static playcraftRecordFailed() {
1137
+ emitEvent("playcraftChallengeFailed");
1409
1138
  }
1410
1139
  /**
1411
1140
  * Forces the playable ad into a paused state.
1412
1141
  *
1413
1142
  * @example
1414
- * // Pause the experience
1415
- * pauseButton.onclick = () => sdk.pause();
1143
+ * pauseButton.onclick = () => sdk.playcraftPause();
1416
1144
  *
1417
- * @fires pause When the ad enters paused state
1145
+ * @fires playcraftPause When the ad enters paused state
1418
1146
  */
1419
- static pause() {
1147
+ static playcraftPause() {
1420
1148
  if (!isForcePaused) {
1421
1149
  isForcePaused = true;
1422
1150
  handlePause();
@@ -1424,15 +1152,13 @@ var _sdk = class _sdk {
1424
1152
  }
1425
1153
  /**
1426
1154
  * Resumes the playable ad from a forced pause state.
1427
- * Only works if the ad was paused via sdk.pause().
1428
1155
  *
1429
1156
  * @example
1430
- * // Resume from pause
1431
- * resumeButton.onclick = () => sdk.resume();
1157
+ * resumeButton.onclick = () => sdk.playcraftResume();
1432
1158
  *
1433
- * @fires resume When the ad resumes from pause
1159
+ * @fires playcraftResume When the ad resumes from pause
1434
1160
  */
1435
- static resume() {
1161
+ static playcraftResume() {
1436
1162
  if (isForcePaused) {
1437
1163
  isForcePaused = false;
1438
1164
  handleResume();
@@ -1446,15 +1172,9 @@ var _sdk = class _sdk {
1446
1172
  * @param context Optional 'this' context for the callback
1447
1173
  *
1448
1174
  * @example
1449
- * // Listen for user interactions
1450
- * sdk.on('interaction', (count) => {
1175
+ * sdk.on('playcraftInteraction', (count) => {
1451
1176
  * console.log(`User interaction #${count}`);
1452
1177
  * });
1453
- *
1454
- * // Listen for resize with context
1455
- * sdk.on('resize', function(width, height) {
1456
- * this.updateLayout(width, height);
1457
- * }, gameInstance);
1458
1178
  */
1459
1179
  static on(event, fn, context) {
1460
1180
  onEvent(event, fn, context);
@@ -1467,8 +1187,7 @@ var _sdk = class _sdk {
1467
1187
  * @param context Optional 'this' context for the callback
1468
1188
  *
1469
1189
  * @example
1470
- * // Listen for first interaction only
1471
- * sdk.once('interaction', () => {
1190
+ * sdk.once('playcraftInteraction', () => {
1472
1191
  * console.log('First user interaction occurred!');
1473
1192
  * });
1474
1193
  */
@@ -1479,22 +1198,16 @@ var _sdk = class _sdk {
1479
1198
  * Removes an event listener.
1480
1199
  *
1481
1200
  * @param event Name of the event to stop listening for
1482
- * @param fn Optional callback function to remove (if not provided, removes all listeners for the event)
1201
+ * @param fn Optional callback function to remove
1483
1202
  * @param context Optional 'this' context to match when removing
1484
1203
  *
1485
1204
  * @example
1486
- * // Remove specific listener
1487
- * const handler = () => console.log('Interaction');
1488
- * sdk.off('interaction', handler);
1489
- *
1490
- * // Remove all listeners for an event
1491
- * sdk.off('interaction');
1205
+ * sdk.off('playcraftInteraction', handler);
1492
1206
  */
1493
1207
  static off(event, fn, context) {
1494
1208
  offEvent(event, fn, context);
1495
1209
  }
1496
1210
  /**
1497
- *
1498
1211
  * @returns 当前渠道
1499
1212
  */
1500
1213
  static getCurChannel() {
@@ -1542,7 +1255,7 @@ var _sdk = class _sdk {
1542
1255
  }
1543
1256
  };
1544
1257
  /** Current version of the SDK */
1545
- _sdk.version = "1.0.13";
1258
+ _sdk.version = "1.0.14-beta.1";
1546
1259
  /** Current maximum width of the playable ad container in pixels */
1547
1260
  _sdk.maxWidth = Math.floor(window.innerWidth);
1548
1261
  /** Current maximum height of the playable ad container in pixels */
@@ -1561,10 +1274,6 @@ _sdk.isFinished = false;
1561
1274
  _sdk.volume = actualVolume;
1562
1275
  /** Number of user interactions with the playable ad (auto-incremented on each touch/click) */
1563
1276
  _sdk.interactions = 0;
1564
- /** Number of successful game actions (e.g., successful matches, level clears).
1565
- * Controlled by calling sdk.recordSuccessCount(), NOT auto-incremented.
1566
- */
1567
- _sdk.successCount = 0;
1568
1277
  var sdk = _sdk;
1569
1278
  window["console"].log(
1570
1279
  `%c @playcraft/adsdk %c v${sdk.version} `,
@@ -1577,6 +1286,5 @@ export {
1577
1286
  hideWechatGuide,
1578
1287
  removeWechatGuide,
1579
1288
  sdk,
1580
- showWechatGuide,
1581
- tracking
1289
+ showWechatGuide
1582
1290
  };