From 142ff43140ff328c263fcbc8ef916ee2604e2f94 Mon Sep 17 00:00:00 2001
From: Hackall <36754621+hackall360@users.noreply.github.com>
Date: Mon, 15 Sep 2025 00:24:38 -0700
Subject: [PATCH] chore: move polliLib setup to deferred script
---
index.html | 51 +--------------------------------------------
js/pollilib-init.js | 48 ++++++++++++++++++++++++++++++++++++++++++
2 files changed, 49 insertions(+), 50 deletions(-)
create mode 100644 js/pollilib-init.js
diff --git a/index.html b/index.html
index 6f019dc..a9ec770 100644
--- a/index.html
+++ b/index.html
@@ -11,56 +11,7 @@
-
+
diff --git a/js/pollilib-init.js b/js/pollilib-init.js
new file mode 100644
index 0000000..bddca31
--- /dev/null
+++ b/js/pollilib-init.js
@@ -0,0 +1,48 @@
+// Configure polliLib default client and expose an explicit client for MCP helpers
+(function(){
+ try {
+ if (window.polliLib) {
+ // Derive base referrer from attribute or window location (no path segments)
+ const cur = document.currentScript;
+ const attrRef = cur && cur.getAttribute('data-referrer');
+ let base = window.location.origin;
+ if (attrRef) {
+ // Support values missing protocol by resolving against window.location.origin
+ try { base = new URL(attrRef, window.location.origin).origin; } catch {}
+ }
+ const referrer = base.endsWith('/') ? base : base + '/';
+ window.polliLib.configure({ referrer });
+ window.polliClient = window.polliLib.getDefaultClient();
+
+ // Provide basic helpers used by image features
+ if (!window.randomSeed) {
+ window.randomSeed = function randomSeed() { return Math.floor(Math.random() * 1000000); };
+ }
+ if (!window.imagePatterns) {
+ window.imagePatterns = [
+ { pattern: /```image\n([\s\S]*?)\n```/i, group: 1 },
+ ];
+ }
+ if (!window.audioPatterns) {
+ window.audioPatterns = [
+ { pattern: /```audio\n([\s\S]*?)\n```/i, group: 1 },
+ ];
+ }
+ if (!window.uiPatterns) {
+ window.uiPatterns = [
+ { pattern: /```ui\n([\s\S]*?)\n```/i, group: 1 },
+ ];
+ }
+ if (!window.voicePatterns) {
+ window.voicePatterns = [
+ { pattern: /```voice\n([\s\S]*?)\n```/i, group: 1 },
+ ];
+ }
+ if (!window.videoPatterns) {
+ window.videoPatterns = [
+ { pattern: /```video\n([\s\S]*?)\n```/i, group: 1 },
+ ];
+ }
+ }
+ } catch (e) { console.warn('polliLib configure failed', e); }
+})();