@useago/sdk 0.3.0 → 0.3.2
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 +2 -0
- package/dist/AgoClient-DPZdN5n2.js +905 -0
- package/dist/AgoClient-DPZdN5n2.js.map +1 -0
- package/dist/AgoClient-wMVUQqCD.cjs +976 -0
- package/dist/AgoClient-wMVUQqCD.cjs.map +1 -0
- package/dist/angular.cjs +138 -100
- package/dist/angular.cjs.map +1 -1
- package/dist/angular.d.ts +1 -0
- package/dist/angular.js +139 -103
- package/dist/angular.js.map +1 -1
- package/dist/client/AgoClient.d.ts +56 -0
- package/dist/client/types.d.ts +5 -1
- package/dist/createMockClient-Ci_N2tH8.cjs +104 -0
- package/dist/createMockClient-Ci_N2tH8.cjs.map +1 -0
- package/dist/createMockClient-U0ae_AYy.js +99 -0
- package/dist/createMockClient-U0ae_AYy.js.map +1 -0
- package/dist/devtools/index.d.ts +2 -0
- package/dist/devtools/initDevPanel.d.ts +15 -0
- package/dist/devtools.cjs +182 -0
- package/dist/devtools.cjs.map +1 -0
- package/dist/devtools.d.ts +2 -0
- package/dist/devtools.js +181 -0
- package/dist/devtools.js.map +1 -0
- package/dist/functions--c6lx3ic.cjs +480 -0
- package/dist/functions--c6lx3ic.cjs.map +1 -0
- package/dist/functions-C9F1dnmh.js +398 -0
- package/dist/functions-C9F1dnmh.js.map +1 -0
- package/dist/helpers/factory.d.ts +20 -0
- package/dist/helpers.cjs +14 -305
- package/dist/helpers.d.ts +1 -0
- package/dist/helpers.js +2 -306
- package/dist/index.cjs +316 -151
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +14 -9
- package/dist/index.js +289 -163
- package/dist/index.js.map +1 -1
- package/dist/react/components/ChatWidget.d.ts +2 -0
- package/dist/react/components/Markdown.d.ts +12 -0
- package/dist/react/components/Message.d.ts +2 -0
- package/dist/react/components/index.d.ts +2 -0
- package/dist/react/context/AgoContext.d.ts +29 -3
- package/dist/react/context/index.d.ts +1 -1
- package/dist/react/hooks/index.d.ts +1 -0
- package/dist/react/hooks/useAgoContext.d.ts +40 -0
- package/dist/react/hooks/useAgoFunction.d.ts +14 -2
- package/dist/react/hooks/useAgoStore.d.ts +17 -0
- package/dist/react/index.d.ts +5 -1
- package/dist/react.cjs +22130 -10274
- package/dist/react.cjs.map +1 -1
- package/dist/react.d.ts +1 -0
- package/dist/react.js +22128 -10289
- package/dist/react.js.map +1 -1
- package/dist/rolldown-runtime-BqCkTl7Q.cjs +50 -0
- package/dist/rolldown-runtime-CNZpIYwj.js +33 -0
- package/dist/state/ClientContextRegistry.d.ts +64 -0
- package/dist/state/createStore.d.ts +30 -0
- package/dist/vue/composables/useAgoStore.d.ts +18 -0
- package/dist/vue/index.d.ts +1 -0
- package/dist/vue.cjs +312 -208
- package/dist/vue.cjs.map +1 -1
- package/dist/vue.d.ts +1 -0
- package/dist/vue.js +311 -218
- package/dist/vue.js.map +1 -1
- package/dist/widget/types.d.ts +1 -0
- package/dist/widget.cjs +0 -2
- package/dist/widget.d.ts +1 -0
- package/dist/widget.js +0 -2
- package/package.json +6 -1
- package/dist/AgoClient-B-SONi_K.js +0 -861
- package/dist/AgoClient-B-SONi_K.js.map +0 -1
- package/dist/AgoClient-xTWfMWKh.cjs +0 -860
- package/dist/AgoClient-xTWfMWKh.cjs.map +0 -1
- package/dist/createMockClient-B1DcBiIK.js +0 -94
- package/dist/createMockClient-B1DcBiIK.js.map +0 -1
- package/dist/createMockClient-BqNSJUu4.cjs +0 -93
- package/dist/createMockClient-BqNSJUu4.cjs.map +0 -1
- package/dist/helpers.cjs.map +0 -1
- package/dist/helpers.js.map +0 -1
- package/dist/widget.cjs.map +0 -1
- package/dist/widget.js.map +0 -1
package/dist/helpers.cjs
CHANGED
|
@@ -1,306 +1,15 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
const
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
description: "Duration in milliseconds (default 3000)"
|
|
18
|
-
}
|
|
19
|
-
},
|
|
20
|
-
required: ["message"]
|
|
21
|
-
},
|
|
22
|
-
handler: async () => ({ shown: false, error: "No toast handler configured" })
|
|
23
|
-
};
|
|
24
|
-
const showNotification = {
|
|
25
|
-
name: "showNotification",
|
|
26
|
-
description: "Show a browser notification to the user. Useful for important alerts even when the tab is not focused.",
|
|
27
|
-
parameters: {
|
|
28
|
-
type: "object",
|
|
29
|
-
properties: {
|
|
30
|
-
title: { type: "string", description: "Notification title" },
|
|
31
|
-
body: { type: "string", description: "Notification body text" }
|
|
32
|
-
},
|
|
33
|
-
required: ["title"]
|
|
34
|
-
},
|
|
35
|
-
handler: async (args) => {
|
|
36
|
-
if (typeof Notification === "undefined") {
|
|
37
|
-
return { shown: false, error: "Notifications not supported" };
|
|
38
|
-
}
|
|
39
|
-
if (Notification.permission === "denied") {
|
|
40
|
-
return { shown: false, error: "Notification permission denied" };
|
|
41
|
-
}
|
|
42
|
-
if (Notification.permission !== "granted") {
|
|
43
|
-
await Notification.requestPermission();
|
|
44
|
-
}
|
|
45
|
-
if (Notification.permission === "granted") {
|
|
46
|
-
new Notification(args.title, { body: args.body });
|
|
47
|
-
return { shown: true };
|
|
48
|
-
}
|
|
49
|
-
return { shown: false, error: "Permission not granted" };
|
|
50
|
-
}
|
|
51
|
-
};
|
|
52
|
-
const openUrl = {
|
|
53
|
-
name: "openUrl",
|
|
54
|
-
description: "Open a URL in a new browser tab.",
|
|
55
|
-
parameters: {
|
|
56
|
-
type: "object",
|
|
57
|
-
properties: {
|
|
58
|
-
url: { type: "string", description: "The URL to open" }
|
|
59
|
-
},
|
|
60
|
-
required: ["url"]
|
|
61
|
-
},
|
|
62
|
-
handler: async (args) => {
|
|
63
|
-
window.open(args.url, "_blank", "noopener,noreferrer");
|
|
64
|
-
return { opened: true };
|
|
65
|
-
}
|
|
66
|
-
};
|
|
67
|
-
const copyToClipboard = {
|
|
68
|
-
name: "copyToClipboard",
|
|
69
|
-
description: "Copy text to the user's clipboard.",
|
|
70
|
-
parameters: {
|
|
71
|
-
type: "object",
|
|
72
|
-
properties: {
|
|
73
|
-
text: { type: "string", description: "The text to copy" }
|
|
74
|
-
},
|
|
75
|
-
required: ["text"]
|
|
76
|
-
},
|
|
77
|
-
handler: async (args) => {
|
|
78
|
-
await navigator.clipboard.writeText(args.text);
|
|
79
|
-
return { copied: true };
|
|
80
|
-
}
|
|
81
|
-
};
|
|
82
|
-
const setTheme = {
|
|
83
|
-
name: "setTheme",
|
|
84
|
-
description: "Change the application's color theme. Sets a data-theme attribute on the document element.",
|
|
85
|
-
parameters: {
|
|
86
|
-
type: "object",
|
|
87
|
-
properties: {
|
|
88
|
-
theme: {
|
|
89
|
-
type: "string",
|
|
90
|
-
description: "Theme to apply",
|
|
91
|
-
enum: ["light", "dark", "system"]
|
|
92
|
-
}
|
|
93
|
-
},
|
|
94
|
-
required: ["theme"]
|
|
95
|
-
},
|
|
96
|
-
handler: async (args) => {
|
|
97
|
-
const theme = args.theme;
|
|
98
|
-
document.documentElement.setAttribute("data-theme", theme);
|
|
99
|
-
if (theme === "dark") {
|
|
100
|
-
document.documentElement.classList.add("dark");
|
|
101
|
-
} else {
|
|
102
|
-
document.documentElement.classList.remove("dark");
|
|
103
|
-
}
|
|
104
|
-
return { theme, applied: true };
|
|
105
|
-
}
|
|
106
|
-
};
|
|
107
|
-
const showConfirmDialog = {
|
|
108
|
-
name: "showConfirmDialog",
|
|
109
|
-
description: "Show a confirmation dialog to the user and return their choice (true/false).",
|
|
110
|
-
parameters: {
|
|
111
|
-
type: "object",
|
|
112
|
-
properties: {
|
|
113
|
-
message: {
|
|
114
|
-
type: "string",
|
|
115
|
-
description: "The confirmation message to display"
|
|
116
|
-
}
|
|
117
|
-
},
|
|
118
|
-
required: ["message"]
|
|
119
|
-
},
|
|
120
|
-
handler: async (args) => {
|
|
121
|
-
const confirmed = window.confirm(args.message);
|
|
122
|
-
return { confirmed };
|
|
123
|
-
}
|
|
124
|
-
};
|
|
125
|
-
const getUserLocation = {
|
|
126
|
-
name: "getUserLocation",
|
|
127
|
-
description: "Get the user's current geographic location (requires permission).",
|
|
128
|
-
parameters: {
|
|
129
|
-
type: "object",
|
|
130
|
-
properties: {}
|
|
131
|
-
},
|
|
132
|
-
handler: async () => {
|
|
133
|
-
if (!navigator.geolocation) {
|
|
134
|
-
return { error: "Geolocation not supported" };
|
|
135
|
-
}
|
|
136
|
-
return new Promise((resolve) => {
|
|
137
|
-
navigator.geolocation.getCurrentPosition(
|
|
138
|
-
(pos) => resolve({
|
|
139
|
-
latitude: pos.coords.latitude,
|
|
140
|
-
longitude: pos.coords.longitude,
|
|
141
|
-
accuracy: pos.coords.accuracy
|
|
142
|
-
}),
|
|
143
|
-
(err) => resolve({ error: err.message })
|
|
144
|
-
);
|
|
145
|
-
});
|
|
146
|
-
}
|
|
147
|
-
};
|
|
148
|
-
const scrollToElement = {
|
|
149
|
-
name: "scrollToElement",
|
|
150
|
-
description: "Scroll the page to a specific element identified by CSS selector.",
|
|
151
|
-
parameters: {
|
|
152
|
-
type: "object",
|
|
153
|
-
properties: {
|
|
154
|
-
selector: {
|
|
155
|
-
type: "string",
|
|
156
|
-
description: "CSS selector of the element to scroll to (e.g. '#section-pricing')"
|
|
157
|
-
},
|
|
158
|
-
behavior: {
|
|
159
|
-
type: "string",
|
|
160
|
-
description: "Scroll behavior",
|
|
161
|
-
enum: ["smooth", "instant"]
|
|
162
|
-
}
|
|
163
|
-
},
|
|
164
|
-
required: ["selector"]
|
|
165
|
-
},
|
|
166
|
-
handler: async (args) => {
|
|
167
|
-
const el = document.querySelector(args.selector);
|
|
168
|
-
if (!el) {
|
|
169
|
-
return { scrolled: false, error: `Element not found: ${args.selector}` };
|
|
170
|
-
}
|
|
171
|
-
el.scrollIntoView({ behavior: args.behavior || "smooth" });
|
|
172
|
-
return { scrolled: true };
|
|
173
|
-
}
|
|
174
|
-
};
|
|
175
|
-
const setLocalStorage = {
|
|
176
|
-
name: "setLocalStorage",
|
|
177
|
-
description: "Store a value in the browser's localStorage.",
|
|
178
|
-
parameters: {
|
|
179
|
-
type: "object",
|
|
180
|
-
properties: {
|
|
181
|
-
key: { type: "string", description: "Storage key" },
|
|
182
|
-
value: { type: "string", description: "Value to store" }
|
|
183
|
-
},
|
|
184
|
-
required: ["key", "value"]
|
|
185
|
-
},
|
|
186
|
-
handler: async (args) => {
|
|
187
|
-
localStorage.setItem(args.key, args.value);
|
|
188
|
-
return { stored: true };
|
|
189
|
-
}
|
|
190
|
-
};
|
|
191
|
-
const getLocalStorage = {
|
|
192
|
-
name: "getLocalStorage",
|
|
193
|
-
description: "Retrieve a value from the browser's localStorage.",
|
|
194
|
-
parameters: {
|
|
195
|
-
type: "object",
|
|
196
|
-
properties: {
|
|
197
|
-
key: { type: "string", description: "Storage key" }
|
|
198
|
-
},
|
|
199
|
-
required: ["key"]
|
|
200
|
-
},
|
|
201
|
-
handler: async (args) => {
|
|
202
|
-
const value = localStorage.getItem(args.key);
|
|
203
|
-
return { key: args.key, value, found: value !== null };
|
|
204
|
-
}
|
|
205
|
-
};
|
|
206
|
-
const highlightElement = {
|
|
207
|
-
name: "highlightElement",
|
|
208
|
-
description: "Highlight a DOM element to draw the user's attention (e.g. for onboarding).",
|
|
209
|
-
parameters: {
|
|
210
|
-
type: "object",
|
|
211
|
-
properties: {
|
|
212
|
-
selector: {
|
|
213
|
-
type: "string",
|
|
214
|
-
description: "CSS selector of the element to highlight"
|
|
215
|
-
},
|
|
216
|
-
color: {
|
|
217
|
-
type: "string",
|
|
218
|
-
description: "Highlight border color (default: #3b82f6)"
|
|
219
|
-
}
|
|
220
|
-
},
|
|
221
|
-
required: ["selector"]
|
|
222
|
-
},
|
|
223
|
-
handler: async (args) => {
|
|
224
|
-
const el = document.querySelector(args.selector);
|
|
225
|
-
if (!el) {
|
|
226
|
-
return { highlighted: false, error: `Element not found: ${args.selector}` };
|
|
227
|
-
}
|
|
228
|
-
const prev = el.style.outline;
|
|
229
|
-
const color = args.color || "#3b82f6";
|
|
230
|
-
el.style.outline = `3px solid ${color}`;
|
|
231
|
-
el.style.outlineOffset = "2px";
|
|
232
|
-
el.scrollIntoView({ behavior: "smooth", block: "center" });
|
|
233
|
-
setTimeout(() => {
|
|
234
|
-
el.style.outline = prev;
|
|
235
|
-
el.style.outlineOffset = "";
|
|
236
|
-
}, 3e3);
|
|
237
|
-
return { highlighted: true };
|
|
238
|
-
}
|
|
239
|
-
};
|
|
240
|
-
const submitForm = {
|
|
241
|
-
name: "submitForm",
|
|
242
|
-
description: "Fill and submit an HTML form on the page. Pass field values as key-value pairs.",
|
|
243
|
-
parameters: {
|
|
244
|
-
type: "object",
|
|
245
|
-
properties: {
|
|
246
|
-
selector: {
|
|
247
|
-
type: "string",
|
|
248
|
-
description: "CSS selector of the form element"
|
|
249
|
-
},
|
|
250
|
-
values: {
|
|
251
|
-
type: "string",
|
|
252
|
-
description: "JSON string of field name → value pairs"
|
|
253
|
-
}
|
|
254
|
-
},
|
|
255
|
-
required: ["selector"]
|
|
256
|
-
},
|
|
257
|
-
handler: async (args) => {
|
|
258
|
-
const form = document.querySelector(args.selector);
|
|
259
|
-
if (!form) {
|
|
260
|
-
return { submitted: false, error: `Form not found: ${args.selector}` };
|
|
261
|
-
}
|
|
262
|
-
if (args.values) {
|
|
263
|
-
const values = JSON.parse(args.values);
|
|
264
|
-
for (const [name, value] of Object.entries(values)) {
|
|
265
|
-
const input = form.elements.namedItem(name);
|
|
266
|
-
if (input) input.value = value;
|
|
267
|
-
}
|
|
268
|
-
}
|
|
269
|
-
form.requestSubmit();
|
|
270
|
-
return { submitted: true };
|
|
271
|
-
}
|
|
272
|
-
};
|
|
273
|
-
const trackEvent = {
|
|
274
|
-
name: "trackEvent",
|
|
275
|
-
description: "Track a custom analytics event. Override the handler to wire up your analytics provider.",
|
|
276
|
-
parameters: {
|
|
277
|
-
type: "object",
|
|
278
|
-
properties: {
|
|
279
|
-
event: { type: "string", description: "Event name" },
|
|
280
|
-
properties: {
|
|
281
|
-
type: "string",
|
|
282
|
-
description: "JSON string of event properties"
|
|
283
|
-
}
|
|
284
|
-
},
|
|
285
|
-
required: ["event"]
|
|
286
|
-
},
|
|
287
|
-
handler: async (args) => {
|
|
288
|
-
const props = args.properties ? JSON.parse(args.properties) : {};
|
|
289
|
-
console.log(`[AGO Analytics] ${args.event}`, props);
|
|
290
|
-
return { tracked: true, event: args.event };
|
|
291
|
-
}
|
|
292
|
-
};
|
|
293
|
-
exports.copyToClipboard = copyToClipboard;
|
|
294
|
-
exports.getLocalStorage = getLocalStorage;
|
|
295
|
-
exports.getUserLocation = getUserLocation;
|
|
296
|
-
exports.highlightElement = highlightElement;
|
|
297
|
-
exports.openUrl = openUrl;
|
|
298
|
-
exports.scrollToElement = scrollToElement;
|
|
299
|
-
exports.setLocalStorage = setLocalStorage;
|
|
300
|
-
exports.setTheme = setTheme;
|
|
301
|
-
exports.showConfirmDialog = showConfirmDialog;
|
|
302
|
-
exports.showNotification = showNotification;
|
|
303
|
-
exports.showToast = showToast;
|
|
304
|
-
exports.submitForm = submitForm;
|
|
305
|
-
exports.trackEvent = trackEvent;
|
|
306
|
-
//# sourceMappingURL=helpers.cjs.map
|
|
2
|
+
const require_functions = require("./functions--c6lx3ic.cjs");
|
|
3
|
+
exports.copyToClipboard = require_functions.copyToClipboard;
|
|
4
|
+
exports.getLocalStorage = require_functions.getLocalStorage;
|
|
5
|
+
exports.getUserLocation = require_functions.getUserLocation;
|
|
6
|
+
exports.highlightElement = require_functions.highlightElement;
|
|
7
|
+
exports.openUrl = require_functions.openUrl;
|
|
8
|
+
exports.scrollToElement = require_functions.scrollToElement;
|
|
9
|
+
exports.setLocalStorage = require_functions.setLocalStorage;
|
|
10
|
+
exports.setTheme = require_functions.setTheme;
|
|
11
|
+
exports.showConfirmDialog = require_functions.showConfirmDialog;
|
|
12
|
+
exports.showNotification = require_functions.showNotification;
|
|
13
|
+
exports.showToast = require_functions.showToast;
|
|
14
|
+
exports.submitForm = require_functions.submitForm;
|
|
15
|
+
exports.trackEvent = require_functions.trackEvent;
|
package/dist/helpers.d.ts
CHANGED
package/dist/helpers.js
CHANGED
|
@@ -1,306 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
description: "Show a toast notification to the user. Use this to confirm actions or display brief messages.",
|
|
4
|
-
parameters: {
|
|
5
|
-
type: "object",
|
|
6
|
-
properties: {
|
|
7
|
-
message: { type: "string", description: "The message to display" },
|
|
8
|
-
type: {
|
|
9
|
-
type: "string",
|
|
10
|
-
description: "Toast type",
|
|
11
|
-
enum: ["success", "error", "warning", "info"]
|
|
12
|
-
},
|
|
13
|
-
duration: {
|
|
14
|
-
type: "number",
|
|
15
|
-
description: "Duration in milliseconds (default 3000)"
|
|
16
|
-
}
|
|
17
|
-
},
|
|
18
|
-
required: ["message"]
|
|
19
|
-
},
|
|
20
|
-
handler: async () => ({ shown: false, error: "No toast handler configured" })
|
|
21
|
-
};
|
|
22
|
-
const showNotification = {
|
|
23
|
-
name: "showNotification",
|
|
24
|
-
description: "Show a browser notification to the user. Useful for important alerts even when the tab is not focused.",
|
|
25
|
-
parameters: {
|
|
26
|
-
type: "object",
|
|
27
|
-
properties: {
|
|
28
|
-
title: { type: "string", description: "Notification title" },
|
|
29
|
-
body: { type: "string", description: "Notification body text" }
|
|
30
|
-
},
|
|
31
|
-
required: ["title"]
|
|
32
|
-
},
|
|
33
|
-
handler: async (args) => {
|
|
34
|
-
if (typeof Notification === "undefined") {
|
|
35
|
-
return { shown: false, error: "Notifications not supported" };
|
|
36
|
-
}
|
|
37
|
-
if (Notification.permission === "denied") {
|
|
38
|
-
return { shown: false, error: "Notification permission denied" };
|
|
39
|
-
}
|
|
40
|
-
if (Notification.permission !== "granted") {
|
|
41
|
-
await Notification.requestPermission();
|
|
42
|
-
}
|
|
43
|
-
if (Notification.permission === "granted") {
|
|
44
|
-
new Notification(args.title, { body: args.body });
|
|
45
|
-
return { shown: true };
|
|
46
|
-
}
|
|
47
|
-
return { shown: false, error: "Permission not granted" };
|
|
48
|
-
}
|
|
49
|
-
};
|
|
50
|
-
const openUrl = {
|
|
51
|
-
name: "openUrl",
|
|
52
|
-
description: "Open a URL in a new browser tab.",
|
|
53
|
-
parameters: {
|
|
54
|
-
type: "object",
|
|
55
|
-
properties: {
|
|
56
|
-
url: { type: "string", description: "The URL to open" }
|
|
57
|
-
},
|
|
58
|
-
required: ["url"]
|
|
59
|
-
},
|
|
60
|
-
handler: async (args) => {
|
|
61
|
-
window.open(args.url, "_blank", "noopener,noreferrer");
|
|
62
|
-
return { opened: true };
|
|
63
|
-
}
|
|
64
|
-
};
|
|
65
|
-
const copyToClipboard = {
|
|
66
|
-
name: "copyToClipboard",
|
|
67
|
-
description: "Copy text to the user's clipboard.",
|
|
68
|
-
parameters: {
|
|
69
|
-
type: "object",
|
|
70
|
-
properties: {
|
|
71
|
-
text: { type: "string", description: "The text to copy" }
|
|
72
|
-
},
|
|
73
|
-
required: ["text"]
|
|
74
|
-
},
|
|
75
|
-
handler: async (args) => {
|
|
76
|
-
await navigator.clipboard.writeText(args.text);
|
|
77
|
-
return { copied: true };
|
|
78
|
-
}
|
|
79
|
-
};
|
|
80
|
-
const setTheme = {
|
|
81
|
-
name: "setTheme",
|
|
82
|
-
description: "Change the application's color theme. Sets a data-theme attribute on the document element.",
|
|
83
|
-
parameters: {
|
|
84
|
-
type: "object",
|
|
85
|
-
properties: {
|
|
86
|
-
theme: {
|
|
87
|
-
type: "string",
|
|
88
|
-
description: "Theme to apply",
|
|
89
|
-
enum: ["light", "dark", "system"]
|
|
90
|
-
}
|
|
91
|
-
},
|
|
92
|
-
required: ["theme"]
|
|
93
|
-
},
|
|
94
|
-
handler: async (args) => {
|
|
95
|
-
const theme = args.theme;
|
|
96
|
-
document.documentElement.setAttribute("data-theme", theme);
|
|
97
|
-
if (theme === "dark") {
|
|
98
|
-
document.documentElement.classList.add("dark");
|
|
99
|
-
} else {
|
|
100
|
-
document.documentElement.classList.remove("dark");
|
|
101
|
-
}
|
|
102
|
-
return { theme, applied: true };
|
|
103
|
-
}
|
|
104
|
-
};
|
|
105
|
-
const showConfirmDialog = {
|
|
106
|
-
name: "showConfirmDialog",
|
|
107
|
-
description: "Show a confirmation dialog to the user and return their choice (true/false).",
|
|
108
|
-
parameters: {
|
|
109
|
-
type: "object",
|
|
110
|
-
properties: {
|
|
111
|
-
message: {
|
|
112
|
-
type: "string",
|
|
113
|
-
description: "The confirmation message to display"
|
|
114
|
-
}
|
|
115
|
-
},
|
|
116
|
-
required: ["message"]
|
|
117
|
-
},
|
|
118
|
-
handler: async (args) => {
|
|
119
|
-
const confirmed = window.confirm(args.message);
|
|
120
|
-
return { confirmed };
|
|
121
|
-
}
|
|
122
|
-
};
|
|
123
|
-
const getUserLocation = {
|
|
124
|
-
name: "getUserLocation",
|
|
125
|
-
description: "Get the user's current geographic location (requires permission).",
|
|
126
|
-
parameters: {
|
|
127
|
-
type: "object",
|
|
128
|
-
properties: {}
|
|
129
|
-
},
|
|
130
|
-
handler: async () => {
|
|
131
|
-
if (!navigator.geolocation) {
|
|
132
|
-
return { error: "Geolocation not supported" };
|
|
133
|
-
}
|
|
134
|
-
return new Promise((resolve) => {
|
|
135
|
-
navigator.geolocation.getCurrentPosition(
|
|
136
|
-
(pos) => resolve({
|
|
137
|
-
latitude: pos.coords.latitude,
|
|
138
|
-
longitude: pos.coords.longitude,
|
|
139
|
-
accuracy: pos.coords.accuracy
|
|
140
|
-
}),
|
|
141
|
-
(err) => resolve({ error: err.message })
|
|
142
|
-
);
|
|
143
|
-
});
|
|
144
|
-
}
|
|
145
|
-
};
|
|
146
|
-
const scrollToElement = {
|
|
147
|
-
name: "scrollToElement",
|
|
148
|
-
description: "Scroll the page to a specific element identified by CSS selector.",
|
|
149
|
-
parameters: {
|
|
150
|
-
type: "object",
|
|
151
|
-
properties: {
|
|
152
|
-
selector: {
|
|
153
|
-
type: "string",
|
|
154
|
-
description: "CSS selector of the element to scroll to (e.g. '#section-pricing')"
|
|
155
|
-
},
|
|
156
|
-
behavior: {
|
|
157
|
-
type: "string",
|
|
158
|
-
description: "Scroll behavior",
|
|
159
|
-
enum: ["smooth", "instant"]
|
|
160
|
-
}
|
|
161
|
-
},
|
|
162
|
-
required: ["selector"]
|
|
163
|
-
},
|
|
164
|
-
handler: async (args) => {
|
|
165
|
-
const el = document.querySelector(args.selector);
|
|
166
|
-
if (!el) {
|
|
167
|
-
return { scrolled: false, error: `Element not found: ${args.selector}` };
|
|
168
|
-
}
|
|
169
|
-
el.scrollIntoView({ behavior: args.behavior || "smooth" });
|
|
170
|
-
return { scrolled: true };
|
|
171
|
-
}
|
|
172
|
-
};
|
|
173
|
-
const setLocalStorage = {
|
|
174
|
-
name: "setLocalStorage",
|
|
175
|
-
description: "Store a value in the browser's localStorage.",
|
|
176
|
-
parameters: {
|
|
177
|
-
type: "object",
|
|
178
|
-
properties: {
|
|
179
|
-
key: { type: "string", description: "Storage key" },
|
|
180
|
-
value: { type: "string", description: "Value to store" }
|
|
181
|
-
},
|
|
182
|
-
required: ["key", "value"]
|
|
183
|
-
},
|
|
184
|
-
handler: async (args) => {
|
|
185
|
-
localStorage.setItem(args.key, args.value);
|
|
186
|
-
return { stored: true };
|
|
187
|
-
}
|
|
188
|
-
};
|
|
189
|
-
const getLocalStorage = {
|
|
190
|
-
name: "getLocalStorage",
|
|
191
|
-
description: "Retrieve a value from the browser's localStorage.",
|
|
192
|
-
parameters: {
|
|
193
|
-
type: "object",
|
|
194
|
-
properties: {
|
|
195
|
-
key: { type: "string", description: "Storage key" }
|
|
196
|
-
},
|
|
197
|
-
required: ["key"]
|
|
198
|
-
},
|
|
199
|
-
handler: async (args) => {
|
|
200
|
-
const value = localStorage.getItem(args.key);
|
|
201
|
-
return { key: args.key, value, found: value !== null };
|
|
202
|
-
}
|
|
203
|
-
};
|
|
204
|
-
const highlightElement = {
|
|
205
|
-
name: "highlightElement",
|
|
206
|
-
description: "Highlight a DOM element to draw the user's attention (e.g. for onboarding).",
|
|
207
|
-
parameters: {
|
|
208
|
-
type: "object",
|
|
209
|
-
properties: {
|
|
210
|
-
selector: {
|
|
211
|
-
type: "string",
|
|
212
|
-
description: "CSS selector of the element to highlight"
|
|
213
|
-
},
|
|
214
|
-
color: {
|
|
215
|
-
type: "string",
|
|
216
|
-
description: "Highlight border color (default: #3b82f6)"
|
|
217
|
-
}
|
|
218
|
-
},
|
|
219
|
-
required: ["selector"]
|
|
220
|
-
},
|
|
221
|
-
handler: async (args) => {
|
|
222
|
-
const el = document.querySelector(args.selector);
|
|
223
|
-
if (!el) {
|
|
224
|
-
return { highlighted: false, error: `Element not found: ${args.selector}` };
|
|
225
|
-
}
|
|
226
|
-
const prev = el.style.outline;
|
|
227
|
-
const color = args.color || "#3b82f6";
|
|
228
|
-
el.style.outline = `3px solid ${color}`;
|
|
229
|
-
el.style.outlineOffset = "2px";
|
|
230
|
-
el.scrollIntoView({ behavior: "smooth", block: "center" });
|
|
231
|
-
setTimeout(() => {
|
|
232
|
-
el.style.outline = prev;
|
|
233
|
-
el.style.outlineOffset = "";
|
|
234
|
-
}, 3e3);
|
|
235
|
-
return { highlighted: true };
|
|
236
|
-
}
|
|
237
|
-
};
|
|
238
|
-
const submitForm = {
|
|
239
|
-
name: "submitForm",
|
|
240
|
-
description: "Fill and submit an HTML form on the page. Pass field values as key-value pairs.",
|
|
241
|
-
parameters: {
|
|
242
|
-
type: "object",
|
|
243
|
-
properties: {
|
|
244
|
-
selector: {
|
|
245
|
-
type: "string",
|
|
246
|
-
description: "CSS selector of the form element"
|
|
247
|
-
},
|
|
248
|
-
values: {
|
|
249
|
-
type: "string",
|
|
250
|
-
description: "JSON string of field name → value pairs"
|
|
251
|
-
}
|
|
252
|
-
},
|
|
253
|
-
required: ["selector"]
|
|
254
|
-
},
|
|
255
|
-
handler: async (args) => {
|
|
256
|
-
const form = document.querySelector(args.selector);
|
|
257
|
-
if (!form) {
|
|
258
|
-
return { submitted: false, error: `Form not found: ${args.selector}` };
|
|
259
|
-
}
|
|
260
|
-
if (args.values) {
|
|
261
|
-
const values = JSON.parse(args.values);
|
|
262
|
-
for (const [name, value] of Object.entries(values)) {
|
|
263
|
-
const input = form.elements.namedItem(name);
|
|
264
|
-
if (input) input.value = value;
|
|
265
|
-
}
|
|
266
|
-
}
|
|
267
|
-
form.requestSubmit();
|
|
268
|
-
return { submitted: true };
|
|
269
|
-
}
|
|
270
|
-
};
|
|
271
|
-
const trackEvent = {
|
|
272
|
-
name: "trackEvent",
|
|
273
|
-
description: "Track a custom analytics event. Override the handler to wire up your analytics provider.",
|
|
274
|
-
parameters: {
|
|
275
|
-
type: "object",
|
|
276
|
-
properties: {
|
|
277
|
-
event: { type: "string", description: "Event name" },
|
|
278
|
-
properties: {
|
|
279
|
-
type: "string",
|
|
280
|
-
description: "JSON string of event properties"
|
|
281
|
-
}
|
|
282
|
-
},
|
|
283
|
-
required: ["event"]
|
|
284
|
-
},
|
|
285
|
-
handler: async (args) => {
|
|
286
|
-
const props = args.properties ? JSON.parse(args.properties) : {};
|
|
287
|
-
console.log(`[AGO Analytics] ${args.event}`, props);
|
|
288
|
-
return { tracked: true, event: args.event };
|
|
289
|
-
}
|
|
290
|
-
};
|
|
291
|
-
export {
|
|
292
|
-
copyToClipboard,
|
|
293
|
-
getLocalStorage,
|
|
294
|
-
getUserLocation,
|
|
295
|
-
highlightElement,
|
|
296
|
-
openUrl,
|
|
297
|
-
scrollToElement,
|
|
298
|
-
setLocalStorage,
|
|
299
|
-
setTheme,
|
|
300
|
-
showConfirmDialog,
|
|
301
|
-
showNotification,
|
|
302
|
-
showToast,
|
|
303
|
-
submitForm,
|
|
304
|
-
trackEvent
|
|
305
|
-
};
|
|
306
|
-
//# sourceMappingURL=helpers.js.map
|
|
1
|
+
import { a as highlightElement, c as setLocalStorage, d as showNotification, f as showToast, i as getUserLocation, l as setTheme, m as trackEvent, o as openUrl, p as submitForm, r as getLocalStorage, s as scrollToElement, t as copyToClipboard, u as showConfirmDialog } from "./functions-C9F1dnmh.js";
|
|
2
|
+
export { copyToClipboard, getLocalStorage, getUserLocation, highlightElement, openUrl, scrollToElement, setLocalStorage, setTheme, showConfirmDialog, showNotification, showToast, submitForm, trackEvent };
|