@burdenoff/fe-libs 2026.1003.4 → 2026.1004.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.
Files changed (42) hide show
  1. package/dist/shared/providers/AppShellProvider.d.ts +2 -0
  2. package/dist/shared/providers/AppShellProvider.d.ts.map +1 -1
  3. package/dist/shared/providers/AppShellProvider.js +153 -147
  4. package/dist/shared/tours/TourPermissionsBoundary.d.ts +7 -0
  5. package/dist/shared/tours/TourPermissionsBoundary.d.ts.map +1 -0
  6. package/dist/shared/tours/TourPermissionsBoundary.js +17 -0
  7. package/dist/shared/tours/TourPlayerProvider.d.ts +1 -1
  8. package/dist/shared/tours/TourPlayerProvider.d.ts.map +1 -1
  9. package/dist/shared/tours/TourPlayerProvider.js +52 -51
  10. package/dist/shared/tours/TourTrigger.js +30 -26
  11. package/dist/shared/tours/ToursContext.d.ts +1 -0
  12. package/dist/shared/tours/ToursContext.d.ts.map +1 -1
  13. package/dist/shared/tours/ToursContext.js +123 -120
  14. package/dist/shared/tours/permissions.d.ts +9 -0
  15. package/dist/shared/tours/permissions.d.ts.map +1 -0
  16. package/dist/shared/tours/permissions.js +7 -0
  17. package/dist/shared/tours/progress.d.ts +6 -1
  18. package/dist/shared/tours/progress.d.ts.map +1 -1
  19. package/dist/shared/tours/progress.js +11 -1
  20. package/dist/shared/tours/routeCatalog.d.ts.map +1 -1
  21. package/dist/shared/tours/routeCatalog.js +51 -0
  22. package/dist/shared/tours/tourTrigger/DesktopTourDropdown.d.ts +2 -0
  23. package/dist/shared/tours/tourTrigger/DesktopTourDropdown.d.ts.map +1 -1
  24. package/dist/shared/tours/tourTrigger/DesktopTourDropdown.js +32 -31
  25. package/dist/shared/tours/tourTrigger/MobileTourSheet.d.ts +2 -0
  26. package/dist/shared/tours/tourTrigger/MobileTourSheet.d.ts.map +1 -1
  27. package/dist/shared/tours/tourTrigger/MobileTourSheet.js +42 -41
  28. package/dist/shared/tours/tourTrigger/TourLoadError.d.ts +4 -0
  29. package/dist/shared/tours/tourTrigger/TourLoadError.d.ts.map +1 -0
  30. package/dist/shared/tours/tourTrigger/TourLoadError.js +21 -0
  31. package/dist/shared/tours/toursContext/gql.d.ts.map +1 -1
  32. package/dist/shared/tours/toursContext/gql.js +2 -0
  33. package/dist/shared/tours/toursContext/useTourMutations.d.ts.map +1 -1
  34. package/dist/shared/tours/toursContext/useTourMutations.js +96 -59
  35. package/dist/shared/tours/types.d.ts +4 -0
  36. package/dist/shared/tours/types.d.ts.map +1 -1
  37. package/dist/shared/tours/useTourPlayer.d.ts +1 -0
  38. package/dist/shared/tours/useTourPlayer.d.ts.map +1 -1
  39. package/dist/shared/tours/useTourPlayer.js +152 -141
  40. package/dist/shared-tours.js +9 -9
  41. package/dist/shared.js +9 -9
  42. package/package.json +2 -2
@@ -5,64 +5,65 @@ import { createContext as r, use as i, useEffect as a } from "react";
5
5
  import { Fragment as o, jsx as s, jsxs as c } from "react/jsx-runtime";
6
6
  //#region src/shared/tours/TourPlayerProvider.tsx
7
7
  var l = r(null);
