@blocklet/pages-kit-inner-components 0.6.71 → 0.6.73
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/lib/cjs/add-component.js +12 -12
- package/lib/cjs/chunks/{draft-data-DfZ81oCU.js → draft-data-1hI-ev3X.js} +1 -1
- package/lib/cjs/chunks/{home-CP3WKJ_e.js → home-ymdnbwRQ.js} +2 -2
- package/lib/cjs/chunks/{index-BqynZDZ3.js → index-BAiZumV7.js} +1 -1
- package/lib/cjs/chunks/{publish-button-t3lAZwFy.js → publish-button-45a3egG-.js} +1 -1
- package/lib/cjs/chunks/{site-state-BRYYpS9Q.js → site-state-CcYU6tKv.js} +1 -1
- package/lib/cjs/chunks/state-BAjDjwwp.js +1 -0
- package/lib/cjs/home.js +1 -1
- package/lib/cjs/locales.js +2 -2
- package/lib/cjs/resources.js +1 -1
- package/lib/cjs/setting.js +3 -3
- package/lib/cjs/site-state.js +1 -1
- package/lib/es/add-component.js +274 -242
- package/lib/es/chunks/{draft-data-BtzZ0_tq.js → draft-data--WtLtXxy.js} +1 -1
- package/lib/es/chunks/{home-DBOWtpCK.js → home-BIH-BNIG.js} +3 -3
- package/lib/es/chunks/{index-CjNVgrdz.js → index-Cj977HLf.js} +1 -1
- package/lib/es/chunks/{publish-button-CFzWcpJ3.js → publish-button-Dn3ikSo5.js} +3 -3
- package/lib/es/chunks/{site-state-DYm1fKT3.js → site-state-BXM-5tZw.js} +5 -1
- package/lib/es/chunks/state-DS2djQbR.js +873 -0
- package/lib/es/home.js +3 -3
- package/lib/es/locales.js +20 -4
- package/lib/es/resources.js +1 -1
- package/lib/es/setting.js +829 -799
- package/lib/es/site-state.js +1 -1
- package/package.json +11 -11
- package/lib/cjs/chunks/state-BP5DoD6I.js +0 -1
- package/lib/es/chunks/state-Biqa_a5U.js +0 -685
package/lib/es/site-state.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import "./chunks/components-DLwSTd_N.js";
|
|
2
|
-
import { c as O, a as b, b as h, S as y, e as L, f as U, h as q, d as v, g as z, i as C, m as F, t as G, j as J, u as K } from "./chunks/site-state-
|
|
2
|
+
import { c as O, a as b, b as h, S as y, e as L, f as U, h as q, d as v, g as z, i as C, m as F, t as G, j as J, u as K } from "./chunks/site-state-BXM-5tZw.js";
|
|
3
3
|
import { nextId as Q } from "@blocklet/pages-kit/utils/common";
|
|
4
4
|
import "@blocklet/pages-kit/utils/page-model";
|
|
5
5
|
import "@blocklet/pages-kit/utils/property";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@blocklet/pages-kit-inner-components",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.73",
|
|
4
4
|
"description": "Pages Kit inner components library",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -69,21 +69,21 @@
|
|
|
69
69
|
"url": "git+https://github.com/blocklet/pages-kit.git"
|
|
70
70
|
},
|
|
71
71
|
"dependencies": {
|
|
72
|
-
"@arcblock/did-connect-react": "^3.1.
|
|
72
|
+
"@arcblock/did-connect-react": "^3.1.41",
|
|
73
73
|
"@arcblock/did-connect-storage-nedb": "^1.8.0",
|
|
74
|
-
"@arcblock/react-hooks": "^3.1.
|
|
75
|
-
"@arcblock/ux": "^3.1.
|
|
74
|
+
"@arcblock/react-hooks": "^3.1.41",
|
|
75
|
+
"@arcblock/ux": "^3.1.41",
|
|
76
76
|
"@blocklet/aigne-hub": "^0.3.29",
|
|
77
|
-
"@blocklet/aigne-sdk": "^0.5.
|
|
78
|
-
"@blocklet/code-editor": "^0.5.
|
|
77
|
+
"@blocklet/aigne-sdk": "^0.5.20",
|
|
78
|
+
"@blocklet/code-editor": "^0.5.20",
|
|
79
79
|
"@blocklet/embed": "^0.2.5",
|
|
80
80
|
"@blocklet/js-sdk": "^1.16.51",
|
|
81
81
|
"@blocklet/logger": "1.16.48",
|
|
82
|
-
"@blocklet/quickjs": "^0.5.
|
|
82
|
+
"@blocklet/quickjs": "^0.5.20",
|
|
83
83
|
"@blocklet/sdk": "^1.16.51",
|
|
84
|
-
"@blocklet/studio-ui": "^0.5.
|
|
84
|
+
"@blocklet/studio-ui": "^0.5.20",
|
|
85
85
|
"@blocklet/tracker": "^1.16.51",
|
|
86
|
-
"@blocklet/ui-react": "^3.1.
|
|
86
|
+
"@blocklet/ui-react": "^3.1.41",
|
|
87
87
|
"@blocklet/uploader": "^0.2.10",
|
|
88
88
|
"@blocklet/uploader-server": "^0.2.10",
|
|
89
89
|
"@dnd-kit/core": "^6.3.1",
|
|
@@ -201,8 +201,8 @@
|
|
|
201
201
|
"yaml": "^2.5.0",
|
|
202
202
|
"yjs": "^13.6.18",
|
|
203
203
|
"zustand": "^4.5.5",
|
|
204
|
-
"@blocklet/pages-kit": "^0.6.
|
|
205
|
-
"@blocklet/pages-kit-block-studio": "^0.6.
|
|
204
|
+
"@blocklet/pages-kit": "^0.6.73",
|
|
205
|
+
"@blocklet/pages-kit-block-studio": "^0.6.73"
|
|
206
206
|
},
|
|
207
207
|
"devDependencies": {
|
|
208
208
|
"@trivago/prettier-plugin-sort-imports": "^5.2.1",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";const ae=require("react/jsx-runtime"),_=require("ufo"),de=require("@blocklet/js-sdk"),ue=require("lodash/isEmpty"),le=require("yaml"),fe=require("@arcblock/ux/lib/Locale/context"),T=require("@blocklet/pages-kit/utils/common"),pe=require("@blocklet/pages-kit/utils/page-model");require("@mui/material");const X=require("@syncedstore/core"),ge=require("@syncedstore/react"),me=require("ahooks"),N=require("immer"),Se=require("lodash/cloneDeep"),Ie=require("lodash/debounce"),m=require("react"),Q=require("react-router-dom"),we=require("y-indexeddb"),Pe=require("y-websocket"),ye=require("yjs");require("@blocklet/pages-kit/types");const D=o=>o&&o.__esModule?o:{default:o};function he(o){if(o&&o.__esModule)return o;const n=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(o){for(const u in o)if(u!=="default"){const l=Object.getOwnPropertyDescriptor(o,u);Object.defineProperty(n,u,l.get?l:{enumerable:!0,get:()=>o[u]})}}return n.default=o,Object.freeze(n)}const Ce=D(ue),be=he(le),Oe=D(X),z=D(Se),Y=D(Ie);function H(){const{pathname:o}=window.location,u=o.match(/\/admin\/(maker|previewer)\/([^/]+)/)?.[2],l=window.__PROJECT_ID__;if(!u&&!l)throw new Error("Unable to get projectId from pathname");return u||l}function ve(o){return`${o}:pages:version`}function je(o,n){return n==="yaml"?Ce.default(o)?"":be.stringify(o,{indent:2}):n==="json"?JSON.parse(JSON.stringify(o||{})):n==="array"?JSON.parse(JSON.stringify(o||[])):o}const q=window.blocklet?.prefix||"/",U=de.createAxios({timeout:200*1e3}),xe=window.location.protocol==="https:"?"wss":"ws",Ee=o=>_.joinURL(`${xe}://${window.location.hostname}`,q,`api/${o}/ws/pages`),ke="z8ia1mAXo8ZE7ytGF36L5uBf9kD2kenhqFGp9";blocklet?.componentMountPoints.find(o=>o.did===ke)?.mountPoint||_.joinURL(q,"/image-bin");function Le(o){return o&&!/^(https?:\/\/|\/)/.test(o)?window.location.origin+_.joinURL(q,"uploads",o):o}const Me=window.innerWidth<=750;function Ne(o,n,u){if(!o||/\.gif/.test(o))return o;const l=(Me?n/1.5:n)*(u==="quality"?1.5:1);return _e(o,{imageFilter:"resize",w:l,f:"webp"})}function _e(o,n){return!o||!n?o:_.withQuery(o,n)}async function Re(o){return U.get(`/api/projects/${o}`).then(n=>n.data)}async function Te(o){return U.post(`/api/projects/${o.id}/update`,o).then(n=>n.data)}const Ae=500,Z=m.createContext(null);function De({url:o,name:n,children:u,waitingSynced:l}){const[C,P]=m.useState(!1),{locale:S}=fe.useLocaleContext(),y=J(),E=`${y}:MakerLocalState`,e=`${y}:${n}`,[t,r]=me.useLocalStorageState(E,{defaultValue:{},listenStorageChange:!0}),c=m.useRef(t);c.current=t;const a=m.useMemo(()=>Oe.default({dataSourceIds:[],dataSources:{},pages:{},pageIds:[],routes:{},routeIds:[],components:{},supportedLocales:[],config:{},resources:{}}),[]),s=m.useMemo(()=>X.getYjsDoc(a),[a]);m.useMemo(()=>new we.IndexeddbPersistence(e,s),[e,s]);const i=m.useMemo(()=>new Pe.WebsocketProvider(o,e,s,{params:{},resyncInterval:5*60*1e3}),[o,e,s]),d=m.useCallback(()=>{i&&(i.wsconnected?(i.disconnect(),setTimeout(()=>i.connect(),100)):i.connect())},[i]),f=m.useMemo(()=>new ye.UndoManager([s.getArray("pageIds"),s.getMap("pages"),s.getArray("supportedLocales"),s.getMap("config"),s.getMap("dataSources"),s.getArray("dataSourceIds"),s.getArray("routeIds"),s.getMap("routes")],{doc:s}),[s]),[w,I]=m.useState(null),[v,h]=m.useState(!1),[k,L]=m.useState(void 0),O=m.useCallback(async()=>{if(y){h(!0);try{const p=await Re(y);I(p)}catch(p){console.error("Failed to fetch project:",p)}finally{h(!1)}}},[y]),j=m.useCallback(async(p,g)=>{if(L(void 0),!!y){g?.optimisticUpdate&&w&&I(b=>({...b,...p}));try{const b=await Te({...p});I(b)}catch(b){console.error("Failed to update project:",b),g?.optimisticUpdate&&I(w),L(b?.response?.data)}}},[y,w]);m.useEffect(()=>{y&&O()},[y,O]);const x=m.useMemo(()=>({doc:s,state:a,localState:{...t,currentLocale:S},setLocalState:p=>r(typeof p=="function"?g=>p(g??{}):p),undoManager:f,projectState:{project:w,isLoadingProject:v,error:k},updateProject:j,forceSync:d}),[s,a,JSON.stringify(t),r,f,w,v,j,k,S,d]);return m.useEffect(()=>{f.on("stack-item-added",({stackItem:p})=>{const{currentPageId:g,currentLocale:b,pages:R}=c.current;p.meta.set("localState",{currentPageId:g,currentLocale:b,pages:R})}),f.on("stack-item-popped",({stackItem:p})=>{const g=p.meta.get("localState");g&&r(b=>({...b,...g}))})},[f,r]),m.useEffect(()=>{i.awareness.setLocalState(t)},[i,t]),m.useEffect(()=>{i.once("synced",()=>{P(!0)});let p=0,g=null;const b=3,R=5e3,B=15e3,A=()=>{p=0,r(M=>({...M,networkStatus:void 0}))},$=()=>{r(M=>({...M,networkStatus:"offline"}))},F=Y.default(({status:M})=>{if(M==="connected")A(),g&&(clearTimeout(g),g=null);else if(M==="disconnected"){if(p++,!g){const ce=Date.now();let V=0;const se=Math.ceil(B/R),K=()=>{V++;const ie=Date.now()-ce;if(i.wsconnected){A();return}if(ie>=B||V>=se){$();return}g=setTimeout(K,R)};g=setTimeout(K,R)}p>=b&&$()}},Ae),G=()=>{i.wsconnected||i.connect(),A()},W=()=>{$()};return i.on("status",F),window.addEventListener("online",G),window.addEventListener("offline",W),i.wsconnected&&A(),()=>{g&&clearTimeout(g),i.off("status",F),window.removeEventListener("online",G),window.removeEventListener("offline",W)}},[i,r]),l&&!C?null:ae.jsx(Z.Provider,{value:x,children:u})}const ee=()=>{const o=m.useContext(Z);if(!o)throw new Error("Context is null");const n=ge.useSyncedStore(o.state),{setLocalState:u,localState:l}=o,C=Q.useNavigate(),P=J(),S=m.useMemo(()=>({get currentPage(){const{localState:{currentPageId:e}}=o;return e?n.pages[e]:void 0},get currentSection(){const{localState:{currentPageId:e,...t}}=o;if(!e)return;const r=t.pages?.[e]?.currentSectionId;if(r)return n.pages[e]?.sections[r]??this.currentPageModel?.getComponentById(r)?.model},get currentSectionProperties(){const{localState:{currentPageId:e,...t}}=o;if(!e)return;const r=t.pages?.[e]?.currentSectionId;if(!r)return;const c=n.pages[e]?.dataSource?.[r];if(!c)return;const{currentLocale:a}=this.currentLocaleMap;return a?c[a]:void 0},get currentSectionPropertiesWithFallback(){const{localState:{currentPageId:e,...t}}=o;if(!e)return;const r=t.pages?.[e]?.currentSectionId;if(!r)return;const c=n.pages[e]?.dataSource?.[r];if(!c)return;const{currentLocale:a,defaultLocale:s,fallbackLocale:i}=this.currentLocaleMap;if(a&&c[a])return c[a];if(s&&c[s])return c[s];if(i&&c[i])return c[i]},get currentLocaleMap(){const{localState:{currentLocale:e},state:{supportedLocales:t,config:{defaultLocale:r}}}=o;return{currentLocale:e,defaultLocale:r,fallbackLocale:t?.[0]?.locale??"en"}},get currentRoute(){const{localState:{currentRouteId:e}}=o;return e?n.routes?.[e]:void 0},get currentPageModel(){const e=this.currentPage??null;if(e)return pe.getPageTemplateModel(e,!1)}}),[JSON.stringify(l),n]),y=m.useMemo(()=>({setCurrentSectionId:(e,t)=>{e===l.currentPageId&&t===l.pages?.[e]?.currentSectionId||(C(_.joinURL("/admin/maker",P??"","pages",e)),u(r=>N.produce(r,c=>{c.currentPageId=e,c.currentComponentId=void 0,c.pages??={},c.pages[e]??={},c.pages[e].currentSectionId=t??void 0,t?window.sessionStorage.setItem("iframe_show_id",`"${t}"`):window.sessionStorage.removeItem("iframe_show_id")})))},setCurrentComponentId:e=>{e!==l.currentComponentId&&(C(_.joinURL("/admin/maker",P??"","components",e)),u(t=>N.produce(t,r=>{r.currentComponentId=e})))},setCurrentRouteId:({routeId:e,dynamicParams:t})=>{u(r=>N.produce(r,c=>{c.currentRouteId=e,c.currentDynamicParams=t}))},setCustomComponentPreviewerProperties:(()=>{const e={};let t="";const r=Y.default(()=>{u(c=>N.produce(c,a=>{a.customComponentPreviewerProperties??={},a.customComponentPreviewerProperties[t]={...a.customComponentPreviewerProperties[t],...z.default(e[t])},delete e[t]}))},5);return(c,a)=>{const s=e[c]??{};Object.assign(s,a),e[c]=s,t=c,r()}})(),setRouteGenerateProcess:e=>{u(t=>N.produce(t,r=>{e?r.routeGenerateProcess={...r.routeGenerateProcess,...e}:r.routeGenerateProcess={}}))},resetRouteGenerateProcess:()=>{u(e=>N.produce(e,t=>{t.routeGenerateProcess={progress:"complete"}}))}}),[u,C,P,S]),E=m.useMemo(()=>({addPage:(e,t)=>{const r=e?.id??T.nextId(),c={...e,id:r,createdAt:e?.createdAt??new Date().toISOString(),updatedAt:e?.updatedAt??new Date().toISOString(),publishedAt:new Date(0).toISOString(),slug:e?.slug??`/${r}`,sections:e?.sections??{},sectionIds:e?.sectionIds??[],isPublic:e?.isPublic??!0,templateConfig:e?.templateConfig??{isTemplate:e?.templateConfig?.isTemplate??!0,displayTemplateId:e?.templateConfig?.displayTemplateId??void 0,dataSourceIds:e?.templateConfig?.dataSourceIds??void 0,dataSourceParameters:e?.templateConfig?.dataSourceParameters??{},enabledGenerate:e?.templateConfig?.enabledGenerate??!1,agentId:e?.templateConfig?.agentId??void 0}};return o.doc.transact(()=>{n.pages[c.id]=c,n.pageIds.splice(t??n.pageIds.length,0,c.id)}),c},addRoute:(e,t)=>{const r=e?.id??T.nextId(),c={...e,id:r,createdAt:e?.createdAt??new Date().toISOString(),updatedAt:e?.updatedAt??new Date().toISOString(),publishedAt:new Date(0).toISOString(),path:e?.path??`/${r}`,handler:e?.handler??"Pages Kit",isPublic:e?.isPublic??!0,params:e?.params??[],enabledGenerate:e?.enabledGenerate??!1,displayTemplateId:e?.displayTemplateId??void 0,dataSource:e?.dataSource??{}};return o.doc.transact(()=>{n.routes??={},n.routeIds??=[],n.routes[c.id]=c,n.routeIds.splice(t??n.routeIds.length,0,c.id)}),c},deleteRoute:e=>{if(!e)return;const t=n.routeIds?.indexOf(e);t!==void 0&&t!==-1&&o.doc.transact(()=>{n.routeIds?.splice(t,1),delete n.routes?.[e]})},deletePage:e=>{const t=n.pageIds.indexOf(e);t!==-1&&o.doc.transact(()=>{n.pageIds.splice(t,1),delete n.pages[e]})},movePage:(e,t)=>{const{pageIds:r}=n,c=r.indexOf(e);c>=0&&r.splice(t,0,...r.splice(c,1))},addSection:(e,t,r,c)=>{const a=n.pages[e];if(!a)throw new Error(`Page ${e} is not exists`);const s={...t,id:t.id??T.nextId(),isTemplateSection:t.isTemplateSection??!0},i=z.default(s.locales);return delete s.locales,o.doc.transact(()=>{if(c&&c.component==="layout-block"){const d=S.currentPageModel?.getComponentById(c.id);d&&(d.model.sections??={},d.model.sections[s.id]=s,d.model.sectionIds??=[],d.model.sectionIds.push(s.id))}else a.sections[s.id]=s,a.sectionIds.splice(r??a.sectionIds.length,0,s.id);i&&(a.dataSource??={},a.dataSource[s.id]=i)}),s},deleteSection:(e,t)=>{const r=n.pages[e];if(!r)throw new Error(`Page ${e} is not exists`);o.doc.transact(()=>{const c=[],a=S.currentPageModel?.getComponentById(t),s=a?.parent;if(a&&(c.push(a.model.id,...a.all().map(i=>i.model.id)),s?.model.component==="layout-block")){const i=s.model.sectionIds?.indexOf(t);i!==void 0&&i!==-1&&(s.model.sectionIds?.splice(i,1),delete s.model.sections?.[t]),s.model.config?.gridSettings&&Object.keys(s.model.config.gridSettings).forEach(d=>{try{delete s.model.config.gridSettings[d]?.[t]}catch{}}),s.model.config?.backgroundSectionId===t&&(s.model.config.backgroundSectionId=void 0)}c.forEach(i=>{const d=r.sectionIds.indexOf(i);d!==-1&&r.sectionIds.splice(d,1),r.sections[i]&&delete r.sections[i],r.dataSource?.[i]&&delete r.dataSource?.[i]})})},lockSection:(e,t)=>{if(!n.pages[e])throw new Error(`Page ${e} is not exists`);const c=S.currentPageModel?.getComponentById(t)?.model;c&&(c.locked=!c.locked)},toggleSectionVisibility:(e,t,r)=>{if(!n.pages[e])throw new Error(`Page ${e} is not exists`);const a=S.currentPageModel?.getComponentById(t)?.model;a&&(a.visibility=r)},moveSection:(e,t,r,c)=>{const a=n.pages[e];if(!a)throw new Error(`Page ${e} is not exists`);const s=S.currentPageModel;if(!s)throw new Error(`Page model for ${e} is not available`);const i=f=>{const w=s.getComponentById(f);if(!w)return null;const I=w.model,v=w.parent;if(!v)return{section:I,container:a,containerType:"root",index:a.sectionIds.indexOf(f)};const h=v.model;return{section:I,container:h,containerType:"layout-block",index:h.sectionIds.indexOf(f)}},d=i(t);if(!d)throw new Error(`Section ${t} not found`);o.doc.transact(()=>{if(r.startsWith("layout-")){const I=r.replace("layout-",""),h=s.getComponentById(I)?.model;if(!h||h.component!=="layout-block")throw new Error(`Layout block ${I} not found`);if(I===t||((O,j)=>{const x=s.getComponentById(O),p=s.getComponentById(j);if(!x||!p||x.model.component!=="layout-block")return!1;let g=p.parent;for(;g;){if(g.model.id===O)return!0;g=g.parent}return!1})(t,I))return;const L=JSON.parse(JSON.stringify(d.section));h.sections||(h.sections={}),h.sectionIds||(h.sectionIds=[]),h.sections[t]=L,h.sectionIds.push(t),d.container.sectionIds.splice(d.index,1),d.containerType==="layout-block"&&delete d.container.sections[t];return}const f=i(r);if(!f)throw new Error(`Target section ${r} not found`);let w=f.index;if(c==="bottom"&&(w=f.index+1),d.container===f.container){const{sectionIds:I}=d.container;I.splice(d.index,1),d.index<w&&(w-=1),I.splice(w,0,t)}else{const I=JSON.parse(JSON.stringify(d.section));f.containerType==="root"||(f.container.sections||(f.container.sections={}),f.container.sections[t]=I),f.container.sectionIds.splice(w,0,t),d.container.sectionIds.splice(d.index,1),d.containerType==="layout-block"&&delete d.container.sections[t]}})},copySection:(e,t)=>{if(!n.pages[e])throw new Error(`Page ${e} is not exists`);const c=S.currentPageModel?.getComponentById(t);if(!c?.model)throw new Error(`Section ${t} is not exists`);const a=JSON.parse(JSON.stringify(c.model)),s=re(a),i=s.id,d=c?.parent;if(d){if(d.model.sections[i]=s,d.model.sectionIds.push(i),S.currentPage?.dataSource?.[t]&&(S.currentPage.dataSource[i]=JSON.parse(JSON.stringify(S.currentPage.dataSource[t])),s.component==="layout-block")){const f=(w,I)=>{const v=w.sectionIds,h=I.sectionIds;v?.forEach((k,L)=>{const O=h?.[L];if(O){if(O&&S.currentPage?.dataSource){const p=S.currentPage.dataSource[O];p&&(S.currentPage.dataSource[k]=JSON.parse(JSON.stringify(p)))}const j=w.sections?.[k],x=I?.sections?.[O];j?.component==="layout-block"&&j.sectionIds&&x?.sectionIds&&f(j,x)}})};s.sectionIds&&a.sectionIds&&f(s,a)}y.setCurrentSectionId(e,i)}return s},addDataSource:e=>{const t=e.id??T.nextId(),r={...e??{},id:t,createdAt:new Date().toISOString()};return o.doc.transact(()=>{n.dataSourceIds??=[],n.dataSources??={},n.dataSourceIds.push(t),n.dataSources[t]=r}),n.dataSources[t]},deleteDataSource:e=>{const t=n.dataSourceIds.indexOf(e);t!==-1&&o.doc.transact(()=>{n.dataSourceIds.splice(t,1),delete n.dataSources[e]})}}),[n,o.doc,S]);return{...o,state:n,actions:E,localActions:y,...S}},J=()=>{const{projectId:o}=Q.useParams();return o??H()??""},$e=()=>window.__PROJECT_SLUG__??"";function te(o){const{resources:n}=o;if(!n.components)return{};const u={};return window?.blocklet?.componentMountPoints?.forEach(l=>{u[l.did]=l}),Object.fromEntries(Object.entries(n.components).map(([l,{blockletId:C,component:P}])=>[l,{data:P,blockletId:C,blockletTitle:u[C]?.title||C}]))}function oe(o){const{components:n}=o;return n||{}}function ne(o){return{...te(o),...oe(o)}}const qe=()=>ne(ee().state);function re(o){const n=JSON.parse(JSON.stringify(o)),u=T.nextId();if(n.component==="layout-block"){const l={...n.config??{}},C=n.sectionIds?.map(P=>{const S=n.sections?.[P],y=re(n.sections?.[P]),E=y.id;return S?.id===n.config?.backgroundSectionId&&(l.backgroundSectionId=y.id),n.config?.gridSettings&&Object.keys(n.config.gridSettings).forEach(e=>{l.gridSettings[e]={...l.gridSettings[e]??{},[E]:{...n.config?.gridSettings?.[e]?.[P],id:E}},delete n.config?.gridSettings?.[e]?.[P]}),y});n.sections=Object.fromEntries(C?.map(P=>[P.id,P])??[]),n.sectionIds=C?.map(P=>P.id)??[],n.config=l}return{...n,id:u}}exports.StoreProvider=De;exports.api=U;exports.autoResizeImage=Ne;exports.getAllComponents=ne;exports.getCustomComponents=oe;exports.getImageAbsoluteUrl=Le;exports.getProjectIdFromPathnameOrWindow=H;exports.getProjectPageVersionKey=ve;exports.getResourceComponents=te;exports.getWssURL=Ee;exports.transformValue=je;exports.useAllComponents=qe;exports.useProjectId=J;exports.useProjectSlug=$e;exports.useStore=ee;
|