@modelnex/sdk 0.5.47 → 0.5.48

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
@@ -5262,27 +5262,33 @@ function useTourPlayback({
5262
5262
  skipRequestedRef.current = false;
5263
5263
  startRequestedRef.current = false;
5264
5264
  const total = tourData.totalSteps ?? tour?.steps?.length ?? 0;
5265
+ const requestedStepIndex = typeof tourData.currentStepIndex === "number" ? tourData.currentStepIndex : 0;
5266
+ const clampedStepIndex = Math.max(0, Math.min(requestedStepIndex, Math.max(0, total - 1)));
5265
5267
  isActiveRef.current = true;
5266
5268
  setIsActive(true);
5267
5269
  setActiveTour(tour ?? null);
5268
5270
  tourRef.current = tour ?? null;
5269
5271
  setTotalSteps(total);
5270
- stepIndexRef.current = 0;
5271
- setCurrentStepIndex(0);
5272
+ stepIndexRef.current = clampedStepIndex;
5273
+ setCurrentStepIndex(clampedStepIndex);
5272
5274
  setPlaybackState("intro");
5273
5275
  if (reviewModeRef.current && tour?.id && previewRunIdRef.current) {
5274
5276
  void logPreviewEvent(serverUrl, toursApiBaseRef.current, tour.id, previewRunIdRef.current, websiteId, {
5275
- stepOrder: 0,
5277
+ stepOrder: clampedStepIndex,
5276
5278
  eventType: "tour_started",
5277
5279
  payload: {
5278
5280
  totalSteps: total,
5279
- source: "sdk_test_preview"
5281
+ source: "sdk_test_preview",
5282
+ resumed: Boolean(tourData.resumed)
5280
5283
  },
5281
- currentStepOrder: 0
5284
+ currentStepOrder: clampedStepIndex
5282
5285
  });
5283
5286
  } else if (tour?.id && userProfile?.userId) {
5284
5287
  void recordTourEvent(serverUrl, toursApiBaseRef.current, tour.id, userProfile.userId, "started", websiteId);
5285
5288
  }
5289
+ if (tour && total > 0) {
5290
+ onStepChangeRef.current?.(clampedStepIndex, total, tour);
5291
+ }
5286
5292
  try {
5287
5293
  const { generateMinifiedAOM: generateMinifiedAOM2 } = await Promise.resolve().then(() => (init_aom(), aom_exports));
5288
5294
  const aom = generateMinifiedAOM2();
package/dist/index.mjs CHANGED
@@ -4433,27 +4433,33 @@ function useTourPlayback({
4433
4433
  skipRequestedRef.current = false;
4434
4434
  startRequestedRef.current = false;
4435
4435
  const total = tourData.totalSteps ?? tour?.steps?.length ?? 0;
4436
+ const requestedStepIndex = typeof tourData.currentStepIndex === "number" ? tourData.currentStepIndex : 0;
4437
+ const clampedStepIndex = Math.max(0, Math.min(requestedStepIndex, Math.max(0, total - 1)));
4436
4438
  isActiveRef.current = true;
4437
4439
  setIsActive(true);
4438
4440
  setActiveTour(tour ?? null);
4439
4441
  tourRef.current = tour ?? null;
4440
4442
  setTotalSteps(total);
4441
- stepIndexRef.current = 0;
4442
- setCurrentStepIndex(0);
4443
+ stepIndexRef.current = clampedStepIndex;
4444
+ setCurrentStepIndex(clampedStepIndex);
4443
4445
  setPlaybackState("intro");
4444
4446
  if (reviewModeRef.current && tour?.id && previewRunIdRef.current) {
4445
4447
  void logPreviewEvent(serverUrl, toursApiBaseRef.current, tour.id, previewRunIdRef.current, websiteId, {
4446
- stepOrder: 0,
4448
+ stepOrder: clampedStepIndex,
4447
4449
  eventType: "tour_started",
4448
4450
  payload: {
4449
4451
  totalSteps: total,
4450
- source: "sdk_test_preview"
4452
+ source: "sdk_test_preview",
4453
+ resumed: Boolean(tourData.resumed)
4451
4454
  },
4452
- currentStepOrder: 0
4455
+ currentStepOrder: clampedStepIndex
4453
4456
  });
4454
4457
  } else if (tour?.id && userProfile?.userId) {
4455
4458
  void recordTourEvent(serverUrl, toursApiBaseRef.current, tour.id, userProfile.userId, "started", websiteId);
4456
4459
  }
4460
+ if (tour && total > 0) {
4461
+ onStepChangeRef.current?.(clampedStepIndex, total, tour);
4462
+ }
4457
4463
  try {
4458
4464
  const { generateMinifiedAOM: generateMinifiedAOM2 } = await import("./aom-SP2LMWQI.mjs");
4459
4465
  const aom = generateMinifiedAOM2();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@modelnex/sdk",
3
- "version": "0.5.47",
3
+ "version": "0.5.48",
4
4
  "description": "React SDK for natural language control of web apps via AI agents",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",