@blocklet/pages-kit-inner-components 0.5.45 → 0.5.48
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 +19 -19
- package/lib/cjs/chunks/{array-Cip5uTnI.js → array-BqHuYyfx.js} +1 -1
- package/lib/cjs/chunks/{config-string-CEipCOnU.js → config-string-4bVR9Vc8.js} +1 -1
- package/lib/cjs/chunks/{draft-data-F0V4PcIs.js → draft-data-CuZfaQ4s.js} +1 -1
- package/lib/cjs/chunks/{home-BCFoaIEZ.js → home-CQTuGad2.js} +3 -3
- package/lib/cjs/chunks/{publish-button-Bbd4z1_d.js → publish-button-1xmfwN7o.js} +1 -1
- package/lib/cjs/chunks/site-state-BtZ8o3J2.js +57 -0
- package/lib/cjs/chunks/state-BVdbNJCA.js +1 -0
- package/lib/cjs/components.js +1 -1
- package/lib/cjs/home.js +1 -1
- package/lib/cjs/locales.js +2 -2
- package/lib/cjs/project-html.js +1 -1
- package/lib/cjs/resources.js +1 -1
- package/lib/cjs/setting.js +3 -3
- package/lib/cjs/site-state.js +1 -1
- package/lib/cjs/theme.js +1 -1
- package/lib/es/add-component.js +18 -17
- package/lib/es/chunks/{array-DM0x2Sjw.js → array-c6HYTLze.js} +1 -1
- package/lib/es/chunks/{config-string-Dw6sJMn_.js → config-string-WMpFf-7V.js} +1 -1
- package/lib/es/chunks/{draft-data-sTSk4UTm.js → draft-data-CWM--ooz.js} +1 -1
- package/lib/es/chunks/{home-ClxOpmCx.js → home-DQjaiv2F.js} +4 -4
- package/lib/es/chunks/{publish-button-CKXdANG9.js → publish-button-wYeS7m-g.js} +3 -3
- package/lib/es/chunks/{site-state-BeEHvakk.js → site-state-D-moj9fA.js} +527 -550
- package/lib/es/chunks/{state-COB6reM7.js → state-l--dTdHq.js} +87 -88
- package/lib/es/components.js +1 -1
- package/lib/es/home.js +3 -3
- package/lib/es/locales.js +2 -2
- package/lib/es/project-html.js +1 -1
- package/lib/es/resources.js +1 -1
- package/lib/es/setting.js +94 -93
- package/lib/es/site-state.js +6 -5
- package/lib/es/theme.js +34 -34
- package/package.json +7 -7
- package/lib/cjs/chunks/site-state-CeQEnrvX.js +0 -57
- package/lib/cjs/chunks/state-UwRWAZRe.js +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";var It=Object.create;var lt=Object.defineProperty;var Rt=Object.getOwnPropertyDescriptor;var Tt=Object.getOwnPropertyNames;var Wt=Object.getPrototypeOf,zt=Object.prototype.hasOwnProperty;var Pt=(t,e,i,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of Tt(e))!zt.call(t,r)&&r!==i&<(t,r,{get:()=>e[r],enumerable:!(n=Rt(e,r))||n.enumerable});return t};var Et=(t,e,i)=>(i=t!=null?It(Wt(t)):{},Pt(e||!t||!t.__esModule?lt(i,"default",{value:t,enumerable:!0}):i,t));const o=require("react/jsx-runtime"),qt=require("@mui/icons-material"),m=require("@mui/material"),Lt=require("lodash/isEmpty"),At=require("lodash/pick"),b=require("react"),Ot=require("lodash/keyBy"),k=require("./state-
|
|
1
|
+
"use strict";var It=Object.create;var lt=Object.defineProperty;var Rt=Object.getOwnPropertyDescriptor;var Tt=Object.getOwnPropertyNames;var Wt=Object.getPrototypeOf,zt=Object.prototype.hasOwnProperty;var Pt=(t,e,i,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of Tt(e))!zt.call(t,r)&&r!==i&<(t,r,{get:()=>e[r],enumerable:!(n=Rt(e,r))||n.enumerable});return t};var Et=(t,e,i)=>(i=t!=null?It(Wt(t)):{},Pt(e||!t||!t.__esModule?lt(i,"default",{value:t,enumerable:!0}):i,t));const o=require("react/jsx-runtime"),qt=require("@mui/icons-material"),m=require("@mui/material"),Lt=require("lodash/isEmpty"),At=require("lodash/pick"),b=require("react"),Ot=require("lodash/keyBy"),k=require("./state-BVdbNJCA.js"),J=require("@blocklet/ai-runtime/components"),Ut=require("@mui/utils"),Mt=require("react-error-boundary"),Ft=require("@blocklet/pages-kit/builtin/markdown/markdown-renderer"),yt=require("@blocklet/pages-kit/contexts/color"),_=require("@emotion/css"),Ht=require("react-syntax-highlighter/dist/esm/styles/prism"),$=require("@arcblock/ux/lib/Theme"),Vt=require("@arcblock/react-hooks/lib/useBrowser"),Dt=require("@arcblock/ux/lib/Colors"),et=require("@blocklet/pages-kit/components"),ct=require("@blocklet/pages-kit/utils/style"),Yt=require("@mui/material/useMediaQuery"),Jt=require("lodash/omit"),bt=require("@iconify-icon/react"),Gt=require("@arcblock/ux/lib/Screenshot"),ot=require("react-router-dom"),Kt=require("@arcblock/ux/lib/Button"),Xt=require("is-uri"),G=require("pathe"),q=require("ufo"),Qt=require("@blocklet/embed/message"),Zt=require("ahooks"),te=require("lodash/isEqual"),ee=require("@blocklet/embed/react"),oe=require("@arcblock/ux/lib/Locale/context"),ne=require("react-twitter-embed"),dt=require("react-use"),C=t=>t&&t.__esModule?t:{default:t},re=C(Lt),X=C(At),ie=C(b),Q=C(Ot),se=C(Ft),ae=C(Vt),ut=C(Dt),wt=C(Yt),R=C(Jt),le=C(Gt),ce=C(Kt),Z=C(Xt),de=C(te),jt="{{CUSTOM_VALUE}}",ue=[{title:"None",value:"none",sx:{py:0}},{title:"Small",value:"small",sx:{py:{xs:2.5,md:4,lg:4,xl:6}}},{title:"Normal",value:"normal",sx:{py:{xs:5,md:7.5,lg:10,xl:12.5}}},{title:"Large",value:"large",sx:{py:{xs:7.5,md:10,lg:12.5,xl:15}}}],me=[{title:"None",value:"none",sx:{py:0}},{title:"Small",value:"small",sx:{py:{xs:2.5,md:4,lg:4,xl:6}}},{title:"Normal",value:"normal",sx:{py:{xs:5,md:7,lg:7,xl:9}}},{title:"Large",value:"large",sx:{py:{xs:6,md:9,lg:9,xl:11}}}],xe=[{title:"None",value:"none",sx:{px:0}},{title:"Small",value:"small",sx:{px:{xs:2,md:4,lg:4,xl:6}}},{title:"Normal",value:"normal",sx:{px:{xs:2.5,md:7.5,lg:10,xl:12.5}}},{title:"Large",value:"large",sx:{px:{xs:2.5,md:10,lg:12.5,xl:15}}}],K=(t,e,i)=>{const n=t.breakpoints.values[i];return`${e}${n?` (${n}px)`:""}`},pe=[{title:"100%",value:"full",sx:{maxWidth:"100%"}},{title:t=>K(t,"Small","sm"),value:"sm",sx:{maxWidth:t=>t.breakpoints.values.sm,width:"100%",mx:"auto"}},{title:t=>K(t,"Normal","md"),value:"md",sx:{maxWidth:t=>t.breakpoints.values.md,width:"100%",mx:"auto"}},{title:t=>K(t,"Large","lg"),value:"lg",sx:{maxWidth:t=>t.breakpoints.values.lg,width:"100%",mx:"auto"}},{title:t=>K(t,"Extra Large","xl"),value:"xl",sx:{maxWidth:t=>t.breakpoints.values.xl,width:"100%",mx:"auto"}},{title:"Custom",value:"custom",sx:{maxWidth:jt,width:"100%",mx:"auto"}}],he=Q.default(ue,"value"),fe=Q.default(me,"value"),ge=Q.default(xe,"value"),ye=Q.default(pe,"value"),be=new Map([["baseSectionPaddingY",he],["maxWidth",ye],["paddingY",fe],["paddingX",ge]]);function _t(t){var l;const{type:e,value:i,format:n="sx",defaultValue:r=null}=t,a=be.get(e);if(!a)return r;const d=i.startsWith("custom:"),s=d?"custom":i;if(a!=null&&a[s]&&((l=a==null?void 0:a[s])!=null&&l[n])){const c=a[s][n];if(d){const x=i.replace("custom:","");try{return JSON.parse(JSON.stringify(c||{}).replaceAll(jt,x))}catch{}}return c}return r}const vt=b.createContext({page:null,getPageMeta:()=>({}),getPageMetaStyle:()=>({})});function we(){return b.useContext(vt)}function je({page:t,children:e,defaultLocale:i="en",currentLocale:n}){const r=b.useMemo(()=>t?JSON.parse(JSON.stringify(t)):null,[JSON.stringify(t)]),a=b.useCallback(()=>{var c;if(!r)return{};const l=n||i;return((c=r.locales)==null?void 0:c[l])??{}},[r,i,n]),d=b.useCallback((l="sx")=>{const c=a();return!c||!c.style?{}:Object.entries(c.style||{}).reduce((u,[h,p])=>{if(!p)return u;const y=`${h}Custom`;c.style[y];const f=_t({type:h,value:p,format:l});return f?{...u,...f}:u},{})},[a]),s=b.useMemo(()=>({page:r,getPageMeta:a,getPageMetaStyle:d}),[r,a,d]);return o.jsx(vt.Provider,{value:s,children:e})}function E({actions:t,center:e,className:i,align:n}){return t&&(t!=null&&t.length)?o.jsx(m.Box,{className:_.cx("flex gap-4 flex-wrap","lg:flex-row lg:gap-8",(e||n==="center")&&"justify-center",!e&&n==="right"&&"justify-end",!e&&n==="left"&&"justify-start",i),sx:{alignItems:"center"},children:t}):null}const _e="section",ve=m.styled(m.Box)`
|
|
2
2
|
overflow: hidden;
|
|
3
3
|
|
|
4
4
|
.section__title {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const i=require("react/jsx-runtime"),s=require("@blocklet/pages-kit/builtin/uploader"),h=require("@iconify-icon/react"),n=require("@mui/material"),l=require("react"),q=require("react-use"),I=require("./state-
|
|
1
|
+
"use strict";const i=require("react/jsx-runtime"),s=require("@blocklet/pages-kit/builtin/uploader"),h=require("@iconify-icon/react"),n=require("@mui/material"),l=require("react"),q=require("react-use"),I=require("./state-BVdbNJCA.js"),v=l.forwardRef(function({showMarkdown:S,markdown:j,onMarkdownChange:o,showUploader:p,value:c,meta:A,onChange:a,...u},z){const[t,m]=l.useState("");l.useEffect(()=>{m(c||"")},[c,m]);const f=async()=>{if(t!==c){const e=I.getImageAbsoluteUrl(t);if(!e){a(t,void 0);return}const r=await s.getImageSize(e).catch(()=>s.getVideoSize(e)).catch(()=>{});a(t,{...r,filename:t})}};q.useDebounce(()=>{t!==c&&a(t)},300,[t]),l.useImperativeHandle(z,()=>({submit:f}));const g={};return p&&(g.InputProps={sx:{pr:0},endAdornment:i.jsx(n.InputAdornment,{position:"end",sx:{mx:.5},children:i.jsx(s.UploaderButton,{onChange:async({response:e})=>{var b;const r=(b=e==null?void 0:e.data)==null?void 0:b.filename,d=I.getImageAbsoluteUrl(r)||"";let x={};d&&(x=await s.getImageSize(d).catch(()=>s.getVideoSize(d)).catch(()=>{})),a(r,{...x,filename:r})}})})}),i.jsx(n.TextField,{size:"small",fullWidth:!0,...u,label:i.jsxs(n.Stack,{direction:"row",spacing:1,alignItems:"center",children:[u.label,S&&i.jsxs(i.Fragment,{children:[" (",i.jsx(n.FormControlLabel,{checked:j,label:i.jsx(n.Box,{component:h.Icon,icon:"tabler:markdown",sx:{verticalAlign:"middle"}}),labelPlacement:"start",control:i.jsx(n.Switch,{size:"small"}),sx:{ml:.25,pr:1},onChange:(e,r)=>o==null?void 0:o(r)}),")"]})]}),InputLabelProps:{shrink:!0,...u.InputLabelProps},value:t,onChange:e=>m(e.target.value),...g,onKeyDown:e=>{e.keyCode!==229&&e.key==="Enter"&&f()}})});exports.ConfigString=v;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("react/jsx-runtime"),t=require("./state-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("react/jsx-runtime"),t=require("./state-BVdbNJCA.js");function n({children:e}){const r=t.useProjectId();return s.jsx(t.StoreProvider,{url:t.getWssURL(r??""),name:"root",waitingSynced:!0,children:s.jsx(o,{children:e})})}function o({children:e}){const{state:r}=t.useStore();return e({state:r})}exports.default=n;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";const e=require("react/jsx-runtime"),R=require("./state-
|
|
1
|
+
"use strict";const e=require("react/jsx-runtime"),R=require("./state-BVdbNJCA.js"),X=require("@arcblock/ux/lib/Locale/context"),ue=require("@arcblock/ux/lib/Result"),de=require("@blocklet/pages-kit/builtin/page/header"),pe=require("@blocklet/pages-kit/contexts/color"),Z=require("@blocklet/pages-kit/utils/data-source"),ge=require("@blocklet/pages-kit/utils/route"),me=require("@blocklet/ui-react/lib/Header"),fe=require("@emotion/css"),V=require("@emotion/react"),he=require("@emotion/styled"),y=require("@mui/material"),ee=require("ahooks"),xe=require("isomorphic-dompurify"),je=require("lodash/cloneDeep"),be=require("lodash/isEmpty"),ye=require("lodash/isEqual"),g=require("react"),ve=require("react-helmet"),w=require("react-router-dom"),te=require("react-use"),_=require("ufo"),E=require("./array-BqHuYyfx.js"),W=require("@arcblock/ux/lib/Theme"),Pe=require("@blocklet/ui-react/lib/Footer");require("webfontloader");const Q=require("./session-BA7Qrcia.js"),q=t=>t&&t.__esModule?t:{default:t},ne=q(ue),we=q(me),oe=q(he),ke=q(xe),z=q(je),Se=q(be),re=q(ye),Re=q(Pe),qe=W.styled(Re.default,{shouldForwardProp:t=>!!t})`
|
|
2
2
|
& > div > .MuiContainer-root {
|
|
3
3
|
max-width: unset;
|
|
4
4
|
}
|
|
@@ -26,11 +26,11 @@
|
|
|
26
26
|
font-family: ${c};
|
|
27
27
|
}
|
|
28
28
|
}
|
|
29
|
-
`})}function Te(){const[t]=w.useSearchParams(),{session:o}=Q.useSessionContext(),a=Q.useIsRoleOrMultiTenant("owner","admin","pagesEditor","member"),i=g.useMemo(()=>{const n=t.get("mode");return E.STATE_MODES.includes(n)?n:"production"},[t]),c=i==="production"?i:o.user?a?i:"production":null;return c?e.jsx(ae,{mode:c}):null}function ae({mode:t}){if(t!=="draft"){const o=window.__PAGE_STATE__;return o?e.jsx(N,{mode:t,state:o}):e.jsx(Le,{mode:t,children:({state:a})=>e.jsx(N,{mode:t,state:a})})}return e.jsx(Be,{children:({state:o})=>e.jsx(N,{mode:t,state:o})})}const Be=g.lazy(()=>Promise.resolve().then(()=>require("./draft-data-
|
|
29
|
+
`})}function Te(){const[t]=w.useSearchParams(),{session:o}=Q.useSessionContext(),a=Q.useIsRoleOrMultiTenant("owner","admin","pagesEditor","member"),i=g.useMemo(()=>{const n=t.get("mode");return E.STATE_MODES.includes(n)?n:"production"},[t]),c=i==="production"?i:o.user?a?i:"production":null;return c?e.jsx(ae,{mode:c}):null}function ae({mode:t}){if(t!=="draft"){const o=window.__PAGE_STATE__;return o?e.jsx(N,{mode:t,state:o}):e.jsx(Le,{mode:t,children:({state:a})=>e.jsx(N,{mode:t,state:a})})}return e.jsx(Be,{children:({state:o})=>e.jsx(N,{mode:t,state:o})})}const Be=g.lazy(()=>Promise.resolve().then(()=>require("./draft-data-CuZfaQ4s.js")));function Le({mode:t,children:o}){const a=document.querySelector('meta[property="pages:version"]'),i=a==null?void 0:a.content,c=R.useProjectId(),n=g.useMemo(()=>{if(i==="{{pagesPublishedAt}}"){const u=localStorage.getItem(R.getProjectPageVersionKey(c??""));return Number(u)?Number(u):new Date().getTime()}return Number(i)},[i]),{loading:m,value:r}=te.useAsync(()=>E.getPages({mode:t,version:n}),[t,n]);return m?e.jsx(se,{}):r?o({state:r}):null}function N({mode:t,state:o}){const{t:a,locale:i}=X.useLocaleContext(),[c]=w.useSearchParams(),n=R.useProjectId(),m=R.useProjectSlug(),r=c.get("hiddenBadge")==="true",u=c.get("showPublish")==="true",{pageIds:f,pages:l,routeIds:p,routes:h,supportedLocales:j,config:{defaultLocale:b},resources:I}=o,x=R.getAllComponents(o),k=g.useMemo(()=>j!=null&&j.some(d=>d.locale===i)?i:void 0,[i,j]),L=Object.values(h||{}).find(d=>(d==null?void 0:d.path)==="/")||Object.values(l).find(d=>(d==null?void 0:d.slug)==="/")?void 0:Object.values(l)[0],U=g.useMemo(()=>t==="production"?f.map(d=>{const s=l[d];return s&&{id:s.id,path:_.joinURL("/",m||n||"",s.slug)}}).filter(E.nonNullable):p.map(d=>{const s=h[d];return s?{id:s.id,path:_.joinURL("/",m||n||"",s.path,`?mode=${t}&showPublish=true`)}:null}).filter(E.nonNullable),[f,l,t,h,p,n,m]),C=([...d])=>(t!=="production"&&u&&d.unshift(e.jsx(g.Suspense,{fallback:e.jsx("div",{}),children:e.jsx(De,{mode:"production",state:o})})),d);return e.jsxs(E.Provider,{value:{pages:U},children:[e.jsxs(w.Routes,{children:[L&&e.jsx(w.Route,{index:!0,element:e.jsx(w.Navigate,{to:_.joinURL("/",k||"",L.slug)})}),p==null?void 0:p.map(d=>{var P,v,S,A;const s=h==null?void 0:h[d];if(!s||!s.displayTemplateId)return null;const M=l[s.displayTemplateId];if(!M)return null;let T=[];if(s.params&&s.params.length>0){const B=ge.generateParamCombinations({basePath:s.path,params:s.params,routeId:s.id,paramsOptions:s.paramsOptions,currentIndex:0,currentParams:[],currentOptionIds:[],result:[]});T=B==null?void 0:B.map(O=>{var F,Y,K,J;const D=O.paramOptionIds.join("-");return e.jsx(w.Route,{path:_.joinURL(":projectIdOrSlug?",O.path),element:e.jsx(G,{mode:t,components:x,page:M,locale:k,defaultLocale:b,headerAddons:C,state:o,pageData:(J=(K=(Y=(F=s.dataSource)==null?void 0:F.pathDataMappings)==null?void 0:Y[D])==null?void 0:K.dataCache)==null?void 0:J[k||b||"en"]})},D)})}return T.push(e.jsx(w.Route,{path:_.joinURL(":projectIdOrSlug?",s.path),element:e.jsx(G,{mode:t,components:x,page:M,locale:k,defaultLocale:b,headerAddons:C,state:o,pageData:(A=(S=(v=(P=s.dataSource)==null?void 0:P.pathDataMappings)==null?void 0:v[s.id])==null?void 0:S.dataCache)==null?void 0:A[k||b||"en"]})},s.id)),T}),f.map(d=>{const s=l[d];return s?e.jsx(w.Route,{path:_.joinURL(":projectIdOrSlug?",s.slug),element:e.jsx(H,{mode:t,components:x,page:s,locale:k,defaultLocale:b,headerAddons:C})},s.id):null}),I.pages&&Object.values(I.pages).map(({blockletId:d,page:s})=>e.jsx(w.Route,{path:_.joinURL("/",`@${d}`,s.slug),element:e.jsx(H,{mode:t,components:x,page:s,locale:k,defaultLocale:b,headerAddons:C})},s.id)),e.jsx(w.Route,{path:"*",element:e.jsx(y.Box,{width:"100vw",height:"100vh",display:"flex",justifyContent:"center",alignItems:"center",children:e.jsx(ne.default,{status:404,extra:e.jsx(le,{href:"/",children:a("common.back")}),sx:{bgcolor:"transparent",width:"100%",height:"100%"}})})})]}),t!=="production"&&!r&&e.jsx(_e,{sx:{bgcolor:"info.light"},children:t}),e.jsx(Me,{})]})}function G({mode:t,pageData:o,components:a,page:i,locale:c,defaultLocale:n,headerAddons:m,state:r}){const u=ee.useReactive({page:null});g.useEffect(()=>{const l=i||null;l?u.page=z.default(l):u.page=null},[i,JSON.stringify(i),u]);const f=g.useRef();return g.useEffect(()=>{re.default(o,f.current)||o&&u.page&&(Z.setPageDataSource(u.page,r,c,o),f.current=z.default(o))},[u.page,o,c,r]),u.page?e.jsx(H,{mode:t,components:a,page:u.page,locale:c,defaultLocale:n,headerAddons:m}):null}function Oe({mode:t,state:o,path:a,pageData:i}){const{t:c,locale:n}=X.useLocaleContext(),{pages:m,supportedLocales:r,config:{defaultLocale:u},resources:f}=o,l=Object.values(m).find(x=>(x==null?void 0:x.slug)===a),p=Object.values(f.pages||{}).find(x=>x.page.slug===a),h=g.useMemo(()=>r!=null&&r.some(x=>x.locale===n)?n:void 0,[n,r]),j=ee.useReactive({page:null});g.useEffect(()=>{const x=l||(p==null?void 0:p.page)||null;x?j.page=z.default(x):j.page=null},[l,p]);const b=g.useRef();if(g.useEffect(()=>{re.default(i,b.current)||i&&j.page&&(Z.setPageDataSource(j.page,o,h,i),b.current=z.default(i))},[{}]),!l&&!(p!=null&&p.page))return e.jsx(y.Box,{width:"100vw",height:"100vh",display:"flex",justifyContent:"center",alignItems:"center",children:e.jsx(ne.default,{style:{background:"inherit"},status:404,extra:e.jsx(le,{href:"/",children:c("common.back")})})});const I=R.getAllComponents(o);return j.page?e.jsx(H,{mode:t,components:I,page:j.page,locale:h,defaultLocale:u}):null}function H({mode:t,components:o,page:a,locale:i,defaultLocale:c,headerAddons:n}){var k,$,L,U,C,d,s,M,T;const m=pe.useColorConvert(),r=((k=a.locales)==null?void 0:k[i])??(($=a.locales)==null?void 0:$[c])??{},u=r.title||((L=window.blocklet)==null?void 0:L.appName),f=r.description||((U=window.blocklet)==null?void 0:U.appDescription),l=R.autoResizeImage(R.getImageAbsoluteUrl(r.image),540),{logo:p,brand:h,description:j,...b}=de.useHeaderState(),I=g.useMemo(()=>P=>{var S;let v=(n==null?void 0:n(P))??P;return v=((S=b.addons)==null?void 0:S.call(b,v))??v,v},[b.addons,n]),x=(C=r.header)!=null&&C.translucent?ce:ie;return e.jsxs(E.PageProvider,{page:a,defaultLocale:c,currentLocale:i,children:[e.jsx(V.Global,{styles:V.css`
|
|
30
30
|
body {
|
|
31
31
|
background-color: ${m(!r.backgroundColor||r.backgroundColor==="transparent"?"background.default":r.backgroundColor)} !important;
|
|
32
32
|
}
|
|
33
|
-
`}),e.jsx(x,{hideNavMenu:!!((d=r.header)!=null&&d.hideNavMenus),translucentTextColor:(s=r.header)==null?void 0:s.translucentTextColor,...p?{logo:p}:{},...h?{brand:h}:{},...j?{description:j}:{},className:fe.cx(((M=r.header)==null?void 0:M.sticky)&&"sticky","page-header"),maxWidth:!1,addons:I}),e.jsx(w.ScrollRestoration,{}),e.jsxs(ve.Helmet,{children:[e.jsx("title",{children:u}),e.jsx("meta",{name:"og:title",content:u}),e.jsx("meta",{name:"og:description",content:f}),e.jsx("meta",{name:"og:image",content:l}),e.jsx("meta",{name:"twitter:image:src",content:l}),e.jsx("meta",{name:"twitter:image",content:l}),e.jsx("meta",{property:"twitter:description",content:f}),e.jsx("meta",{property:"twitter:title",content:u}),e.jsx("meta",{name:"description",content:f})]}),e.jsx(y.Stack,{flexGrow:1,className:"PageView-root",sx:{"& .BlockBase-root:first-child":{pt:"0 !important"}},children:a.sectionIds.map(P=>{var B,O,D,F;const v=a.sections[P];if(!v||v.visibility==="hidden")return null;const S=(O=(B=a.dataSource)==null?void 0:B[P])==null?void 0:O[i],A=((F=(D=a.dataSource)==null?void 0:D[P])==null?void 0:F[c])??{};return e.jsx(E.BlockRenderer,{id:P,type:v.component,mode:t,section:v,config:{...Se.default(S)?A:S,locale:i,dev:t==="draft"?{mode:t,components:o,defaultLocale:c}:{mode:t,defaultLocale:c}},page:a},P)})}),!((T=r.footer)!=null&&T.hidden)&&e.jsx(Ce,{})]})}const De=g.lazy(()=>Promise.resolve().then(()=>require("./publish-button-
|
|
33
|
+
`}),e.jsx(x,{hideNavMenu:!!((d=r.header)!=null&&d.hideNavMenus),translucentTextColor:(s=r.header)==null?void 0:s.translucentTextColor,...p?{logo:p}:{},...h?{brand:h}:{},...j?{description:j}:{},className:fe.cx(((M=r.header)==null?void 0:M.sticky)&&"sticky","page-header"),maxWidth:!1,addons:I}),e.jsx(w.ScrollRestoration,{}),e.jsxs(ve.Helmet,{children:[e.jsx("title",{children:u}),e.jsx("meta",{name:"og:title",content:u}),e.jsx("meta",{name:"og:description",content:f}),e.jsx("meta",{name:"og:image",content:l}),e.jsx("meta",{name:"twitter:image:src",content:l}),e.jsx("meta",{name:"twitter:image",content:l}),e.jsx("meta",{property:"twitter:description",content:f}),e.jsx("meta",{property:"twitter:title",content:u}),e.jsx("meta",{name:"description",content:f})]}),e.jsx(y.Stack,{flexGrow:1,className:"PageView-root",sx:{"& .BlockBase-root:first-child":{pt:"0 !important"}},children:a.sectionIds.map(P=>{var B,O,D,F;const v=a.sections[P];if(!v||v.visibility==="hidden")return null;const S=(O=(B=a.dataSource)==null?void 0:B[P])==null?void 0:O[i],A=((F=(D=a.dataSource)==null?void 0:D[P])==null?void 0:F[c])??{};return e.jsx(E.BlockRenderer,{id:P,type:v.component,mode:t,section:v,config:{...Se.default(S)?A:S,locale:i,dev:t==="draft"?{mode:t,components:o,defaultLocale:c}:{mode:t,defaultLocale:c}},page:a},P)})}),!((T=r.footer)!=null&&T.hidden)&&e.jsx(Ce,{})]})}const De=g.lazy(()=>Promise.resolve().then(()=>require("./publish-button-1xmfwN7o.js"))),ie=oe.default(we.default)`
|
|
34
34
|
&.sticky {
|
|
35
35
|
position: sticky;
|
|
36
36
|
top: 0;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),F=require("./state-UwRWAZRe.js"),W=require("@arcblock/ux/lib/Locale/context"),ee=require("@arcblock/ux/lib/Toast"),te=require("@blocklet/pages-kit/utils/route"),O=require("@mui/icons-material"),J=require("@mui/lab"),s=require("@mui/material"),se=require("immer"),ne=require("lodash/difference"),l=require("react"),ie=require("react-use"),re=require("./home-BCFoaIEZ.js"),U=require("./array-Cip5uTnI.js"),G=r=>r&&r.__esModule?r:{default:r},$=G(ee),H=G(ne);function oe(r){const[j,k]=l.useState(!1);return e.jsx(J.LoadingButton,{...r,loading:r.loading||j,onClick:u=>{var b;const p=(b=r.onClick)==null?void 0:b.call(r,u);p instanceof Promise&&(k(!0),p.finally(()=>{k(!1)}))}})}const ae=s.createSvgIcon(e.jsxs("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[e.jsx("path",{d:"M7.75732 16.2426L16.2426 7.75736",stroke:"#4B5563",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"}),e.jsx("path",{d:"M16.2426 16.2426L7.75732 7.75735",stroke:"#4B5563",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})]}),"Close");function le(){const[r,j]=l.useState(),k=l.useMemo(()=>r?e.jsx(s.Dialog,{...r}):null,[r]),u=l.useCallback(()=>{j(void 0)},[]),p=l.useCallback(({title:b,content:d,cancelText:S="Cancel",okText:f="Ok",onOk:g,onClose:c,okIcon:P,okColor:w="primary",cancelColor:y="primary",DialogContentProps:A,form:E,...z})=>{j({...z,open:!0,children:e.jsxs("form",{onSubmit:v=>v.preventDefault(),children:[b&&e.jsxs(s.DialogTitle,{className:"between",zIndex:"appBar",bgcolor:"background.paper",sx:{borderBottom:v=>`1px solid ${v.palette.divider}`},children:[e.jsx(s.Box,{children:b}),e.jsx(s.IconButton,{size:"small",onClick:async()=>{u(),c==null||c()},children:e.jsx(ae,{})})]}),d&&e.jsx(s.DialogContent,{...A,sx:{mt:-3,...A==null?void 0:A.sx},children:e.jsx(s.Box,{pt:3,children:d})}),e.jsxs(s.DialogActions,{children:[e.jsx(s.Button,{variant:"outlined",color:y||"primary",onClick:c??u,children:S}),e.jsx(oe,{variant:"contained",color:w||"primary",startIcon:P,loadingPosition:P?"start":"center",onClick:async()=>{await(g==null?void 0:g()),u()},type:"submit",children:f})]})]}),onClose:c??u})},[u]);return{dialog:k,showDialog:p,closeDialog:u}}const ce=l.forwardRef(({mode:r,state:j},k)=>{const{t:u}=W.useLocaleContext(),[p,b]=l.useState(!1),{dialog:d,showDialog:S}=le(),f=F.useProjectId(),g=l.useCallback(P=>{let w=[];S({title:u("maker.publishToProduction"),content:e.jsxs(s.Box,{sx:{minWidth:300},children:[e.jsx(s.Alert,{color:"warning",icon:e.jsx(O.Warning,{}),children:u("maker.publishToProductionTip")}),e.jsx(s.Box,{maxHeight:"50vh",overflow:"auto",mt:2,children:e.jsx(de,{state:j,toMode:r,onChange:y=>w=y,defaultRouteIds:P})})]}),okText:u("maker.publish"),cancelText:u("common.cancel"),onOk:async()=>{if((w==null?void 0:w.length)===0){const y=u("maker.publishSelectPagesMessage");throw $.default.error(y),new Error(y)}localStorage.setItem(F.getProjectPageVersionKey(f??""),String(new Date().getTime())),b(!0);try{await U.publishPages({mode:r,routes:w}),$.default.success(u("maker.publishSuccessMessage"))}catch(y){throw $.default.error(y.message),y}finally{b(!1)}}})},[r,j,u,f,S]);l.useImperativeHandle(k,()=>({openPublishDialog:g}));const c=l.useCallback(()=>{g()},[g]);return e.jsxs(e.Fragment,{children:[e.jsx(J.LoadingButton,{color:"primary",variant:"contained",size:"small",sx:{mr:1},onClick:c,loading:p,disabled:p,children:u("maker.publish")}),d]})});function ue({routePathInfo:r,checked:j,onClick:k,route:u}){var d,S,f,g,c;const{t:p}=W.useLocaleContext(),b=!((d=r.routeMetaData)!=null&&d.publishedAt)||((S=r.routeMetaData)==null?void 0:S.updatedAt)&&new Date((f=r.routeMetaData)==null?void 0:f.updatedAt)>new Date((g=r.routeMetaData)==null?void 0:g.publishedAt);return e.jsx(s.ListItem,{sx:{pl:4,pr:3},disablePadding:!0,secondaryAction:e.jsxs(s.Box,{display:"flex",alignItems:"center",sx:{minWidth:"auto"},children:[b&&e.jsx(s.Box,{mr:.35,className:"visible",color:"warning.main",sx:{display:"flex",alignItems:"center"},title:p("maker.pages.needPublish"),children:e.jsx(s.Tooltip,{title:p("maker.pages.needPublish"),children:e.jsx(O.Sync,{fontSize:"small",sx:{fontSize:"16px"}})})}),(!((c=r.routeMetaData)!=null&&c.isPublic)||!u.isPublic)&&e.jsx(s.Box,{className:"visible",color:"warning.main",children:e.jsx(s.Tooltip,{title:p("maker.pages.notPublic"),children:e.jsx(O.VisibilityOff,{fontSize:"small",sx:{fontSize:"16px"}})})})]}),children:e.jsxs(s.ListItemButton,{onClick:k,dense:!0,children:[e.jsx(s.ListItemIcon,{children:e.jsx(s.Checkbox,{edge:"start",checked:j,tabIndex:-1})}),e.jsx(s.ListItemText,{primary:r.path,primaryTypographyProps:{fontSize:"0.8rem",fontStyle:"italic",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",pr:1}})]})})}function de({state:r,toMode:j,onChange:k,defaultRouteIds:u}){const{t:p,locale:b}=W.useLocaleContext(),[d,S]=l.useState(!1),[f,g]=l.useState(()=>u?Object.fromEntries(u.filter(t=>!t.includes("-")).map(t=>[t,!0])):{}),[c,P]=l.useState({}),[w,y]=l.useState(()=>u?Object.fromEntries(u.filter(t=>t.includes("-")).map(t=>[t,!0])):{}),[A,E]=l.useState({}),{loading:z,error:v,value:x}=ie.useAsync(()=>U.getPages({mode:j}),[j]);if(v)throw v;const D=l.useMemo(()=>r.routeIds||[],[r]),I=l.useMemo(()=>(x==null?void 0:x.pageIds)||[],[x]),T=l.useMemo(()=>!D||!r.routes?[]:JSON.parse(JSON.stringify(D)).sort((o,i)=>{var h,m;const n=(h=r.routes)==null?void 0:h[o],a=(m=r.routes)==null?void 0:m[i];return n!=null&&n.publishedAt&&new Date(n.publishedAt).getTime()<new Date(n.updatedAt).getTime()?-1:a!=null&&a.publishedAt&&new Date(a.publishedAt).getTime()<new Date(a.updatedAt).getTime()?1:new Date((n==null?void 0:n.updatedAt)??"").getTime()-new Date((a==null?void 0:a.updatedAt)??"").getTime()}),[r,D]),q=l.useMemo(()=>{if(!T)return[];if(!c)return T;const t=[...T].filter(o=>!c[o]);return Object.values(c).forEach(o=>{o.forEach(i=>{t.push(`${i.originalRouteId}-${i.paramOptionIds.join("-")}`)})}),t},[T,c]),B=l.useMemo(()=>!x||!I||!q?[]:H.default(I,q),[q,x,I]),C=l.useMemo(()=>D?[...D].concat(B):B,[D,B]),_=l.useCallback(()=>{const t={};T==null||T.forEach(o=>{var n;const i=(n=r.routes)==null?void 0:n[o];if(i&&i.params&&i.params.length>0&&i.paramsOptions&&i.paramsOptions.length>0){const a=te.generateParamCombinations({basePath:i.path,params:i.params,routeId:i.id,paramsOptions:i.paramsOptions,currentIndex:0,currentParams:[],currentOptionIds:[],result:[]});a.length>0&&(t[i.id]=a)}}),P(t)},[T,r.routes]);l.useEffect(()=>{_()},[_]),l.useEffect(()=>{E(t=>{const o={...t};return Object.keys(c).forEach(i=>{var n;c[i]&&((n=c[i])==null?void 0:n.length)>0&&o[i]===void 0&&(o[i]=!0)}),o})},[c]);const K=l.useRef(!0);l.useEffect(()=>{y(t=>{const o={...t};return Object.keys(c).length===0||(Object.keys(c).forEach(i=>{const n=c[i]||[],a=d||!!f[i];n.forEach(h=>{const m=`${i}-${h.paramOptionIds.join("-")}`;K.current?o[m]=a||t[m]||!1:o[m]=a})}),K.current=!1),o})},[f,c,d]);const Q=(t,o)=>{o.stopPropagation(),E(i=>{const n={...i};return n[t]=!n[t],n})},N=l.useCallback(t=>{g(o=>{const i=se.produce(o,n=>{d?(Object.assign(n,Object.fromEntries(C.map(a=>[a,!0]))),delete n[t]):n[t]?(delete n[t],B.includes(t)&&(D||[]).filter(a=>{var h,m;return((h=r.pages[a])==null?void 0:h.slug)===((m=x==null?void 0:x.pages[t])==null?void 0:m.slug)}).forEach(a=>{delete n[a]})):(n[t]=!0,D&&D.includes(t)&&B.filter(a=>{var h,m;return((h=x==null?void 0:x.pages[a])==null?void 0:h.slug)===((m=r.pages[t])==null?void 0:m.slug)}).forEach(a=>{n[a]=!0}))});return S(H.default(C,Object.keys(i)).length===0),i})},[d,C,B,r,x,D]),X=l.useCallback((t,o)=>{const i=`${t}-${o.paramOptionIds.join("-")}`;y(n=>{var m;const a={...n};a[i]=!a[i];const h=((m=c[t])==null?void 0:m.every(L=>a[`${t}-${L.paramOptionIds.join("-")}`]))??!1;return g(L=>{if(h&&!L[t])return{...L,[t]:!0};if(!h&&L[t]){const R={...L};return delete R[t],R}return L}),a})},[c]),Y=l.useCallback(()=>{S(t=>(t&&g({}),!t))},[]);return l.useEffect(()=>{const t=d?C:Object.keys(f),o=Object.entries(w).filter(([,n])=>n).map(([n])=>n).filter(n=>n!==void 0),i=Array.from(new Set([...t,...o]));k(d?null:i)},[d,f,w,C,k]),z?e.jsx(re.Loading,{sx:{my:4}}):e.jsxs(s.List,{disablePadding:!0,sx:{maxWidth:700},children:[e.jsx(s.ListItem,{sx:{position:"sticky",top:0,bgcolor:"background.paper",zIndex:1},disablePadding:!0,children:e.jsxs(s.ListItemButton,{onClick:Y,dense:!0,children:[e.jsx(s.ListItemIcon,{children:e.jsx(s.Checkbox,{edge:"start",checked:d,tabIndex:-1})}),e.jsx(s.ListItemText,{primary:p("common.all")})]})}),T.map(t=>{var L,R;const o=(L=r.routes)==null?void 0:L[t];if(!o)return null;const i=!1,n=c&&c[t]&&((R=c[t])==null?void 0:R.length)>0,a=A[t]!==!1,h=c[t]||[],m=!o.publishedAt||o.updatedAt&&new Date(o.updatedAt).getTime()>new Date(o.publishedAt).getTime();return e.jsxs(s.Box,{children:[e.jsx(s.ListItem,{sx:{pr:4},disablePadding:!0,secondaryAction:e.jsxs(s.Box,{sx:{display:"flex",alignItems:"center"},children:[m&&e.jsx(s.Tooltip,{title:p("maker.pages.needPublish"),children:e.jsx(O.Sync,{fontSize:"small",sx:{color:"warning.main",fontSize:16,mr:.35}})}),!o.isPublic&&e.jsx(s.Tooltip,{title:p("maker.pages.notPublic"),children:e.jsx(O.VisibilityOff,{fontSize:"small",sx:{color:"warning.main",fontSize:16,mr:.35}})}),i,n&&e.jsx(s.Box,{onClick:M=>Q(t,M),sx:{display:"inline-flex",alignItems:"center",mr:.35,cursor:"pointer",color:"info.main"},children:a?e.jsx(O.KeyboardArrowDown,{fontSize:"small",sx:{fontSize:"18px"}}):e.jsx(O.KeyboardArrowRight,{fontSize:"small",sx:{fontSize:"18px"}})})]}),children:e.jsxs(s.ListItemButton,{onClick:()=>N(t),dense:!0,children:[e.jsx(s.ListItemIcon,{children:e.jsx(s.Checkbox,{edge:"start",checked:d||!!f[t],tabIndex:-1})}),e.jsx(s.ListItemText,{primary:o.path,primaryTypographyProps:{noWrap:!0,textOverflow:"ellipsis"},secondaryTypographyProps:{noWrap:!0,textOverflow:"ellipsis"}})]})}),n&&e.jsx(s.Collapse,{in:a,children:e.jsx(s.Box,{children:h.map(M=>{const V=`${t}-${M.paramOptionIds.join("-")}`,Z=w[V]||!1;return e.jsx(ue,{routePathInfo:M,checked:d||Z,onClick:()=>X(t,M),route:o},V)})})})]},t)}),B.map(t=>{var i,n;const o=x==null?void 0:x.pages[t];return o?e.jsx(s.ListItem,{disablePadding:!0,secondaryAction:e.jsx(s.Chip,{color:"warning",label:"deleted",size:"small"}),children:e.jsxs(s.ListItemButton,{onClick:()=>N(t),dense:!0,children:[e.jsx(s.ListItemIcon,{children:e.jsx(s.Checkbox,{edge:"start",checked:d||!!f[t],tabIndex:-1})}),e.jsx(s.ListItemText,{primary:o.slug,secondary:(n=(i=o.locales)==null?void 0:i[b])==null?void 0:n.title,primaryTypographyProps:{noWrap:!0,textOverflow:"ellipsis"},secondaryTypographyProps:{noWrap:!0,textOverflow:"ellipsis"}})]})},t):null})]})}exports.default=ce;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),F=require("./state-BVdbNJCA.js"),W=require("@arcblock/ux/lib/Locale/context"),ee=require("@arcblock/ux/lib/Toast"),te=require("@blocklet/pages-kit/utils/route"),O=require("@mui/icons-material"),J=require("@mui/lab"),s=require("@mui/material"),se=require("immer"),ne=require("lodash/difference"),l=require("react"),ie=require("react-use"),re=require("./home-CQTuGad2.js"),U=require("./array-BqHuYyfx.js"),G=r=>r&&r.__esModule?r:{default:r},$=G(ee),H=G(ne);function oe(r){const[j,k]=l.useState(!1);return e.jsx(J.LoadingButton,{...r,loading:r.loading||j,onClick:u=>{var b;const p=(b=r.onClick)==null?void 0:b.call(r,u);p instanceof Promise&&(k(!0),p.finally(()=>{k(!1)}))}})}const ae=s.createSvgIcon(e.jsxs("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[e.jsx("path",{d:"M7.75732 16.2426L16.2426 7.75736",stroke:"#4B5563",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"}),e.jsx("path",{d:"M16.2426 16.2426L7.75732 7.75735",stroke:"#4B5563",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})]}),"Close");function le(){const[r,j]=l.useState(),k=l.useMemo(()=>r?e.jsx(s.Dialog,{...r}):null,[r]),u=l.useCallback(()=>{j(void 0)},[]),p=l.useCallback(({title:b,content:d,cancelText:S="Cancel",okText:f="Ok",onOk:g,onClose:c,okIcon:P,okColor:w="primary",cancelColor:y="primary",DialogContentProps:A,form:E,...z})=>{j({...z,open:!0,children:e.jsxs("form",{onSubmit:v=>v.preventDefault(),children:[b&&e.jsxs(s.DialogTitle,{className:"between",zIndex:"appBar",bgcolor:"background.paper",sx:{borderBottom:v=>`1px solid ${v.palette.divider}`},children:[e.jsx(s.Box,{children:b}),e.jsx(s.IconButton,{size:"small",onClick:async()=>{u(),c==null||c()},children:e.jsx(ae,{})})]}),d&&e.jsx(s.DialogContent,{...A,sx:{mt:-3,...A==null?void 0:A.sx},children:e.jsx(s.Box,{pt:3,children:d})}),e.jsxs(s.DialogActions,{children:[e.jsx(s.Button,{variant:"outlined",color:y||"primary",onClick:c??u,children:S}),e.jsx(oe,{variant:"contained",color:w||"primary",startIcon:P,loadingPosition:P?"start":"center",onClick:async()=>{await(g==null?void 0:g()),u()},type:"submit",children:f})]})]}),onClose:c??u})},[u]);return{dialog:k,showDialog:p,closeDialog:u}}const ce=l.forwardRef(({mode:r,state:j},k)=>{const{t:u}=W.useLocaleContext(),[p,b]=l.useState(!1),{dialog:d,showDialog:S}=le(),f=F.useProjectId(),g=l.useCallback(P=>{let w=[];S({title:u("maker.publishToProduction"),content:e.jsxs(s.Box,{sx:{minWidth:300},children:[e.jsx(s.Alert,{color:"warning",icon:e.jsx(O.Warning,{}),children:u("maker.publishToProductionTip")}),e.jsx(s.Box,{maxHeight:"50vh",overflow:"auto",mt:2,children:e.jsx(de,{state:j,toMode:r,onChange:y=>w=y,defaultRouteIds:P})})]}),okText:u("maker.publish"),cancelText:u("common.cancel"),onOk:async()=>{if((w==null?void 0:w.length)===0){const y=u("maker.publishSelectPagesMessage");throw $.default.error(y),new Error(y)}localStorage.setItem(F.getProjectPageVersionKey(f??""),String(new Date().getTime())),b(!0);try{await U.publishPages({mode:r,routes:w}),$.default.success(u("maker.publishSuccessMessage"))}catch(y){throw $.default.error(y.message),y}finally{b(!1)}}})},[r,j,u,f,S]);l.useImperativeHandle(k,()=>({openPublishDialog:g}));const c=l.useCallback(()=>{g()},[g]);return e.jsxs(e.Fragment,{children:[e.jsx(J.LoadingButton,{color:"primary",variant:"contained",size:"small",sx:{mr:1},onClick:c,loading:p,disabled:p,children:u("maker.publish")}),d]})});function ue({routePathInfo:r,checked:j,onClick:k,route:u}){var d,S,f,g,c;const{t:p}=W.useLocaleContext(),b=!((d=r.routeMetaData)!=null&&d.publishedAt)||((S=r.routeMetaData)==null?void 0:S.updatedAt)&&new Date((f=r.routeMetaData)==null?void 0:f.updatedAt)>new Date((g=r.routeMetaData)==null?void 0:g.publishedAt);return e.jsx(s.ListItem,{sx:{pl:4,pr:3},disablePadding:!0,secondaryAction:e.jsxs(s.Box,{display:"flex",alignItems:"center",sx:{minWidth:"auto"},children:[b&&e.jsx(s.Box,{mr:.35,className:"visible",color:"warning.main",sx:{display:"flex",alignItems:"center"},title:p("maker.pages.needPublish"),children:e.jsx(s.Tooltip,{title:p("maker.pages.needPublish"),children:e.jsx(O.Sync,{fontSize:"small",sx:{fontSize:"16px"}})})}),(!((c=r.routeMetaData)!=null&&c.isPublic)||!u.isPublic)&&e.jsx(s.Box,{className:"visible",color:"warning.main",children:e.jsx(s.Tooltip,{title:p("maker.pages.notPublic"),children:e.jsx(O.VisibilityOff,{fontSize:"small",sx:{fontSize:"16px"}})})})]}),children:e.jsxs(s.ListItemButton,{onClick:k,dense:!0,children:[e.jsx(s.ListItemIcon,{children:e.jsx(s.Checkbox,{edge:"start",checked:j,tabIndex:-1})}),e.jsx(s.ListItemText,{primary:r.path,primaryTypographyProps:{fontSize:"0.8rem",fontStyle:"italic",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",pr:1}})]})})}function de({state:r,toMode:j,onChange:k,defaultRouteIds:u}){const{t:p,locale:b}=W.useLocaleContext(),[d,S]=l.useState(!1),[f,g]=l.useState(()=>u?Object.fromEntries(u.filter(t=>!t.includes("-")).map(t=>[t,!0])):{}),[c,P]=l.useState({}),[w,y]=l.useState(()=>u?Object.fromEntries(u.filter(t=>t.includes("-")).map(t=>[t,!0])):{}),[A,E]=l.useState({}),{loading:z,error:v,value:x}=ie.useAsync(()=>U.getPages({mode:j}),[j]);if(v)throw v;const D=l.useMemo(()=>r.routeIds||[],[r]),I=l.useMemo(()=>(x==null?void 0:x.pageIds)||[],[x]),T=l.useMemo(()=>!D||!r.routes?[]:JSON.parse(JSON.stringify(D)).sort((o,i)=>{var h,m;const n=(h=r.routes)==null?void 0:h[o],a=(m=r.routes)==null?void 0:m[i];return n!=null&&n.publishedAt&&new Date(n.publishedAt).getTime()<new Date(n.updatedAt).getTime()?-1:a!=null&&a.publishedAt&&new Date(a.publishedAt).getTime()<new Date(a.updatedAt).getTime()?1:new Date((n==null?void 0:n.updatedAt)??"").getTime()-new Date((a==null?void 0:a.updatedAt)??"").getTime()}),[r,D]),q=l.useMemo(()=>{if(!T)return[];if(!c)return T;const t=[...T].filter(o=>!c[o]);return Object.values(c).forEach(o=>{o.forEach(i=>{t.push(`${i.originalRouteId}-${i.paramOptionIds.join("-")}`)})}),t},[T,c]),B=l.useMemo(()=>!x||!I||!q?[]:H.default(I,q),[q,x,I]),C=l.useMemo(()=>D?[...D].concat(B):B,[D,B]),_=l.useCallback(()=>{const t={};T==null||T.forEach(o=>{var n;const i=(n=r.routes)==null?void 0:n[o];if(i&&i.params&&i.params.length>0&&i.paramsOptions&&i.paramsOptions.length>0){const a=te.generateParamCombinations({basePath:i.path,params:i.params,routeId:i.id,paramsOptions:i.paramsOptions,currentIndex:0,currentParams:[],currentOptionIds:[],result:[]});a.length>0&&(t[i.id]=a)}}),P(t)},[T,r.routes]);l.useEffect(()=>{_()},[_]),l.useEffect(()=>{E(t=>{const o={...t};return Object.keys(c).forEach(i=>{var n;c[i]&&((n=c[i])==null?void 0:n.length)>0&&o[i]===void 0&&(o[i]=!0)}),o})},[c]);const K=l.useRef(!0);l.useEffect(()=>{y(t=>{const o={...t};return Object.keys(c).length===0||(Object.keys(c).forEach(i=>{const n=c[i]||[],a=d||!!f[i];n.forEach(h=>{const m=`${i}-${h.paramOptionIds.join("-")}`;K.current?o[m]=a||t[m]||!1:o[m]=a})}),K.current=!1),o})},[f,c,d]);const Q=(t,o)=>{o.stopPropagation(),E(i=>{const n={...i};return n[t]=!n[t],n})},N=l.useCallback(t=>{g(o=>{const i=se.produce(o,n=>{d?(Object.assign(n,Object.fromEntries(C.map(a=>[a,!0]))),delete n[t]):n[t]?(delete n[t],B.includes(t)&&(D||[]).filter(a=>{var h,m;return((h=r.pages[a])==null?void 0:h.slug)===((m=x==null?void 0:x.pages[t])==null?void 0:m.slug)}).forEach(a=>{delete n[a]})):(n[t]=!0,D&&D.includes(t)&&B.filter(a=>{var h,m;return((h=x==null?void 0:x.pages[a])==null?void 0:h.slug)===((m=r.pages[t])==null?void 0:m.slug)}).forEach(a=>{n[a]=!0}))});return S(H.default(C,Object.keys(i)).length===0),i})},[d,C,B,r,x,D]),X=l.useCallback((t,o)=>{const i=`${t}-${o.paramOptionIds.join("-")}`;y(n=>{var m;const a={...n};a[i]=!a[i];const h=((m=c[t])==null?void 0:m.every(L=>a[`${t}-${L.paramOptionIds.join("-")}`]))??!1;return g(L=>{if(h&&!L[t])return{...L,[t]:!0};if(!h&&L[t]){const R={...L};return delete R[t],R}return L}),a})},[c]),Y=l.useCallback(()=>{S(t=>(t&&g({}),!t))},[]);return l.useEffect(()=>{const t=d?C:Object.keys(f),o=Object.entries(w).filter(([,n])=>n).map(([n])=>n).filter(n=>n!==void 0),i=Array.from(new Set([...t,...o]));k(d?null:i)},[d,f,w,C,k]),z?e.jsx(re.Loading,{sx:{my:4}}):e.jsxs(s.List,{disablePadding:!0,sx:{maxWidth:700},children:[e.jsx(s.ListItem,{sx:{position:"sticky",top:0,bgcolor:"background.paper",zIndex:1},disablePadding:!0,children:e.jsxs(s.ListItemButton,{onClick:Y,dense:!0,children:[e.jsx(s.ListItemIcon,{children:e.jsx(s.Checkbox,{edge:"start",checked:d,tabIndex:-1})}),e.jsx(s.ListItemText,{primary:p("common.all")})]})}),T.map(t=>{var L,R;const o=(L=r.routes)==null?void 0:L[t];if(!o)return null;const i=!1,n=c&&c[t]&&((R=c[t])==null?void 0:R.length)>0,a=A[t]!==!1,h=c[t]||[],m=!o.publishedAt||o.updatedAt&&new Date(o.updatedAt).getTime()>new Date(o.publishedAt).getTime();return e.jsxs(s.Box,{children:[e.jsx(s.ListItem,{sx:{pr:4},disablePadding:!0,secondaryAction:e.jsxs(s.Box,{sx:{display:"flex",alignItems:"center"},children:[m&&e.jsx(s.Tooltip,{title:p("maker.pages.needPublish"),children:e.jsx(O.Sync,{fontSize:"small",sx:{color:"warning.main",fontSize:16,mr:.35}})}),!o.isPublic&&e.jsx(s.Tooltip,{title:p("maker.pages.notPublic"),children:e.jsx(O.VisibilityOff,{fontSize:"small",sx:{color:"warning.main",fontSize:16,mr:.35}})}),i,n&&e.jsx(s.Box,{onClick:M=>Q(t,M),sx:{display:"inline-flex",alignItems:"center",mr:.35,cursor:"pointer",color:"info.main"},children:a?e.jsx(O.KeyboardArrowDown,{fontSize:"small",sx:{fontSize:"18px"}}):e.jsx(O.KeyboardArrowRight,{fontSize:"small",sx:{fontSize:"18px"}})})]}),children:e.jsxs(s.ListItemButton,{onClick:()=>N(t),dense:!0,children:[e.jsx(s.ListItemIcon,{children:e.jsx(s.Checkbox,{edge:"start",checked:d||!!f[t],tabIndex:-1})}),e.jsx(s.ListItemText,{primary:o.path,primaryTypographyProps:{noWrap:!0,textOverflow:"ellipsis"},secondaryTypographyProps:{noWrap:!0,textOverflow:"ellipsis"}})]})}),n&&e.jsx(s.Collapse,{in:a,children:e.jsx(s.Box,{children:h.map(M=>{const V=`${t}-${M.paramOptionIds.join("-")}`,Z=w[V]||!1;return e.jsx(ue,{routePathInfo:M,checked:d||Z,onClick:()=>X(t,M),route:o},V)})})})]},t)}),B.map(t=>{var i,n;const o=x==null?void 0:x.pages[t];return o?e.jsx(s.ListItem,{disablePadding:!0,secondaryAction:e.jsx(s.Chip,{color:"warning",label:"deleted",size:"small"}),children:e.jsxs(s.ListItemButton,{onClick:()=>N(t),dense:!0,children:[e.jsx(s.ListItemIcon,{children:e.jsx(s.Checkbox,{edge:"start",checked:d||!!f[t],tabIndex:-1})}),e.jsx(s.ListItemText,{primary:o.slug,secondary:(n=(i=o.locales)==null?void 0:i[b])==null?void 0:n.title,primaryTypographyProps:{noWrap:!0,textOverflow:"ellipsis"},secondaryTypographyProps:{noWrap:!0,textOverflow:"ellipsis"}})]})},t):null})]})}exports.default=ce;
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
"use strict";var _t=Object.defineProperty;var kt=(e,n,t)=>n in e?_t(e,n,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[n]=t;var v=(e,n,t)=>kt(e,typeof n!="symbol"?n+"":n,t);const vt=require("@blocklet/pages-kit/builtin/utils"),ye=require("@blocklet/pages-kit/types"),de=require("@blocklet/pages-kit/utils/property"),pe=require("@blocklet/quickjs"),Rt=require("@blocklet/sdk/lib/config"),Ae=require("lru-cache"),at=require("node-fetch"),q=require("ufo"),Z=require("crypto"),xt=require("@blocklet/logger"),w=require("fs"),S=require("path"),Lt=require("lodash/isNil"),Nt=require("@blocklet/pages-kit/utils/builtin"),rt=require("@blocklet/pages-kit/utils/typescript/builtin-module-transformer"),He=require("@blocklet/sdk/lib/component"),Mt=require("autoprefixer"),$t=require("esbuild"),Ut=require("postcss"),Ft=require("tailwindcss"),qt=require("typescript"),ee=require("@syncedstore/core"),Bt=require("yjs"),Ht=require("@blocklet/pages-kit/utils/data-source"),Ee=require("@blocklet/pages-kit/utils/route"),Gt=require("lodash"),Qe=require("@blocklet/pages-kit/utils/common"),Vt=require("@blocklet/pages-kit/utils/page-model"),Jt=require("@reactivedata/reactive"),Ne=require("glob"),Kt=require("lib0/decoding"),zt=require("lib0/encoding"),Yt=require("lodash/cloneDeep"),Wt=require("lodash/debounce"),Qt=require("lodash/get"),Xt=require("lodash/isEmpty"),Zt=require("lodash/pick"),es=require("lodash/set"),ts=require("lodash/union"),ss=require("p-limit"),ns=require("stream/promises"),os=require("tar"),as=require("wait-on"),ie=require("y-protocols/awareness"),ve=require("y-protocols/sync"),rs=require("yaml"),k=require("sequelize");require("sqlite3");require("@blocklet/pages-kit/types/state");const L=e=>e&&e.__esModule?e:{default:e};function fe(e){if(e&&e.__esModule)return e;const n=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const t in e)if(t!=="default"){const s=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(n,t,s.get?s:{enumerable:!0,get:()=>e[t]})}}return n.default=e,Object.freeze(n)}const C=L(Rt),is=L(at),cs=L(xt),it=L(S),ls=L(Lt),ds=L(Mt),ps=fe($t),us=L(Ut),fs=L(Ft),F=L(qt),V=fe(Bt),Re=fe(Kt),x=fe(zt),ms=L(Yt),ct=L(Wt),Ge=L(Qt),lt=L(Xt),hs=L(Zt),Xe=L(es),gs=L(ts),ys=L(ss),Ss=L(as),ne=fe(rs);C.default.env.mode;C.default.env.OPENAI_API_KEY||process.env.OPENAI_API_KEY;C.default.env.OPENAI_BASE_URL||process.env.OPENAI_BASE_URL;C.default.env.TRANSLATE_ADDITIONAL_PROMPT||process.env.TRANSLATE_ADDITIONAL_PROMPT;C.default.env.PAGE_CONTENT_ADDITIONAL_PROMPT||process.env.PAGE_CONTENT_ADDITIONAL_PROMPT;const Es="image-bin";C.default.env.INIT_TEMPLATE_PATH;const ws=process.env.DATABASE_URL||it.default.join(C.default.env.dataDir,"db/pages-kit.db"),Ze=C.default,bs=()=>C.default.env.tenantMode==="multiple",Is=()=>{var e;return(ls.default(Ze.env.preferences.multiTenantAllProjectAccessPassports)?[]:(e=Ze.env.preferences.multiTenantAllProjectAccessPassports)==null?void 0:e.split(","))||[]},Cs=it.default.join(C.default.env.dataDir,"fs-memoize-cache"),Os=C.default.env.FS_MEMOIZE_CACHE_VERSION||"v1.0.0",y=cs.default("pages-kit"),As=k.DataTypes.sqlite.DATE.parse;k.DataTypes.sqlite.DATE.parse=(e,n)=>typeof e=="number"?new Date(e):As(e,n);const me=new k.Sequelize({dialect:"sqlite",storage:ws,benchmark:process.env.ENABLE_SEQUELIZE_BENCHMARK==="true",retry:{match:[/SQLITE_BUSY/],name:"query",max:10},logging:process.env.ENABLE_SEQUELIZE_LOGGING==="true"?console.log:!1});me.query("pragma journal_mode = WAL;");me.query("pragma synchronous = normal;");me.query("pragma journal_size_limit = 67108864;");class Pe extends k.Model{}Pe.init({id:{type:k.DataTypes.UUID,allowNull:!1,primaryKey:!0,defaultValue:k.DataTypes.UUIDV4},projectId:{type:k.DataTypes.UUID,allowNull:!1},componentId:{type:k.DataTypes.STRING,allowNull:!1}},{sequelize:me,tableName:"ProjectComponents",timestamps:!1});class K extends k.Model{static async getProjectByIdOrSlug(n){return K.findOne({where:{[k.Op.or]:[{id:n},{slug:n}]}})}}K.init({id:{type:k.DataTypes.UUID,defaultValue:k.DataTypes.UUIDV4,primaryKey:!0},name:{type:k.DataTypes.STRING,allowNull:!1},description:k.DataTypes.TEXT,createdAt:k.DataTypes.DATE,updatedAt:k.DataTypes.DATE,createdBy:{type:k.DataTypes.STRING,allowNull:!1},updatedBy:{type:k.DataTypes.STRING,allowNull:!1},slug:k.DataTypes.STRING,icon:k.DataTypes.STRING,pinnedAt:k.DataTypes.DATE,useAllResources:k.DataTypes.BOOLEAN,npmSecret:k.DataTypes.STRING,relatedBlocklets:{type:k.DataTypes.JSON,allowNull:!1,defaultValue:{},get(){return this.getDataValue("relatedBlocklets")||{}},set(e){this.setDataValue("relatedBlocklets",JSON.stringify(e||{}))}}},{sequelize:me,paranoid:!0});K.hasMany(Pe,{foreignKey:"projectId",as:"components"});const Ps=Cs,Ts=Os,Me=7*24*60*60*1e3,js=24*60*60*1e3,dt=async(e="")=>{const n=S.join(Ps,e);try{if(!(await w.promises.stat(n)).isDirectory())throw new Error(`${n} is not a directory`)}catch{await w.promises.mkdir(n,{recursive:!0})}return n},Ds=(e,n)=>{const t=Z.createHash("md5").update(n).digest("hex");return S.join(e,`${Ts}-${t}.json`)},_s=async(e="")=>{const n=await dt(e),t=Date.now();try{const s=await w.promises.readdir(n);await Promise.all(s.filter(o=>o.endsWith(".json")).map(async o=>{const a=S.join(n,o);try{const r=await w.promises.readFile(a,"utf-8"),u=JSON.parse(r);u.createdAt&&t-u.createdAt>Me&&await w.promises.unlink(a)}catch{try{const u=await w.promises.stat(a);t-u.mtimeMs>Me&&await w.promises.unlink(a)}catch{}}}))}catch(s){console.error(`Failed to cleanup cache in ${n}:`,s)}},ks=(()=>{const e=new Set;return setInterval(async()=>{await Promise.all(Array.from(e).map(s=>_s(s)))},js).unref(),s=>{e.add(s)}})();function Ve(e,n){return n.subdir&&ks(n.subdir),pe.memoize(async(...s)=>{const o=await dt(n.subdir||""),a=n.keyGenerator?n.keyGenerator(...s):JSON.stringify(s),r=Ds(o,a);try{const u=await w.promises.readFile(r,"utf-8"),{value:c,createdAt:i}=JSON.parse(u);if(i&&Date.now()-i>Me)throw await w.promises.unlink(r).catch(()=>{}),new Error("Cache expired");return c}catch{const c=await e(...s),i=JSON.stringify({value:c,createdAt:Date.now()});return w.promises.writeFile(r,i,"utf-8").catch(d=>{console.error("Failed to write fs cache:",d)}),c}},{keyGenerator:n.keyGenerator,lruOptions:n.lruOptions})}const vs=async(e,{componentId:n})=>{const t=`@tailwind components;
|
|
2
|
+
@tailwind utilities;
|
|
3
|
+
`,s=`.CustomComponent_${n}`;return(await us.default([fs.default({content:[{raw:e,extension:"tsx"}]}),ds.default({overrideBrowserslist:["> 1%","last 2 versions"],stats:{}}),a=>{a.walkRules(r=>{r.selectors=r.selectors.map(u=>u.replace(/\.(.+)/g,`${s}.$1,${s} .$1`))})}]).process(t)).css},Rs=async(e,{componentId:n})=>{const t=await vs(e,{componentId:n});return`export const __PagesKit_CSS__ = ${JSON.stringify(t)};
|
|
4
|
+
|
|
5
|
+
${e}
|
|
6
|
+
`},et=Ve(async(e,n)=>{let t=F.default.transpileModule(e,{compilerOptions:{jsx:F.default.JsxEmit.React,target:F.default.ScriptTarget.ES2016,module:F.default.ModuleKind.ESNext},transformers:{before:[rt.createBuiltinModuleTransformer(F.default)]}}).outputText;if(n.tailwind&&(t=await Rs(t,{componentId:n.componentId})),n.module===ye.PreloadComponentScriptModule.ESM)return t;const s=F.default.transpileModule(t,{compilerOptions:{jsx:F.default.JsxEmit.React,target:F.default.ScriptTarget.ES2016,module:F.default.ModuleKind.CommonJS,moduleResolution:F.default.ModuleResolutionKind.Node16}}).outputText;return n.module===ye.PreloadComponentScriptModule.CJS?s:Ls(n.moduleName,s)},{keyGenerator:(e,n)=>{const t=Z.createHash("md5").update(e).digest("hex"),s={...n,componentId:n.componentId,module:n.module,...n.module!==ye.PreloadComponentScriptModule.ESM?{moduleName:n.moduleName}:{},tailwind:n.tailwind};return JSON.stringify(["transpileModule",t,s])},lruOptions:{max:100,ttl:1e3*60*60*24*7},subdir:"transpileModule"}),xs=async(e,n)=>{var r,u;const s=(u=(r=(await ps.build({entryPoints:["index.tsx"],external:Object.keys(Nt.BuiltinModules),format:"esm",target:"esnext",bundle:!0,write:!1,plugins:[{name:"vfs",setup(c){let i=null;c.onResolve({filter:/.*/},d=>d.path==="index.tsx"?{path:"index.tsx",namespace:"vfs"}:d.path==="./component"?{path:"component.tsx",namespace:"vfs"}:null),c.onLoad({filter:/.*/,namespace:"vfs"},async d=>{var E;if(d.path==="index.tsx")return{contents:`export { ${n} } from './component'`,loader:"tsx"};if(d.path==="component.tsx")return{contents:e,loader:"tsx"};if(rt.isRelativeModule(d.path)){const f=d.path.split("/").pop();if(i||(i=await De({ensureLoaded:!1})),(E=i==null?void 0:i.chunks)!=null&&E[f])try{const p=w.readFileSync(i.chunks[f],"utf-8");return y.info("get chunk from local file system",f),{contents:p,loader:"tsx"}}catch{}}return null})}}]})).outputFiles)==null?void 0:r[0])==null?void 0:u.contents;if(!s)throw new Error("Failed to build server code");const o=Buffer.from(s).toString();return F.default.transpileModule(o,{compilerOptions:{module:F.default.ModuleKind.ESNext,target:F.default.ScriptTarget.ES2020}}).outputText},pt=Ve(async(e,n)=>{const t=await xs(e,n);return new RegExp(`export\\s+\\{[^}]*(?:\\w+\\s+as\\s+${n}\\b|\\b${n}\\b)[^}]*\\}`,"m").test(t)?t:void 0},{keyGenerator:(e,n)=>{const t=Z.createHash("md5").update(e).digest("hex");return JSON.stringify(["extractExportValueSchema",t,n])},lruOptions:{max:100,ttl:1e3*60*60*24*7},subdir:"extractExportValueSchema"}),Ls=(e,n)=>`// GENERATED FILE. DO NOT EDIT.
|
|
7
|
+
var ${e} = async function () {
|
|
8
|
+
|
|
9
|
+
const exports = {};
|
|
10
|
+
let moduleExports = null;
|
|
11
|
+
|
|
12
|
+
// add commonjs module compatibility layer
|
|
13
|
+
const module = { exports: moduleExports };
|
|
14
|
+
|
|
15
|
+
// execute component code
|
|
16
|
+
${n}
|
|
17
|
+
|
|
18
|
+
// handle possible module.exports
|
|
19
|
+
if (module.exports && module.exports !== moduleExports) {
|
|
20
|
+
// if module.exports is used, use it first
|
|
21
|
+
return typeof module.exports === 'object' ? module.exports : { default: module.exports };
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
// ensure a default export
|
|
25
|
+
if (!('default' in exports) && Object.keys(exports).length === 0) {
|
|
26
|
+
// module has no exports, return null to indicate invalid
|
|
27
|
+
return null;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
return exports;
|
|
31
|
+
};
|
|
32
|
+
`,ce=new Ae.LRUCache({max:100}),ut=60*60,$e=60;function ft(e){y.info("clear preload components cache",{cacheKey:e}),ce.delete(e)}function mt(e){for(const n of ce.keys())n.includes(e)&&(y.info("clear preload components cache",{cacheKey:n}),ft(n))}function ht({mode:e,instanceId:n,componentId:t,locale:s}){return["getPreloadComponents",e,n,t,s].join("-")}async function Ns({mode:e,req:n,state:t,locale:s,instances:o,module:a}){const{supportedLocales:r,config:{defaultLocale:u}}=t;if(!u)return null;const c=(await Promise.all(o.map(async p=>{try{const l=ht({mode:e,instanceId:p.id,componentId:p.componentId,locale:s});if(e!=="draft"&&p.useCache&&ce.has(l))return y.info(`get preload component from cache: ${l}`),ce.get(l);const m=ue({state:t,componentId:p.componentId});if(!m)return null;const b=await gt({req:n,state:t,componentId:m.id,locale:s,defaultLocale:u,properties:p.properties});if(!b)return null;const _={instanceId:p.id,preload:b};if(e!=="draft"&&p.useCache){let A=ut;p.cacheDuration&&(A=p.cacheDuration),y.info(`set preload component to cache(${A}s): ${l}`),ce.set(l,_,{ttl:A*1e3})}return _}catch(l){return y.error("get preload component error",{instanceId:p.id,componentId:p.componentId},{error:l}),null}}))).filter(p=>!!p),i=Object.values(c.reduce((p,l)=>({...p,...l.preload.components}),{}));async function d(){const p=await Promise.all(i.map(async l=>{const m=de.componentUMDName({componentId:l.component.id}),b=a===ye.PreloadComponentScriptModule.ESM?{module:a,script:await et(l.script,{componentId:l.component.id,module:a,tailwind:e!=="draft"})}:{module:a,script:await et(l.script,{componentId:l.component.id,module:a,moduleName:m,tailwind:e!=="draft"}),moduleName:m};return[l.component.id,{component:l.component,script:b}]}));return Object.fromEntries(p)}const E=await d();return{config:{defaultLocale:u,supportedLocales:r},components:E,instances:c.map(p=>({id:p.instanceId,componentId:p.preload.component.id,locales:{[p.preload.locale]:{props:p.preload.props}}}))}}async function gt({req:e,state:n,componentId:t,locale:s,defaultLocale:o,properties:a}){const{supportedLocales:r}=n,u=ue({state:n,componentId:t});if(!u)return null;const c=r.some(d=>d.locale===s)?s:o;if(!c)return null;const i=await yt({req:e,state:n,componentId:t,locale:c,defaultLocale:o,properties:a});return i?{component:u,...i}:null}const Ms=20;async function yt({req:e,depth:n=0,state:t,componentId:s,locale:o,defaultLocale:a,properties:r}){if(n>Ms)throw new RangeError("max component depth exceeded");const u=$s({state:t,componentId:s,properties:r,locale:o});if(!u)return null;const{props:c}=u,i={locale:o||a,components:{[u.component.id]:{component:u.component,script:u.script}},props:{...c}};try{const d=await Fs({...u,req:e});d!=null&&d.props&&Object.assign(i.props,d.props)}catch(d){y.error("preload data at server side error",{componentId:s,name:u.component.name},{error:d})}return await Promise.all(Object.entries(c).map(async([d,E])=>{if((E==null?void 0:E.type)===de.RenderNestedComponent){const f=await yt({req:e,depth:n+1,state:t,componentId:E.componentId,locale:o,defaultLocale:a,properties:E.properties});f&&(Object.assign(i.components,f.components),Object.assign(i.props,{[d]:{type:de.RenderNestedComponent,componentId:E.componentId,props:f.props}}))}})),i}function $s({state:e,componentId:n,locale:t,properties:s}){const o=ue({state:e,componentId:n});if(!o)return null;const a=de.mergeComponent({componentId:n,getComponent:r=>ue({state:e,componentId:r}),locale:t,defaultLocale:e.config.defaultLocale,properties:s});return a?{component:o,script:a.script,props:{locale:t,...a.props}}:null}function ue({state:e,componentId:n}){var t,s,o;return((t=e.components[n])==null?void 0:t.data)??((o=(s=e.resources.components)==null?void 0:s[n])==null?void 0:o.component)}function Us({state:e,name:n}){var s,o;const t=n.toLowerCase();return((s=Object.values(e.components).find(a=>{var r;return((r=a.data.name)==null?void 0:r.toLowerCase())===t}))==null?void 0:s.data)??((o=e.resources.components&&Object.values(e.resources.components).find(a=>{var r;return((r=a.component.name)==null?void 0:r.toLowerCase())===t}))==null?void 0:o.component)}async function Fs({component:e,script:n,props:t,req:s}){if(!(n!=null&&n.includes("getServerSideProps")))return null;const o=await pt(n,"getServerSideProps");if(!o)return null;const a=o.match(/export\s*{\s*(\w+)\s+as\s+getServerSideProps\s*}/)||o.match(/export\s*{\s*getServerSideProps\s*}/),r=(a==null?void 0:a[1])||"getServerSideProps",u=new Promise(i=>{setTimeout(()=>{i({})},$e*1e3)});return await Promise.race([u,pe.Sandbox.callFunction({code:`${o}
|
|
33
|
+
|
|
34
|
+
export async function getServerSidePropsWrapper(props) {
|
|
35
|
+
const { location, fetch, props: componentProps } = props;
|
|
36
|
+
// 使用局部变量而不是全局变量
|
|
37
|
+
const originalLocation = typeof window !== 'undefined' ? window.location : undefined;
|
|
38
|
+
const originalFetch = globalThis.fetch;
|
|
39
|
+
|
|
40
|
+
try {
|
|
41
|
+
globalThis.location = location;
|
|
42
|
+
globalThis.fetch = fetch;
|
|
43
|
+
return await ${r}(componentProps);
|
|
44
|
+
} finally {
|
|
45
|
+
// 清理全局状态
|
|
46
|
+
if (originalLocation) globalThis.location = originalLocation;
|
|
47
|
+
if (originalFetch) globalThis.fetch = originalFetch;
|
|
48
|
+
}
|
|
49
|
+
}`,filename:`${e.name||e.id}.js`,moduleLoader:i=>{if(i==="@blocklet/pages-kit/builtin/utils")return`const { joinURL, withQuery, getQuery, getComponentMountPoint } = globalThis
|
|
50
|
+
export { joinURL, withQuery, getQuery, getComponentMountPoint }
|
|
51
|
+
`;if(i==="@blocklet/pages-kit/builtin/dayjs")return pe.BuiltinModules.dayjs},global:{console:{log:(...i)=>{y.info(...i)},warn:(...i)=>{y.warn(...i)},error:(...i)=>{y.error(...i)}},getComponentMountPoint:vt.getComponentMountPoint,joinURL:q.joinURL,withQuery:q.withQuery,getQuery:q.getQuery},functionName:"getServerSidePropsWrapper",args:[{location:{href:q.joinURL(q.withHttps(s.hostname),s.originalUrl)},fetch:(i,{...d}={})=>{const E=typeof i=="string"&&i.startsWith("/")?q.joinURL(C.default.env.appUrl,i):i;if(typeof E=="string"&&q.parseURL(E).host===q.parseURL(C.default.env.appUrl).host){const f=s.get("cookie");if(f){const p=new at.Headers(d.headers);p.set("cookie",f),d.headers=p}}return is.default(E,{...d,timeout:$e*1e3}).then(f=>({ok:f.ok,status:f.status,statusText:f.statusText,headers:Object.fromEntries(f.headers.entries()),json:()=>f.json()}))},props:t}]})])}const St=pe.memoize(async(e,n,t)=>{if(!(e!=null&&e.includes(n)))return null;const s=await pt(e,n);if(s)try{return await pe.Sandbox.callFunction({code:`
|
|
52
|
+
${s}
|
|
53
|
+
|
|
54
|
+
export function get${n}SchemaWrapper() {
|
|
55
|
+
return ${n};
|
|
56
|
+
}
|
|
57
|
+
`,filename:`${t}.js`,functionName:`get${n}SchemaWrapper`})}catch(o){return y.error(`获取 ${n} 失败`,{componentId:t,error:o}),null}return null},{keyGenerator:(e,n,t)=>{const s=Z.createHash("md5").update(e).digest("hex");return JSON.stringify(["getExportSchemaValueFromCode",s,n,t])},lruOptions:{max:100,ttl:1e3*60*60}}),qs="z8iZiDFg3vkkrPwsiba1TLXy3H9XHzFERsP8o",Ue="page",Fe="trigger-reload-project-resource",Je=qs,Bs="z2qa7BQdkEb3TwYyEYC1psK6uvmGnHSUHt5RM";function we(e){e.observeDeep(n=>{n.some(t=>t.changes.keys.has("updatedAt")||t.changes.keys.has("publishedAt"))||e.set("updatedAt",new Date().toISOString())})}function Et(){return w.mkdtempSync(S.join(C.default.env.dataDir,"tmp-"))}function be(e,n,t=[]){return Array.isArray(e)?e.flatMap((s,o)=>be(s,n,[...t,o])):typeof e=="object"?e===null?[]:Object.entries(e).flatMap(([s,o])=>be(o,n,[...t,s])):n(e)?[t]:[]}function B(e){return e.filter(n=>n!=null)}function Hs(e){e.pages&&Object.keys(e.pages).forEach(t=>{const s=ee.getYjsValue(e.pages[t]);s&&s instanceof V.Map&&we(s)});const n=ee.getYjsValue(e.pages);n&&n instanceof V.Map&&n.observe(t=>{t.changes.keys.forEach((s,o)=>{if(s.action==="add"){const a=ee.getYjsValue(e.pages[o]);a&&a instanceof V.Map&&we(a)}})})}function Gs(e){e.routes&&Object.keys(e.routes).forEach(t=>{var o;const s=ee.getYjsValue((o=e.routes)==null?void 0:o[t]);s&&s instanceof V.Map&&we(s)});const n=ee.getYjsValue(e.routes);n&&n instanceof V.Map&&n.observe(t=>{t.changes.keys.forEach((s,o)=>{var a;if(s.action==="add"){const r=ee.getYjsValue((a=e.routes)==null?void 0:a[o]);r&&r instanceof V.Map&&we(r)}})})}function Vs(e,n){var t;for(const s of n||Object.keys(e.routes||{})){let o=s,a=[];if(s.includes("-")){const[r,...u]=s.split("-");o=r,a=u||[]}if(((t=e.routes)==null?void 0:t[o])!==void 0){e.routes[o].publishedAt=new Date().toISOString();const r=e.routes[o];if(!r||!r.params||r.params.length===0)continue;if(s.includes("-")&&a.length>0){const u=Ee.getRouteMetaDataByOptionIds(a,r);u&&(u.publishedAt=new Date().toISOString())}if(!n){const u=Ee.generateParamCombinations({basePath:r.path,params:r.params,routeId:r.id,paramsOptions:r.paramsOptions,currentIndex:0,currentParams:[],currentOptionIds:[],result:[]});for(const c of u)c.routeMetaData??(c.routeMetaData={}),c.routeMetaData.publishedAt=new Date().toISOString()}}}}function xe({page:e,route:n,state:t,routeId:s,routePathInfo:o}){var r,u,c,i,d,E,f,p,l;y.info(`Executing datasource data assembly, routeId: ${s}, routePathInfo: ${JSON.stringify(o)}`);const a={...Gt.cloneDeep(e),id:s,slug:(o==null?void 0:o.path)??n.path,createdAt:n.createdAt,updatedAt:((r=o==null?void 0:o.routeMetaData)==null?void 0:r.updatedAt)??n.updatedAt,publishedAt:((u=o==null?void 0:o.routeMetaData)==null?void 0:u.publishedAt)??n.publishedAt,isPublic:(((c=o==null?void 0:o.routeMetaData)==null?void 0:c.isPublic)??n.isPublic)&&n.isPublic};for(const m of t.supportedLocales){if(n.dataSource){let b=n.id;o&&(b=o.paramOptionIds.join("-"));const _=((E=(d=(i=n.dataSource.pathDataMappings)==null?void 0:i[b])==null?void 0:d.dataCache)==null?void 0:E[m.locale])??((l=(p=(f=n.dataSource.pathDataMappings)==null?void 0:f[b])==null?void 0:p.dataCache)==null?void 0:l[t.config.defaultLocale||"en"]);if(!_)continue;Ht.setPageDataSource(a,t,m.locale,_)}o&&o.routeMetaData&&(o.routeMetaData.publishedAt=new Date().toISOString())}return a}const Ie=new Ae.LRUCache({max:20,ttl:10*60*1e3});function Js(e,n=[]){let t=0;const s=Array.from(Ie.keys()),o=[];for(const a of e){o.push(`page-html:prod:${a}:lang-path=none`);for(const r of n)o.push(`page-html:prod:/${r}${a}:lang-path=${r}`)}for(const a of s){const r=a.split(":lang-path=")[0]||"";for(const u of o){const i=(u.split(":lang-path=")[0]||"").replace(/\/:[^/]+/g,"");if(r.startsWith(i)){Ie.delete(a),t++,y.info(`[Cache CLEAR] key: ${a}`);break}}}return y.info(`[Cache CLEAR] cleared ${t} entries for patterns:`,o),t}function Ks({projectId:e,projectSlug:n,supportedLocales:t=[]}){let s=0;const o=Array.from(Ie.keys()),a=[];a.push(`page-html:prod:/${e}`),n&&n!==e&&a.push(`page-html:prod:/${n}`);for(const r of t)a.push(`page-html:prod:/${r}/${e}`),n&&n!==e&&(n!=="/"?a.push(`page-html:prod:/${r}/${n}`):a.push(`page-html:prod:/${r}`));for(const r of o)for(const u of a)if(r.startsWith(u)){Ie.delete(r),s++,y.info(`[Cache CLEAR PROJECT] key: ${r}`);break}return y.info(`[Cache CLEAR PROJECT] cleared ${s} entries for project ${e}${n?` (slug: ${n})`:""}`),s}const{uploadToMediaKit:zs}=require("@blocklet/uploader-server"),Ke=/^\w+(\w|-|\.)+\w+\.(jpe?g|png|gif|svg|bmp|webp|mp4|m4v|webm)$/,le=/mediakit:\/\/([a-f0-9]{32}\.(jpe?g|png|gif|svg|bmp|webp|mp4|m4v|webm))/i,tt=/mediakit:\/\/([a-f0-9]{32}\.(jpe?g|png|gif|svg|bmp|webp|mp4|m4v|webm))/gi,Ys=1e4,Ws=3e4,he=0,Le=1,Qs=0,Xs=1,qe=C.default,se=S.join(process.env.BLOCKLET_DATA_DIR,"site-state"),Zs=["production","draft"],en=["production"];function Ce(e){return(e==null?void 0:e.replace(/\//g,"|"))||""}function tn(){var t;const e=qe.env.languages.map(s=>({locale:s.code,name:s.name})),n=(t=e[0])==null?void 0:t.locale;return{pageIds:[],pages:{},routeIds:[],routes:{},dataSourceIds:[],dataSources:{},components:{},supportedLocales:e,config:{defaultLocale:n},resources:{}}}const j=class j extends V.Doc{constructor(t){super();v(this,"syncedStore");v(this,"conns",new Map);v(this,"awareness");v(this,"releaseTimer");v(this,"awarenessChangeHandler",({added:t,updated:s,removed:o},a)=>{const r=t.concat(s,o);if(a!==null){const i=this.conns.get(a);i&&(t.forEach(d=>{i.add(d)}),o.forEach(d=>{i.delete(d)}))}const u=x.createEncoder();x.writeVarUint(u,Le),x.writeVarUint8Array(u,ie.encodeAwarenessUpdate(this.awareness,r));const c=x.toUint8Array(u);this.conns.forEach((i,d)=>this.send(d,c))});v(this,"updateHandler",t=>{const s=x.createEncoder();x.writeVarUint(s,he),ve.writeUpdate(s,t);const o=x.toUint8Array(s);this.conns.forEach((a,r)=>this.send(r,o))});v(this,"ensureDataStructure",()=>{var c;const{supportedLocales:t,pages:s,pageIds:o,config:a,routes:r,routeIds:u}=this.syncedStore;{const i=new Set(Object.keys(s));let d=0;for(;d<o.length;){const E=o[d];i.has(E)?(i.delete(E),d++):o.splice(d,1)}}{const i=new Set(Object.keys(r));let d=0;for(;d<u.length;){const E=u[d];i.has(E)?(i.delete(E),d++):u.splice(d,1)}}t.splice(0,t.length),t.push(...qe.env.languages.map(i=>({locale:i.code,name:i.name}))),a.defaultLocale=(c=t[0])==null?void 0:c.locale;{let i=0;const d=new Set;for(;i<t.length;){const{locale:E}=t[i];d.has(E)?t.splice(i,1):(i++,d.add(E))}}});v(this,"send",(t,s)=>{t.readyState!==Qs&&t.readyState!==Xs&&this.closeConn(t);try{t.send(s,o=>{o&&this.closeConn(t)})}catch{this.closeConn(t)}});v(this,"closeConn",t=>{if(t.removeAllListeners(),this.conns.has(t)){const s=this.conns.get(t);this.conns.delete(t),s&&ie.removeAwarenessStates(this.awareness,Array.from(s),null)}t.close(),this.checkAndScheduleRelease()});v(this,"autoSave",ct.default(()=>{w.mkdirSync(S.dirname(this.draftYjsFilePath),{recursive:!0}),w.writeFileSync(this.draftYjsFilePath,V.encodeStateAsUpdate(this))},Ys));v(this,"save",({flush:t=!1}={})=>{this.autoSave(),t&&this.autoSave.flush()});v(this,"publish",async({mode:t,routes:s})=>{const o=await this.getState("draft"),a=await this.getState("production");await Be(o,a,{routes:s,mergeMode:"replace",deleteRoutes:!0,publishMode:t}),a.config.publishedAt=new Date().getTime(),Vs(this.syncedStore,s),await this.setState(t,a),await this.clearPageCacheForRoutes(s,a)});v(this,"mergeState",async(t,s)=>{var u,c,i;const o=JSON.parse(JSON.stringify(s));(u=t.config).fontFamily??(u.fontFamily={});const a=(c=o.config)==null?void 0:c.fontFamily,r=(i=t.config)==null?void 0:i.fontFamily;t.config.fontFamily.title=(a==null?void 0:a.title)||(r==null?void 0:r.title),t.config.fontFamily.description=(a==null?void 0:a.description)||(r==null?void 0:r.description),await new Promise((d,E)=>{this.transact(async()=>{try{const f=await Be(t,s);d(f)}catch(f){E(f)}})})});v(this,"clearPageCacheForRoutes",async(t,s)=>{const o=S.basename(this.options.path),a=await K.findByPk(o),r=(a==null?void 0:a.slug)||o;if(y.info(`[SiteState] clearing page cache for project ${o}, routes:`,t||[]),!t||t.length===0){Ks({projectId:o,projectSlug:r,supportedLocales:s.supportedLocales.map(d=>d.locale)});return}const u=s.supportedLocales.map(d=>d.locale),c=[],i=t.filter(d=>s.pages[d]);for(const d of i){const f=s.pages[d].slug;r&&r!==o&&(r==="/"?c.push(f):c.push(`/${r}${f}`)),c.push(`/${o}${f}`)}if(y.info(`[SiteState] clearing page cache for project ${o}, pathPatterns:`,c),c.length>0){const d=Js(c,u);y.info(`[SiteState] cleared ${d} page cache entries for project ${o}, routes:`,t)}});v(this,"addConnection",t=>{if(this.conns.has(t))return;this.cancelRelease(),t.binaryType="arraybuffer",this.conns.set(t,new Set),t.on("message",a=>this.messageListener(t,new Uint8Array(a)));let s=!0;const o=setInterval(()=>{if(!s)this.conns.has(t)&&this.closeConn(t),clearInterval(o);else if(this.conns.has(t)){s=!1;try{t.ping()}catch{this.closeConn(t),clearInterval(o)}}},Ws);t.on("close",()=>{this.closeConn(t),clearInterval(o)}),t.on("pong",()=>{s=!0});{const a=x.createEncoder();x.writeVarUint(a,he),ve.writeSyncStep1(a,this),this.send(t,x.toUint8Array(a));const r=this.awareness.getStates();if(r.size>0){const u=x.createEncoder();x.writeVarUint(u,Le),x.writeVarUint8Array(u,ie.encodeAwarenessUpdate(this.awareness,Array.from(r.keys()))),this.send(t,x.toUint8Array(u))}}});v(this,"messageListener",(t,s)=>{try{const o=x.createEncoder(),a=Re.createDecoder(s),r=Re.readVarUint(a);switch(r){case he:x.writeVarUint(o,he),ve.readSyncMessage(a,o,this,null),x.length(o)>1&&(this.ensureDataStructure(),this.send(t,x.toUint8Array(o)));break;case Le:{ie.applyAwarenessUpdate(this.awareness,Re.readVarUint8Array(a),t);break}default:y.warn(`Unsupported messageType ${r}`)}}catch(o){y.error(o)}this.save()});this.options=t,w.existsSync(this.draftYjsFilePath)&&V.applyUpdate(this,w.readFileSync(this.draftYjsFilePath)),this.syncedStore=Jt.reactive(ee.syncedStore({pages:{},pageIds:[],components:{},supportedLocales:[],config:{},resources:{},routeIds:[],routes:{},dataSourceIds:[],dataSources:{}},this)),this.initObserver(),this.on("update",this.updateHandler),this.awareness=new ie.Awareness(this),this.awareness.on("update",this.awarenessChangeHandler),this.ensureDataStructure()}static safeDeleteProjectStateDir(t){if(!t)throw new Error("Should provide project context");try{const s=S.join(se,t),o=S.join(se,`@del-${t}`);w.renameSync(s,o)}catch(s){y.error("Failed to safe delete project state dir:",s)}}static get projectIds(){return Ne.globSync("*/",{cwd:se,ignore:["@del-*","@tmp-*",".*","staging","production","@backup-*"]})}static get allShared(){return this.projectIds.map(t=>j.shared(t))}static shared(t){if(!t)throw new Error("Should provide project context");let s=j.sharedInstances[t];return s||(s=new j({path:S.join(se,t)}),j.sharedInstances[t]=s,jt({projectId:t,pages:Te,components:je}),s)}static async getProductionState(t){var o,a;let s=j.productionStates.get(t);if(!s){const r=S.join(se,t,"production");if(s=await ze(r,{includeResources:!0})??tn(),!((o=s==null?void 0:s.config)!=null&&o.defaultLocale)){s.config??(s.config={});const u=qe.env.languages.map(c=>({locale:c.code,name:c.name}));s.config.defaultLocale=(a=u[0])==null?void 0:a.locale}j.productionStates.set(t,s)}return{...s,resources:await De().then(async r=>{var E,f;const{pages:u,components:c}=hs.default(r,"pages","components");let i=c;const d=await K.findByPk(t);if(d!=null&&d.useAllResources)i=c;else{const l=(await Pe.findAll({where:{projectId:t}})).map(b=>b.componentId);i=Object.fromEntries(Object.entries(c||{}).filter(([b])=>l.includes(b)))}return Object.keys(((E=s==null?void 0:s.resources)==null?void 0:E.components)||{}).length>0&&(i={...i,...(f=s==null?void 0:s.resources)==null?void 0:f.components}),{pages:u,components:i}}).catch(()=>({}))}}destroy(){this.cancelRelease(),this.save({flush:!0}),this.conns.forEach((s,o)=>this.closeConn(o)),this.awareness.destroy();const t=S.basename(this.options.path);delete j.sharedInstances[t],super.destroy()}initObserver(){Hs(this.syncedStore),Gs(this.syncedStore)}get draftYjsFilePath(){return S.join(this.options.path,"draft.yjs")}static async getStateByProjectId(t,s){if(s==="draft"){const o=j.shared(t);return JSON.parse(JSON.stringify(o.syncedStore))}return j.getProductionState(t)}async getState(t){if(t==="draft")return JSON.parse(JSON.stringify(this.syncedStore));const s=S.basename(this.options.path);return j.getProductionState(s)}async setState(t,s){const o=await Ct(s,{exportAssets:!1,includeResources:!0}),a=this.getPublishDir(t);if(w.mkdirSync(S.dirname(a),{recursive:!0}),w.rmSync(a,{force:!0,recursive:!0}),w.renameSync(o,a),t==="production"){const r=S.basename(this.options.path);j.productionStates.set(r,s)}}getPublishDir(t){return S.join(this.options.path,t)}checkAndScheduleRelease(){this.conns.size===0&&this.scheduleRelease()}scheduleRelease(){this.cancelRelease();const t=S.basename(this.options.path);this.releaseTimer=setTimeout(()=>{y.info(`[SiteState] releasing instance due to no active connections: ${t}`),this.conns.size===0&&(this.releaseTimer=void 0,this.destroy())},j.RELEASE_DELAY),y.info(`[SiteState] scheduled release for project ${t} in ${j.RELEASE_DELAY/1e3}s`)}cancelRelease(){if(this.releaseTimer){clearTimeout(this.releaseTimer),this.releaseTimer=void 0;const t=S.basename(this.options.path);y.info(`[SiteState] cancelled scheduled release for project ${t}`)}}static async pageUrlMap(t,s){var r,u;let{projectIds:o}=this;s&&(o=[s]);const a={};for(const c of o){const i=await K.findByPk(c);if(!i)continue;const d=await j.getStateByProjectId(c,t),E=i.slug||c,f=gs.default(C.default.env.languages.map(l=>l.code),d.supportedLocales.map(l=>l.locale)),p=(l,m)=>{E&&(a[q.joinURL("/",E,l)]={...m,shouldRedirect:!0,mainPage:!0}),a[q.joinURL("/",c,l)]={...m,shouldRedirect:!0,mainPage:!0};for(const b of f){const _={...m,locale:b};a[q.joinURL("/",b,c,l)]=_,E&&(a[q.joinURL("/",b,E,l)]=_)}};if(t==="draft")for(const l of d.routeIds||[]){const m=(r=d==null?void 0:d.routes)==null?void 0:r[l];if(!m)continue;if(m.params&&m.params.length>0){const A=Ee.generateParamCombinations({basePath:m.path,params:m.params,routeId:m.id,paramsOptions:m.paramsOptions,currentIndex:0,currentParams:[],currentOptionIds:[],result:[]});for(const M of A){const Y=M.path,te={projectId:c,projectSlug:E,pageSlug:Y,pageId:m.displayTemplateId||"",routeId:l,defaultLocale:f==null?void 0:f[0],locales:f,publishedAt:d.config.publishedAt,isPublic:m.isPublic&&((u=M==null?void 0:M.routeMetaData)==null?void 0:u.isPublic)};p(Y,te)}}const b=m.path,_={projectId:c,projectSlug:E,pageSlug:b,pageId:m.displayTemplateId||"",routeId:l,defaultLocale:f==null?void 0:f[0],locales:f,publishedAt:d.config.publishedAt,isPublic:m.isPublic};p(b,_)}for(const l of d.pageIds){const m=d.pages[l];if(!m||t==="production"&&!m.isPublic)continue;const b=m.slug,_=i.slug||c,A={projectId:c,projectSlug:_,pageSlug:b,pageId:l,defaultLocale:f==null?void 0:f[0],locales:f,publishedAt:d.config.publishedAt,isPublic:m.isPublic,templateConfig:m.templateConfig};p(b,A)}}return a}getDocumentSize(){return V.encodeStateAsUpdate(this).byteLength}static getInstancesSizeInfo(){const t=[];for(const[s,o]of Object.entries(j.sharedInstances)){const a=o.getDocumentSize();t.push({projectId:s,sizeInBytes:a,sizeInMB:`${(a/(1024*1024)).toFixed(2)} MB`,activeConnections:o.conns.size})}return t}static startPeriodicCheck(){this.periodicCheckTimer||(this.periodicCheckTimer=setInterval(()=>{this.performPeriodicCheck()},this.PERIODIC_CHECK_INTERVAL),y.info(`[SiteState] periodic check started, interval: ${this.PERIODIC_CHECK_INTERVAL/(60*60*1e3)} hours`))}static stopPeriodicCheck(){this.periodicCheckTimer&&(clearInterval(this.periodicCheckTimer),this.periodicCheckTimer=void 0,y.info("[SiteState] periodic check stopped"))}static performPeriodicCheck(){const t=Object.keys(j.sharedInstances).length,s=[],o=[];for(const[a,r]of Object.entries(j.sharedInstances))r.conns.size===0?s.push({projectId:a,instance:r}):o.push({projectId:a,connections:r.conns.size});if(y.info(`[SiteState] periodic check summary: total instances: ${t}, with connections: ${o.length}, without connections: ${s.length}`),s.length>0){y.info(`[SiteState] releasing ${s.length} instances without connections:`,s.map(r=>r.projectId));let a=0;for(const{projectId:r,instance:u}of s)try{y.info(`[SiteState] releasing instance due to periodic check: ${r}`),u.destroy(),a++}catch(c){y.error(`[SiteState] failed to release instance ${r} during periodic check:`,c)}y.info(`[SiteState] periodic check completed: ${a}/${s.length} instances released successfully`)}else t>0?y.debug("[SiteState] periodic check: all instances have active connections"):y.debug("[SiteState] periodic check: no instances exist")}};v(j,"PRODUCTION_CACHE_TTL",7*24*60*60*1e3),v(j,"RELEASE_DELAY",5*60*1e3),v(j,"PERIODIC_CHECK_INTERVAL",2*60*60*1e3),v(j,"sharedInstances",{}),v(j,"productionStates",new Ae.LRUCache({max:100,ttl:j.PRODUCTION_CACHE_TTL})),v(j,"periodicCheckTimer");let z=j;async function sn(e,n,t){if(!e||!w.existsSync(e)||!w.lstatSync(e).isFile())return null;let s=t[e];return s||(s=(async()=>{var o;try{const a=(o=await zs({filePath:e,fileName:n}))==null?void 0:o.data;return a==null?void 0:a.filename}catch(a){return y.error(`Failed to upload asset ${e}:`,a),null}})(),t[e]=s),s}const wt=async(e,n)=>{const t=S.basename(e),s=await He.call({name:Je,path:q.joinURL("/uploads",t),responseType:"stream",method:"GET"});if(s.status>=200&&s.status<400){const o=w.createWriteStream(n);await ns.pipeline(s.data,o)}else throw new Error(`download asset failed ${s.status}`)},bt=async(e,n)=>{await Promise.all(e.map(async t=>{try{await wt(t,S.join(n,S.basename(t)))}catch(s){y.error(`Failed to export assets: ${t}, ${s}`)}}))};function It(e){return Ke.test(e)?[e]:le.test(e)?(tt.lastIndex=0,Array.from(e.matchAll(tt)).map(t=>t[1]).filter(t=>!!t)):[]}async function ge(e,n,t){const{getFilename:s,exportAssets:o}=t,a=S.join(n,s(e));if(w.mkdirSync(S.dirname(a),{recursive:!0}),w.writeFileSync(a,ne.stringify(e)),o){const u=be(e,c=>typeof c=="string"&&(Ke.test(c)||le.test(c))).map(c=>{const i=Ge.default(e,c);return It(i)}).flat().filter(Boolean);await bt(u,S.dirname(a))}}const st=new Ae.LRUCache({max:20,ttl:30*24*60*60*1e3});async function nt(e,n,t){var u;const s=be(e,c=>typeof c=="string"&&(Ke.test(c)||le.test(c))),o=ys.default(2),a=s.map(c=>o(async()=>{try{const i=Ge.default(e,c),d=It(i);for(const E of d){const f=S.basename(E),p=t.getFilePath(E,c),l=p?`${p}:${f}`:f,m=st.get(l);if(m){le.test(i)||Xe.default(e,c,m);return}const b=await sn(p,f,n);b&&(le.test(i)||Xe.default(e,c,b),st.set(l,b))}}catch(i){y.error(`Failed to process upload for path ${c.join(".")}:`,i.message||i.reason)}})),r=await Promise.allSettled(a);(u=t.onFinish)==null||u.call(t,r)}async function Ct(e,{exportAssets:n,pageIds:t="all",componentIds:s="all",rawConfig:o,includeResources:a=!1,routeIds:r="all"}={}){var ae,I,g,O,D,W,T,$,H,Q,J,re;const u=t==="all"?e.pageIds:t,c=de.getComponentDependencies({state:e,pageIds:u,componentIds:s==="all"?Object.keys(e.components):s}),i=r==="all"?e.routeIds:r,d=h=>{var P;return{id:h.id,name:h.name,isTemplateSection:h.isTemplateSection??!1,templateDescription:h.templateDescription,llmConfig:h.llmConfig,component:h.component,config:h.config,visibility:h.visibility,sections:h!=null&&h.sectionIds?B((P=h==null?void 0:h.sectionIds)==null?void 0:P.map(R=>{var N;const U=(N=h.sections)==null?void 0:N[R];return U&&d(U)})):void 0}},E=(h,P)=>{var R;return{id:h.id,createdAt:h.createdAt,updatedAt:h.updatedAt,publishedAt:h.publishedAt,isPublic:h.isPublic??!0,templateConfig:h.templateConfig,meta:((R=h.locales)==null?void 0:R[P])??{},sections:B(h.sectionIds.map(U=>{const N=h.sections[U];return N&&d(N)})),dataSource:Object.fromEntries(Object.entries(h.dataSource||{}).map(([U,N])=>[U,(N==null?void 0:N[P])??{}]))}},f=h=>({id:h.id,createdAt:h.createdAt,updatedAt:h.updatedAt,publishedAt:h.publishedAt,path:h.path,handler:h.handler,isPublic:h.isPublic??!0,params:h.params??[],enabledGenerate:h.enabledGenerate??!1,displayTemplateId:h.displayTemplateId,dataSource:h.dataSource}),p=B(i.map(h=>{const P=e.routes[h];return P&&f(P)})),l=B(e.supportedLocales.map(h=>h.locale).flatMap(h=>u.map(P=>{const R=e.pages[P];return R&&{locale:h,slug:R.slug,page:E(R,h)}}))),m=Et(),b=S.join(m,"pages");w.mkdirSync(b,{recursive:!0});const _=S.join(m,"components");w.mkdirSync(_,{recursive:!0});const A=S.join(m,"routes");w.mkdirSync(A,{recursive:!0});for(const{locale:h,slug:P,page:R}of l)await ge(R,b,{getFilename:()=>`${Ce(P)||"index"}.${h}.yml`,exportAssets:n});for(const h of p)await ge(h,A,{getFilename:()=>`${Ce(h.path)||"index"}.yml`,exportAssets:n});for(const h of c){const P=(ae=e.components[h])==null?void 0:ae.data;P&&await ge(P,_,{getFilename:R=>`${R.name||"unnamed"}.${R.id}.yml`,exportAssets:n})}const M=S.join(m,".blocklet/pages/pages.config.yml");w.mkdirSync(S.dirname(M),{recursive:!0});const Y={pages:B(u.map(h=>{const P=e.pages[h];return P&&{id:h,slug:P.slug}})),routes:B(i.map(h=>{const P=e.routes[h];return P&&{id:h,path:P.path}})),components:B(c.map(h=>{var R;const P=(R=e.components[h])==null?void 0:R.data;return P&&{id:h,name:P.name}})),...a?{resources:{components:B(Object.keys(((I=e.resources)==null?void 0:I.components)||{}).filter(h=>c.includes(h)).map(h=>{var P,R,U,N;return{id:h,name:(N=(U=(R=(P=e.resources)==null?void 0:P.components)==null?void 0:R[h])==null?void 0:U.component)==null?void 0:N.name}}))}}:{},supportedLocales:e.supportedLocales,config:e.config};w.writeFileSync(M,ne.stringify(Y));const te=S.join(m,"config.source.json");if(o&&w.writeFileSync(te,JSON.stringify(o)),a){const h=S.join(m,"resources"),P=S.join(h,"components");w.mkdirSync(P,{recursive:!0});for(const N of Object.keys(((g=e==null?void 0:e.resources)==null?void 0:g.components)??{}).filter(G=>c.includes(G))){const G=(W=(D=(O=e.resources)==null?void 0:O.components)==null?void 0:D[N])==null?void 0:W.component;G&&await ge(G,P,{getFilename:X=>`${X.name||"unnamed"}.${X.id}.yml`,exportAssets:n})}const R=S.join(m,"chunks");w.mkdirSync(R,{recursive:!0});const{chunks:U}=await De();for(const N of Object.keys(((T=e==null?void 0:e.resources)==null?void 0:T.components)??{}).filter(G=>c.includes(G))){const G=(Q=(H=($=e.resources)==null?void 0:$.components)==null?void 0:H[N])==null?void 0:Q.component;if(G&&((J=G.renderer)==null?void 0:J.type)==="react-component"){const X=((re=G.renderer)==null?void 0:re.chunks)??[];if((X==null?void 0:X.length)>0)for(const _e of X){const We=S.join(R,_e),ke=U==null?void 0:U[_e];try{ke&&w.existsSync(ke)&&!w.existsSync(We)&&w.copyFileSync(ke,We)}catch(Dt){y.error(`copy chunk ${_e} error`,Dt.message)}}}}}return m}async function ze(e,{importAssets:n,includeResources:t}={}){var a,r,u,c;if(!w.existsSync(e))return null;let s,o=!1;try{w.lstatSync(e).isDirectory()?s=e:/\.(tgz|gz|tar)$/.test(e)&&(o=!0,s=Et(),await os.x({file:e,C:s}));const i=Ne.globSync("**/.blocklet/pages/pages.config.yml",{cwd:s,absolute:!0}).at(0),d=i&&S.join(S.dirname(i),"../../pages"),E=i&&S.join(S.dirname(i),"../../components"),f=i&&S.join(S.dirname(i),"../../chunks"),p=i&&S.join(S.dirname(i),"../../routes");if(!i)return null;const l=ne.parse(w.readFileSync(i).toString()),m=(I,g,O)=>{let D=S.join(I,`${g}${O?`.${O}`:""}.yml`);return(!w.existsSync(D)||!w.lstatSync(D).isFile())&&(D=S.join(I,g,`index${O?`.${O}`:""}.yml`),!w.existsSync(D)||!w.lstatSync(D))?null:ne.parse(w.readFileSync(D).toString())},b=(I,g)=>{try{const O=Ne.globSync(`*.${g}.yml`,{cwd:I,absolute:!0})[0];return O?ne.parse(w.readFileSync(O).toString()):null}catch(O){y.error("parse component error",O)}return null},_=(I,g)=>{let O=S.join(I,`${g}.yml`);return(!w.existsSync(O)||!w.lstatSync(O).isFile())&&(O=S.join(I,g,"index.yml"),!w.existsSync(O)||!w.lstatSync(O))?null:ne.parse(w.readFileSync(O).toString())},A=B(l.pages.map(({slug:I})=>{var W;const g=B(l.supportedLocales.map(({locale:T})=>{const $=d?m(d,Ce(I),T):void 0;if($)return{locale:T,page:$};const H=d?m(d,I,T):void 0;return H&&{locale:T,page:H}})),O=(W=g[0])==null?void 0:W.page;if(!O)return null;const D=O.sections.map(Vt.unzipSection);return{id:O.id||Qe.nextId(),createdAt:O.createdAt,updatedAt:O.updatedAt,publishedAt:O.publishedAt,isPublic:O.isPublic??!0,templateConfig:O.templateConfig,slug:I,sections:Object.fromEntries(D.map(T=>[T.id,T])),sectionIds:D.map(T=>T.id),locales:Object.fromEntries(g.map(({locale:T,page:$})=>[T,$.meta])),dataSource:O.dataSource?Object.fromEntries([...new Set(g.flatMap(({page:T})=>Object.keys(T.dataSource??{})))].map(T=>[T,Object.fromEntries(g.map(({locale:$,page:H})=>{var J;const Q=(J=H.dataSource)==null?void 0:J[T];return[$,Q||{}]}))])):Object.fromEntries([...new Set(g.flatMap(({page:T})=>T.sections.map($=>$.id)))].map(T=>[T,Object.fromEntries(g.map(({locale:$,page:H})=>{var re;const Q=(re=H.dataSource)==null?void 0:re[T];if(Q)return[$,Q];const J=H.sections.find(h=>h.id===T);return[$,(J==null?void 0:J.properties)||{}]}))]))}})),M=B(((a=l==null?void 0:l.routes)==null?void 0:a.map(({path:I})=>{const g=p?_(p,Ce(I)):void 0;return{...g,id:(g==null?void 0:g.id)||Qe.nextId(),createdAt:(g==null?void 0:g.createdAt)??new Date().toISOString(),updatedAt:(g==null?void 0:g.updatedAt)??new Date().toISOString(),publishedAt:new Date(0).toISOString(),path:(g==null?void 0:g.path)??`/${g==null?void 0:g.id}`,params:g==null?void 0:g.params,handler:(g==null?void 0:g.handler)??"Pages Kit",isPublic:(g==null?void 0:g.isPublic)??!0,enabledGenerate:(g==null?void 0:g.enabledGenerate)??!1,displayTemplateId:(g==null?void 0:g.displayTemplateId)??void 0,dataSource:(g==null?void 0:g.dataSource)??{}}}))??[]),Y=E?B(((r=l.components)==null?void 0:r.map(({id:I})=>b(E,I)))??[]):[];if(n){const I=(...g)=>{y.info(`[${o?S.basename(e):S.basename(S.join(e,"../../../../"))}] importAssets:`,...g)};try{I("wait image-bin api ready"),await Ss.default({resources:[`${He.getComponentWebEndpoint(Es)}/api/sdk/uploads`],validateStatus:D=>D>=200&&D<=500}),I("image-bin api is ready");const g={},O={};I("start to upload assets"),await Promise.allSettled([nt(Y,g,{getFilePath:D=>E&&S.join(E,D),onFinish:D=>{I(`upload ${D.length} component assets`)}}),nt(A,O,{getFilePath:(D,W)=>{const T=Ge.default(A,W.slice(0,1));return d&&S.join(d,S.dirname(T.slug),D)},onFinish:D=>{I(`upload ${D.length} page assets`)}})]),I("upload assets done"),global.gc&&global.gc()}catch(g){I("Error during asset import:",g)}}const te={};if(t){const I=i&&S.join(S.dirname(i),"../../resources/components"),g=B(((c=(u=l.resources)==null?void 0:u.components)==null?void 0:c.map(({id:O})=>b(I,O)))??[]);g.length>0&&(te.components=Object.fromEntries(g.map((O,D)=>[O.id,{index:D,component:O}])))}const ae={};if(f&&w.existsSync(f)){const I=w.readdirSync(f);for(const g of I)ae[g]=S.join(f,g)}return{supportedLocales:l.supportedLocales,pageIds:A.map(I=>I.id),components:Object.fromEntries(Y.map((I,g)=>[I.id,{index:g,data:I}])),pages:Object.fromEntries(A.map(I=>[I.id,I])),config:l.config||{},resources:te,chunks:ae,routeIds:M.map(I=>I.id),routes:Object.fromEntries(M.map(I=>[I.id,I])),dataSourceIds:[],dataSources:{}}}finally{o&&s&&w.rmSync(s,{force:!0,recursive:!0})}}async function Be(e,n,{routes:t,mergeMode:s="byUpdateTime",deleteRoutes:o=!1,publishMode:a=void 0}={}){try{a&&mt(a)}catch(f){y.error("clear preload page cache error",{error:f})}const{pages:r,pageIds:u,routeIds:c,routes:i,supportedLocales:d}=e;if(a==="production"){let f=t??[],p=null;for(const l of c??[]){const m=i==null?void 0:i[l];if(m!=null&&m.params&&(m==null?void 0:m.params.length)>0&&(m!=null&&m.paramsOptions)&&(m==null?void 0:m.paramsOptions.length)>0){const b=Ee.generateParamCombinations({basePath:m.path,params:m.params,routeId:m.id,paramsOptions:m.paramsOptions,currentIndex:0,currentParams:[],currentOptionIds:[],result:[]}),_=Object.fromEntries(b.map(A=>[`${l}-${A.paramOptionIds.join("-")}`,A]));p={...p||{},..._},t||(f=[...f,...b.map(A=>`${l}-${A.paramOptionIds.join("-")}`)])}else t||f.push(l)}y.info("routeIds to be published: ",f);for(const l of f){let m=l;if(m.includes("-")){const[A]=m.split("-");m=A}const b=i==null?void 0:i[m];if(!b){const A=n.pageIds.indexOf(m);A!==-1&&o&&(n.pageIds.splice(A,1),delete n.pages[m]);for(const M of n.pageIds)M.includes(`${m}-`)&&(n.pageIds.splice(n.pageIds.indexOf(M),1),delete n.pages[M]);y.info("delete main route page",m);continue}if(l.includes("-")&&!(p!=null&&p[l])){const A=n.pageIds.indexOf(l);A!==-1&&o&&(n.pageIds.splice(A,1),delete n.pages[l]),y.info("delete page",l);continue}if(!b.displayTemplateId){y.info("no display template",l);continue}const _=r[b.displayTemplateId];if(!_){y.info("no template page",l);continue}if(n.pageIds.includes(l)){if(y.info("has need update page",l),s==="replace")n.pages[l]=xe({page:_,route:b,state:e,routeId:l,routePathInfo:p==null?void 0:p[l]}),y.info("replace page",l);else if(s==="byUpdateTime"){const A=n.pages[b.id];(!A||b.updatedAt&&b.updatedAt>A.updatedAt)&&(n.pages[l]=xe({page:_,route:b,state:e,routeId:l,routePathInfo:p==null?void 0:p[l]}),y.info("replace page by update time",l))}}else n.pageIds.push(l),n.pages[l]=xe({page:_,route:b,state:e,routeId:l,routePathInfo:p==null?void 0:p[l]}),y.info("add page",l)}if(o&&!t)for(const l of n.pageIds)f!=null&&f.includes(l)||(delete n.pages[l],y.info("delete page",l)),n.pageIds=[...n.pageIds].filter(m=>f==null?void 0:f.includes(m))}else{for(const f of u){const p=r[f];if(p)if(n.pageIds.includes(p.id)){if(s==="replace")n.pages[p.id]=p;else if(s==="byUpdateTime"){const l=n.pages[p.id];(!l||p.updatedAt&&p.updatedAt>l.updatedAt)&&(n.pages[p.id]=p)}}else n.pageIds.push(p.id),n.pages[p.id]=p}for(const f of c){const p=i[f];if(p)if(n.routeIds.includes(p.id)){if(s==="replace")n.routes[p.id]=p;else if(s==="byUpdateTime"){const l=n.routes[p.id];(!l||p.updatedAt&&p.updatedAt>l.updatedAt)&&(n.routes[p.id]=p)}}else n.routeIds.push(p.id),n.routes[p.id]=p}}if(n.supportedLocales.splice(0,n.supportedLocales.length),n.supportedLocales.push(...ms.default(d)),o)for(const f of Object.keys(n.components))delete n.components[f];let E=JSON.parse(JSON.stringify(e.components));E=Object.fromEntries(await Promise.all(Object.entries(E).map(async([f,p])=>{const l=await Ot(p==null?void 0:p.data);return[f,{...p,data:l}]}))),Object.assign(n.components,E),Object.assign(n.config,JSON.parse(JSON.stringify(e.config))),lt.default(e.resources.components)||(n.resources.components=JSON.parse(JSON.stringify(e.resources.components||{})))}const Ot=Ve(async e=>{var n;if(!lt.default(e==null?void 0:e.properties))return e;if(((n=e==null?void 0:e.renderer)==null?void 0:n.type)==="react-component"){const{script:t}=(e==null?void 0:e.renderer)||{};if(t&&t.includes("PROPERTIES_SCHEMA"))try{const s=await St(t,"PROPERTIES_SCHEMA",e.id);s&&s.length>0&&e&&(e.properties={},s.forEach((o,a)=>{e!=null&&e.properties&&(e.properties[o.id]={index:a,data:o})}))}catch(s){y.error("checkPropertiesFromCode error",{componentId:e.id,name:e.name},{error:s})}}return e},{keyGenerator:e=>{var i,d,E,f;const n=(e==null?void 0:e.id)||"",t=(e==null?void 0:e.name)||"",s=((i=e==null?void 0:e.renderer)==null?void 0:i.type)||"",o=(e==null?void 0:e.properties)||{},a=(e==null?void 0:e.updatedAt)||"",r=Z.createHash("md5").update(JSON.stringify(o)).digest("hex");let u="",c="";return((d=e==null?void 0:e.renderer)==null?void 0:d.type)==="react-component"&&(u=Z.createHash("md5").update(((E=e==null?void 0:e.renderer)==null?void 0:E.script)||"").digest("hex"),c=Z.createHash("md5").update(((f=e==null?void 0:e.renderer)==null?void 0:f.editComponent)||"").digest("hex")),JSON.stringify(["checkPropertiesFromCode",n,t,s,r,a,u,c])},lruOptions:{max:100,ttl:1e3*60*60},subdir:"checkPropertiesFromCode"});let Oe,oe,Te,je,Ye;function At(){return Oe=(async()=>{const e=He.getResources({types:[{did:Je,type:Ue},{did:Bs,type:Ue}]});oe=(await Promise.all(e.map(async t=>{const s=t.path?await ze(t.path,{importAssets:!1}):void 0;return s?{blockletId:t.did,state:s,blockletTitle:t.title}:void 0}))).filter(t=>!!t),Te=oe.reduce((t,s)=>Object.assign(t,Object.fromEntries(Object.values(s.state.pages).map(o=>o?[o==null?void 0:o.id,{page:o,blockletId:s.blockletId}]:[]))),{});const n=oe.reduce((t,s)=>Object.assign(t,Object.fromEntries(Object.values(s.state.components).map(o=>[o.data.id,{blockletId:s.blockletId,component:o.data}]))),{});je=Object.fromEntries(await Promise.all(Object.entries(n).map(async([t,s])=>{const o=await Ot(s.component);return[t,{...s,component:o}]}))),Ye=oe.reduce((t,s)=>Object.assign(t,s.state.chunks),{})})(),Oe}function Pt(e){const n=ct.default(async()=>{await At().catch(t=>{y.error("load resource states error",{error:t})}),await(e==null?void 0:e({states:oe,pages:Te,components:je,chunks:Ye}))},3e3,{leading:!1,trailing:!0});return n(),C.default.events.on(C.default.Events.componentAdded,n),C.default.events.on(C.default.Events.componentRemoved,n),C.default.events.on(C.default.Events.componentStarted,n),C.default.events.on(C.default.Events.componentStopped,n),C.default.events.on(C.default.Events.componentUpdated,n),C.default.events.on(Fe,n),()=>{C.default.events.off(C.default.Events.componentAdded,n),C.default.events.off(C.default.Events.componentRemoved,n),C.default.events.off(C.default.Events.componentStarted,n),C.default.events.off(C.default.Events.componentStopped,n),C.default.events.off(C.default.Events.componentUpdated,n),C.default.events.off(Fe,n)}}const Tt=Symbol.for("GLOBAL_RESOURCE_STATES_LISTENER_KEY"),Se=globalThis;var ot;(ot=Se[Tt])==null||ot.call(Se);Se[Tt]=Pt(async({pages:e,components:n})=>{const{projectIds:t}=z;y.info(`start update resource states projects(${t.length})`,t),await Promise.race([new Promise(s=>{setTimeout(()=>{s({})},30*1e3)}),Promise.all(t.map(async s=>{jt({projectId:s,pages:e,components:n})}))]).catch(s=>{y.error("update resource states failed:",s)})});z.startPeriodicCheck();process.on("beforeExit",()=>{z.stopPeriodicCheck()});process.on("SIGINT",()=>{z.stopPeriodicCheck(),process.exit(0)});process.on("SIGTERM",()=>{z.stopPeriodicCheck(),process.exit(0)});async function jt({projectId:e,pages:n,components:t}){const s=z.sharedInstances[e];if(!s){y.info(`projectId: ${e} not found in sharedInstances`);return}s.syncedStore.resources.pages=n;const o=await K.findByPk(e);if(o!=null&&o.useAllResources)s.syncedStore.resources.components=t;else{const r=(await Pe.findAll({where:{projectId:e}})).map(c=>c.componentId),u=Object.fromEntries(Object.entries(t||{}).filter(([c])=>r.includes(c)));s.syncedStore.resources.components=u}y.info(`update [${e}] resource states:`,{pages:Object.keys(s.syncedStore.resources.pages||{}).length,components:Object.keys(s.syncedStore.resources.components||{}).length})}async function nn(){y.info("trigger reload all project resource"),C.default.events.emit(Fe)}async function De({ensureLoaded:e=!0}={}){return e&&(Oe??(Oe=At()),await Oe),{states:oe,pages:Te,components:je,chunks:Ye}}exports.COMPONENT_DID=Je;exports.CUSTOM_COMPONENT_CACHE_DURATION_IN_SECONDS=ut;exports.GET_SERVER_SIDE_PROPS_TIMEOUT_IN_SECONDS=$e;exports.PUBLISH_MODES=en;exports.Project=K;exports.RESOURCE_TYPE=Ue;exports.SITE_STATE_PATH=se;exports.STATE_MODES=Zs;exports.SiteState=z;exports.clearPreloadComponentsCache=ft;exports.clearPreloadComponentsCacheByMode=mt;exports.downloadAsset=wt;exports.downloadAssets=bt;exports.fromPackage=ze;exports.getComponentFromState=ue;exports.getComponentFromStateByName=Us;exports.getExportSchemaValueFromCode=St;exports.getMultiTenantAllProjectAccessPassports=Is;exports.getPreloadComponent=gt;exports.getPreloadComponents=Ns;exports.getPreloadComponentsCacheKey=ht;exports.getResourceStates=De;exports.initPackResourceStates=Pt;exports.isMultiTenant=bs;exports.logger=y;exports.mergeState=Be;exports.toPackage=Ct;exports.triggerReloadAllProjectResource=nn;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const D=require("react/jsx-runtime"),U=require("@mui/material"),k=require("ufo"),H=require("@blocklet/js-sdk"),ee=require("lodash/isEmpty"),te=require("yaml"),oe=require("@arcblock/ux/lib/Locale/context"),R=require("@blocklet/pages-kit/utils/common"),ne=require("@blocklet/pages-kit/utils/page-model"),F=require("@syncedstore/core"),re=require("@syncedstore/react"),se=require("ahooks"),_=require("immer"),ce=require("lodash/cloneDeep"),ie=require("lodash/debounce"),m=require("react"),W=require("react-router-dom"),ae=require("y-indexeddb"),de=require("y-websocket"),le=require("yjs");require("@blocklet/pages-kit/types");const A=o=>o&&o.__esModule?o:{default:o};function ue(o){if(o&&o.__esModule)return o;const n=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(o){for(const l in o)if(l!=="default"){const w=Object.getOwnPropertyDescriptor(o,l);Object.defineProperty(n,l,w.get?w:{enumerable:!0,get:()=>o[l]})}}return n.default=o,Object.freeze(n)}const fe=A(ee),me=ue(te),Se=A(F),J=A(ce),V=A(ie),pe=o=>{const n=blocklet==null?void 0:blocklet.componentMountPoints.find(l=>l.name===o);return n?n.mountPoint:"/"};function N(){const{pathname:o}=window.location,n=o.match(/\/admin\/(maker|previewer)\/([^/]+)/),l=n==null?void 0:n[2],w=window.__PROJECT_ID__;if(!l&&!w)throw new Error("Unable to get projectId from pathname");return l||w}function ge(o){return`${o}:pages:version`}function Pe(o,n){return n==="yaml"?fe.default(o)?"":me.stringify(o,{indent:2}):n==="json"?JSON.parse(JSON.stringify(o||{})):n==="array"?JSON.parse(JSON.stringify(o||[])):o}function we({error:o}){return D.jsx(U.Box,{children:D.jsx(U.Alert,{severity:"error",children:o.message})})}var G;const q=((G=window.blocklet)==null?void 0:G.prefix)||"/",$=H.createAxios({timeout:200*1e3}),Ie=window.location.protocol==="https:"?"wss":"ws",ye=o=>k.joinURL(`${Ie}://${window.location.hostname}`,q,`api/${o}/ws/pages`),he="z8ia1mAXo8ZE7ytGF36L5uBf9kD2kenhqFGp9";var B;(B=blocklet==null?void 0:blocklet.componentMountPoints.find(o=>o.did===he))!=null&&B.mountPoint||k.joinURL(q,"/image-bin");function Ce(o){return o&&!/^(https?:\/\/|\/)/.test(o)?window.location.origin+k.joinURL(q,"uploads",o):o}const je=window.innerWidth<=750;function ve(o,n,l){if(!o||/\.gif/.test(o))return o;const w=(je?n/1.5:n)*(l==="quality"?1.5:1);return be(o,{imageFilter:"resize",w,f:"webp"})}function be(o,n){return!o||!n?o:k.withQuery(o,n)}async function Oe(o){return $.get(`/api/projects/${o}`).then(n=>n.data)}async function Me(o){return $.post(`/api/projects/${o.id}/update`,o).then(n=>n.data)}const Le=500,z=m.createContext(null);function xe({url:o,name:n,children:l,waitingSynced:w}){const[L,O]=m.useState(!1),{locale:p}=oe.useLocaleContext(),j=T(),E=`${j}:MakerLocalState`,e=`${j}:${n}`,[t,c]=se.useLocalStorageState(E,{defaultValue:{},listenStorageChange:!0}),s=m.useRef(t);s.current=t;const i=m.useMemo(()=>Se.default({dataSourceIds:[],dataSources:{},pages:{},pageIds:[],routes:{},routeIds:[],components:{},supportedLocales:[],config:{},resources:{}}),[]),r=m.useMemo(()=>F.getYjsDoc(i),[i]);m.useMemo(()=>new ae.IndexeddbPersistence(e,r),[e,r]);const a=m.useMemo(()=>new de.WebsocketProvider(o,e,r,{params:{},resyncInterval:5*60*1e3}),[o,e,r]),d=m.useCallback(()=>{a&&(a.disconnect(),a.connect())},[a]),u=m.useMemo(()=>new le.UndoManager([r.getArray("pageIds"),r.getMap("pages"),r.getArray("supportedLocales"),r.getMap("config"),r.getMap("dataSources"),r.getArray("dataSourceIds"),r.getArray("routeIds"),r.getMap("routes")],{doc:r}),[r]),[f,S]=m.useState(null),[x,I]=m.useState(!1),[y,v]=m.useState(void 0),g=m.useCallback(async()=>{if(j){I(!0);try{const P=await Oe(j);S(P)}catch(P){console.error("Failed to fetch project:",P)}finally{I(!1)}}},[j]),b=m.useCallback(async(P,h)=>{var M;if(v(void 0),!!j){h!=null&&h.optimisticUpdate&&f&&S(C=>({...C,...P}));try{const C=await Me({...P});S(C)}catch(C){console.error("Failed to update project:",C),h!=null&&h.optimisticUpdate&&S(f),v((M=C==null?void 0:C.response)==null?void 0:M.data)}}},[j,f]);m.useEffect(()=>{j&&g()},[j,g]);const Z=m.useMemo(()=>({doc:r,state:i,localState:{...t,currentLocale:p},setLocalState:P=>c(typeof P=="function"?h=>P(h??{}):P),undoManager:u,projectState:{project:f,isLoadingProject:x,error:y},updateProject:b,forceSync:d}),[r,i,JSON.stringify(t),c,u,f,x,b,y,p,d]);return m.useEffect(()=>{u.on("stack-item-added",({stackItem:P})=>{const{currentPageId:h,currentLocale:M,pages:C}=s.current;P.meta.set("localState",{currentPageId:h,currentLocale:M,pages:C})}),u.on("stack-item-popped",({stackItem:P})=>{const h=P.meta.get("localState");h&&c(M=>({...M,...h}))})},[u,c]),m.useEffect(()=>{a.awareness.setLocalState(t)},[a,t]),m.useEffect(()=>{a.once("synced",()=>O(!0));const P=()=>{c(C=>({...C,networkStatus:void 0}))},h=()=>{c(C=>({...C,networkStatus:"offline"}))},M=V.default(({status:C})=>{C==="connected"?P():C==="disconnected"&&h()},Le);return a.on("status",M),window.addEventListener("online",P),window.addEventListener("offline",h),()=>{a.off("status",M),window.removeEventListener("online",P),window.removeEventListener("offline",h)}},[a,c]),w&&!L?null:D.jsx(z.Provider,{value:Z,children:l})}const K=()=>{const o=m.useContext(z);if(!o)throw new Error("Context is null");const n=re.useSyncedStore(o.state),{setLocalState:l,localState:w}=o,L=W.useNavigate(),O=T(),p=m.useMemo(()=>({get currentPage(){const{localState:{currentPageId:e}}=o;return e?n.pages[e]:void 0},get currentSection(){var s,i,r,a,d;const{localState:{currentPageId:e,...t}}=o;if(!e)return;const c=(i=(s=t.pages)==null?void 0:s[e])==null?void 0:i.currentSectionId;if(c)return((r=n.pages[e])==null?void 0:r.sections[c])??((d=(a=this.currentPageModel)==null?void 0:a.getComponentById(c))==null?void 0:d.model)},get currentSectionProperties(){var r,a,d,u;const{localState:{currentPageId:e,...t}}=o;if(!e)return;const c=(a=(r=t.pages)==null?void 0:r[e])==null?void 0:a.currentSectionId;if(!c)return;const s=(u=(d=n.pages[e])==null?void 0:d.dataSource)==null?void 0:u[c];if(!s)return;const{currentLocale:i}=this.currentLocaleMap;return i?s[i]:void 0},get currentSectionPropertiesWithFallback(){var d,u,f,S;const{localState:{currentPageId:e,...t}}=o;if(!e)return;const c=(u=(d=t.pages)==null?void 0:d[e])==null?void 0:u.currentSectionId;if(!c)return;const s=(S=(f=n.pages[e])==null?void 0:f.dataSource)==null?void 0:S[c];if(!s)return;const{currentLocale:i,defaultLocale:r,fallbackLocale:a}=this.currentLocaleMap;if(i&&s[i])return s[i];if(r&&s[r])return s[r];if(a&&s[a])return s[a]},get currentLocaleMap(){var s;const{localState:{currentLocale:e},state:{supportedLocales:t,config:{defaultLocale:c}}}=o;return{currentLocale:e,defaultLocale:c,fallbackLocale:((s=t==null?void 0:t[0])==null?void 0:s.locale)??"en"}},get currentRoute(){var t;const{localState:{currentRouteId:e}}=o;return e?(t=n.routes)==null?void 0:t[e]:void 0},get currentPageModel(){const e=this.currentPage??null;if(e)return ne.getPageTemplateModel(e,!1)}}),[JSON.stringify(w),n]),j=m.useMemo(()=>({setCurrentSectionId:(e,t)=>{var c,s;e===w.currentPageId&&t===((s=(c=w.pages)==null?void 0:c[e])==null?void 0:s.currentSectionId)||(L(k.joinURL("/admin/maker",O??"","pages",e)),l(i=>_.produce(i,r=>{var a;r.currentPageId=e,r.currentComponentId=void 0,t!==void 0&&(r.pages??(r.pages={}),(a=r.pages)[e]??(a[e]={}),r.pages[e].currentSectionId=t??void 0),t?window.sessionStorage.setItem("iframe_show_id",`"${t}"`):window.sessionStorage.removeItem("iframe_show_id")})))},setCurrentComponentId:e=>{e!==w.currentComponentId&&(L(k.joinURL("/admin/maker",O??"","components",e)),l(t=>_.produce(t,c=>{c.currentComponentId=e})))},setCurrentRouteId:({routeId:e,dynamicParams:t})=>{l(c=>_.produce(c,s=>{s.currentRouteId=e,s.currentDynamicParams=t}))},setCustomComponentPreviewerProperties:(()=>{const e={};let t="";const c=V.default(()=>{l(s=>_.produce(s,i=>{i.customComponentPreviewerProperties??(i.customComponentPreviewerProperties={}),i.customComponentPreviewerProperties[t]={...i.customComponentPreviewerProperties[t],...J.default(e[t])},delete e[t]}))},5);return(s,i)=>{const r=e[s]??{};Object.assign(r,i),e[s]=r,t=s,c()}})(),setRouteGenerateProcess:e=>{l(t=>_.produce(t,c=>{e?c.routeGenerateProcess={...c.routeGenerateProcess,...e}:c.routeGenerateProcess={}}))},resetRouteGenerateProcess:()=>{l(e=>_.produce(e,t=>{t.routeGenerateProcess={progress:"complete"}}))}}),[l,L,O,p]),E=m.useMemo(()=>({addPage:(e,t)=>{var i,r,a,d,u,f;const c=(e==null?void 0:e.id)??R.nextId(),s={...e,id:c,createdAt:(e==null?void 0:e.createdAt)??new Date().toISOString(),updatedAt:(e==null?void 0:e.updatedAt)??new Date().toISOString(),publishedAt:new Date(0).toISOString(),slug:(e==null?void 0:e.slug)??`/${c}`,sections:(e==null?void 0:e.sections)??{},sectionIds:(e==null?void 0:e.sectionIds)??[],isPublic:(e==null?void 0:e.isPublic)??!0,templateConfig:(e==null?void 0:e.templateConfig)??{isTemplate:((i=e==null?void 0:e.templateConfig)==null?void 0:i.isTemplate)??!0,displayTemplateId:((r=e==null?void 0:e.templateConfig)==null?void 0:r.displayTemplateId)??void 0,dataSourceIds:((a=e==null?void 0:e.templateConfig)==null?void 0:a.dataSourceIds)??void 0,dataSourceParameters:((d=e==null?void 0:e.templateConfig)==null?void 0:d.dataSourceParameters)??{},enabledGenerate:((u=e==null?void 0:e.templateConfig)==null?void 0:u.enabledGenerate)??!1,agentId:((f=e==null?void 0:e.templateConfig)==null?void 0:f.agentId)??void 0}};return o.doc.transact(()=>{n.pages[s.id]=s,n.pageIds.splice(t??n.pageIds.length,0,s.id)}),s},addRoute:(e,t)=>{const c=(e==null?void 0:e.id)??R.nextId(),s={...e,id:c,createdAt:(e==null?void 0:e.createdAt)??new Date().toISOString(),updatedAt:(e==null?void 0:e.updatedAt)??new Date().toISOString(),publishedAt:new Date(0).toISOString(),path:(e==null?void 0:e.path)??`/${c}`,handler:(e==null?void 0:e.handler)??"Pages Kit",isPublic:(e==null?void 0:e.isPublic)??!0,params:(e==null?void 0:e.params)??[],enabledGenerate:(e==null?void 0:e.enabledGenerate)??!1,displayTemplateId:(e==null?void 0:e.displayTemplateId)??void 0,dataSource:(e==null?void 0:e.dataSource)??{}};return o.doc.transact(()=>{n.routes??(n.routes={}),n.routeIds??(n.routeIds=[]),n.routes[s.id]=s,n.routeIds.splice(t??n.routeIds.length,0,s.id)}),s},deleteRoute:e=>{var c;if(!e)return;const t=(c=n.routeIds)==null?void 0:c.indexOf(e);t!==void 0&&t!==-1&&o.doc.transact(()=>{var s,i;(s=n.routeIds)==null||s.splice(t,1),(i=n.routes)==null||delete i[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:c}=n,s=c.indexOf(e);s>=0&&c.splice(t,0,...c.splice(s,1))},addSection:(e,t,c,s)=>{const i=n.pages[e];if(!i)throw new Error(`Page ${e} is not exists`);const r={...t,id:t.id??R.nextId(),isTemplateSection:t.isTemplateSection??!0,llmConfig:t.llmConfig??{}},a=J.default(r.locales);return delete r.locales,o.doc.transact(()=>{var d,u,f;if(s&&s.component==="layout-block"){const S=(d=p.currentPageModel)==null?void 0:d.getComponentById(s.id);S&&((u=S.model).sections??(u.sections={}),S.model.sections[r.id]=r,(f=S.model).sectionIds??(f.sectionIds=[]),S.model.sectionIds.push(r.id))}else i.sections[r.id]=r,i.sectionIds.splice(c??i.sectionIds.length,0,r.id);a&&(i.dataSource??(i.dataSource={}),i.dataSource[r.id]=a)}),r},deleteSection:(e,t)=>{const c=n.pages[e];if(!c)throw new Error(`Page ${e} is not exists`);o.doc.transact(()=>{var a,d,u,f,S,x;const s=[],i=(a=p.currentPageModel)==null?void 0:a.getComponentById(t),r=i==null?void 0:i.parent;if(i&&(s.push(i.model.id,...i.all().map(I=>I.model.id)),(r==null?void 0:r.model.component)==="layout-block")){const I=(d=r.model.sectionIds)==null?void 0:d.indexOf(t);I!==void 0&&I!==-1&&((u=r.model.sectionIds)==null||u.splice(I,1),(f=r.model.sections)==null||delete f[t]),(S=r.model.config)!=null&&S.gridSettings&&Object.keys(r.model.config.gridSettings).forEach(y=>{var v;try{(v=r.model.config.gridSettings[y])==null||delete v[t]}catch{}}),((x=r.model.config)==null?void 0:x.backgroundSectionId)===t&&(r.model.config.backgroundSectionId=void 0)}s.forEach(I=>{var v,g;const y=c.sectionIds.indexOf(I);y!==-1&&c.sectionIds.splice(y,1),c.sections[I]&&delete c.sections[I],(v=c.dataSource)!=null&&v[I]&&((g=c.dataSource)==null||delete g[I])})})},lockSection:(e,t)=>{var i,r;if(!n.pages[e])throw new Error(`Page ${e} is not exists`);const s=(r=(i=p.currentPageModel)==null?void 0:i.getComponentById(t))==null?void 0:r.model;s&&(s.locked=!s.locked)},toggleSectionVisibility:(e,t,c)=>{var r,a;if(!n.pages[e])throw new Error(`Page ${e} is not exists`);const i=(a=(r=p.currentPageModel)==null?void 0:r.getComponentById(t))==null?void 0:a.model;i&&(i.visibility=c)},moveSection:(e,t,c,s)=>{var r,a,d,u,f,S,x,I;if(!n.pages[e])throw new Error(`Page ${e} is not exists`);if(s&&s!==t){const y=(r=p.currentPageModel)==null?void 0:r.getComponentById(t),v=(a=p.currentPageModel)==null?void 0:a.getComponentById(s),g=y==null?void 0:y.parent,b=v==null?void 0:v.parent;b&&g&&((d=b==null?void 0:b.model)==null?void 0:d.id)===((u=g==null?void 0:g.model)==null?void 0:u.id)?o.doc.transact(()=>{g.model.sectionIds.splice(y.getIndex(),1),g.model.sectionIds.splice(v.getIndex(),0,t)}):b&&g&&((f=b==null?void 0:b.model)==null?void 0:f.id)!==((S=g==null?void 0:g.model)==null?void 0:S.id)&&t!==s&&!((I=(x=y==null?void 0:y.model)==null?void 0:x.sectionIds)!=null&&I.includes(s))&&o.doc.transact(()=>{b.model.sections[t]=JSON.parse(JSON.stringify(y.model)),b.model.sectionIds.splice(v.getIndex(),0,t),g.model.sectionIds.splice(y.getIndex(),1),delete g.model.sections[t]})}},copySection:(e,t)=>{var u,f,S;if(!n.pages[e])throw new Error(`Page ${e} is not exists`);const s=(u=p.currentPageModel)==null?void 0:u.getComponentById(t);if(!(s!=null&&s.model))throw new Error(`Section ${t} is not exists`);const i=JSON.parse(JSON.stringify(s.model)),r=ke(i),a=r.id,d=s==null?void 0:s.parent;return d&&(d.model.sections[a]=r,d.model.sectionIds.push(a),j.setCurrentSectionId(e,a),(S=(f=p.currentPage)==null?void 0:f.dataSource)!=null&&S[t]&&(p.currentPage.dataSource[a]=JSON.parse(JSON.stringify(p.currentPage.dataSource[t])))),r},addDataSource:e=>{const t=e.id??R.nextId(),c={...e??{},id:t,createdAt:new Date().toISOString()};return o.doc.transact(()=>{n.dataSourceIds??(n.dataSourceIds=[]),n.dataSources??(n.dataSources={}),n.dataSourceIds.push(t),n.dataSources[t]=c}),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,p]);return{...o,state:n,actions:E,localActions:j,...p}},T=()=>{const{projectId:o}=W.useParams();return o??N()??""},Ee=()=>window.__PROJECT_SLUG__??"";function Q(o){var w,L;const{resources:n}=o;if(!n.components)return{};const l={};return(L=(w=window==null?void 0:window.blocklet)==null?void 0:w.componentMountPoints)==null||L.forEach(O=>{l[O.did]=O}),Object.fromEntries(Object.entries(n.components).map(([O,{blockletId:p,component:j}])=>{var E;return[O,{data:j,blockletId:p,blockletTitle:((E=l[p])==null?void 0:E.title)||p}]}))}function X(o){const{components:n}=o;return n||{}}function Y(o){return{...Q(o),...X(o)}}const _e=()=>Y(K().state);function ke(o){const n=JSON.parse(JSON.stringify(o)),l=R.nextId();return{...n,id:l}}exports.ErrorView=we;exports.StoreProvider=xe;exports.api=$;exports.autoResizeImage=ve;exports.getAllComponents=Y;exports.getCustomComponents=X;exports.getImageAbsoluteUrl=Ce;exports.getMountPoint=pe;exports.getProjectIdFromPathnameOrWindow=N;exports.getProjectPageVersionKey=ge;exports.getResourceComponents=Q;exports.getWssURL=ye;exports.transformValue=Pe;exports.useAllComponents=_e;exports.useProjectId=T;exports.useProjectSlug=Ee;exports.useStore=K;
|
package/lib/cjs/components.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});require("@blocklet/pages-kit/builtin/utils");require("@blocklet/pages-kit/types");require("@blocklet/pages-kit/utils/property");require("@blocklet/quickjs");require("@blocklet/sdk/lib/config");require("lru-cache");require("node-fetch");require("ufo");require("crypto");const e=require("./chunks/site-state-
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});require("@blocklet/pages-kit/builtin/utils");require("@blocklet/pages-kit/types");require("@blocklet/pages-kit/utils/property");require("@blocklet/quickjs");require("@blocklet/sdk/lib/config");require("lru-cache");require("node-fetch");require("ufo");require("crypto");const e=require("./chunks/site-state-BtZ8o3J2.js");exports.CUSTOM_COMPONENT_CACHE_DURATION_IN_SECONDS=e.CUSTOM_COMPONENT_CACHE_DURATION_IN_SECONDS;exports.GET_SERVER_SIDE_PROPS_TIMEOUT_IN_SECONDS=e.GET_SERVER_SIDE_PROPS_TIMEOUT_IN_SECONDS;exports.clearPreloadComponentsCache=e.clearPreloadComponentsCache;exports.clearPreloadComponentsCacheByMode=e.clearPreloadComponentsCacheByMode;exports.getComponentFromState=e.getComponentFromState;exports.getComponentFromStateByName=e.getComponentFromStateByName;exports.getExportSchemaValueFromCode=e.getExportSchemaValueFromCode;exports.getPreloadComponent=e.getPreloadComponent;exports.getPreloadComponents=e.getPreloadComponents;exports.getPreloadComponentsCacheKey=e.getPreloadComponentsCacheKey;
|
package/lib/cjs/home.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});require("react/jsx-runtime");require("./chunks/state-
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});require("react/jsx-runtime");require("./chunks/state-BVdbNJCA.js");require("@arcblock/ux/lib/Locale/context");require("@arcblock/ux/lib/Result");require("@blocklet/pages-kit/builtin/page/header");require("@blocklet/pages-kit/contexts/color");require("@blocklet/pages-kit/utils/data-source");require("@blocklet/pages-kit/utils/route");require("@blocklet/ui-react/lib/Header");require("@emotion/css");require("@emotion/react");require("@emotion/styled");require("@mui/material");require("ahooks");require("isomorphic-dompurify");require("lodash/cloneDeep");require("lodash/isEmpty");require("lodash/isEqual");require("react");require("react-helmet");require("react-router-dom");require("react-use");require("ufo");require("./chunks/array-BqHuYyfx.js");const e=require("./chunks/home-CQTuGad2.js");require("./chunks/session-BA7Qrcia.js");exports.HomeView=e.HomeView;exports.PageRoutes=e.PageRoutes;exports.PageView=e.PageView;exports.PageViewByPath=e.PageViewByPath;exports.PageViewWithDataSource=e.PageViewWithDataSource;exports.TranslucentHeader=e.TranslucentHeader;exports.default=e.Home;
|