impact-nova 2.2.7 → 2.2.9

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 (121) hide show
  1. package/dist/components/data/ag-grid-react/ag-grid-header-dom.js +6 -8
  2. package/dist/components/data/ag-grid-react/ag-grid-tooltip-overflow.d.ts +1 -1
  3. package/dist/components/data/ag-grid-react/ag-grid-tooltip-overflow.js +25 -13
  4. package/dist/components/data/ag-grid-react/headers/components/section-renderers.js +19 -18
  5. package/dist/components/data/ag-grid-react/headers/custom-header.js +1 -1
  6. package/dist/components/data/ag-grid-react/headers/custom-inner-header-group.js +7 -7
  7. package/dist/components/data/ag-grid-react/info-system-story-columns.d.ts +38 -1
  8. package/dist/components/data/ag-grid-react/strip-column-min-width-constraints.d.ts +3 -0
  9. package/dist/components/data/data-table/data-table.d.ts +1 -1
  10. package/dist/components/data/data-table/data-table.js +41 -39
  11. package/dist/components/data/data-table/data-table.types.d.ts +1 -1
  12. package/dist/components/flows/filter-panel/filter-panel.js +101 -94
  13. package/dist/components/flows/filter-strip/filter-tag-list.js +96 -88
  14. package/dist/components/flows/guidance/adapters/ag-grid-adapter.d.ts +13 -0
  15. package/dist/components/flows/guidance/adapters/ag-grid-adapter.js +30 -0
  16. package/dist/components/flows/guidance/adapters/ag-grid.d.ts +2 -0
  17. package/dist/components/flows/guidance/adapters/ag-grid.js +6 -0
  18. package/dist/components/flows/guidance/adapters/dialog.d.ts +1 -0
  19. package/dist/components/flows/guidance/adapters/dialog.js +5 -0
  20. package/dist/components/flows/guidance/adapters/overlay-adapter.d.ts +5 -0
  21. package/dist/components/flows/guidance/adapters/overlay-adapter.js +21 -0
  22. package/dist/components/flows/guidance/engine.d.ts +1 -0
  23. package/dist/components/flows/guidance/engine.js +36 -0
  24. package/dist/components/flows/guidance/guidance-context.d.ts +29 -0
  25. package/dist/components/flows/guidance/guidance-context.js +35 -0
  26. package/dist/components/flows/guidance/guidance-error-boundary.d.ts +16 -0
  27. package/dist/components/flows/guidance/guidance-error-boundary.js +49 -0
  28. package/dist/components/flows/guidance/guidance-layer.d.ts +2 -0
  29. package/dist/components/flows/guidance/guidance-layer.js +71 -0
  30. package/dist/components/flows/guidance/guidance-provider.d.ts +3 -0
  31. package/dist/components/flows/guidance/guidance-provider.js +58 -0
  32. package/dist/components/flows/guidance/guidance-target.d.ts +7 -0
  33. package/dist/components/flows/guidance/guidance-target.js +27 -0
  34. package/dist/components/flows/guidance/guidance.types.d.ts +1 -0
  35. package/dist/components/flows/guidance/help-center/filter-help-center-guides.d.ts +7 -0
  36. package/dist/components/flows/guidance/help-center/filter-help-center-guides.js +11 -0
  37. package/dist/components/flows/guidance/help-center/guide-catalog.d.ts +3 -0
  38. package/dist/components/flows/guidance/help-center/guide-catalog.js +118 -0
  39. package/dist/components/flows/guidance/help-center/help-center-header.d.ts +3 -0
  40. package/dist/components/flows/guidance/help-center/help-center-header.js +43 -0
  41. package/dist/components/flows/guidance/help-center/help-center.constants.d.ts +5 -0
  42. package/dist/components/flows/guidance/help-center/help-center.constants.js +7 -0
  43. package/dist/components/flows/guidance/help-center/help-center.d.ts +10 -0
  44. package/dist/components/flows/guidance/help-center/help-center.js +95 -0
  45. package/dist/components/flows/guidance/help-center/help-center.story-helpers.d.ts +10 -0
  46. package/dist/components/flows/guidance/help-center/help-center.types.d.ts +39 -0
  47. package/dist/components/flows/guidance/help-center.d.ts +6 -0
  48. package/dist/components/flows/guidance/help-center.js +19 -0
  49. package/dist/components/flows/guidance/hooks/use-guidance.d.ts +19 -0
  50. package/dist/components/flows/guidance/hooks/use-guidance.js +50 -0
  51. package/dist/components/flows/guidance/hooks/use-help-center.d.ts +24 -0
  52. package/dist/components/flows/guidance/hooks/use-help-center.js +67 -0
  53. package/dist/components/flows/guidance/hooks/useGuidanceOverlayGeometry.d.ts +2 -0
  54. package/dist/components/flows/guidance/hooks/useGuidanceOverlayGeometry.js +30 -0
  55. package/dist/components/flows/guidance/index.d.ts +18 -0
  56. package/dist/components/flows/guidance/index.js +48 -0
  57. package/dist/components/flows/guidance/renderers/announcement-renderer.d.ts +3 -0
  58. package/dist/components/flows/guidance/renderers/announcement-renderer.js +40 -0
  59. package/dist/components/flows/guidance/renderers/coach-mark-renderer.d.ts +2 -0
  60. package/dist/components/flows/guidance/renderers/coach-mark-renderer.js +14 -0
  61. package/dist/components/flows/guidance/renderers/guidance-card-shared.d.ts +42 -0
  62. package/dist/components/flows/guidance/renderers/guidance-card-shared.js +213 -0
  63. package/dist/components/flows/guidance/renderers/guidance-renderer-shared.d.ts +48 -0
  64. package/dist/components/flows/guidance/renderers/guidance-renderer-shared.js +254 -0
  65. package/dist/components/flows/guidance/renderers/guidance-tour-overlay.d.ts +11 -0
  66. package/dist/components/flows/guidance/renderers/guidance-tour-overlay.js +217 -0
  67. package/dist/components/flows/guidance/renderers/renderer-registry.d.ts +6 -0
  68. package/dist/components/flows/guidance/renderers/renderer-registry.js +19 -0
  69. package/dist/components/flows/guidance/renderers/spotlight-renderer.d.ts +2 -0
  70. package/dist/components/flows/guidance/renderers/spotlight-renderer.js +14 -0
  71. package/dist/components/flows/guidance/renderers.d.ts +4 -0
  72. package/dist/components/flows/guidance/renderers.js +11 -0
  73. package/dist/components/flows/guidance/target.d.ts +3 -0
  74. package/dist/components/flows/guidance/target.js +6 -0
  75. package/dist/components/flows/guidance/triggers.d.ts +2 -0
  76. package/dist/components/flows/guidance/triggers.js +16 -0
  77. package/dist/components/flows/guidance/use-guidance-target.d.ts +5 -0
  78. package/dist/components/flows/guidance/use-guidance-target.js +16 -0
  79. package/dist/components/flows/guidance/utils/motion-settle.d.ts +2 -0
  80. package/dist/components/flows/guidance/utils/motion-settle.js +17 -0
  81. package/dist/components/forms/prompt/prompt.js +13 -13
  82. package/dist/i18n/defaultMessages.d.ts +13 -0
  83. package/dist/i18n/defaultMessages.js +23 -11
  84. package/dist/i18n/index.d.ts +1 -1
  85. package/dist/i18n/locales/de.js +12 -0
  86. package/dist/i18n/locales/es.js +12 -0
  87. package/dist/i18n/locales/hi.js +12 -0
  88. package/dist/i18n/locales/kn.js +12 -0
  89. package/dist/impact-nova-components.css +52 -10
  90. package/dist/impact-nova.css +1 -1
  91. package/dist/lib/guidance/analytics/analytics-adapter.d.ts +16 -0
  92. package/dist/lib/guidance/analytics/analytics-adapter.js +50 -0
  93. package/dist/lib/guidance/engine/guidance-engine.d.ts +74 -0
  94. package/dist/lib/guidance/engine/guidance-engine.js +384 -0
  95. package/dist/lib/guidance/engine/guide-registry.d.ts +21 -0
  96. package/dist/lib/guidance/engine/guide-registry.js +71 -0
  97. package/dist/lib/guidance/engine/manifest-validator.d.ts +4 -0
  98. package/dist/lib/guidance/engine/manifest-validator.js +102 -0
  99. package/dist/lib/guidance/engine/step-navigation.d.ts +5 -0
  100. package/dist/lib/guidance/engine/step-navigation.js +35 -0
  101. package/dist/lib/guidance/index.d.ts +12 -0
  102. package/dist/lib/guidance/storage/storage-adapter.d.ts +10 -0
  103. package/dist/lib/guidance/storage/storage-adapter.js +51 -0
  104. package/dist/lib/guidance/storage/storage-keys.d.ts +10 -0
  105. package/dist/lib/guidance/storage/storage-keys.js +23 -0
  106. package/dist/lib/guidance/targets/ref-registry.d.ts +12 -0
  107. package/dist/lib/guidance/targets/ref-registry.js +65 -0
  108. package/dist/lib/guidance/targets/target-resolver.d.ts +13 -0
  109. package/dist/lib/guidance/targets/target-resolver.js +85 -0
  110. package/dist/lib/guidance/triggers/built-in-triggers.d.ts +14 -0
  111. package/dist/lib/guidance/triggers/built-in-triggers.js +88 -0
  112. package/dist/lib/guidance/triggers/trigger-registry.d.ts +9 -0
  113. package/dist/lib/guidance/triggers/trigger-registry.js +44 -0
  114. package/dist/lib/guidance/types/guidance.types.d.ts +181 -0
  115. package/dist/lib/overflow/is-line-clamp-text-clipped.d.ts +2 -0
  116. package/dist/lib/overflow/is-line-clamp-text-clipped.js +33 -0
  117. package/dist/lib/overflow/is-text-overflowing.d.ts +1 -0
  118. package/dist/lib/overflow/is-text-overflowing.js +8 -3
  119. package/dist/llms/rules/installation.js +1 -1
  120. package/dist/llms/rules/requirements.js +1 -1
  121. package/package.json +51 -22
