From 6db99f96dfbbdc5694765f611696ded58883bf36 Mon Sep 17 00:00:00 2001 From: khondokartowsif171 Date: Mon, 19 Oct 2026 01:20:55 +0600 Subject: [PATCH] Gate Studio frontend by workspace and isolate browser catalog state --- Dockerfile | 2 +- Dockerfile.api | 2 +- app.js | 314 ++++++++++++------------------- docs/runtime-reconciliation.md | 7 +- index.html | 104 +++++----- server/main.cjs | 13 +- server/static.cjs | 2 +- test/frontend-workspace.test.cjs | 73 +++++++ test/static-main.test.cjs | 3 + workspace.js | 89 +++++++++ 10 files changed, 350 insertions(+), 259 deletions(-) create mode 100644 test/frontend-workspace.test.cjs create mode 100644 workspace.js diff --git a/Dockerfile b/Dockerfile index 3cc84f7..52d2104 100644 --- a/Dockerfile +++ b/Dockerfile @@ -9,7 +9,7 @@ RUN rm -rf /usr/share/nginx/html/* COPY nginx.conf /etc/nginx/conf.d/default.conf # Publish web assets only. Backend source, tests and local configuration are not static downloads. -COPY index.html app.js style.css sw.js manifest.json gt_full_catalog.json /usr/share/nginx/html/ +COPY index.html app.js workspace.js style.css sw.js manifest.json gt_full_catalog.json /usr/share/nginx/html/ COPY assets/ /usr/share/nginx/html/assets/ COPY data/ /usr/share/nginx/html/data/ diff --git a/Dockerfile.api b/Dockerfile.api index 3f143f1..16bf3e1 100644 --- a/Dockerfile.api +++ b/Dockerfile.api @@ -5,7 +5,7 @@ ENV NODE_ENV=production PORT=3000 STUDIO_DATA_DIR=/data/studio COPY package.json package-lock.json ./ RUN npm ci --omit=dev --ignore-scripts --no-fund --no-audit COPY server/ ./server/ -COPY index.html app.js style.css sw.js manifest.json gt_full_catalog.json ./public/ +COPY index.html app.js workspace.js style.css sw.js manifest.json gt_full_catalog.json ./public/ COPY assets/ ./public/assets/ COPY data/ ./public/data/ RUN mkdir -p /data/studio && chown -R node:node /app /data/studio diff --git a/app.js b/app.js index ee50c95..f69a753 100644 --- a/app.js +++ b/app.js @@ -19,10 +19,10 @@ const I18N_DICTIONARY = { poster_mode_label: "ডিসপ্লে মোড (Display Mode):", mode_single_btn: "🎯 ১টি প্রোডাক্ট হিরো ৩ডি স্টেজ", mode_multi_btn: "🔲 মাল্টি-প্রোডাক্ট গ্রিড ভিউ (৩-৪টি প্রোডাক্ট)", - trends_label: "🔥 গুগল ট্রেন্ডিং সার্চ (Google Trends 1-Click Load):", - trends_badge: "Realtime BD Trends", + trends_label: "🛍️ আপনার catalog থেকে বাছুন:", + trends_badge: "Workspace catalog", product_input_label: "প্রডাক্ট লিংক বা নাম (Product Link or Name):", - open_catalog_btn: "🛍️ GT ক্যাটালগ লিস্ট (560+)", + open_catalog_btn: "🛍️ আপনার catalog", product_input_ph: "e.g. Silk Saree, Smartwatch, Pure Honey, Sneaker or Skincare", product_price_label: "মূল্য ও অফার (Price & Discount):", product_price_ph: "e.g. ৳ ১,০৬০ (৳ ১,৪৭০) 28% OFF", @@ -220,10 +220,10 @@ const I18N_DICTIONARY = { poster_mode_label: "Display Mode:", mode_single_btn: "🎯 1 Product Hero 3D Stage", mode_multi_btn: "🔲 Multi-Product Grid View (3-4 Products)", - trends_label: "🔥 Google Trending Searches (Google Trends 1-Click Load):", - trends_badge: "Realtime BD Trends", + trends_label: "🛍️ Choose from your catalog:", + trends_badge: "Workspace catalog", product_input_label: "Product Link or Name:", - open_catalog_btn: "🛍️ GT Catalog List (560+)", + open_catalog_btn: "🛍️ Your catalog", product_input_ph: "e.g. Silk Saree, Smartwatch, Pure Honey, Sneaker or Skincare", product_price_label: "Price & Discount Offer:", product_price_ph: "e.g. ৳ 1,060 (৳ 1,470) 28% OFF", @@ -465,7 +465,17 @@ window.applyLanguage = function(lang) { if (typeof renderHistory === 'function') renderHistory(); }; -document.addEventListener('DOMContentLoaded', () => { +document.addEventListener('aura-studio-ready', () => { + const brandSelect = document.getElementById('brandWatermarkSelect'); + if (brandSelect) brandSelect.replaceChildren(new Option(window.AuraStudio.workspace.name || window.AuraStudio.workspace.tenant, 'workspace')); + const storeContext = document.getElementById('inboxStoreContext'); + if (storeContext) storeContext.value = window.AuraStudio.workspace.name || window.AuraStudio.workspace.tenant; + ['productInput', 'productPrice', 'customBadgeInput', 'ugcProductName', 'ugcTargetAudience', 'gridMainHeadlineInput'].forEach(id => { + const field = document.getElementById(id); if (field) field.value = ''; + }); + for (let slot = 1; slot <= 4; slot++) { + ['slotTitle', 'slotPrice', 'slotBadge'].forEach(prefix => { const field = document.getElementById(prefix + slot); if (field) field.value = ''; }); + } initNavigation(); initSettings(); initCatalogBrowser(); @@ -552,9 +562,9 @@ function initSettings() { const statusMsg = document.getElementById('settingsStatusMsg'); // Load saved settings - const savedKey = localStorage.getItem('opal_gemini_api_key') || ''; - const savedModel = localStorage.getItem('opal_selected_model') || 'gemini-2.0-flash'; - const savedN8n = localStorage.getItem('opal_n8n_webhook') || 'https://n8n.auraajenticai.cloud/webhook/gt-auto-post'; + const savedKey = window.AuraStudio.local.getItem('opal_gemini_api_key') || ''; + const savedModel = window.AuraStudio.local.getItem('opal_selected_model') || 'gemini-2.0-flash'; + const savedN8n = window.AuraStudio.local.getItem('opal_n8n_webhook') || ''; if (apiKeyInput) apiKeyInput.value = savedKey; if (modelSelect) modelSelect.value = savedModel; @@ -567,11 +577,11 @@ function initSettings() { const n8nUrl = n8nWebhookInput ? n8nWebhookInput.value.trim() : ''; if (n8nUrl) { - localStorage.setItem('opal_n8n_webhook', n8nUrl); + window.AuraStudio.local.setItem('opal_n8n_webhook', n8nUrl); } if (!key) { - localStorage.setItem('opal_selected_model', model); + window.AuraStudio.local.setItem('opal_selected_model', model); statusMsg.classList.remove('hidden'); statusMsg.style.color = '#10B981'; statusMsg.textContent = '✅ Settings saved (Offline templates active).'; @@ -585,8 +595,8 @@ function initSettings() { try { const res = await callGeminiApi(key, model, "Respond with: 'Aura Studio Connected successfully!'"); if (res) { - localStorage.setItem('opal_gemini_api_key', key); - localStorage.setItem('opal_selected_model', model); + window.AuraStudio.local.setItem('opal_gemini_api_key', key); + window.AuraStudio.local.setItem('opal_selected_model', model); statusMsg.style.color = '#10B981'; statusMsg.textContent = `✅ Verified & Active: ${res.trim()}`; } @@ -606,7 +616,7 @@ function getCachedPromptResult(cacheKey) { return GEMINI_CACHE.get(cacheKey); } try { - const stored = sessionStorage.getItem(`opal_cache_${cacheKey}`); + const stored = window.AuraStudio.session.getItem(`opal_cache_${cacheKey}`); if (stored) { const parsed = JSON.parse(stored); if (Date.now() - parsed.ts < 1000 * 60 * 60 * 2) { // 2 hour cache @@ -621,7 +631,7 @@ function getCachedPromptResult(cacheKey) { function setCachedPromptResult(cacheKey, data) { GEMINI_CACHE.set(cacheKey, data); try { - sessionStorage.setItem(`opal_cache_${cacheKey}`, JSON.stringify({ ts: Date.now(), data })); + window.AuraStudio.session.setItem(`opal_cache_${cacheKey}`, JSON.stringify({ ts: Date.now(), data })); } catch (e) {} } @@ -638,7 +648,7 @@ async function callGeminiApi(apiKey, model, prompt, retries = 2) { } const modelHierarchy = [ - model || localStorage.getItem('opal_selected_model') || 'gemini-2.0-flash', + model || window.AuraStudio.local.getItem('opal_selected_model') || 'gemini-2.0-flash', 'gemini-1.5-flash', 'gemma-2-27b-it' ]; @@ -1012,7 +1022,7 @@ function initMiniAppsHub() { } function getCustomMiniApps() { - return JSON.parse(localStorage.getItem('opal_custom_apps') || '[]'); + return JSON.parse(window.AuraStudio.local.getItem('opal_custom_apps') || '[]'); } function renderMiniApps() { @@ -1105,7 +1115,7 @@ function initMiniAppBuilder() { const existing = getCustomMiniApps(); existing.unshift(newApp); - localStorage.setItem('opal_custom_apps', JSON.stringify(existing)); + window.AuraStudio.local.setItem('opal_custom_apps', JSON.stringify(existing)); statusMsg.classList.remove('hidden'); statusMsg.style.color = '#10B981'; @@ -1193,7 +1203,7 @@ window.closeAppRunner = function() { }; // Handle Mini-App Execution -document.addEventListener('DOMContentLoaded', () => { +document.addEventListener('aura-studio-ready', () => { const execBtn = document.getElementById('runnerExecuteBtn'); if (execBtn) { execBtn.addEventListener('click', async () => { @@ -1212,7 +1222,7 @@ document.addEventListener('DOMContentLoaded', () => { const inputs = document.querySelectorAll('.runner-input'); const selectedBrandKey = document.getElementById('brandWatermarkSelect')?.value || 'glamourstouch'; const activeBrand = getBrandProfile(selectedBrandKey); - const cleanPhone = (activeBrand.footerHotline || '01712-426871').replace(/\D/g, ''); + const cleanPhone = (activeBrand.footerHotline || '').replace(/\D/g, ''); const dynamicWaLink = `https://wa.me/88${cleanPhone}`; let prompt = currentRunningApp.promptTemplate || 'Generate helpful response for the user.'; @@ -1231,8 +1241,8 @@ document.addEventListener('DOMContentLoaded', () => { prompt = prompt.replace(/{{wa_link}}/g, dynamicWaLink); prompt = prompt.replace(/https:\/\/wa\.me\/8801712426871/g, dynamicWaLink); - const apiKey = localStorage.getItem('opal_gemini_api_key') || ''; - const model = currentRunningApp.model || localStorage.getItem('opal_selected_model') || 'gemini-2.0-flash'; + const apiKey = window.AuraStudio.local.getItem('opal_gemini_api_key') || ''; + const model = currentRunningApp.model || window.AuraStudio.local.getItem('opal_selected_model') || 'gemini-2.0-flash'; try { let output = ''; @@ -1705,9 +1715,9 @@ function initPosterLab() { shareWhatsAppBtn.addEventListener('click', () => { const selectedBrand = document.getElementById('brandWatermarkSelect')?.value || 'glamourstouch'; const activeBrand = getBrandProfile(selectedBrand); - const cleanPhone = (activeBrand.footerHotline || '01712-426871').replace(/\D/g, ''); + const cleanPhone = (activeBrand.footerHotline || '').replace(/\D/g, ''); const pTitle = productInput.value.trim() || 'Authentic Product'; - const text = encodeURIComponent(`✨ Hello! I want to order: ${pTitle}\nWebsite: https://${activeBrand.footerSite || 'glamourstouch.com'}\nHotline: ${activeBrand.footerHotline}`); + const text = encodeURIComponent(`✨ Hello! I want to order: ${pTitle}\nWebsite: https://${activeBrand.footerSite || ''}\nHotline: ${activeBrand.footerHotline}`); window.open(`https://wa.me/88${cleanPhone}?text=${text}`, '_blank'); }); @@ -1717,7 +1727,7 @@ function initPosterLab() { if (autoPostN8nBtn) { autoPostN8nBtn.addEventListener('click', async () => { - const webhookUrl = localStorage.getItem('opal_n8n_webhook'); + const webhookUrl = window.AuraStudio.local.getItem('opal_n8n_webhook'); if (!webhookUrl) { alert('⚠️ Please configure n8n Webhook URL in Settings first!'); switchToTab('tabSettings'); @@ -1732,7 +1742,7 @@ function initPosterLab() { try { const selectedBrand = document.getElementById('brandWatermarkSelect')?.value || 'glamourstouch'; const activeBrand = getBrandProfile(selectedBrand); - const cleanPhone = (activeBrand.footerHotline || '01712-426871').replace(/\D/g, ''); + const cleanPhone = (activeBrand.footerHotline || '').replace(/\D/g, ''); const pTitle = productInput.value.trim() || 'Authentic Product'; const pPrice = productPrice.value.trim() || '৳ ১,০৬০'; const posterDataUrl = posterCanvas.toDataURL('image/jpeg', 0.92); @@ -1774,100 +1784,17 @@ function initPosterLab() { // --- Dynamic Brand Profiles & Tenant Sync Engine --- const DEFAULT_BRAND_PROFILES = { - glamourstouch: { - id: 'glamourstouch', - headerTitle: "✨ GLAMOUR'S TOUCH ✨", - headerSub: '100% AUTHENTIC KOREAN COSMETICS • DERMATOLOGIST TESTED', - badgeL1: '🌿 Pure & Safe Care', - badgeL2: '🛡️ Authentic Seal', - footerSite: 'glamourstouch.com', - footerHotline: '01712-426871', - theme: 'obsidian_gold', - category: 'cosmetics' - }, - panjabi: { - id: 'panjabi', - headerTitle: '👑 AURA HERITAGE PANJABI 👑', - headerSub: 'ROYAL DESIGNER PANJABI & KABLI SUITS • 100% PURE COTTON & SILK', - badgeL1: '🧵 100% Pre-Shrunk Weave', - badgeL2: '✨ Size Trial Available', - footerSite: 'panjabi.auraajenticai.cloud', - footerHotline: '01712-426871', - theme: 'obsidian_gold', - category: 'panjabi' - }, - snehalata: { - id: 'snehalata', - headerTitle: '🌸 SNEHALATA AURA 🌸', - headerSub: 'PREMIUM LUXURY FASHION, SAREE & LIFESTYLE • 100% AUTHENTIC', - badgeL1: '👗 Pure Fabric Weave', - badgeL2: '✨ Size Trial Guarantee', - footerSite: 'snehalata.com', - footerHotline: '01712-426871', - theme: 'rose_quartz', - category: 'fashion' - }, - techvolt: { - id: 'techvolt', - headerTitle: '⚡ TECHVOLT GADGETS ⚡', - headerSub: 'OFFICIAL WARRANTY • SMART ELECTRONICS & AUDIO ACCESSORIES', - badgeL1: '🔋 High Battery Life', - badgeL2: '🛡️ 1 Year Warranty', - footerSite: 'techvolt.auraajenticai.cloud', - footerHotline: '01712-426871', - theme: 'cyber_neon', - category: 'electronics' - }, - organic: { - id: 'organic', - headerTitle: '🍯 PRANON ORGANIC 🍯', - headerSub: '100% PURE NATURAL HONEY & UNADULTERATED ORGANIC FOODS', - badgeL1: '🌿 100% Lab Tested', - badgeL2: '🛡️ Double Money Back', - footerSite: 'organic.auraajenticai.cloud', - footerHotline: '01712-426871', - theme: 'botanical_eco', - category: 'organic' - }, - sneakerlab: { - id: 'sneakerlab', - headerTitle: '👟 SNEAKERLAB BD 👟', - headerSub: 'PREMIUM STREETWEAR & GENUINE LEATHER FOOTWEAR', - badgeL1: '👟 Memory Foam Cushion', - badgeL2: '✨ Doorstep Fitting', - footerSite: 'sneakers.auraajenticai.cloud', - footerHotline: '01712-426871', - theme: 'obsidian_gold', - category: 'sneakerlab' - }, - royale: { - id: 'royale', - headerTitle: '💎 AURA ROYALE 💎', - headerSub: 'LUXURY JEWELRY, WATCHES & 24-HOUR SIGNATURE PERFUMES', - badgeL1: '💎 24h Projection', - badgeL2: '👑 Pure Luxury Finish', - footerSite: 'royale.auraajenticai.cloud', - footerHotline: '01712-426871', - theme: 'obsidian_gold', - category: 'royale' - }, - custom: { - id: 'custom', - headerTitle: '🛍️ UNIVERSAL MERCHANT 🛍️', - headerSub: '100% ORIGINAL AUTHENTIC • CASH ON DELIVERY BANGLADESH', - badgeL1: '⭐ Premium Quality', - badgeL2: '🛡️ 100% Original', - footerSite: 'auraajenticai.cloud', - footerHotline: '01712-426871', - theme: 'obsidian_gold', - category: 'general' + workspace: { + id: 'workspace', headerTitle: window.AuraStudio.workspace.name || window.AuraStudio.workspace.tenant, + headerSub: '', badgeL1: '', badgeL2: '', footerSite: '', footerHotline: '', + theme: 'obsidian_gold', category: 'general' } }; function getDynamicBrandProfiles() { let customMap = {}; try { - const saved = localStorage.getItem('opal_custom_brands'); + const saved = window.AuraStudio.local.getItem('opal_custom_brands'); if (saved) customMap = JSON.parse(saved); } catch (e) {} return Object.assign({}, DEFAULT_BRAND_PROFILES, customMap); @@ -1875,7 +1802,7 @@ function getDynamicBrandProfiles() { function getBrandProfile(brandKey) { const all = getDynamicBrandProfiles(); - return all[brandKey] || all.glamourstouch; + return all[brandKey] || all.workspace; } // Universal Dynamic Product Resolver @@ -6206,7 +6133,8 @@ window.loadCgiIntoPosterLab = function(promptId) { } }; -async function drawWhatsAppQrOnCanvas(ctx, x, y, size, hotline = '01712-426871') { +async function drawWhatsAppQrOnCanvas(ctx, x, y, size, hotline = '') { + if (!String(hotline).replace(/\D/g, '')) return; ctx.fillStyle = '#FFFFFF'; roundRect(ctx, x - 4, y - 4, size + 8, size + 8, 10); ctx.fill(); @@ -6266,12 +6194,12 @@ function initInboxAI() { generateBtn.addEventListener('click', async () => { const query = customerMsgInput.value.trim(); const storeInfo = storeContextInput.value.trim(); - const apiKey = localStorage.getItem('opal_gemini_api_key') || ''; - const model = localStorage.getItem('opal_selected_model') || 'gemini-2.0-flash'; + const apiKey = window.AuraStudio.local.getItem('opal_gemini_api_key') || ''; + const model = window.AuraStudio.local.getItem('opal_selected_model') || 'gemini-2.0-flash'; const selectedBrand = document.getElementById('brandWatermarkSelect')?.value || 'glamourstouch'; const activeBrand = getBrandProfile(selectedBrand); - const cleanPhone = (activeBrand.footerHotline || '01712-426871').replace(/\D/g, ''); + const cleanPhone = (activeBrand.footerHotline || '').replace(/\D/g, ''); const dynamicWaLink = `https://wa.me/88${cleanPhone}`; if (!query) { @@ -6331,7 +6259,7 @@ function initHistory() { function renderHistory() { if (!historyContainer) return; const dict = I18N_DICTIONARY[window.currentLang] || I18N_DICTIONARY.bn; - const list = JSON.parse(localStorage.getItem('opal_history') || '[]'); + const list = JSON.parse(window.AuraStudio.local.getItem('opal_history') || '[]'); if (list.length === 0) { historyContainer.innerHTML = `
@@ -6358,7 +6286,7 @@ function initHistory() { if (clearBtn) { clearBtn.addEventListener('click', () => { - localStorage.removeItem('opal_history'); + window.AuraStudio.local.removeItem('opal_history'); renderHistory(); }); } @@ -6367,9 +6295,9 @@ function initHistory() { } function saveGenerationToHistory(item) { - const list = JSON.parse(localStorage.getItem('opal_history') || '[]'); + const list = JSON.parse(window.AuraStudio.local.getItem('opal_history') || '[]'); list.unshift(item); - localStorage.setItem('opal_history', JSON.stringify(list.slice(0, 30))); + window.AuraStudio.local.setItem('opal_history', JSON.stringify(list.slice(0, 30))); } // --- 7. Google Flow & Omni UGC Video Ads Studio (Google Veo 3.1) --- @@ -6541,8 +6469,8 @@ function initUgcStudio() { const preset = UGC_PRESET_LIBRARY[selectedUgcPreset] || UGC_PRESET_LIBRARY.unhinged_review; try { - const apiKey = localStorage.getItem('opal_gemini_api_key') || ''; - const model = localStorage.getItem('opal_selected_model') || 'gemini-2.0-flash'; + const apiKey = window.AuraStudio.local.getItem('opal_gemini_api_key') || ''; + const model = window.AuraStudio.local.getItem('opal_selected_model') || 'gemini-2.0-flash'; let masterPrompt = ''; let timelineShots = []; @@ -6661,7 +6589,7 @@ Generate: // --- Universal Multi-Store Catalog & Client URL Sync Engine --- window.ALL_STORES = {}; -window.activeStoreId = 'glamourstouch'; +window.activeStoreId = null; window.GT_CATALOG = []; let selectedCatalogBrand = 'all'; @@ -6689,36 +6617,29 @@ async function initCatalogBrowser() { const productInput = document.getElementById('productInput'); const autocompleteList = document.getElementById('productAutocompleteList'); - // 1. Initialize Master Store: Glamour's Touch (563 Products) - try { - const res = await fetch('gt_full_catalog.json'); - if (res.ok) { - window.GT_CATALOG = await res.json(); - window.ALL_STORES['glamourstouch'] = { - id: 'glamourstouch', - name: "Glamour's Touch", - icon: '✨', - domain: 'glamourstouch.com', - url: 'https://glamourstouch.com', - category: 'cosmetics', - badge: 'KOREAN COSMETICS', - count: window.GT_CATALOG.length, - products: window.GT_CATALOG, - isMaster: true - }; - } - } catch (e) { - console.warn('Could not load gt_full_catalog.json:', e); - } - + const htmlText = window.AuraStudio.escapeText; + const apiUrl = window.AuraStudio.apiUrl; + // Load only the authenticated workspace catalog; no global merchant fallback. // 2. Load Synced Stores from backend API await loadSyncedStoresFromBackend(); + window.activeStoreId = Object.keys(window.ALL_STORES)[0] || null; + const shortcuts = document.getElementById('trendingPosterChips'); + if (shortcuts) { + shortcuts.replaceChildren(); + Object.values(window.ALL_STORES).flatMap(item => item.products || []).slice(0, 7).forEach(product => { + const button = document.createElement('button'); + button.type = 'button'; button.className = 'pill-btn'; button.textContent = product.title; + button.addEventListener('click', () => window.applyCatalogProductToPoster(product.id)); + shortcuts.appendChild(button); + }); + } async function loadSyncedStoresFromBackend() { try { - const res = await fetch('/api/get-synced-stores'); - if (res.ok) { + const res = await fetch(apiUrl('/api/get-synced-stores'), { cache: 'no-store' }); + { const data = await res.json(); + if (!res.ok || data.success !== true) throw new Error(data.error || 'Catalog load হয়নি।'); if (data && Array.isArray(data.stores)) { data.stores.forEach(s => { let catEmoji = '🛍️'; @@ -6746,7 +6667,7 @@ async function initCatalogBrowser() { } } } catch (e) { - console.warn('Could not load synced stores:', e); + if (storeSyncStatusMsg) { storeSyncStatusMsg.classList.remove('hidden'); storeSyncStatusMsg.textContent = e.message || 'Catalog load হয়নি।'; } } } @@ -6760,8 +6681,8 @@ async function initCatalogBrowser() { const st = window.ALL_STORES[k]; const isActive = k === window.activeStoreId; html += ` - `; }); @@ -6812,7 +6733,13 @@ async function initCatalogBrowser() { // Update Store Banner function updateStoreBanner() { const cur = window.ALL_STORES[window.activeStoreId]; - if (!cur) return; + if (!cur) { + if (activeStoreTitle) activeStoreTitle.textContent = window.AuraStudio.workspace.name || window.AuraStudio.workspace.tenant; + if (activeStoreBadge) activeStoreBadge.textContent = 'CATALOG'; + if (activeStoreUrlLink) { activeStoreUrlLink.removeAttribute('href'); activeStoreUrlLink.textContent = ''; } + if (deleteCurrentStoreBtn) deleteCurrentStoreBtn.classList.add('hidden'); + return; + } if (activeStoreIcon) activeStoreIcon.textContent = cur.icon || '🛍️'; if (activeStoreTitle) activeStoreTitle.textContent = `${cur.name} (${cur.domain})`; @@ -6839,13 +6766,16 @@ async function initCatalogBrowser() { if (confirm(`আপনি কি "${cur.name}" স্টোর বক্স এবং এর সব প্রডাক্ট মুছে ফেলতে চান?`)) { try { - await fetch('/api/delete-synced-store', { + const response = await fetch(apiUrl('/api/delete-synced-store'), { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ storeId: cur.id }) }); + const result = await response.json(); + if (!response.ok || result.success !== true) throw new Error(result.error || 'Store মুছে ফেলা হয়নি।'); delete window.ALL_STORES[cur.id]; - switchActiveStore('glamourstouch'); + window.activeStoreId = Object.keys(window.ALL_STORES)[0] || null; + renderStoreSwitcher(); updateStoreBanner(); renderBrandFilterChips(); renderCatalogGrid(); } catch (e) { alert('Error deleting store: ' + e.message); } @@ -6879,7 +6809,7 @@ async function initCatalogBrowser() { startStoreSyncBtn.disabled = true; try { - const res = await fetch('/api/sync-store', { + const res = await fetch(apiUrl('/api/sync-store'), { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ @@ -6986,7 +6916,7 @@ async function initCatalogBrowser() { return; } - const brandCounts = {}; + const brandCounts = Object.create(null); cur.products.forEach(p => { const b = p.brand || cur.name || 'Brand'; brandCounts[b] = (brandCounts[b] || 0) + 1; @@ -6999,7 +6929,7 @@ async function initCatalogBrowser() { let html = ``; topBrands.forEach(b => { - html += ``; + html += ``; }); brandChipsContainer.innerHTML = html; @@ -7018,7 +6948,14 @@ async function initCatalogBrowser() { function renderCatalogGrid() { if (!catalogGridContainer) return; const cur = window.ALL_STORES[window.activeStoreId]; - if (!cur) return; + if (!cur) { + catalogGridContainer.replaceChildren(); + const empty = document.createElement('p'); + empty.textContent = 'এই workspace-এ catalog এখনও যোগ করা হয়নি। নিজের store connect বা URL দিয়ে sync করুন।'; + catalogGridContainer.appendChild(empty); + if (catalogCountText) catalogCountText.textContent = '0 products'; + return; + } const dict = I18N_DICTIONARY[window.currentLang] || I18N_DICTIONARY.bn; const query = (catalogSearchInput ? catalogSearchInput.value : '').toLowerCase().trim(); @@ -7036,9 +6973,9 @@ async function initCatalogBrowser() { if (catalogCountText) { if (window.currentLang === 'en') { - catalogCountText.textContent = `${cur.name} — ${filtered.length} authentic products found (Total ${cur.products.length})`; + catalogCountText.textContent = `${cur.name} — ${filtered.length} products found (Total ${cur.products.length})`; } else { - catalogCountText.textContent = `${cur.name} — ${filtered.length}টি আসল প্রোডাক্ট পাওয়া গেছে (মোট ${cur.products.length}টি)`; + catalogCountText.textContent = `${cur.name} — ${filtered.length}টি প্রোডাক্ট পাওয়া গেছে (মোট ${cur.products.length}টি)`; } } @@ -7055,20 +6992,20 @@ async function initCatalogBrowser() { const displayList = filtered.slice(0, 150); catalogGridContainer.innerHTML = displayList.map(p => `
- ${p.title} + ${htmlText(p.title)}
- ${p.brand || cur.name} -

${p.title}

+ ${htmlText(p.brand || cur.name)} +

${htmlText(p.title)}

- ${p.price} - ${p.regularPrice} + ${htmlText(p.price)} + ${htmlText(p.regularPrice)}
- -
@@ -7092,7 +7029,7 @@ async function initCatalogBrowser() { } if (!p) return; - const text = `✨ ${p.title}\n🏷️ ব্র্যান্ড / স্টোর: ${p.brand || storeObj.name}\n💰 অফার মূল্য: ${p.price} (রেগুলার ${p.regularPrice})\n🛡️ ১০০% আসল ও প্রিমিয়াম কোয়ালিটি নিশ্চিত\n🔗 লিংক: ${p.link || storeObj.url}\n📸 ইমেজ: ${p.image}`; + const text = `✨ ${p.title}\n🏷️ ব্র্যান্ড / স্টোর: ${p.brand || storeObj.name}\n💰 মূল্য: ${p.price}${p.regularPrice ? ' (রেগুলার ' + p.regularPrice + ')' : ''}\n🔗 লিংক: ${p.link || storeObj.url}\n📸 ইমেজ: ${p.image}`; navigator.clipboard.writeText(text).then(() => { alert(`✅ "${p.title}"-এর সম্পূর্ণ তথ্য কপি হয়েছে!`); }).catch(() => { @@ -7131,33 +7068,26 @@ async function initCatalogBrowser() { const clearBtn = document.getElementById('clearPhotoBtn'); if (pInput) pInput.value = p.title; - if (pPrice) pPrice.value = `${p.price} (${p.regularPrice}) 20% OFF`; - if (pBadge) pBadge.value = `🛡️ 100% Authentic ${p.brand || storeObj.name}`; + if (pPrice) pPrice.value = [p.price, p.regularPrice ? '(' + p.regularPrice + ')' : ''].filter(Boolean).join(' '); + if (pBadge) pBadge.value = ''; - if (pBrand) { - if (storeObj.id === 'glamourstouch') { - pBrand.value = 'glamourstouch'; - } else if (storeObj.category && pBrand.querySelector(`option[value="${storeObj.category}"]`)) { - pBrand.value = storeObj.category; - } else { - pBrand.value = 'custom'; - } - } + if (pBrand) pBrand.value = 'workspace'; if (photoImg && photoBox && p.image) { photoImg.src = p.image; photoBox.classList.remove('hidden'); if (clearBtn) clearBtn.classList.remove('hidden'); + } else if (photoImg && photoBox) { + photoImg.removeAttribute('src'); + photoBox.classList.add('hidden'); + if (clearBtn) clearBtn.classList.add('hidden'); } window.closeCatalogModal(); if (autocompleteList) autocompleteList.classList.add('hidden'); switchToTab('tabPosterLab'); - setTimeout(() => { - const genBtn = document.getElementById('generatePosterBtn'); - if (genBtn) genBtn.click(); - }, 250); + // Product selection fills the form; rendering remains an explicit user action. }; // 8. Live Autocomplete on #productInput across all active stores @@ -7185,16 +7115,16 @@ async function initCatalogBrowser() { const dict = I18N_DICTIONARY[window.currentLang] || I18N_DICTIONARY.bn; autocompleteList.innerHTML = matches.map(p => ` -
- ${p.title} +
+ ${htmlText(p.title)}
-
${p.title}
+
${htmlText(p.title)}
- ${p.brand || p.storeName || "Authentic"} - ${p.price} + ${htmlText(p.brand || p.storeName || "Authentic")} + ${htmlText(p.price)}
-
diff --git a/docs/runtime-reconciliation.md b/docs/runtime-reconciliation.md index b34fa25..dc96605 100644 --- a/docs/runtime-reconciliation.md +++ b/docs/runtime-reconciliation.md @@ -1,3 +1,9 @@ +# Frontend workspace integration — 19 October 2026 + +The candidate now gates app startup on verified workspace identity, scopes browser private state by client UUID, removes prototype merchant catalog/default policy for new clients, and escapes imported catalog markup. Local and Linux image tests pass 58/58. Separate loopback browser QA confirms inert HTML-like product names, source price transfer without a fabricated discount, and an empty second workspace. The large poster renderer section is unchanged. CLI configuration now requires STUDIO_LOGIN_URL. + +Connected Client catalog brokerage, full Client startup/recovery, persistent Studio service configuration and actual release remain open. No Meta 1-Click Connector inspection or change was made. + # Studio runtime source reconciliation Captured on 2026-10-18 from the running Aura Studio static application. app.js is restored byte-for-byte from the privately preserved live file, SHA-256 025a1d94971361944cc3a3197bb894255d96cc824f603da3425466fab4cbdf74. The remaining checked static entry/config files match repository main after line-ending normalization. @@ -38,4 +44,3 @@ Catalog list/import/delete responses replace merchant image URLs with a same-ori The backend candidate is not deployed. Frontend authentication/workspace selection, private browser-state namespacing, imported-text rendering, connected Client catalog access and persistent production configuration remain required release work. The prototype global GT catalog is not a valid default for another client. No Meta connector inspection or modification is part of this work. The local branch reference was found zero-filled. Its bytes were retained outside the Git refs directory, the remote branch was read, and the existing local commit object was checked before restoring the reference to `cbe6e0ae94e22e6c34ecc55bad036ff8c165b488`. No working files were reset. The cause of that local reference damage is not established. - diff --git a/index.html b/index.html index babe341..3ac5938 100644 --- a/index.html +++ b/index.html @@ -22,6 +22,17 @@ +
@@ -246,16 +257,7 @@ - +
@@ -277,37 +279,29 @@
- +
- +
- +
- +
@@ -348,13 +342,7 @@ 🎁 ট্রেন্ডিং মাল্টি-প্যাক কম্বো (1-Click Multi Combos): Full Catalog Combos - +
@@ -370,10 +358,10 @@ ছবি সিলেক্ট করুন
- - + +
- + @@ -387,10 +375,10 @@ ছবি সিলেক্ট করুন
- - + +
- + @@ -404,10 +392,10 @@ ছবি সিলেক্ট করুন
- - + +
- + @@ -421,10 +409,10 @@ ছবি সিলেক্ট করুন
- - + +
- + @@ -649,11 +637,11 @@ Format with clear bullet points, emojis, and a call-to-action.
- +
- +
@@ -777,7 +765,7 @@ Format with clear bullet points, emojis, and a call-to-action.
- +
- - - +