vanilla-agent 1.26.0 → 1.28.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/dist/index.cjs +7 -7
- package/dist/index.cjs.map +1 -1
- package/dist/index.global.js +11 -11
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +7 -7
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/utils/code-generators.ts +39 -5
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vanilla-agent",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.28.0",
|
|
4
4
|
"description": "Themeable, plugable streaming agent widget for websites, in plain JS with support for voice input and reasoning / tool output.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.cjs",
|
|
@@ -1329,14 +1329,48 @@ function generateScriptAdvancedCode(config: any): string {
|
|
|
1329
1329
|
" });",
|
|
1330
1330
|
" };",
|
|
1331
1331
|
"",
|
|
1332
|
-
" //
|
|
1333
|
-
"
|
|
1334
|
-
"
|
|
1332
|
+
" // Wait for framework hydration to complete (Next.js, Nuxt, etc.)",
|
|
1333
|
+
" // This prevents the framework from removing dynamically added CSS during reconciliation",
|
|
1334
|
+
" var waitForHydration = function(callback) {",
|
|
1335
|
+
" var executed = false;",
|
|
1336
|
+
" ",
|
|
1337
|
+
" var execute = function() {",
|
|
1338
|
+
" if (executed) return;",
|
|
1339
|
+
" executed = true;",
|
|
1340
|
+
" callback();",
|
|
1341
|
+
" };",
|
|
1342
|
+
"",
|
|
1343
|
+
" var afterDom = function() {",
|
|
1344
|
+
" // Strategy 1: Use requestIdleCallback if available (best for detecting idle after hydration)",
|
|
1345
|
+
" if (typeof requestIdleCallback !== 'undefined') {",
|
|
1346
|
+
" requestIdleCallback(function() {",
|
|
1347
|
+
" // Double requestAnimationFrame ensures at least one full paint cycle completed",
|
|
1348
|
+
" requestAnimationFrame(function() {",
|
|
1349
|
+
" requestAnimationFrame(execute);",
|
|
1350
|
+
" });",
|
|
1351
|
+
" }, { timeout: 3000 }); // Max wait 3 seconds, then proceed anyway",
|
|
1352
|
+
" } else {",
|
|
1353
|
+
" // Strategy 2: Fallback for Safari (no requestIdleCallback)",
|
|
1354
|
+
" // 300ms is typically enough for hydration on most pages",
|
|
1355
|
+
" setTimeout(execute, 300);",
|
|
1356
|
+
" }",
|
|
1357
|
+
" };",
|
|
1358
|
+
"",
|
|
1335
1359
|
" if (document.readyState === 'loading') {",
|
|
1336
|
-
" document.addEventListener('DOMContentLoaded',
|
|
1360
|
+
" document.addEventListener('DOMContentLoaded', afterDom);",
|
|
1337
1361
|
" } else {",
|
|
1338
|
-
"
|
|
1362
|
+
" // DOM already ready, but still wait for potential hydration",
|
|
1363
|
+
" afterDom();",
|
|
1339
1364
|
" }",
|
|
1365
|
+
" };",
|
|
1366
|
+
"",
|
|
1367
|
+
" // Boot sequence: wait for hydration, then load CSS and JS, then initialize",
|
|
1368
|
+
" // This prevents Next.js/Nuxt/etc. from removing dynamically added CSS during reconciliation",
|
|
1369
|
+
" waitForHydration(function() {",
|
|
1370
|
+
" loadCSS();",
|
|
1371
|
+
" loadJS(function() {",
|
|
1372
|
+
" init();",
|
|
1373
|
+
" });",
|
|
1340
1374
|
" });",
|
|
1341
1375
|
"})();",
|
|
1342
1376
|
"</script>"
|