@blocklet/pages-kit-inner-components 0.4.83 → 0.4.84

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.
@@ -1,4 +1,5 @@
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-AYUSPJ7w.js";
1
+ import { q as D, o as H, p as M, S as O, r as j, a as q, u as v, s as B, n as L, t as U, v as b } from "./chunks/site-state-D5tVTSMt.js";
2
+ import "@blocklet/pages-kit/utils/property";
2
3
  import "@blocklet/quickjs";
3
4
  import "@blocklet/sdk/lib/component";
4
5
  import "@blocklet/sdk/lib/config";
@@ -22,16 +23,17 @@ import "y-protocols/awareness";
22
23
  import "y-protocols/sync";
23
24
  import "yaml";
24
25
  import "yjs";
26
+ export * from "@blocklet/pages-kit/types/state";
25
27
  export {
26
- x as PUBLISH_MODES,
27
- D as SITE_STATE_PATH,
28
- H as STATE_MODES,
29
- M as default,
30
- O as fromPackage,
31
- j as getResourceStates,
32
- q as initPackResourceStates,
33
- v as mergeState,
34
- B as nextId,
35
- L as toPackage,
36
- U as triggerReloadAllProjectResource
28
+ D as PUBLISH_MODES,
29
+ H as SITE_STATE_PATH,
30
+ M as STATE_MODES,
31
+ O as default,
32
+ j as fromPackage,
33
+ q as getResourceStates,
34
+ v as initPackResourceStates,
35
+ B as mergeState,
36
+ L as nextId,
37
+ U as toPackage,
38
+ b as triggerReloadAllProjectResource
37
39
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blocklet/pages-kit-inner-components",
3
- "version": "0.4.83",
3
+ "version": "0.4.84",
4
4
  "description": "Pages Kit inner components library",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -67,13 +67,13 @@
67
67
  "dependencies": {
68
68
  "@arcblock/did-auth": "^1.19.15",
69
69
  "@arcblock/did-auth-storage-nedb": "^1.7.1",
70
- "@arcblock/did-connect": "^2.12.43",
71
- "@arcblock/react-hooks": "^2.12.43",
72
- "@arcblock/ux": "^2.12.43",
70
+ "@arcblock/did-connect": "^2.12.44",
71
+ "@arcblock/react-hooks": "^2.12.44",
72
+ "@arcblock/ux": "^2.12.44",
73
73
  "@blocklet/ai-kit": "^0.1.72",
74
74
  "@blocklet/ai-runtime": "^0.4.254",
75
75
  "@blocklet/code-editor": "^0.4.254",
76
- "@blocklet/crawler": "^2.1.238",
76
+ "@blocklet/crawler": "^2.1.241",
77
77
  "@blocklet/embed": "^0.2.3",
78
78
  "@blocklet/js-sdk": "^1.16.40",
79
79
  "@blocklet/logger": "1.16.36",
@@ -81,9 +81,9 @@
81
81
  "@blocklet/sdk": "^1.16.40",
82
82
  "@blocklet/studio-ui": "^0.4.254",
83
83
  "@blocklet/tracker": "^1.16.40",
84
- "@blocklet/ui-react": "^2.12.43",
85
- "@blocklet/uploader": "^0.1.79",
86
- "@blocklet/uploader-server": "^0.1.90",
84
+ "@blocklet/ui-react": "^2.12.44",
85
+ "@blocklet/uploader": "^0.1.81",
86
+ "@blocklet/uploader-server": "^0.1.92",
87
87
  "@emotion/cache": "^11.13.1",
88
88
  "@emotion/css": "^11.13.0",
89
89
  "@emotion/react": "^11.13.0",
@@ -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.83",
206
- "@blocklet/pages-kit-block-studio": "^0.4.83"
205
+ "@blocklet/pages-kit": "^0.4.84",
206
+ "@blocklet/pages-kit-block-studio": "^0.4.84"
207
207
  },
208
208
  "devDependencies": {
209
209
  "@trivago/prettier-plugin-sort-imports": "^5.2.1",
@@ -1,57 +0,0 @@
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"),H=require("@blocklet/quickjs"),ot=require("@blocklet/sdk/lib/config"),Ee=require("lru-cache"),Le=require("node-fetch"),x=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"),P=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),It=L(Le),Ot=L(rt),Ct=L(it),Pt=X(ct),jt=L(lt),At=L(pt),D=L(ut),pe=X(ft),v=X(mt),vt=L(ht),_t=L(h),Dt=L(wt),J=X(Et),B=X(bt),xt=L(Tt);w.default.env.mode;const kt="image-bin";w.default.env.INIT_TEMPLATE_PATH;const Rt=process.env.DATABASE_URL||_t.default.join(w.default.env.dataDir,"db/pages-kit.db"),_e=w.default,Nt=()=>w.default.env.tenantMode==="multiple",Lt=()=>{var t;return(xt.default(_e.env.preferences.multiTenantAllProjectAccessPassports)?[]:(t=_e.env.preferences.multiTenantAllProjectAccessPassports)==null?void 0:t.split(","))||[]},I=Ot.default("pages-kit"),Ut=P.DataTypes.sqlite.DATE.parse;P.DataTypes.sqlite.DATE.parse=(t,n)=>typeof t=="number"?new Date(t):Ut(t,n);const Z=new P.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 P.Model{}ce.init({id:{type:P.DataTypes.UUID,allowNull:!1,primaryKey:!0,defaultValue:P.DataTypes.UUIDV4},projectId:{type:P.DataTypes.UUID,allowNull:!1},componentId:{type:P.DataTypes.STRING,allowNull:!1}},{sequelize:Z,tableName:"ProjectComponents",timestamps:!1});class $ extends P.Model{static async getProjectByIdOrSlug(n){return $.findOne({where:{[P.Op.or]:[{id:n},{slug:n}]}})}}$.init({id:{type:P.DataTypes.UUID,defaultValue:P.DataTypes.UUIDV4,primaryKey:!0},name:{type:P.DataTypes.STRING,allowNull:!1},description:P.DataTypes.TEXT,createdAt:P.DataTypes.DATE,updatedAt:P.DataTypes.DATE,createdBy:{type:P.DataTypes.STRING,allowNull:!1},updatedBy:{type:P.DataTypes.STRING,allowNull:!1},slug:P.DataTypes.STRING,icon:P.DataTypes.STRING,pinnedAt:P.DataTypes.DATE,useAllResources:P.DataTypes.BOOLEAN,npmSecret:P.DataTypes.STRING,relatedBlocklets:{type:P.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
- @tailwind utilities;
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
-
5
- ${t}
6
- `},De=H.memoize(async(t,n)=>{let e=D.default.transpileModule(t,{compilerOptions:{jsx:D.default.JsxEmit.React,target:D.default.ScriptTarget.ES2016,module:D.default.ModuleKind.ESNext},transformers:{before:[Ue.createBuiltinModuleTransformer(D.default)]}}).outputText;if(n.tailwind&&(e=await Ft(e,{componentId:n.componentId})),n.module===se.PreloadComponentScriptModule.ESM)return e;const s=D.default.transpileModule(e,{compilerOptions:{jsx:D.default.JsxEmit.React,target:D.default.ScriptTarget.ES2016,module:D.default.ModuleKind.CommonJS,moduleResolution:D.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 Pt.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 m=p.path.split("/").pop();if(c||(c=await Ae({ensureLoaded:!1})),(u=c==null?void 0:c.chunks)!=null&&u[m])try{const g=E.readFileSync(c.chunks[m],"utf-8");return I.info("get chunk from local file system",m),{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 D.default.transpileModule(o,{compilerOptions:{module:D.default.ModuleKind.ESNext,target:D.default.ScriptTarget.ES2020}}).outputText},Me=H.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
- var ${t} = ${e?"async":""} function () {
8
-
9
- const exports = {};
10
- let moduleExports = null;
11
-
12
- // add commonjs module compatibility layer
13
- const module = { exports: moduleExports };
14
-
15
- // execute component code
16
- ${n}
17
-
18
- // handle possible module.exports
19
- if (module.exports && module.exports !== moduleExports) {
20
- // if module.exports is used, use it first
21
- return typeof module.exports === 'object' ? module.exports : { default: module.exports };
22
- }
23
-
24
- // ensure a default export
25
- if (!('default' in exports) && Object.keys(exports).length === 0) {
26
- // module has no exports, return null to indicate invalid
27
- return null;
28
- }
29
-
30
- return exports;
31
- };
32
- `},K=new Ee.LRUCache({max:100}),Fe=60*60,me=60;function qe(t){I.info("clear preload components cache",{cacheKey:t}),K.delete(t)}function $e(t){for(const n of K.keys())n.includes(t)&&(I.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&&K.has(S))return I.info(`get preload component from cache: ${S}`),K.get(S);const j=Q({state:e,componentId:g.componentId});if(!j)return null;const _=await He({req:n,state:e,componentId:j.id,locale:s,defaultLocale:a,properties:g.properties});if(!_)return null;const F={instanceId:g.id,preload:_};if(t!=="draft"&&g.useCache){let R=Fe;g.cacheDuration&&(R=g.cacheDuration),I.info(`set preload component to cache(${R}s): ${S}`),K.set(S,F,{ttl:R*1e3})}return F}catch(S){return I.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}),_=r===se.PreloadComponentScriptModule.ESM?{module:r,script:await De(S.script,{componentId:S.component.id,module:r,tailwind:t!=="draft"})}:{module:r,script:await De(S.script,{componentId:S.component.id,module:r,moduleName:j,tailwind:t!=="draft"}),moduleName:j};return[S.component.id,{component:S.component,script:_}]}));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 He({req:t,state:n,componentId:e,locale:s,defaultLocale:o,properties:r}){const{supportedLocales:l}=n,a=Q({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 Ve({req:t,state:n,componentId:e,locale:i,defaultLocale:o,properties:r});return c?{component:a,...c}:null}const Ht=20;async function Ve({req:t,depth:n=0,state:e,componentId:s,locale:o,defaultLocale:r,properties:l}){if(n>Ht)throw new RangeError("max component depth exceeded");const a=Vt({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 zt({...a,req:t});p!=null&&p.props&&Object.assign(c.props,p.props)}catch(p){I.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 m=await Ve({req:t,depth:n+1,state:e,componentId:u.componentId,locale:o,defaultLocale:r,properties:u.properties});m&&(Object.assign(c.components,m.components),Object.assign(c.props,{[p]:{type:oe.RenderNestedComponent,componentId:u.componentId,props:m.props}}))}})),c}function Vt({state:t,componentId:n,locale:e,properties:s}){const o=Q({state:t,componentId:n});if(!o)return null;const r=oe.mergeComponent({componentId:n,getComponent:l=>Q({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 Q({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 zt({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=>{setTimeout(()=>{I.error("getServerSideProps timeout"),a({})},me*1e3)});return await Promise.race([r,H.Sandbox.callFunction({code:`${o}
33
-
34
- export async function getServerSidePropsWrapper(props) {
35
- const { location, fetch, props: componentProps } = props;
36
- // 使用局部变量而不是全局变量
37
- const originalLocation = typeof window !== 'undefined' ? window.location : undefined;
38
- const originalFetch = globalThis.fetch;
39
-
40
- try {
41
- globalThis.location = location;
42
- globalThis.fetch = fetch;
43
- return await getServerSideProps(componentProps);
44
- } finally {
45
- // 清理全局状态
46
- if (originalLocation) globalThis.location = originalLocation;
47
- if (originalFetch) globalThis.fetch = originalFetch;
48
- }
49
- }`,filename:`${t.name||t.id}.js`,moduleLoader:a=>{if(a==="@blocklet/pages-kit/builtin/utils")return`const { joinURL, withQuery, getQuery, getComponentMountPoint } = globalThis
50
- export { joinURL, withQuery, getQuery, getComponentMountPoint }
51
- `;if(a==="@blocklet/pages-kit/builtin/dayjs")return H.BuiltinModules.dayjs},global:{console:{log:(...a)=>{I.info(...a)},warn:(...a)=>{I.warn(...a)},error:(...a)=>{I.error(...a)}},getComponentMountPoint:nt.getComponentMountPoint,joinURL:x.joinURL,withQuery:x.withQuery,getQuery:x.getQuery},functionName:"getServerSidePropsWrapper",args:[{location:{href:x.joinURL(x.withHttps(s.hostname),s.originalUrl)},fetch:(a,{...i}={})=>{const c=typeof a=="string"&&a.startsWith("/")?x.joinURL(w.default.env.appUrl,a):a;if(typeof c=="string"&&x.parseURL(c).host===x.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 It.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=H.memoize(async(t,n,e)=>{if(!(t!=null&&t.includes(n)))return null;const s=await Me(t,n);if(s)try{return await H.Sandbox.callFunction({code:`
52
- ${s}
53
-
54
- export function get${n}SchemaWrapper() {
55
- return ${n};
56
- }
57
- `,filename:`${e}.js`,functionName:`get${n}SchemaWrapper`})}catch(o){return I.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}}),Jt="z8iZiDFg3vkkrPwsiba1TLXy3H9XHzFERsP8o",ge="page",he="trigger-reload-project-resource",Te=Jt,Kt="z2qa7BQdkEb3TwYyEYC1psK6uvmGnHSUHt5RM",{uploadToMediaKit:Yt}=require("@blocklet/uploader-server"),ye=gt.customAlphabet("abcdefghijklmnopqrstuvwxyz0123456789",16),Ie=/^\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,xe=/mediakit:\/\/([a-f0-9]{32}\.(jpe?g|png|gif|svg|bmp|webp|mp4|m4v|webm))/gi,Qt=1e4,Wt=3e4,te=0,ue=1,Xt=0,Zt=1,Se=w.default,z=h.join(process.env.BLOCKLET_DATA_DIR,"site-state"),es=["production","draft"],ts=["production"];function ze(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 B.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=v.createEncoder();v.writeVarUint(a,ue),v.writeVarUint8Array(a,G.encodeAwarenessUpdate(this.awareness,l));const i=v.toUint8Array(a);this.conns.forEach((c,p)=>this.send(p,i))});A(this,"updateHandler",e=>{const s=v.createEncoder();v.writeVarUint(s,te),le.writeUpdate(s,e);const o=v.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,B.encodeStateAsUpdate(this))},Qt));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 m=await we(e,s);p(m)}catch(m){u(m)}})})});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)}}},Wt);e.on("close",()=>{this.closeConn(e),clearInterval(o)}),e.on("pong",()=>{s=!0});{const r=v.createEncoder();v.writeVarUint(r,te),le.writeSyncStep1(r,this),this.send(e,v.toUint8Array(r));const l=this.awareness.getStates();if(l.size>0){const a=v.createEncoder();v.writeVarUint(a,ue),v.writeVarUint8Array(a,G.encodeAwarenessUpdate(this.awareness,Array.from(l.keys()))),this.send(e,v.toUint8Array(a))}}});A(this,"messageListener",(e,s)=>{try{const o=v.createEncoder(),r=pe.createDecoder(s),l=pe.readVarUint(r);switch(l){case te:v.writeVarUint(o,te),le.readSyncMessage(r,o,this,null),v.length(o)>1&&(this.ensureDataStructure(),this.send(e,v.toUint8Array(o)));break;case ue:{G.applyAwarenessUpdate(this.awareness,pe.readVarUint8Array(r),e);break}default:I.warn(`Unsupported messageType ${l}`)}}catch(o){I.error(o)}this.save()});this.options=e,E.existsSync(this.draftYjsFilePath)&&B.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(z,e),o=h.join(z,`@del-${e}`);E.renameSync(s,o)}catch(s){I.error("Failed to safe delete project state dir:",s)}}static get projectIds(){return fe.globSync("*/",{cwd:z,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(z,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 B.Map&&e(r)});const s=ee.getYjsValue(this.syncedStore.pages);s&&s instanceof B.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 B.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 Oe(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,m,g,S;const{pages:i,components:c}=N.pick(a,"pages","components");let p=c;if((m=(u=this.states[e])==null?void 0:u.resources)!=null&&m.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),_=await $.findByPk(j);if(_!=null&&_.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,m=l.slug||r,g={projectId:r,projectSlug:m,pageSlug:u,pageId:c,defaultLocale:i==null?void 0:i[0],locales:i,publishedAt:a.config.publishedAt,isPublic:p.isPublic,isTemplate:p.isTemplate};m&&(o[x.joinURL("/",m,u)]={...g,shouldRedirect:!0,mainPage:!0}),o[x.joinURL("/",r,u)]={...g,shouldRedirect:!0,mainPage:!0};for(const S of i){const j={...g,locale:S};o[x.joinURL("/",S,r,u)]=j,m&&(o[x.joinURL("/",S,m,u)]=j)}}}return o}getDocumentSize(){return B.encodeStateAsUpdate(this).byteLength}static getInstancesSizeInfo(){const e=[];for(const[s,o]of this.sharedInstances.entries()){const r=o.getDocumentSize();e.push({projectId:s,sizeInBytes:r,sizeInMB:`${(r/(1024*1024)).toFixed(2)} MB`,activeConnections:o.conns.size})}return e}};A(q,"INSTANCE_TTL",30*60*1e3),A(q,"sharedInstances",new Ee.LRUCache({max:100,ttl:q.INSTANCE_TTL,dispose:e=>{e.destroy()}}));let W=q;function Je(){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()=>{var o;try{const r=(o=await Yt({filePath:t,fileName:n}))==null?void 0:o.data;return r==null?void 0:r.filename}catch(r){return I.error(`Failed to upload asset ${t}:`,r),null}})(),e[t]=s),s}const os=async(t,n)=>{const e=h.basename(t),s=await be.call({name:Te,path:x.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){I.error(`Failed to export assets: ${e}, ${s}`)}}))};function Ke(t){return Ie.test(t)?[t]:Y.test(t)?(xe.lastIndex=0,Array.from(t.matchAll(xe)).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,J.stringify(t)),o){const a=re(t,i=>typeof i=="string"&&(Ie.test(i)||Y.test(i))).map(i=>{const c=N.get(t,i);return Ke(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"&&(Ie.test(i)||Y.test(i))),o=vt.default(2),r=s.map(i=>o(async()=>{try{const c=N.get(t,i),p=Ke(c);for(const u of p){const m=h.basename(u),g=e.getFilePath(u,i),S=g?`${g}:${m}`:m,j=ke.get(S);if(j){Y.test(c)||N.set(t,i,j);return}const _=await ns(g,m,n);_&&(Y.test(c)||N.set(t,i,_),ke.set(S,_))}}catch(c){I.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,C;const l=e==="all"?t.pageIds:e,a=as({state:t,pageIds:l,componentIds:s==="all"?Object.keys(t.components):s}),i=(f,d)=>{var b;return{id:f.id,name:f.name,isTemplateSection:f.isTemplateSection??!1,templateDescription:f.templateDescription,llmConfig:f.llmConfig,component:f.component,config:f.config,visibility:f.visibility,properties:((b=f.locales)==null?void 0:b[d])??{}}},c=(f,d)=>{var b;return{id:f.id,createdAt:f.createdAt,updatedAt:f.updatedAt,publishedAt:f.publishedAt,isPublic:f.isPublic??!0,isTemplate:f.isTemplate??!1,meta:((b=f.locales)==null?void 0:b[d])??{},sections:M(f.sectionIds.map(k=>{const U=f.sections[k];return U&&i(U,d)}))}},p=M(t.supportedLocales.map(f=>f.locale).flatMap(f=>l.map(d=>{const b=t.pages[d];return b&&{locale:f,slug:b.slug,page:c(b,f)}}))),u=Je(),m=h.join(u,"pages");E.mkdirSync(m,{recursive:!0});const g=h.join(u,"components");E.mkdirSync(g,{recursive:!0});for(const{locale:f,slug:d,page:b}of p)await de(b,m,{getFilename:()=>`${ze(d)||"index"}.${f}.yml`,exportAssets:n});for(const f of a){const d=(F=t.components[f])==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(f=>{const d=t.pages[f];return d&&{id:f,slug:d.slug}})),components:M(a.map(f=>{var b;const d=(b=t.components[f])==null?void 0:b.data;return d&&{id:f,name:d.name}})),...r?{resources:{components:M(Object.keys(((R=t.resources)==null?void 0:R.components)||{}).map(f=>{var d,b,k,U;return{id:f,name:(U=(k=(b=(d=t.resources)==null?void 0:d.components)==null?void 0:b[f])==null?void 0:k.component)==null?void 0:U.name}}))}}:{},supportedLocales:t.supportedLocales,config:t.config};E.writeFileSync(S,J.stringify(j));const _=h.join(u,"config.source.json");if(o&&E.writeFileSync(_,JSON.stringify(o)),r){const f=h.join(u,"resources"),d=h.join(f,"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=(C=(O=(T=t.resources)==null?void 0:T.components)==null?void 0:O[b])==null?void 0:C.component;k&&await de(k,d,{getFilename:U=>`${U.name||"unnamed"}.${U.id}.yml`,exportAssets:n})}}return u}async function Oe(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=Je(),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 m=J.parse(E.readFileSync(i).toString()),g=(y,T,O)=>{let C=h.join(y,`${T}${O?`.${O}`:""}.yml`);return(!E.existsSync(C)||!E.lstatSync(C).isFile())&&(C=h.join(y,T,`index${O?`.${O}`:""}.yml`),!E.existsSync(C)||!E.lstatSync(C))?null:J.parse(E.readFileSync(C).toString())},S=(y,T)=>{try{const O=fe.globSync(`*.${T}.yml`,{cwd:y,absolute:!0})[0];return O?J.parse(E.readFileSync(O).toString()):null}catch(O){I.error("parse component error",O)}return null},j=M(m.pages.map(({slug:y})=>{var f;const T=M(m.supportedLocales.map(({locale:d})=>{const b=c?g(c,ze(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=(f=T[0])==null?void 0:f.page;if(!O)return null;const C=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,llmConfig:d.llmConfig,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||ye(),createdAt:O.createdAt,updatedAt:O.updatedAt,publishedAt:O.publishedAt,isPublic:O.isPublic??!0,isTemplate:O.isTemplate??!1,slug:y,sections:Object.fromEntries(C.map(d=>[d.id,d])),sectionIds:C.map(d=>d.id),locales:Object.fromEntries(T.map(({locale:d,page:b})=>[d,b.meta]))}})),_=p?M(((r=m.components)==null?void 0:r.map(({id:y})=>S(p,y)))??[]):[];if(n){const y=(...T)=>{I.info(`[${o?h.basename(t):h.basename(h.join(t,"../../../../"))}] importAssets:`,...T)};try{y("wait image-bin api ready"),await Dt.default({resources:[`${be.getComponentWebEndpoint(kt)}/api/sdk/uploads`],validateStatus:C=>C>=200&&C<=500}),y("image-bin api is ready");const T={},O={};y("start to upload assets"),await Promise.allSettled([Re(_,T,{getFilePath:C=>p&&h.join(p,C),onFinish:C=>{y(`upload ${C.length} component assets`)}}),Re(j,O,{getFilePath:(C,f)=>{const d=N.get(j,f.slice(0,1));return c&&h.join(c,h.dirname(d.slug),C)},onFinish:C=>{y(`upload ${C.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=m.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,C)=>[O.id,{index:C,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:m.supportedLocales,pageIds:j.map(y=>y.id),components:Object.fromEntries(_.map((y,T)=>[y.id,{index:T,data:y}])),pages:Object.fromEntries(j.map(y=>[y.id,y])),config:m.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){I.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 m=n.pageIds.indexOf(p);m!==-1&&o&&(n.pageIds.splice(m,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 m=n.pages[u.id];(!m||u.updatedAt&&u.updatedAt>m.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 m=await Qe(u==null?void 0:u.data);return[p,{...u,data:m}]}))),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 Qe=H.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){I.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,V,Ce,Pe,je;function We(){return ae=(async()=>{const t=be.getResources({types:[{did:Te,type:ge},{did:Kt,type:ge}]});V=(await Promise.all(t.map(async e=>{const s=e.path?await Oe(e.path,{importAssets:!1}):void 0;return s?{blockletId:e.did,state:s,blockletTitle:e.title}:void 0}))).filter(e=>!!e),Ce=V.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=V.reduce((e,s)=>Object.assign(e,Object.fromEntries(Object.values(s.state.components).map(o=>[o.data.id,{blockletId:s.blockletId,component:o.data}]))),{});Pe=Object.fromEntries(await Promise.all(Object.entries(n).map(async([e,s])=>{const o=await Qe(s.component);return[e,{...s,component:o}]}))),je=V.reduce((e,s)=>Object.assign(e,s.state.chunks),{})})(),ae}function Xe(t){const n=N.debounce(async()=>{await We().catch(e=>{I.error("load resource states error",{error:e})}),await(t==null?void 0:t({states:V,pages:Ce,components:Pe,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}=W;I.info(`start update resource states projects(${e.length})`,e),await Promise.race([new Promise(s=>{setTimeout(()=>{I.error("update resource states timeout"),s({})},30*1e3)}),Promise.all(e.map(async s=>{const o=W.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}I.info(`update [${s}] resource states:`,{pages:Object.keys(o.syncedStore.resources.pages||{}).length,components:Object.keys(o.syncedStore.resources.components||{}).length})}))]).catch(s=>{I.error("update resource states failed:",s)})});async function is(){I.info("trigger reload all project resource"),w.default.events.emit(he)}async function Ae({ensureLoaded:t=!0}={}){return t&&(ae??(ae=We()),await ae),{states:V,pages:Ce,components:Pe,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=z;exports.STATE_MODES=es;exports.SiteState=W;exports.clearPreloadComponentsCache=qe;exports.clearPreloadComponentsCacheByMode=$e;exports.fromPackage=Oe;exports.getComponentFromState=Q;exports.getComponentFromStateByName=Gt;exports.getExportSchemaValueFromCode=Ge;exports.getMultiTenantAllProjectAccessPassports=Lt;exports.getPreloadComponent=He;exports.getPreloadComponents=Bt;exports.getPreloadComponentsCacheKey=Be;exports.getResourceStates=Ae;exports.initPackResourceStates=Xe;exports.isMultiTenant=Nt;exports.logger=I;exports.mergeState=we;exports.nextId=ye;exports.toPackage=Ye;exports.triggerReloadAllProjectResource=is;
File without changes
File without changes
File without changes
File without changes