Initial commit

This commit is contained in:
2026-02-18 15:43:09 +03:00
commit 03c3a6ee00
312 changed files with 14121 additions and 0 deletions

View File

@@ -0,0 +1 @@
import{_ as T,i as o,c as h,o as c,b as r,j as u,a5 as _,z as d,F as p,r as y,t as D,ad as S}from"./main-D6qyxymd.js";const R={props:{plugin:{type:Object,required:!0},settings:{type:Object,required:!0}},emits:["update:settings"],data(){return{isLoading:!1,definitions:{},panelOpen:!1}},computed:{tablesOptions(){return Object.keys(this.definitions).map(e=>({label:e,value:e}))},realtimeTables(){var e;return((e=this.settings.publicData)==null?void 0:e.realtimeTables)||{}}},watch:{"plugin.doc.definitions":{handler(e){this.applyDefinitions(e)},immediate:!0},panelOpen(e){e&&this.queueDocRefresh(200)},settings:{handler(){this.scheduleConfigWatch()},deep:!0}},mounted(){var e,t,i;(e=this.settings.publicData)!=null&&e.realtimeTables||this.changeRealtimeTables({}),this.applyDefinitions(((i=(t=this.plugin)==null?void 0:t.doc)==null?void 0:i.definitions)||{}),this.scheduleConfigWatch(),this.queueDocRefresh()},beforeUnmount(){this._refreshTimeout&&(clearTimeout(this._refreshTimeout),this._refreshTimeout=null)},methods:{scheduleConfigWatch(){const e=S("supabase"),t={projectUrl:(e==null?void 0:e.projectUrl)||null,baseProjectRef:(e==null?void 0:e.baseProjectRef)||null,branch:(e==null?void 0:e.branch)||null,branchSlug:(e==null?void 0:e.branchSlug)||null},i=JSON.stringify(t);if(this._lastConfigSnapshot===i)return;const s=this._lastConfigSnapshot?JSON.parse(this._lastConfigSnapshot):null;this._lastConfigSnapshot=i,s&&this.queueDocRefresh(200)},handleTogglePanel(e){this.panelOpen=e},queueDocRefresh(e=1e3){this._refreshTimeout&&clearTimeout(this._refreshTimeout),this._refreshTimeout=setTimeout(async()=>{var t,i;try{this.isLoading=!0,await this.plugin.fetchDoc(),this.applyDefinitions(((i=(t=this.plugin)==null?void 0:t.doc)==null?void 0:i.definitions)||{})}catch(s){wwLib.wwLog.error(s)}finally{this.isLoading=!1}},1e3)},applyDefinitions(e={}){const t=e||{};this.definitions=t;const i=new Set(Object.keys(t)),s={...this.realtimeTables};let l=!1;for(const a of Object.keys(s))i.has(a)||(delete s[a],l=!0);l&&this.changeRealtimeTables(s)},async fetchTables(){var e,t;try{this.isLoading=!0,await this.plugin.fetchDoc(),this.definitions=((t=(e=this.plugin)==null?void 0:e.doc)==null?void 0:t.definitions)||{}}catch(i){wwLib.wwLog.error(i)}finally{this.isLoading=!1}},updateReatimeTable(e,t){const i={...this.realtimeTables};i[e]=t;for(const s in i)this.tablesOptions.find(l=>l.value===s)||delete i[s];this.changeRealtimeTables(i)},changeRealtimeTables(e){this.$emit("update:settings",{...this.settings,publicData:{...this.settings.publicData,realtimeTables:e}}),this.subscribeTables(e)},subscribeTables(e){this.settings.publicData.realtimeTables&&this.plugin.subscribeTables(e)}}},L={class:"mb-3 label-sm text-blue-500 flex items-center"},O={class:"label-2 ml-2"};function k(e,t,i,s,l,a){const m=o("wwEditorIcon"),b=o("wwEditorInputSwitch"),f=o("wwEditorFormRow"),g=o("wwLoader");return c(),h(p,null,[r("div",L,[u(m,{class:"mr-1",name:"information-circle",small:""}),t[1]||(t[1]=_(" This feature allow your collections to be updated in realtime automcatically. You must enable realtime on your tables both in WeWeb and in Supabase in order to use this feature. "))]),u(f,{label:"Enable realtime table",onTogglePanel:a.handleTogglePanel},{"append-label":d(()=>[t[2]||(t[2]=r("a",{class:"ww-editor-link ml-2",href:"https://supabase.com/docs/guides/api#realtime-api-1",target:"_blank"}," Find it here ",-1)),r("button",{type:"button",class:"ww-editor-button -primary -small ml-auto",onClick:t[0]||(t[0]=(...n)=>a.fetchTables&&a.fetchTables(...n))},"refresh")]),default:d(()=>[(c(!0),h(p,null,y(a.tablesOptions,n=>(c(),h("div",{key:n.value,class:"flex items-center mb-2"},[u(b,{modelValue:a.realtimeTables[n.value],"onUpdate:modelValue":w=>a.updateReatimeTable(n.value,w),small:""},null,8,["modelValue","onUpdate:modelValue"]),r("div",O,D(n.label),1)]))),128))]),_:1},8,["onTogglePanel"]),u(g,{loading:l.isLoading},null,8,["loading"])],64)}const C=T(R,[["render",k]]);export{C as default};