@blocklet/pages-kit-inner-components 0.4.39 → 0.4.40
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/_chunks/{site-state-DuOokNvt.js → site-state-DtuL49Z6.js} +5 -5
- package/lib/cjs/components.js +1 -1
- package/lib/cjs/project-html.js +1 -1
- package/lib/cjs/resources.js +1 -1
- package/lib/cjs/site-state.js +1 -1
- package/lib/es/_chunks/{site-state-C4Qd1dyU.js → site-state-Da4qgEoo.js} +149 -151
- package/lib/es/components.js +1 -1
- package/lib/es/project-html.js +1 -1
- package/lib/es/resources.js +1 -1
- package/lib/es/site-state.js +1 -1
- package/package.json +3 -3
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
"use strict";var tt=Object.defineProperty;var st=(t,n,e)=>n in t?tt(t,n,{enumerable:!0,configurable:!0,writable:!0,value:e}):t[n]=e;var A=(t,n,e)=>st(t,typeof n!="symbol"?n+"":n,e);const nt=require("@blocklet/pages-kit/builtin/utils"),se=require("@blocklet/pages-kit/types"),oe=require("@blocklet/pages-kit/utils/property"),B=require("@blocklet/quickjs"),ot=require("@blocklet/sdk/lib/config"),
|
|
1
|
+
"use strict";var tt=Object.defineProperty;var st=(t,n,e)=>n in t?tt(t,n,{enumerable:!0,configurable:!0,writable:!0,value:e}):t[n]=e;var A=(t,n,e)=>st(t,typeof n!="symbol"?n+"":n,e);const nt=require("@blocklet/pages-kit/builtin/utils"),se=require("@blocklet/pages-kit/types"),oe=require("@blocklet/pages-kit/utils/property"),B=require("@blocklet/quickjs"),ot=require("@blocklet/sdk/lib/config"),Ee=require("lru-cache"),Le=require("node-fetch"),D=require("ufo"),ie=require("crypto"),rt=require("@blocklet/logger"),at=require("@blocklet/pages-kit/utils/builtin"),Ue=require("@blocklet/pages-kit/utils/typescript/builtin-module-transformer"),be=require("@blocklet/sdk/lib/component"),it=require("autoprefixer"),ct=require("esbuild"),E=require("fs"),lt=require("postcss"),pt=require("tailwindcss"),ut=require("typescript"),dt=require("@reactivedata/reactive"),ee=require("@syncedstore/core"),fe=require("glob"),ft=require("lib0/decoding"),mt=require("lib0/encoding"),N=require("lodash"),gt=require("nanoid"),ht=require("p-limit"),h=require("path"),yt=require("stream/promises"),St=require("tar"),wt=require("wait-on"),G=require("y-protocols/awareness"),le=require("y-protocols/sync"),Et=require("yaml"),bt=require("yjs"),Tt=require("lodash/isNil"),I=require("sequelize");require("sqlite3");const L=t=>t&&t.__esModule?t:{default:t};function X(t){if(t&&t.__esModule)return t;const n=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const e in t)if(e!=="default"){const s=Object.getOwnPropertyDescriptor(t,e);Object.defineProperty(n,e,s.get?s:{enumerable:!0,get:()=>t[e]})}}return n.default=t,Object.freeze(n)}const w=L(ot),Ot=L(Le),Pt=L(rt),Ct=L(it),It=X(ct),jt=L(lt),At=L(pt),x=L(ut),pe=X(ft),_=X(mt),_t=L(ht),vt=L(h),xt=L(wt),K=X(Et),V=X(bt),Dt=L(Tt);w.default.env.mode;const kt="image-bin";w.default.env.INIT_TEMPLATE_PATH;const Rt=process.env.DATABASE_URL||vt.default.join(w.default.env.dataDir,"db/pages-kit.db"),ve=w.default,Nt=()=>w.default.env.tenantMode==="multiple",Lt=()=>{var t;return(Dt.default(ve.env.preferences.multiTenantAllProjectAccessPassports)?[]:(t=ve.env.preferences.multiTenantAllProjectAccessPassports)==null?void 0:t.split(","))||[]},C=Pt.default("pages-kit"),Ut=I.DataTypes.sqlite.DATE.parse;I.DataTypes.sqlite.DATE.parse=(t,n)=>typeof t=="number"?new Date(t):Ut(t,n);const Z=new I.Sequelize({dialect:"sqlite",storage:Rt,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});Z.query("pragma journal_mode = WAL;");Z.query("pragma synchronous = normal;");Z.query("pragma journal_size_limit = 67108864;");class ce extends I.Model{}ce.init({id:{type:I.DataTypes.UUID,allowNull:!1,primaryKey:!0,defaultValue:I.DataTypes.UUIDV4},projectId:{type:I.DataTypes.UUID,allowNull:!1},componentId:{type:I.DataTypes.STRING,allowNull:!1}},{sequelize:Z,tableName:"ProjectComponents",timestamps:!1});class $ extends I.Model{static async getProjectByIdOrSlug(n){return $.findOne({where:{[I.Op.or]:[{id:n},{slug:n}]}})}}$.init({id:{type:I.DataTypes.UUID,defaultValue:I.DataTypes.UUIDV4,primaryKey:!0},name:{type:I.DataTypes.STRING,allowNull:!1},description:I.DataTypes.TEXT,createdAt:I.DataTypes.DATE,updatedAt:I.DataTypes.DATE,createdBy:{type:I.DataTypes.STRING,allowNull:!1},updatedBy:{type:I.DataTypes.STRING,allowNull:!1},slug:I.DataTypes.STRING,icon:I.DataTypes.STRING,pinnedAt:I.DataTypes.DATE,useAllResources:I.DataTypes.BOOLEAN,relatedBlocklets:{type:I.DataTypes.JSON,allowNull:!1,defaultValue:{},get(){return this.getDataValue("relatedBlocklets")||{}},set(t){this.setDataValue("relatedBlocklets",JSON.stringify(t||{}))}}},{sequelize:Z,paranoid:!0});$.hasMany(ce,{foreignKey:"projectId",as:"components"});const Mt=async(t,{componentId:n})=>{const e=`@tailwind components;
|
|
2
2
|
@tailwind utilities;
|
|
3
3
|
`,s=`.CustomComponent_${n}`;return(await jt.default([At.default({content:[{raw:t,extension:"tsx"}]}),Ct.default({overrideBrowserslist:["> 1%","last 2 versions"],stats:{}}),r=>{r.walkRules(l=>{l.selectors=l.selectors.map(a=>a.replace(/\.(.+)/g,`${s}.$1,${s} .$1`))})}]).process(e)).css},Ft=async(t,{componentId:n})=>{const e=await Mt(t,{componentId:n});return`export const __PagesKit_CSS__ = ${JSON.stringify(e)};
|
|
4
4
|
|
|
5
5
|
${t}
|
|
6
|
-
`},
|
|
6
|
+
`},xe=B.memoize(async(t,n)=>{let e=x.default.transpileModule(t,{compilerOptions:{jsx:x.default.JsxEmit.React,target:x.default.ScriptTarget.ES2016,module:x.default.ModuleKind.ESNext},transformers:{before:[Ue.createBuiltinModuleTransformer(x.default)]}}).outputText;if(n.tailwind&&(e=await Ft(e,{componentId:n.componentId})),n.module===se.PreloadComponentScriptModule.ESM)return e;const s=x.default.transpileModule(e,{compilerOptions:{jsx:x.default.JsxEmit.React,target:x.default.ScriptTarget.ES2016,module:x.default.ModuleKind.CommonJS,moduleResolution:x.default.ModuleResolutionKind.Node16}}).outputText;return n.module===se.PreloadComponentScriptModule.CJS?s:$t(n.moduleName,s)},{keyGenerator:(t,n)=>{const e=ie.createHash("md5").update(t).digest("hex"),s={...n,componentId:n.componentId,module:n.module,...n.module!==se.PreloadComponentScriptModule.ESM?{moduleName:n.moduleName}:{},tailwind:n.tailwind};return JSON.stringify(["transpileModule",e,s])},lruOptions:{max:100,ttl:1e3*60*60}}),qt=async(t,n)=>{var l,a;const s=(a=(l=(await It.build({entryPoints:["index.tsx"],external:Object.keys(at.BuiltinModules),format:"esm",target:"esnext",bundle:!0,write:!1,plugins:[{name:"vfs",setup(i){let c=null;i.onResolve({filter:/.*/},p=>p.path==="index.tsx"?{path:"index.tsx",namespace:"vfs"}:p.path==="./component"?{path:"component.tsx",namespace:"vfs"}:null),i.onLoad({filter:/.*/,namespace:"vfs"},async p=>{var u;if(p.path==="index.tsx")return{contents:`export { ${n} } from './component'`,loader:"tsx"};if(p.path==="component.tsx")return{contents:t,loader:"tsx"};if(Ue.isRelativeModule(p.path)){const f=p.path.split("/").pop();if(c||(c=await Ae({ensureLoaded:!1})),(u=c==null?void 0:c.chunks)!=null&&u[f])try{const g=E.readFileSync(c.chunks[f],"utf-8");return C.info("get chunk from local file system",f),{contents:g,loader:"tsx"}}catch{}}return null})}}]})).outputFiles)==null?void 0:l[0])==null?void 0:a.contents;if(!s)throw new Error("Failed to build server code");const o=Buffer.from(s).toString();return x.default.transpileModule(o,{compilerOptions:{module:x.default.ModuleKind.ESNext,target:x.default.ScriptTarget.ES2020}}).outputText},Me=B.memoize(async(t,n)=>{const e=await qt(t,n);return new RegExp(`export\\s+\\{\\s+${n}\\s+\\}`,"m").test(e)?e:void 0},{keyGenerator:(t,n)=>{const e=ie.createHash("md5").update(t).digest("hex");return JSON.stringify(["extractExportValueSchema",e,n])},lruOptions:{max:100,ttl:1e3*60*60}}),$t=(t,n)=>{const e=/\bawait\b/.test(n);return`// GENERATED FILE. DO NOT EDIT.
|
|
7
7
|
var ${t} = ${e?"async":""} function () {
|
|
8
8
|
|
|
9
9
|
const exports = {};
|
|
@@ -29,7 +29,7 @@ var ${t} = ${e?"async":""} function () {
|
|
|
29
29
|
|
|
30
30
|
return exports;
|
|
31
31
|
};
|
|
32
|
-
`},z=new
|
|
32
|
+
`},z=new Ee.LRUCache({max:100}),Fe=60*60,me=60;function qe(t){C.info("clear preload components cache",{cacheKey:t}),z.delete(t)}function $e(t){for(const n of z.keys())n.includes(t)&&(C.info("clear preload components cache",{cacheKey:n}),qe(n))}function Be({mode:t,instanceId:n,componentId:e,locale:s}){return["getPreloadComponents",t,n,e,s].join("-")}async function Bt({mode:t,req:n,state:e,locale:s,instances:o,module:r}){const{supportedLocales:l,config:{defaultLocale:a}}=e;if(!a)return null;const i=(await Promise.all(o.map(async g=>{try{const S=Be({mode:t,instanceId:g.id,componentId:g.componentId,locale:s});if(t!=="draft"&&g.useCache&&z.has(S))return C.info(`get preload component from cache: ${S}`),z.get(S);const j=W({state:e,componentId:g.componentId});if(!j)return null;const v=await Ve({req:n,state:e,componentId:j.id,locale:s,defaultLocale:a,properties:g.properties});if(!v)return null;const F={instanceId:g.id,preload:v};if(t!=="draft"&&g.useCache){let R=Fe;g.cacheDuration&&(R=g.cacheDuration),C.info(`set preload component to cache(${R}s): ${S}`),z.set(S,F,{ttl:R*1e3})}return F}catch(S){return C.error("get preload component error",{instanceId:g.id,componentId:g.componentId},{error:S}),null}}))).filter(g=>!!g),c=Object.values(i.reduce((g,S)=>({...g,...S.preload.components}),{}));async function p(){const g=await Promise.all(c.map(async S=>{const j=oe.componentUMDName({componentId:S.component.id}),v=r===se.PreloadComponentScriptModule.ESM?{module:r,script:await xe(S.script,{componentId:S.component.id,module:r,tailwind:t!=="draft"})}:{module:r,script:await xe(S.script,{componentId:S.component.id,module:r,moduleName:j,tailwind:t!=="draft"}),moduleName:j};return[S.component.id,{component:S.component,script:v}]}));return Object.fromEntries(g)}const u=await p();return{config:{defaultLocale:a,supportedLocales:l},components:u,instances:i.map(g=>({id:g.instanceId,componentId:g.preload.component.id,locales:{[g.preload.locale]:{props:g.preload.props}}}))}}async function Ve({req:t,state:n,componentId:e,locale:s,defaultLocale:o,properties:r}){const{supportedLocales:l}=n,a=W({state:n,componentId:e});if(!a)return null;const i=l.some(p=>p.locale===s)?s:o;if(!i)return null;const c=await He({req:t,state:n,componentId:e,locale:i,defaultLocale:o,properties:r});return c?{component:a,...c}:null}const Vt=20;async function He({req:t,depth:n=0,state:e,componentId:s,locale:o,defaultLocale:r,properties:l}){if(n>Vt)throw new RangeError("max component depth exceeded");const a=Ht({state:e,componentId:s,properties:l,locale:o});if(!a)return null;const{props:i}=a,c={locale:o||r,components:{[a.component.id]:{component:a.component,script:a.script}},props:{...i}};try{const p=await Jt({...a,req:t});p!=null&&p.props&&Object.assign(c.props,p.props)}catch(p){C.error("preload data at server side error",{componentId:s,name:a.component.name},{error:p})}return await Promise.all(Object.entries(i).map(async([p,u])=>{if((u==null?void 0:u.type)===oe.RenderNestedComponent){const f=await He({req:t,depth:n+1,state:e,componentId:u.componentId,locale:o,defaultLocale:r,properties:u.properties});f&&(Object.assign(c.components,f.components),Object.assign(c.props,{[p]:{type:oe.RenderNestedComponent,componentId:u.componentId,props:f.props}}))}})),c}function Ht({state:t,componentId:n,locale:e,properties:s}){const o=W({state:t,componentId:n});if(!o)return null;const r=oe.mergeComponent({componentId:n,getComponent:l=>W({state:t,componentId:l}),locale:e,defaultLocale:t.config.defaultLocale,properties:s});return r?{component:o,script:r.script,props:{locale:e,...r.properties}}:null}function W({state:t,componentId:n}){var e,s,o;return((e=t.components[n])==null?void 0:e.data)??((o=(s=t.resources.components)==null?void 0:s[n])==null?void 0:o.component)}function Gt({state:t,name:n}){var s,o;const e=n.toLowerCase();return((s=Object.values(t.components).find(r=>{var l;return((l=r.data.name)==null?void 0:l.toLowerCase())===e}))==null?void 0:s.data)??((o=t.resources.components&&Object.values(t.resources.components).find(r=>{var l;return((l=r.component.name)==null?void 0:l.toLowerCase())===e}))==null?void 0:o.component)}async function Jt({component:t,script:n,props:e,req:s}){if(!(n!=null&&n.includes("getServerSideProps")))return null;const o=await Me(n,"getServerSideProps");if(!o)return null;const r=new Promise((a,i)=>{setTimeout(()=>{i(new Error("getServerSideProps timeout in promise race"))},me*1e3)});return await Promise.race([r,B.Sandbox.callFunction({code:`${o}
|
|
33
33
|
|
|
34
34
|
export async function getServerSidePropsWrapper(props) {
|
|
35
35
|
const { location, fetch } = props;
|
|
@@ -48,10 +48,10 @@ export async function getServerSidePropsWrapper(props) {
|
|
|
48
48
|
}
|
|
49
49
|
}`,filename:`${t.name||t.id}.js`,moduleLoader:a=>{if(a==="@blocklet/pages-kit/builtin/utils")return`const { joinURL, withQuery, getQuery, getComponentMountPoint } = globalThis
|
|
50
50
|
export { joinURL, withQuery, getQuery, getComponentMountPoint }
|
|
51
|
-
`;if(a==="@blocklet/pages-kit/builtin/dayjs")return B.BuiltinModules.dayjs},global:{console:{log:(...a)=>{C.info(...a)},warn:(...a)=>{C.warn(...a)},error:(...a)=>{C.error(...a)}},getComponentMountPoint:nt.getComponentMountPoint,joinURL:D.joinURL,withQuery:D.withQuery,getQuery:D.getQuery},functionName:"getServerSidePropsWrapper",args:[{location:{href:D.joinURL(D.withHttps(s.hostname),s.originalUrl)},fetch:(a,{...i}={})=>{const c=typeof a=="string"&&a.startsWith("/")?D.joinURL(w.default.env.appUrl,a):a;if(typeof c=="string"&&D.parseURL(c).host===D.parseURL(w.default.env.appUrl).host){const p=s.get("cookie");if(p){const u=new
|
|
51
|
+
`;if(a==="@blocklet/pages-kit/builtin/dayjs")return B.BuiltinModules.dayjs},global:{console:{log:(...a)=>{C.info(...a)},warn:(...a)=>{C.warn(...a)},error:(...a)=>{C.error(...a)}},getComponentMountPoint:nt.getComponentMountPoint,joinURL:D.joinURL,withQuery:D.withQuery,getQuery:D.getQuery},functionName:"getServerSidePropsWrapper",args:[{location:{href:D.joinURL(D.withHttps(s.hostname),s.originalUrl)},fetch:(a,{...i}={})=>{const c=typeof a=="string"&&a.startsWith("/")?D.joinURL(w.default.env.appUrl,a):a;if(typeof c=="string"&&D.parseURL(c).host===D.parseURL(w.default.env.appUrl).host){const p=s.get("cookie");if(p){const u=new Le.Headers(i.headers);u.set("cookie",p),i.headers=u}}return Ot.default(c,{...i,timeout:me*1e3}).then(p=>({ok:p.ok,status:p.status,statusText:p.statusText,headers:Object.fromEntries(p.headers.entries()),json:()=>p.json()}))},props:e}]})])}const Ge=B.memoize(async(t,n,e)=>{if(!(t!=null&&t.includes(n)))return null;const s=await Me(t,n);if(s)try{return await B.Sandbox.callFunction({code:`
|
|
52
52
|
${s}
|
|
53
53
|
|
|
54
54
|
export function get${n}SchemaWrapper() {
|
|
55
55
|
return ${n};
|
|
56
56
|
}
|
|
57
|
-
`,filename:`${e}.js`,functionName:`get${n}SchemaWrapper`})}catch(o){return C.error(`获取 ${n} 失败`,{componentId:e,error:o}),null}return null},{keyGenerator:(t,n,e)=>{const s=ie.createHash("md5").update(t).digest("hex");return JSON.stringify(["getExportSchemaValueFromCode",s,n,e])},lruOptions:{max:100,ttl:1e3*60*60}}),Kt="z8iZiDFg3vkkrPwsiba1TLXy3H9XHzFERsP8o",he="page",ye="trigger-reload-project-resource",Oe=Kt,zt="z2qa7rr3eUyVnWp2PCxEVARuUfLFh6cE5V2xV",{uploadToMediaKit:Yt}=require("@blocklet/uploader-server"),Se=gt.customAlphabet("abcdefghijklmnopqrstuvwxyz0123456789",16),Pe=/^\w+(\w|-|\.)+\w+\.(jpe?g|png|gif|svg|bmp|webp|mp4|m4v|webm)$/,Y=/mediakit:\/\/([a-f0-9]{32}\.(jpe?g|png|gif|svg|bmp|webp|mp4|m4v|webm))/i,ke=/mediakit:\/\/([a-f0-9]{32}\.(jpe?g|png|gif|svg|bmp|webp|mp4|m4v|webm))/gi,Wt=1e4,Qt=3e4,te=0,ue=1,Xt=0,Zt=1,we=w.default,J=h.join(process.env.BLOCKLET_DATA_DIR,"site-state"),es=["production","draft"],ts=["production"];function Je(t){return(t==null?void 0:t.replace(/\//g,"|"))||""}function ss(){var e;const t=we.env.languages.map(s=>({locale:s.code,name:s.name})),n=(e=t[0])==null?void 0:e.locale;return{pageIds:[],pages:{},components:{},supportedLocales:t,config:{defaultLocale:n},resources:{}}}const q=class q extends V.Doc{constructor(e){super();A(this,"states",{});A(this,"syncedStore");A(this,"conns",new Map);A(this,"awareness");A(this,"awarenessChangeHandler",({added:e,updated:s,removed:o},r)=>{const l=e.concat(s,o);if(r!==null){const c=this.conns.get(r);c&&(e.forEach(p=>{c.add(p)}),o.forEach(p=>{c.delete(p)}))}const a=_.createEncoder();_.writeVarUint(a,ue),_.writeVarUint8Array(a,G.encodeAwarenessUpdate(this.awareness,l));const i=_.toUint8Array(a);this.conns.forEach((c,p)=>this.send(p,i))});A(this,"updateHandler",e=>{const s=_.createEncoder();_.writeVarUint(s,te),le.writeUpdate(s,e);const o=_.toUint8Array(s);this.conns.forEach((r,l)=>this.send(l,o))});A(this,"ensureDataStructure",()=>{var l;const{supportedLocales:e,pages:s,pageIds:o,config:r}=this.syncedStore;{const a=new Set(Object.keys(s));let i=0;for(;i<o.length;){const c=o[i];a.has(c)?(a.delete(c),i++):o.splice(i,1)}}e.splice(0,e.length),e.push(...we.env.languages.map(a=>({locale:a.code,name:a.name}))),r.defaultLocale=(l=e[0])==null?void 0:l.locale;{let a=0;const i=new Set;for(;a<e.length;){const{locale:c}=e[a];i.has(c)?e.splice(a,1):(a++,i.add(c))}}});A(this,"send",(e,s)=>{e.readyState!==Xt&&e.readyState!==Zt&&this.closeConn(e);try{e.send(s,o=>{o&&this.closeConn(e)})}catch{this.closeConn(e)}});A(this,"closeConn",e=>{if(e.removeAllListeners(),this.conns.has(e)){const s=this.conns.get(e);this.conns.delete(e),s&&G.removeAwarenessStates(this.awareness,Array.from(s),null)}e.close()});A(this,"autoSave",N.debounce(()=>{E.mkdirSync(h.dirname(this.draftYjsFilePath),{recursive:!0}),E.writeFileSync(this.draftYjsFilePath,V.encodeStateAsUpdate(this))},Wt));A(this,"save",({flush:e=!1}={})=>{this.autoSave(),e&&this.autoSave.flush()});A(this,"publish",async({mode:e,pages:s})=>{const o=await this.getState("draft"),r=await this.getState("production");await Ee(o,r,{pages:s,pageMergeMode:"replace",deletePages:!0,publishMode:e}),r.config.publishedAt=new Date().getTime();for(const l of s||Object.keys(this.syncedStore.pages))this.syncedStore.pages[l]&&(this.syncedStore.pages[l].publishedAt=new Date().toISOString());await this.setState(e,r)});A(this,"mergeState",async(e,s)=>{var a,i,c;const o=JSON.parse(JSON.stringify(s));(a=e.config).fontFamily??(a.fontFamily={});const r=(i=o.config)==null?void 0:i.fontFamily,l=(c=e.config)==null?void 0:c.fontFamily;e.config.fontFamily.title=(r==null?void 0:r.title)||(l==null?void 0:l.title),e.config.fontFamily.description=(r==null?void 0:r.description)||(l==null?void 0:l.description),await new Promise((p,u)=>{this.transact(async()=>{try{const f=await Ee(e,s);p(f)}catch(f){u(f)}})})});A(this,"addConnection",e=>{if(this.conns.has(e))return;e.binaryType="arraybuffer",this.conns.set(e,new Set),e.on("message",r=>this.messageListener(e,new Uint8Array(r)));let s=!0;const o=setInterval(()=>{if(!s)this.conns.has(e)&&this.closeConn(e),clearInterval(o);else if(this.conns.has(e)){s=!1;try{e.ping()}catch{this.closeConn(e),clearInterval(o)}}},Qt);e.on("close",()=>{this.closeConn(e),clearInterval(o)}),e.on("pong",()=>{s=!0});{const r=_.createEncoder();_.writeVarUint(r,te),le.writeSyncStep1(r,this),this.send(e,_.toUint8Array(r));const l=this.awareness.getStates();if(l.size>0){const a=_.createEncoder();_.writeVarUint(a,ue),_.writeVarUint8Array(a,G.encodeAwarenessUpdate(this.awareness,Array.from(l.keys()))),this.send(e,_.toUint8Array(a))}}});A(this,"messageListener",(e,s)=>{try{const o=_.createEncoder(),r=pe.createDecoder(s),l=pe.readVarUint(r);switch(l){case te:_.writeVarUint(o,te),le.readSyncMessage(r,o,this,null),_.length(o)>1&&(this.ensureDataStructure(),this.send(e,_.toUint8Array(o)));break;case ue:{G.applyAwarenessUpdate(this.awareness,pe.readVarUint8Array(r),e);break}default:C.warn(`Unsupported messageType ${l}`)}}catch(o){C.error(o)}this.save()});this.options=e,E.existsSync(this.draftYjsFilePath)&&V.applyUpdate(this,E.readFileSync(this.draftYjsFilePath)),this.syncedStore=dt.reactive(ee.syncedStore({pages:{},pageIds:[],components:{},supportedLocales:[],config:{},resources:{}},this)),this.initObserver(),this.on("update",this.updateHandler),this.awareness=new G.Awareness(this),this.awareness.on("update",this.awarenessChangeHandler),this.ensureDataStructure()}static safeDeleteProjectStateDir(e){if(!e)throw new Error("Should provide project context");try{const s=h.join(J,e),o=h.join(J,`@del-${e}`);E.renameSync(s,o)}catch(s){C.error("Failed to safe delete project state dir:",s)}}static get projectIds(){return me.globSync("*/",{cwd:J,ignore:["@del-*","@tmp-*",".*","staging","production","@backup-*"]})}static get allShared(){return this.projectIds.map(e=>q.shared(e))}static shared(e){if(!e)throw new Error("Should provide project context");let s=this.sharedInstances.get(e);return s||(s=new q({path:h.join(J,e)}),this.sharedInstances.set(e,s),s)}destroy(){this.conns.forEach((e,s)=>this.closeConn(s)),this.awareness.destroy(),super.destroy()}initObserver(){const e=o=>{o.observeDeep(r=>{r.some(l=>l.changes.keys.has("updatedAt")||l.changes.keys.has("publishedAt"))||o.set("updatedAt",new Date().toISOString())})};this.syncedStore.pages&&Object.keys(this.syncedStore.pages).forEach(o=>{const r=ee.getYjsValue(this.syncedStore.pages[o]);r&&r instanceof V.Map&&e(r)});const s=ee.getYjsValue(this.syncedStore.pages);s&&s instanceof V.Map&&s.observe(o=>{o.changes.keys.forEach((r,l)=>{if(r.action==="add"){const a=ee.getYjsValue(this.syncedStore.pages[l]);a&&a instanceof V.Map&&e(a)}})})}get draftYjsFilePath(){return h.join(this.options.path,"draft.yjs")}async getState(e){var s,o,r,l;if(e==="draft")return JSON.parse(JSON.stringify(this.syncedStore));if(!this.states[e]&&(this.states[e]=await Ce(this.getPublishDir(e),{includeResources:!0})??ss(),!((o=(s=this.states[e])==null?void 0:s.config)!=null&&o.defaultLocale))){(r=this.states[e]).config??(r.config={});const a=we.env.languages.map(i=>({locale:i.code,name:i.name}));this.states[e].config.defaultLocale=(l=a[0])==null?void 0:l.locale}return{...this.states[e],resources:await _e().then(async a=>{var u,f,g,S;const{pages:i,components:c}=N.pick(a,"pages","components");let p=c;if((f=(u=this.states[e])==null?void 0:u.resources)!=null&&f.components)p={...(S=(g=this.states[e])==null?void 0:g.resources)==null?void 0:S.components};else{const j=h.basename(this.options.path),v=await $.findByPk(j);if(v!=null&&v.useAllResources)p=c;else{const R=(await ce.findAll({where:{projectId:j}})).map(T=>T.componentId);p=Object.fromEntries(Object.entries(c||{}).filter(([T])=>R.includes(T)))}}return{pages:i,components:p}}).catch(()=>({}))}}async setState(e,s){const o=await Ye(s,{exportAssets:!1,includeResources:!0}),r=this.getPublishDir(e);E.mkdirSync(h.dirname(r),{recursive:!0}),E.rmSync(r,{force:!0,recursive:!0}),E.renameSync(o,r),this.states[e]=s}getPublishDir(e){return h.join(this.options.path,e)}static async pageUrlMap(e){const{projectIds:s}=this,o={};for(const r of s){const l=await $.findByPk(r);if(!l)continue;const a=await q.shared(r).getState(e),i=N.union(w.default.env.languages.map(c=>c.code),a.supportedLocales.map(c=>c.locale));for(const c of a.pageIds){const p=a.pages[c];if(!p||e==="production"&&!p.isPublic)continue;const u=p.slug,f=l.slug||r,g={projectId:r,projectSlug:f,pageSlug:u,pageId:c,defaultLocale:i==null?void 0:i[0],locales:i,publishedAt:a.config.publishedAt,isPublic:p.isPublic,isTemplate:p.isTemplate};f&&(o[D.joinURL("/",f,u)]={...g,shouldRedirect:!0,mainPage:!0}),o[D.joinURL("/",r,u)]={...g,shouldRedirect:!0,mainPage:!0};for(const S of i){const j={...g,locale:S};o[D.joinURL("/",S,r,u)]=j,f&&(o[D.joinURL("/",S,f,u)]=j)}}}return o}};A(q,"INSTANCE_TTL",30*60*1e3),A(q,"sharedInstances",new be.LRUCache({max:100,ttl:q.INSTANCE_TTL,dispose:e=>{e.destroy()}}));let Q=q;function Ke(){return E.mkdtempSync(h.join(w.default.env.dataDir,"tmp-"))}function re(t,n,e=[]){return Array.isArray(t)?t.flatMap((s,o)=>re(s,n,[...e,o])):typeof t=="object"?t===null?[]:Object.entries(t).flatMap(([s,o])=>re(o,n,[...e,s])):n(t)?[e]:[]}function M(t){return t.filter(n=>n!=null)}async function ns(t,n,e){if(!t||!E.existsSync(t)||!E.lstatSync(t).isFile())return null;let s=e[t];return s||(s=(async()=>(await Yt({filePath:t,fileName:n})).data.filename)(),e[t]=s),s}const os=async(t,n)=>{const e=h.basename(t),s=await Te.call({name:Oe,path:D.joinURL("/uploads",e),responseType:"stream",method:"GET"});if(s.status>=200&&s.status<400){const o=E.createWriteStream(n);await yt.pipeline(s.data,o)}else throw new Error(`download asset failed ${s.status}`)},rs=async(t,n)=>{await Promise.all(t.map(async e=>{try{await os(e,h.join(n,h.basename(e)))}catch(s){C.error(`Failed to export assets: ${e}, ${s}`)}}))};function ze(t){return Pe.test(t)?[t]:Y.test(t)?(ke.lastIndex=0,Array.from(t.matchAll(ke)).map(e=>e[1]).filter(e=>!!e)):[]}async function de(t,n,e){const{getFilename:s,exportAssets:o}=e,r=h.join(n,s(t));if(E.mkdirSync(h.dirname(r),{recursive:!0}),E.writeFileSync(r,K.stringify(t)),o){const a=re(t,i=>typeof i=="string"&&(Pe.test(i)||Y.test(i))).map(i=>{const c=N.get(t,i);return ze(c)}).flat().filter(Boolean);await rs(a,h.dirname(r))}}const Re=new be.LRUCache({max:1e3,ttl:30*24*60*60*1e3});async function Ne(t,n,e){var a;const s=re(t,i=>typeof i=="string"&&(Pe.test(i)||Y.test(i))),o=_t.default(2),r=s.map(i=>o(async()=>{try{const c=N.get(t,i),p=ze(c);for(const u of p){const f=h.basename(u),g=e.getFilePath(u,i),S=g?`${g}:${f}`:f,j=Re.get(S);if(j){Y.test(c)||N.set(t,i,j);return}const v=await ns(g,f,n);v&&(Y.test(c)||N.set(t,i,v),Re.set(S,v))}}catch(c){C.error(`Failed to process upload for path ${i.join(".")}:`,c.message||c.reason)}})),l=await Promise.allSettled(r);(a=e.onFinish)==null||a.call(e,l)}async function Ye(t,{exportAssets:n,pageIds:e="all",componentIds:s="all",rawConfig:o,includeResources:r=!1}={}){var F,R,y,T,O,P;const l=e==="all"?t.pageIds:e,a=as({state:t,pageIds:l,componentIds:s==="all"?Object.keys(t.components):s}),i=(m,d)=>{var b;return{id:m.id,name:m.name,isTemplateSection:m.isTemplateSection??!1,templateDescription:m.templateDescription,component:m.component,config:m.config,visibility:m.visibility,properties:((b=m.locales)==null?void 0:b[d])??{}}},c=(m,d)=>{var b;return{id:m.id,createdAt:m.createdAt,updatedAt:m.updatedAt,publishedAt:m.publishedAt,isPublic:m.isPublic??!0,isTemplate:m.isTemplate??!1,meta:((b=m.locales)==null?void 0:b[d])??{},sections:M(m.sectionIds.map(k=>{const U=m.sections[k];return U&&i(U,d)}))}},p=M(t.supportedLocales.map(m=>m.locale).flatMap(m=>l.map(d=>{const b=t.pages[d];return b&&{locale:m,slug:b.slug,page:c(b,m)}}))),u=Ke(),f=h.join(u,"pages");E.mkdirSync(f,{recursive:!0});const g=h.join(u,"components");E.mkdirSync(g,{recursive:!0});for(const{locale:m,slug:d,page:b}of p)await de(b,f,{getFilename:()=>`${Je(d)||"index"}.${m}.yml`,exportAssets:n});for(const m of a){const d=(F=t.components[m])==null?void 0:F.data;d&&await de(d,g,{getFilename:b=>`${b.name||"unnamed"}.${b.id}.yml`,exportAssets:n})}const S=h.join(u,".blocklet/pages/pages.config.yml");E.mkdirSync(h.dirname(S),{recursive:!0});const j={pages:M(l.map(m=>{const d=t.pages[m];return d&&{id:m,slug:d.slug}})),components:M(a.map(m=>{var b;const d=(b=t.components[m])==null?void 0:b.data;return d&&{id:m,name:d.name}})),...r?{resources:{components:M(Object.keys(((R=t.resources)==null?void 0:R.components)||{}).map(m=>{var d,b,k,U;return{id:m,name:(U=(k=(b=(d=t.resources)==null?void 0:d.components)==null?void 0:b[m])==null?void 0:k.component)==null?void 0:U.name}}))}}:{},supportedLocales:t.supportedLocales,config:t.config};E.writeFileSync(S,K.stringify(j));const v=h.join(u,"config.source.json");if(o&&E.writeFileSync(v,JSON.stringify(o)),r){const m=h.join(u,"resources"),d=h.join(m,"components");E.mkdirSync(d,{recursive:!0});for(const b of Object.keys(((y=t==null?void 0:t.resources)==null?void 0:y.components)??{})){const k=(P=(O=(T=t.resources)==null?void 0:T.components)==null?void 0:O[b])==null?void 0:P.component;k&&await de(k,d,{getFilename:U=>`${U.name||"unnamed"}.${U.id}.yml`,exportAssets:n})}}return u}async function Ce(t,{importAssets:n,includeResources:e}={}){var r,l,a;if(!E.existsSync(t))return null;let s,o=!1;try{E.lstatSync(t).isDirectory()?s=t:/\.(tgz|gz|tar)$/.test(t)&&(o=!0,s=Ke(),await St.x({file:t,C:s}));const i=me.globSync("**/.blocklet/pages/pages.config.yml",{cwd:s,absolute:!0}).at(0),c=i&&h.join(h.dirname(i),"../../pages"),p=i&&h.join(h.dirname(i),"../../components"),u=i&&h.join(h.dirname(i),"../../chunks");if(!i)return null;const f=K.parse(E.readFileSync(i).toString()),g=(y,T,O)=>{let P=h.join(y,`${T}${O?`.${O}`:""}.yml`);return(!E.existsSync(P)||!E.lstatSync(P).isFile())&&(P=h.join(y,T,`index${O?`.${O}`:""}.yml`),!E.existsSync(P)||!E.lstatSync(P))?null:K.parse(E.readFileSync(P).toString())},S=(y,T)=>{try{const O=me.globSync(`*.${T}.yml`,{cwd:y,absolute:!0})[0];return O?K.parse(E.readFileSync(O).toString()):null}catch(O){C.error("parse component error",O)}return null},j=M(f.pages.map(({slug:y})=>{var m;const T=M(f.supportedLocales.map(({locale:d})=>{const b=c?g(c,Je(y),d):void 0;if(b)return{locale:d,page:b};const k=c?g(c,y,d):void 0;return k&&{locale:d,page:k}})),O=(m=T[0])==null?void 0:m.page;if(!O)return null;const P=O.sections.map(d=>{const b=d.id||Se();return{id:b,component:d.component,config:d.config,name:d.name,isTemplateSection:d.isTemplateSection??!1,templateDescription:d.templateDescription,visibility:d.visibility,locales:Object.fromEntries(M(T.map(({locale:k,page:U})=>{const ve=U.sections.find(et=>et.id===b);return ve&&[k,ve.properties]})))}});return{id:O.id||Se(),createdAt:O.createdAt,updatedAt:O.updatedAt,publishedAt:O.publishedAt,isPublic:O.isPublic??!0,isTemplate:O.isTemplate??!1,slug:y,sections:Object.fromEntries(P.map(d=>[d.id,d])),sectionIds:P.map(d=>d.id),locales:Object.fromEntries(T.map(({locale:d,page:b})=>[d,b.meta]))}})),v=p?M(((r=f.components)==null?void 0:r.map(({id:y})=>S(p,y)))??[]):[];if(n){const y=(...T)=>{C.info(`[${o?h.basename(t):h.basename(h.join(t,"../../../../"))}] importAssets:`,...T)};try{y("wait image-bin api ready"),await xt.default({resources:[`${Te.getComponentWebEndpoint(kt)}/api/sdk/uploads`],validateStatus:P=>P>=200&&P<=500}),y("image-bin api is ready");const T={},O={};y("start to upload assets"),await Promise.allSettled([Ne(v,T,{getFilePath:P=>p&&h.join(p,P),onFinish:P=>{y(`upload ${P.length} component assets`)}}),Ne(j,O,{getFilePath:(P,m)=>{const d=N.get(j,m.slice(0,1));return c&&h.join(c,h.dirname(d.slug),P)},onFinish:P=>{y(`upload ${P.length} page assets`)}})]),y("upload assets done"),global.gc&&global.gc()}catch(T){y("Error during asset import:",T)}}const F={};if(e){const y=i&&h.join(h.dirname(i),"../../resources/components"),T=M(((a=(l=f.resources)==null?void 0:l.components)==null?void 0:a.map(({id:O})=>S(y,O)))??[]);T.length>0&&(F.components=Object.fromEntries(T.map((O,P)=>[O.id,{index:P,component:O}])))}const R={};if(u&&E.existsSync(u)){const y=E.readdirSync(u);for(const T of y)R[T]=h.join(u,T)}return{supportedLocales:f.supportedLocales,pageIds:j.map(y=>y.id),components:Object.fromEntries(v.map((y,T)=>[y.id,{index:T,data:y}])),pages:Object.fromEntries(j.map(y=>[y.id,y])),config:f.config||{},resources:F,chunks:R}}finally{o&&s&&E.rmSync(s,{force:!0,recursive:!0})}}async function Ee(t,n,{pages:e,pageMergeMode:s="byUpdateTime",deletePages:o=!1,publishMode:r=void 0}={}){try{r&&$e(r)}catch(p){C.error("clear preload page cache error",{error:p})}const{pageIds:l,pages:a,supportedLocales:i}=t;for(const p of e??l){const u=a[p];if(!u){const f=n.pageIds.indexOf(p);f!==-1&&o&&(n.pageIds.splice(f,1),delete n.pages[p]);continue}if(n.pageIds.includes(u.id)){if(s==="replace")n.pages[u.id]=u;else if(s==="byUpdateTime"){const f=n.pages[u.id];(!f||u.updatedAt&&u.updatedAt>f.updatedAt)&&(n.pages[u.id]=u)}}else n.pageIds.push(u.id),n.pages[u.id]=u}if(o&&!e)for(const p of n.pageIds)t.pageIds.includes(p)||delete n.pages[p],n.pageIds=[...n.pageIds].filter(u=>t.pageIds.includes(u));if(n.supportedLocales.splice(0,n.supportedLocales.length),n.supportedLocales.push(...N.cloneDeep(i)),o)for(const p of Object.keys(n.components))delete n.components[p];let c=JSON.parse(JSON.stringify(t.components));c=Object.fromEntries(await Promise.all(Object.entries(c).map(async([p,u])=>{const f=await We(u==null?void 0:u.data);return[p,{...u,data:f}]}))),Object.assign(n.components,c),Object.assign(n.config,JSON.parse(JSON.stringify(t.config))),n.resources.components=JSON.parse(JSON.stringify(t.resources.components||{}))}const We=B.memoize(async t=>{var n;if(!N.isEmpty(t==null?void 0:t.properties))return t;if(((n=t==null?void 0:t.renderer)==null?void 0:n.type)==="react-component"){const{script:e}=(t==null?void 0:t.renderer)||{};if(e&&e.includes("PROPERTIES_SCHEMA"))try{const s=await Ge(e,"PROPERTIES_SCHEMA",t.id);s&&s.length>0&&t&&(t.properties={},s.forEach((o,r)=>{t!=null&&t.properties&&(t.properties[o.id]={index:r,data:o})}))}catch(s){C.error("checkPropertiesFromCode error",{componentId:t.id,name:t.name},{error:s})}}return t},{keyGenerator:t=>{var l;const n=(t==null?void 0:t.id)||"",e=(t==null?void 0:t.name)||"",s=((l=t==null?void 0:t.renderer)==null?void 0:l.type)||"",o=(t==null?void 0:t.properties)||{},r=ie.createHash("md5").update(JSON.stringify(o)).digest("hex");return JSON.stringify(["checkPropertiesFromCode",n,e,s,r])},lruOptions:{max:100,ttl:1e3*60*60}});function as({state:t,pageIds:n=[],componentIds:e=[]}){var l;const s=(a,i=new Set)=>(Array.isArray(a)&&a.forEach(c=>s(c,i)),a&&typeof a=="object"&&(typeof a.componentId=="string"&&i.add(a.componentId),Object.values(a).forEach(c=>s(c,i))),i),o=new Set(e);for(const a of n){const i=t.pages[a];s(i,o)}const r=[...o];for(;r.length;){const a=r.shift();o.has(a)||o.add(a);const i=(l=t.components[a])==null?void 0:l.data;if(i)for(const c of s(i))o.has(c)||r.push(c)}return[...o]}let ae,H,Ie,je,Ae;function Qe(){return ae=(async()=>{const t=Te.getResources({types:[{did:Oe,type:he},{did:zt,type:he}]});H=(await Promise.all(t.map(async e=>{const s=e.path?await Ce(e.path,{importAssets:!1}):void 0;return s?{blockletId:e.did,state:s,blockletTitle:e.title}:void 0}))).filter(e=>!!e),Ie=H.reduce((e,s)=>Object.assign(e,Object.fromEntries(Object.values(s.state.pages).map(o=>o?[o==null?void 0:o.id,{page:o,blockletId:s.blockletId}]:[]))),{});const n=H.reduce((e,s)=>Object.assign(e,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([e,s])=>{const o=await We(s.component);return[e,{...s,component:o}]}))),Ae=H.reduce((e,s)=>Object.assign(e,s.state.chunks),{})})(),ae}function Xe(t){const n=N.debounce(async()=>{await Qe().catch(e=>{C.error("load resource states error",{error:e})}),await(t==null?void 0:t({states:H,pages:Ie,components:je,chunks:Ae}))},3e3,{leading:!1,trailing:!0});return n(),w.default.events.on(w.default.Events.componentAdded,n),w.default.events.on(w.default.Events.componentRemoved,n),w.default.events.on(w.default.Events.componentStarted,n),w.default.events.on(w.default.Events.componentStopped,n),w.default.events.on(w.default.Events.componentUpdated,n),w.default.events.on(ye,n),()=>{w.default.events.off(w.default.Events.componentAdded,n),w.default.events.off(w.default.Events.componentRemoved,n),w.default.events.off(w.default.Events.componentStarted,n),w.default.events.off(w.default.Events.componentStopped,n),w.default.events.off(w.default.Events.componentUpdated,n),w.default.events.off(ye,n)}}const Ze=Symbol.for("GLOBAL_RESOURCE_STATES_LISTENER_KEY"),ne=globalThis;var Le;(Le=ne[Ze])==null||Le.call(ne);ne[Ze]=Xe(async({pages:t,components:n})=>{const{projectIds:e}=Q;await Promise.all(e.map(async s=>{const o=Q.shared(s);o.syncedStore.resources.pages=t;const r=await $.findByPk(s);if(r!=null&&r.useAllResources)o.syncedStore.resources.components=n;else{const a=(await ce.findAll({where:{projectId:s}})).map(c=>c.componentId),i=Object.fromEntries(Object.entries(n||{}).filter(([c])=>a.includes(c)));o.syncedStore.resources.components=i}C.info(`update [${s}] resource states:`,{pages:Object.keys(o.syncedStore.resources.pages||{}).length,components:Object.keys(o.syncedStore.resources.components||{}).length})}))});async function is(){C.info("trigger reload all project resource"),w.default.events.emit(ye)}async function _e({ensureLoaded:t=!0}={}){return t&&(ae??(ae=Qe()),await ae),{states:H,pages:Ie,components:je,chunks:Ae}}exports.COMPONENT_DID=Oe;exports.CUSTOM_COMPONENT_CACHE_DURATION_IN_SECONDS=Fe;exports.GET_SERVER_SIDE_PROPS_TIMEOUT_IN_SECONDS=ge;exports.PUBLISH_MODES=ts;exports.Project=$;exports.RESOURCE_TYPE=he;exports.SITE_STATE_PATH=J;exports.STATE_MODES=es;exports.SiteState=Q;exports.clearPreloadComponentsCache=qe;exports.clearPreloadComponentsCacheByMode=$e;exports.fromPackage=Ce;exports.getComponentFromState=W;exports.getComponentFromStateByName=Gt;exports.getExportSchemaValueFromCode=Ge;exports.getMultiTenantAllProjectAccessPassports=Lt;exports.getPreloadComponent=Ve;exports.getPreloadComponents=Bt;exports.getPreloadComponentsCacheKey=Be;exports.getResourceStates=_e;exports.initPackResourceStates=Xe;exports.isMultiTenant=Nt;exports.logger=C;exports.mergeState=Ee;exports.nextId=Se;exports.toPackage=Ye;exports.triggerReloadAllProjectResource=is;
|
|
57
|
+
`,filename:`${e}.js`,functionName:`get${n}SchemaWrapper`})}catch(o){return C.error(`获取 ${n} 失败`,{componentId:e,error:o}),null}return null},{keyGenerator:(t,n,e)=>{const s=ie.createHash("md5").update(t).digest("hex");return JSON.stringify(["getExportSchemaValueFromCode",s,n,e])},lruOptions:{max:100,ttl:1e3*60*60}}),Kt="z8iZiDFg3vkkrPwsiba1TLXy3H9XHzFERsP8o",ge="page",he="trigger-reload-project-resource",Te=Kt,zt="z2qa7rr3eUyVnWp2PCxEVARuUfLFh6cE5V2xV",{uploadToMediaKit:Yt}=require("@blocklet/uploader-server"),ye=gt.customAlphabet("abcdefghijklmnopqrstuvwxyz0123456789",16),Oe=/^\w+(\w|-|\.)+\w+\.(jpe?g|png|gif|svg|bmp|webp|mp4|m4v|webm)$/,Y=/mediakit:\/\/([a-f0-9]{32}\.(jpe?g|png|gif|svg|bmp|webp|mp4|m4v|webm))/i,De=/mediakit:\/\/([a-f0-9]{32}\.(jpe?g|png|gif|svg|bmp|webp|mp4|m4v|webm))/gi,Wt=1e4,Qt=3e4,te=0,ue=1,Xt=0,Zt=1,Se=w.default,J=h.join(process.env.BLOCKLET_DATA_DIR,"site-state"),es=["production","draft"],ts=["production"];function Je(t){return(t==null?void 0:t.replace(/\//g,"|"))||""}function ss(){var e;const t=Se.env.languages.map(s=>({locale:s.code,name:s.name})),n=(e=t[0])==null?void 0:e.locale;return{pageIds:[],pages:{},components:{},supportedLocales:t,config:{defaultLocale:n},resources:{}}}const q=class q extends V.Doc{constructor(e){super();A(this,"states",{});A(this,"syncedStore");A(this,"conns",new Map);A(this,"awareness");A(this,"awarenessChangeHandler",({added:e,updated:s,removed:o},r)=>{const l=e.concat(s,o);if(r!==null){const c=this.conns.get(r);c&&(e.forEach(p=>{c.add(p)}),o.forEach(p=>{c.delete(p)}))}const a=_.createEncoder();_.writeVarUint(a,ue),_.writeVarUint8Array(a,G.encodeAwarenessUpdate(this.awareness,l));const i=_.toUint8Array(a);this.conns.forEach((c,p)=>this.send(p,i))});A(this,"updateHandler",e=>{const s=_.createEncoder();_.writeVarUint(s,te),le.writeUpdate(s,e);const o=_.toUint8Array(s);this.conns.forEach((r,l)=>this.send(l,o))});A(this,"ensureDataStructure",()=>{var l;const{supportedLocales:e,pages:s,pageIds:o,config:r}=this.syncedStore;{const a=new Set(Object.keys(s));let i=0;for(;i<o.length;){const c=o[i];a.has(c)?(a.delete(c),i++):o.splice(i,1)}}e.splice(0,e.length),e.push(...Se.env.languages.map(a=>({locale:a.code,name:a.name}))),r.defaultLocale=(l=e[0])==null?void 0:l.locale;{let a=0;const i=new Set;for(;a<e.length;){const{locale:c}=e[a];i.has(c)?e.splice(a,1):(a++,i.add(c))}}});A(this,"send",(e,s)=>{e.readyState!==Xt&&e.readyState!==Zt&&this.closeConn(e);try{e.send(s,o=>{o&&this.closeConn(e)})}catch{this.closeConn(e)}});A(this,"closeConn",e=>{if(e.removeAllListeners(),this.conns.has(e)){const s=this.conns.get(e);this.conns.delete(e),s&&G.removeAwarenessStates(this.awareness,Array.from(s),null)}e.close()});A(this,"autoSave",N.debounce(()=>{E.mkdirSync(h.dirname(this.draftYjsFilePath),{recursive:!0}),E.writeFileSync(this.draftYjsFilePath,V.encodeStateAsUpdate(this))},Wt));A(this,"save",({flush:e=!1}={})=>{this.autoSave(),e&&this.autoSave.flush()});A(this,"publish",async({mode:e,pages:s})=>{const o=await this.getState("draft"),r=await this.getState("production");await we(o,r,{pages:s,pageMergeMode:"replace",deletePages:!0,publishMode:e}),r.config.publishedAt=new Date().getTime();for(const l of s||Object.keys(this.syncedStore.pages))this.syncedStore.pages[l]&&(this.syncedStore.pages[l].publishedAt=new Date().toISOString());await this.setState(e,r)});A(this,"mergeState",async(e,s)=>{var a,i,c;const o=JSON.parse(JSON.stringify(s));(a=e.config).fontFamily??(a.fontFamily={});const r=(i=o.config)==null?void 0:i.fontFamily,l=(c=e.config)==null?void 0:c.fontFamily;e.config.fontFamily.title=(r==null?void 0:r.title)||(l==null?void 0:l.title),e.config.fontFamily.description=(r==null?void 0:r.description)||(l==null?void 0:l.description),await new Promise((p,u)=>{this.transact(async()=>{try{const f=await we(e,s);p(f)}catch(f){u(f)}})})});A(this,"addConnection",e=>{if(this.conns.has(e))return;e.binaryType="arraybuffer",this.conns.set(e,new Set),e.on("message",r=>this.messageListener(e,new Uint8Array(r)));let s=!0;const o=setInterval(()=>{if(!s)this.conns.has(e)&&this.closeConn(e),clearInterval(o);else if(this.conns.has(e)){s=!1;try{e.ping()}catch{this.closeConn(e),clearInterval(o)}}},Qt);e.on("close",()=>{this.closeConn(e),clearInterval(o)}),e.on("pong",()=>{s=!0});{const r=_.createEncoder();_.writeVarUint(r,te),le.writeSyncStep1(r,this),this.send(e,_.toUint8Array(r));const l=this.awareness.getStates();if(l.size>0){const a=_.createEncoder();_.writeVarUint(a,ue),_.writeVarUint8Array(a,G.encodeAwarenessUpdate(this.awareness,Array.from(l.keys()))),this.send(e,_.toUint8Array(a))}}});A(this,"messageListener",(e,s)=>{try{const o=_.createEncoder(),r=pe.createDecoder(s),l=pe.readVarUint(r);switch(l){case te:_.writeVarUint(o,te),le.readSyncMessage(r,o,this,null),_.length(o)>1&&(this.ensureDataStructure(),this.send(e,_.toUint8Array(o)));break;case ue:{G.applyAwarenessUpdate(this.awareness,pe.readVarUint8Array(r),e);break}default:C.warn(`Unsupported messageType ${l}`)}}catch(o){C.error(o)}this.save()});this.options=e,E.existsSync(this.draftYjsFilePath)&&V.applyUpdate(this,E.readFileSync(this.draftYjsFilePath)),this.syncedStore=dt.reactive(ee.syncedStore({pages:{},pageIds:[],components:{},supportedLocales:[],config:{},resources:{}},this)),this.initObserver(),this.on("update",this.updateHandler),this.awareness=new G.Awareness(this),this.awareness.on("update",this.awarenessChangeHandler),this.ensureDataStructure()}static safeDeleteProjectStateDir(e){if(!e)throw new Error("Should provide project context");try{const s=h.join(J,e),o=h.join(J,`@del-${e}`);E.renameSync(s,o)}catch(s){C.error("Failed to safe delete project state dir:",s)}}static get projectIds(){return fe.globSync("*/",{cwd:J,ignore:["@del-*","@tmp-*",".*","staging","production","@backup-*"]})}static get allShared(){return this.projectIds.map(e=>q.shared(e))}static shared(e){if(!e)throw new Error("Should provide project context");let s=this.sharedInstances.get(e);return s||(s=new q({path:h.join(J,e)}),this.sharedInstances.set(e,s),s)}destroy(){this.conns.forEach((e,s)=>this.closeConn(s)),this.awareness.destroy(),super.destroy()}initObserver(){const e=o=>{o.observeDeep(r=>{r.some(l=>l.changes.keys.has("updatedAt")||l.changes.keys.has("publishedAt"))||o.set("updatedAt",new Date().toISOString())})};this.syncedStore.pages&&Object.keys(this.syncedStore.pages).forEach(o=>{const r=ee.getYjsValue(this.syncedStore.pages[o]);r&&r instanceof V.Map&&e(r)});const s=ee.getYjsValue(this.syncedStore.pages);s&&s instanceof V.Map&&s.observe(o=>{o.changes.keys.forEach((r,l)=>{if(r.action==="add"){const a=ee.getYjsValue(this.syncedStore.pages[l]);a&&a instanceof V.Map&&e(a)}})})}get draftYjsFilePath(){return h.join(this.options.path,"draft.yjs")}async getState(e){var s,o,r,l;if(e==="draft")return JSON.parse(JSON.stringify(this.syncedStore));if(!this.states[e]&&(this.states[e]=await Pe(this.getPublishDir(e),{includeResources:!0})??ss(),!((o=(s=this.states[e])==null?void 0:s.config)!=null&&o.defaultLocale))){(r=this.states[e]).config??(r.config={});const a=Se.env.languages.map(i=>({locale:i.code,name:i.name}));this.states[e].config.defaultLocale=(l=a[0])==null?void 0:l.locale}return{...this.states[e],resources:await Ae().then(async a=>{var u,f,g,S;const{pages:i,components:c}=N.pick(a,"pages","components");let p=c;if((f=(u=this.states[e])==null?void 0:u.resources)!=null&&f.components)p={...(S=(g=this.states[e])==null?void 0:g.resources)==null?void 0:S.components};else{const j=h.basename(this.options.path),v=await $.findByPk(j);if(v!=null&&v.useAllResources)p=c;else{const R=(await ce.findAll({where:{projectId:j}})).map(T=>T.componentId);p=Object.fromEntries(Object.entries(c||{}).filter(([T])=>R.includes(T)))}}return{pages:i,components:p}}).catch(()=>({}))}}async setState(e,s){const o=await Ye(s,{exportAssets:!1,includeResources:!0}),r=this.getPublishDir(e);E.mkdirSync(h.dirname(r),{recursive:!0}),E.rmSync(r,{force:!0,recursive:!0}),E.renameSync(o,r),this.states[e]=s}getPublishDir(e){return h.join(this.options.path,e)}static async pageUrlMap(e){const{projectIds:s}=this,o={};for(const r of s){const l=await $.findByPk(r);if(!l)continue;const a=await q.shared(r).getState(e),i=N.union(w.default.env.languages.map(c=>c.code),a.supportedLocales.map(c=>c.locale));for(const c of a.pageIds){const p=a.pages[c];if(!p||e==="production"&&!p.isPublic)continue;const u=p.slug,f=l.slug||r,g={projectId:r,projectSlug:f,pageSlug:u,pageId:c,defaultLocale:i==null?void 0:i[0],locales:i,publishedAt:a.config.publishedAt,isPublic:p.isPublic,isTemplate:p.isTemplate};f&&(o[D.joinURL("/",f,u)]={...g,shouldRedirect:!0,mainPage:!0}),o[D.joinURL("/",r,u)]={...g,shouldRedirect:!0,mainPage:!0};for(const S of i){const j={...g,locale:S};o[D.joinURL("/",S,r,u)]=j,f&&(o[D.joinURL("/",S,f,u)]=j)}}}return o}};A(q,"INSTANCE_TTL",30*60*1e3),A(q,"sharedInstances",new Ee.LRUCache({max:100,ttl:q.INSTANCE_TTL,dispose:e=>{e.destroy()}}));let Q=q;function Ke(){return E.mkdtempSync(h.join(w.default.env.dataDir,"tmp-"))}function re(t,n,e=[]){return Array.isArray(t)?t.flatMap((s,o)=>re(s,n,[...e,o])):typeof t=="object"?t===null?[]:Object.entries(t).flatMap(([s,o])=>re(o,n,[...e,s])):n(t)?[e]:[]}function M(t){return t.filter(n=>n!=null)}async function ns(t,n,e){if(!t||!E.existsSync(t)||!E.lstatSync(t).isFile())return null;let s=e[t];return s||(s=(async()=>(await Yt({filePath:t,fileName:n})).data.filename)(),e[t]=s),s}const os=async(t,n)=>{const e=h.basename(t),s=await be.call({name:Te,path:D.joinURL("/uploads",e),responseType:"stream",method:"GET"});if(s.status>=200&&s.status<400){const o=E.createWriteStream(n);await yt.pipeline(s.data,o)}else throw new Error(`download asset failed ${s.status}`)},rs=async(t,n)=>{await Promise.all(t.map(async e=>{try{await os(e,h.join(n,h.basename(e)))}catch(s){C.error(`Failed to export assets: ${e}, ${s}`)}}))};function ze(t){return Oe.test(t)?[t]:Y.test(t)?(De.lastIndex=0,Array.from(t.matchAll(De)).map(e=>e[1]).filter(e=>!!e)):[]}async function de(t,n,e){const{getFilename:s,exportAssets:o}=e,r=h.join(n,s(t));if(E.mkdirSync(h.dirname(r),{recursive:!0}),E.writeFileSync(r,K.stringify(t)),o){const a=re(t,i=>typeof i=="string"&&(Oe.test(i)||Y.test(i))).map(i=>{const c=N.get(t,i);return ze(c)}).flat().filter(Boolean);await rs(a,h.dirname(r))}}const ke=new Ee.LRUCache({max:1e3,ttl:30*24*60*60*1e3});async function Re(t,n,e){var a;const s=re(t,i=>typeof i=="string"&&(Oe.test(i)||Y.test(i))),o=_t.default(2),r=s.map(i=>o(async()=>{try{const c=N.get(t,i),p=ze(c);for(const u of p){const f=h.basename(u),g=e.getFilePath(u,i),S=g?`${g}:${f}`:f,j=ke.get(S);if(j){Y.test(c)||N.set(t,i,j);return}const v=await ns(g,f,n);v&&(Y.test(c)||N.set(t,i,v),ke.set(S,v))}}catch(c){C.error(`Failed to process upload for path ${i.join(".")}:`,c.message||c.reason)}})),l=await Promise.allSettled(r);(a=e.onFinish)==null||a.call(e,l)}async function Ye(t,{exportAssets:n,pageIds:e="all",componentIds:s="all",rawConfig:o,includeResources:r=!1}={}){var F,R,y,T,O,P;const l=e==="all"?t.pageIds:e,a=as({state:t,pageIds:l,componentIds:s==="all"?Object.keys(t.components):s}),i=(m,d)=>{var b;return{id:m.id,name:m.name,isTemplateSection:m.isTemplateSection??!1,templateDescription:m.templateDescription,component:m.component,config:m.config,visibility:m.visibility,properties:((b=m.locales)==null?void 0:b[d])??{}}},c=(m,d)=>{var b;return{id:m.id,createdAt:m.createdAt,updatedAt:m.updatedAt,publishedAt:m.publishedAt,isPublic:m.isPublic??!0,isTemplate:m.isTemplate??!1,meta:((b=m.locales)==null?void 0:b[d])??{},sections:M(m.sectionIds.map(k=>{const U=m.sections[k];return U&&i(U,d)}))}},p=M(t.supportedLocales.map(m=>m.locale).flatMap(m=>l.map(d=>{const b=t.pages[d];return b&&{locale:m,slug:b.slug,page:c(b,m)}}))),u=Ke(),f=h.join(u,"pages");E.mkdirSync(f,{recursive:!0});const g=h.join(u,"components");E.mkdirSync(g,{recursive:!0});for(const{locale:m,slug:d,page:b}of p)await de(b,f,{getFilename:()=>`${Je(d)||"index"}.${m}.yml`,exportAssets:n});for(const m of a){const d=(F=t.components[m])==null?void 0:F.data;d&&await de(d,g,{getFilename:b=>`${b.name||"unnamed"}.${b.id}.yml`,exportAssets:n})}const S=h.join(u,".blocklet/pages/pages.config.yml");E.mkdirSync(h.dirname(S),{recursive:!0});const j={pages:M(l.map(m=>{const d=t.pages[m];return d&&{id:m,slug:d.slug}})),components:M(a.map(m=>{var b;const d=(b=t.components[m])==null?void 0:b.data;return d&&{id:m,name:d.name}})),...r?{resources:{components:M(Object.keys(((R=t.resources)==null?void 0:R.components)||{}).map(m=>{var d,b,k,U;return{id:m,name:(U=(k=(b=(d=t.resources)==null?void 0:d.components)==null?void 0:b[m])==null?void 0:k.component)==null?void 0:U.name}}))}}:{},supportedLocales:t.supportedLocales,config:t.config};E.writeFileSync(S,K.stringify(j));const v=h.join(u,"config.source.json");if(o&&E.writeFileSync(v,JSON.stringify(o)),r){const m=h.join(u,"resources"),d=h.join(m,"components");E.mkdirSync(d,{recursive:!0});for(const b of Object.keys(((y=t==null?void 0:t.resources)==null?void 0:y.components)??{})){const k=(P=(O=(T=t.resources)==null?void 0:T.components)==null?void 0:O[b])==null?void 0:P.component;k&&await de(k,d,{getFilename:U=>`${U.name||"unnamed"}.${U.id}.yml`,exportAssets:n})}}return u}async function Pe(t,{importAssets:n,includeResources:e}={}){var r,l,a;if(!E.existsSync(t))return null;let s,o=!1;try{E.lstatSync(t).isDirectory()?s=t:/\.(tgz|gz|tar)$/.test(t)&&(o=!0,s=Ke(),await St.x({file:t,C:s}));const i=fe.globSync("**/.blocklet/pages/pages.config.yml",{cwd:s,absolute:!0}).at(0),c=i&&h.join(h.dirname(i),"../../pages"),p=i&&h.join(h.dirname(i),"../../components"),u=i&&h.join(h.dirname(i),"../../chunks");if(!i)return null;const f=K.parse(E.readFileSync(i).toString()),g=(y,T,O)=>{let P=h.join(y,`${T}${O?`.${O}`:""}.yml`);return(!E.existsSync(P)||!E.lstatSync(P).isFile())&&(P=h.join(y,T,`index${O?`.${O}`:""}.yml`),!E.existsSync(P)||!E.lstatSync(P))?null:K.parse(E.readFileSync(P).toString())},S=(y,T)=>{try{const O=fe.globSync(`*.${T}.yml`,{cwd:y,absolute:!0})[0];return O?K.parse(E.readFileSync(O).toString()):null}catch(O){C.error("parse component error",O)}return null},j=M(f.pages.map(({slug:y})=>{var m;const T=M(f.supportedLocales.map(({locale:d})=>{const b=c?g(c,Je(y),d):void 0;if(b)return{locale:d,page:b};const k=c?g(c,y,d):void 0;return k&&{locale:d,page:k}})),O=(m=T[0])==null?void 0:m.page;if(!O)return null;const P=O.sections.map(d=>{const b=d.id||ye();return{id:b,component:d.component,config:d.config,name:d.name,isTemplateSection:d.isTemplateSection??!1,templateDescription:d.templateDescription,visibility:d.visibility,locales:Object.fromEntries(M(T.map(({locale:k,page:U})=>{const _e=U.sections.find(et=>et.id===b);return _e&&[k,_e.properties]})))}});return{id:O.id||ye(),createdAt:O.createdAt,updatedAt:O.updatedAt,publishedAt:O.publishedAt,isPublic:O.isPublic??!0,isTemplate:O.isTemplate??!1,slug:y,sections:Object.fromEntries(P.map(d=>[d.id,d])),sectionIds:P.map(d=>d.id),locales:Object.fromEntries(T.map(({locale:d,page:b})=>[d,b.meta]))}})),v=p?M(((r=f.components)==null?void 0:r.map(({id:y})=>S(p,y)))??[]):[];if(n){const y=(...T)=>{C.info(`[${o?h.basename(t):h.basename(h.join(t,"../../../../"))}] importAssets:`,...T)};try{y("wait image-bin api ready"),await xt.default({resources:[`${be.getComponentWebEndpoint(kt)}/api/sdk/uploads`],validateStatus:P=>P>=200&&P<=500}),y("image-bin api is ready");const T={},O={};y("start to upload assets"),await Promise.allSettled([Re(v,T,{getFilePath:P=>p&&h.join(p,P),onFinish:P=>{y(`upload ${P.length} component assets`)}}),Re(j,O,{getFilePath:(P,m)=>{const d=N.get(j,m.slice(0,1));return c&&h.join(c,h.dirname(d.slug),P)},onFinish:P=>{y(`upload ${P.length} page assets`)}})]),y("upload assets done"),global.gc&&global.gc()}catch(T){y("Error during asset import:",T)}}const F={};if(e){const y=i&&h.join(h.dirname(i),"../../resources/components"),T=M(((a=(l=f.resources)==null?void 0:l.components)==null?void 0:a.map(({id:O})=>S(y,O)))??[]);T.length>0&&(F.components=Object.fromEntries(T.map((O,P)=>[O.id,{index:P,component:O}])))}const R={};if(u&&E.existsSync(u)){const y=E.readdirSync(u);for(const T of y)R[T]=h.join(u,T)}return{supportedLocales:f.supportedLocales,pageIds:j.map(y=>y.id),components:Object.fromEntries(v.map((y,T)=>[y.id,{index:T,data:y}])),pages:Object.fromEntries(j.map(y=>[y.id,y])),config:f.config||{},resources:F,chunks:R}}finally{o&&s&&E.rmSync(s,{force:!0,recursive:!0})}}async function we(t,n,{pages:e,pageMergeMode:s="byUpdateTime",deletePages:o=!1,publishMode:r=void 0}={}){try{r&&$e(r)}catch(p){C.error("clear preload page cache error",{error:p})}const{pageIds:l,pages:a,supportedLocales:i}=t;for(const p of e??l){const u=a[p];if(!u){const f=n.pageIds.indexOf(p);f!==-1&&o&&(n.pageIds.splice(f,1),delete n.pages[p]);continue}if(n.pageIds.includes(u.id)){if(s==="replace")n.pages[u.id]=u;else if(s==="byUpdateTime"){const f=n.pages[u.id];(!f||u.updatedAt&&u.updatedAt>f.updatedAt)&&(n.pages[u.id]=u)}}else n.pageIds.push(u.id),n.pages[u.id]=u}if(o&&!e)for(const p of n.pageIds)t.pageIds.includes(p)||delete n.pages[p],n.pageIds=[...n.pageIds].filter(u=>t.pageIds.includes(u));if(n.supportedLocales.splice(0,n.supportedLocales.length),n.supportedLocales.push(...N.cloneDeep(i)),o)for(const p of Object.keys(n.components))delete n.components[p];let c=JSON.parse(JSON.stringify(t.components));c=Object.fromEntries(await Promise.all(Object.entries(c).map(async([p,u])=>{const f=await We(u==null?void 0:u.data);return[p,{...u,data:f}]}))),Object.assign(n.components,c),Object.assign(n.config,JSON.parse(JSON.stringify(t.config))),n.resources.components=JSON.parse(JSON.stringify(t.resources.components||{}))}const We=B.memoize(async t=>{var n;if(!N.isEmpty(t==null?void 0:t.properties))return t;if(((n=t==null?void 0:t.renderer)==null?void 0:n.type)==="react-component"){const{script:e}=(t==null?void 0:t.renderer)||{};if(e&&e.includes("PROPERTIES_SCHEMA"))try{const s=await Ge(e,"PROPERTIES_SCHEMA",t.id);s&&s.length>0&&t&&(t.properties={},s.forEach((o,r)=>{t!=null&&t.properties&&(t.properties[o.id]={index:r,data:o})}))}catch(s){C.error("checkPropertiesFromCode error",{componentId:t.id,name:t.name},{error:s})}}return t},{keyGenerator:t=>{var l;const n=(t==null?void 0:t.id)||"",e=(t==null?void 0:t.name)||"",s=((l=t==null?void 0:t.renderer)==null?void 0:l.type)||"",o=(t==null?void 0:t.properties)||{},r=ie.createHash("md5").update(JSON.stringify(o)).digest("hex");return JSON.stringify(["checkPropertiesFromCode",n,e,s,r])},lruOptions:{max:100,ttl:1e3*60*60}});function as({state:t,pageIds:n=[],componentIds:e=[]}){var l;const s=(a,i=new Set)=>(Array.isArray(a)&&a.forEach(c=>s(c,i)),a&&typeof a=="object"&&(typeof a.componentId=="string"&&i.add(a.componentId),Object.values(a).forEach(c=>s(c,i))),i),o=new Set(e);for(const a of n){const i=t.pages[a];s(i,o)}const r=[...o];for(;r.length;){const a=r.shift();o.has(a)||o.add(a);const i=(l=t.components[a])==null?void 0:l.data;if(i)for(const c of s(i))o.has(c)||r.push(c)}return[...o]}let ae,H,Ce,Ie,je;function Qe(){return ae=(async()=>{const t=be.getResources({types:[{did:Te,type:ge},{did:zt,type:ge}]});H=(await Promise.all(t.map(async e=>{const s=e.path?await Pe(e.path,{importAssets:!1}):void 0;return s?{blockletId:e.did,state:s,blockletTitle:e.title}:void 0}))).filter(e=>!!e),Ce=H.reduce((e,s)=>Object.assign(e,Object.fromEntries(Object.values(s.state.pages).map(o=>o?[o==null?void 0:o.id,{page:o,blockletId:s.blockletId}]:[]))),{});const n=H.reduce((e,s)=>Object.assign(e,Object.fromEntries(Object.values(s.state.components).map(o=>[o.data.id,{blockletId:s.blockletId,component:o.data}]))),{});Ie=Object.fromEntries(await Promise.all(Object.entries(n).map(async([e,s])=>{const o=await We(s.component);return[e,{...s,component:o}]}))),je=H.reduce((e,s)=>Object.assign(e,s.state.chunks),{})})(),ae}function Xe(t){const n=N.debounce(async()=>{await Qe().catch(e=>{C.error("load resource states error",{error:e})}),await(t==null?void 0:t({states:H,pages:Ce,components:Ie,chunks:je}))},3e3,{leading:!1,trailing:!0});return n(),w.default.events.on(w.default.Events.componentAdded,n),w.default.events.on(w.default.Events.componentRemoved,n),w.default.events.on(w.default.Events.componentStarted,n),w.default.events.on(w.default.Events.componentStopped,n),w.default.events.on(w.default.Events.componentUpdated,n),w.default.events.on(he,n),()=>{w.default.events.off(w.default.Events.componentAdded,n),w.default.events.off(w.default.Events.componentRemoved,n),w.default.events.off(w.default.Events.componentStarted,n),w.default.events.off(w.default.Events.componentStopped,n),w.default.events.off(w.default.Events.componentUpdated,n),w.default.events.off(he,n)}}const Ze=Symbol.for("GLOBAL_RESOURCE_STATES_LISTENER_KEY"),ne=globalThis;var Ne;(Ne=ne[Ze])==null||Ne.call(ne);ne[Ze]=Xe(async({pages:t,components:n})=>{const{projectIds:e}=Q;await Promise.all(e.map(async s=>{const o=Q.shared(s);o.syncedStore.resources.pages=t;const r=await $.findByPk(s);if(r!=null&&r.useAllResources)o.syncedStore.resources.components=n;else{const a=(await ce.findAll({where:{projectId:s}})).map(c=>c.componentId),i=Object.fromEntries(Object.entries(n||{}).filter(([c])=>a.includes(c)));o.syncedStore.resources.components=i}C.info(`update [${s}] resource states:`,{pages:Object.keys(o.syncedStore.resources.pages||{}).length,components:Object.keys(o.syncedStore.resources.components||{}).length})}))});async function is(){C.info("trigger reload all project resource"),w.default.events.emit(he)}async function Ae({ensureLoaded:t=!0}={}){return t&&(ae??(ae=Qe()),await ae),{states:H,pages:Ce,components:Ie,chunks:je}}exports.COMPONENT_DID=Te;exports.CUSTOM_COMPONENT_CACHE_DURATION_IN_SECONDS=Fe;exports.GET_SERVER_SIDE_PROPS_TIMEOUT_IN_SECONDS=me;exports.PUBLISH_MODES=ts;exports.Project=$;exports.RESOURCE_TYPE=ge;exports.SITE_STATE_PATH=J;exports.STATE_MODES=es;exports.SiteState=Q;exports.clearPreloadComponentsCache=qe;exports.clearPreloadComponentsCacheByMode=$e;exports.fromPackage=Pe;exports.getComponentFromState=W;exports.getComponentFromStateByName=Gt;exports.getExportSchemaValueFromCode=Ge;exports.getMultiTenantAllProjectAccessPassports=Lt;exports.getPreloadComponent=Ve;exports.getPreloadComponents=Bt;exports.getPreloadComponentsCacheKey=Be;exports.getResourceStates=Ae;exports.initPackResourceStates=Xe;exports.isMultiTenant=Nt;exports.logger=C;exports.mergeState=we;exports.nextId=ye;exports.toPackage=Ye;exports.triggerReloadAllProjectResource=is;
|
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-DtuL49Z6.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/project-html.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";const k=require("./_chunks/site-state-
|
|
1
|
+
"use strict";const k=require("./_chunks/site-state-DtuL49Z6.js"),S=require("@blocklet/crawler/middlewares"),W=require("@blocklet/pages-kit/types"),J=require("@blocklet/pages-kit/utils/preload"),G=require("@blocklet/sdk/lib/component"),D=require("@blocklet/sdk/lib/config"),z=require("cheerio"),K=require("express"),A=require("fs"),Q=require("mustache"),I=require("path"),j=require("ufo"),q=e=>e&&e.__esModule?e:{default:e};function V(e){if(e&&e.__esModule)return e;const l=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const t in e)if(t!=="default"){const d=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(l,t,d.get?d:{enumerable:!0,get:()=>e[t]})}}return l.default=e,Object.freeze(l)}const a=q(D),U=V(z),X=q(Q),Y=["/assets/"],R=()=>[!0,"true"].includes(a.default.env.preferences.allowCrawler);function x(){R()?S.initCronCrawlBlocklet({time:"30 30 */12 * * *",options:{}}):S.cancelCronCrawlBlocklet()}x();a.default.events.on(a.default.Events.envUpdate,x);function Z({app:e,viteDevServer:l,state:t}){let d;if(l){const r=A.readFileSync(I.resolve(process.cwd(),"./index.html"),"utf-8");e.use(async(b,T,y)=>{const v=b.originalUrl;d=await l.transformIndexHtml(v,r),y()})}else d=A.readFileSync(I.resolve(process.env.BLOCKLET_APP_DIR,"dist/index.html"),"utf-8");const C=K.Router();C.use(S.initSEOMiddleware({autoReturnHtml:!1,allowCrawler:R})),C.get("/:path(*)?",async(r,b,T)=>{var E,L,M;if(Y.some(c=>r.path.startsWith(c))){T();return}const y=performance.now(),v=()=>Math.round(performance.now()-y),B="production";let o,p,h=d;if(r.path.startsWith("/pages")){const c=r.params.lang,g=r.cookies.nf_lang,w=new Set([...a.default.env.languages.map(f=>f.code)]);let m=(c&&w.has(c)?c:void 0)||(w.has(g)?g:void 0)||[...w][0];if((!m||!((E=t.supportedLocales)!=null&&E.find(f=>f.locale===m)))&&(m=((M=(L=t.supportedLocales)==null?void 0:L[0])==null?void 0:M.locale)||""),m){const f=[];Object.values(t.pages).forEach(s=>{const P=Object.values((s==null?void 0:s.sections)??{}).filter(i=>{var _;return i.component==="custom-component"&&((_=i.config)==null?void 0:_.componentId)}).map(i=>{var _,O;return{id:i.id,componentId:i.config.componentId,useCache:i.config.useCache,cacheDuration:i.config.cacheDuration,properties:(O=(_=i.locales)==null?void 0:_[m])==null?void 0:O.properties}});f.push(...P)});const N=new Promise((s,P)=>{setTimeout(()=>{P(new Error("getPreloadComponents timeout in promise race, skip it"))},90*1e3)});try{await Promise.race([N,k.getPreloadComponents({mode:B,req:r,state:t,locale:m,instances:f,module:W.PreloadComponentScriptModule.UMD_FN}).then(s=>{s&&(p=J.injectPreloadComponents(s))})])}catch(s){k.logger.warn("getPreloadComponents timeout in promise race, skip inject html elements"),k.logger.warn(s)}}}try{const c=(o==null?void 0:o.title)||a.default.env.appName,g=(o==null?void 0:o.description)||a.default.env.appDescription,w=j.withQuery(j.joinURL(a.default.env.appUrl,"/.well-known/service/blocklet/og.png"),{title:c,description:g});h=X.default.render(d,{ogTitle:c,ogDescription:g,ogImage:F(o==null?void 0:o.image)||w,pagesPublishedAt:(t==null?void 0:t.config.publishedAt)||new Date().getTime()})}catch{}const n=t==null?void 0:t.config.fontFamily,H=r.query.mode==="draft"||r.url.includes("preview"),u=U.load(h);u("head").find("#injected-head-elements").replaceWith(`
|
|
2
2
|
${o!=null&&o.backgroundColor?`<meta name="theme-color" content="${o.backgroundColor}" /><style>html,body,#app {background-color: ${o.backgroundColor} !important;}</style>`:""}
|
|
3
3
|
${n!=null&&n.title?`<link rel="preload" as="style" href="https://fonts.googleapis.com/css?family=${n.title}&display=swap">`:""}
|
|
4
4
|
${n!=null&&n.description&&(n==null?void 0:n.description)!==(n==null?void 0:n.title)?`<link rel="preload" as="style" href="https://fonts.googleapis.com/css?family=${n.description}&display=swap">`:""}
|
package/lib/cjs/resources.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const c=require("./_chunks/site-state-
|
|
1
|
+
"use strict";const c=require("./_chunks/site-state-DtuL49Z6.js"),M=require("async_hooks"),U=require("express"),F=require("fs"),J=require("joi"),O=require("lodash"),b=require("path"),X=require("@blocklet/sdk/lib/middlewares/auth"),W=require("@blocklet/sdk/lib/component"),E=t=>t&&t.__esModule?t:{default:t},p=E(F),I=E(J),k=E(b),v=E(X);new M.AsyncLocalStorage;const $=async(t,e,o)=>{var n,s,r,a;try{const{projectId:u}=t.params;if(!u)return o();const f=await c.Project.findByPk(u);if(!f)return e==null?void 0:e.status(404).json({error:"Project not found"});const P=(n=t.user)==null?void 0:n.did,h=((s=t.user)==null?void 0:s.role)||"UNKNOWN_ROLE";if(!P)return e==null?void 0:e.status(401).json({error:"Authentication required"});if(c.isMultiTenant()){const w=f.createdBy===P,i=(a=(r=c.getMultiTenantAllProjectAccessPassports())==null?void 0:r.includes)==null?void 0:a.call(r,h);if(!w&&!i)return e==null?void 0:e.status(403).json({error:"No permission to access this project in multi-tenant mode"})}else if(!["owner","admin","pagesEditor"].includes(h))return e==null?void 0:e.status(403).json({error:"No permission to access this project in single-tenant mode"});t.project=f,t.projectId=u,o()}catch(u){c.logger.error("Project middleware error:",u),e==null||e.status(500).json({error:"Internal server error"})}};function N(t,e){return new Promise((o,n)=>{const s=p.default.createReadStream(t),r=p.default.createWriteStream(e);s.on("error",n),r.on("error",n),r.on("finish",o),s.pipe(r)})}async function T(t,e){await p.default.promises.mkdir(e,{recursive:!0});const o=await p.default.promises.readdir(t,{withFileTypes:!0});for(const n of o){const s=k.default.join(t,n.name),r=k.default.join(e,n.name);n.isDirectory()?await T(s,r):await N(s,r)}}async function G(t,e){(await p.default.promises.stat(t)).isDirectory()?await T(t,e):await N(t,e)}const D=(t,e,o)=>c.isMultiTenant()?v.default()(t,e,o):v.default({roles:["owner","admin","pagesEditor"]})(t,e,o),K=(t,e)=>{const o=W.getResourceExportDir({projectId:t,releaseId:e});return b.join(o,c.COMPONENT_DID,c.RESOURCE_TYPE)},S=U.Router(),B="@page",q="@component",y=":",_="ALL",L="@project",C=({pageId:t,projectId:e})=>[B,e,t].join(y),Y=t=>{const[e,o,n]=t.split(y);if(e===B)return{pageId:n,projectId:o}},A=({componentId:t,projectId:e})=>[q,e,t].join(y),z=t=>{const[e,o,n]=t.split(y);if(e===q)return{componentId:n,projectId:o}},H=t=>[L,t].join(y),Q=t=>{const[e,o]=t.split(y);if(e===L)return o},V=t=>{try{return JSON.parse(t)}catch{}return{}};async function x(t){const e=await c.SiteState.shared(t).getState("production"),o=await c.Project.findByPk(t),n=e.pageIds.map(r=>{const a=e.pages[r];if(a)return{id:C({pageId:r,projectId:t}),name:a.slug}}).filter(Boolean),s=O.sortBy(Object.values(e.components),r=>r.index).map(({data:r})=>({id:A({componentId:r.id,projectId:t}),name:r.name||r.id}));return{id:H(t),name:(o==null?void 0:o.name)||"Unnamed Project",children:[{id:C({pageId:_,projectId:t}),name:"Pages",children:n},{id:A({componentId:_,projectId:t}),name:"Components",children:s}]}}S.get("/resources",D,async(t,e)=>{const{projectId:o}=V(t.query.resourcesParams);if(o){t.params={...t.params,projectId:o},await $(t,e,()=>{});const r=await x(o);e.json({resources:[r]});return}const n=await c.Project.findAll({where:{}}),s=await Promise.all(n.map(r=>x(r.id)));e.json({resources:s})});const Z=I.default.object({projectId:I.default.string().required().min(1),releaseId:I.default.string().allow(""),resources:I.default.array().items(I.default.string()).required(),locale:I.default.string().allow("")});S.post("/resources",D,async(t,e)=>{const{resources:o,projectId:n,releaseId:s}=await Z.validateAsync(t.body),r="production",a=[],u=[];for(const i of o){if(Q(i))continue;const{pageId:m,projectId:j}=Y(i)||{};if(m)m===_||m&&j&&a.push({pageId:m,projectId:j});else{const{componentId:l,projectId:d}=z(i)||{};l===_||l&&d&&u.push({componentId:l,projectId:d})}}const f=O.groupBy(a,"projectId"),P=O.groupBy(u,"projectId"),h=new Set([...Object.keys(f),...Object.keys(P)]),w=K(n,s);p.default.rmSync(w,{recursive:!0,force:!0}),p.default.mkdirSync(w,{recursive:!0});for(const i of h){const m=await c.SiteState.shared(i).getState(r),j=f[i],l=P[i],d=j==null?void 0:j.map(g=>g.pageId),R=l==null?void 0:l.map(g=>g.componentId);if(d!=null&&d.length||R!=null&&R.length){const g=await c.toPackage(m,{exportAssets:!0,pageIds:d,componentIds:R});await G(g,w),p.default.rmSync(g,{recursive:!0,force:!0})}c.logger.info(`Exported resources for project ${i}`,{pageIds:d,componentIds:R})}e.json({})});S.get("/all-resources",D,async(t,e)=>{const{states:o}=await c.getResourceStates(),n=o==null?void 0:o.map(s=>{const r={blockletId:s.blockletId,blockletTitle:s.blockletTitle,components:{}};if(s.state.components&&(r.components=s.state.components),Object.keys(r.components).length!==0)return r}).filter(Boolean);e.json(n)});module.exports=S;
|
package/lib/cjs/site-state.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("./_chunks/site-state-
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("./_chunks/site-state-DtuL49Z6.js");require("@blocklet/quickjs");require("@blocklet/sdk/lib/component");require("@blocklet/sdk/lib/config");require("@reactivedata/reactive");require("@syncedstore/core");require("crypto");require("fs");require("glob");require("lib0/decoding");require("lib0/encoding");require("lodash");require("lru-cache");require("nanoid");require("p-limit");require("path");require("stream/promises");require("tar");require("ufo");require("wait-on");require("y-protocols/awareness");require("y-protocols/sync");require("yaml");require("yjs");exports.PUBLISH_MODES=e.PUBLISH_MODES;exports.SITE_STATE_PATH=e.SITE_STATE_PATH;exports.STATE_MODES=e.STATE_MODES;exports.default=e.SiteState;exports.fromPackage=e.fromPackage;exports.getResourceStates=e.getResourceStates;exports.initPackResourceStates=e.initPackResourceStates;exports.mergeState=e.mergeState;exports.nextId=e.nextId;exports.toPackage=e.toPackage;exports.triggerReloadAllProjectResource=e.triggerReloadAllProjectResource;
|
|
@@ -1,51 +1,51 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var P = (t, o, e) =>
|
|
4
|
-
import { getComponentMountPoint as
|
|
1
|
+
var et = Object.defineProperty;
|
|
2
|
+
var tt = (t, o, e) => o in t ? et(t, o, { enumerable: !0, configurable: !0, writable: !0, value: e }) : t[o] = e;
|
|
3
|
+
var P = (t, o, e) => tt(t, typeof o != "symbol" ? o + "" : o, e);
|
|
4
|
+
import { getComponentMountPoint as st } from "@blocklet/pages-kit/builtin/utils";
|
|
5
5
|
import { PreloadComponentScriptModule as X } from "@blocklet/pages-kit/types";
|
|
6
|
-
import { componentUMDName as
|
|
7
|
-
import { memoize as ae, Sandbox as
|
|
6
|
+
import { componentUMDName as ot, RenderNestedComponent as Oe, mergeComponent as nt } from "@blocklet/pages-kit/utils/property";
|
|
7
|
+
import { memoize as ae, Sandbox as Me, BuiltinModules as rt } from "@blocklet/quickjs";
|
|
8
8
|
import S from "@blocklet/sdk/lib/config";
|
|
9
9
|
import { LRUCache as he } from "lru-cache";
|
|
10
|
-
import
|
|
11
|
-
import { joinURL as M, getQuery as
|
|
10
|
+
import at, { Headers as it } from "node-fetch";
|
|
11
|
+
import { joinURL as M, getQuery as ct, withQuery as lt, parseURL as Ae, withHttps as pt } from "ufo";
|
|
12
12
|
import { createHash as ie } from "crypto";
|
|
13
|
-
import
|
|
14
|
-
import { BuiltinModules as
|
|
15
|
-
import { createBuiltinModuleTransformer as
|
|
13
|
+
import ut from "@blocklet/logger";
|
|
14
|
+
import { BuiltinModules as dt } from "@blocklet/pages-kit/utils/builtin";
|
|
15
|
+
import { createBuiltinModuleTransformer as mt, isRelativeModule as ft } from "@blocklet/pages-kit/utils/typescript/builtin-module-transformer";
|
|
16
16
|
import { getResources as gt, getComponentWebEndpoint as ht, call as yt } from "@blocklet/sdk/lib/component";
|
|
17
17
|
import St from "autoprefixer";
|
|
18
18
|
import * as wt from "esbuild";
|
|
19
|
-
import { readFileSync as H, existsSync as V, lstatSync as Z, readdirSync as Et, rmSync as
|
|
19
|
+
import { readFileSync as H, existsSync as V, lstatSync as Z, readdirSync as Et, rmSync as Fe, mkdtempSync as bt, renameSync as ve, mkdirSync as F, writeFileSync as te, createWriteStream as It } from "fs";
|
|
20
20
|
import Ot from "postcss";
|
|
21
|
-
import
|
|
21
|
+
import At from "tailwindcss";
|
|
22
22
|
import j from "typescript";
|
|
23
|
-
import { reactive as
|
|
23
|
+
import { reactive as vt } from "@reactivedata/reactive";
|
|
24
24
|
import { syncedStore as Tt, getYjsValue as le } from "@syncedstore/core";
|
|
25
25
|
import { globSync as me } from "glob";
|
|
26
26
|
import * as pe from "lib0/decoding";
|
|
27
27
|
import * as C from "lib0/encoding";
|
|
28
|
-
import { get as ye, isEmpty as Pt, set as
|
|
28
|
+
import { get as ye, isEmpty as Pt, set as Te, pick as Ct, debounce as $e, union as xt, cloneDeep as jt } from "lodash";
|
|
29
29
|
import { customAlphabet as kt } from "nanoid";
|
|
30
30
|
import Dt from "p-limit";
|
|
31
31
|
import Nt, { join as O, dirname as L, basename as J } from "path";
|
|
32
32
|
import { pipeline as Lt } from "stream/promises";
|
|
33
33
|
import { x as Rt } from "tar";
|
|
34
34
|
import Ut from "wait-on";
|
|
35
|
-
import { Awareness as _t, encodeAwarenessUpdate as
|
|
35
|
+
import { Awareness as _t, encodeAwarenessUpdate as Pe, removeAwarenessStates as Mt, applyAwarenessUpdate as Ft } from "y-protocols/awareness";
|
|
36
36
|
import { writeUpdate as $t, writeSyncStep1 as Bt, readSyncMessage as Vt } from "y-protocols/sync";
|
|
37
37
|
import * as K from "yaml";
|
|
38
38
|
import * as B from "yjs";
|
|
39
39
|
import Gt from "lodash/isNil";
|
|
40
|
-
import { DataTypes as T, Sequelize as Jt, Model as
|
|
40
|
+
import { DataTypes as T, Sequelize as Jt, Model as Be, Op as Ht } from "sequelize";
|
|
41
41
|
import "sqlite3";
|
|
42
42
|
S.env.mode;
|
|
43
43
|
const Kt = "image-bin";
|
|
44
44
|
S.env.INIT_TEMPLATE_PATH;
|
|
45
|
-
const Wt = process.env.DATABASE_URL || Nt.join(S.env.dataDir, "db/pages-kit.db"),
|
|
45
|
+
const Wt = process.env.DATABASE_URL || Nt.join(S.env.dataDir, "db/pages-kit.db"), Ce = S, so = () => S.env.tenantMode === "multiple", oo = () => {
|
|
46
46
|
var t;
|
|
47
|
-
return (Gt(
|
|
48
|
-
},
|
|
47
|
+
return (Gt(Ce.env.preferences.multiTenantAllProjectAccessPassports) ? [] : (t = Ce.env.preferences.multiTenantAllProjectAccessPassports) == null ? void 0 : t.split(",")) || [];
|
|
48
|
+
}, A = ut("pages-kit"), zt = T.sqlite.DATE.parse;
|
|
49
49
|
T.sqlite.DATE.parse = (t, o) => typeof t == "number" ? new Date(t) : zt(t, o);
|
|
50
50
|
const Y = new Jt({
|
|
51
51
|
dialect: "sqlite",
|
|
@@ -63,7 +63,7 @@ const Y = new Jt({
|
|
|
63
63
|
Y.query("pragma journal_mode = WAL;");
|
|
64
64
|
Y.query("pragma synchronous = normal;");
|
|
65
65
|
Y.query("pragma journal_size_limit = 67108864;");
|
|
66
|
-
class ce extends
|
|
66
|
+
class ce extends Be {
|
|
67
67
|
// Foreign key to Component
|
|
68
68
|
}
|
|
69
69
|
ce.init(
|
|
@@ -85,7 +85,7 @@ ce.init(
|
|
|
85
85
|
},
|
|
86
86
|
{ sequelize: Y, tableName: "ProjectComponents", timestamps: !1 }
|
|
87
87
|
);
|
|
88
|
-
class $ extends
|
|
88
|
+
class $ extends Be {
|
|
89
89
|
static async getProjectByIdOrSlug(o) {
|
|
90
90
|
return $.findOne({
|
|
91
91
|
where: {
|
|
@@ -143,7 +143,7 @@ const Yt = async (t, { componentId: o }) => {
|
|
|
143
143
|
@tailwind utilities;
|
|
144
144
|
`, s = `.CustomComponent_${o}`;
|
|
145
145
|
return (await Ot([
|
|
146
|
-
|
|
146
|
+
At({ content: [{ raw: t, extension: "tsx" }] }),
|
|
147
147
|
St({
|
|
148
148
|
overrideBrowserslist: ["> 1%", "last 2 versions"],
|
|
149
149
|
stats: {}
|
|
@@ -162,7 +162,7 @@ const Yt = async (t, { componentId: o }) => {
|
|
|
162
162
|
|
|
163
163
|
${t}
|
|
164
164
|
`;
|
|
165
|
-
},
|
|
165
|
+
}, xe = ae(
|
|
166
166
|
async (t, o) => {
|
|
167
167
|
let e = j.transpileModule(t, {
|
|
168
168
|
compilerOptions: {
|
|
@@ -171,7 +171,7 @@ ${t}
|
|
|
171
171
|
module: j.ModuleKind.ESNext
|
|
172
172
|
},
|
|
173
173
|
transformers: {
|
|
174
|
-
before: [
|
|
174
|
+
before: [mt(j)]
|
|
175
175
|
}
|
|
176
176
|
}).outputText;
|
|
177
177
|
if (o.tailwind && (e = await qt(e, { componentId: o.componentId })), o.module === X.ESM) return e;
|
|
@@ -207,7 +207,7 @@ ${t}
|
|
|
207
207
|
var l, a;
|
|
208
208
|
const s = (a = (l = (await wt.build({
|
|
209
209
|
entryPoints: ["index.tsx"],
|
|
210
|
-
external: Object.keys(
|
|
210
|
+
external: Object.keys(dt),
|
|
211
211
|
format: "esm",
|
|
212
212
|
target: "esnext",
|
|
213
213
|
bundle: !0,
|
|
@@ -217,22 +217,20 @@ ${t}
|
|
|
217
217
|
name: "vfs",
|
|
218
218
|
setup(i) {
|
|
219
219
|
let c = null;
|
|
220
|
-
i.onResolve({ filter: /.*/ }, (p) => p.path === "index.tsx" ? { path: "index.tsx", namespace: "vfs" } : p.path === "./component" ? { path: "component.tsx", namespace: "vfs" } :
|
|
220
|
+
i.onResolve({ filter: /.*/ }, (p) => p.path === "index.tsx" ? { path: "index.tsx", namespace: "vfs" } : p.path === "./component" ? { path: "component.tsx", namespace: "vfs" } : null), i.onLoad({ filter: /.*/, namespace: "vfs" }, async (p) => {
|
|
221
221
|
var u;
|
|
222
222
|
if (p.path === "index.tsx")
|
|
223
223
|
return { contents: `export { ${o} } from './component'`, loader: "tsx" };
|
|
224
224
|
if (p.path === "component.tsx")
|
|
225
225
|
return { contents: t, loader: "tsx" };
|
|
226
|
-
if (
|
|
227
|
-
c || (c = await Ze({ ensureLoaded: !1 }));
|
|
226
|
+
if (ft(p.path)) {
|
|
228
227
|
const m = p.path.split("/").pop();
|
|
229
|
-
if ((u = c == null ? void 0 : c.chunks) != null && u[m])
|
|
228
|
+
if (c || (c = await Xe({ ensureLoaded: !1 })), (u = c == null ? void 0 : c.chunks) != null && u[m])
|
|
230
229
|
try {
|
|
231
230
|
const g = H(c.chunks[m], "utf-8");
|
|
232
|
-
return
|
|
231
|
+
return A.info("get chunk from local file system", m), { contents: g, loader: "tsx" };
|
|
233
232
|
} catch {
|
|
234
233
|
}
|
|
235
|
-
return { contents: "", loader: "tsx" };
|
|
236
234
|
}
|
|
237
235
|
return null;
|
|
238
236
|
});
|
|
@@ -245,7 +243,7 @@ ${t}
|
|
|
245
243
|
return j.transpileModule(n, {
|
|
246
244
|
compilerOptions: { module: j.ModuleKind.ESNext, target: j.ScriptTarget.ES2020 }
|
|
247
245
|
}).outputText;
|
|
248
|
-
},
|
|
246
|
+
}, Ve = ae(
|
|
249
247
|
async (t, o) => {
|
|
250
248
|
const e = await Qt(t, o);
|
|
251
249
|
return new RegExp(`export\\s+\\{\\s+${o}\\s+\\}`, "m").test(e) ? e : void 0;
|
|
@@ -291,13 +289,13 @@ var ${t} = ${e ? "async" : ""} function () {
|
|
|
291
289
|
`;
|
|
292
290
|
}, W = new he({
|
|
293
291
|
max: 100
|
|
294
|
-
}), Zt = 60 * 60,
|
|
292
|
+
}), Zt = 60 * 60, je = 60;
|
|
295
293
|
function es(t) {
|
|
296
|
-
|
|
294
|
+
A.info("clear preload components cache", { cacheKey: t }), W.delete(t);
|
|
297
295
|
}
|
|
298
296
|
function ts(t) {
|
|
299
297
|
for (const o of W.keys())
|
|
300
|
-
o.includes(t) && (
|
|
298
|
+
o.includes(t) && (A.info("clear preload components cache", { cacheKey: o }), es(o));
|
|
301
299
|
}
|
|
302
300
|
function ss({
|
|
303
301
|
mode: t,
|
|
@@ -330,13 +328,13 @@ async function no({
|
|
|
330
328
|
locale: s
|
|
331
329
|
});
|
|
332
330
|
if (t !== "draft" && g.useCache && W.has(y))
|
|
333
|
-
return
|
|
334
|
-
const
|
|
335
|
-
if (!
|
|
331
|
+
return A.info(`get preload component from cache: ${y}`), W.get(y);
|
|
332
|
+
const v = se({ state: e, componentId: g.componentId });
|
|
333
|
+
if (!v) return null;
|
|
336
334
|
const x = await os({
|
|
337
335
|
req: o,
|
|
338
336
|
state: e,
|
|
339
|
-
componentId:
|
|
337
|
+
componentId: v.id,
|
|
340
338
|
locale: s,
|
|
341
339
|
defaultLocale: a,
|
|
342
340
|
properties: g.properties
|
|
@@ -345,13 +343,13 @@ async function no({
|
|
|
345
343
|
const U = { instanceId: g.id, preload: x };
|
|
346
344
|
if (t !== "draft" && g.useCache) {
|
|
347
345
|
let D = Zt;
|
|
348
|
-
g.cacheDuration && (D = g.cacheDuration),
|
|
346
|
+
g.cacheDuration && (D = g.cacheDuration), A.info(`set preload component to cache(${D}s): ${y}`), W.set(y, U, {
|
|
349
347
|
ttl: D * 1e3
|
|
350
348
|
});
|
|
351
349
|
}
|
|
352
350
|
return U;
|
|
353
351
|
} catch (y) {
|
|
354
|
-
return
|
|
352
|
+
return A.error("get preload component error", { instanceId: g.id, componentId: g.componentId }, { error: y }), null;
|
|
355
353
|
}
|
|
356
354
|
})
|
|
357
355
|
)).filter((g) => !!g), c = Object.values(
|
|
@@ -360,22 +358,22 @@ async function no({
|
|
|
360
358
|
async function p() {
|
|
361
359
|
const g = await Promise.all(
|
|
362
360
|
c.map(async (y) => {
|
|
363
|
-
const
|
|
361
|
+
const v = ot({ componentId: y.component.id }), x = r === X.ESM ? {
|
|
364
362
|
module: r,
|
|
365
|
-
script: await
|
|
363
|
+
script: await xe(y.script, {
|
|
366
364
|
componentId: y.component.id,
|
|
367
365
|
module: r,
|
|
368
366
|
tailwind: t !== "draft"
|
|
369
367
|
})
|
|
370
368
|
} : {
|
|
371
369
|
module: r,
|
|
372
|
-
script: await
|
|
370
|
+
script: await xe(y.script, {
|
|
373
371
|
componentId: y.component.id,
|
|
374
372
|
module: r,
|
|
375
|
-
moduleName:
|
|
373
|
+
moduleName: v,
|
|
376
374
|
tailwind: t !== "draft"
|
|
377
375
|
}),
|
|
378
|
-
moduleName:
|
|
376
|
+
moduleName: v
|
|
379
377
|
};
|
|
380
378
|
return [y.component.id, { component: y.component, script: x }];
|
|
381
379
|
})
|
|
@@ -405,14 +403,14 @@ async function os({
|
|
|
405
403
|
if (!a) return null;
|
|
406
404
|
const i = l.some((p) => p.locale === s) ? s : n;
|
|
407
405
|
if (!i) return null;
|
|
408
|
-
const c = await
|
|
406
|
+
const c = await Ge({ req: t, state: o, componentId: e, locale: i, defaultLocale: n, properties: r });
|
|
409
407
|
return c ? {
|
|
410
408
|
component: a,
|
|
411
409
|
...c
|
|
412
410
|
} : null;
|
|
413
411
|
}
|
|
414
412
|
const ns = 20;
|
|
415
|
-
async function
|
|
413
|
+
async function Ge({
|
|
416
414
|
req: t,
|
|
417
415
|
depth: o = 0,
|
|
418
416
|
state: e,
|
|
@@ -433,12 +431,12 @@ async function Je({
|
|
|
433
431
|
const p = await as({ ...a, req: t });
|
|
434
432
|
p != null && p.props && Object.assign(c.props, p.props);
|
|
435
433
|
} catch (p) {
|
|
436
|
-
|
|
434
|
+
A.error("preload data at server side error", { componentId: s, name: a.component.name }, { error: p });
|
|
437
435
|
}
|
|
438
436
|
return await Promise.all(
|
|
439
437
|
Object.entries(i).map(async ([p, u]) => {
|
|
440
438
|
if ((u == null ? void 0 : u.type) === Oe) {
|
|
441
|
-
const m = await
|
|
439
|
+
const m = await Ge({
|
|
442
440
|
req: t,
|
|
443
441
|
depth: o + 1,
|
|
444
442
|
state: e,
|
|
@@ -466,7 +464,7 @@ function rs({
|
|
|
466
464
|
}) {
|
|
467
465
|
const n = se({ state: t, componentId: o });
|
|
468
466
|
if (!n) return null;
|
|
469
|
-
const r =
|
|
467
|
+
const r = nt({
|
|
470
468
|
componentId: o,
|
|
471
469
|
getComponent: (l) => se({ state: t, componentId: l }),
|
|
472
470
|
locale: e,
|
|
@@ -498,16 +496,16 @@ async function as({
|
|
|
498
496
|
}) {
|
|
499
497
|
if (!(o != null && o.includes("getServerSideProps")))
|
|
500
498
|
return null;
|
|
501
|
-
const n = await
|
|
499
|
+
const n = await Ve(o, "getServerSideProps");
|
|
502
500
|
if (!n) return null;
|
|
503
501
|
const r = new Promise((a, i) => {
|
|
504
502
|
setTimeout(() => {
|
|
505
503
|
i(new Error("getServerSideProps timeout in promise race"));
|
|
506
|
-
},
|
|
504
|
+
}, je * 1e3);
|
|
507
505
|
});
|
|
508
506
|
return await Promise.race([
|
|
509
507
|
r,
|
|
510
|
-
|
|
508
|
+
Me.callFunction({
|
|
511
509
|
code: `${n}
|
|
512
510
|
|
|
513
511
|
export async function getServerSidePropsWrapper(props) {
|
|
@@ -533,45 +531,45 @@ export async function getServerSidePropsWrapper(props) {
|
|
|
533
531
|
export { joinURL, withQuery, getQuery, getComponentMountPoint }
|
|
534
532
|
`;
|
|
535
533
|
if (a === "@blocklet/pages-kit/builtin/dayjs")
|
|
536
|
-
return
|
|
534
|
+
return rt.dayjs;
|
|
537
535
|
},
|
|
538
536
|
global: {
|
|
539
537
|
console: {
|
|
540
538
|
// NOTE: do not return logger.xxx result, it will cause memory leak
|
|
541
539
|
// eslint-disable-next-line prettier/prettier
|
|
542
540
|
log: (...a) => {
|
|
543
|
-
|
|
541
|
+
A.info(...a);
|
|
544
542
|
},
|
|
545
543
|
warn: (...a) => {
|
|
546
|
-
|
|
544
|
+
A.warn(...a);
|
|
547
545
|
},
|
|
548
546
|
error: (...a) => {
|
|
549
|
-
|
|
547
|
+
A.error(...a);
|
|
550
548
|
}
|
|
551
549
|
},
|
|
552
|
-
getComponentMountPoint:
|
|
550
|
+
getComponentMountPoint: st,
|
|
553
551
|
joinURL: M,
|
|
554
|
-
withQuery:
|
|
555
|
-
getQuery:
|
|
552
|
+
withQuery: lt,
|
|
553
|
+
getQuery: ct
|
|
556
554
|
},
|
|
557
555
|
functionName: "getServerSidePropsWrapper",
|
|
558
556
|
args: [
|
|
559
557
|
{
|
|
560
558
|
// NOTE: IMPORTANT! place location and fetch (has side effect) at the args not global
|
|
561
559
|
// because the global is shared between all runtime and just init once
|
|
562
|
-
location: { href: M(
|
|
560
|
+
location: { href: M(pt(s.hostname), s.originalUrl) },
|
|
563
561
|
fetch: (a, { ...i } = {}) => {
|
|
564
562
|
const c = typeof a == "string" && a.startsWith("/") ? M(S.env.appUrl, a) : a;
|
|
565
|
-
if (typeof c == "string" &&
|
|
563
|
+
if (typeof c == "string" && Ae(c).host === Ae(S.env.appUrl).host) {
|
|
566
564
|
const p = s.get("cookie");
|
|
567
565
|
if (p) {
|
|
568
|
-
const u = new
|
|
566
|
+
const u = new it(i.headers);
|
|
569
567
|
u.set("cookie", p), i.headers = u;
|
|
570
568
|
}
|
|
571
569
|
}
|
|
572
|
-
return
|
|
570
|
+
return at(c, {
|
|
573
571
|
...i,
|
|
574
|
-
timeout:
|
|
572
|
+
timeout: je * 1e3
|
|
575
573
|
}).then((p) => ({
|
|
576
574
|
ok: p.ok,
|
|
577
575
|
status: p.status,
|
|
@@ -590,10 +588,10 @@ const is = ae(
|
|
|
590
588
|
async (t, o, e) => {
|
|
591
589
|
if (!(t != null && t.includes(o)))
|
|
592
590
|
return null;
|
|
593
|
-
const s = await
|
|
591
|
+
const s = await Ve(t, o);
|
|
594
592
|
if (s)
|
|
595
593
|
try {
|
|
596
|
-
return await
|
|
594
|
+
return await Me.callFunction({
|
|
597
595
|
code: `
|
|
598
596
|
${s}
|
|
599
597
|
|
|
@@ -605,7 +603,7 @@ const is = ae(
|
|
|
605
603
|
functionName: `get${o}SchemaWrapper`
|
|
606
604
|
});
|
|
607
605
|
} catch (n) {
|
|
608
|
-
return
|
|
606
|
+
return A.error(`获取 ${o} 失败`, { componentId: e, error: n }), null;
|
|
609
607
|
}
|
|
610
608
|
return null;
|
|
611
609
|
},
|
|
@@ -619,8 +617,8 @@ const is = ae(
|
|
|
619
617
|
ttl: 1e3 * 60 * 60
|
|
620
618
|
}
|
|
621
619
|
}
|
|
622
|
-
), cs = "z8iZiDFg3vkkrPwsiba1TLXy3H9XHzFERsP8o",
|
|
623
|
-
function
|
|
620
|
+
), cs = "z8iZiDFg3vkkrPwsiba1TLXy3H9XHzFERsP8o", ke = "page", fe = "trigger-reload-project-resource", Je = cs, ls = "z2qa7rr3eUyVnWp2PCxEVARuUfLFh6cE5V2xV", { uploadToMediaKit: ps } = require("@blocklet/uploader-server"), De = kt("abcdefghijklmnopqrstuvwxyz0123456789", 16), Se = /^\w+(\w|-|\.)+\w+\.(jpe?g|png|gif|svg|bmp|webp|mp4|m4v|webm)$/, z = /mediakit:\/\/([a-f0-9]{32}\.(jpe?g|png|gif|svg|bmp|webp|mp4|m4v|webm))/i, Ne = /mediakit:\/\/([a-f0-9]{32}\.(jpe?g|png|gif|svg|bmp|webp|mp4|m4v|webm))/gi, us = 1e4, ds = 3e4, q = 0, ue = 1, ms = 0, fs = 1, ge = S, Q = O(process.env.BLOCKLET_DATA_DIR, "site-state"), ao = ["production", "draft"], io = ["production"];
|
|
621
|
+
function He(t) {
|
|
624
622
|
return (t == null ? void 0 : t.replace(/\//g, "|")) || "";
|
|
625
623
|
}
|
|
626
624
|
function gs() {
|
|
@@ -653,7 +651,7 @@ const _ = class _ extends B.Doc {
|
|
|
653
651
|
}));
|
|
654
652
|
}
|
|
655
653
|
const a = C.createEncoder();
|
|
656
|
-
C.writeVarUint(a, ue), C.writeVarUint8Array(a,
|
|
654
|
+
C.writeVarUint(a, ue), C.writeVarUint8Array(a, Pe(this.awareness, l));
|
|
657
655
|
const i = C.toUint8Array(a);
|
|
658
656
|
this.conns.forEach((c, p) => this.send(p, i));
|
|
659
657
|
});
|
|
@@ -701,7 +699,7 @@ const _ = class _ extends B.Doc {
|
|
|
701
699
|
}
|
|
702
700
|
e.close();
|
|
703
701
|
});
|
|
704
|
-
P(this, "autoSave",
|
|
702
|
+
P(this, "autoSave", $e(() => {
|
|
705
703
|
F(L(this.draftYjsFilePath), { recursive: !0 }), te(this.draftYjsFilePath, B.encodeStateAsUpdate(this));
|
|
706
704
|
}, us));
|
|
707
705
|
P(this, "save", ({ flush: e = !1 } = {}) => {
|
|
@@ -709,7 +707,7 @@ const _ = class _ extends B.Doc {
|
|
|
709
707
|
});
|
|
710
708
|
P(this, "publish", async ({ mode: e, pages: s }) => {
|
|
711
709
|
const n = await this.getState("draft"), r = await this.getState("production");
|
|
712
|
-
await
|
|
710
|
+
await Ue(n, r, { pages: s, pageMergeMode: "replace", deletePages: !0, publishMode: e }), r.config.publishedAt = (/* @__PURE__ */ new Date()).getTime();
|
|
713
711
|
for (const l of s || Object.keys(this.syncedStore.pages))
|
|
714
712
|
this.syncedStore.pages[l] && (this.syncedStore.pages[l].publishedAt = (/* @__PURE__ */ new Date()).toISOString());
|
|
715
713
|
await this.setState(e, r);
|
|
@@ -722,7 +720,7 @@ const _ = class _ extends B.Doc {
|
|
|
722
720
|
e.config.fontFamily.title = (r == null ? void 0 : r.title) || (l == null ? void 0 : l.title), e.config.fontFamily.description = (r == null ? void 0 : r.description) || (l == null ? void 0 : l.description), await new Promise((p, u) => {
|
|
723
721
|
this.transact(async () => {
|
|
724
722
|
try {
|
|
725
|
-
const m = await
|
|
723
|
+
const m = await Ue(e, s);
|
|
726
724
|
p(m);
|
|
727
725
|
} catch (m) {
|
|
728
726
|
u(m);
|
|
@@ -758,7 +756,7 @@ const _ = class _ extends B.Doc {
|
|
|
758
756
|
const l = this.awareness.getStates();
|
|
759
757
|
if (l.size > 0) {
|
|
760
758
|
const a = C.createEncoder();
|
|
761
|
-
C.writeVarUint(a, ue), C.writeVarUint8Array(a,
|
|
759
|
+
C.writeVarUint(a, ue), C.writeVarUint8Array(a, Pe(this.awareness, Array.from(l.keys()))), this.send(e, C.toUint8Array(a));
|
|
762
760
|
}
|
|
763
761
|
}
|
|
764
762
|
});
|
|
@@ -774,14 +772,14 @@ const _ = class _ extends B.Doc {
|
|
|
774
772
|
break;
|
|
775
773
|
}
|
|
776
774
|
default:
|
|
777
|
-
|
|
775
|
+
A.warn(`Unsupported messageType ${l}`);
|
|
778
776
|
}
|
|
779
777
|
} catch (n) {
|
|
780
|
-
|
|
778
|
+
A.error(n);
|
|
781
779
|
}
|
|
782
780
|
this.save();
|
|
783
781
|
});
|
|
784
|
-
this.options = e, V(this.draftYjsFilePath) && B.applyUpdate(this, H(this.draftYjsFilePath)), this.syncedStore =
|
|
782
|
+
this.options = e, V(this.draftYjsFilePath) && B.applyUpdate(this, H(this.draftYjsFilePath)), this.syncedStore = vt(
|
|
785
783
|
Tt(
|
|
786
784
|
{ pages: {}, pageIds: [], components: {}, supportedLocales: [], config: {}, resources: {} },
|
|
787
785
|
this
|
|
@@ -794,9 +792,9 @@ const _ = class _ extends B.Doc {
|
|
|
794
792
|
throw new Error("Should provide project context");
|
|
795
793
|
try {
|
|
796
794
|
const s = O(Q, e), n = O(Q, `@del-${e}`);
|
|
797
|
-
|
|
795
|
+
ve(s, n);
|
|
798
796
|
} catch (s) {
|
|
799
|
-
|
|
797
|
+
A.error("Failed to safe delete project state dir:", s);
|
|
800
798
|
}
|
|
801
799
|
}
|
|
802
800
|
static get projectIds() {
|
|
@@ -847,14 +845,14 @@ const _ = class _ extends B.Doc {
|
|
|
847
845
|
var s, n, r, l;
|
|
848
846
|
if (e === "draft")
|
|
849
847
|
return JSON.parse(JSON.stringify(this.syncedStore));
|
|
850
|
-
if (!this.states[e] && (this.states[e] = await
|
|
848
|
+
if (!this.states[e] && (this.states[e] = await ze(this.getPublishDir(e), { includeResources: !0 }) ?? gs(), !((n = (s = this.states[e]) == null ? void 0 : s.config) != null && n.defaultLocale))) {
|
|
851
849
|
(r = this.states[e]).config ?? (r.config = {});
|
|
852
850
|
const a = ge.env.languages.map((i) => ({ locale: i.code, name: i.name }));
|
|
853
851
|
this.states[e].config.defaultLocale = (l = a[0]) == null ? void 0 : l.locale;
|
|
854
852
|
}
|
|
855
853
|
return {
|
|
856
854
|
...this.states[e],
|
|
857
|
-
resources: await
|
|
855
|
+
resources: await Xe().then(async (a) => {
|
|
858
856
|
var u, m, g, y;
|
|
859
857
|
const { pages: i, components: c } = Ct(a, "pages", "components");
|
|
860
858
|
let p = c;
|
|
@@ -863,11 +861,11 @@ const _ = class _ extends B.Doc {
|
|
|
863
861
|
...(y = (g = this.states[e]) == null ? void 0 : g.resources) == null ? void 0 : y.components
|
|
864
862
|
};
|
|
865
863
|
else {
|
|
866
|
-
const
|
|
864
|
+
const v = J(this.options.path), x = await $.findByPk(v);
|
|
867
865
|
if (x != null && x.useAllResources)
|
|
868
866
|
p = c;
|
|
869
867
|
else {
|
|
870
|
-
const D = (await ce.findAll({ where: { projectId:
|
|
868
|
+
const D = (await ce.findAll({ where: { projectId: v } })).map((E) => E.componentId);
|
|
871
869
|
p = Object.fromEntries(
|
|
872
870
|
Object.entries(c || {}).filter(([E]) => D.includes(E))
|
|
873
871
|
);
|
|
@@ -879,7 +877,7 @@ const _ = class _ extends B.Doc {
|
|
|
879
877
|
}
|
|
880
878
|
async setState(e, s) {
|
|
881
879
|
const n = await ws(s, { exportAssets: !1, includeResources: !0 }), r = this.getPublishDir(e);
|
|
882
|
-
F(L(r), { recursive: !0 }),
|
|
880
|
+
F(L(r), { recursive: !0 }), Fe(r, { force: !0, recursive: !0 }), ve(n, r), this.states[e] = s;
|
|
883
881
|
}
|
|
884
882
|
getPublishDir(e) {
|
|
885
883
|
return O(this.options.path, e);
|
|
@@ -919,8 +917,8 @@ const _ = class _ extends B.Doc {
|
|
|
919
917
|
mainPage: !0
|
|
920
918
|
};
|
|
921
919
|
for (const y of i) {
|
|
922
|
-
const
|
|
923
|
-
n[M("/", y, r, u)] =
|
|
920
|
+
const v = { ...g, locale: y };
|
|
921
|
+
n[M("/", y, r, u)] = v, m && (n[M("/", y, m, u)] = v);
|
|
924
922
|
}
|
|
925
923
|
}
|
|
926
924
|
}
|
|
@@ -937,7 +935,7 @@ P(_, "sharedInstances", new he({
|
|
|
937
935
|
}
|
|
938
936
|
}));
|
|
939
937
|
let oe = _;
|
|
940
|
-
function
|
|
938
|
+
function Ke() {
|
|
941
939
|
return bt(O(S.env.dataDir, "tmp-"));
|
|
942
940
|
}
|
|
943
941
|
function ne(t, o, e = []) {
|
|
@@ -957,7 +955,7 @@ async function hs(t, o, e) {
|
|
|
957
955
|
}
|
|
958
956
|
const ys = async (t, o) => {
|
|
959
957
|
const e = J(t), s = await yt({
|
|
960
|
-
name:
|
|
958
|
+
name: Je,
|
|
961
959
|
path: M("/uploads", e),
|
|
962
960
|
responseType: "stream",
|
|
963
961
|
method: "GET"
|
|
@@ -973,13 +971,13 @@ const ys = async (t, o) => {
|
|
|
973
971
|
try {
|
|
974
972
|
await ys(e, O(o, J(e)));
|
|
975
973
|
} catch (s) {
|
|
976
|
-
|
|
974
|
+
A.error(`Failed to export assets: ${e}, ${s}`);
|
|
977
975
|
}
|
|
978
976
|
})
|
|
979
977
|
);
|
|
980
978
|
};
|
|
981
|
-
function
|
|
982
|
-
return Se.test(t) ? [t] : z.test(t) ? (
|
|
979
|
+
function We(t) {
|
|
980
|
+
return Se.test(t) ? [t] : z.test(t) ? (Ne.lastIndex = 0, Array.from(t.matchAll(Ne)).map((e) => e[1]).filter((e) => !!e)) : [];
|
|
983
981
|
}
|
|
984
982
|
async function de(t, o, e) {
|
|
985
983
|
const { getFilename: s, exportAssets: n } = e, r = O(o, s(t));
|
|
@@ -989,16 +987,16 @@ async function de(t, o, e) {
|
|
|
989
987
|
(i) => typeof i == "string" && (Se.test(i) || z.test(i))
|
|
990
988
|
).map((i) => {
|
|
991
989
|
const c = ye(t, i);
|
|
992
|
-
return
|
|
990
|
+
return We(c);
|
|
993
991
|
}).flat().filter(Boolean);
|
|
994
992
|
await Ss(a, L(r));
|
|
995
993
|
}
|
|
996
994
|
}
|
|
997
|
-
const
|
|
995
|
+
const Le = new he({
|
|
998
996
|
max: 1e3,
|
|
999
997
|
ttl: 30 * 24 * 60 * 60 * 1e3
|
|
1000
998
|
});
|
|
1001
|
-
async function
|
|
999
|
+
async function Re(t, o, e) {
|
|
1002
1000
|
var a;
|
|
1003
1001
|
const s = ne(
|
|
1004
1002
|
t,
|
|
@@ -1006,18 +1004,18 @@ async function Ue(t, o, e) {
|
|
|
1006
1004
|
), n = Dt(2), r = s.map(
|
|
1007
1005
|
(i) => n(async () => {
|
|
1008
1006
|
try {
|
|
1009
|
-
const c = ye(t, i), p =
|
|
1007
|
+
const c = ye(t, i), p = We(c);
|
|
1010
1008
|
for (const u of p) {
|
|
1011
|
-
const m = J(u), g = e.getFilePath(u, i), y = g ? `${g}:${m}` : m,
|
|
1012
|
-
if (
|
|
1013
|
-
z.test(c) ||
|
|
1009
|
+
const m = J(u), g = e.getFilePath(u, i), y = g ? `${g}:${m}` : m, v = Le.get(y);
|
|
1010
|
+
if (v) {
|
|
1011
|
+
z.test(c) || Te(t, i, v);
|
|
1014
1012
|
return;
|
|
1015
1013
|
}
|
|
1016
1014
|
const x = await hs(g, m, o);
|
|
1017
|
-
x && (z.test(c) ||
|
|
1015
|
+
x && (z.test(c) || Te(t, i, x), Le.set(y, x));
|
|
1018
1016
|
}
|
|
1019
1017
|
} catch (c) {
|
|
1020
|
-
|
|
1018
|
+
A.error(`Failed to process upload for path ${i.join(".")}:`, c.message || c.reason);
|
|
1021
1019
|
}
|
|
1022
1020
|
})
|
|
1023
1021
|
), l = await Promise.allSettled(r);
|
|
@@ -1075,13 +1073,13 @@ async function ws(t, {
|
|
|
1075
1073
|
};
|
|
1076
1074
|
})
|
|
1077
1075
|
)
|
|
1078
|
-
), u =
|
|
1076
|
+
), u = Ke(), m = O(u, "pages");
|
|
1079
1077
|
F(m, { recursive: !0 });
|
|
1080
1078
|
const g = O(u, "components");
|
|
1081
1079
|
F(g, { recursive: !0 });
|
|
1082
1080
|
for (const { locale: f, slug: d, page: w } of p)
|
|
1083
1081
|
await de(w, m, {
|
|
1084
|
-
getFilename: () => `${
|
|
1082
|
+
getFilename: () => `${He(d) || "index"}.${f}.yml`,
|
|
1085
1083
|
exportAssets: o
|
|
1086
1084
|
});
|
|
1087
1085
|
for (const f of a) {
|
|
@@ -1093,7 +1091,7 @@ async function ws(t, {
|
|
|
1093
1091
|
}
|
|
1094
1092
|
const y = O(u, ".blocklet/pages/pages.config.yml");
|
|
1095
1093
|
F(L(y), { recursive: !0 });
|
|
1096
|
-
const
|
|
1094
|
+
const v = {
|
|
1097
1095
|
pages: R(
|
|
1098
1096
|
l.map((f) => {
|
|
1099
1097
|
const d = t.pages[f];
|
|
@@ -1126,7 +1124,7 @@ async function ws(t, {
|
|
|
1126
1124
|
supportedLocales: t.supportedLocales,
|
|
1127
1125
|
config: t.config
|
|
1128
1126
|
};
|
|
1129
|
-
te(y, K.stringify(
|
|
1127
|
+
te(y, K.stringify(v));
|
|
1130
1128
|
const x = O(u, "config.source.json");
|
|
1131
1129
|
if (n && te(x, JSON.stringify(n)), r) {
|
|
1132
1130
|
const f = O(u, "resources"), d = O(f, "components");
|
|
@@ -1141,13 +1139,13 @@ async function ws(t, {
|
|
|
1141
1139
|
}
|
|
1142
1140
|
return u;
|
|
1143
1141
|
}
|
|
1144
|
-
async function
|
|
1142
|
+
async function ze(t, { importAssets: o, includeResources: e } = {}) {
|
|
1145
1143
|
var r, l, a;
|
|
1146
1144
|
if (!V(t))
|
|
1147
1145
|
return null;
|
|
1148
1146
|
let s, n = !1;
|
|
1149
1147
|
try {
|
|
1150
|
-
Z(t).isDirectory() ? s = t : /\.(tgz|gz|tar)$/.test(t) && (n = !0, s =
|
|
1148
|
+
Z(t).isDirectory() ? s = t : /\.(tgz|gz|tar)$/.test(t) && (n = !0, s = Ke(), await Rt({ file: t, C: s }));
|
|
1151
1149
|
const i = me("**/.blocklet/pages/pages.config.yml", { cwd: s, absolute: !0 }).at(0), c = i && O(L(i), "../../pages"), p = i && O(L(i), "../../components"), u = i && O(L(i), "../../chunks");
|
|
1152
1150
|
if (!i)
|
|
1153
1151
|
return null;
|
|
@@ -1159,15 +1157,15 @@ async function Ye(t, { importAssets: o, includeResources: e } = {}) {
|
|
|
1159
1157
|
const b = me(`*.${E}.yml`, { cwd: h, absolute: !0 })[0];
|
|
1160
1158
|
return b ? K.parse(H(b).toString()) : null;
|
|
1161
1159
|
} catch (b) {
|
|
1162
|
-
|
|
1160
|
+
A.error("parse component error", b);
|
|
1163
1161
|
}
|
|
1164
1162
|
return null;
|
|
1165
|
-
},
|
|
1163
|
+
}, v = R(
|
|
1166
1164
|
m.pages.map(({ slug: h }) => {
|
|
1167
1165
|
var f;
|
|
1168
1166
|
const E = R(
|
|
1169
1167
|
m.supportedLocales.map(({ locale: d }) => {
|
|
1170
|
-
const w = c ? g(c,
|
|
1168
|
+
const w = c ? g(c, He(h), d) : void 0;
|
|
1171
1169
|
if (w)
|
|
1172
1170
|
return { locale: d, page: w };
|
|
1173
1171
|
const k = c ? g(c, h, d) : void 0;
|
|
@@ -1177,7 +1175,7 @@ async function Ye(t, { importAssets: o, includeResources: e } = {}) {
|
|
|
1177
1175
|
if (!b)
|
|
1178
1176
|
return null;
|
|
1179
1177
|
const I = b.sections.map((d) => {
|
|
1180
|
-
const w = d.id ||
|
|
1178
|
+
const w = d.id || De();
|
|
1181
1179
|
return {
|
|
1182
1180
|
id: w,
|
|
1183
1181
|
component: d.component,
|
|
@@ -1189,7 +1187,7 @@ async function Ye(t, { importAssets: o, includeResources: e } = {}) {
|
|
|
1189
1187
|
locales: Object.fromEntries(
|
|
1190
1188
|
R(
|
|
1191
1189
|
E.map(({ locale: k, page: N }) => {
|
|
1192
|
-
const Ie = N.sections.find((
|
|
1190
|
+
const Ie = N.sections.find((Ze) => Ze.id === w);
|
|
1193
1191
|
return Ie && [k, Ie.properties];
|
|
1194
1192
|
})
|
|
1195
1193
|
)
|
|
@@ -1197,7 +1195,7 @@ async function Ye(t, { importAssets: o, includeResources: e } = {}) {
|
|
|
1197
1195
|
};
|
|
1198
1196
|
});
|
|
1199
1197
|
return {
|
|
1200
|
-
id: b.id ||
|
|
1198
|
+
id: b.id || De(),
|
|
1201
1199
|
createdAt: b.createdAt,
|
|
1202
1200
|
updatedAt: b.updatedAt,
|
|
1203
1201
|
publishedAt: b.publishedAt,
|
|
@@ -1212,7 +1210,7 @@ async function Ye(t, { importAssets: o, includeResources: e } = {}) {
|
|
|
1212
1210
|
), x = p ? R(((r = m.components) == null ? void 0 : r.map(({ id: h }) => y(p, h))) ?? []) : [];
|
|
1213
1211
|
if (o) {
|
|
1214
1212
|
const h = (...E) => {
|
|
1215
|
-
|
|
1213
|
+
A.info(`[${n ? J(t) : J(O(t, "../../../../"))}] importAssets:`, ...E);
|
|
1216
1214
|
};
|
|
1217
1215
|
try {
|
|
1218
1216
|
h("wait image-bin api ready"), await Ut({
|
|
@@ -1221,15 +1219,15 @@ async function Ye(t, { importAssets: o, includeResources: e } = {}) {
|
|
|
1221
1219
|
}), h("image-bin api is ready");
|
|
1222
1220
|
const E = {}, b = {};
|
|
1223
1221
|
h("start to upload assets"), await Promise.allSettled([
|
|
1224
|
-
|
|
1222
|
+
Re(x, E, {
|
|
1225
1223
|
getFilePath: (I) => p && O(p, I),
|
|
1226
1224
|
onFinish: (I) => {
|
|
1227
1225
|
h(`upload ${I.length} component assets`);
|
|
1228
1226
|
}
|
|
1229
1227
|
}),
|
|
1230
|
-
|
|
1228
|
+
Re(v, b, {
|
|
1231
1229
|
getFilePath: (I, f) => {
|
|
1232
|
-
const d = ye(
|
|
1230
|
+
const d = ye(v, f.slice(0, 1));
|
|
1233
1231
|
return c && O(c, L(d.slug), I);
|
|
1234
1232
|
},
|
|
1235
1233
|
onFinish: (I) => {
|
|
@@ -1258,18 +1256,18 @@ async function Ye(t, { importAssets: o, includeResources: e } = {}) {
|
|
|
1258
1256
|
}
|
|
1259
1257
|
return {
|
|
1260
1258
|
supportedLocales: m.supportedLocales,
|
|
1261
|
-
pageIds:
|
|
1259
|
+
pageIds: v.map((h) => h.id),
|
|
1262
1260
|
components: Object.fromEntries(x.map((h, E) => [h.id, { index: E, data: h }])),
|
|
1263
|
-
pages: Object.fromEntries(
|
|
1261
|
+
pages: Object.fromEntries(v.map((h) => [h.id, h])),
|
|
1264
1262
|
config: m.config || {},
|
|
1265
1263
|
resources: U,
|
|
1266
1264
|
chunks: D
|
|
1267
1265
|
};
|
|
1268
1266
|
} finally {
|
|
1269
|
-
n && s &&
|
|
1267
|
+
n && s && Fe(s, { force: !0, recursive: !0 });
|
|
1270
1268
|
}
|
|
1271
1269
|
}
|
|
1272
|
-
async function
|
|
1270
|
+
async function Ue(t, o, {
|
|
1273
1271
|
pages: e,
|
|
1274
1272
|
pageMergeMode: s = "byUpdateTime",
|
|
1275
1273
|
deletePages: n = !1,
|
|
@@ -1278,7 +1276,7 @@ async function _e(t, o, {
|
|
|
1278
1276
|
try {
|
|
1279
1277
|
r && ts(r);
|
|
1280
1278
|
} catch (p) {
|
|
1281
|
-
|
|
1279
|
+
A.error("clear preload page cache error", { error: p });
|
|
1282
1280
|
}
|
|
1283
1281
|
const { pageIds: l, pages: a, supportedLocales: i } = t;
|
|
1284
1282
|
for (const p of e ?? l) {
|
|
@@ -1308,7 +1306,7 @@ async function _e(t, o, {
|
|
|
1308
1306
|
c = Object.fromEntries(
|
|
1309
1307
|
await Promise.all(
|
|
1310
1308
|
Object.entries(c).map(async ([p, u]) => {
|
|
1311
|
-
const m = await
|
|
1309
|
+
const m = await Ye(u == null ? void 0 : u.data);
|
|
1312
1310
|
return [
|
|
1313
1311
|
p,
|
|
1314
1312
|
{
|
|
@@ -1320,7 +1318,7 @@ async function _e(t, o, {
|
|
|
1320
1318
|
)
|
|
1321
1319
|
), Object.assign(o.components, c), Object.assign(o.config, JSON.parse(JSON.stringify(t.config))), o.resources.components = JSON.parse(JSON.stringify(t.resources.components || {}));
|
|
1322
1320
|
}
|
|
1323
|
-
const
|
|
1321
|
+
const Ye = ae(
|
|
1324
1322
|
async (t) => {
|
|
1325
1323
|
var o;
|
|
1326
1324
|
if (!Pt(t == null ? void 0 : t.properties))
|
|
@@ -1337,7 +1335,7 @@ const qe = ae(
|
|
|
1337
1335
|
});
|
|
1338
1336
|
}));
|
|
1339
1337
|
} catch (s) {
|
|
1340
|
-
|
|
1338
|
+
A.error("checkPropertiesFromCode error", { componentId: t.id, name: t.name }, { error: s });
|
|
1341
1339
|
}
|
|
1342
1340
|
}
|
|
1343
1341
|
return t;
|
|
@@ -1377,17 +1375,17 @@ function Es({
|
|
|
1377
1375
|
return [...n];
|
|
1378
1376
|
}
|
|
1379
1377
|
let re, G, we, Ee, be;
|
|
1380
|
-
function
|
|
1378
|
+
function qe() {
|
|
1381
1379
|
return re = (async () => {
|
|
1382
1380
|
const t = gt({
|
|
1383
1381
|
types: [
|
|
1384
|
-
{ did:
|
|
1385
|
-
{ did: ls, type:
|
|
1382
|
+
{ did: Je, type: ke },
|
|
1383
|
+
{ did: ls, type: ke }
|
|
1386
1384
|
]
|
|
1387
1385
|
});
|
|
1388
1386
|
G = (await Promise.all(
|
|
1389
1387
|
t.map(async (e) => {
|
|
1390
|
-
const s = e.path ? await
|
|
1388
|
+
const s = e.path ? await ze(e.path, { importAssets: !1 }) : void 0;
|
|
1391
1389
|
return s ? { blockletId: e.did, state: s, blockletTitle: e.title } : void 0;
|
|
1392
1390
|
})
|
|
1393
1391
|
)).filter((e) => !!e), we = G.reduce(
|
|
@@ -1411,7 +1409,7 @@ function Qe() {
|
|
|
1411
1409
|
Ee = Object.fromEntries(
|
|
1412
1410
|
await Promise.all(
|
|
1413
1411
|
Object.entries(o).map(async ([e, s]) => {
|
|
1414
|
-
const n = await
|
|
1412
|
+
const n = await Ye(s.component);
|
|
1415
1413
|
return [
|
|
1416
1414
|
e,
|
|
1417
1415
|
{
|
|
@@ -1425,10 +1423,10 @@ function Qe() {
|
|
|
1425
1423
|
})(), re;
|
|
1426
1424
|
}
|
|
1427
1425
|
function bs(t) {
|
|
1428
|
-
const o =
|
|
1426
|
+
const o = $e(
|
|
1429
1427
|
async () => {
|
|
1430
|
-
await
|
|
1431
|
-
|
|
1428
|
+
await qe().catch((e) => {
|
|
1429
|
+
A.error("load resource states error", { error: e });
|
|
1432
1430
|
}), await (t == null ? void 0 : t({
|
|
1433
1431
|
states: G,
|
|
1434
1432
|
pages: we,
|
|
@@ -1443,10 +1441,10 @@ function bs(t) {
|
|
|
1443
1441
|
S.events.off(S.Events.componentAdded, o), S.events.off(S.Events.componentRemoved, o), S.events.off(S.Events.componentStarted, o), S.events.off(S.Events.componentStopped, o), S.events.off(S.Events.componentUpdated, o), S.events.off(fe, o);
|
|
1444
1442
|
};
|
|
1445
1443
|
}
|
|
1446
|
-
const
|
|
1447
|
-
var
|
|
1448
|
-
(
|
|
1449
|
-
ee[
|
|
1444
|
+
const Qe = Symbol.for("GLOBAL_RESOURCE_STATES_LISTENER_KEY"), ee = globalThis;
|
|
1445
|
+
var _e;
|
|
1446
|
+
(_e = ee[Qe]) == null || _e.call(ee);
|
|
1447
|
+
ee[Qe] = bs(async ({ pages: t, components: o }) => {
|
|
1450
1448
|
const { projectIds: e } = oe;
|
|
1451
1449
|
await Promise.all(
|
|
1452
1450
|
e.map(async (s) => {
|
|
@@ -1461,7 +1459,7 @@ ee[Xe] = bs(async ({ pages: t, components: o }) => {
|
|
|
1461
1459
|
);
|
|
1462
1460
|
n.syncedStore.resources.components = i;
|
|
1463
1461
|
}
|
|
1464
|
-
|
|
1462
|
+
A.info(`update [${s}] resource states:`, {
|
|
1465
1463
|
pages: Object.keys(n.syncedStore.resources.pages || {}).length,
|
|
1466
1464
|
components: Object.keys(n.syncedStore.resources.components || {}).length
|
|
1467
1465
|
});
|
|
@@ -1469,20 +1467,20 @@ ee[Xe] = bs(async ({ pages: t, components: o }) => {
|
|
|
1469
1467
|
);
|
|
1470
1468
|
});
|
|
1471
1469
|
async function co() {
|
|
1472
|
-
|
|
1470
|
+
A.info("trigger reload all project resource"), S.events.emit(fe);
|
|
1473
1471
|
}
|
|
1474
|
-
async function
|
|
1472
|
+
async function Xe({
|
|
1475
1473
|
ensureLoaded: t = !0
|
|
1476
1474
|
} = {}) {
|
|
1477
|
-
return t && (re ?? (re =
|
|
1475
|
+
return t && (re ?? (re = qe()), await re), { states: G, pages: we, components: Ee, chunks: be };
|
|
1478
1476
|
}
|
|
1479
1477
|
export {
|
|
1480
|
-
|
|
1481
|
-
|
|
1478
|
+
Je as C,
|
|
1479
|
+
je as G,
|
|
1482
1480
|
$ as P,
|
|
1483
|
-
|
|
1481
|
+
ke as R,
|
|
1484
1482
|
oe as S,
|
|
1485
|
-
|
|
1483
|
+
Xe as a,
|
|
1486
1484
|
no as b,
|
|
1487
1485
|
Zt as c,
|
|
1488
1486
|
es as d,
|
|
@@ -1493,14 +1491,14 @@ export {
|
|
|
1493
1491
|
so as i,
|
|
1494
1492
|
se as j,
|
|
1495
1493
|
ro as k,
|
|
1496
|
-
|
|
1494
|
+
A as l,
|
|
1497
1495
|
is as m,
|
|
1498
|
-
|
|
1496
|
+
De as n,
|
|
1499
1497
|
Q as o,
|
|
1500
1498
|
ao as p,
|
|
1501
1499
|
io as q,
|
|
1502
|
-
|
|
1503
|
-
|
|
1500
|
+
ze as r,
|
|
1501
|
+
Ue as s,
|
|
1504
1502
|
ws as t,
|
|
1505
1503
|
bs as u,
|
|
1506
1504
|
co as v
|
package/lib/es/components.js
CHANGED
|
@@ -7,7 +7,7 @@ import "lru-cache";
|
|
|
7
7
|
import "node-fetch";
|
|
8
8
|
import "ufo";
|
|
9
9
|
import "crypto";
|
|
10
|
-
import { c as _, G as E, d as i, e as d, j as l, k as N, m as O, h as P, b as c, f as g } from "./_chunks/site-state-
|
|
10
|
+
import { c as _, G as E, d as i, e as d, j as l, k as N, m as O, h as P, b as c, f as g } from "./_chunks/site-state-Da4qgEoo.js";
|
|
11
11
|
export {
|
|
12
12
|
_ as CUSTOM_COMPONENT_CACHE_DURATION_IN_SECONDS,
|
|
13
13
|
E as GET_SERVER_SIDE_PROPS_TIMEOUT_IN_SECONDS,
|
package/lib/es/project-html.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { b as H, l as P } from "./_chunks/site-state-
|
|
1
|
+
import { b as H, l as P } from "./_chunks/site-state-Da4qgEoo.js";
|
|
2
2
|
import { initCronCrawlBlocklet as W, cancelCronCrawlBlocklet as N, initSEOMiddleware as J } from "@blocklet/crawler/middlewares";
|
|
3
3
|
import { PreloadComponentScriptModule as G } from "@blocklet/pages-kit/types";
|
|
4
4
|
import { injectPreloadComponents as K } from "@blocklet/pages-kit/utils/preload";
|
package/lib/es/resources.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { P as S, i as b, g as M, l as x, C as J, R as X, S as N, t as W, a as G } from "./_chunks/site-state-
|
|
1
|
+
import { P as S, i as b, g as M, l as x, C as J, R as X, S as N, t as W, a as G } from "./_chunks/site-state-Da4qgEoo.js";
|
|
2
2
|
import { AsyncLocalStorage as K } from "async_hooks";
|
|
3
3
|
import { Router as Y } from "express";
|
|
4
4
|
import d from "fs";
|
package/lib/es/site-state.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { q as x, o as D, p as H, S as M, r as O, a as j, u as q, s as v, n as B, t as L, v as U } from "./_chunks/site-state-
|
|
1
|
+
import { q as x, o as D, p as H, S as M, r as O, a as j, u as q, s as v, n as B, t as L, v as U } from "./_chunks/site-state-Da4qgEoo.js";
|
|
2
2
|
import "@blocklet/quickjs";
|
|
3
3
|
import "@blocklet/sdk/lib/component";
|
|
4
4
|
import "@blocklet/sdk/lib/config";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@blocklet/pages-kit-inner-components",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.40",
|
|
4
4
|
"description": "Pages Kit inner components library",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -202,8 +202,8 @@
|
|
|
202
202
|
"yaml": "^2.5.0",
|
|
203
203
|
"yjs": "^13.6.18",
|
|
204
204
|
"zustand": "^4.5.5",
|
|
205
|
-
"@blocklet/pages-kit": "^0.4.
|
|
206
|
-
"@blocklet/pages-kit-block-studio": "^0.4.
|
|
205
|
+
"@blocklet/pages-kit": "^0.4.40",
|
|
206
|
+
"@blocklet/pages-kit-block-studio": "^0.4.40"
|
|
207
207
|
},
|
|
208
208
|
"devDependencies": {
|
|
209
209
|
"@trivago/prettier-plugin-sort-imports": "^5.2.1",
|