@modelnex/sdk 0.5.55 → 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,9 +5289,8 @@ function useTourPlayback({
5265
5289
  }
5266
5290
  const tour = tourData.tourContext ?? tourRef.current;
5267
5291
  const expType = experienceTypeRef.current;
5268
- const matchesType = !tour?.type || tour.type === expType;
5269
- const isCompatibleResumption = !!tourData.resumed && (expType === "onboarding" && tour?.type === "tour" || expType === "tour" && tour?.type === "onboarding");
5270
- if (!matchesType && !isCompatibleResumption) {
5292
+ const isCompatible = shouldAcceptTourExperienceType(expType, tour?.type, !!tourData.resumed);
5293
+ if (!isCompatible) {
5271
5294
  emitSdkDebugLog("[TourClient] Ignoring tour start for mismatched experience type", {
5272
5295
  incomingType: tour?.type,
5273
5296
  hookType: expType,
@@ -5544,6 +5567,11 @@ function useTourPlayback({
5544
5567
  const endingTourId = tourRef.current?.id;
5545
5568
  const endingPreviewRunId = previewRunIdRef.current;
5546
5569
  const endingStepOrder = stepIndexRef.current;
5570
+ const completedPreviewDraft = getCompletedDraftPreviewToSuppress({
5571
+ endingTourId,
5572
+ endingPreviewRunId,
5573
+ experienceType
5574
+ });
5547
5575
  isActiveRef.current = false;
5548
5576
  startRequestedRef.current = false;
5549
5577
  releasePlaybackOwnership();
@@ -5553,6 +5581,10 @@ function useTourPlayback({
5553
5581
  runCleanup(pendingManualWaitCleanupRef.current);
5554
5582
  pendingManualWaitCleanupRef.current = null;
5555
5583
  clearPendingManualInputSync();
5584
+ if (completedPreviewDraft) {
5585
+ persistSuppressedDraftPreview(completedPreviewDraft);
5586
+ clearActiveDraftPreview(experienceType);
5587
+ }
5556
5588
  if (!skipRequestedRef.current && userProfile?.userId && tourRef.current) {
5557
5589
  markTourComplete(serverUrl, toursApiBaseRef.current, tourRef.current.id, userProfile.userId, experienceType, websiteId);
5558
5590
  }
@@ -5577,7 +5609,7 @@ function useTourPlayback({
5577
5609
  });
5578
5610
  }
5579
5611
  if (reviewModeRef.current) {
5580
- if (endingTourId) {
5612
+ if (endingTourId && !completedPreviewDraft) {
5581
5613
  persistSuppressedDraftPreview({
5582
5614
  id: endingTourId,
5583
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,9 +4460,8 @@ function useTourPlayback({
4436
4460
  }
4437
4461
  const tour = tourData.tourContext ?? tourRef.current;
4438
4462
  const expType = experienceTypeRef.current;
4439
- const matchesType = !tour?.type || tour.type === expType;
4440
- const isCompatibleResumption = !!tourData.resumed && (expType === "onboarding" && tour?.type === "tour" || expType === "tour" && tour?.type === "onboarding");
4441
- if (!matchesType && !isCompatibleResumption) {
4463
+ const isCompatible = shouldAcceptTourExperienceType(expType, tour?.type, !!tourData.resumed);
4464
+ if (!isCompatible) {
4442
4465
  emitSdkDebugLog("[TourClient] Ignoring tour start for mismatched experience type", {
4443
4466
  incomingType: tour?.type,
4444
4467
  hookType: expType,
@@ -4715,6 +4738,11 @@ function useTourPlayback({
4715
4738
  const endingTourId = tourRef.current?.id;
4716
4739
  const endingPreviewRunId = previewRunIdRef.current;
4717
4740
  const endingStepOrder = stepIndexRef.current;
4741
+ const completedPreviewDraft = getCompletedDraftPreviewToSuppress({
4742
+ endingTourId,
4743
+ endingPreviewRunId,
4744
+ experienceType
4745
+ });
4718
4746
  isActiveRef.current = false;
4719
4747
  startRequestedRef.current = false;
4720
4748
  releasePlaybackOwnership();
@@ -4724,6 +4752,10 @@ function useTourPlayback({
4724
4752
  runCleanup(pendingManualWaitCleanupRef.current);
4725
4753
  pendingManualWaitCleanupRef.current = null;
4726
4754
  clearPendingManualInputSync();
4755
+ if (completedPreviewDraft) {
4756
+ persistSuppressedDraftPreview(completedPreviewDraft);
4757
+ clearActiveDraftPreview(experienceType);
4758
+ }
4727
4759
  if (!skipRequestedRef.current && userProfile?.userId && tourRef.current) {
4728
4760
  markTourComplete(serverUrl, toursApiBaseRef.current, tourRef.current.id, userProfile.userId, experienceType, websiteId);
4729
4761
  }
@@ -4748,7 +4780,7 @@ function useTourPlayback({
4748
4780
  });
4749
4781
  }
4750
4782
  if (reviewModeRef.current) {
4751
- if (endingTourId) {
4783
+ if (endingTourId && !completedPreviewDraft) {
4752
4784
  persistSuppressedDraftPreview({
4753
4785
  id: endingTourId,
4754
4786
  experienceType
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@modelnex/sdk",
3
- "version": "0.5.55",
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",