top of page

import wixLocation from 'wix-location'; import { getCompanionBootstrap, saveMyCompanionState, deleteMyCompanionState, shareCommunityItem, communityAction } from 'backend/companion'; $w.onReady(async function () { const frame = $w('#companionEmbed'); async function hydrate() { try { const data = await getCompanionBootstrap(); frame.postMessage({ source: 'auriva-wix', type: 'HYDRATE', ...data }); } catch (error) { console.error('[Auriva Companion] bootstrap failed', error); frame.postMessage({ source: 'auriva-wix', type: 'ERROR', message: String(error?.message || error) }); } } frame.onMessage(async (event) => { const message = event.data || {}; if (message.source !== 'auriva-companion') return; try { if (message.type === 'GET_BOOTSTRAP') await hydrate(); if (message.type === 'SAVE_STATE') { const result = await saveMyCompanionState(message.state); frame.postMessage({ source: 'auriva-wix', type: 'SAVE_RESULT', ...result }); } if (message.type === 'DELETE_STATE') { await deleteMyCompanionState(); frame.postMessage({ source: 'auriva-wix', type: 'SAVE_RESULT', ok: true }); } if (message.type === 'SHARE_RECIPE') { await shareCommunityItem(message.item); const data = await getCompanionBootstrap(); frame.postMessage({ source: 'auriva-wix', type: 'COMMUNITY_UPDATED', items: data.community }); } if (message.type === 'COMMUNITY_ACTION') { await communityAction(message.id, message.action); } if (message.type === 'OPEN_URL' && typeof message.url === 'string') { wixLocation.to(message.url); } } catch (error) { console.error('[Auriva Companion] request failed', error); frame.postMessage({ source: 'auriva-wix', type: 'ERROR', message: String(error?.message || error) }); } }); await hydrate(); });

import wixLocation from 'wix-location'; import { getCompanionBootstrap, saveMyCompanionState, deleteMyCompanionState, shareCommunityItem, communityAction } from 'backend/companion'; $w.onReady(async function () { const frame = $w('#companionEmbed'); async function hydrate() { try { const data = await getCompanionBootstrap(); frame.postMessage({ source: 'auriva-wix', type: 'HYDRATE', ...data }); } catch (error) { console.error('[Auriva Companion] bootstrap failed', error); frame.postMessage({ source: 'auriva-wix', type: 'ERROR', message: String(error?.message || error) }); } } frame.onMessage(async (event) => { const message = event.data || {}; if (message.source !== 'auriva-companion') return; try { if (message.type === 'GET_BOOTSTRAP') await hydrate(); if (message.type === 'SAVE_STATE') { const result = await saveMyCompanionState(message.state); frame.postMessage({ source: 'auriva-wix', type: 'SAVE_RESULT', ...result }); } if (message.type === 'DELETE_STATE') { await deleteMyCompanionState(); frame.postMessage({ source: 'auriva-wix', type: 'SAVE_RESULT', ok: true }); } if (message.type === 'SHARE_RECIPE') { await shareCommunityItem(message.item); const data = await getCompanionBootstrap(); frame.postMessage({ source: 'auriva-wix', type: 'COMMUNITY_UPDATED', items: data.community }); } if (message.type === 'COMMUNITY_ACTION') { await communityAction(message.id, message.action); } if (message.type === 'OPEN_URL' && typeof message.url === 'string') { wixLocation.to(message.url); } } catch (error) { console.error('[Auriva Companion] request failed', error); frame.postMessage({ source: 'auriva-wix', type: 'ERROR', message: String(error?.message || error) }); } }); await hydrate(); });

import wixLocation from 'wix-location'; import { getCompanionBootstrap, saveMyCompanionState, deleteMyCompanionState, shareCommunityItem, communityAction } from 'backend/companion'; $w.onReady(async function () { const frame = $w('#companionEmbed'); async function hydrate() { try { const data = await getCompanionBootstrap(); frame.postMessage({ source: 'auriva-wix', type: 'HYDRATE', ...data }); } catch (error) { console.error('[Auriva Companion] bootstrap failed', error); frame.postMessage({ source: 'auriva-wix', type: 'ERROR', message: String(error?.message || error) }); } } frame.onMessage(async (event) => { const message = event.data || {}; if (message.source !== 'auriva-companion') return; try { if (message.type === 'GET_BOOTSTRAP') await hydrate(); if (message.type === 'SAVE_STATE') { const result = await saveMyCompanionState(message.state); frame.postMessage({ source: 'auriva-wix', type: 'SAVE_RESULT', ...result }); } if (message.type === 'DELETE_STATE') { await deleteMyCompanionState(); frame.postMessage({ source: 'auriva-wix', type: 'SAVE_RESULT', ok: true }); } if (message.type === 'SHARE_RECIPE') { await shareCommunityItem(message.item); const data = await getCompanionBootstrap(); frame.postMessage({ source: 'auriva-wix', type: 'COMMUNITY_UPDATED', items: data.community }); } if (message.type === 'COMMUNITY_ACTION') { await communityAction(message.id, message.action); } if (message.type === 'OPEN_URL' && typeof message.url === 'string') { wixLocation.to(message.url); } } catch (error) { console.error('[Auriva Companion] request failed', error); frame.postMessage({ source: 'auriva-wix', type: 'ERROR', message: String(error?.message || error) }); } }); await hydrate(); });

Home

Auriva Companion

bottom of page