veo-sdk 0.6.0 → 0.6.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/dist/builder-ENKEIVF2.mjs +5 -0
- package/dist/{builder-3QPHB2VJ.mjs.map → builder-ENKEIVF2.mjs.map} +1 -1
- package/dist/builder.cjs +366 -20
- package/dist/builder.cjs.map +1 -1
- package/dist/builder.d.cts +2 -2
- package/dist/builder.d.ts +2 -2
- package/dist/builder.mjs +4 -4
- package/dist/{chunk-N4VFMZFA.mjs → chunk-4QZDNJJE.mjs} +3 -3
- package/dist/{chunk-N4VFMZFA.mjs.map → chunk-4QZDNJJE.mjs.map} +1 -1
- package/dist/{chunk-GMXQMZ4X.mjs → chunk-L3QQJLDJ.mjs} +3 -3
- package/dist/{chunk-GMXQMZ4X.mjs.map → chunk-L3QQJLDJ.mjs.map} +1 -1
- package/dist/{chunk-O6USA4TU.mjs → chunk-ZILDR4YE.mjs} +368 -22
- package/dist/chunk-ZILDR4YE.mjs.map +1 -0
- package/dist/detect-theme-X4K3TLUL.mjs +446 -0
- package/dist/detect-theme-X4K3TLUL.mjs.map +1 -0
- package/dist/{guide-preview-DylsEhrg.d.cts → guide-preview-DEFhfA4o.d.cts} +115 -0
- package/dist/{guide-preview-DylsEhrg.d.ts → guide-preview-DEFhfA4o.d.ts} +115 -0
- package/dist/index.cjs +994 -51
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +13 -1
- package/dist/index.d.ts +13 -1
- package/dist/index.mjs +141 -16
- package/dist/index.mjs.map +1 -1
- package/dist/veo-builder.js +92 -20
- package/dist/veo-builder.js.map +1 -1
- package/dist/veo-guides.js +84 -12
- package/dist/veo-guides.js.map +1 -1
- package/dist/veo-theme.js +2 -0
- package/dist/veo-theme.js.map +1 -0
- package/dist/veo.js +2 -2
- package/dist/veo.js.map +1 -1
- package/package.json +2 -2
- package/dist/builder-3QPHB2VJ.mjs +0 -5
- package/dist/chunk-O6USA4TU.mjs.map +0 -1
package/dist/index.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { P as PreviewGuideInput, a as PreviewHandle, b as PreviewResult, c as closeGuidePreview, p as previewGuide } from './guide-preview-
|
|
1
|
+
export { P as PreviewGuideInput, a as PreviewHandle, b as PreviewResult, c as closeGuidePreview, p as previewGuide } from './guide-preview-DEFhfA4o.cjs';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Configuración de la autocaptura de interacciones del DOM.
|
|
@@ -49,6 +49,18 @@ interface VeoConfig {
|
|
|
49
49
|
* tooltips. Default: `false`.
|
|
50
50
|
*/
|
|
51
51
|
guides?: boolean;
|
|
52
|
+
/**
|
|
53
|
+
* Detectar el tema visual de la app (colores base en claro/oscuro y fuentes)
|
|
54
|
+
* para que el design system de OnUser arranque con la marca del cliente.
|
|
55
|
+
* Solo viajan colores y nombres de fuentes, como mucho una vez al día por
|
|
56
|
+
* navegador. Default: `true`; `false` lo deshabilita.
|
|
57
|
+
*/
|
|
58
|
+
detectTheme?: boolean;
|
|
59
|
+
/**
|
|
60
|
+
* URL del bundle del detector de tema (`veo-theme.js`). Solo aplica al build
|
|
61
|
+
* IIFE; si se omite, se deriva del `<script>` que cargó `veo.js`.
|
|
62
|
+
*/
|
|
63
|
+
themeUrl?: string;
|
|
52
64
|
/**
|
|
53
65
|
* URL del bundle del builder (`veo-builder.js`). Solo se carga cuando la
|
|
54
66
|
* página trae `?veoBuilder=<token>` (modo edición desde el dashboard). Si
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { P as PreviewGuideInput, a as PreviewHandle, b as PreviewResult, c as closeGuidePreview, p as previewGuide } from './guide-preview-
|
|
1
|
+
export { P as PreviewGuideInput, a as PreviewHandle, b as PreviewResult, c as closeGuidePreview, p as previewGuide } from './guide-preview-DEFhfA4o.js';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Configuración de la autocaptura de interacciones del DOM.
|
|
@@ -49,6 +49,18 @@ interface VeoConfig {
|
|
|
49
49
|
* tooltips. Default: `false`.
|
|
50
50
|
*/
|
|
51
51
|
guides?: boolean;
|
|
52
|
+
/**
|
|
53
|
+
* Detectar el tema visual de la app (colores base en claro/oscuro y fuentes)
|
|
54
|
+
* para que el design system de OnUser arranque con la marca del cliente.
|
|
55
|
+
* Solo viajan colores y nombres de fuentes, como mucho una vez al día por
|
|
56
|
+
* navegador. Default: `true`; `false` lo deshabilita.
|
|
57
|
+
*/
|
|
58
|
+
detectTheme?: boolean;
|
|
59
|
+
/**
|
|
60
|
+
* URL del bundle del detector de tema (`veo-theme.js`). Solo aplica al build
|
|
61
|
+
* IIFE; si se omite, se deriva del `<script>` que cargó `veo.js`.
|
|
62
|
+
*/
|
|
63
|
+
themeUrl?: string;
|
|
52
64
|
/**
|
|
53
65
|
* URL del bundle del builder (`veo-builder.js`). Solo se carga cuando la
|
|
54
66
|
* página trae `?veoBuilder=<token>` (modo edición desde el dashboard). Si
|
package/dist/index.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { definePlugin, guidesPlugin, runPreviewMode } from './chunk-
|
|
2
|
-
export { definePlugin, guidesPlugin } from './chunk-
|
|
3
|
-
import { hasWindow, hasDocument, uuidv7, DEFAULT_AUTOCAPTURE_CONFIG, MAX_ANCESTORS, hasLocalStorage, hasNavigatorSendBeacon, ALWAYS_BLOCK_SELECTORS, buildSelectorPath, resolveBuilderToken, filterHumanClasses, PRIORITY_ATTRIBUTES, SENSITIVE_ATTRIBUTES, getPreviewToken,
|
|
4
|
-
export { closeGuidePreview, previewGuide } from './chunk-
|
|
1
|
+
import { definePlugin, guidesPlugin, runPreviewMode } from './chunk-L3QQJLDJ.mjs';
|
|
2
|
+
export { definePlugin, guidesPlugin } from './chunk-L3QQJLDJ.mjs';
|
|
3
|
+
import { hasWindow, hasDocument, uuidv7, DEFAULT_AUTOCAPTURE_CONFIG, MAX_ANCESTORS, hasLocalStorage, hasNavigatorSendBeacon, isBuilderMode, ALWAYS_BLOCK_SELECTORS, buildSelectorPath, resolveBuilderToken, filterHumanClasses, PRIORITY_ATTRIBUTES, SENSITIVE_ATTRIBUTES, getPreviewToken, previewGuide, closeGuidePreview } from './chunk-ZILDR4YE.mjs';
|
|
4
|
+
export { closeGuidePreview, previewGuide } from './chunk-ZILDR4YE.mjs';
|
|
5
5
|
import './chunk-PTG3BTJE.mjs';
|
|
6
6
|
|
|
7
7
|
// src/contract/v1.ts
|
|
@@ -291,6 +291,118 @@ function spaRouterPlugin() {
|
|
|
291
291
|
});
|
|
292
292
|
}
|
|
293
293
|
|
|
294
|
+
// src/plugins/theme-detect/index.ts
|
|
295
|
+
var STORAGE_PREFIX = "veo_theme_";
|
|
296
|
+
var RESEND_AFTER_MS = 24 * 60 * 60 * 1e3;
|
|
297
|
+
var SETTLE_MS = 4e3;
|
|
298
|
+
var MAX_RUNS_PER_PAGE = 4;
|
|
299
|
+
function readState(key) {
|
|
300
|
+
try {
|
|
301
|
+
const raw = localStorage.getItem(key);
|
|
302
|
+
const parsed = raw ? JSON.parse(raw) : null;
|
|
303
|
+
return parsed && typeof parsed === "object" ? parsed : {};
|
|
304
|
+
} catch {
|
|
305
|
+
return {};
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
function writeState(key, state) {
|
|
309
|
+
try {
|
|
310
|
+
localStorage.setItem(key, JSON.stringify(state));
|
|
311
|
+
} catch {
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
function guessMode(doc, prefersDark) {
|
|
315
|
+
const hints = [
|
|
316
|
+
doc.documentElement.className,
|
|
317
|
+
doc.documentElement.dataset.theme,
|
|
318
|
+
doc.documentElement.dataset.mode,
|
|
319
|
+
doc.body?.className
|
|
320
|
+
].join(" ").toLowerCase();
|
|
321
|
+
if (/\bdark\b/.test(hints)) return "dark";
|
|
322
|
+
if (/\blight\b/.test(hints)) return "light";
|
|
323
|
+
return prefersDark ? "dark" : "light";
|
|
324
|
+
}
|
|
325
|
+
function isFresh(state, mode, now) {
|
|
326
|
+
const last = state[mode];
|
|
327
|
+
return last !== void 0 && now - last.at < RESEND_AFTER_MS;
|
|
328
|
+
}
|
|
329
|
+
function shouldSendSnapshot(state, mode, hash, now) {
|
|
330
|
+
const last = state[mode];
|
|
331
|
+
return !last || last.hash !== hash || now - last.at >= RESEND_AFTER_MS;
|
|
332
|
+
}
|
|
333
|
+
function themeDetectPlugin(config) {
|
|
334
|
+
const storageKey = `${STORAGE_PREFIX}${config.apiKey.slice(-16) || "default"}`;
|
|
335
|
+
let observer = null;
|
|
336
|
+
let timer = null;
|
|
337
|
+
let destroyed = false;
|
|
338
|
+
let runs = 0;
|
|
339
|
+
const run = async () => {
|
|
340
|
+
if (destroyed || runs >= MAX_RUNS_PER_PAGE) return;
|
|
341
|
+
const prefersDark = typeof window.matchMedia === "function" && window.matchMedia("(prefers-color-scheme: dark)").matches;
|
|
342
|
+
const guess = guessMode(document, prefersDark);
|
|
343
|
+
if (isFresh(readState(storageKey), guess, Date.now())) return;
|
|
344
|
+
runs++;
|
|
345
|
+
try {
|
|
346
|
+
const detector = await config.loadDetector();
|
|
347
|
+
if (!detector || destroyed) return;
|
|
348
|
+
const snapshot = detector.detectTheme();
|
|
349
|
+
if (!snapshot) return;
|
|
350
|
+
const hash = detector.snapshotHash(snapshot);
|
|
351
|
+
const state = readState(storageKey);
|
|
352
|
+
const now = Date.now();
|
|
353
|
+
const mark = () => {
|
|
354
|
+
const record = { hash, at: Date.now() };
|
|
355
|
+
state[snapshot.mode] = record;
|
|
356
|
+
state[guess] = state[guess] && guess !== snapshot.mode ? state[guess] : record;
|
|
357
|
+
writeState(storageKey, state);
|
|
358
|
+
};
|
|
359
|
+
if (!shouldSendSnapshot(state, snapshot.mode, hash, now)) {
|
|
360
|
+
mark();
|
|
361
|
+
return;
|
|
362
|
+
}
|
|
363
|
+
if (config.debug) console.log("[veo] theme snapshot", snapshot);
|
|
364
|
+
const res = await fetch(`${config.apiUrl}/v1/workspaces/theme-snapshot`, {
|
|
365
|
+
method: "POST",
|
|
366
|
+
headers: { "X-Api-Key": config.apiKey, "Content-Type": "application/json" },
|
|
367
|
+
body: JSON.stringify(snapshot),
|
|
368
|
+
credentials: "omit"
|
|
369
|
+
});
|
|
370
|
+
if (res.ok) mark();
|
|
371
|
+
} catch (err) {
|
|
372
|
+
if (config.debug) console.warn("[veo] theme detect failed", err);
|
|
373
|
+
}
|
|
374
|
+
};
|
|
375
|
+
const schedule = (delayMs) => {
|
|
376
|
+
if (timer) clearTimeout(timer);
|
|
377
|
+
timer = setTimeout(() => {
|
|
378
|
+
timer = null;
|
|
379
|
+
const idle = window.requestIdleCallback;
|
|
380
|
+
if (typeof idle === "function") idle(() => void run());
|
|
381
|
+
else void run();
|
|
382
|
+
}, delayMs);
|
|
383
|
+
};
|
|
384
|
+
return {
|
|
385
|
+
name: "theme-detect",
|
|
386
|
+
install() {
|
|
387
|
+
if (!hasWindow() || !hasDocument()) return;
|
|
388
|
+
if (document.readyState === "complete") schedule(SETTLE_MS);
|
|
389
|
+
else window.addEventListener("load", () => schedule(SETTLE_MS), { once: true });
|
|
390
|
+
if (typeof MutationObserver === "function") {
|
|
391
|
+
observer = new MutationObserver(() => schedule(1500));
|
|
392
|
+
observer.observe(document.documentElement, {
|
|
393
|
+
attributes: true,
|
|
394
|
+
attributeFilter: ["class", "data-theme", "data-mode"]
|
|
395
|
+
});
|
|
396
|
+
}
|
|
397
|
+
},
|
|
398
|
+
destroy() {
|
|
399
|
+
destroyed = true;
|
|
400
|
+
observer?.disconnect();
|
|
401
|
+
if (timer) clearTimeout(timer);
|
|
402
|
+
}
|
|
403
|
+
};
|
|
404
|
+
}
|
|
405
|
+
|
|
294
406
|
// src/core/queue.ts
|
|
295
407
|
var RETRY_MAX_DELAY_MS = 3e4;
|
|
296
408
|
var Queue = class {
|
|
@@ -437,26 +549,26 @@ var Session = class {
|
|
|
437
549
|
};
|
|
438
550
|
|
|
439
551
|
// src/core/storage.ts
|
|
440
|
-
var
|
|
552
|
+
var STORAGE_PREFIX2 = "veo:";
|
|
441
553
|
var ONE_YEAR_MS = 365 * 24 * 60 * 60 * 1e3;
|
|
442
554
|
var LocalStorageAdapter = class {
|
|
443
555
|
get(key) {
|
|
444
|
-
return localStorage.getItem(
|
|
556
|
+
return localStorage.getItem(STORAGE_PREFIX2 + key);
|
|
445
557
|
}
|
|
446
558
|
set(key, value) {
|
|
447
559
|
try {
|
|
448
|
-
localStorage.setItem(
|
|
560
|
+
localStorage.setItem(STORAGE_PREFIX2 + key, value);
|
|
449
561
|
} catch {
|
|
450
562
|
}
|
|
451
563
|
}
|
|
452
564
|
remove(key) {
|
|
453
|
-
localStorage.removeItem(
|
|
565
|
+
localStorage.removeItem(STORAGE_PREFIX2 + key);
|
|
454
566
|
}
|
|
455
567
|
clear() {
|
|
456
568
|
const toRemove = [];
|
|
457
569
|
for (let i = 0; i < localStorage.length; i++) {
|
|
458
570
|
const key = localStorage.key(i);
|
|
459
|
-
if (key?.startsWith(
|
|
571
|
+
if (key?.startsWith(STORAGE_PREFIX2)) toRemove.push(key);
|
|
460
572
|
}
|
|
461
573
|
for (const key of toRemove) localStorage.removeItem(key);
|
|
462
574
|
}
|
|
@@ -467,7 +579,7 @@ function readCookies() {
|
|
|
467
579
|
}
|
|
468
580
|
var CookieAdapter = class {
|
|
469
581
|
get(key) {
|
|
470
|
-
const name = `${
|
|
582
|
+
const name = `${STORAGE_PREFIX2}${key}=`;
|
|
471
583
|
for (const cookie of readCookies()) {
|
|
472
584
|
if (cookie.startsWith(name)) {
|
|
473
585
|
return decodeURIComponent(cookie.slice(name.length));
|
|
@@ -478,19 +590,19 @@ var CookieAdapter = class {
|
|
|
478
590
|
set(key, value, options) {
|
|
479
591
|
const maxAgeSec = Math.floor((options?.ttlMs ?? ONE_YEAR_MS) / 1e3);
|
|
480
592
|
const secure = typeof location !== "undefined" && location.protocol === "https:" ? "; Secure" : "";
|
|
481
|
-
document.cookie = `${
|
|
593
|
+
document.cookie = `${STORAGE_PREFIX2}${key}=${encodeURIComponent(
|
|
482
594
|
value
|
|
483
595
|
)}; Path=/; Max-Age=${maxAgeSec}; SameSite=Lax${secure}`;
|
|
484
596
|
}
|
|
485
597
|
remove(key) {
|
|
486
|
-
document.cookie = `${
|
|
598
|
+
document.cookie = `${STORAGE_PREFIX2}${key}=; Path=/; Max-Age=0; SameSite=Lax`;
|
|
487
599
|
}
|
|
488
600
|
clear() {
|
|
489
601
|
for (const cookie of readCookies()) {
|
|
490
602
|
const eq = cookie.indexOf("=");
|
|
491
603
|
const name = eq === -1 ? cookie : cookie.slice(0, eq);
|
|
492
|
-
if (name.startsWith(
|
|
493
|
-
this.remove(name.slice(
|
|
604
|
+
if (name.startsWith(STORAGE_PREFIX2)) {
|
|
605
|
+
this.remove(name.slice(STORAGE_PREFIX2.length));
|
|
494
606
|
}
|
|
495
607
|
}
|
|
496
608
|
}
|
|
@@ -779,13 +891,23 @@ var Client = class {
|
|
|
779
891
|
};
|
|
780
892
|
|
|
781
893
|
// src/core/setup.ts
|
|
782
|
-
function setupClient(config, onGuides, loadBuilder) {
|
|
894
|
+
function setupClient(config, onGuides, loadBuilder, loadThemeDetector) {
|
|
783
895
|
const client = new Client(config);
|
|
784
896
|
client.use(spaRouterPlugin());
|
|
785
897
|
if (config.autocapture !== false) {
|
|
786
898
|
const autocaptureConfig = typeof config.autocapture === "object" ? config.autocapture : {};
|
|
787
899
|
client.use(autocapturePlugin(autocaptureConfig));
|
|
788
900
|
}
|
|
901
|
+
if (config.detectTheme !== false && loadThemeDetector && !isBuilderMode()) {
|
|
902
|
+
client.use(
|
|
903
|
+
themeDetectPlugin({
|
|
904
|
+
apiUrl: resolveApiUrl(config),
|
|
905
|
+
apiKey: config.apiKey,
|
|
906
|
+
loadDetector: loadThemeDetector,
|
|
907
|
+
...config.debug !== void 0 ? { debug: config.debug } : {}
|
|
908
|
+
})
|
|
909
|
+
);
|
|
910
|
+
}
|
|
789
911
|
onGuides(client);
|
|
790
912
|
if (typeof window !== "undefined") {
|
|
791
913
|
const stub = window.veo;
|
|
@@ -844,7 +966,10 @@ function init(config) {
|
|
|
844
966
|
// Fallback de carga del builder para bundlers: `import()` dinámico → el bundler
|
|
845
967
|
// lo code-splitea (solo se descarga en modo builder). Así el consumidor por
|
|
846
968
|
// bundler NO necesita copiar `veo-builder.js` ni setear `builderUrl`.
|
|
847
|
-
() => import('./builder-
|
|
969
|
+
() => import('./builder-ENKEIVF2.mjs').then((m) => m.initBuilderMode()),
|
|
970
|
+
// Detector de tema: también por `import()` dinámico → chunk aparte que el
|
|
971
|
+
// bundler solo descarga cuando toca detectar (como mucho una vez al día).
|
|
972
|
+
() => import('./detect-theme-X4K3TLUL.mjs')
|
|
848
973
|
);
|
|
849
974
|
}
|
|
850
975
|
|