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.
- package/dist/components/data/ag-grid-react/ag-grid-header-dom.js +6 -8
- package/dist/components/data/ag-grid-react/ag-grid-tooltip-overflow.d.ts +1 -1
- package/dist/components/data/ag-grid-react/ag-grid-tooltip-overflow.js +25 -13
- package/dist/components/data/ag-grid-react/headers/components/section-renderers.js +19 -18
- package/dist/components/data/ag-grid-react/headers/custom-header.js +1 -1
- package/dist/components/data/ag-grid-react/headers/custom-inner-header-group.js +7 -7
- package/dist/components/data/ag-grid-react/info-system-story-columns.d.ts +38 -1
- package/dist/components/data/ag-grid-react/strip-column-min-width-constraints.d.ts +3 -0
- package/dist/components/data/data-table/data-table.d.ts +1 -1
- package/dist/components/data/data-table/data-table.js +41 -39
- package/dist/components/data/data-table/data-table.types.d.ts +1 -1
- package/dist/components/flows/filter-panel/filter-panel.js +101 -94
- package/dist/components/flows/filter-strip/filter-tag-list.js +96 -88
- package/dist/components/flows/guidance/adapters/ag-grid-adapter.d.ts +13 -0
- package/dist/components/flows/guidance/adapters/ag-grid-adapter.js +30 -0
- package/dist/components/flows/guidance/adapters/ag-grid.d.ts +2 -0
- package/dist/components/flows/guidance/adapters/ag-grid.js +6 -0
- package/dist/components/flows/guidance/adapters/dialog.d.ts +1 -0
- package/dist/components/flows/guidance/adapters/dialog.js +5 -0
- package/dist/components/flows/guidance/adapters/overlay-adapter.d.ts +5 -0
- package/dist/components/flows/guidance/adapters/overlay-adapter.js +21 -0
- package/dist/components/flows/guidance/engine.d.ts +1 -0
- package/dist/components/flows/guidance/engine.js +36 -0
- package/dist/components/flows/guidance/guidance-context.d.ts +29 -0
- package/dist/components/flows/guidance/guidance-context.js +35 -0
- package/dist/components/flows/guidance/guidance-error-boundary.d.ts +16 -0
- package/dist/components/flows/guidance/guidance-error-boundary.js +49 -0
- package/dist/components/flows/guidance/guidance-layer.d.ts +2 -0
- package/dist/components/flows/guidance/guidance-layer.js +71 -0
- package/dist/components/flows/guidance/guidance-provider.d.ts +3 -0
- package/dist/components/flows/guidance/guidance-provider.js +58 -0
- package/dist/components/flows/guidance/guidance-target.d.ts +7 -0
- package/dist/components/flows/guidance/guidance-target.js +27 -0
- package/dist/components/flows/guidance/guidance.types.d.ts +1 -0
- package/dist/components/flows/guidance/help-center/filter-help-center-guides.d.ts +7 -0
- package/dist/components/flows/guidance/help-center/filter-help-center-guides.js +11 -0
- package/dist/components/flows/guidance/help-center/guide-catalog.d.ts +3 -0
- package/dist/components/flows/guidance/help-center/guide-catalog.js +118 -0
- package/dist/components/flows/guidance/help-center/help-center-header.d.ts +3 -0
- package/dist/components/flows/guidance/help-center/help-center-header.js +43 -0
- package/dist/components/flows/guidance/help-center/help-center.constants.d.ts +5 -0
- package/dist/components/flows/guidance/help-center/help-center.constants.js +7 -0
- package/dist/components/flows/guidance/help-center/help-center.d.ts +10 -0
- package/dist/components/flows/guidance/help-center/help-center.js +95 -0
- package/dist/components/flows/guidance/help-center/help-center.story-helpers.d.ts +10 -0
- package/dist/components/flows/guidance/help-center/help-center.types.d.ts +39 -0
- package/dist/components/flows/guidance/help-center.d.ts +6 -0
- package/dist/components/flows/guidance/help-center.js +19 -0
- package/dist/components/flows/guidance/hooks/use-guidance.d.ts +19 -0
- package/dist/components/flows/guidance/hooks/use-guidance.js +50 -0
- package/dist/components/flows/guidance/hooks/use-help-center.d.ts +24 -0
- package/dist/components/flows/guidance/hooks/use-help-center.js +67 -0
- package/dist/components/flows/guidance/hooks/useGuidanceOverlayGeometry.d.ts +2 -0
- package/dist/components/flows/guidance/hooks/useGuidanceOverlayGeometry.js +30 -0
- package/dist/components/flows/guidance/index.d.ts +18 -0
- package/dist/components/flows/guidance/index.js +48 -0
- package/dist/components/flows/guidance/renderers/announcement-renderer.d.ts +3 -0
- package/dist/components/flows/guidance/renderers/announcement-renderer.js +40 -0
- package/dist/components/flows/guidance/renderers/coach-mark-renderer.d.ts +2 -0
- package/dist/components/flows/guidance/renderers/coach-mark-renderer.js +14 -0
- package/dist/components/flows/guidance/renderers/guidance-card-shared.d.ts +42 -0
- package/dist/components/flows/guidance/renderers/guidance-card-shared.js +213 -0
- package/dist/components/flows/guidance/renderers/guidance-renderer-shared.d.ts +48 -0
- package/dist/components/flows/guidance/renderers/guidance-renderer-shared.js +254 -0
- package/dist/components/flows/guidance/renderers/guidance-tour-overlay.d.ts +11 -0
- package/dist/components/flows/guidance/renderers/guidance-tour-overlay.js +217 -0
- package/dist/components/flows/guidance/renderers/renderer-registry.d.ts +6 -0
- package/dist/components/flows/guidance/renderers/renderer-registry.js +19 -0
- package/dist/components/flows/guidance/renderers/spotlight-renderer.d.ts +2 -0
- package/dist/components/flows/guidance/renderers/spotlight-renderer.js +14 -0
- package/dist/components/flows/guidance/renderers.d.ts +4 -0
- package/dist/components/flows/guidance/renderers.js +11 -0
- package/dist/components/flows/guidance/target.d.ts +3 -0
- package/dist/components/flows/guidance/target.js +6 -0
- package/dist/components/flows/guidance/triggers.d.ts +2 -0
- package/dist/components/flows/guidance/triggers.js +16 -0
- package/dist/components/flows/guidance/use-guidance-target.d.ts +5 -0
- package/dist/components/flows/guidance/use-guidance-target.js +16 -0
- package/dist/components/flows/guidance/utils/motion-settle.d.ts +2 -0
- package/dist/components/flows/guidance/utils/motion-settle.js +17 -0
- package/dist/components/forms/prompt/prompt.js +13 -13
- package/dist/i18n/defaultMessages.d.ts +13 -0
- package/dist/i18n/defaultMessages.js +23 -11
- package/dist/i18n/index.d.ts +1 -1
- package/dist/i18n/locales/de.js +12 -0
- package/dist/i18n/locales/es.js +12 -0
- package/dist/i18n/locales/hi.js +12 -0
- package/dist/i18n/locales/kn.js +12 -0
- package/dist/impact-nova-components.css +52 -10
- package/dist/impact-nova.css +1 -1
- package/dist/lib/guidance/analytics/analytics-adapter.d.ts +16 -0
- package/dist/lib/guidance/analytics/analytics-adapter.js +50 -0
- package/dist/lib/guidance/engine/guidance-engine.d.ts +74 -0
- package/dist/lib/guidance/engine/guidance-engine.js +384 -0
- package/dist/lib/guidance/engine/guide-registry.d.ts +21 -0
- package/dist/lib/guidance/engine/guide-registry.js +71 -0
- package/dist/lib/guidance/engine/manifest-validator.d.ts +4 -0
- package/dist/lib/guidance/engine/manifest-validator.js +102 -0
- package/dist/lib/guidance/engine/step-navigation.d.ts +5 -0
- package/dist/lib/guidance/engine/step-navigation.js +35 -0
- package/dist/lib/guidance/index.d.ts +12 -0
- package/dist/lib/guidance/storage/storage-adapter.d.ts +10 -0
- package/dist/lib/guidance/storage/storage-adapter.js +51 -0
- package/dist/lib/guidance/storage/storage-keys.d.ts +10 -0
- package/dist/lib/guidance/storage/storage-keys.js +23 -0
- package/dist/lib/guidance/targets/ref-registry.d.ts +12 -0
- package/dist/lib/guidance/targets/ref-registry.js +65 -0
- package/dist/lib/guidance/targets/target-resolver.d.ts +13 -0
- package/dist/lib/guidance/targets/target-resolver.js +85 -0
- package/dist/lib/guidance/triggers/built-in-triggers.d.ts +14 -0
- package/dist/lib/guidance/triggers/built-in-triggers.js +88 -0
- package/dist/lib/guidance/triggers/trigger-registry.d.ts +9 -0
- package/dist/lib/guidance/triggers/trigger-registry.js +44 -0
- package/dist/lib/guidance/types/guidance.types.d.ts +181 -0
- package/dist/lib/overflow/is-line-clamp-text-clipped.d.ts +2 -0
- package/dist/lib/overflow/is-line-clamp-text-clipped.js +33 -0
- package/dist/lib/overflow/is-text-overflowing.d.ts +1 -0
- package/dist/lib/overflow/is-text-overflowing.js +8 -3
- package/dist/llms/rules/installation.js +1 -1
- package/dist/llms/rules/requirements.js +1 -1
- package/package.json +51 -22
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
function a(t) {
|
|
2
|
+
return {
|
|
3
|
+
...t,
|
|
4
|
+
title: c(t.title),
|
|
5
|
+
body: c(t.body),
|
|
6
|
+
footer: t.footer ? c(t.footer) : void 0,
|
|
7
|
+
media: t.media ? {
|
|
8
|
+
...t.media,
|
|
9
|
+
src: l(t.media.src)
|
|
10
|
+
} : void 0,
|
|
11
|
+
actions: t.actions?.map((i) => ({
|
|
12
|
+
...i,
|
|
13
|
+
label: c(i.label)
|
|
14
|
+
}))
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
function p(t) {
|
|
18
|
+
return {
|
|
19
|
+
...t,
|
|
20
|
+
steps: t.steps.map((i) => ({
|
|
21
|
+
...i,
|
|
22
|
+
content: a(i.content)
|
|
23
|
+
})),
|
|
24
|
+
locale: Object.fromEntries(
|
|
25
|
+
Object.entries(t.locale).map(([i, n]) => [
|
|
26
|
+
i,
|
|
27
|
+
n.map((r) => a(r))
|
|
28
|
+
])
|
|
29
|
+
)
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
function c(t) {
|
|
33
|
+
return t.replace(/<[^>]*>/g, "").replace(/javascript:/gi, "").trim();
|
|
34
|
+
}
|
|
35
|
+
function l(t) {
|
|
36
|
+
if (t.startsWith("/") || t.startsWith("./"))
|
|
37
|
+
return t;
|
|
38
|
+
try {
|
|
39
|
+
const i = new URL(t);
|
|
40
|
+
if (i.protocol === "https:" || i.protocol === "http:")
|
|
41
|
+
return t;
|
|
42
|
+
} catch {
|
|
43
|
+
return "";
|
|
44
|
+
}
|
|
45
|
+
return "";
|
|
46
|
+
}
|
|
47
|
+
function f(t) {
|
|
48
|
+
const i = [];
|
|
49
|
+
t.schemaVersion !== 1 && i.push(`Unsupported schemaVersion: ${t.schemaVersion}`), t.id || i.push("Guide manifest requires id"), t.steps.length || i.push("Guide manifest requires at least one step");
|
|
50
|
+
const n = /* @__PURE__ */ new Set();
|
|
51
|
+
for (const r of t.steps)
|
|
52
|
+
n.has(r.id) && i.push(`Duplicate step id: ${r.id}`), n.add(r.id), (r.content.body.includes("<script") || r.content.body.includes("javascript:")) && i.push(`Step ${r.id} body contains disallowed content`);
|
|
53
|
+
if (t.transitions?.length) {
|
|
54
|
+
const r = d(t);
|
|
55
|
+
r && i.push(r);
|
|
56
|
+
}
|
|
57
|
+
for (const r of t.triggers) {
|
|
58
|
+
const s = u(r);
|
|
59
|
+
s && i.push(s);
|
|
60
|
+
}
|
|
61
|
+
return i;
|
|
62
|
+
}
|
|
63
|
+
function u(t) {
|
|
64
|
+
if ("op" in t) {
|
|
65
|
+
if (!t.conditions.length)
|
|
66
|
+
return `Trigger ${t.op} requires conditions`;
|
|
67
|
+
for (const i of t.conditions) {
|
|
68
|
+
const n = u(i);
|
|
69
|
+
if (n)
|
|
70
|
+
return n;
|
|
71
|
+
}
|
|
72
|
+
return null;
|
|
73
|
+
}
|
|
74
|
+
return t.plugin ? null : "Trigger plugin key is required";
|
|
75
|
+
}
|
|
76
|
+
function d(t) {
|
|
77
|
+
const i = /* @__PURE__ */ new Map();
|
|
78
|
+
for (const e of t.transitions ?? []) {
|
|
79
|
+
const o = i.get(e.from) ?? [];
|
|
80
|
+
o.push(e.to), i.set(e.from, o);
|
|
81
|
+
}
|
|
82
|
+
const n = /* @__PURE__ */ new Set(), r = /* @__PURE__ */ new Set(), s = (e) => {
|
|
83
|
+
if (n.has(e))
|
|
84
|
+
return !0;
|
|
85
|
+
if (r.has(e))
|
|
86
|
+
return !1;
|
|
87
|
+
n.add(e);
|
|
88
|
+
for (const o of i.get(e) ?? [])
|
|
89
|
+
if (s(o))
|
|
90
|
+
return !0;
|
|
91
|
+
return n.delete(e), r.add(e), !1;
|
|
92
|
+
};
|
|
93
|
+
for (const e of t.steps)
|
|
94
|
+
if (s(e.id))
|
|
95
|
+
return "Guide transitions contain a cycle";
|
|
96
|
+
return null;
|
|
97
|
+
}
|
|
98
|
+
export {
|
|
99
|
+
p as sanitizeGuideManifest,
|
|
100
|
+
a as sanitizeStepContent,
|
|
101
|
+
f as validateGuideManifest
|
|
102
|
+
};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { GuideManifest, Step, TriggerExpression } from '../types/guidance.types';
|
|
2
|
+
export declare function getStepById(manifest: GuideManifest, stepId: string): Step | undefined;
|
|
3
|
+
export declare function getStepIndex(manifest: GuideManifest, stepId: string): number;
|
|
4
|
+
export declare function getNextStepId(manifest: GuideManifest, currentStepId: string, evaluateCondition: (expression: TriggerExpression) => Promise<boolean>): Promise<string | null>;
|
|
5
|
+
export declare function resolveLocalizedStepContent(manifest: GuideManifest, step: Step, locale: string): Step['content'];
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
function a(t, e) {
|
|
2
|
+
return t.steps.find((n) => n.id === e);
|
|
3
|
+
}
|
|
4
|
+
function c(t, e) {
|
|
5
|
+
return t.steps.findIndex((n) => n.id === e);
|
|
6
|
+
}
|
|
7
|
+
function l(t, e, n) {
|
|
8
|
+
const o = (t.transitions ?? []).filter(
|
|
9
|
+
(r) => r.from === e
|
|
10
|
+
);
|
|
11
|
+
if (!o.length) {
|
|
12
|
+
const r = c(t, e), s = t.steps[r + 1];
|
|
13
|
+
return Promise.resolve(s?.id ?? null);
|
|
14
|
+
}
|
|
15
|
+
return u(o, n);
|
|
16
|
+
}
|
|
17
|
+
async function u(t, e) {
|
|
18
|
+
for (const n of t)
|
|
19
|
+
if (!n.condition || await e(n.condition))
|
|
20
|
+
return n.to;
|
|
21
|
+
return null;
|
|
22
|
+
}
|
|
23
|
+
function d(t, e, n) {
|
|
24
|
+
const i = t.locale[n], o = c(t, e.id);
|
|
25
|
+
if (i?.[o])
|
|
26
|
+
return i[o];
|
|
27
|
+
const r = n.split("-")[0], s = t.locale[r];
|
|
28
|
+
return s?.[o] ? s[o] : e.content;
|
|
29
|
+
}
|
|
30
|
+
export {
|
|
31
|
+
l as getNextStepId,
|
|
32
|
+
a as getStepById,
|
|
33
|
+
c as getStepIndex,
|
|
34
|
+
d as resolveLocalizedStepContent
|
|
35
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export * from './types/guidance.types';
|
|
2
|
+
export { GuidanceEngine } from './engine/guidance-engine';
|
|
3
|
+
export { GuideRegistry } from './engine/guide-registry';
|
|
4
|
+
export { sanitizeGuideManifest, validateGuideManifest, } from './engine/manifest-validator';
|
|
5
|
+
export { getNextStepId, getStepById, resolveLocalizedStepContent, } from './engine/step-navigation';
|
|
6
|
+
export { TriggerPluginRegistry } from './triggers/trigger-registry';
|
|
7
|
+
export { registerBuiltInTriggerPlugins } from './triggers/built-in-triggers';
|
|
8
|
+
export { LocalStorageGuidanceAdapter, defaultGuidanceStorageAdapter, } from './storage/storage-adapter';
|
|
9
|
+
export { buildGuidanceStorageKey, buildCampaignStorageKey, buildSessionStatsKey, } from './storage/storage-keys';
|
|
10
|
+
export { NoopGuidanceAnalyticsAdapter, SamplingGuidanceAnalyticsAdapter, defaultGuidanceAnalyticsAdapter, } from './analytics/analytics-adapter';
|
|
11
|
+
export { GuidanceTargetRefRegistry, globalGuidanceTargetRefRegistry, } from './targets/ref-registry';
|
|
12
|
+
export { TargetResolver, waitForTargetResolved, waitForTargetVisible, resolveTargetSynchronously } from './targets/target-resolver';
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { GuidanceStorageAdapter } from '../types/guidance.types';
|
|
2
|
+
export declare class LocalStorageGuidanceAdapter implements GuidanceStorageAdapter {
|
|
3
|
+
private readonly keyPrefix;
|
|
4
|
+
constructor(keyPrefix?: string);
|
|
5
|
+
get(keys: string[]): Promise<Record<string, unknown>>;
|
|
6
|
+
set(entries: Record<string, unknown>): Promise<void>;
|
|
7
|
+
delete(keys: string[]): Promise<void>;
|
|
8
|
+
erasure(): Promise<void>;
|
|
9
|
+
}
|
|
10
|
+
export declare const defaultGuidanceStorageAdapter: LocalStorageGuidanceAdapter;
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
const r = "guidance:";
|
|
2
|
+
class i {
|
|
3
|
+
keyPrefix;
|
|
4
|
+
constructor(t = r) {
|
|
5
|
+
this.keyPrefix = t;
|
|
6
|
+
}
|
|
7
|
+
async get(t) {
|
|
8
|
+
if (typeof window > "u")
|
|
9
|
+
return {};
|
|
10
|
+
const e = {};
|
|
11
|
+
for (const o of t) {
|
|
12
|
+
const n = window.localStorage.getItem(`${this.keyPrefix}${o}`);
|
|
13
|
+
if (n !== null)
|
|
14
|
+
try {
|
|
15
|
+
e[o] = JSON.parse(n);
|
|
16
|
+
} catch {
|
|
17
|
+
e[o] = n;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
return e;
|
|
21
|
+
}
|
|
22
|
+
async set(t) {
|
|
23
|
+
if (!(typeof window > "u"))
|
|
24
|
+
for (const [e, o] of Object.entries(t))
|
|
25
|
+
window.localStorage.setItem(
|
|
26
|
+
`${this.keyPrefix}${e}`,
|
|
27
|
+
JSON.stringify(o)
|
|
28
|
+
);
|
|
29
|
+
}
|
|
30
|
+
async delete(t) {
|
|
31
|
+
if (!(typeof window > "u"))
|
|
32
|
+
for (const e of t)
|
|
33
|
+
window.localStorage.removeItem(`${this.keyPrefix}${e}`);
|
|
34
|
+
}
|
|
35
|
+
async erasure() {
|
|
36
|
+
if (typeof window > "u")
|
|
37
|
+
return;
|
|
38
|
+
const t = [];
|
|
39
|
+
for (let e = 0; e < window.localStorage.length; e += 1) {
|
|
40
|
+
const o = window.localStorage.key(e);
|
|
41
|
+
o?.startsWith(this.keyPrefix) && t.push(o);
|
|
42
|
+
}
|
|
43
|
+
for (const e of t)
|
|
44
|
+
window.localStorage.removeItem(e);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
const s = new i();
|
|
48
|
+
export {
|
|
49
|
+
i as LocalStorageGuidanceAdapter,
|
|
50
|
+
s as defaultGuidanceStorageAdapter
|
|
51
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export declare function buildGuidanceStorageKey(tenantId: string, guideId: string, suffix: string): string;
|
|
2
|
+
export declare function buildCampaignStorageKey(tenantId: string, campaignId: string): string;
|
|
3
|
+
export declare function buildSessionStatsKey(tenantId: string): string;
|
|
4
|
+
export interface SessionStats {
|
|
5
|
+
guidesShownThisSession: number;
|
|
6
|
+
lastGuideEndedAt: number | null;
|
|
7
|
+
dismissedCounts: Record<string, number>;
|
|
8
|
+
snoozedUntil: Record<string, number>;
|
|
9
|
+
}
|
|
10
|
+
export declare function createDefaultSessionStats(): SessionStats;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
function t(n, e, i) {
|
|
2
|
+
return `guidance:${n}:${e}:${i}`;
|
|
3
|
+
}
|
|
4
|
+
function s(n, e) {
|
|
5
|
+
return `guidance:${n}:campaign:${e}`;
|
|
6
|
+
}
|
|
7
|
+
function u(n) {
|
|
8
|
+
return `guidance:${n}:session:stats`;
|
|
9
|
+
}
|
|
10
|
+
function a() {
|
|
11
|
+
return {
|
|
12
|
+
guidesShownThisSession: 0,
|
|
13
|
+
lastGuideEndedAt: null,
|
|
14
|
+
dismissedCounts: {},
|
|
15
|
+
snoozedUntil: {}
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
export {
|
|
19
|
+
s as buildCampaignStorageKey,
|
|
20
|
+
t as buildGuidanceStorageKey,
|
|
21
|
+
u as buildSessionStatsKey,
|
|
22
|
+
a as createDefaultSessionStats
|
|
23
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { ResolvedTarget, TargetDescriptor } from '../types/guidance.types';
|
|
2
|
+
export declare class GuidanceTargetRefRegistry {
|
|
3
|
+
private readonly targets;
|
|
4
|
+
private finalizationRegistry;
|
|
5
|
+
constructor();
|
|
6
|
+
register(targetId: string, element: HTMLElement, scope?: string): () => void;
|
|
7
|
+
unregister(targetId: string): void;
|
|
8
|
+
clearScope(scope: string): void;
|
|
9
|
+
resolve(targetId: string): ResolvedTarget | null;
|
|
10
|
+
resolveDescriptor(descriptor: TargetDescriptor, scopeRoot?: HTMLElement | null): ResolvedTarget | null;
|
|
11
|
+
}
|
|
12
|
+
export declare const globalGuidanceTargetRefRegistry: GuidanceTargetRefRegistry;
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
class o {
|
|
2
|
+
targets = /* @__PURE__ */ new Map();
|
|
3
|
+
finalizationRegistry = null;
|
|
4
|
+
constructor() {
|
|
5
|
+
typeof FinalizationRegistry < "u" && (this.finalizationRegistry = new FinalizationRegistry(
|
|
6
|
+
(e) => {
|
|
7
|
+
this.targets.delete(e);
|
|
8
|
+
}
|
|
9
|
+
));
|
|
10
|
+
}
|
|
11
|
+
register(e, t, r) {
|
|
12
|
+
return this.targets.size >= 500 && process.env.NODE_ENV === "development" && console.warn(
|
|
13
|
+
"[guidance] Target registry exceeded 500 entries"
|
|
14
|
+
), this.targets.set(e, {
|
|
15
|
+
targetId: e,
|
|
16
|
+
elementRef: new WeakRef(t),
|
|
17
|
+
scope: r
|
|
18
|
+
}), this.finalizationRegistry?.register(t, e), () => {
|
|
19
|
+
this.unregister(e);
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
unregister(e) {
|
|
23
|
+
this.targets.delete(e);
|
|
24
|
+
}
|
|
25
|
+
clearScope(e) {
|
|
26
|
+
for (const [t, r] of this.targets.entries())
|
|
27
|
+
r.scope === e && this.targets.delete(t);
|
|
28
|
+
}
|
|
29
|
+
resolve(e) {
|
|
30
|
+
const t = this.targets.get(e);
|
|
31
|
+
if (!t)
|
|
32
|
+
return null;
|
|
33
|
+
const r = t.elementRef.deref() ?? null;
|
|
34
|
+
return {
|
|
35
|
+
targetId: e,
|
|
36
|
+
element: r,
|
|
37
|
+
rect: r?.getBoundingClientRect() ?? null,
|
|
38
|
+
source: "ref"
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
resolveDescriptor(e, t) {
|
|
42
|
+
const r = this.resolve(e.targetId);
|
|
43
|
+
if (r?.element)
|
|
44
|
+
return r;
|
|
45
|
+
if (typeof document > "u")
|
|
46
|
+
return null;
|
|
47
|
+
const s = t ?? document, i = `[data-guidance-target="${e.targetId}"]`, n = s === document ? document.querySelector(i) : s.querySelector(i);
|
|
48
|
+
return n ? {
|
|
49
|
+
targetId: e.targetId,
|
|
50
|
+
element: n,
|
|
51
|
+
rect: n.getBoundingClientRect(),
|
|
52
|
+
source: "selector"
|
|
53
|
+
} : {
|
|
54
|
+
targetId: e.targetId,
|
|
55
|
+
element: null,
|
|
56
|
+
rect: null,
|
|
57
|
+
source: "selector"
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
const g = new o();
|
|
62
|
+
export {
|
|
63
|
+
o as GuidanceTargetRefRegistry,
|
|
64
|
+
g as globalGuidanceTargetRefRegistry
|
|
65
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { GuidancePlugin, ResolvedTarget, TargetDescriptor } from '../types/guidance.types';
|
|
2
|
+
import { GuidanceTargetRefRegistry } from './ref-registry';
|
|
3
|
+
export declare class TargetResolver {
|
|
4
|
+
private readonly adapterPlugins;
|
|
5
|
+
private readonly refRegistry;
|
|
6
|
+
constructor(refRegistry: GuidanceTargetRefRegistry);
|
|
7
|
+
registerAdapter(plugin: GuidancePlugin): void;
|
|
8
|
+
unregisterAdapter(pluginType: string): void;
|
|
9
|
+
resolve(descriptor: TargetDescriptor, scopeRoot?: HTMLElement | null, adapterType?: string, adapterConfig?: Record<string, unknown>): ResolvedTarget | null;
|
|
10
|
+
}
|
|
11
|
+
export declare function resolveTargetSynchronously(resolver: TargetResolver, descriptor: TargetDescriptor): ResolvedTarget | null;
|
|
12
|
+
export declare function waitForTargetResolved(resolver: TargetResolver, descriptor: TargetDescriptor, timeoutMs?: number): Promise<ResolvedTarget | null>;
|
|
13
|
+
export declare function waitForTargetVisible(element: HTMLElement, timeoutMs?: number): Promise<boolean>;
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
class f {
|
|
2
|
+
adapterPlugins = /* @__PURE__ */ new Map();
|
|
3
|
+
refRegistry;
|
|
4
|
+
constructor(e) {
|
|
5
|
+
this.refRegistry = e;
|
|
6
|
+
}
|
|
7
|
+
registerAdapter(e) {
|
|
8
|
+
this.adapterPlugins.set(e.type, e);
|
|
9
|
+
}
|
|
10
|
+
unregisterAdapter(e) {
|
|
11
|
+
this.adapterPlugins.delete(e);
|
|
12
|
+
}
|
|
13
|
+
resolve(e, t, n, r) {
|
|
14
|
+
if (n) {
|
|
15
|
+
const s = this.adapterPlugins.get(n);
|
|
16
|
+
if (s?.resolve) {
|
|
17
|
+
const o = {
|
|
18
|
+
targetDescriptor: e,
|
|
19
|
+
scopeRoot: t
|
|
20
|
+
};
|
|
21
|
+
try {
|
|
22
|
+
const l = s.resolve(
|
|
23
|
+
o,
|
|
24
|
+
r ?? {}
|
|
25
|
+
);
|
|
26
|
+
if (l && !(l instanceof Promise))
|
|
27
|
+
return l;
|
|
28
|
+
} catch {
|
|
29
|
+
return null;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
return this.refRegistry.resolveDescriptor(e, t);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
const c = 16;
|
|
37
|
+
function u(i) {
|
|
38
|
+
const e = i.getBoundingClientRect();
|
|
39
|
+
return e.width > 0 && e.height > 0;
|
|
40
|
+
}
|
|
41
|
+
function d(i, e) {
|
|
42
|
+
const t = i.resolve(e);
|
|
43
|
+
return !t?.element || e.waitUntil === "visible" && !u(t.element) ? null : t;
|
|
44
|
+
}
|
|
45
|
+
async function w(i, e, t = 5e3) {
|
|
46
|
+
const n = Date.now();
|
|
47
|
+
for (; Date.now() - n < t; ) {
|
|
48
|
+
const r = i.resolve(e);
|
|
49
|
+
if (r?.element)
|
|
50
|
+
if (e.waitUntil === "visible") {
|
|
51
|
+
const s = t - (Date.now() - n);
|
|
52
|
+
if (await g(
|
|
53
|
+
r.element,
|
|
54
|
+
Math.max(s, c)
|
|
55
|
+
))
|
|
56
|
+
return r;
|
|
57
|
+
} else
|
|
58
|
+
return r;
|
|
59
|
+
await new Promise((s) => {
|
|
60
|
+
window.setTimeout(s, c);
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
return null;
|
|
64
|
+
}
|
|
65
|
+
function g(i, e = 5e3) {
|
|
66
|
+
if (typeof window > "u" || typeof IntersectionObserver > "u")
|
|
67
|
+
return Promise.resolve(!0);
|
|
68
|
+
const t = i.getBoundingClientRect();
|
|
69
|
+
return t.width > 0 && t.height > 0 ? Promise.resolve(!0) : new Promise((n) => {
|
|
70
|
+
const r = new IntersectionObserver((o) => {
|
|
71
|
+
o.some(
|
|
72
|
+
(a) => a.isIntersecting && a.intersectionRatio > 0
|
|
73
|
+
) && (r.disconnect(), clearTimeout(s), n(!0));
|
|
74
|
+
}), s = setTimeout(() => {
|
|
75
|
+
r.disconnect(), n(!1);
|
|
76
|
+
}, e);
|
|
77
|
+
r.observe(i);
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
export {
|
|
81
|
+
f as TargetResolver,
|
|
82
|
+
d as resolveTargetSynchronously,
|
|
83
|
+
w as waitForTargetResolved,
|
|
84
|
+
g as waitForTargetVisible
|
|
85
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { GuidancePlugin } from '../types/guidance.types';
|
|
2
|
+
export declare function createRouteEnteredTriggerPlugin(): GuidancePlugin;
|
|
3
|
+
export declare function createRouteExitedTriggerPlugin(): GuidancePlugin;
|
|
4
|
+
export declare function createFirstVisitTriggerPlugin(): GuidancePlugin;
|
|
5
|
+
export declare function createNthVisitTriggerPlugin(): GuidancePlugin;
|
|
6
|
+
export declare function createAppVersionTriggerPlugin(): GuidancePlugin;
|
|
7
|
+
export declare function createFeatureFlagTriggerPlugin(): GuidancePlugin;
|
|
8
|
+
export declare function createPermissionTriggerPlugin(): GuidancePlugin;
|
|
9
|
+
export declare function createUserSegmentTriggerPlugin(): GuidancePlugin;
|
|
10
|
+
export declare function createCustomEventTriggerPlugin(): GuidancePlugin;
|
|
11
|
+
export declare function createManualTriggerPlugin(): GuidancePlugin;
|
|
12
|
+
export declare function registerBuiltInTriggerPlugins(registry: {
|
|
13
|
+
register: (plugin: GuidancePlugin) => void;
|
|
14
|
+
}): void;
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
function n() {
|
|
2
|
+
return {
|
|
3
|
+
type: "trigger.route-entered",
|
|
4
|
+
evaluate: (e, t) => {
|
|
5
|
+
const r = String(t.path ?? "");
|
|
6
|
+
return t.exact ? e.routePath === r : e.routePath.startsWith(r);
|
|
7
|
+
}
|
|
8
|
+
};
|
|
9
|
+
}
|
|
10
|
+
function u() {
|
|
11
|
+
return {
|
|
12
|
+
type: "trigger.route-exited",
|
|
13
|
+
evaluate: (e, t) => !e.routePath.startsWith(String(t.path ?? ""))
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
function g() {
|
|
17
|
+
return {
|
|
18
|
+
type: "trigger.first-visit",
|
|
19
|
+
evaluate: (e, t) => {
|
|
20
|
+
const r = String(t.guideId ?? "");
|
|
21
|
+
return (e.visitCounts[r] ?? 0) === 0;
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
function a() {
|
|
26
|
+
return {
|
|
27
|
+
type: "trigger.nth-visit",
|
|
28
|
+
evaluate: (e, t) => {
|
|
29
|
+
const r = String(t.guideId ?? ""), i = Number(t.count ?? 0);
|
|
30
|
+
return (e.visitCounts[r] ?? 0) === i;
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
function s() {
|
|
35
|
+
return {
|
|
36
|
+
type: "trigger.app-version",
|
|
37
|
+
evaluate: (e, t) => e.appVersion === String(t.version ?? "")
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
function o() {
|
|
41
|
+
return {
|
|
42
|
+
type: "trigger.feature-flag",
|
|
43
|
+
evaluate: (e, t) => {
|
|
44
|
+
const r = String(t.flag ?? ""), i = e.featureFlags[r] ?? !1;
|
|
45
|
+
return t.enabled === void 0 ? i : i === !!t.enabled;
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
function l() {
|
|
50
|
+
return {
|
|
51
|
+
type: "trigger.permission",
|
|
52
|
+
evaluate: (e, t) => e.permissions.includes(String(t.permission ?? ""))
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
function c() {
|
|
56
|
+
return {
|
|
57
|
+
type: "trigger.user-segment",
|
|
58
|
+
evaluate: (e, t) => e.userSegments.includes(String(t.segment ?? ""))
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
function p() {
|
|
62
|
+
return {
|
|
63
|
+
type: "trigger.custom-event",
|
|
64
|
+
evaluate: (e, t) => e.customEvents.has(String(t.event ?? ""))
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
function v() {
|
|
68
|
+
return {
|
|
69
|
+
type: "trigger.manual",
|
|
70
|
+
evaluate: () => !1
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
function f(e) {
|
|
74
|
+
e.register(n()), e.register(u()), e.register(g()), e.register(a()), e.register(s()), e.register(o()), e.register(l()), e.register(c()), e.register(p()), e.register(v());
|
|
75
|
+
}
|
|
76
|
+
export {
|
|
77
|
+
s as createAppVersionTriggerPlugin,
|
|
78
|
+
p as createCustomEventTriggerPlugin,
|
|
79
|
+
o as createFeatureFlagTriggerPlugin,
|
|
80
|
+
g as createFirstVisitTriggerPlugin,
|
|
81
|
+
v as createManualTriggerPlugin,
|
|
82
|
+
a as createNthVisitTriggerPlugin,
|
|
83
|
+
l as createPermissionTriggerPlugin,
|
|
84
|
+
n as createRouteEnteredTriggerPlugin,
|
|
85
|
+
u as createRouteExitedTriggerPlugin,
|
|
86
|
+
c as createUserSegmentTriggerPlugin,
|
|
87
|
+
f as registerBuiltInTriggerPlugins
|
|
88
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { GuidancePlugin, TriggerContext, TriggerExpression } from '../types/guidance.types';
|
|
2
|
+
export declare class TriggerPluginRegistry {
|
|
3
|
+
private readonly plugins;
|
|
4
|
+
register(plugin: GuidancePlugin): void;
|
|
5
|
+
unregister(pluginType: string): void;
|
|
6
|
+
get(pluginType: string): GuidancePlugin | undefined;
|
|
7
|
+
evaluateExpression(expression: TriggerExpression, context: TriggerContext): Promise<boolean>;
|
|
8
|
+
evaluateAll(expressions: TriggerExpression[], context: TriggerContext): Promise<boolean>;
|
|
9
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
class r {
|
|
2
|
+
plugins = /* @__PURE__ */ new Map();
|
|
3
|
+
register(t) {
|
|
4
|
+
this.plugins.set(t.type, t);
|
|
5
|
+
}
|
|
6
|
+
unregister(t) {
|
|
7
|
+
this.plugins.delete(t);
|
|
8
|
+
}
|
|
9
|
+
get(t) {
|
|
10
|
+
return this.plugins.get(t);
|
|
11
|
+
}
|
|
12
|
+
async evaluateExpression(t, e) {
|
|
13
|
+
if ("op" in t) {
|
|
14
|
+
if (t.op === "not") {
|
|
15
|
+
const i = t.conditions[0];
|
|
16
|
+
return i ? !await this.evaluateExpression(i, e) : !1;
|
|
17
|
+
}
|
|
18
|
+
const a = await Promise.all(
|
|
19
|
+
t.conditions.map(
|
|
20
|
+
(i) => this.evaluateExpression(i, e)
|
|
21
|
+
)
|
|
22
|
+
);
|
|
23
|
+
return t.op === "and" ? a.every(Boolean) : a.some(Boolean);
|
|
24
|
+
}
|
|
25
|
+
const n = this.plugins.get(t.plugin);
|
|
26
|
+
if (!n?.evaluate)
|
|
27
|
+
return !1;
|
|
28
|
+
try {
|
|
29
|
+
return !!await n.evaluate(e, t.config ?? {});
|
|
30
|
+
} catch {
|
|
31
|
+
return !1;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
async evaluateAll(t, e) {
|
|
35
|
+
return t.length ? (await Promise.all(
|
|
36
|
+
t.map(
|
|
37
|
+
(a) => this.evaluateExpression(a, e)
|
|
38
|
+
)
|
|
39
|
+
)).every(Boolean) : !0;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
export {
|
|
43
|
+
r as TriggerPluginRegistry
|
|
44
|
+
};
|