@modelnex/sdk 0.5.54 → 0.5.58

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
@@ -3939,6 +3939,11 @@ function shouldExecuteTourCommandBatch(isPlaybackActive) {
3939
3939
  function shouldAcceptTourStart(state) {
3940
3940
  return !state.isPlaybackActive && !state.startRequested;
3941
3941
  }
3942
+ function shouldAcceptTourExperienceType(hookType, incomingType, isResumed) {
3943
+ const matchesType = !incomingType || incomingType === hookType;
3944
+ const isCompatibleResumption = isResumed && (hookType === "onboarding" && incomingType === "tour" || hookType === "tour" && incomingType === "onboarding");
3945
+ return matchesType || isCompatibleResumption;
3946
+ }
3942
3947
  function shouldRunTourAutoDiscovery(state) {
3943
3948
  return state.enableAutoDiscovery && !state.disabled && !state.isPlaybackActive && !state.startRequested && !state.hasPendingTour;
3944
3949
  }
@@ -3978,6 +3983,25 @@ function releaseTourPlaybackOwnership(key, ownerId) {
3978
3983
 
3979
3984
  // src/hooks/useTourPlayback.ts
3980
3985
  init_dev_logging();
3986
+ function shouldSuppressCompletedDraftPreview({
3987
+ endingTourId,
3988
+ endingPreviewRunId
3989
+ }) {
3990
+ return Boolean(endingTourId && endingPreviewRunId);
3991
+ }
3992
+ function getCompletedDraftPreviewToSuppress({
3993
+ endingTourId,
3994
+ endingPreviewRunId,
3995
+ experienceType
3996
+ }) {
3997
+ if (!shouldSuppressCompletedDraftPreview({ endingTourId, endingPreviewRunId })) {
3998
+ return null;
3999
+ }
4000
+ return {
4001
+ id: endingTourId,
4002
+ experienceType
4003
+ };
4004
+ }
3981
4005
  function resolveElement(step) {
3982
4006
  const el = step.element;
3983
4007
  if (!el) return null;
@@ -5265,10 +5289,12 @@ function useTourPlayback({
5265
5289
  }
5266
5290
  const tour = tourData.tourContext ?? tourRef.current;
5267
5291
  const expType = experienceTypeRef.current;
5268
- if (tour?.type && tour.type !== expType) {
5292
+ const isCompatible = shouldAcceptTourExperienceType(expType, tour?.type, !!tourData.resumed);
5293
+ if (!isCompatible) {
5269
5294
  emitSdkDebugLog("[TourClient] Ignoring tour start for mismatched experience type", {
5270
- incomingType: tour.type,
5271
- hookType: expType
5295
+ incomingType: tour?.type,
5296
+ hookType: expType,
5297
+ resumed: tourData.resumed
5272
5298
  }, { devMode: devModeRef.current });
5273
5299
  return;
5274
5300
  }
@@ -5541,6 +5567,11 @@ function useTourPlayback({
5541
5567
  const endingTourId = tourRef.current?.id;
5542
5568
  const endingPreviewRunId = previewRunIdRef.current;
5543
5569
  const endingStepOrder = stepIndexRef.current;
5570
+ const completedPreviewDraft = getCompletedDraftPreviewToSuppress({
5571
+ endingTourId,
5572
+ endingPreviewRunId,
5573
+ experienceType
5574
+ });
5544
5575
  isActiveRef.current = false;
5545
5576
  startRequestedRef.current = false;
5546
5577
  releasePlaybackOwnership();
@@ -5550,6 +5581,10 @@ function useTourPlayback({
5550
5581
  runCleanup(pendingManualWaitCleanupRef.current);
5551
5582
  pendingManualWaitCleanupRef.current = null;
5552
5583
  clearPendingManualInputSync();
5584
+ if (completedPreviewDraft) {
5585
+ persistSuppressedDraftPreview(completedPreviewDraft);
5586
+ clearActiveDraftPreview(experienceType);
5587
+ }
5553
5588
  if (!skipRequestedRef.current && userProfile?.userId && tourRef.current) {
5554
5589
  markTourComplete(serverUrl, toursApiBaseRef.current, tourRef.current.id, userProfile.userId, experienceType, websiteId);
5555
5590
  }
@@ -5574,7 +5609,7 @@ function useTourPlayback({
5574
5609
  });
5575
5610
  }
5576
5611
  if (reviewModeRef.current) {
5577
- if (endingTourId) {
5612
+ if (endingTourId && !completedPreviewDraft) {
5578
5613
  persistSuppressedDraftPreview({
5579
5614
  id: endingTourId,
5580
5615
  experienceType
package/dist/index.mjs CHANGED
@@ -3111,6 +3111,11 @@ function shouldExecuteTourCommandBatch(isPlaybackActive) {
3111
3111
  function shouldAcceptTourStart(state) {
3112
3112
  return !state.isPlaybackActive && !state.startRequested;
3113
3113
  }
3114
+ function shouldAcceptTourExperienceType(hookType, incomingType, isResumed) {
3115
+ const matchesType = !incomingType || incomingType === hookType;
3116
+ const isCompatibleResumption = isResumed && (hookType === "onboarding" && incomingType === "tour" || hookType === "tour" && incomingType === "onboarding");
3117
+ return matchesType || isCompatibleResumption;
3118
+ }
3114
3119
  function shouldRunTourAutoDiscovery(state) {
3115
3120
  return state.enableAutoDiscovery && !state.disabled && !state.isPlaybackActive && !state.startRequested && !state.hasPendingTour;
3116
3121
  }
@@ -3149,6 +3154,25 @@ function releaseTourPlaybackOwnership(key, ownerId) {
3149
3154
  }
3150
3155
 
3151
3156
  // src/hooks/useTourPlayback.ts
3157
+ function shouldSuppressCompletedDraftPreview({
3158
+ endingTourId,
3159
+ endingPreviewRunId
3160
+ }) {
3161
+ return Boolean(endingTourId && endingPreviewRunId);
3162
+ }
3163
+ function getCompletedDraftPreviewToSuppress({
3164
+ endingTourId,
3165
+ endingPreviewRunId,
3166
+ experienceType
3167
+ }) {
3168
+ if (!shouldSuppressCompletedDraftPreview({ endingTourId, endingPreviewRunId })) {
3169
+ return null;
3170
+ }
3171
+ return {
3172
+ id: endingTourId,
3173
+ experienceType
3174
+ };
3175
+ }
3152
3176
  function resolveElement(step) {
3153
3177
  const el = step.element;
3154
3178
  if (!el) return null;
@@ -4436,10 +4460,12 @@ function useTourPlayback({
4436
4460
  }
4437
4461
  const tour = tourData.tourContext ?? tourRef.current;
4438
4462
  const expType = experienceTypeRef.current;
4439
- if (tour?.type && tour.type !== expType) {
4463
+ const isCompatible = shouldAcceptTourExperienceType(expType, tour?.type, !!tourData.resumed);
4464
+ if (!isCompatible) {
4440
4465
  emitSdkDebugLog("[TourClient] Ignoring tour start for mismatched experience type", {
4441
- incomingType: tour.type,
4442
- hookType: expType
4466
+ incomingType: tour?.type,
4467
+ hookType: expType,
4468
+ resumed: tourData.resumed
4443
4469
  }, { devMode: devModeRef.current });
4444
4470
  return;
4445
4471
  }
@@ -4712,6 +4738,11 @@ function useTourPlayback({
4712
4738
  const endingTourId = tourRef.current?.id;
4713
4739
  const endingPreviewRunId = previewRunIdRef.current;
4714
4740
  const endingStepOrder = stepIndexRef.current;
4741
+ const completedPreviewDraft = getCompletedDraftPreviewToSuppress({
4742
+ endingTourId,
4743
+ endingPreviewRunId,
4744
+ experienceType
4745
+ });
4715
4746
  isActiveRef.current = false;
4716
4747
  startRequestedRef.current = false;
4717
4748
  releasePlaybackOwnership();
@@ -4721,6 +4752,10 @@ function useTourPlayback({
4721
4752
  runCleanup(pendingManualWaitCleanupRef.current);
4722
4753
  pendingManualWaitCleanupRef.current = null;
4723
4754
  clearPendingManualInputSync();
4755
+ if (completedPreviewDraft) {
4756
+ persistSuppressedDraftPreview(completedPreviewDraft);
4757
+ clearActiveDraftPreview(experienceType);
4758
+ }
4724
4759
  if (!skipRequestedRef.current && userProfile?.userId && tourRef.current) {
4725
4760
  markTourComplete(serverUrl, toursApiBaseRef.current, tourRef.current.id, userProfile.userId, experienceType, websiteId);
4726
4761
  }
@@ -4745,7 +4780,7 @@ function useTourPlayback({
4745
4780
  });
4746
4781
  }
4747
4782
  if (reviewModeRef.current) {
4748
- if (endingTourId) {
4783
+ if (endingTourId && !completedPreviewDraft) {
4749
4784
  persistSuppressedDraftPreview({
4750
4785
  id: endingTourId,
4751
4786
  experienceType
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@modelnex/sdk",
3
- "version": "0.5.54",
3
+ "version": "0.5.58",
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",