guideagent 0.1.0
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/README.md +1 -0
- package/dist/index.d.mts +37 -0
- package/dist/index.d.ts +37 -0
- package/dist/index.js +518 -0
- package/dist/index.mjs +429 -0
- package/dist/loader-KPVIVLN6.mjs +56 -0
- package/dist/loader-TLGJWSBC.mjs +38 -0
- package/licence +21 -0
- package/package.json +35 -0
package/README.md
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
http://127.0.0.1:5500/guideagent/test.html
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
interface LanguageStrings {
|
|
2
|
+
guide_label: string;
|
|
3
|
+
next_btn: string;
|
|
4
|
+
prev_btn: string;
|
|
5
|
+
finish_btn: string;
|
|
6
|
+
guide_me_btn: string;
|
|
7
|
+
guide_complete: string;
|
|
8
|
+
step_of: string;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
interface StepTranslation {
|
|
12
|
+
title: string;
|
|
13
|
+
description: string;
|
|
14
|
+
}
|
|
15
|
+
interface Step {
|
|
16
|
+
selector: string;
|
|
17
|
+
order: number;
|
|
18
|
+
translations: Record<string, StepTranslation>;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
interface GuideConfig {
|
|
22
|
+
steps: Step[];
|
|
23
|
+
language?: string;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
declare const GuideAgent: {
|
|
27
|
+
version: string;
|
|
28
|
+
init(config: GuideConfig): void;
|
|
29
|
+
initFromUrl(configUrl: string): Promise<void>;
|
|
30
|
+
start(): void;
|
|
31
|
+
stop(): void;
|
|
32
|
+
setLang(lang: string): void;
|
|
33
|
+
getStrings(): LanguageStrings;
|
|
34
|
+
createFloatingButton(): void;
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
export { GuideAgent as default };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
interface LanguageStrings {
|
|
2
|
+
guide_label: string;
|
|
3
|
+
next_btn: string;
|
|
4
|
+
prev_btn: string;
|
|
5
|
+
finish_btn: string;
|
|
6
|
+
guide_me_btn: string;
|
|
7
|
+
guide_complete: string;
|
|
8
|
+
step_of: string;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
interface StepTranslation {
|
|
12
|
+
title: string;
|
|
13
|
+
description: string;
|
|
14
|
+
}
|
|
15
|
+
interface Step {
|
|
16
|
+
selector: string;
|
|
17
|
+
order: number;
|
|
18
|
+
translations: Record<string, StepTranslation>;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
interface GuideConfig {
|
|
22
|
+
steps: Step[];
|
|
23
|
+
language?: string;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
declare const GuideAgent: {
|
|
27
|
+
version: string;
|
|
28
|
+
init(config: GuideConfig): void;
|
|
29
|
+
initFromUrl(configUrl: string): Promise<void>;
|
|
30
|
+
start(): void;
|
|
31
|
+
stop(): void;
|
|
32
|
+
setLang(lang: string): void;
|
|
33
|
+
getStrings(): LanguageStrings;
|
|
34
|
+
createFloatingButton(): void;
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
export { GuideAgent as default };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,518 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __esm = (fn, res) => function __init() {
|
|
7
|
+
return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
|
|
8
|
+
};
|
|
9
|
+
var __export = (target, all) => {
|
|
10
|
+
for (var name in all)
|
|
11
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
12
|
+
};
|
|
13
|
+
var __copyProps = (to, from, except, desc) => {
|
|
14
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
15
|
+
for (let key of __getOwnPropNames(from))
|
|
16
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
17
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
18
|
+
}
|
|
19
|
+
return to;
|
|
20
|
+
};
|
|
21
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
22
|
+
|
|
23
|
+
// src/config/loader.ts
|
|
24
|
+
var loader_exports = {};
|
|
25
|
+
__export(loader_exports, {
|
|
26
|
+
loadConfig: () => loadConfig
|
|
27
|
+
});
|
|
28
|
+
async function loadConfig(configUrl) {
|
|
29
|
+
try {
|
|
30
|
+
const response = await fetch(configUrl);
|
|
31
|
+
if (!response.ok) {
|
|
32
|
+
throw new Error(
|
|
33
|
+
`GuideAgent: Failed to load config from "${configUrl}" \u2014 HTTP ${response.status}`
|
|
34
|
+
);
|
|
35
|
+
}
|
|
36
|
+
const config = await response.json();
|
|
37
|
+
if (!config.steps || !Array.isArray(config.steps)) {
|
|
38
|
+
throw new Error(
|
|
39
|
+
`GuideAgent: Invalid config \u2014 "steps" array missing in "${configUrl}"`
|
|
40
|
+
);
|
|
41
|
+
}
|
|
42
|
+
config.steps.forEach((step, index) => {
|
|
43
|
+
if (!step.selector) {
|
|
44
|
+
throw new Error(
|
|
45
|
+
`GuideAgent: Step ${index + 1} missing "selector" field`
|
|
46
|
+
);
|
|
47
|
+
}
|
|
48
|
+
if (!step.translations) {
|
|
49
|
+
throw new Error(
|
|
50
|
+
`GuideAgent: Step ${index + 1} missing "translations" field`
|
|
51
|
+
);
|
|
52
|
+
}
|
|
53
|
+
if (!step.translations["en"]) {
|
|
54
|
+
throw new Error(
|
|
55
|
+
`GuideAgent: Step ${index + 1} missing "en" translation \u2014 English is required as fallback`
|
|
56
|
+
);
|
|
57
|
+
}
|
|
58
|
+
Object.entries(step.translations).forEach(([lang, t]) => {
|
|
59
|
+
if (!t.title) {
|
|
60
|
+
throw new Error(
|
|
61
|
+
`GuideAgent: Step ${index + 1} "${lang}" translation missing "title"`
|
|
62
|
+
);
|
|
63
|
+
}
|
|
64
|
+
if (!t.description) {
|
|
65
|
+
throw new Error(
|
|
66
|
+
`GuideAgent: Step ${index + 1} "${lang}" translation missing "description"`
|
|
67
|
+
);
|
|
68
|
+
}
|
|
69
|
+
});
|
|
70
|
+
});
|
|
71
|
+
console.log(
|
|
72
|
+
`GuideAgent: Config loaded \u2705 \u2014 ${config.steps.length} steps for page "${config.page}"`
|
|
73
|
+
);
|
|
74
|
+
return config;
|
|
75
|
+
} catch (error) {
|
|
76
|
+
console.error("GuideAgent config load failed:", error);
|
|
77
|
+
throw error;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
var init_loader = __esm({
|
|
81
|
+
"src/config/loader.ts"() {
|
|
82
|
+
"use strict";
|
|
83
|
+
}
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
// src/index.ts
|
|
87
|
+
var index_exports = {};
|
|
88
|
+
__export(index_exports, {
|
|
89
|
+
default: () => index_default
|
|
90
|
+
});
|
|
91
|
+
module.exports = __toCommonJS(index_exports);
|
|
92
|
+
|
|
93
|
+
// src/i18n/en.json
|
|
94
|
+
var en_default = {
|
|
95
|
+
guide_label: "GuideAgent",
|
|
96
|
+
next_btn: "Next \u2192",
|
|
97
|
+
prev_btn: "\u2190 Prev",
|
|
98
|
+
finish_btn: "Finish \u2713",
|
|
99
|
+
guide_me_btn: "\u{1F9ED} Guide Me",
|
|
100
|
+
guide_complete: "\u2713 Guide Complete!",
|
|
101
|
+
step_of: "Step {current} of {total}"
|
|
102
|
+
};
|
|
103
|
+
|
|
104
|
+
// src/i18n/ta.json
|
|
105
|
+
var ta_default = {
|
|
106
|
+
guide_label: "Vazhi Kaatti",
|
|
107
|
+
next_btn: "Aduthu \u2192",
|
|
108
|
+
prev_btn: "\u2190 Munnaadi",
|
|
109
|
+
finish_btn: "Mudinthathu \u2713",
|
|
110
|
+
guide_me_btn: "\u{1F9ED} Vazhi Kaattu",
|
|
111
|
+
guide_complete: "\u2713 Vazhi Kaattal Mudinthathu!",
|
|
112
|
+
step_of: "Padi {current} / {total}"
|
|
113
|
+
};
|
|
114
|
+
|
|
115
|
+
// src/i18n/hi.json
|
|
116
|
+
var hi_default = {
|
|
117
|
+
guide_label: "GuideAgent",
|
|
118
|
+
next_btn: "Aage \u2192",
|
|
119
|
+
prev_btn: "\u2190 Peeche",
|
|
120
|
+
finish_btn: "Khatam \u2713",
|
|
121
|
+
guide_me_btn: "\u{1F9ED} Mujhe Guide Karo",
|
|
122
|
+
guide_complete: "\u2713 Guide Poora Hua!",
|
|
123
|
+
step_of: "Kadam {current} / {total}"
|
|
124
|
+
};
|
|
125
|
+
|
|
126
|
+
// src/config/i18n.ts
|
|
127
|
+
var languages = { en: en_default, ta: ta_default, hi: hi_default };
|
|
128
|
+
var currentLang = "en";
|
|
129
|
+
function setLanguage(lang) {
|
|
130
|
+
if (languages[lang]) {
|
|
131
|
+
currentLang = lang;
|
|
132
|
+
console.log(`GuideAgent: Language set to "${lang}" \u2705`);
|
|
133
|
+
} else {
|
|
134
|
+
console.warn(`GuideAgent: "${lang}" not supported \u2014 using "en"`);
|
|
135
|
+
currentLang = "en";
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
function getCurrentLang() {
|
|
139
|
+
return currentLang;
|
|
140
|
+
}
|
|
141
|
+
function getStrings() {
|
|
142
|
+
var _a;
|
|
143
|
+
return (_a = languages[currentLang]) != null ? _a : languages["en"];
|
|
144
|
+
}
|
|
145
|
+
function formatStep(template, current, total) {
|
|
146
|
+
return template.replace("{current}", String(current)).replace("{total}", String(total));
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
// src/renderer/highlight.ts
|
|
150
|
+
var highlightBox = null;
|
|
151
|
+
var overlayMask = null;
|
|
152
|
+
function highlight(el) {
|
|
153
|
+
removeHighlight();
|
|
154
|
+
const rect = el.getBoundingClientRect();
|
|
155
|
+
overlayMask = document.createElement("div");
|
|
156
|
+
Object.assign(overlayMask.style, {
|
|
157
|
+
position: "fixed",
|
|
158
|
+
// fixed = stays in place even when user scrolls
|
|
159
|
+
top: "0",
|
|
160
|
+
left: "0",
|
|
161
|
+
width: "100vw",
|
|
162
|
+
// full screen width
|
|
163
|
+
height: "100vh",
|
|
164
|
+
// full screen height
|
|
165
|
+
backgroundColor: "rgba(0, 0, 0, 0.55)",
|
|
166
|
+
// semi-transparent black
|
|
167
|
+
zIndex: "9998",
|
|
168
|
+
// sits above your portfolio content
|
|
169
|
+
pointerEvents: "none"
|
|
170
|
+
// user can still interact with page behind it
|
|
171
|
+
});
|
|
172
|
+
highlightBox = document.createElement("div");
|
|
173
|
+
Object.assign(highlightBox.style, {
|
|
174
|
+
position: "fixed",
|
|
175
|
+
top: `${rect.top - 6}px`,
|
|
176
|
+
// 6px padding above element
|
|
177
|
+
left: `${rect.left - 6}px`,
|
|
178
|
+
// 6px padding left of element
|
|
179
|
+
width: `${rect.width + 12}px`,
|
|
180
|
+
// 12px wider (6px each side)
|
|
181
|
+
height: `${rect.height + 12}px`,
|
|
182
|
+
// 12px taller (6px each side)
|
|
183
|
+
border: "2px solid #6366f1",
|
|
184
|
+
// indigo border color
|
|
185
|
+
borderRadius: "8px",
|
|
186
|
+
zIndex: "9999",
|
|
187
|
+
// sits above the dark mask
|
|
188
|
+
pointerEvents: "none",
|
|
189
|
+
boxShadow: "0 0 12px rgba(99, 102, 241, 0.6)",
|
|
190
|
+
// soft glow effect
|
|
191
|
+
transition: "all 0.3s ease"
|
|
192
|
+
// smooth animation when moving steps
|
|
193
|
+
});
|
|
194
|
+
document.body.appendChild(overlayMask);
|
|
195
|
+
document.body.appendChild(highlightBox);
|
|
196
|
+
}
|
|
197
|
+
function removeHighlight() {
|
|
198
|
+
highlightBox == null ? void 0 : highlightBox.remove();
|
|
199
|
+
overlayMask == null ? void 0 : overlayMask.remove();
|
|
200
|
+
highlightBox = null;
|
|
201
|
+
overlayMask = null;
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
// src/renderer/tooltip.ts
|
|
205
|
+
var tooltipEl = null;
|
|
206
|
+
function showTooltip(el, title, description, onNext, onPrev, isFirst, isLast, currentStep, totalSteps) {
|
|
207
|
+
var _a, _b;
|
|
208
|
+
removeTooltip();
|
|
209
|
+
const s = getStrings();
|
|
210
|
+
const rect = el.getBoundingClientRect();
|
|
211
|
+
tooltipEl = document.createElement("div");
|
|
212
|
+
Object.assign(tooltipEl.style, {
|
|
213
|
+
position: "fixed",
|
|
214
|
+
zIndex: "10000",
|
|
215
|
+
background: "#1e1e2e",
|
|
216
|
+
color: "#ffffff",
|
|
217
|
+
padding: "16px 20px",
|
|
218
|
+
borderRadius: "10px",
|
|
219
|
+
width: "280px",
|
|
220
|
+
boxShadow: "0 8px 32px rgba(0,0,0,0.4)",
|
|
221
|
+
fontFamily: "sans-serif",
|
|
222
|
+
fontSize: "14px",
|
|
223
|
+
lineHeight: "1.5",
|
|
224
|
+
border: "1px solid #6366f1"
|
|
225
|
+
});
|
|
226
|
+
tooltipEl.innerHTML = `
|
|
227
|
+
<div style="
|
|
228
|
+
display: flex;
|
|
229
|
+
justify-content: space-between;
|
|
230
|
+
align-items: center;
|
|
231
|
+
margin-bottom: 8px;
|
|
232
|
+
">
|
|
233
|
+
<span style="font-size:12px; color:#a5b4fc; font-weight:600; text-transform:uppercase;">
|
|
234
|
+
${s.guide_label}
|
|
235
|
+
</span>
|
|
236
|
+
<span style="font-size:12px; color:#64748b;">
|
|
237
|
+
${formatStep(s.step_of, currentStep, totalSteps)}
|
|
238
|
+
</span>
|
|
239
|
+
</div>
|
|
240
|
+
|
|
241
|
+
<div style="font-size:16px; font-weight:700; margin-bottom:8px; color:#ffffff;">
|
|
242
|
+
${title}
|
|
243
|
+
</div>
|
|
244
|
+
|
|
245
|
+
<div style="font-size:14px; color:#cbd5e1; margin-bottom:16px;">
|
|
246
|
+
${description}
|
|
247
|
+
</div>
|
|
248
|
+
|
|
249
|
+
<div style="display:flex; gap:8px; justify-content:flex-end;">
|
|
250
|
+
${!isFirst ? `
|
|
251
|
+
<button id="guide-prev-btn" style="
|
|
252
|
+
background:transparent; color:#a5b4fc;
|
|
253
|
+
border:1px solid #6366f1; padding:6px 14px;
|
|
254
|
+
border-radius:6px; cursor:pointer; font-size:13px;
|
|
255
|
+
">${s.prev_btn}</button>
|
|
256
|
+
` : ""}
|
|
257
|
+
|
|
258
|
+
<button id="guide-next-btn" style="
|
|
259
|
+
background:#6366f1; color:white; border:none;
|
|
260
|
+
padding:6px 14px; border-radius:6px; cursor:pointer;
|
|
261
|
+
font-size:13px; font-weight:600;
|
|
262
|
+
">${isLast ? s.finish_btn : s.next_btn}</button>
|
|
263
|
+
</div>
|
|
264
|
+
`;
|
|
265
|
+
const viewportWidth = window.innerWidth;
|
|
266
|
+
const viewportHeight = window.innerHeight;
|
|
267
|
+
const tooltipWidth = 280;
|
|
268
|
+
const tooltipHeight = 180;
|
|
269
|
+
let top = rect.bottom + 12;
|
|
270
|
+
let left = rect.left;
|
|
271
|
+
if (top + tooltipHeight > viewportHeight) {
|
|
272
|
+
top = rect.top - tooltipHeight - 12;
|
|
273
|
+
}
|
|
274
|
+
if (top < 16) {
|
|
275
|
+
top = viewportHeight / 2 - tooltipHeight / 2;
|
|
276
|
+
}
|
|
277
|
+
if (left + tooltipWidth > viewportWidth) {
|
|
278
|
+
left = viewportWidth - tooltipWidth - 16;
|
|
279
|
+
}
|
|
280
|
+
if (left < 16) {
|
|
281
|
+
left = 16;
|
|
282
|
+
}
|
|
283
|
+
tooltipEl.style.top = `${top}px`;
|
|
284
|
+
tooltipEl.style.left = `${left}px`;
|
|
285
|
+
document.body.appendChild(tooltipEl);
|
|
286
|
+
(_a = document.getElementById("guide-next-btn")) == null ? void 0 : _a.addEventListener("click", onNext);
|
|
287
|
+
(_b = document.getElementById("guide-prev-btn")) == null ? void 0 : _b.addEventListener("click", onPrev);
|
|
288
|
+
}
|
|
289
|
+
function removeTooltip() {
|
|
290
|
+
tooltipEl == null ? void 0 : tooltipEl.remove();
|
|
291
|
+
tooltipEl = null;
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
// src/core/stepManager.ts
|
|
295
|
+
var StepManager = class {
|
|
296
|
+
constructor(steps) {
|
|
297
|
+
this.steps = steps.sort((a, b) => a.order - b.order);
|
|
298
|
+
this.currentIndex = 0;
|
|
299
|
+
}
|
|
300
|
+
current() {
|
|
301
|
+
return this.steps[this.currentIndex];
|
|
302
|
+
}
|
|
303
|
+
next() {
|
|
304
|
+
if (this.currentIndex < this.steps.length - 1) {
|
|
305
|
+
this.currentIndex++;
|
|
306
|
+
return this.steps[this.currentIndex];
|
|
307
|
+
}
|
|
308
|
+
return null;
|
|
309
|
+
}
|
|
310
|
+
prev() {
|
|
311
|
+
if (this.currentIndex > 0) {
|
|
312
|
+
this.currentIndex--;
|
|
313
|
+
return this.steps[this.currentIndex];
|
|
314
|
+
}
|
|
315
|
+
return null;
|
|
316
|
+
}
|
|
317
|
+
reset() {
|
|
318
|
+
this.currentIndex = 0;
|
|
319
|
+
}
|
|
320
|
+
isFirst() {
|
|
321
|
+
return this.currentIndex === 0;
|
|
322
|
+
}
|
|
323
|
+
isLast() {
|
|
324
|
+
return this.currentIndex === this.steps.length - 1;
|
|
325
|
+
}
|
|
326
|
+
currentNumber() {
|
|
327
|
+
return this.currentIndex + 1;
|
|
328
|
+
}
|
|
329
|
+
totalSteps() {
|
|
330
|
+
return this.steps.length;
|
|
331
|
+
}
|
|
332
|
+
};
|
|
333
|
+
|
|
334
|
+
// src/core/engine.ts
|
|
335
|
+
var GuideEngine = class {
|
|
336
|
+
// tracks if guide is currently running
|
|
337
|
+
constructor(config) {
|
|
338
|
+
this.active = false;
|
|
339
|
+
this.manager = new StepManager(config.steps);
|
|
340
|
+
}
|
|
341
|
+
// ─── Public API ───────────────────────────────────────────
|
|
342
|
+
start() {
|
|
343
|
+
if (this.active) this.stop();
|
|
344
|
+
this.active = true;
|
|
345
|
+
this.manager.reset();
|
|
346
|
+
this.renderStep();
|
|
347
|
+
console.log("GuideAgent \u25B6 Guide started");
|
|
348
|
+
}
|
|
349
|
+
next() {
|
|
350
|
+
if (!this.active) return;
|
|
351
|
+
const step = this.manager.next();
|
|
352
|
+
if (step) {
|
|
353
|
+
this.renderStep();
|
|
354
|
+
} else {
|
|
355
|
+
this.finish();
|
|
356
|
+
}
|
|
357
|
+
}
|
|
358
|
+
prev() {
|
|
359
|
+
if (!this.active) return;
|
|
360
|
+
const step = this.manager.prev();
|
|
361
|
+
if (step) {
|
|
362
|
+
this.renderStep();
|
|
363
|
+
}
|
|
364
|
+
}
|
|
365
|
+
stop() {
|
|
366
|
+
this.active = false;
|
|
367
|
+
removeHighlight();
|
|
368
|
+
removeTooltip();
|
|
369
|
+
console.log("GuideAgent \u25A0 Guide stopped");
|
|
370
|
+
}
|
|
371
|
+
// Add this inside GuideEngine class in engine.ts
|
|
372
|
+
// after the stop() method
|
|
373
|
+
// Loads config from a JSON file URL then starts the guide
|
|
374
|
+
async loadFromUrl(configUrl) {
|
|
375
|
+
try {
|
|
376
|
+
const { loadConfig: loadConfig2 } = await Promise.resolve().then(() => (init_loader(), loader_exports));
|
|
377
|
+
const config = await loadConfig2(configUrl);
|
|
378
|
+
this.manager = new StepManager(config.steps);
|
|
379
|
+
console.log("GuideAgent: Config loaded from URL \u2705");
|
|
380
|
+
} catch (error) {
|
|
381
|
+
console.error("GuideAgent: Could not load config:", error);
|
|
382
|
+
}
|
|
383
|
+
}
|
|
384
|
+
// ─── Private Methods ──────────────────────────────────────
|
|
385
|
+
finish() {
|
|
386
|
+
this.active = false;
|
|
387
|
+
removeHighlight();
|
|
388
|
+
removeTooltip();
|
|
389
|
+
console.log("GuideAgent \u2705 Guide complete");
|
|
390
|
+
this.showCompletionBadge();
|
|
391
|
+
}
|
|
392
|
+
renderStep() {
|
|
393
|
+
const step = this.manager.current();
|
|
394
|
+
setTimeout(() => {
|
|
395
|
+
const el = document.querySelector(step.selector);
|
|
396
|
+
if (!el) {
|
|
397
|
+
console.warn(`GuideAgent \u26A0 "${step.selector}" not found \u2014 skipping`);
|
|
398
|
+
this.next();
|
|
399
|
+
return;
|
|
400
|
+
}
|
|
401
|
+
el.scrollIntoView({ behavior: "smooth", block: "center" });
|
|
402
|
+
setTimeout(() => {
|
|
403
|
+
var _a;
|
|
404
|
+
const lang = getCurrentLang();
|
|
405
|
+
const translation = (_a = step.translations[lang]) != null ? _a : step.translations["en"];
|
|
406
|
+
highlight(el);
|
|
407
|
+
showTooltip(
|
|
408
|
+
el,
|
|
409
|
+
translation.title,
|
|
410
|
+
translation.description,
|
|
411
|
+
() => this.next(),
|
|
412
|
+
() => this.prev(),
|
|
413
|
+
this.manager.isFirst(),
|
|
414
|
+
this.manager.isLast(),
|
|
415
|
+
this.manager.currentNumber(),
|
|
416
|
+
this.manager.totalSteps()
|
|
417
|
+
);
|
|
418
|
+
console.log(
|
|
419
|
+
`GuideAgent \u2192 Step ${this.manager.currentNumber()}/${this.manager.totalSteps()} [${lang}]: ${translation.title}`
|
|
420
|
+
);
|
|
421
|
+
}, 1e3);
|
|
422
|
+
}, 300);
|
|
423
|
+
}
|
|
424
|
+
showCompletionBadge() {
|
|
425
|
+
const s = getStrings();
|
|
426
|
+
const badge = document.createElement("div");
|
|
427
|
+
Object.assign(badge.style, {
|
|
428
|
+
position: "fixed",
|
|
429
|
+
bottom: "32px",
|
|
430
|
+
left: "50%",
|
|
431
|
+
transform: "translateX(-50%)",
|
|
432
|
+
background: "#22c55e",
|
|
433
|
+
color: "white",
|
|
434
|
+
padding: "10px 24px",
|
|
435
|
+
borderRadius: "999px",
|
|
436
|
+
fontSize: "14px",
|
|
437
|
+
fontWeight: "600",
|
|
438
|
+
fontFamily: "sans-serif",
|
|
439
|
+
zIndex: "10001",
|
|
440
|
+
boxShadow: "0 4px 16px rgba(34,197,94,0.4)"
|
|
441
|
+
});
|
|
442
|
+
badge.textContent = s.guide_complete;
|
|
443
|
+
document.body.appendChild(badge);
|
|
444
|
+
setTimeout(() => badge.remove(), 2e3);
|
|
445
|
+
}
|
|
446
|
+
};
|
|
447
|
+
|
|
448
|
+
// src/index.ts
|
|
449
|
+
var engine = null;
|
|
450
|
+
var floatingBtn = null;
|
|
451
|
+
var GuideAgent = {
|
|
452
|
+
version: "0.1.0",
|
|
453
|
+
init(config) {
|
|
454
|
+
engine = new GuideEngine(config);
|
|
455
|
+
this.createFloatingButton();
|
|
456
|
+
console.log("GuideAgent initialized \u2705");
|
|
457
|
+
},
|
|
458
|
+
async initFromUrl(configUrl) {
|
|
459
|
+
try {
|
|
460
|
+
const { loadConfig: loadConfig2 } = await Promise.resolve().then(() => (init_loader(), loader_exports));
|
|
461
|
+
const config = await loadConfig2(configUrl);
|
|
462
|
+
engine = new GuideEngine({ steps: config.steps });
|
|
463
|
+
this.createFloatingButton();
|
|
464
|
+
console.log("GuideAgent initialized from URL \u2705");
|
|
465
|
+
} catch (error) {
|
|
466
|
+
console.error("GuideAgent: initFromUrl failed:", error);
|
|
467
|
+
}
|
|
468
|
+
},
|
|
469
|
+
start() {
|
|
470
|
+
engine == null ? void 0 : engine.start();
|
|
471
|
+
},
|
|
472
|
+
stop() {
|
|
473
|
+
engine == null ? void 0 : engine.stop();
|
|
474
|
+
},
|
|
475
|
+
setLang(lang) {
|
|
476
|
+
setLanguage(lang);
|
|
477
|
+
if (floatingBtn) {
|
|
478
|
+
floatingBtn.textContent = getStrings().guide_me_btn;
|
|
479
|
+
}
|
|
480
|
+
},
|
|
481
|
+
// Expose getStrings so HTML can read page content keys
|
|
482
|
+
getStrings() {
|
|
483
|
+
return getStrings();
|
|
484
|
+
},
|
|
485
|
+
createFloatingButton() {
|
|
486
|
+
floatingBtn == null ? void 0 : floatingBtn.remove();
|
|
487
|
+
floatingBtn = document.createElement("button");
|
|
488
|
+
floatingBtn.textContent = getStrings().guide_me_btn;
|
|
489
|
+
Object.assign(floatingBtn.style, {
|
|
490
|
+
position: "fixed",
|
|
491
|
+
bottom: "24px",
|
|
492
|
+
right: "24px",
|
|
493
|
+
background: "#6366f1",
|
|
494
|
+
color: "white",
|
|
495
|
+
border: "none",
|
|
496
|
+
padding: "12px 20px",
|
|
497
|
+
borderRadius: "999px",
|
|
498
|
+
fontSize: "14px",
|
|
499
|
+
fontWeight: "600",
|
|
500
|
+
fontFamily: "sans-serif",
|
|
501
|
+
cursor: "pointer",
|
|
502
|
+
zIndex: "10001",
|
|
503
|
+
boxShadow: "0 4px 20px rgba(99,102,241,0.5)",
|
|
504
|
+
transition: "transform 0.2s ease"
|
|
505
|
+
});
|
|
506
|
+
floatingBtn.addEventListener("mouseenter", () => {
|
|
507
|
+
floatingBtn.style.transform = "scale(1.05)";
|
|
508
|
+
});
|
|
509
|
+
floatingBtn.addEventListener("mouseleave", () => {
|
|
510
|
+
floatingBtn.style.transform = "scale(1)";
|
|
511
|
+
});
|
|
512
|
+
floatingBtn.addEventListener("click", () => {
|
|
513
|
+
engine == null ? void 0 : engine.start();
|
|
514
|
+
});
|
|
515
|
+
document.body.appendChild(floatingBtn);
|
|
516
|
+
}
|
|
517
|
+
};
|
|
518
|
+
var index_default = GuideAgent;
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,429 @@
|
|
|
1
|
+
// src/i18n/en.json
|
|
2
|
+
var en_default = {
|
|
3
|
+
guide_label: "GuideAgent",
|
|
4
|
+
next_btn: "Next \u2192",
|
|
5
|
+
prev_btn: "\u2190 Prev",
|
|
6
|
+
finish_btn: "Finish \u2713",
|
|
7
|
+
guide_me_btn: "\u{1F9ED} Guide Me",
|
|
8
|
+
guide_complete: "\u2713 Guide Complete!",
|
|
9
|
+
step_of: "Step {current} of {total}"
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
// src/i18n/ta.json
|
|
13
|
+
var ta_default = {
|
|
14
|
+
guide_label: "Vazhi Kaatti",
|
|
15
|
+
next_btn: "Aduthu \u2192",
|
|
16
|
+
prev_btn: "\u2190 Munnaadi",
|
|
17
|
+
finish_btn: "Mudinthathu \u2713",
|
|
18
|
+
guide_me_btn: "\u{1F9ED} Vazhi Kaattu",
|
|
19
|
+
guide_complete: "\u2713 Vazhi Kaattal Mudinthathu!",
|
|
20
|
+
step_of: "Padi {current} / {total}"
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
// src/i18n/hi.json
|
|
24
|
+
var hi_default = {
|
|
25
|
+
guide_label: "GuideAgent",
|
|
26
|
+
next_btn: "Aage \u2192",
|
|
27
|
+
prev_btn: "\u2190 Peeche",
|
|
28
|
+
finish_btn: "Khatam \u2713",
|
|
29
|
+
guide_me_btn: "\u{1F9ED} Mujhe Guide Karo",
|
|
30
|
+
guide_complete: "\u2713 Guide Poora Hua!",
|
|
31
|
+
step_of: "Kadam {current} / {total}"
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
// src/config/i18n.ts
|
|
35
|
+
var languages = { en: en_default, ta: ta_default, hi: hi_default };
|
|
36
|
+
var currentLang = "en";
|
|
37
|
+
function setLanguage(lang) {
|
|
38
|
+
if (languages[lang]) {
|
|
39
|
+
currentLang = lang;
|
|
40
|
+
console.log(`GuideAgent: Language set to "${lang}" \u2705`);
|
|
41
|
+
} else {
|
|
42
|
+
console.warn(`GuideAgent: "${lang}" not supported \u2014 using "en"`);
|
|
43
|
+
currentLang = "en";
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
function getCurrentLang() {
|
|
47
|
+
return currentLang;
|
|
48
|
+
}
|
|
49
|
+
function getStrings() {
|
|
50
|
+
var _a;
|
|
51
|
+
return (_a = languages[currentLang]) != null ? _a : languages["en"];
|
|
52
|
+
}
|
|
53
|
+
function formatStep(template, current, total) {
|
|
54
|
+
return template.replace("{current}", String(current)).replace("{total}", String(total));
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
// src/renderer/highlight.ts
|
|
58
|
+
var highlightBox = null;
|
|
59
|
+
var overlayMask = null;
|
|
60
|
+
function highlight(el) {
|
|
61
|
+
removeHighlight();
|
|
62
|
+
const rect = el.getBoundingClientRect();
|
|
63
|
+
overlayMask = document.createElement("div");
|
|
64
|
+
Object.assign(overlayMask.style, {
|
|
65
|
+
position: "fixed",
|
|
66
|
+
// fixed = stays in place even when user scrolls
|
|
67
|
+
top: "0",
|
|
68
|
+
left: "0",
|
|
69
|
+
width: "100vw",
|
|
70
|
+
// full screen width
|
|
71
|
+
height: "100vh",
|
|
72
|
+
// full screen height
|
|
73
|
+
backgroundColor: "rgba(0, 0, 0, 0.55)",
|
|
74
|
+
// semi-transparent black
|
|
75
|
+
zIndex: "9998",
|
|
76
|
+
// sits above your portfolio content
|
|
77
|
+
pointerEvents: "none"
|
|
78
|
+
// user can still interact with page behind it
|
|
79
|
+
});
|
|
80
|
+
highlightBox = document.createElement("div");
|
|
81
|
+
Object.assign(highlightBox.style, {
|
|
82
|
+
position: "fixed",
|
|
83
|
+
top: `${rect.top - 6}px`,
|
|
84
|
+
// 6px padding above element
|
|
85
|
+
left: `${rect.left - 6}px`,
|
|
86
|
+
// 6px padding left of element
|
|
87
|
+
width: `${rect.width + 12}px`,
|
|
88
|
+
// 12px wider (6px each side)
|
|
89
|
+
height: `${rect.height + 12}px`,
|
|
90
|
+
// 12px taller (6px each side)
|
|
91
|
+
border: "2px solid #6366f1",
|
|
92
|
+
// indigo border color
|
|
93
|
+
borderRadius: "8px",
|
|
94
|
+
zIndex: "9999",
|
|
95
|
+
// sits above the dark mask
|
|
96
|
+
pointerEvents: "none",
|
|
97
|
+
boxShadow: "0 0 12px rgba(99, 102, 241, 0.6)",
|
|
98
|
+
// soft glow effect
|
|
99
|
+
transition: "all 0.3s ease"
|
|
100
|
+
// smooth animation when moving steps
|
|
101
|
+
});
|
|
102
|
+
document.body.appendChild(overlayMask);
|
|
103
|
+
document.body.appendChild(highlightBox);
|
|
104
|
+
}
|
|
105
|
+
function removeHighlight() {
|
|
106
|
+
highlightBox == null ? void 0 : highlightBox.remove();
|
|
107
|
+
overlayMask == null ? void 0 : overlayMask.remove();
|
|
108
|
+
highlightBox = null;
|
|
109
|
+
overlayMask = null;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
// src/renderer/tooltip.ts
|
|
113
|
+
var tooltipEl = null;
|
|
114
|
+
function showTooltip(el, title, description, onNext, onPrev, isFirst, isLast, currentStep, totalSteps) {
|
|
115
|
+
var _a, _b;
|
|
116
|
+
removeTooltip();
|
|
117
|
+
const s = getStrings();
|
|
118
|
+
const rect = el.getBoundingClientRect();
|
|
119
|
+
tooltipEl = document.createElement("div");
|
|
120
|
+
Object.assign(tooltipEl.style, {
|
|
121
|
+
position: "fixed",
|
|
122
|
+
zIndex: "10000",
|
|
123
|
+
background: "#1e1e2e",
|
|
124
|
+
color: "#ffffff",
|
|
125
|
+
padding: "16px 20px",
|
|
126
|
+
borderRadius: "10px",
|
|
127
|
+
width: "280px",
|
|
128
|
+
boxShadow: "0 8px 32px rgba(0,0,0,0.4)",
|
|
129
|
+
fontFamily: "sans-serif",
|
|
130
|
+
fontSize: "14px",
|
|
131
|
+
lineHeight: "1.5",
|
|
132
|
+
border: "1px solid #6366f1"
|
|
133
|
+
});
|
|
134
|
+
tooltipEl.innerHTML = `
|
|
135
|
+
<div style="
|
|
136
|
+
display: flex;
|
|
137
|
+
justify-content: space-between;
|
|
138
|
+
align-items: center;
|
|
139
|
+
margin-bottom: 8px;
|
|
140
|
+
">
|
|
141
|
+
<span style="font-size:12px; color:#a5b4fc; font-weight:600; text-transform:uppercase;">
|
|
142
|
+
${s.guide_label}
|
|
143
|
+
</span>
|
|
144
|
+
<span style="font-size:12px; color:#64748b;">
|
|
145
|
+
${formatStep(s.step_of, currentStep, totalSteps)}
|
|
146
|
+
</span>
|
|
147
|
+
</div>
|
|
148
|
+
|
|
149
|
+
<div style="font-size:16px; font-weight:700; margin-bottom:8px; color:#ffffff;">
|
|
150
|
+
${title}
|
|
151
|
+
</div>
|
|
152
|
+
|
|
153
|
+
<div style="font-size:14px; color:#cbd5e1; margin-bottom:16px;">
|
|
154
|
+
${description}
|
|
155
|
+
</div>
|
|
156
|
+
|
|
157
|
+
<div style="display:flex; gap:8px; justify-content:flex-end;">
|
|
158
|
+
${!isFirst ? `
|
|
159
|
+
<button id="guide-prev-btn" style="
|
|
160
|
+
background:transparent; color:#a5b4fc;
|
|
161
|
+
border:1px solid #6366f1; padding:6px 14px;
|
|
162
|
+
border-radius:6px; cursor:pointer; font-size:13px;
|
|
163
|
+
">${s.prev_btn}</button>
|
|
164
|
+
` : ""}
|
|
165
|
+
|
|
166
|
+
<button id="guide-next-btn" style="
|
|
167
|
+
background:#6366f1; color:white; border:none;
|
|
168
|
+
padding:6px 14px; border-radius:6px; cursor:pointer;
|
|
169
|
+
font-size:13px; font-weight:600;
|
|
170
|
+
">${isLast ? s.finish_btn : s.next_btn}</button>
|
|
171
|
+
</div>
|
|
172
|
+
`;
|
|
173
|
+
const viewportWidth = window.innerWidth;
|
|
174
|
+
const viewportHeight = window.innerHeight;
|
|
175
|
+
const tooltipWidth = 280;
|
|
176
|
+
const tooltipHeight = 180;
|
|
177
|
+
let top = rect.bottom + 12;
|
|
178
|
+
let left = rect.left;
|
|
179
|
+
if (top + tooltipHeight > viewportHeight) {
|
|
180
|
+
top = rect.top - tooltipHeight - 12;
|
|
181
|
+
}
|
|
182
|
+
if (top < 16) {
|
|
183
|
+
top = viewportHeight / 2 - tooltipHeight / 2;
|
|
184
|
+
}
|
|
185
|
+
if (left + tooltipWidth > viewportWidth) {
|
|
186
|
+
left = viewportWidth - tooltipWidth - 16;
|
|
187
|
+
}
|
|
188
|
+
if (left < 16) {
|
|
189
|
+
left = 16;
|
|
190
|
+
}
|
|
191
|
+
tooltipEl.style.top = `${top}px`;
|
|
192
|
+
tooltipEl.style.left = `${left}px`;
|
|
193
|
+
document.body.appendChild(tooltipEl);
|
|
194
|
+
(_a = document.getElementById("guide-next-btn")) == null ? void 0 : _a.addEventListener("click", onNext);
|
|
195
|
+
(_b = document.getElementById("guide-prev-btn")) == null ? void 0 : _b.addEventListener("click", onPrev);
|
|
196
|
+
}
|
|
197
|
+
function removeTooltip() {
|
|
198
|
+
tooltipEl == null ? void 0 : tooltipEl.remove();
|
|
199
|
+
tooltipEl = null;
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
// src/core/stepManager.ts
|
|
203
|
+
var StepManager = class {
|
|
204
|
+
constructor(steps) {
|
|
205
|
+
this.steps = steps.sort((a, b) => a.order - b.order);
|
|
206
|
+
this.currentIndex = 0;
|
|
207
|
+
}
|
|
208
|
+
current() {
|
|
209
|
+
return this.steps[this.currentIndex];
|
|
210
|
+
}
|
|
211
|
+
next() {
|
|
212
|
+
if (this.currentIndex < this.steps.length - 1) {
|
|
213
|
+
this.currentIndex++;
|
|
214
|
+
return this.steps[this.currentIndex];
|
|
215
|
+
}
|
|
216
|
+
return null;
|
|
217
|
+
}
|
|
218
|
+
prev() {
|
|
219
|
+
if (this.currentIndex > 0) {
|
|
220
|
+
this.currentIndex--;
|
|
221
|
+
return this.steps[this.currentIndex];
|
|
222
|
+
}
|
|
223
|
+
return null;
|
|
224
|
+
}
|
|
225
|
+
reset() {
|
|
226
|
+
this.currentIndex = 0;
|
|
227
|
+
}
|
|
228
|
+
isFirst() {
|
|
229
|
+
return this.currentIndex === 0;
|
|
230
|
+
}
|
|
231
|
+
isLast() {
|
|
232
|
+
return this.currentIndex === this.steps.length - 1;
|
|
233
|
+
}
|
|
234
|
+
currentNumber() {
|
|
235
|
+
return this.currentIndex + 1;
|
|
236
|
+
}
|
|
237
|
+
totalSteps() {
|
|
238
|
+
return this.steps.length;
|
|
239
|
+
}
|
|
240
|
+
};
|
|
241
|
+
|
|
242
|
+
// src/core/engine.ts
|
|
243
|
+
var GuideEngine = class {
|
|
244
|
+
// tracks if guide is currently running
|
|
245
|
+
constructor(config) {
|
|
246
|
+
this.active = false;
|
|
247
|
+
this.manager = new StepManager(config.steps);
|
|
248
|
+
}
|
|
249
|
+
// ─── Public API ───────────────────────────────────────────
|
|
250
|
+
start() {
|
|
251
|
+
if (this.active) this.stop();
|
|
252
|
+
this.active = true;
|
|
253
|
+
this.manager.reset();
|
|
254
|
+
this.renderStep();
|
|
255
|
+
console.log("GuideAgent \u25B6 Guide started");
|
|
256
|
+
}
|
|
257
|
+
next() {
|
|
258
|
+
if (!this.active) return;
|
|
259
|
+
const step = this.manager.next();
|
|
260
|
+
if (step) {
|
|
261
|
+
this.renderStep();
|
|
262
|
+
} else {
|
|
263
|
+
this.finish();
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
prev() {
|
|
267
|
+
if (!this.active) return;
|
|
268
|
+
const step = this.manager.prev();
|
|
269
|
+
if (step) {
|
|
270
|
+
this.renderStep();
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
stop() {
|
|
274
|
+
this.active = false;
|
|
275
|
+
removeHighlight();
|
|
276
|
+
removeTooltip();
|
|
277
|
+
console.log("GuideAgent \u25A0 Guide stopped");
|
|
278
|
+
}
|
|
279
|
+
// Add this inside GuideEngine class in engine.ts
|
|
280
|
+
// after the stop() method
|
|
281
|
+
// Loads config from a JSON file URL then starts the guide
|
|
282
|
+
async loadFromUrl(configUrl) {
|
|
283
|
+
try {
|
|
284
|
+
const { loadConfig } = await import("./loader-KPVIVLN6.mjs");
|
|
285
|
+
const config = await loadConfig(configUrl);
|
|
286
|
+
this.manager = new StepManager(config.steps);
|
|
287
|
+
console.log("GuideAgent: Config loaded from URL \u2705");
|
|
288
|
+
} catch (error) {
|
|
289
|
+
console.error("GuideAgent: Could not load config:", error);
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
// ─── Private Methods ──────────────────────────────────────
|
|
293
|
+
finish() {
|
|
294
|
+
this.active = false;
|
|
295
|
+
removeHighlight();
|
|
296
|
+
removeTooltip();
|
|
297
|
+
console.log("GuideAgent \u2705 Guide complete");
|
|
298
|
+
this.showCompletionBadge();
|
|
299
|
+
}
|
|
300
|
+
renderStep() {
|
|
301
|
+
const step = this.manager.current();
|
|
302
|
+
setTimeout(() => {
|
|
303
|
+
const el = document.querySelector(step.selector);
|
|
304
|
+
if (!el) {
|
|
305
|
+
console.warn(`GuideAgent \u26A0 "${step.selector}" not found \u2014 skipping`);
|
|
306
|
+
this.next();
|
|
307
|
+
return;
|
|
308
|
+
}
|
|
309
|
+
el.scrollIntoView({ behavior: "smooth", block: "center" });
|
|
310
|
+
setTimeout(() => {
|
|
311
|
+
var _a;
|
|
312
|
+
const lang = getCurrentLang();
|
|
313
|
+
const translation = (_a = step.translations[lang]) != null ? _a : step.translations["en"];
|
|
314
|
+
highlight(el);
|
|
315
|
+
showTooltip(
|
|
316
|
+
el,
|
|
317
|
+
translation.title,
|
|
318
|
+
translation.description,
|
|
319
|
+
() => this.next(),
|
|
320
|
+
() => this.prev(),
|
|
321
|
+
this.manager.isFirst(),
|
|
322
|
+
this.manager.isLast(),
|
|
323
|
+
this.manager.currentNumber(),
|
|
324
|
+
this.manager.totalSteps()
|
|
325
|
+
);
|
|
326
|
+
console.log(
|
|
327
|
+
`GuideAgent \u2192 Step ${this.manager.currentNumber()}/${this.manager.totalSteps()} [${lang}]: ${translation.title}`
|
|
328
|
+
);
|
|
329
|
+
}, 1e3);
|
|
330
|
+
}, 300);
|
|
331
|
+
}
|
|
332
|
+
showCompletionBadge() {
|
|
333
|
+
const s = getStrings();
|
|
334
|
+
const badge = document.createElement("div");
|
|
335
|
+
Object.assign(badge.style, {
|
|
336
|
+
position: "fixed",
|
|
337
|
+
bottom: "32px",
|
|
338
|
+
left: "50%",
|
|
339
|
+
transform: "translateX(-50%)",
|
|
340
|
+
background: "#22c55e",
|
|
341
|
+
color: "white",
|
|
342
|
+
padding: "10px 24px",
|
|
343
|
+
borderRadius: "999px",
|
|
344
|
+
fontSize: "14px",
|
|
345
|
+
fontWeight: "600",
|
|
346
|
+
fontFamily: "sans-serif",
|
|
347
|
+
zIndex: "10001",
|
|
348
|
+
boxShadow: "0 4px 16px rgba(34,197,94,0.4)"
|
|
349
|
+
});
|
|
350
|
+
badge.textContent = s.guide_complete;
|
|
351
|
+
document.body.appendChild(badge);
|
|
352
|
+
setTimeout(() => badge.remove(), 2e3);
|
|
353
|
+
}
|
|
354
|
+
};
|
|
355
|
+
|
|
356
|
+
// src/index.ts
|
|
357
|
+
var engine = null;
|
|
358
|
+
var floatingBtn = null;
|
|
359
|
+
var GuideAgent = {
|
|
360
|
+
version: "0.1.0",
|
|
361
|
+
init(config) {
|
|
362
|
+
engine = new GuideEngine(config);
|
|
363
|
+
this.createFloatingButton();
|
|
364
|
+
console.log("GuideAgent initialized \u2705");
|
|
365
|
+
},
|
|
366
|
+
async initFromUrl(configUrl) {
|
|
367
|
+
try {
|
|
368
|
+
const { loadConfig } = await import("./loader-KPVIVLN6.mjs");
|
|
369
|
+
const config = await loadConfig(configUrl);
|
|
370
|
+
engine = new GuideEngine({ steps: config.steps });
|
|
371
|
+
this.createFloatingButton();
|
|
372
|
+
console.log("GuideAgent initialized from URL \u2705");
|
|
373
|
+
} catch (error) {
|
|
374
|
+
console.error("GuideAgent: initFromUrl failed:", error);
|
|
375
|
+
}
|
|
376
|
+
},
|
|
377
|
+
start() {
|
|
378
|
+
engine == null ? void 0 : engine.start();
|
|
379
|
+
},
|
|
380
|
+
stop() {
|
|
381
|
+
engine == null ? void 0 : engine.stop();
|
|
382
|
+
},
|
|
383
|
+
setLang(lang) {
|
|
384
|
+
setLanguage(lang);
|
|
385
|
+
if (floatingBtn) {
|
|
386
|
+
floatingBtn.textContent = getStrings().guide_me_btn;
|
|
387
|
+
}
|
|
388
|
+
},
|
|
389
|
+
// Expose getStrings so HTML can read page content keys
|
|
390
|
+
getStrings() {
|
|
391
|
+
return getStrings();
|
|
392
|
+
},
|
|
393
|
+
createFloatingButton() {
|
|
394
|
+
floatingBtn == null ? void 0 : floatingBtn.remove();
|
|
395
|
+
floatingBtn = document.createElement("button");
|
|
396
|
+
floatingBtn.textContent = getStrings().guide_me_btn;
|
|
397
|
+
Object.assign(floatingBtn.style, {
|
|
398
|
+
position: "fixed",
|
|
399
|
+
bottom: "24px",
|
|
400
|
+
right: "24px",
|
|
401
|
+
background: "#6366f1",
|
|
402
|
+
color: "white",
|
|
403
|
+
border: "none",
|
|
404
|
+
padding: "12px 20px",
|
|
405
|
+
borderRadius: "999px",
|
|
406
|
+
fontSize: "14px",
|
|
407
|
+
fontWeight: "600",
|
|
408
|
+
fontFamily: "sans-serif",
|
|
409
|
+
cursor: "pointer",
|
|
410
|
+
zIndex: "10001",
|
|
411
|
+
boxShadow: "0 4px 20px rgba(99,102,241,0.5)",
|
|
412
|
+
transition: "transform 0.2s ease"
|
|
413
|
+
});
|
|
414
|
+
floatingBtn.addEventListener("mouseenter", () => {
|
|
415
|
+
floatingBtn.style.transform = "scale(1.05)";
|
|
416
|
+
});
|
|
417
|
+
floatingBtn.addEventListener("mouseleave", () => {
|
|
418
|
+
floatingBtn.style.transform = "scale(1)";
|
|
419
|
+
});
|
|
420
|
+
floatingBtn.addEventListener("click", () => {
|
|
421
|
+
engine == null ? void 0 : engine.start();
|
|
422
|
+
});
|
|
423
|
+
document.body.appendChild(floatingBtn);
|
|
424
|
+
}
|
|
425
|
+
};
|
|
426
|
+
var index_default = GuideAgent;
|
|
427
|
+
export {
|
|
428
|
+
index_default as default
|
|
429
|
+
};
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
// src/config/loader.ts
|
|
2
|
+
async function loadConfig(configUrl) {
|
|
3
|
+
try {
|
|
4
|
+
const response = await fetch(configUrl);
|
|
5
|
+
if (!response.ok) {
|
|
6
|
+
throw new Error(
|
|
7
|
+
`GuideAgent: Failed to load config from "${configUrl}" \u2014 HTTP ${response.status}`
|
|
8
|
+
);
|
|
9
|
+
}
|
|
10
|
+
const config = await response.json();
|
|
11
|
+
if (!config.steps || !Array.isArray(config.steps)) {
|
|
12
|
+
throw new Error(
|
|
13
|
+
`GuideAgent: Invalid config \u2014 "steps" array missing in "${configUrl}"`
|
|
14
|
+
);
|
|
15
|
+
}
|
|
16
|
+
config.steps.forEach((step, index) => {
|
|
17
|
+
if (!step.selector) {
|
|
18
|
+
throw new Error(
|
|
19
|
+
`GuideAgent: Step ${index + 1} missing "selector" field`
|
|
20
|
+
);
|
|
21
|
+
}
|
|
22
|
+
if (!step.translations) {
|
|
23
|
+
throw new Error(
|
|
24
|
+
`GuideAgent: Step ${index + 1} missing "translations" field`
|
|
25
|
+
);
|
|
26
|
+
}
|
|
27
|
+
if (!step.translations["en"]) {
|
|
28
|
+
throw new Error(
|
|
29
|
+
`GuideAgent: Step ${index + 1} missing "en" translation \u2014 English is required as fallback`
|
|
30
|
+
);
|
|
31
|
+
}
|
|
32
|
+
Object.entries(step.translations).forEach(([lang, t]) => {
|
|
33
|
+
if (!t.title) {
|
|
34
|
+
throw new Error(
|
|
35
|
+
`GuideAgent: Step ${index + 1} "${lang}" translation missing "title"`
|
|
36
|
+
);
|
|
37
|
+
}
|
|
38
|
+
if (!t.description) {
|
|
39
|
+
throw new Error(
|
|
40
|
+
`GuideAgent: Step ${index + 1} "${lang}" translation missing "description"`
|
|
41
|
+
);
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
});
|
|
45
|
+
console.log(
|
|
46
|
+
`GuideAgent: Config loaded \u2705 \u2014 ${config.steps.length} steps for page "${config.page}"`
|
|
47
|
+
);
|
|
48
|
+
return config;
|
|
49
|
+
} catch (error) {
|
|
50
|
+
console.error("GuideAgent config load failed:", error);
|
|
51
|
+
throw error;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
export {
|
|
55
|
+
loadConfig
|
|
56
|
+
};
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
// src/config/loader.ts
|
|
2
|
+
async function loadConfig(configUrl) {
|
|
3
|
+
try {
|
|
4
|
+
const response = await fetch(configUrl);
|
|
5
|
+
if (!response.ok) {
|
|
6
|
+
throw new Error(
|
|
7
|
+
`GuideAgent: Failed to load config from "${configUrl}" \u2014 HTTP ${response.status}`
|
|
8
|
+
);
|
|
9
|
+
}
|
|
10
|
+
const config = await response.json();
|
|
11
|
+
if (!config.steps || !Array.isArray(config.steps)) {
|
|
12
|
+
throw new Error(
|
|
13
|
+
`GuideAgent: Invalid config \u2014 "steps" array missing in "${configUrl}"`
|
|
14
|
+
);
|
|
15
|
+
}
|
|
16
|
+
config.steps.forEach((step, index) => {
|
|
17
|
+
if (!step.selector) {
|
|
18
|
+
throw new Error(`GuideAgent: Step ${index + 1} missing "selector" field`);
|
|
19
|
+
}
|
|
20
|
+
if (!step.title) {
|
|
21
|
+
throw new Error(`GuideAgent: Step ${index + 1} missing "title" field`);
|
|
22
|
+
}
|
|
23
|
+
if (!step.description) {
|
|
24
|
+
throw new Error(`GuideAgent: Step ${index + 1} missing "description" field`);
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
console.log(
|
|
28
|
+
`GuideAgent: Config loaded \u2705 \u2014 ${config.steps.length} steps for page "${config.page}"`
|
|
29
|
+
);
|
|
30
|
+
return config;
|
|
31
|
+
} catch (error) {
|
|
32
|
+
console.error("GuideAgent config load failed:", error);
|
|
33
|
+
throw error;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
export {
|
|
37
|
+
loadConfig
|
|
38
|
+
};
|
package/licence
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Raghul
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/package.json
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "guideagent",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Contextual in-app guidance SDK for web apps — multilingual, config-driven, developer-first",
|
|
5
|
+
"main": "./dist/index.js",
|
|
6
|
+
"module": "./dist/index.mjs",
|
|
7
|
+
"types": "./dist/index.d.ts",
|
|
8
|
+
"files": [
|
|
9
|
+
"dist"
|
|
10
|
+
],
|
|
11
|
+
"scripts": {
|
|
12
|
+
"build": "tsup src/index.ts --format cjs,esm --dts",
|
|
13
|
+
"dev": "tsup src/index.ts --format cjs,esm --dts --watch"
|
|
14
|
+
},
|
|
15
|
+
"keywords": [
|
|
16
|
+
"onboarding",
|
|
17
|
+
"guide",
|
|
18
|
+
"tooltip",
|
|
19
|
+
"sdk",
|
|
20
|
+
"walkthrough",
|
|
21
|
+
"multilingual",
|
|
22
|
+
"react",
|
|
23
|
+
"flutter"
|
|
24
|
+
],
|
|
25
|
+
"author": "Raghul <your@email.com>",
|
|
26
|
+
"license": "MIT",
|
|
27
|
+
"repository": {
|
|
28
|
+
"type": "git",
|
|
29
|
+
"url": "https://github.com/YOUR_USERNAME/guideagent"
|
|
30
|
+
},
|
|
31
|
+
"devDependencies": {
|
|
32
|
+
"tsup": "^8.0.0",
|
|
33
|
+
"typescript": "^5.0.0"
|
|
34
|
+
}
|
|
35
|
+
}
|