8
- function u({ children: r, onTourStart: i, onTourComplete: a, onTourSkip: u, onStepChange: f, onStepComplete: p, zIndex: m = 9998 }) {
9
- let h = e({
10
- onTourStart: i,
11
- onTourComplete: a,
12
- onTourSkip: u,
13
- onStepChange: f,
14
- onStepComplete: p
15
- }), g = {
16
- isPlaying: h.isPlaying,
17
- currentTour: h.currentTour,
18
- currentStepIndex: h.currentStepIndex,
19
- isPaused: h.isPaused,
20
- isCompleted: h.isCompleted,
21
- isSkipped: h.isSkipped,
22
- currentStep: h.currentStep,
23
- totalSteps: h.totalSteps,
24
- progress: h.progress,
25
- canGoNext: h.canGoNext,
26
- canGoPrevious: h.canGoPrevious,
27
- startTour: h.startTour,
28
- stopTour: h.stopTour,
29
- nextStep: h.nextStep,
30
- previousStep: h.previousStep,
31
- goToStep: h.goToStep,
32
- pauseTour: h.pauseTour,
33
- resumeTour: h.resumeTour,
34
- skipTour: h.skipTour,
35
- completeTour: h.completeTour
8
+ function u({ children: r, scopeKey: i, onTourStart: a, onTourComplete: u, onTourSkip: f, onStepChange: p, onStepComplete: m, zIndex: h = 9998 }) {
9
+ let g = e({
10
+ scopeKey: i,
11
+ onTourStart: a,
12
+ onTourComplete: u,
13
+ onTourSkip: f,
14
+ onStepChange: p,
15
+ onStepComplete: m
16
+ }), _ = {
17
+ isPlaying: g.isPlaying,
18
+ currentTour: g.currentTour,
19
+ currentStepIndex: g.currentStepIndex,
20
+ isPaused: g.isPaused,
21
+ isCompleted: g.isCompleted,
22
+ isSkipped: g.isSkipped,
23
+ currentStep: g.currentStep,
24
+ totalSteps: g.totalSteps,
25
+ progress: g.progress,
26
+ canGoNext: g.canGoNext,
27
+ canGoPrevious: g.canGoPrevious,
28
+ startTour: g.startTour,
29
+ stopTour: g.stopTour,
30
+ nextStep: g.nextStep,
31
+ previousStep: g.previousStep,
32
+ goToStep: g.goToStep,
33
+ pauseTour: g.pauseTour,
34
+ resumeTour: g.resumeTour,
35
+ skipTour: g.skipTour,
36
+ completeTour: g.completeTour
36
37
  };
37
38
  return /* @__PURE__ */ c(l.Provider, {
38
- value: g,
39
- children: [r, h.isPlaying && !h.isPaused && h.currentStep && /* @__PURE__ */ c(o, { children: [
39
+ value: _,
40
+ children: [r, g.isPlaying && !g.isPaused && g.currentStep && /* @__PURE__ */ c(o, { children: [
40
41
  /* @__PURE__ */ s(t, {
41
- targetRect: h.targetRect,
42
- zIndex: m
42
+ targetRect: g.targetRect,
43
+ zIndex: h
43
44
  }),
44
45
  /* @__PURE__ */ s(n, {
45
- step: h.currentStep,
46
- stepIndex: h.currentStepIndex,
47
- totalSteps: h.totalSteps,
48
- onNext: h.nextStep,
49
- onPrevious: h.previousStep,
50
- onSkip: h.skipTour,
51
- onComplete: h.completeTour,
52
- canGoNext: h.canGoNext,
53
- canGoPrevious: h.canGoPrevious,
54
- isLastStep: h.isLastStep,
55
- placement: h.currentStep.placement,
56
- targetRect: h.targetRect
46
+ step: g.currentStep,
47
+ stepIndex: g.currentStepIndex,
48
+ totalSteps: g.totalSteps,
49
+ onNext: g.nextStep,
50
+ onPrevious: g.previousStep,
51
+ onSkip: g.skipTour,
52
+ onComplete: g.completeTour,
53
+ canGoNext: g.canGoNext,
54
+ canGoPrevious: g.canGoPrevious,
55
+ isLastStep: g.isLastStep,
56
+ placement: g.currentStep.placement,
57
+ targetRect: g.targetRect
57
58
  }),
58
59
  /* @__PURE__ */ s(d, {
59
- onNext: h.nextStep,
60
- onPrevious: h.previousStep,
61
- onSkip: h.skipTour,
62
- onComplete: h.completeTour,
63
- canGoNext: h.canGoNext,
64
- canGoPrevious: h.canGoPrevious,
65
- isLastStep: h.isLastStep
60
+ onNext: g.nextStep,
61
+ onPrevious: g.previousStep,
62
+ onSkip: g.skipTour,
63
+ onComplete: g.completeTour,
64
+ canGoNext: g.canGoNext,
65
+ canGoPrevious: g.canGoPrevious,
66
+ isLastStep: g.isLastStep
66
67
  })
67
68
  ] })]
68
69
  });
@@ -47,7 +47,7 @@ function O({ actions: e }) {
47
47
  function k({ pathname: i, navigateTo: a, actions: o }) {
48
48
  let [v, y] = h(!1), [b, T] = h(!1), [D, O] = h(null), k = m(null), A = m(null);
49
49
  t("header-help", v, d(() => y(!1), []));
50
- let { pageTours: j, productId: M, moduleId: N, pageId: P, loading: F } = s(), I = n(), L = !!a, R = e()?.pageAccessDenied ?? !1;
50
+ let { pageTours: j, productId: M, moduleId: N, pageId: P, loading: F, error: I, refetch: L } = s(), R = n(), z = !!a, B = e()?.pageAccessDenied ?? !1;
51
51
  f(() => {
52
52
  let e = () => {
53
53
  T(window.innerWidth < 768);
@@ -66,23 +66,23 @@ function k({ pathname: i, navigateTo: a, actions: o }) {
66
66
  };
67
67
  return v && document.addEventListener("keydown", e), () => document.removeEventListener("keydown", e);
68
68
  }, [v]);
69
- let z = (e) => {
69
+ let V = (e) => {
70
70
  y(!1);
71
71
  let t = E(e, i, {
72
72
  productId: M ?? "",
73
73
  moduleId: N,
74
74
  pageId: P
75
- }, L);
75
+ }, z);
76
76
  if (t.type === "navigate") {
77
77
  O(e.id), a?.(t.targetPath);
78
78
  return;
79
79
  }
80
80
  t.type !== "ignore" && window.setTimeout(() => {
81
- I(e);
81
+ R(e);
82
82
  }, S);
83
- }, B = (e) => {
83
+ }, H = (e) => {
84
84
  y(!1), e.onClick?.();
85
- }, V = p(() => ({
85
+ }, U = p(() => ({
86
86
  productId: M ?? "",
87
87
  moduleId: N,
88
88
  pageId: P
@@ -90,40 +90,40 @@ function k({ pathname: i, navigateTo: a, actions: o }) {
90
90
  N,
91
91
  P,
92
92
  M
93
- ]), H = p(() => j.filter((e) => w(e, M)).sort((e, t) => {
94
- let n = r(e, V) - r(t, V);
93
+ ]), W = p(() => j.filter((e) => w(e, M)).sort((e, t) => {
94
+ let n = r(e, U) - r(t, U);
95
95
  if (n !== 0) return n;
96
96
  let i = (t.priority ?? 0) - (e.priority ?? 0);
97
97
  return i === 0 ? (e.displayOrder ?? 0) - (t.displayOrder ?? 0) : i;
98
98
  }), [
99
- V,
99
+ U,
100
100
  M,
101
101
  j
102
102
  ]);
103
103
  f(() => {
104
104
  if (!D) return;
105
- let e = H.find((e) => e.id === D);
105
+ let e = W.find((e) => e.id === D);
106
106
  if (!e) {
107
107
  O(null);
108
108
  return;
109
109
  }
110
- let t = E(e, i, V, L);
110
+ let t = E(e, i, U, z);
111
111
  if (t.type === "navigate") return;
112
112
  if (t.type === "ignore") {
113
113
  O(null);
114
114
  return;
115
115
  }
116
116
  let n = window.setTimeout(() => {
117
- I(e), O(null);
117
+ R(e), O(null);
118
118
  }, C);
119
119
  return () => window.clearTimeout(n);
120
120
  }, [
121
- H,
122
- L,
123
- V,
121
+ W,
122
+ z,
123
+ U,
124
124
  i,
125
125
  D,
126
- I
126
+ R
127
127
  ]), f(() => {
128
128
  if (!D) return;
129
129
  let e = window.setTimeout(() => {
@@ -131,34 +131,38 @@ function k({ pathname: i, navigateTo: a, actions: o }) {
131
131
  }, x);
132
132
  return () => window.clearTimeout(e);
133
133
  }, [D]);
134
- let U = H.length > 0, W = R;
134
+ let G = W.length > 0, K = B;
135
135
  return f(() => {
136
- W && v && y(!1);
137
- }, [W, v]), W ? null : /* @__PURE__ */ _("div", {
136
+ K && v && y(!1);
137
+ }, [K, v]), K ? null : /* @__PURE__ */ _("div", {
138
138
  className: "relative",
139
139
  children: [
140
140
  /* @__PURE__ */ g(c, {
141
141
  ref: k,
142
142
  isOpen: v,
143
- hasTours: U,
143
+ hasTours: G,
144
144
  onClick: () => y(!v)
145
145
  }),
146
146
  v && b && /* @__PURE__ */ g(l, {
147
147
  ref: A,
148
148
  loading: F,
149
- tours: H,
149
+ error: I,
150
+ onRetry: L,
151
+ tours: W,
150
152
  onClose: () => y(!1),
151
- onStartTour: z,
153
+ onStartTour: V,
152
154
  actions: o,
153
- onAction: B
155
+ onAction: H
154
156
  }),
155
157
  v && !b && /* @__PURE__ */ g(u, {
156
158
  ref: A,
157
159
  loading: F,
158
- tours: H,
159
- onStartTour: z,
160
+ error: I,
161
+ onRetry: L,
162
+ tours: W,
163
+ onStartTour: V,
160
164
  actions: o,
161
- onAction: B
165
+ onAction: H
162
166
  })
163
167
  ]
164
168
  });
@@ -2,6 +2,7 @@ import { ReactNode } from 'react';
2
2
  import { Tour } from './types';
3
3
  import { TrackEventType, TrackEventOptions } from './toursContext/useTourMutations';
4
4
  export interface ToursContextValue {
5
+ progressScopeKey?: string;
5
6
  tours: Tour[];
6
7
  pageTours: Tour[];
7
8
  loading: boolean;
@@ -1 +1 @@
1
- {"version":3,"file":"ToursContext.d.ts","sourceRoot":"","sources":["../../../src/shared/tours/ToursContext.tsx"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAQL,KAAK,SAAS,EACf,MAAM,OAAO,CAAC;AAOf,OAAO,EAAE,KAAK,IAAI,EAAE,MAAM,SAAS,CAAC;AAOpC,OAAO,EAEL,KAAK,cAAc,EACnB,KAAK,iBAAiB,EACvB,MAAM,iCAA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,EAAE,MAAM,GAAG,SAAS,CAAC;IAC7B,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC;CAC5B;AAID,MAAM,WAAW,kBAAkB;IACjC,QAAQ,EAAE,SAAS,CAAC;IACpB,0EAA0E;IAC1E,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,yEAAyE;IACzE,iBAAiB,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,MAAM,GAAG,SAAS,CAAC;IAC7D,kEAAkE;IAClE,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED,wBAAgB,aAAa,CAAC,EAC5B,QAAQ,EACR,aAAsB,EACtB,iBAAiB,EACjB,QAAgB,GACjB,EAAE,kBAAkB,2CA+TpB;AAED,wBAAgB,eAAe,IAAI,iBAAiB,CAMnD;AAED,wBAAgB,mBAAmB,IAAI,iBAAiB,CAmBvD;AAED,wBAAgB,QAAQ;;;;mBAjYP,IAAI;4BAET,MAAM,UACN,SAAS,GAAG,WAAW,GAAG,SAAS,WAClC,MAAM,KACZ,OAAO,CAAC,IAAI,CAAC;EAqYnB;AAED,wBAAgB,gBAAgB,IAAI,IAAI,GAAG,IAAI,CAG9C"}
@@ -3,172 +3,175 @@ import "../../shared-graphql.js";
3
3
  import { useAppShell as t } from "../providers/shell/AppShellContext.js";
4
4
  import { useAuth as n } from "../providers/shell/AuthProvider.js";
5
5
  import { useActiveContext as r } from "../providers/shell/ActiveContextProvider.js";
6
- import { useLogger as i } from "../logger/useLogger.js";
6
+ import { useSafePermissions as i } from "../providers/shell/PermissionProvider.js";
7
+ import { useLogger as a } from "../logger/useLogger.js";
7
8
  import "../../shared-logger.js";
8
- import { isTourVisibleForContext as a } from "./routeCatalog.js";
9
- import { GET_TOURS_FOR_CONTEXT as o, GET_TOURS_FOR_CONTEXT_WITHOUT_PROGRESS as s } from "./toursContext/gql.js";
10
- import { isMyProgressFieldMissingError as c, isTeardownInvariant as l } from "./toursContext/errors.js";
11
- import { normalizeDeviceType as u } from "./toursContext/session.js";
12
- import { deriveRouteContext as d } from "./toursContext/route.js";
13
- import { useIdleReady as ee } from "./toursContext/useIdleReady.js";
14
- import { useTourMutations as te } from "./toursContext/useTourMutations.js";
15
- import { createContext as f, use as p, useCallback as m, useEffect as h, useMemo as g, useRef as _, useState as v } from "react";
16
- import { jsx as ne } from "react/jsx-runtime";
17
- import { useLocation as y } from "react-router";
9
+ import { isTourAllowedByPermissions as o } from "./permissions.js";
10
+ import { isTourVisibleForContext as s } from "./routeCatalog.js";
11
+ import { GET_TOURS_FOR_CONTEXT as c, GET_TOURS_FOR_CONTEXT_WITHOUT_PROGRESS as l } from "./toursContext/gql.js";
12
+ import { isMyProgressFieldMissingError as u, isTeardownInvariant as d } from "./toursContext/errors.js";
13
+ import { normalizeDeviceType as ee } from "./toursContext/session.js";
14
+ import { deriveRouteContext as te } from "./toursContext/route.js";
15
+ import { useIdleReady as ne } from "./toursContext/useIdleReady.js";
16
+ import { useTourMutations as re } from "./toursContext/useTourMutations.js";
17
+ import { createContext as ie, use as f, useCallback as p, useEffect as m, useMemo as h, useRef as g, useState as _ } from "react";
18
+ import { jsx as ae } from "react/jsx-runtime";
19
+ import { useLocation as oe } from "react-router";
18
20
  //#region src/shared/tours/ToursContext.tsx
19
- var b = f(null);
20
- function x({ children: f, defaultPageId: p = "home", getPageIdFromPath: x, disabled: S = !1 }) {
21
- let C = y(), w = e("global"), { workspaceId: T } = r(), { user: E } = n(), { productSlug: D } = t(), O = i("ToursContext"), k = T ?? void 0, A = S || C.pathname.startsWith("/devportal"), { moduleId: j, pageId: M } = g(() => d(C.pathname, D, p, x), [
22
- p,
23
- x,
24
- C.pathname,
25
- D
26
- ]), [N, P] = v([]), [F, I] = v(!1), [L, R] = v(null), z = ee(), B = _([]), re = _(0), ie = _(/* @__PURE__ */ new Map()), V = _(void 0), H = _(!1), U = _(!0), W = _(0), G = _(!0);
27
- h(() => (U.current = !0, () => {
21
+ var v = ie(null);
22
+ function y({ children: ie, defaultPageId: f = "home", getPageIdFromPath: y, disabled: b = !1 }) {
23
+ let x = oe(), S = e("global"), { workspaceId: C } = r(), { user: w } = n(), T = i(), { productSlug: E } = t(), D = a("ToursContext"), O = C ?? void 0, k = b || x.pathname.startsWith("/devportal"), { moduleId: A, pageId: j } = h(() => te(x.pathname, E, f, y), [
24
+ f,
25
+ y,
26
+ x.pathname,
27
+ E
28
+ ]), [M, N] = _([]), [P, F] = _(!1), [I, L] = _(null), R = ne(), z = g([]), se = g(0), B = g(/* @__PURE__ */ new Map()), V = g(void 0), H = g(!1), U = g(!0), W = g(0), G = g(!0);
29
+ m(() => (U.current = !0, () => {
28
30
  U.current = !1;
29
31
  }), []);
30
- let K = m(async (e = !1) => {
31
- if (!z && !e) return;
32
- if (A) {
33
- U.current && (P([]), I(!1), R(null));
32
+ let K = p(async (e = !1) => {
33
+ if (!R && !e) return;
34
+ if (k) {
35
+ U.current && (N([]), F(!1), L(null));
34
36
  return;
35
37
  }
36
- if (!w) return;
37
- let t = O.child("fetch", {
38
- productSlug: D,
39
- workspaceId: k,
40
- moduleId: j,
41
- pageId: M
42
- }), n = u(), r = [
43
- D,
38
+ if (!S) return;
39
+ let t = D.child("fetch", {
40
+ productSlug: E,
41
+ workspaceId: O,
42
+ moduleId: A,
43
+ pageId: j
44
+ }), n = ee(), r = [
45
+ E,
46
+ A ?? "",
44
47
  j ?? "",
45
- M ?? "",
46
- k,
48
+ O,
47
49
  n,
48
- E?.id ?? "anonymous"
50
+ w?.id ?? "anonymous"
49
51
  ].join("::");
50
52
  if (!e && H.current && V.current === r) return;
51
- U.current && (I(!0), R(null));
53
+ U.current && (F(!0), L(null));
52
54
  let i = ++W.current;
53
55
  try {
54
56
  let e = { context: {
55
- productId: D,
56
- moduleId: j,
57
- pageId: M,
58
- workspaceId: k,
57
+ productId: E,
58
+ moduleId: A,
59
+ pageId: j,
60
+ workspaceId: O,
59
61
  deviceType: n
60
- } }, a = "network-only", l, u = G.current ? o : s;
62
+ } }, a = "network-only", o, s = G.current ? c : l;
61
63
  try {
62
- l = await w.query({
63
- query: u,
64
+ o = await S.query({
65
+ query: s,
64
66
  variables: e,
65
67
  fetchPolicy: a,
66
68
  errorPolicy: "none"
67
69
  });
68
- let n = l.errors;
69
- u === o && n?.some((e) => c(e)) && (G.current = !1, t.warn("[ToursContext] Gateway returned a Tour.myProgress validation error — falling back to query without progress chips until the backend field is published."), l = await w.query({
70
- query: s,
70
+ let n = o.errors;
71
+ s === c && n?.some((e) => u(e)) && (G.current = !1, t.warn("[ToursContext] Gateway returned a Tour.myProgress validation error — falling back to query without progress chips until the backend field is published."), o = await S.query({
72
+ query: l,
71
73
  variables: e,
72
74
  fetchPolicy: a,
73
75
  errorPolicy: "none"
74
76
  }));
75
77
  } catch (n) {
76
- if (u === o && c(n)) G.current = !1, t.warn("[ToursContext] Gateway does not expose Tour.myProgress yet — falling back to query without progress chips until the backend field is published."), l = await w.query({
77
- query: s,
78
+ if (s === c && u(n)) G.current = !1, t.warn("[ToursContext] Gateway does not expose Tour.myProgress yet — falling back to query without progress chips until the backend field is published."), o = await S.query({
79
+ query: l,
78
80
  variables: e,
79
81
  fetchPolicy: a,
80
82
  errorPolicy: "none"
81
83
  });
82
84
  else throw n;
83
85
  }
84
- let d = (l.data?.toursForContext ?? []).filter((e, t, n) => n.findIndex((t) => t.id === e.id) === t);
85
- U.current && i === W.current && (P(d), V.current = r, H.current = !0);
86
+ let d = (o.data?.toursForContext ?? []).filter((e, t, n) => n.findIndex((t) => t.id === e.id) === t);
87
+ U.current && i === W.current && (N(d), V.current = r, H.current = !0);
86
88
  } catch (e) {
87
- if (!U.current || i !== W.current || l(e)) return;
89
+ if (!U.current || i !== W.current || d(e)) return;
88
90
  let n = e instanceof Error ? e : /* @__PURE__ */ Error("Failed to fetch tours");
89
- t.error("Failed to fetch tours for context", n), R(n), P([]);
91
+ t.error("Failed to fetch tours for context", n), L(n), N([]);
90
92
  } finally {
91
- U.current && i === W.current && I(!1);
93
+ U.current && i === W.current && F(!1);
92
94
  }
93
95
  }, [
94
- z,
96
+ R,
97
+ k,
98
+ S,
99
+ D,
95
100
  A,
96
- w,
97
- O,
98
101
  j,
99
- M,
100
- D,
101
- k,
102
- E?.id
103
- ]), q = _(E?.id);
104
- h(() => {
105
- q.current !== E?.id && (q.current = E?.id, H.current = !1, V.current = void 0, U.current && P([]));
106
- }, [E?.id]), h(() => {
102
+ E,
103
+ O,
104
+ w?.id
105
+ ]), q = `${w?.id ?? ""}:${O ?? ""}`, [ce, le] = _(q);
106
+ ce !== q && (le(q), N([]), F(!0), L(null), z.current = [], H.current = !1, V.current = void 0, W.current += 1, B.current.clear()), m(() => {
107
107
  K();
108
- }, [K]), h(() => {
109
- B.current = N;
110
- }, [N]);
111
- let J = m(() => {
108
+ }, [K]), m(() => {
109
+ z.current = M;
110
+ }, [M]);
111
+ let J = p(() => {
112
112
  K(!0);
113
- }, [K]), Y = g(() => N.filter((e) => e.isActive && e.steps?.length > 0 && a(e, {
114
- productId: D,
115
- moduleId: j,
116
- pageId: M
113
+ }, [K]), Y = h(() => M.filter((e) => o(e, T)), [M, T]), X = h(() => Y.filter((e) => e.isActive && e.steps?.length > 0 && s(e, {
114
+ productId: E,
115
+ moduleId: A,
116
+ pageId: j
117
117
  })).sort((e, t) => (t.priority ?? 0) - (e.priority ?? 0)), [
118
- N,
118
+ Y,
119
+ A,
119
120
  j,
120
- M,
121
- D
122
- ]), X = g(() => z ? Y.find((e) => e.triggerType === "AUTO_FIRST_VISIT" || e.triggerType === "AUTO_ALWAYS") ?? null : null, [Y, z]), { trackProgress: Z, recordStepCompletion: Q, trackEvent: $ } = te({
123
- globalClient: w,
124
- userId: E?.id,
125
- productSlug: D,
126
- moduleId: j,
127
- pageId: M,
128
- workspaceId: k,
129
- setAllTours: P,
130
- allToursRef: B,
131
- progressMutationVersionRef: re,
132
- latestProgressMutationByTourRef: ie
133
- }), ae = g(() => ({
134
- tours: N,
135
- pageTours: Y,
136
- loading: F,
137
- error: L,
121
+ E
122
+ ]), Z = h(() => R ? X.find((e) => e.triggerType === "AUTO_FIRST_VISIT" || e.triggerType === "AUTO_ALWAYS") ?? null : null, [X, R]), { trackProgress: Q, recordStepCompletion: $, trackEvent: ue } = re({
123
+ globalClient: S,
124
+ userId: w?.id,
125
+ productSlug: E,
126
+ moduleId: A,
127
+ pageId: j,
128
+ workspaceId: O,
129
+ setAllTours: N,
130
+ allToursRef: z,
131
+ progressMutationVersionRef: se,
132
+ latestProgressMutationByTourRef: B
133
+ }), de = h(() => ({
134
+ progressScopeKey: `${w?.id ?? ""}:${O ?? ""}`,
135
+ tours: Y,
136
+ pageTours: X,
137
+ loading: P,
138
+ error: I,
138
139
  refetch: J,
139
- trackProgress: Z,
140
- recordStepCompletion: Q,
141
- trackEvent: $,
142
- autoStartTour: X,
143
- productId: D,
144
- moduleId: j,
145
- pageId: M
140
+ trackProgress: Q,
141
+ recordStepCompletion: $,
142
+ trackEvent: ue,
143
+ autoStartTour: Z,
144
+ productId: E,
145
+ moduleId: A,
146
+ pageId: j
146
147
  }), [
147
- N,
148
- X,
149
- L,
150
- F,
151
- j,
152
- M,
153
148
  Y,
154
- D,
155
- Q,
156
- J,
149
+ w?.id,
150
+ O,
151
+ Z,
152
+ I,
153
+ P,
154
+ A,
155
+ j,
156
+ X,
157
+ E,
157
158
  $,
158
- Z
159
+ J,
160
+ ue,
161
+ Q
159
162
  ]);
160
- return /* @__PURE__ */ ne(b.Provider, {
161
- value: ae,
162
- children: f
163
+ return /* @__PURE__ */ ae(v.Provider, {
164
+ value: de,
165
+ children: ie
163
166
  });
164
167
  }
165
- function S() {
166
- let e = p(b);
168
+ function b() {
169
+ let e = f(v);
167
170
  if (!e) throw Error("useToursContext must be used within a ToursProvider");
168
171
  return e;
169
172
  }
170
- function C() {
171
- return p(b) || {
173
+ function x() {
174
+ return f(v) || {
172
175
  tours: [],
173
176
  pageTours: [],
174
177
  loading: !1,
@@ -183,8 +186,8 @@ function C() {
183
186
  pageId: void 0
184
187
  };
185
188
  }
186
- function w() {
187
- let e = S();
189
+ function S() {
190
+ let e = b();
188
191
  return {
189
192
  tours: e.pageTours,
190
193
  loading: e.loading,
@@ -193,8 +196,8 @@ function w() {
193
196
  trackProgress: e.trackProgress
194
197
  };
195
198
  }
196
- function T() {
197
- return S().autoStartTour;
199
+ function C() {
200
+ return b().autoStartTour;
198
201
  }
199
202
  //#endregion
200
- export { x as ToursProvider, T as useAutoStartTour, C as useSafeToursContext, w as useTours, S as useToursContext };
203
+ export { y as ToursProvider, C as useAutoStartTour, x as useSafeToursContext, S as useTours, b as useToursContext };
@@ -0,0 +1,9 @@
1
+ import { Tour } from './types';
2
+ interface TourPermissions {
3
+ isLoading: boolean;
4
+ hasPermission: (permission: string) => boolean;
5
+ }
6
+ /** Tour targeting is guidance; the gateway still authorizes every product action. */
7
+ export declare function isTourAllowedByPermissions(tour: Pick<Tour, 'triggerConfig'>, permissions: TourPermissions | null): boolean;
8
+ export {};
9
+ //# sourceMappingURL=permissions.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"permissions.d.ts","sourceRoot":"","sources":["../../../src/shared/tours/permissions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAEpC,UAAU,eAAe;IACvB,SAAS,EAAE,OAAO,CAAC;IACnB,aAAa,EAAE,CAAC,UAAU,EAAE,MAAM,KAAK,OAAO,CAAC;CAChD;AAED,qFAAqF;AACrF,wBAAgB,0BAA0B,CACxC,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,eAAe,CAAC,EACjC,WAAW,EAAE,eAAe,GAAG,IAAI,GAClC,OAAO,CAYT"}
@@ -0,0 +1,7 @@
1
+ //#region src/shared/tours/permissions.ts
2
+ function e(e, t) {
3
+ let n = e.triggerConfig?.requiredPermissions;
4
+ return n === void 0 ? !0 : !Array.isArray(n) || n.some((e) => typeof e != "string" || !e.trim()) ? !1 : n.length === 0 ? !0 : !t || t.isLoading ? !1 : n.every((e) => t.hasPermission(e));
5
+ }
6
+ //#endregion
7
+ export { e as isTourAllowedByPermissions };
@@ -1,7 +1,12 @@
1
- import { TourUserStatus, TourUserProgressSummary } from './types';
1
+ import { TourStep, TourUserStatus, TourUserProgressSummary } from './types';
2
2
  export interface TourProgressCarrier {
3
3
  id: string;
4
4
  myProgress?: TourUserProgressSummary | null;
5
5
  }
6
6
  export declare function withTourProgressStatus<T extends TourProgressCarrier>(tours: readonly T[], tourId: string, status: TourUserStatus): T[];
7
+ /** Resume only an unfinished tour, using persisted step IDs that still exist. */
8
+ export declare function tourResumeStepIndex(tour: {
9
+ steps: readonly Pick<TourStep, 'id'>[];
10
+ myProgress?: TourUserProgressSummary | null;
11
+ }): number;
7
12
  //# sourceMappingURL=progress.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"progress.d.ts","sourceRoot":"","sources":["../../../src/shared/tours/progress.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,uBAAuB,EAAE,MAAM,SAAS,CAAC;AAEvE,MAAM,WAAW,mBAAmB;IAClC,EAAE,EAAE,MAAM,CAAC;IACX,UAAU,CAAC,EAAE,uBAAuB,GAAG,IAAI,CAAC;CAC7C;AAED,wBAAgB,sBAAsB,CAAC,CAAC,SAAS,mBAAmB,EAClE,KAAK,EAAE,SAAS,CAAC,EAAE,EACnB,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,cAAc,GACrB,CAAC,EAAE,CAYL"}
1
+ {"version":3,"file":"progress.d.ts","sourceRoot":"","sources":["../../../src/shared/tours/progress.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,cAAc,EAAE,uBAAuB,EAAE,MAAM,SAAS,CAAC;AAEjF,MAAM,WAAW,mBAAmB;IAClC,EAAE,EAAE,MAAM,CAAC;IACX,UAAU,CAAC,EAAE,uBAAuB,GAAG,IAAI,CAAC;CAC7C;AAED,wBAAgB,sBAAsB,CAAC,CAAC,SAAS,mBAAmB,EAClE,KAAK,EAAE,SAAS,CAAC,EAAE,EACnB,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,cAAc,GACrB,CAAC,EAAE,CAkBL;AAED,iFAAiF;AACjF,wBAAgB,mBAAmB,CAAC,IAAI,EAAE;IACxC,KAAK,EAAE,SAAS,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,EAAE,CAAC;IACvC,UAAU,CAAC,EAAE,uBAAuB,GAAG,IAAI,CAAC;CAC7C,GAAG,MAAM,CAQT"}
@@ -3,10 +3,20 @@ function e(e, t, n) {
3
3
  return e.map((e) => e.id === t ? {
4
4
  ...e,
5
5
  myProgress: {
6
+ ...e.myProgress,
7
+ ...n === "IN_PROGRESS" && e.myProgress?.status !== "IN_PROGRESS" ? {
8
+ completedSteps: [],
9
+ currentStepId: null
10
+ } : {},
6
11
  id: e.myProgress?.id ?? `optimistic-${t}`,
7
12
  status: n
8
13
  }
9
14
  } : e);
10
15
  }
16
+ function t(e) {
17
+ if (e.myProgress?.status !== "IN_PROGRESS") return 0;
18
+ let t = e.myProgress.completedSteps, n = new Set(Array.isArray(t) ? t.filter((e) => typeof e == "string") : []), r = e.steps.findIndex((e) => !n.has(e.id));
19
+ return Math.max(0, r);
20
+ }
11
21
  //#endregion
12
- export { e as withTourProgressStatus };
22
+ export { t as tourResumeStepIndex, e as withTourProgressStatus };