@@ -0,0 +1,16 @@
1
+ import { GuidanceAnalyticsAdapter, GuidanceAnalyticsEvent } from '../types/guidance.types';
2
+ export declare class NoopGuidanceAnalyticsAdapter implements GuidanceAnalyticsAdapter {
3
+ track(): void;
4
+ }
5
+ export declare class SamplingGuidanceAnalyticsAdapter implements GuidanceAnalyticsAdapter {
6
+ private readonly delegate;
7
+ private readonly stepSampleRate;
8
+ private readonly batchSize;
9
+ private readonly flushIntervalMs;
10
+ private readonly eventQueue;
11
+ private flushTimer;
12
+ constructor(delegate: GuidanceAnalyticsAdapter, stepSampleRate?: number, batchSize?: number, flushIntervalMs?: number);
13
+ track(event: GuidanceAnalyticsEvent): void;
14
+ flush(): Promise<void>;
15
+ }
16
+ export declare const defaultGuidanceAnalyticsAdapter: NoopGuidanceAnalyticsAdapter;
@@ -0,0 +1,50 @@
1
+ const h = /* @__PURE__ */ new Set([
2
+ "guide.started",
3
+ "guide.completed",
4
+ "guide.dismissed",
5
+ "guide.error",
6
+ "help_center.opened"
7
+ ]), l = /* @__PURE__ */ new Set(["step.viewed", "step.interacted"]);
8
+ class u {
9
+ track() {
10
+ }
11
+ }
12
+ class n {
13
+ delegate;
14
+ stepSampleRate;
15
+ batchSize;
16
+ flushIntervalMs;
17
+ eventQueue = [];
18
+ flushTimer = null;
19
+ constructor(e, t = 0.25, i = 10, a = 5e3) {
20
+ this.delegate = e, this.stepSampleRate = t, this.batchSize = i, this.flushIntervalMs = a;
21
+ }
22
+ track(e) {
23
+ if (!(l.has(e.name) && Math.random() > this.stepSampleRate)) {
24
+ if (h.has(e.name)) {
25
+ this.delegate.track(e);
26
+ return;
27
+ }
28
+ if (this.eventQueue.push(e), this.eventQueue.length >= this.batchSize) {
29
+ this.flush();
30
+ return;
31
+ }
32
+ this.flushTimer || (this.flushTimer = setTimeout(() => {
33
+ this.flush();
34
+ }, this.flushIntervalMs));
35
+ }
36
+ }
37
+ async flush() {
38
+ this.flushTimer && (clearTimeout(this.flushTimer), this.flushTimer = null);
39
+ const e = this.eventQueue.splice(0);
40
+ for (const t of e)
41
+ this.delegate.track(t);
42
+ await this.delegate.flush?.();
43
+ }
44
+ }
45
+ const r = new u();
46
+ export {
47
+ u as NoopGuidanceAnalyticsAdapter,
48
+ n as SamplingGuidanceAnalyticsAdapter,
49
+ r as defaultGuidanceAnalyticsAdapter
50
+ };
@@ -0,0 +1,74 @@
1
+ import { GuidanceEngineConfig, GuidanceError, GuidanceEventHandler, GuidanceEventName, GuidanceSessionState, GuideManifest, RenderInstruction, Unsubscribe } from '../types/guidance.types';
2
+ import { GuideRegistry } from './guide-registry';
3
+ import { TriggerPluginRegistry } from '../triggers/trigger-registry';
4
+ import { TargetResolver } from '../targets/target-resolver';
5
+ import { GuidanceTargetRefRegistry } from '../targets/ref-registry';
6
+ type Listener = () => void;
7
+ export declare class GuidanceEngine {
8
+ private sessionState;
9
+ private readonly listeners;
10
+ private readonly eventHandlers;
11
+ private readonly guideRegistry;
12
+ private readonly triggerRegistry;
13
+ private readonly targetRefRegistry;
14
+ private readonly targetResolver;
15
+ private readonly guideQueue;
16
+ private previewMode;
17
+ private consentGranted;
18
+ private routePath;
19
+ private featureFlags;
20
+ private permissions;
21
+ private userSegments;
22
+ private customEvents;
23
+ private visitCounts;
24
+ private evaluationFrame;
25
+ private cachedRenderInstruction;
26
+ private readonly config;
27
+ constructor(config: GuidanceEngineConfig);
28
+ get state(): GuidanceSessionState;
29
+ get registry(): GuideRegistry;
30
+ get triggers(): TriggerPluginRegistry;
31
+ get targets(): GuidanceTargetRefRegistry;
32
+ get resolver(): TargetResolver;
33
+ subscribe(listener: Listener): Unsubscribe;
34
+ on(eventName: GuidanceEventName, handler: GuidanceEventHandler): Unsubscribe;
35
+ registerGuide(manifest: GuideManifest, routeScope?: string): void;
36
+ unregisterGuide(guideId: string): void;
37
+ unregisterRouteScope(routeScope: string): void;
38
+ setRoutePath(routePath: string): void;
39
+ setFeatureFlags(featureFlags: Record<string, boolean>): void;
40
+ setPermissions(permissions: string[]): void;
41
+ setUserSegments(userSegments: string[]): void;
42
+ emitCustomEvent(eventName: string): void;
43
+ grantConsent(): void;
44
+ setPreviewMode(enabled: boolean): void;
45
+ start(guideId: string, options?: {
46
+ manual?: boolean;
47
+ }): Promise<void>;
48
+ replay(guideId: string): Promise<void>;
49
+ dismiss(dismissMode?: 'session' | 'forever' | 'snoozed'): Promise<void>;
50
+ snooze(guideId?: string): Promise<void>;
51
+ advanceStep(): Promise<void>;
52
+ skipStep(): Promise<void>;
53
+ getRenderInstruction(): RenderInstruction | null;
54
+ private syncRenderInstructionCache;
55
+ evaluateTriggers(routeScope?: string): Promise<void>;
56
+ private activateGuide;
57
+ private completeGuide;
58
+ private canStartGuide;
59
+ private isGuideEligible;
60
+ private buildTriggerContext;
61
+ private enqueueGuide;
62
+ private dequeueNextGuide;
63
+ private loadSessionStats;
64
+ private saveSessionStats;
65
+ private hydrateVisitCounts;
66
+ private incrementVisitCount;
67
+ private scheduleEvaluation;
68
+ private setSession;
69
+ private notify;
70
+ private emitEvent;
71
+ private track;
72
+ reportError(error: GuidanceError): void;
73
+ }
74
+ export {};
@@ -0,0 +1,384 @@
1
+ import { GuideRegistry as h } from "./guide-registry.js";
2
+ import { getNextStepId as l, getStepIndex as p, getStepById as f, resolveLocalizedStepContent as S } from "./step-navigation.js";
3
+ import { TriggerPluginRegistry as v } from "../triggers/trigger-registry.js";
4
+ import { registerBuiltInTriggerPlugins as m } from "../triggers/built-in-triggers.js";
5
+ import { TargetResolver as w, resolveTargetSynchronously as y, waitForTargetResolved as R } from "../targets/target-resolver.js";
6
+ import { GuidanceTargetRefRegistry as I } from "../targets/ref-registry.js";
7
+ import { buildGuidanceStorageKey as a, buildSessionStatsKey as u, createDefaultSessionStats as G } from "../storage/storage-keys.js";
8
+ class P {
9
+ sessionState = { status: "idle" };
10
+ listeners = /* @__PURE__ */ new Set();
11
+ eventHandlers = /* @__PURE__ */ new Map();
12
+ guideRegistry = new h();
13
+ triggerRegistry = new v();
14
+ targetRefRegistry = new I();
15
+ targetResolver;
16
+ guideQueue = [];
17
+ previewMode = !1;
18
+ consentGranted = !0;
19
+ routePath = "/";
20
+ featureFlags = {};
21
+ permissions = [];
22
+ userSegments = [];
23
+ customEvents = /* @__PURE__ */ new Set();
24
+ visitCounts = {};
25
+ evaluationFrame = null;
26
+ cachedRenderInstruction = null;
27
+ config;
28
+ constructor(t) {
29
+ this.config = t, this.targetResolver = new w(this.targetRefRegistry), m(this.triggerRegistry), this.consentGranted = !t.consentRequired;
30
+ }
31
+ get state() {
32
+ return this.sessionState;
33
+ }
34
+ get registry() {
35
+ return this.guideRegistry;
36
+ }
37
+ get triggers() {
38
+ return this.triggerRegistry;
39
+ }
40
+ get targets() {
41
+ return this.targetRefRegistry;
42
+ }
43
+ get resolver() {
44
+ return this.targetResolver;
45
+ }
46
+ subscribe(t) {
47
+ return this.listeners.add(t), () => {
48
+ this.listeners.delete(t);
49
+ };
50
+ }
51
+ on(t, e) {
52
+ const s = this.eventHandlers.get(t) ?? /* @__PURE__ */ new Set();
53
+ return s.add(e), this.eventHandlers.set(t, s), () => {
54
+ s.delete(e);
55
+ };
56
+ }
57
+ registerGuide(t, e) {
58
+ this.guideRegistry.register(t, e), this.scheduleEvaluation();
59
+ }
60
+ unregisterGuide(t) {
61
+ this.guideRegistry.unregister(t);
62
+ }
63
+ unregisterRouteScope(t) {
64
+ this.guideRegistry.unregisterRouteScope(t), this.targetRefRegistry.clearScope(t);
65
+ }
66
+ setRoutePath(t) {
67
+ this.routePath = t, this.scheduleEvaluation();
68
+ }
69
+ setFeatureFlags(t) {
70
+ this.featureFlags = t;
71
+ }
72
+ setPermissions(t) {
73
+ this.permissions = t;
74
+ }
75
+ setUserSegments(t) {
76
+ this.userSegments = t;
77
+ }
78
+ emitCustomEvent(t) {
79
+ this.customEvents.add(t), this.scheduleEvaluation(), queueMicrotask(() => {
80
+ this.customEvents.delete(t);
81
+ });
82
+ }
83
+ grantConsent() {
84
+ this.consentGranted = !0;
85
+ }
86
+ setPreviewMode(t) {
87
+ this.previewMode = t;
88
+ }
89
+ async start(t, e) {
90
+ const s = this.guideRegistry.get(t);
91
+ if (!s) {
92
+ this.setSession({
93
+ status: "error",
94
+ guideId: t,
95
+ error: { code: "guide_not_found", message: `Guide not found: ${t}`, guideId: t }
96
+ });
97
+ return;
98
+ }
99
+ if (!this.consentGranted && !this.previewMode)
100
+ return;
101
+ if (this.sessionState.status === "active" && this.sessionState.guideId !== t) {
102
+ if (s.queueOnConflict) {
103
+ this.enqueueGuide(t);
104
+ return;
105
+ }
106
+ return;
107
+ }
108
+ await this.canStartGuide(t, e?.manual ?? !1) && await this.activateGuide(s, 0);
109
+ }
110
+ async replay(t) {
111
+ this.previewMode = !0, await this.start(t, { manual: !0 });
112
+ }
113
+ async dismiss(t = "session") {
114
+ const e = this.sessionState.guideId;
115
+ if (e) {
116
+ if (t === "forever" && await this.config.storage.set({
117
+ [a(this.config.tenantId, e, "dismissed")]: {
118
+ dismissed: !0,
119
+ timestamp: Date.now()
120
+ }
121
+ }), t === "snoozed") {
122
+ const s = await this.loadSessionStats();
123
+ s.snoozedUntil[e] = Date.now() + 1440 * 60 * 1e3, await this.saveSessionStats(s);
124
+ }
125
+ this.emitEvent("guideEnd", { guideId: e, reason: "dismissed" }), this.track("guide.dismissed", { guideId: e, dismissMode: t }), this.setSession({ status: "dismissed", guideId: e, dismissMode: t }), await this.dequeueNextGuide();
126
+ }
127
+ }
128
+ async snooze(t) {
129
+ (t ?? this.sessionState.guideId) && await this.dismiss("snoozed");
130
+ }
131
+ async advanceStep() {
132
+ const t = this.sessionState.guideId, e = this.sessionState.stepId;
133
+ if (!t || !e || this.sessionState.status !== "active")
134
+ return;
135
+ const s = this.guideRegistry.get(t);
136
+ if (!s)
137
+ return;
138
+ this.track("step.completed", { guideId: t, stepId: e });
139
+ const i = await l(
140
+ s,
141
+ e,
142
+ (r) => this.triggerRegistry.evaluateExpression(r, this.buildTriggerContext())
143
+ );
144
+ if (!i) {
145
+ await this.completeGuide(t);
146
+ return;
147
+ }
148
+ const n = p(s, i);
149
+ await this.activateGuide(s, n);
150
+ }
151
+ async skipStep() {
152
+ const t = this.sessionState.guideId, e = this.sessionState.stepId;
153
+ !t || !e || (this.track("step.skipped", { guideId: t, stepId: e }), await this.advanceStep());
154
+ }
155
+ getRenderInstruction() {
156
+ return this.cachedRenderInstruction;
157
+ }
158
+ syncRenderInstructionCache() {
159
+ if (this.sessionState.status !== "active" || !this.sessionState.guideId || this.sessionState.stepId === void 0 || this.sessionState.stepIndex === void 0) {
160
+ this.cachedRenderInstruction = null;
161
+ return;
162
+ }
163
+ const t = this.guideRegistry.get(this.sessionState.guideId), e = t ? f(t, this.sessionState.stepId) : void 0;
164
+ if (!t || !e) {
165
+ this.cachedRenderInstruction = null;
166
+ return;
167
+ }
168
+ this.cachedRenderInstruction = {
169
+ guideId: t.id,
170
+ stepId: e.id,
171
+ stepIndex: this.sessionState.stepIndex,
172
+ totalSteps: t.steps.length,
173
+ renderer: e.renderer,
174
+ content: S(t, e, this.config.locale),
175
+ target: this.sessionState.resolvedTarget ?? null,
176
+ skippable: e.skippable,
177
+ advanceOn: e.advanceOn
178
+ };
179
+ }
180
+ async evaluateTriggers(t) {
181
+ if (this.previewMode || this.sessionState.status === "active")
182
+ return;
183
+ const e = await this.loadSessionStats();
184
+ if (e.guidesShownThisSession >= this.config.maxGuidesPerSession || e.lastGuideEndedAt && Date.now() - e.lastGuideEndedAt < this.config.cooldownBetweenGuides)
185
+ return;
186
+ const s = t ? this.guideRegistry.getForRoute(t) : [], i = s.length > 0 ? s : this.guideRegistry.getAll();
187
+ await this.hydrateVisitCounts(i.map((o) => o.id));
188
+ const n = [];
189
+ for (const o of this.guideRegistry.getSortedByPriority(
190
+ i.map((d) => d.id)
191
+ ))
192
+ await this.isGuideEligible(o, e) && n.push(o);
193
+ if (!n.length)
194
+ return;
195
+ const r = n[0];
196
+ this.track("guide.triggered", { guideId: r.id }), await this.start(r.id);
197
+ }
198
+ async activateGuide(t, e) {
199
+ const s = t.steps[e];
200
+ if (!s) {
201
+ await this.completeGuide(t.id);
202
+ return;
203
+ }
204
+ let i = y(
205
+ this.targetResolver,
206
+ s.target
207
+ );
208
+ if (i?.element || (this.setSession({
209
+ status: "evaluating",
210
+ guideId: t.id,
211
+ stepIndex: e,
212
+ stepId: s.id
213
+ }), i = await R(
214
+ this.targetResolver,
215
+ s.target,
216
+ s.timeout ?? 5e3
217
+ )), !i?.element) {
218
+ this.setSession({
219
+ status: "blocked",
220
+ guideId: t.id,
221
+ stepIndex: e,
222
+ stepId: s.id,
223
+ reason: i ? "target_not_visible" : "target_not_found"
224
+ });
225
+ return;
226
+ }
227
+ if (e === 0) {
228
+ this.emitEvent("guideStart", { guideId: t.id, stepId: s.id }), this.track("guide.started", { guideId: t.id });
229
+ const n = await this.loadSessionStats();
230
+ n.guidesShownThisSession += 1, await this.saveSessionStats(n), await this.incrementVisitCount(t.id);
231
+ }
232
+ this.emitEvent("stepChange", { guideId: t.id, stepId: s.id }), this.track("step.viewed", { guideId: t.id, stepId: s.id }), this.setSession({
233
+ status: "active",
234
+ guideId: t.id,
235
+ stepIndex: e,
236
+ stepId: s.id,
237
+ resolvedTarget: {
238
+ ...i,
239
+ rect: i.element.getBoundingClientRect()
240
+ }
241
+ }), t.persistence.resumeOnRefresh && await this.config.storage.set({
242
+ [a(this.config.tenantId, t.id, "lastStep")]: {
243
+ stepId: s.id,
244
+ timestamp: Date.now()
245
+ }
246
+ });
247
+ }
248
+ async completeGuide(t) {
249
+ this.guideRegistry.get(t)?.persistence.mode === "showOnce" && await this.config.storage.set({
250
+ [a(this.config.tenantId, t, "dismissed")]: {
251
+ dismissed: !0,
252
+ timestamp: Date.now()
253
+ }
254
+ }), await this.config.storage.delete([
255
+ a(this.config.tenantId, t, "lastStep")
256
+ ]);
257
+ const s = await this.loadSessionStats();
258
+ s.lastGuideEndedAt = Date.now(), await this.saveSessionStats(s), this.emitEvent("guideEnd", { guideId: t, reason: "completed" }), this.track("guide.completed", { guideId: t }), this.setSession({ status: "completed", guideId: t }), await this.dequeueNextGuide();
259
+ }
260
+ async canStartGuide(t, e) {
261
+ if (e || this.previewMode)
262
+ return !0;
263
+ const s = this.guideRegistry.get(t);
264
+ if (!s)
265
+ return !1;
266
+ const i = await this.loadSessionStats();
267
+ return this.isGuideEligible(s, i);
268
+ }
269
+ async isGuideEligible(t, e) {
270
+ const s = a(
271
+ this.config.tenantId,
272
+ t.id,
273
+ "dismissed"
274
+ );
275
+ if ((await this.config.storage.get([s]))[s]?.dismissed && t.persistence.mode !== "replayable")
276
+ return !1;
277
+ const r = e.snoozedUntil[t.id];
278
+ if (r && Date.now() < r || (e.dismissedCounts[t.id] ?? 0) >= 3 && t.persistence.mode === "showOnce")
279
+ return !1;
280
+ if (t.persistence.schedule) {
281
+ const d = Date.now(), c = Date.parse(t.persistence.schedule.start), g = Date.parse(t.persistence.schedule.end);
282
+ if (d < c || d > g)
283
+ return !1;
284
+ }
285
+ return this.triggerRegistry.evaluateAll(
286
+ t.triggers,
287
+ this.buildTriggerContext()
288
+ );
289
+ }
290
+ buildTriggerContext() {
291
+ return {
292
+ routePath: this.routePath,
293
+ appVersion: this.config.appVersion,
294
+ featureFlags: this.featureFlags,
295
+ permissions: this.permissions,
296
+ userSegments: this.userSegments,
297
+ customEvents: this.customEvents,
298
+ visitCounts: this.visitCounts,
299
+ now: Date.now(),
300
+ previewMode: this.previewMode
301
+ };
302
+ }
303
+ enqueueGuide(t) {
304
+ this.guideQueue.includes(t) || (this.guideQueue.push(t), this.setSession({
305
+ status: "queued",
306
+ guideId: t,
307
+ position: this.guideQueue.indexOf(t) + 1
308
+ }), this.track("guide.queued", { guideId: t }));
309
+ }
310
+ async dequeueNextGuide() {
311
+ this.previewMode = !1;
312
+ const t = this.guideQueue.shift();
313
+ if (!t) {
314
+ this.setSession({ status: "idle" });
315
+ return;
316
+ }
317
+ await this.start(t);
318
+ }
319
+ async loadSessionStats() {
320
+ const t = u(this.config.tenantId);
321
+ return (await this.config.storage.get([t]))[t] ?? G();
322
+ }
323
+ async saveSessionStats(t) {
324
+ await this.config.storage.set({
325
+ [u(this.config.tenantId)]: t
326
+ });
327
+ }
328
+ async hydrateVisitCounts(t) {
329
+ if (!t.length)
330
+ return;
331
+ const e = t.map(
332
+ (i) => a(this.config.tenantId, i, "visitCount")
333
+ ), s = await this.config.storage.get(e);
334
+ for (const i of t) {
335
+ const n = a(
336
+ this.config.tenantId,
337
+ i,
338
+ "visitCount"
339
+ ), r = s[n];
340
+ typeof r == "number" && (this.visitCounts[i] = r);
341
+ }
342
+ }
343
+ async incrementVisitCount(t) {
344
+ const e = a(
345
+ this.config.tenantId,
346
+ t,
347
+ "visitCount"
348
+ ), n = ((await this.config.storage.get([e]))[e] ?? 0) + 1;
349
+ this.visitCounts[t] = n, await this.config.storage.set({ [e]: n });
350
+ }
351
+ scheduleEvaluation() {
352
+ typeof window > "u" || (this.evaluationFrame !== null && cancelAnimationFrame(this.evaluationFrame), this.evaluationFrame = requestAnimationFrame(() => {
353
+ this.evaluationFrame = null, this.evaluateTriggers(this.routePath);
354
+ }));
355
+ }
356
+ setSession(t) {
357
+ this.sessionState = t, this.syncRenderInstructionCache(), this.notify();
358
+ }
359
+ notify() {
360
+ for (const t of this.listeners)
361
+ t();
362
+ }
363
+ emitEvent(t, e) {
364
+ for (const s of this.eventHandlers.get(t) ?? [])
365
+ s(e);
366
+ }
367
+ track(t, e) {
368
+ this.config.analytics.track({
369
+ name: t,
370
+ properties: e,
371
+ timestamp: Date.now()
372
+ });
373
+ }
374
+ reportError(t) {
375
+ this.config.errorReporter?.report(t), this.track("guide.error", { ...t }), this.setSession({
376
+ status: "error",
377
+ guideId: t.guideId,
378
+ error: t
379
+ });
380
+ }
381
+ }
382
+ export {
383
+ P as GuidanceEngine
384
+ };
@@ -0,0 +1,21 @@
1
+ import { GuideManifest } from '../types/guidance.types';
2
+ type GuideRegistryListener = () => void;
3
+ export declare class GuideRegistry {
4
+ private readonly guides;
5
+ private readonly routeScopes;
6
+ private readonly registrationOrder;
7
+ private readonly listeners;
8
+ private registryVersion;
9
+ subscribe(listener: GuideRegistryListener): () => void;
10
+ getVersion(): number;
11
+ private notifyListeners;
12
+ register(manifest: GuideManifest, routeScope?: string): void;
13
+ unregister(guideId: string): void;
14
+ unregisterRouteScope(routeScope: string): void;
15
+ get(guideId: string): GuideManifest | undefined;
16
+ getAll(): GuideManifest[];
17
+ getForRoute(routeScope: string): GuideManifest[];
18
+ getSortedByPriority(guideIds?: string[]): GuideManifest[];
19
+ private enforceCapacity;
20
+ }
21
+ export {};
@@ -0,0 +1,71 @@
1
+ import { validateGuideManifest as o, sanitizeGuideManifest as n } from "./manifest-validator.js";
2
+ const d = 50;
3
+ class a {
4
+ guides = /* @__PURE__ */ new Map();
5
+ routeScopes = /* @__PURE__ */ new Map();
6
+ registrationOrder = [];
7
+ listeners = /* @__PURE__ */ new Set();
8
+ registryVersion = 0;
9
+ subscribe(e) {
10
+ return this.listeners.add(e), () => {
11
+ this.listeners.delete(e);
12
+ };
13
+ }
14
+ getVersion() {
15
+ return this.registryVersion;
16
+ }
17
+ notifyListeners() {
18
+ this.registryVersion += 1;
19
+ for (const e of this.listeners)
20
+ e();
21
+ }
22
+ register(e, t) {
23
+ const i = o(e);
24
+ if (i.length > 0)
25
+ throw new Error(
26
+ `Invalid guide manifest "${e.id}": ${i.join("; ")}`
27
+ );
28
+ const r = n(e);
29
+ if (this.guides.has(r.id) || this.registrationOrder.push(r.id), this.guides.set(r.id, r), t) {
30
+ const s = this.routeScopes.get(t) ?? /* @__PURE__ */ new Set();
31
+ s.add(r.id), this.routeScopes.set(t, s);
32
+ }
33
+ this.enforceCapacity(), this.notifyListeners();
34
+ }
35
+ unregister(e) {
36
+ this.guides.delete(e), this.registrationOrder.splice(this.registrationOrder.indexOf(e), 1);
37
+ for (const [t, i] of this.routeScopes.entries())
38
+ i.delete(e), i.size || this.routeScopes.delete(t);
39
+ this.notifyListeners();
40
+ }
41
+ unregisterRouteScope(e) {
42
+ const t = this.routeScopes.get(e);
43
+ if (t)
44
+ for (const i of Array.from(t))
45
+ this.unregister(i);
46
+ }
47
+ get(e) {
48
+ return this.guides.get(e);
49
+ }
50
+ getAll() {
51
+ return Array.from(this.guides.values());
52
+ }
53
+ getForRoute(e) {
54
+ const t = this.routeScopes.get(e);
55
+ return t ? Array.from(t).map((i) => this.guides.get(i)).filter((i) => !!i) : [];
56
+ }
57
+ getSortedByPriority(e) {
58
+ return (e ? e.map((i) => this.guides.get(i)).filter((i) => !!i) : this.getAll()).sort((i, r) => i.priority !== r.priority ? i.priority - r.priority : this.registrationOrder.indexOf(i.id) - this.registrationOrder.indexOf(r.id));
59
+ }
60
+ enforceCapacity() {
61
+ for (; this.guides.size > d; ) {
62
+ const e = this.registrationOrder.shift();
63
+ if (!e)
64
+ break;
65
+ this.unregister(e);
66
+ }
67
+ }
68
+ }
69
+ export {
70
+ a as GuideRegistry
71
+ };
@@ -0,0 +1,4 @@
1
+ import { GuideManifest, StepContent } from '../types/guidance.types';
2
+ export declare function sanitizeStepContent(content: StepContent): StepContent;
3
+ export declare function sanitizeGuideManifest(manifest: GuideManifest): GuideManifest;
4
+ export declare function validateGuideManifest(manifest: GuideManifest): string[];