@blocklet/pages-kit-inner-components 0.0.7 → 0.0.8
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/home.js +1 -1
- package/lib/cjs/locales.js +1 -0
- package/lib/cjs/resources.js +1 -1
- package/lib/cjs/setting.js +31 -0
- package/lib/cjs/site-state.js +1 -1
- package/lib/{draft-data-B1uf57Cy.mjs → draft-data-Bs6uEYy4.mjs} +3 -3
- package/lib/draft-data-DJNZo1YQ.js +1 -0
- package/lib/es/home.js +6 -5
- package/lib/es/locales.js +701 -0
- package/lib/es/resources.js +1 -1
- package/lib/es/setting.js +1329 -0
- package/lib/es/site-state.js +1 -1
- package/lib/home-Cn3Pji4Z.mjs +2280 -0
- package/lib/home-DHx60V0N.js +542 -0
- package/lib/publish-button-B_ySfzVo.js +1 -0
- package/lib/{publish-button-CP42jrDJ.mjs → publish-button-C-CnCCa5.mjs} +85 -83
- package/lib/{site-state-BmPKdiAM.mjs → site-state-CUnFMunr.mjs} +264 -254
- package/lib/site-state-DR63hFZ4.js +1 -0
- package/lib/state-C6rI6VKx.mjs +376 -0
- package/lib/state-CfaAw7fr.js +1 -0
- package/package.json +59 -38
- package/lib/draft-data-Wp7NHQJ8.js +0 -1
- package/lib/home-DZ1HSzX6.js +0 -542
- package/lib/home-NljemGBa.mjs +0 -2619
- package/lib/publish-button-h0M1NWWo.js +0 -1
- package/lib/site-state-CD1Wvsfh.js +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const P=require("./components-DITf866E.js"),ke=require("@blocklet/quickjs"),le=require("@blocklet/sdk/lib/component"),Re=require("@blocklet/sdk/lib/config"),Ce=require("@reactivedata/reactive"),H=require("@syncedstore/core"),y=require("fs"),re=require("glob"),Le=require("lib0/decoding"),Ue=require("lib0/encoding"),_=require("lodash"),Ee=require("lru-cache"),Ne=require("nanoid"),Fe=require("p-limit"),d=require("path"),qe=require("stream/promises"),Me=require("tar"),x=require("ufo"),xe=require("wait-on"),M=require("y-protocols/awareness"),te=require("y-protocols/sync"),Be=require("yaml"),Ve=require("yjs"),$e=require("lodash/isNil"),A=require("sequelize");require("sqlite3");const Y=t=>t&&t.__esModule?t:{default:t};function Z(t){if(t&&t.__esModule)return t;const s=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const e in t)if(e!=="default"){const n=Object.getOwnPropertyDescriptor(t,e);Object.defineProperty(s,e,n.get?n:{enumerable:!0,get:()=>t[e]})}}return s.default=t,Object.freeze(s)}const m=Y(Re),se=Z(Le),v=Z(Ue),Ge=Y(Fe),Je=Y(d),Ye=Y(xe),V=Z(Be),q=Z(Ve),ze=Y($e);m.default.env.mode;const He="image-bin";m.default.env.INIT_TEMPLATE_PATH;const Ke=process.env.DATABASE_URL||Je.default.join(m.default.env.dataDir,"db/pages-kit.db"),me=m.default,We=()=>m.default.env.tenantMode==="multiple",Xe=()=>{var t;return(ze.default(me.env.preferences.multiTenantAllProjectAccessPassports)?[]:(t=me.env.preferences.multiTenantAllProjectAccessPassports)==null?void 0:t.split(","))||[]},Qe=A.DataTypes.sqlite.DATE.parse;A.DataTypes.sqlite.DATE.parse=(t,s)=>typeof t=="number"?new Date(t):Qe(t,s);const z=new A.Sequelize({dialect:"sqlite",storage:Ke,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 ee extends A.Model{}ee.init({id:{type:A.DataTypes.UUID,allowNull:!1,primaryKey:!0,defaultValue:A.DataTypes.UUIDV4},projectId:{type:A.DataTypes.UUID,allowNull:!1},componentId:{type:A.DataTypes.STRING,allowNull:!1}},{sequelize:z,tableName:"ProjectComponents",timestamps:!1});class N extends A.Model{static async getProjectByIdOrSlug(s){return N.findOne({where:{[A.Op.or]:[{id:s},{slug:s}]}})}}N.init({id:{type:A.DataTypes.UUID,defaultValue:A.DataTypes.UUIDV4,primaryKey:!0},name:{type:A.DataTypes.STRING,allowNull:!1},description:A.DataTypes.TEXT,createdAt:A.DataTypes.DATE,updatedAt:A.DataTypes.DATE,createdBy:{type:A.DataTypes.STRING,allowNull:!1},updatedBy:{type:A.DataTypes.STRING,allowNull:!1},slug:A.DataTypes.STRING,icon:A.DataTypes.STRING,pinnedAt:A.DataTypes.DATE,useAllResources:A.DataTypes.BOOLEAN,relatedBlocklets:{type:A.DataTypes.JSON,allowNull:!1,defaultValue:{},get(){return this.getDataValue("relatedBlocklets")||{}},set(t){this.setDataValue("relatedBlocklets",JSON.stringify(t||{}))}}},{sequelize:z,paranoid:!0});N.hasMany(ee,{foreignKey:"projectId",as:"components"});const Ze="z8iZiDFg3vkkrPwsiba1TLXy3H9XHzFERsP8o",be="page",oe="trigger-reload-project-resource",pe=Ze,{uploadToMediaKit:et}=require("@blocklet/uploader-server"),ie=Ne.customAlphabet("abcdefghijklmnopqrstuvwxyz0123456789",16),ue=/^\w+(\w|-|\.)+\w+\.(jpe?g|png|gif|svg|bmp|webp|mp4|m4v|webm)$/,$=/mediakit:\/\/([a-f0-9]{32}\.(jpe?g|png|gif|svg|bmp|webp|mp4|m4v|webm))/i,ye=/mediakit:\/\/([a-f0-9]{32}\.(jpe?g|png|gif|svg|bmp|webp|mp4|m4v|webm))/gi,tt=1e4,st=3e4,K=0,ne=1,nt=0,at=1,rt=m.default,B=d.join(process.env.BLOCKLET_DATA_DIR,"site-state"),ot=["production","draft"],it=["production"];function Ae(t){return(t==null?void 0:t.replace(/\//g,"|"))||""}function ct(){return{pageIds:[],pages:{},components:{},supportedLocales:[],config:{},resources:{}}}const U=class U extends q.Doc{constructor(s){super(),this.options=s,this.states={},this.conns=new Map,this.awarenessChangeHandler=({added:e,updated:n,removed:a},r)=>{const l=e.concat(n,a);if(r!==null){const c=this.conns.get(r);c&&(e.forEach(f=>{c.add(f)}),a.forEach(f=>{c.delete(f)}))}const i=v.createEncoder();v.writeVarUint(i,ne),v.writeVarUint8Array(i,M.encodeAwarenessUpdate(this.awareness,l));const o=v.toUint8Array(i);this.conns.forEach((c,f)=>this.send(f,o))},this.updateHandler=e=>{const n=v.createEncoder();v.writeVarUint(n,K),te.writeUpdate(n,e);const a=v.toUint8Array(n);this.conns.forEach((r,l)=>this.send(l,a))},this.ensureDataStructure=()=>{var l;const{supportedLocales:e,pages:n,pageIds:a,config:r}=this.syncedStore;{const i=new Set(Object.keys(n));let o=0;for(;o<a.length;){const c=a[o];i.has(c)?(i.delete(c),o++):a.splice(o,1)}}e.splice(0,e.length),e.push(...rt.env.languages.map(i=>({locale:i.code,name:i.name}))),r.defaultLocale=(l=e[0])==null?void 0:l.locale;{let i=0;const o=new Set;for(;i<e.length;){const{locale:c}=e[i];o.has(c)?e.splice(i,1):(i++,o.add(c))}}},this.send=(e,n)=>{e.readyState!==nt&&e.readyState!==at&&this.closeConn(e);try{e.send(n,a=>{a&&this.closeConn(e)})}catch{this.closeConn(e)}},this.closeConn=e=>{if(e.removeAllListeners(),this.conns.has(e)){const n=this.conns.get(e);this.conns.delete(e),n&&M.removeAwarenessStates(this.awareness,Array.from(n),null)}e.close()},this.autoSave=_.debounce(()=>{y.mkdirSync(d.dirname(this.draftYjsFilePath),{recursive:!0}),y.writeFileSync(this.draftYjsFilePath,q.encodeStateAsUpdate(this))},tt),this.save=({flush:e=!1}={})=>{this.autoSave(),e&&this.autoSave.flush()},this.publish=async({mode:e,pages:n})=>{const a=await this.getState("draft"),r=await this.getState("production");await ce(a,r,{pages:n,pageMergeMode:"replace",deletePages:!0,publishMode:e}),r.config.publishedAt=new Date().getTime();for(const l of n||Object.keys(this.syncedStore.pages))this.syncedStore.pages[l]&&(this.syncedStore.pages[l].publishedAt=new Date().toISOString());await this.setState(e,r)},this.mergeState=async(e,n)=>{var i,o,c;const a=JSON.parse(JSON.stringify(n));(i=e.config).fontFamily??(i.fontFamily={});const r=(o=a.config)==null?void 0:o.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((f,p)=>{this.transact(async()=>{try{const w=await ce(e,n);f(w)}catch(w){p(w)}})})},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 n=!0;const a=setInterval(()=>{if(!n)this.conns.has(e)&&this.closeConn(e),clearInterval(a);else if(this.conns.has(e)){n=!1;try{e.ping()}catch{this.closeConn(e),clearInterval(a)}}},st);e.on("close",()=>{this.closeConn(e),clearInterval(a)}),e.on("pong",()=>{n=!0});{const r=v.createEncoder();v.writeVarUint(r,K),te.writeSyncStep1(r,this),this.send(e,v.toUint8Array(r));const l=this.awareness.getStates();if(l.size>0){const i=v.createEncoder();v.writeVarUint(i,ne),v.writeVarUint8Array(i,M.encodeAwarenessUpdate(this.awareness,Array.from(l.keys()))),this.send(e,v.toUint8Array(i))}}},this.messageListener=(e,n)=>{try{const a=v.createEncoder(),r=se.createDecoder(n),l=se.readVarUint(r);switch(l){case K:v.writeVarUint(a,K),te.readSyncMessage(r,a,this,null),v.length(a)>1&&(this.ensureDataStructure(),this.send(e,v.toUint8Array(a)));break;case ne:{M.applyAwarenessUpdate(this.awareness,se.readVarUint8Array(r),e);break}default:P.logger.warn(`Unsupported messageType ${l}`)}}catch(a){P.logger.error(a)}this.save()},y.existsSync(this.draftYjsFilePath)&&q.applyUpdate(this,y.readFileSync(this.draftYjsFilePath)),this.syncedStore=Ce.reactive(H.syncedStore({pages:{},pageIds:[],components:{},supportedLocales:[],config:{},resources:{}},this)),this.initObserver(),this.on("update",this.updateHandler),this.awareness=new M.Awareness(this),this.awareness.on("update",this.awarenessChangeHandler),this.ensureDataStructure()}static safeDeleteProjectStateDir(s){if(!s)throw new Error("Should provide project context");try{const e=d.join(B,s),n=d.join(B,`@del-${s}`);y.renameSync(e,n)}catch(e){P.logger.error("Failed to safe delete project state dir:",e)}}static get projectIds(){return re.globSync("*/",{cwd:B,ignore:["@del-*","@tmp-*",".*","staging","production","@backup-*"]})}static get allShared(){return this.projectIds.map(s=>U.shared(s))}static shared(s){if(!s)throw new Error("Should provide project context");let e=this.sharedInstances.get(s);return e||(e=new U({path:d.join(B,s)}),this.sharedInstances.set(s,e),e)}destroy(){this.conns.forEach((s,e)=>this.closeConn(e)),this.awareness.destroy(),super.destroy()}initObserver(){const s=n=>{n.observeDeep(a=>{a.some(r=>r.changes.keys.has("updatedAt")||r.changes.keys.has("publishedAt"))||n.set("updatedAt",new Date().toISOString())})};this.syncedStore.pages&&Object.keys(this.syncedStore.pages).forEach(n=>{const a=H.getYjsValue(this.syncedStore.pages[n]);a&&a instanceof q.Map&&s(a)});const e=H.getYjsValue(this.syncedStore.pages);e&&e instanceof q.Map&&e.observe(n=>{n.changes.keys.forEach((a,r)=>{if(a.action==="add"){const l=H.getYjsValue(this.syncedStore.pages[r]);l&&l instanceof q.Map&&s(l)}})})}get draftYjsFilePath(){return d.join(this.options.path,"draft.yjs")}async getState(s){return s==="draft"?JSON.parse(JSON.stringify(this.syncedStore)):(this.states[s]||(this.states[s]=await de(this.getPublishDir(s),{includeResources:!0})??ct()),{...this.states[s],resources:await _e().then(async e=>{var l,i,o,c;const{pages:n,components:a}=_.pick(e,"pages","components");let r=a;if((i=(l=this.states[s])==null?void 0:l.resources)!=null&&i.components)r={...(c=(o=this.states[s])==null?void 0:o.resources)==null?void 0:c.components};else{const f=d.basename(this.options.path),p=await N.findByPk(f);if(p!=null&&p.useAllResources)r=a;else{const I=(await ee.findAll({where:{projectId:f}})).map(D=>D.componentId);r=Object.fromEntries(Object.entries(a||{}).filter(([D])=>I.includes(D)))}}return{pages:n,components:r}}).catch(()=>({}))})}async setState(s,e){const n=await ve(e,{exportAssets:!1,includeResources:!0}),a=this.getPublishDir(s);y.mkdirSync(d.dirname(a),{recursive:!0}),y.rmSync(a,{force:!0,recursive:!0}),y.renameSync(n,a),this.states[s]=e}getPublishDir(s){return d.join(this.options.path,s)}static async pageUrlMap(s){const{projectIds:e}=this,n={};for(const a of e){const r=await N.findByPk(a);if(!r)continue;const l=await U.shared(a).getState(s),i=_.union(m.default.env.languages.map(o=>o.code),l.supportedLocales.map(o=>o.locale));for(const o of l.pageIds){const c=l.pages[o];if(!c||s==="production"&&!c.isPublic)continue;const f=c.slug,p=r.slug||a,w={projectId:a,projectSlug:p,pageSlug:f,pageId:o,defaultLocale:i==null?void 0:i[0],locales:i,publishedAt:l.config.publishedAt,isPublic:c.isPublic};p&&(n[x.joinURL("/",p,f)]={...w,shouldRedirect:!0,mainPage:!0}),n[x.joinURL("/",a,f)]={...w,shouldRedirect:!0,mainPage:!0};for(const I of i){const O={...w,locale:I};n[x.joinURL("/",I,a,f)]=O,p&&(n[x.joinURL("/",I,p,f)]=O)}}}return n}};U.INSTANCE_TTL=30*60*1e3,U.sharedInstances=new Ee.LRUCache({max:100,ttl:U.INSTANCE_TTL,dispose:s=>{s.destroy()}});let J=U;function Te(){return y.mkdtempSync(d.join(m.default.env.dataDir,"tmp-"))}function X(t,s,e=[]){return Array.isArray(t)?t.flatMap((n,a)=>X(n,s,[...e,a])):typeof t=="object"?t===null?[]:Object.entries(t).flatMap(([n,a])=>X(a,s,[...e,n])):s(t)?[e]:[]}function C(t){return t.filter(s=>s!=null)}async function lt(t,s,e){if(!t||!y.existsSync(t)||!y.lstatSync(t).isFile())return null;let n=e[t];return n||(n=(async()=>(await et({filePath:t,fileName:s})).data.filename)(),e[t]=n),n}const pt=async(t,s)=>{const e=d.basename(t),n=await le.call({name:pe,path:x.joinURL("/uploads",e),responseType:"stream",method:"GET"});if(n.status>=200&&n.status<400){const a=y.createWriteStream(s);await qe.pipeline(n.data,a)}else throw new Error(`download asset failed ${n.status}`)},ut=async(t,s)=>{await Promise.all(t.map(async e=>{try{await pt(e,d.join(s,d.basename(e)))}catch(n){P.logger.error(`Failed to export assets: ${e}, ${n}`)}}))};function je(t){return ue.test(t)?[t]:$.test(t)?(ye.lastIndex=0,Array.from(t.matchAll(ye)).map(e=>e[1]).filter(e=>!!e)):[]}async function ae(t,s,e){const{getFilename:n,exportAssets:a}=e,r=d.join(s,n(t));if(y.mkdirSync(d.dirname(r),{recursive:!0}),y.writeFileSync(r,V.stringify(t)),a){const i=X(t,o=>typeof o=="string"&&(ue.test(o)||$.test(o))).map(o=>{const c=_.get(t,o);return je(c)}).flat().filter(Boolean);await ut(i,d.dirname(r))}}const he=new Ee.LRUCache({max:1e3,ttl:30*24*60*60*1e3});async function Se(t,s,e){var i;const n=X(t,o=>typeof o=="string"&&(ue.test(o)||$.test(o))),a=Ge.default(2),r=n.map(o=>a(async()=>{try{const c=_.get(t,o),f=je(c);for(const p of f){const w=d.basename(p),I=e.getFilePath(p,o),O=I?`${I}:${w}`:w,D=he.get(O);if(D){$.test(c)||_.set(t,o,D);return}const L=await lt(I,w,s);L&&($.test(c)||_.set(t,o,L),he.set(O,L))}}catch(c){P.logger.error(`Failed to process upload for path ${o.join(".")}:`,c.message||c.reason)}})),l=await Promise.allSettled(r);(i=e.onFinish)==null||i.call(e,l)}async function ve(t,{exportAssets:s,pageIds:e="all",componentIds:n="all",rawConfig:a,includeResources:r=!1}={}){var g,T,S,E,F,j;const l=e==="all"?t.pageIds:e,i=dt({state:t,pageIds:l,componentIds:n==="all"?Object.keys(t.components):n}),o=(u,h)=>{var b;return{id:u.id,name:u.name,component:u.component,config:u.config,visibility:u.visibility,properties:((b=u.locales)==null?void 0:b[h])??{}}},c=(u,h)=>{var b;return{id:u.id,createdAt:u.createdAt,updatedAt:u.updatedAt,publishedAt:u.publishedAt,isPublic:u.isPublic??!0,meta:((b=u.locales)==null?void 0:b[h])??{},sections:C(u.sectionIds.map(k=>{const R=u.sections[k];return R&&o(R,h)}))}},f=C(t.supportedLocales.map(u=>u.locale).flatMap(u=>l.map(h=>{const b=t.pages[h];return b&&{locale:u,slug:b.slug,page:c(b,u)}}))),p=Te(),w=d.join(p,"pages");y.mkdirSync(w,{recursive:!0});const I=d.join(p,"components");y.mkdirSync(I,{recursive:!0});for(const{locale:u,slug:h,page:b}of f)await ae(b,w,{getFilename:()=>`${Ae(h)||"index"}.${u}.yml`,exportAssets:s});for(const u of i){const h=(g=t.components[u])==null?void 0:g.data;h&&await ae(h,I,{getFilename:b=>`${b.name||"unnamed"}.${b.id}.yml`,exportAssets:s})}const O=d.join(p,".blocklet/pages/pages.config.yml");y.mkdirSync(d.dirname(O),{recursive:!0});const D={pages:C(l.map(u=>{const h=t.pages[u];return h&&{id:u,slug:h.slug}})),components:C(i.map(u=>{var b;const h=(b=t.components[u])==null?void 0:b.data;return h&&{id:u,name:h.name}})),...r?{resources:{components:C(Object.keys(((T=t.resources)==null?void 0:T.components)||{}).map(u=>{var h,b,k,R;return{id:u,name:(R=(k=(b=(h=t.resources)==null?void 0:h.components)==null?void 0:b[u])==null?void 0:k.component)==null?void 0:R.name}}))}}:{},supportedLocales:t.supportedLocales,config:t.config};y.writeFileSync(O,V.stringify(D));const L=d.join(p,"config.source.json");if(a&&y.writeFileSync(L,JSON.stringify(a)),r){const u=d.join(p,"resources"),h=d.join(u,"components");y.mkdirSync(h,{recursive:!0});for(const b of Object.keys(((S=t==null?void 0:t.resources)==null?void 0:S.components)??{})){const k=(j=(F=(E=t.resources)==null?void 0:E.components)==null?void 0:F[b])==null?void 0:j.component;k&&await ae(k,h,{getFilename:R=>`${R.name||"unnamed"}.${R.id}.yml`,exportAssets:s})}}return p}async function de(t,{importAssets:s,includeResources:e}={}){var r,l,i;if(!y.existsSync(t))return null;let n,a=!1;try{y.lstatSync(t).isDirectory()?n=t:/\.(tgz|gz|tar)$/.test(t)&&(a=!0,n=Te(),await Me.x({file:t,C:n}));const o=re.globSync("**/.blocklet/pages/pages.config.yml",{cwd:n,absolute:!0}).at(0),c=o&&d.join(d.dirname(o),"../../pages"),f=o&&d.join(d.dirname(o),"../../components");if(!o)return null;const p=V.parse(y.readFileSync(o).toString()),w=(g,T,S)=>{let E=d.join(g,`${T}${S?`.${S}`:""}.yml`);return(!y.existsSync(E)||!y.lstatSync(E).isFile())&&(E=d.join(g,T,`index${S?`.${S}`:""}.yml`),!y.existsSync(E)||!y.lstatSync(E))?null:V.parse(y.readFileSync(E).toString())},I=(g,T)=>{try{const S=re.globSync(`*.${T}.yml`,{cwd:g,absolute:!0})[0];return S?V.parse(y.readFileSync(S).toString()):null}catch(S){P.logger.error("parse component error",S)}return null},O=C(p.pages.map(({slug:g})=>{var F;const T=C(p.supportedLocales.map(({locale:j})=>{const u=c?w(c,Ae(g),j):void 0;if(u)return{locale:j,page:u};const h=c?w(c,g,j):void 0;return h&&{locale:j,page:h}})),S=(F=T[0])==null?void 0:F.page;if(!S)return null;const E=S.sections.map(j=>{const u=j.id||ie();return{id:u,component:j.component,config:j.config,name:j.name,visibility:j.visibility,locales:Object.fromEntries(C(T.map(({locale:h,page:b})=>{const k=b.sections.find(R=>R.id===u);return k&&[h,k.properties]})))}});return{id:S.id||ie(),createdAt:S.createdAt,updatedAt:S.updatedAt,publishedAt:S.publishedAt,isPublic:S.isPublic??!0,slug:g,sections:Object.fromEntries(E.map(j=>[j.id,j])),sectionIds:E.map(j=>j.id),locales:Object.fromEntries(T.map(({locale:j,page:u})=>[j,u.meta]))}})),D=f?C(((r=p.components)==null?void 0:r.map(({id:g})=>I(f,g)))??[]):[];if(s){const g=(...T)=>{P.logger.info(`[${a?d.basename(t):d.basename(d.join(t,"../../../../"))}] importAssets:`,...T)};try{g("wait image-bin api ready"),await Ye.default({resources:[`${le.getComponentWebEndpoint(He)}/api/sdk/uploads`],validateStatus:E=>E>=200&&E<=500}),g("image-bin api is ready");const T={},S={};g("start to upload assets"),await Promise.allSettled([Se(D,T,{getFilePath:E=>f&&d.join(f,E),onFinish:E=>{g(`upload ${E.length} component assets`)}}),Se(O,S,{getFilePath:(E,F)=>{const j=_.get(O,F.slice(0,1));return c&&d.join(c,d.dirname(j.slug),E)},onFinish:E=>{g(`upload ${E.length} page assets`)}})]),g("upload assets done"),global.gc&&global.gc()}catch(T){g("Error during asset import:",T)}}const L={};if(e){const g=o&&d.join(d.dirname(o),"../../resources/components"),T=C(((i=(l=p.resources)==null?void 0:l.components)==null?void 0:i.map(({id:S})=>I(g,S)))??[]);T.length>0&&(L.components=Object.fromEntries(T.map((S,E)=>[S.id,{index:E,component:S}])))}return{supportedLocales:p.supportedLocales,pageIds:O.map(g=>g.id),components:Object.fromEntries(D.map((g,T)=>[g.id,{index:T,data:g}])),pages:Object.fromEntries(O.map(g=>[g.id,g])),config:p.config||{},resources:L}}finally{a&&n&&y.rmSync(n,{force:!0,recursive:!0})}}async function ce(t,s,{pages:e,pageMergeMode:n="byUpdateTime",deletePages:a=!1,publishMode:r=void 0}={}){try{r&&P.clearPreloadComponentsCacheByMode(r)}catch(f){P.logger.error("clear preload page cache error",{error:f})}const{pageIds:l,pages:i,supportedLocales:o}=t;for(const f of e??l){const p=i[f];if(!p){const w=s.pageIds.indexOf(f);w!==-1&&a&&(s.pageIds.splice(w,1),delete s.pages[f]);continue}if(s.pageIds.includes(p.id)){if(n==="replace")s.pages[p.id]=p;else if(n==="byUpdateTime"){const w=s.pages[p.id];(!w||p.updatedAt&&p.updatedAt>w.updatedAt)&&(s.pages[p.id]=p)}}else s.pageIds.push(p.id),s.pages[p.id]=p}if(a&&!e)for(const f of s.pageIds)t.pageIds.includes(f)||delete s.pages[f],s.pageIds=[...s.pageIds].filter(p=>t.pageIds.includes(p));if(s.supportedLocales.splice(0,s.supportedLocales.length),s.supportedLocales.push(..._.cloneDeep(o)),a)for(const f of Object.keys(s.components))delete s.components[f];let c=JSON.parse(JSON.stringify(t.components));c=Object.fromEntries(await Promise.all(Object.entries(c).map(async([f,p])=>{const w=await Ie(p==null?void 0:p.data);return[f,{...p,data:w}]}))),Object.assign(s.components,c),Object.assign(s.config,JSON.parse(JSON.stringify(t.config))),s.resources.components=JSON.parse(JSON.stringify(t.resources.components||{}))}const Ie=ke.memoize(async t=>{var s;if(!_.isEmpty(t==null?void 0:t.properties))return t;if(((s=t==null?void 0:t.renderer)==null?void 0:s.type)==="react-component"){const{script:e}=(t==null?void 0:t.renderer)||{};if(e)try{const n=await P.getExportSchemaValueFromCode(e,"PROPERTIES_SCHEMA",t.id);n&&n.length>0&&t&&(t.properties={},n.forEach((a,r)=>{t!=null&&t.properties&&(t.properties[a.id]={index:r,data:a})}))}catch(n){P.logger.error("checkPropertiesFromCode error",{componentId:t.id,name:t.name},{error:n})}}return t},{keyGenerator:t=>JSON.stringify(["checkPropertiesFromCode",t])});function dt({state:t,pageIds:s=[],componentIds:e=[]}){var l;const n=(i,o=new Set)=>(Array.isArray(i)&&i.forEach(c=>n(c,o)),i&&typeof i=="object"&&(typeof i.componentId=="string"&&o.add(i.componentId),Object.values(i).forEach(c=>n(c,o))),o),a=new Set(e);for(const i of s){const o=t.pages[i];n(o,a)}const r=[...a];for(;r.length;){const i=r.shift();a.has(i)||a.add(i);const o=(l=t.components[i])==null?void 0:l.data;if(o)for(const c of n(o))a.has(c)||r.push(c)}return[...a]}let Q,G,fe,ge;function Oe(){return Q=(async()=>{const t=le.getResources({types:[{did:pe,type:be}]});G=(await Promise.all(t.map(async e=>{const n=e.path?await de(e.path,{importAssets:!1}):void 0;return n?{blockletId:e.did,state:n,blockletTitle:e.title}:void 0}))).filter(e=>!!e),fe=G.reduce((e,n)=>Object.assign(e,Object.fromEntries(Object.values(n.state.pages).map(a=>a?[a==null?void 0:a.id,{page:a,blockletId:n.blockletId}]:[]))),{});const s=G.reduce((e,n)=>Object.assign(e,Object.fromEntries(Object.values(n.state.components).map(a=>[a.data.id,{blockletId:n.blockletId,component:a.data}]))),{});ge=Object.fromEntries(await Promise.all(Object.entries(s).map(async([e,n])=>{const a=await Ie(n.component);return[e,{...n,component:a}]})))})(),Q}function Pe(t){const s=_.debounce(async()=>{await Oe().catch(e=>{P.logger.error("load resource states error",{error:e})}),await(t==null?void 0:t({states:G,pages:fe,components:ge}))},3e3,{leading:!1,trailing:!0});return s(),m.default.events.on(m.default.Events.componentAdded,s),m.default.events.on(m.default.Events.componentRemoved,s),m.default.events.on(m.default.Events.componentStarted,s),m.default.events.on(m.default.Events.componentStopped,s),m.default.events.on(m.default.Events.componentUpdated,s),m.default.events.on(oe,s),()=>{m.default.events.off(m.default.Events.componentAdded,s),m.default.events.off(m.default.Events.componentRemoved,s),m.default.events.off(m.default.Events.componentStarted,s),m.default.events.off(m.default.Events.componentStopped,s),m.default.events.off(m.default.Events.componentUpdated,s),m.default.events.off(oe,s)}}const De=Symbol.for("GLOBAL_RESOURCE_STATES_LISTENER_KEY"),W=globalThis;var we;(we=W[De])==null||we.call(W);W[De]=Pe(async({pages:t,components:s})=>{const{projectIds:e}=J;await Promise.all(e.map(async n=>{const a=J.shared(n);a.syncedStore.resources.pages=t;const r=await N.findByPk(n);if(r!=null&&r.useAllResources)a.syncedStore.resources.components=s;else{const i=(await ee.findAll({where:{projectId:n}})).map(c=>c.componentId),o=Object.fromEntries(Object.entries(s||{}).filter(([c])=>i.includes(c)));a.syncedStore.resources.components=o}P.logger.info(`update [${n}] resource states:`,{pages:Object.keys(a.syncedStore.resources.pages||{}).length,components:Object.keys(a.syncedStore.resources.components||{}).length})}))});async function ft(){P.logger.info("trigger reload all project resource"),m.default.events.emit(oe)}async function _e(){return Q??(Q=Oe()),await Q,{states:G,pages:fe,components:ge}}exports.COMPONENT_DID=pe;exports.PUBLISH_MODES=it;exports.Project=N;exports.RESOURCE_TYPE=be;exports.SITE_STATE_PATH=B;exports.STATE_MODES=ot;exports.SiteState=J;exports.fromPackage=de;exports.getMultiTenantAllProjectAccessPassports=Xe;exports.getResourceStates=_e;exports.initPackResourceStates=Pe;exports.isMultiTenant=We;exports.mergeState=ce;exports.nextId=ie;exports.toPackage=ve;exports.triggerReloadAllProjectResource=ft;
|
|
@@ -0,0 +1,376 @@
|
|
|
1
|
+
import { jsx as k } from "react/jsx-runtime";
|
|
2
|
+
import { Box as x, Alert as G, Tooltip as V } from "@mui/material";
|
|
3
|
+
import q from "gradient-parser";
|
|
4
|
+
import K from "tinycolor2";
|
|
5
|
+
import { joinURL as j, withQuery as Q } from "ufo";
|
|
6
|
+
import { createAxios as X } from "@blocklet/js-sdk";
|
|
7
|
+
import Z, { getYjsDoc as J } from "@syncedstore/core";
|
|
8
|
+
import { useSyncedStore as Y } from "@syncedstore/react";
|
|
9
|
+
import { useLocalStorageState as H } from "ahooks";
|
|
10
|
+
import { produce as T } from "immer";
|
|
11
|
+
import tt from "js-cookie";
|
|
12
|
+
import et from "lodash/debounce";
|
|
13
|
+
import { customAlphabet as ot } from "nanoid";
|
|
14
|
+
import { createContext as nt, useState as y, useRef as rt, useMemo as g, useCallback as U, useEffect as C, useContext as st } from "react";
|
|
15
|
+
import { useNavigate as it, useParams as ct } from "react-router-dom";
|
|
16
|
+
import { IndexeddbPersistence as at } from "y-indexeddb";
|
|
17
|
+
import { WebsocketProvider as dt } from "y-websocket";
|
|
18
|
+
import { UndoManager as ut } from "yjs";
|
|
19
|
+
function lt() {
|
|
20
|
+
const { pathname: t } = window.location, o = t.match(/\/admin\/(maker|previewer)\/([^/]+)/), u = o == null ? void 0 : o[2], c = window.__PROJECT_ID__;
|
|
21
|
+
if (!u && !c)
|
|
22
|
+
throw new Error("Unable to get projectId from pathname");
|
|
23
|
+
return u || c;
|
|
24
|
+
}
|
|
25
|
+
function Bt(t) {
|
|
26
|
+
return `${t}:pages:version`;
|
|
27
|
+
}
|
|
28
|
+
function Gt({ error: t }) {
|
|
29
|
+
return /* @__PURE__ */ k(x, { children: /* @__PURE__ */ k(G, { severity: "error", children: t.message }) });
|
|
30
|
+
}
|
|
31
|
+
var M;
|
|
32
|
+
const b = ((M = window.blocklet) == null ? void 0 : M.prefix) || "/", F = X({
|
|
33
|
+
timeout: 200 * 1e3
|
|
34
|
+
}), ft = window.location.protocol === "https:" ? "wss" : "ws", Vt = (t) => j(`${ft}://${window.location.hostname}`, b, `api/${t}/ws/pages`), mt = "z8ia1mAXo8ZE7ytGF36L5uBf9kD2kenhqFGp9";
|
|
35
|
+
var W;
|
|
36
|
+
(W = blocklet == null ? void 0 : blocklet.componentMountPoints.find((t) => t.did === mt)) != null && W.mountPoint || j(b, "/image-bin");
|
|
37
|
+
function qt(t) {
|
|
38
|
+
return t && !/^(https?:\/\/|\/)/.test(t) ? window.location.origin + j(b, "uploads", t) : t;
|
|
39
|
+
}
|
|
40
|
+
const pt = window.innerWidth <= 750;
|
|
41
|
+
function Kt(t, o, u) {
|
|
42
|
+
if (!t || /\.gif/.test(t)) return t;
|
|
43
|
+
const c = (pt ? o / 1.5 : o) * (u === "quality" ? 1.5 : 1);
|
|
44
|
+
return wt(t, { imageFilter: "resize", w: c, f: "webp" });
|
|
45
|
+
}
|
|
46
|
+
function wt(t, o) {
|
|
47
|
+
return !t || !o ? t : Q(t, o);
|
|
48
|
+
}
|
|
49
|
+
function ht(t) {
|
|
50
|
+
if (t != null && t.trim())
|
|
51
|
+
try {
|
|
52
|
+
return q.parse(t), !0;
|
|
53
|
+
} catch {
|
|
54
|
+
return !1;
|
|
55
|
+
}
|
|
56
|
+
return !1;
|
|
57
|
+
}
|
|
58
|
+
function Qt(t) {
|
|
59
|
+
return typeof t != "string" ? !1 : !!(ht(t) || K(t).isValid());
|
|
60
|
+
}
|
|
61
|
+
async function St(t) {
|
|
62
|
+
return F.get(`/api/projects/${t}`).then((o) => o.data);
|
|
63
|
+
}
|
|
64
|
+
async function gt(t) {
|
|
65
|
+
return F.post(`/api/projects/${t.id}/update`, t).then((o) => o.data);
|
|
66
|
+
}
|
|
67
|
+
const Pt = 500, D = ot("abcdefghijklmnopqrstuvwxyz0123456789", 16), N = nt(null);
|
|
68
|
+
function Xt({
|
|
69
|
+
url: t,
|
|
70
|
+
name: o,
|
|
71
|
+
children: u,
|
|
72
|
+
waitingSynced: c
|
|
73
|
+
}) {
|
|
74
|
+
const [a, l] = y(!1), p = z(), e = `${p}:MakerLocalState`, r = `${p}:${o}`, [s, n] = H(e, {
|
|
75
|
+
defaultValue: {}
|
|
76
|
+
}), i = rt(s);
|
|
77
|
+
i.current = s;
|
|
78
|
+
const h = g(
|
|
79
|
+
() => Z({
|
|
80
|
+
pages: {},
|
|
81
|
+
pageIds: [],
|
|
82
|
+
components: {},
|
|
83
|
+
supportedLocales: [],
|
|
84
|
+
config: {},
|
|
85
|
+
resources: {}
|
|
86
|
+
}),
|
|
87
|
+
[]
|
|
88
|
+
), w = g(() => J(h), [h]);
|
|
89
|
+
g(() => new at(r, w), [r, w]);
|
|
90
|
+
const P = g(
|
|
91
|
+
() => new dt(t, r, w, { params: { token: tt.get("login_token") } }),
|
|
92
|
+
[t, r, w]
|
|
93
|
+
), I = g(
|
|
94
|
+
() => new ut(
|
|
95
|
+
[w.getArray("pageIds"), w.getMap("pages"), w.getArray("supportedLocales"), w.getMap("config")],
|
|
96
|
+
{ doc: w }
|
|
97
|
+
),
|
|
98
|
+
[w]
|
|
99
|
+
), [v, E] = y(null), [A, L] = y(!1), [_, O] = y(void 0), $ = U(async () => {
|
|
100
|
+
if (p) {
|
|
101
|
+
L(!0);
|
|
102
|
+
try {
|
|
103
|
+
const d = await St(p);
|
|
104
|
+
E(d);
|
|
105
|
+
} catch (d) {
|
|
106
|
+
console.error("Failed to fetch project:", d);
|
|
107
|
+
} finally {
|
|
108
|
+
L(!1);
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
}, [p]), R = U(
|
|
112
|
+
async (d, f) => {
|
|
113
|
+
var S;
|
|
114
|
+
if (O(void 0), !!p) {
|
|
115
|
+
f != null && f.optimisticUpdate && v && E((m) => ({
|
|
116
|
+
...m,
|
|
117
|
+
...d
|
|
118
|
+
}));
|
|
119
|
+
try {
|
|
120
|
+
const m = await gt({
|
|
121
|
+
...d
|
|
122
|
+
});
|
|
123
|
+
E(m);
|
|
124
|
+
} catch (m) {
|
|
125
|
+
console.error("Failed to update project:", m), f != null && f.optimisticUpdate && E(v), O((S = m == null ? void 0 : m.response) == null ? void 0 : S.data);
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
},
|
|
129
|
+
[p, v]
|
|
130
|
+
);
|
|
131
|
+
C(() => {
|
|
132
|
+
p && $();
|
|
133
|
+
}, [p, $]);
|
|
134
|
+
const B = g(
|
|
135
|
+
() => ({
|
|
136
|
+
doc: w,
|
|
137
|
+
state: h,
|
|
138
|
+
localState: s,
|
|
139
|
+
setLocalState: (d) => n(typeof d == "function" ? (f) => d(f ?? {}) : d),
|
|
140
|
+
undoManager: I,
|
|
141
|
+
projectState: {
|
|
142
|
+
project: v,
|
|
143
|
+
isLoadingProject: A,
|
|
144
|
+
error: _
|
|
145
|
+
},
|
|
146
|
+
updateProject: R
|
|
147
|
+
}),
|
|
148
|
+
[w, h, s, n, I, v, A, R, _]
|
|
149
|
+
);
|
|
150
|
+
return C(() => {
|
|
151
|
+
I.on("stack-item-added", ({ stackItem: d }) => {
|
|
152
|
+
const { currentPageId: f, currentLocale: S, pages: m } = i.current;
|
|
153
|
+
d.meta.set("localState", { currentPageId: f, currentLocale: S, pages: m });
|
|
154
|
+
}), I.on("stack-item-popped", ({ stackItem: d }) => {
|
|
155
|
+
const f = d.meta.get("localState");
|
|
156
|
+
f && n((S) => ({ ...S, ...f }));
|
|
157
|
+
});
|
|
158
|
+
}, [I, n]), C(() => {
|
|
159
|
+
P.awareness.setLocalState(s);
|
|
160
|
+
}, [P, s]), C(() => {
|
|
161
|
+
P.once("synced", () => l(!0));
|
|
162
|
+
const d = () => {
|
|
163
|
+
n((m) => ({
|
|
164
|
+
...m,
|
|
165
|
+
networkStatus: void 0
|
|
166
|
+
}));
|
|
167
|
+
}, f = () => {
|
|
168
|
+
n((m) => ({
|
|
169
|
+
...m,
|
|
170
|
+
networkStatus: "offline"
|
|
171
|
+
}));
|
|
172
|
+
}, S = et(({ status: m }) => {
|
|
173
|
+
m === "connected" ? d() : m === "disconnected" && f();
|
|
174
|
+
}, Pt);
|
|
175
|
+
return P.on("status", S), window.addEventListener("online", d), window.addEventListener("offline", f), () => {
|
|
176
|
+
P.off("status", S), window.removeEventListener("online", d), window.removeEventListener("offline", f);
|
|
177
|
+
};
|
|
178
|
+
}, [P, n]), c && !a ? null : /* @__PURE__ */ k(N.Provider, { value: B, children: u });
|
|
179
|
+
}
|
|
180
|
+
const kt = () => {
|
|
181
|
+
const t = st(N);
|
|
182
|
+
if (!t)
|
|
183
|
+
throw new Error("Context is null");
|
|
184
|
+
const o = Y(t.state), { setLocalState: u } = t, c = it(), a = z(), l = g(
|
|
185
|
+
() => ({
|
|
186
|
+
setCurrentSectionId: (e, r) => {
|
|
187
|
+
c(j("/admin/maker", a ?? "", "pages", e)), u(
|
|
188
|
+
(s) => T(s, (n) => {
|
|
189
|
+
var i;
|
|
190
|
+
n.currentPageId = e, n.currentComponentId = void 0, r !== void 0 && (n.pages ?? (n.pages = {}), (i = n.pages)[e] ?? (i[e] = {}), n.pages[e].currentSectionId = r ?? void 0), r ? window.sessionStorage.setItem("iframe_show_id", `"${r}"`) : window.sessionStorage.removeItem("iframe_show_id");
|
|
191
|
+
})
|
|
192
|
+
);
|
|
193
|
+
},
|
|
194
|
+
setCurrentComponentId: (e) => {
|
|
195
|
+
c(j("/admin/maker", a ?? "", "components", e)), u(
|
|
196
|
+
(r) => T(r, (s) => {
|
|
197
|
+
s.currentComponentId = e;
|
|
198
|
+
})
|
|
199
|
+
);
|
|
200
|
+
}
|
|
201
|
+
}),
|
|
202
|
+
[u, c, a]
|
|
203
|
+
), p = g(
|
|
204
|
+
() => ({
|
|
205
|
+
addPage: (e, r) => {
|
|
206
|
+
const s = (e == null ? void 0 : e.id) ?? D(), n = {
|
|
207
|
+
...e,
|
|
208
|
+
id: s,
|
|
209
|
+
createdAt: (e == null ? void 0 : e.createdAt) ?? (/* @__PURE__ */ new Date()).toISOString(),
|
|
210
|
+
updatedAt: (e == null ? void 0 : e.updatedAt) ?? (/* @__PURE__ */ new Date()).toISOString(),
|
|
211
|
+
publishedAt: (/* @__PURE__ */ new Date(0)).toISOString(),
|
|
212
|
+
slug: (e == null ? void 0 : e.slug) ?? `/${s}`,
|
|
213
|
+
sections: (e == null ? void 0 : e.sections) ?? {},
|
|
214
|
+
sectionIds: (e == null ? void 0 : e.sectionIds) ?? [],
|
|
215
|
+
isPublic: (e == null ? void 0 : e.isPublic) ?? !0
|
|
216
|
+
};
|
|
217
|
+
return t.doc.transact(() => {
|
|
218
|
+
o.pages[n.id] = n, o.pageIds.splice(r ?? o.pageIds.length, 0, n.id);
|
|
219
|
+
}), n;
|
|
220
|
+
},
|
|
221
|
+
deletePage: (e) => {
|
|
222
|
+
const r = o.pageIds.indexOf(e);
|
|
223
|
+
r !== -1 && t.doc.transact(() => {
|
|
224
|
+
o.pageIds.splice(r, 1), delete o.pages[e];
|
|
225
|
+
});
|
|
226
|
+
},
|
|
227
|
+
movePage: (e, r) => {
|
|
228
|
+
const { pageIds: s } = o, n = s.indexOf(e);
|
|
229
|
+
n >= 0 && s.splice(r, 0, ...s.splice(n, 1));
|
|
230
|
+
},
|
|
231
|
+
addSection: (e, r, s) => {
|
|
232
|
+
const n = o.pages[e];
|
|
233
|
+
if (!n)
|
|
234
|
+
throw new Error(`Page ${e} is not exists`);
|
|
235
|
+
const i = {
|
|
236
|
+
...r,
|
|
237
|
+
id: r.id ?? D()
|
|
238
|
+
};
|
|
239
|
+
return t.doc.transact(() => {
|
|
240
|
+
n.sections[i.id] = i, n.sectionIds.splice(s ?? n.sectionIds.length, 0, i.id);
|
|
241
|
+
}), i;
|
|
242
|
+
},
|
|
243
|
+
deleteSection: (e, r) => {
|
|
244
|
+
const s = o.pages[e];
|
|
245
|
+
if (!s)
|
|
246
|
+
throw new Error(`Page ${e} is not exists`);
|
|
247
|
+
const n = s.sectionIds.indexOf(r);
|
|
248
|
+
n !== -1 && t.doc.transact(() => {
|
|
249
|
+
s.sectionIds.splice(n, 1), delete s.sections[r];
|
|
250
|
+
});
|
|
251
|
+
},
|
|
252
|
+
toggleSectionVisibility: (e, r, s) => {
|
|
253
|
+
const n = o.pages[e];
|
|
254
|
+
if (!n)
|
|
255
|
+
throw new Error(`Page ${e} is not exists`);
|
|
256
|
+
const i = n.sections[r];
|
|
257
|
+
i && (i.visibility = s);
|
|
258
|
+
},
|
|
259
|
+
moveSection: (e, r, s) => {
|
|
260
|
+
const n = o.pages[e];
|
|
261
|
+
if (!n)
|
|
262
|
+
throw new Error(`Page ${e} is not exists`);
|
|
263
|
+
const { sectionIds: i } = n, h = i.indexOf(r);
|
|
264
|
+
h >= 0 && i.splice(s, 0, ...i.splice(h, 1));
|
|
265
|
+
}
|
|
266
|
+
}),
|
|
267
|
+
[o, t.doc]
|
|
268
|
+
);
|
|
269
|
+
return {
|
|
270
|
+
...t,
|
|
271
|
+
state: o,
|
|
272
|
+
actions: p,
|
|
273
|
+
localActions: l,
|
|
274
|
+
get currentPage() {
|
|
275
|
+
const {
|
|
276
|
+
localState: { currentPageId: e }
|
|
277
|
+
} = t;
|
|
278
|
+
return e ? o.pages[e] : void 0;
|
|
279
|
+
},
|
|
280
|
+
get currentSection() {
|
|
281
|
+
var n, i, h;
|
|
282
|
+
const {
|
|
283
|
+
localState: { currentPageId: e, ...r }
|
|
284
|
+
} = t;
|
|
285
|
+
if (!e)
|
|
286
|
+
return;
|
|
287
|
+
const s = (i = (n = r.pages) == null ? void 0 : n[e]) == null ? void 0 : i.currentSectionId;
|
|
288
|
+
if (s)
|
|
289
|
+
return (h = o.pages[e]) == null ? void 0 : h.sections[s];
|
|
290
|
+
}
|
|
291
|
+
};
|
|
292
|
+
}, z = () => {
|
|
293
|
+
const { projectId: t } = ct();
|
|
294
|
+
return t ?? lt();
|
|
295
|
+
};
|
|
296
|
+
function It(t) {
|
|
297
|
+
var c, a;
|
|
298
|
+
const { resources: o } = t;
|
|
299
|
+
if (!o.components)
|
|
300
|
+
return {};
|
|
301
|
+
const u = {};
|
|
302
|
+
return (a = (c = window == null ? void 0 : window.blocklet) == null ? void 0 : c.componentMountPoints) == null || a.forEach((l) => {
|
|
303
|
+
u[l.did] = l;
|
|
304
|
+
}), Object.fromEntries(
|
|
305
|
+
Object.entries(o.components).map(([l, { blockletId: p, component: e }]) => {
|
|
306
|
+
var r;
|
|
307
|
+
return [
|
|
308
|
+
l,
|
|
309
|
+
{ data: e, blockletId: p, blockletTitle: ((r = u[p]) == null ? void 0 : r.title) || p }
|
|
310
|
+
];
|
|
311
|
+
})
|
|
312
|
+
);
|
|
313
|
+
}
|
|
314
|
+
function vt(t) {
|
|
315
|
+
const { components: o } = t;
|
|
316
|
+
return o || {};
|
|
317
|
+
}
|
|
318
|
+
function jt(t) {
|
|
319
|
+
return {
|
|
320
|
+
...It(t),
|
|
321
|
+
...vt(t)
|
|
322
|
+
};
|
|
323
|
+
}
|
|
324
|
+
const Zt = () => jt(kt().state), Et = [
|
|
325
|
+
/\.\./,
|
|
326
|
+
// Directory traversal
|
|
327
|
+
/<[^>]*>/,
|
|
328
|
+
// HTML/XML tags
|
|
329
|
+
/%[0-9a-f]{2}/i,
|
|
330
|
+
// Percent encoding
|
|
331
|
+
/[<>'"%;{}()\\]/,
|
|
332
|
+
// Special characters
|
|
333
|
+
// eslint-disable-next-line no-control-regex
|
|
334
|
+
/\x00/,
|
|
335
|
+
// Null byte
|
|
336
|
+
/\n|\r|\t|\v|\f/,
|
|
337
|
+
// Control characters
|
|
338
|
+
/[^a-zA-Z0-9-_@/]/
|
|
339
|
+
// Disallow any characters except alphanumeric, dash, underscore and forward slash
|
|
340
|
+
];
|
|
341
|
+
function Jt(t, o, u) {
|
|
342
|
+
const c = [];
|
|
343
|
+
{
|
|
344
|
+
let a;
|
|
345
|
+
o.slug ? o.slug.startsWith("/") ? o.slug !== "/" && o.slug.endsWith("/") ? a = t("maker.properties.pathCheckEndWithoutSlash") : /\/{2,}/.test(o.slug) ? a = t("maker.properties.pathCheckConsecutiveSlash") : /\s/.test(o.slug) ? a = t("maker.properties.pathCheckWhitespace") : Et.some((l) => l.test(o.slug)) ? a = t("maker.properties.pathCheckInvalid") : Object.values(u.pages).some((l) => (l == null ? void 0 : l.id) !== o.id && (l == null ? void 0 : l.slug) === o.slug) && (a = t("maker.properties.pathCheckAlreadyExist")) : a = t("maker.properties.pathCheckStartWithSlash") : a = t("maker.properties.pathCheckRequired"), a && c.push({ path: ["path"], message: a });
|
|
346
|
+
}
|
|
347
|
+
return c.length > 0 ? c : null;
|
|
348
|
+
}
|
|
349
|
+
function Yt({ errors: t, ...o }) {
|
|
350
|
+
return t != null && t.length ? /* @__PURE__ */ k(
|
|
351
|
+
V,
|
|
352
|
+
{
|
|
353
|
+
...o,
|
|
354
|
+
title: /* @__PURE__ */ k(x, { children: t.map((u, c) => /* @__PURE__ */ k(x, { children: u.message }, c)) })
|
|
355
|
+
}
|
|
356
|
+
) : null;
|
|
357
|
+
}
|
|
358
|
+
export {
|
|
359
|
+
Gt as E,
|
|
360
|
+
Yt as P,
|
|
361
|
+
Xt as S,
|
|
362
|
+
Kt as a,
|
|
363
|
+
Qt as b,
|
|
364
|
+
F as c,
|
|
365
|
+
lt as d,
|
|
366
|
+
Bt as e,
|
|
367
|
+
jt as f,
|
|
368
|
+
qt as g,
|
|
369
|
+
kt as h,
|
|
370
|
+
ht as i,
|
|
371
|
+
Zt as j,
|
|
372
|
+
Vt as k,
|
|
373
|
+
Jt as l,
|
|
374
|
+
D as n,
|
|
375
|
+
z as u
|
|
376
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const j=require("react/jsx-runtime"),v=require("@mui/material"),Q=require("gradient-parser"),X=require("tinycolor2"),I=require("ufo"),Y=require("@blocklet/js-sdk"),T=require("@syncedstore/core"),Z=require("@syncedstore/react"),J=require("ahooks"),$=require("immer"),H=require("js-cookie"),ee=require("lodash/debounce"),te=require("nanoid"),c=require("react"),F=require("react-router-dom"),ne=require("y-indexeddb"),oe=require("y-websocket"),se=require("yjs"),y=e=>e&&e.__esModule?e:{default:e},re=y(Q),ce=y(X),ie=y(T),ae=y(H),ue=y(ee);function B(){const{pathname:e}=window.location,n=e.match(/\/admin\/(maker|previewer)\/([^/]+)/),l=n==null?void 0:n[2],a=window.__PROJECT_ID__;if(!l&&!a)throw new Error("Unable to get projectId from pathname");return l||a}function de(e){return`${e}:pages:version`}function le({error:e}){return j.jsx(v.Box,{children:j.jsx(v.Alert,{severity:"error",children:e.message})})}var W;const _=((W=window.blocklet)==null?void 0:W.prefix)||"/",b=Y.createAxios({timeout:200*1e3}),fe=window.location.protocol==="https:"?"wss":"ws",me=e=>I.joinURL(`${fe}://${window.location.hostname}`,_,`api/${e}/ws/pages`),pe="z8ia1mAXo8ZE7ytGF36L5uBf9kD2kenhqFGp9";var D;(D=blocklet==null?void 0:blocklet.componentMountPoints.find(e=>e.did===pe))!=null&&D.mountPoint||I.joinURL(_,"/image-bin");function we(e){return e&&!/^(https?:\/\/|\/)/.test(e)?window.location.origin+I.joinURL(_,"uploads",e):e}const ge=window.innerWidth<=750;function he(e,n,l){if(!e||/\.gif/.test(e))return e;const a=(ge?n/1.5:n)*(l==="quality"?1.5:1);return Se(e,{imageFilter:"resize",w:a,f:"webp"})}function Se(e,n){return!e||!n?e:I.withQuery(e,n)}function V(e){if(e!=null&&e.trim())try{return re.default.parse(e),!0}catch{return!1}return!1}function Pe(e){return typeof e!="string"?!1:!!(V(e)||ce.default(e).isValid())}async function je(e){return b.get(`/api/projects/${e}`).then(n=>n.data)}async function Ie(e){return b.post(`/api/projects/${e.id}/update`,e).then(n=>n.data)}const ke=500,C=te.customAlphabet("abcdefghijklmnopqrstuvwxyz0123456789",16),z=c.createContext(null);function xe({url:e,name:n,children:l,waitingSynced:a}){const[u,f]=c.useState(!1),w=L(),t=`${w}:MakerLocalState`,s=`${w}:${n}`,[r,o]=J.useLocalStorageState(t,{defaultValue:{}}),i=c.useRef(r);i.current=r;const h=c.useMemo(()=>ie.default({pages:{},pageIds:[],components:{},supportedLocales:[],config:{},resources:{}}),[]),g=c.useMemo(()=>T.getYjsDoc(h),[h]);c.useMemo(()=>new ne.IndexeddbPersistence(s,g),[s,g]);const P=c.useMemo(()=>new oe.WebsocketProvider(e,s,g,{params:{token:ae.default.get("login_token")}}),[e,s,g]),k=c.useMemo(()=>new se.UndoManager([g.getArray("pageIds"),g.getMap("pages"),g.getArray("supportedLocales"),g.getMap("config")],{doc:g}),[g]),[x,E]=c.useState(null),[A,q]=c.useState(!1),[R,M]=c.useState(void 0),O=c.useCallback(async()=>{if(w){q(!0);try{const d=await je(w);E(d)}catch(d){console.error("Failed to fetch project:",d)}finally{q(!1)}}},[w]),U=c.useCallback(async(d,m)=>{var S;if(M(void 0),!!w){m!=null&&m.optimisticUpdate&&x&&E(p=>({...p,...d}));try{const p=await Ie({...d});E(p)}catch(p){console.error("Failed to update project:",p),m!=null&&m.optimisticUpdate&&E(x),M((S=p==null?void 0:p.response)==null?void 0:S.data)}}},[w,x]);c.useEffect(()=>{w&&O()},[w,O]);const K=c.useMemo(()=>({doc:g,state:h,localState:r,setLocalState:d=>o(typeof d=="function"?m=>d(m??{}):d),undoManager:k,projectState:{project:x,isLoadingProject:A,error:R},updateProject:U}),[g,h,r,o,k,x,A,U,R]);return c.useEffect(()=>{k.on("stack-item-added",({stackItem:d})=>{const{currentPageId:m,currentLocale:S,pages:p}=i.current;d.meta.set("localState",{currentPageId:m,currentLocale:S,pages:p})}),k.on("stack-item-popped",({stackItem:d})=>{const m=d.meta.get("localState");m&&o(S=>({...S,...m}))})},[k,o]),c.useEffect(()=>{P.awareness.setLocalState(r)},[P,r]),c.useEffect(()=>{P.once("synced",()=>f(!0));const d=()=>{o(p=>({...p,networkStatus:void 0}))},m=()=>{o(p=>({...p,networkStatus:"offline"}))},S=ue.default(({status:p})=>{p==="connected"?d():p==="disconnected"&&m()},ke);return P.on("status",S),window.addEventListener("online",d),window.addEventListener("offline",m),()=>{P.off("status",S),window.removeEventListener("online",d),window.removeEventListener("offline",m)}},[P,o]),a&&!u?null:j.jsx(z.Provider,{value:K,children:l})}const G=()=>{const e=c.useContext(z);if(!e)throw new Error("Context is null");const n=Z.useSyncedStore(e.state),{setLocalState:l}=e,a=F.useNavigate(),u=L(),f=c.useMemo(()=>({setCurrentSectionId:(t,s)=>{a(I.joinURL("/admin/maker",u??"","pages",t)),l(r=>$.produce(r,o=>{var i;o.currentPageId=t,o.currentComponentId=void 0,s!==void 0&&(o.pages??(o.pages={}),(i=o.pages)[t]??(i[t]={}),o.pages[t].currentSectionId=s??void 0),s?window.sessionStorage.setItem("iframe_show_id",`"${s}"`):window.sessionStorage.removeItem("iframe_show_id")}))},setCurrentComponentId:t=>{a(I.joinURL("/admin/maker",u??"","components",t)),l(s=>$.produce(s,r=>{r.currentComponentId=t}))}}),[l,a,u]),w=c.useMemo(()=>({addPage:(t,s)=>{const r=(t==null?void 0:t.id)??C(),o={...t,id:r,createdAt:(t==null?void 0:t.createdAt)??new Date().toISOString(),updatedAt:(t==null?void 0:t.updatedAt)??new Date().toISOString(),publishedAt:new Date(0).toISOString(),slug:(t==null?void 0:t.slug)??`/${r}`,sections:(t==null?void 0:t.sections)??{},sectionIds:(t==null?void 0:t.sectionIds)??[],isPublic:(t==null?void 0:t.isPublic)??!0};return e.doc.transact(()=>{n.pages[o.id]=o,n.pageIds.splice(s??n.pageIds.length,0,o.id)}),o},deletePage:t=>{const s=n.pageIds.indexOf(t);s!==-1&&e.doc.transact(()=>{n.pageIds.splice(s,1),delete n.pages[t]})},movePage:(t,s)=>{const{pageIds:r}=n,o=r.indexOf(t);o>=0&&r.splice(s,0,...r.splice(o,1))},addSection:(t,s,r)=>{const o=n.pages[t];if(!o)throw new Error(`Page ${t} is not exists`);const i={...s,id:s.id??C()};return e.doc.transact(()=>{o.sections[i.id]=i,o.sectionIds.splice(r??o.sectionIds.length,0,i.id)}),i},deleteSection:(t,s)=>{const r=n.pages[t];if(!r)throw new Error(`Page ${t} is not exists`);const o=r.sectionIds.indexOf(s);o!==-1&&e.doc.transact(()=>{r.sectionIds.splice(o,1),delete r.sections[s]})},toggleSectionVisibility:(t,s,r)=>{const o=n.pages[t];if(!o)throw new Error(`Page ${t} is not exists`);const i=o.sections[s];i&&(i.visibility=r)},moveSection:(t,s,r)=>{const o=n.pages[t];if(!o)throw new Error(`Page ${t} is not exists`);const{sectionIds:i}=o,h=i.indexOf(s);h>=0&&i.splice(r,0,...i.splice(h,1))}}),[n,e.doc]);return{...e,state:n,actions:w,localActions:f,get currentPage(){const{localState:{currentPageId:t}}=e;return t?n.pages[t]:void 0},get currentSection(){var o,i,h;const{localState:{currentPageId:t,...s}}=e;if(!t)return;const r=(i=(o=s.pages)==null?void 0:o[t])==null?void 0:i.currentSectionId;if(r)return(h=n.pages[t])==null?void 0:h.sections[r]}}},L=()=>{const{projectId:e}=F.useParams();return e??B()};function ve(e){var a,u;const{resources:n}=e;if(!n.components)return{};const l={};return(u=(a=window==null?void 0:window.blocklet)==null?void 0:a.componentMountPoints)==null||u.forEach(f=>{l[f.did]=f}),Object.fromEntries(Object.entries(n.components).map(([f,{blockletId:w,component:t}])=>{var s;return[f,{data:t,blockletId:w,blockletTitle:((s=l[w])==null?void 0:s.title)||w}]}))}function ye(e){const{components:n}=e;return n||{}}function N(e){return{...ve(e),...ye(e)}}const Ee=()=>N(G().state),Ce=[/\.\./,/<[^>]*>/,/%[0-9a-f]{2}/i,/[<>'"%;{}()\\]/,/\x00/,/\n|\r|\t|\v|\f/,/[^a-zA-Z0-9-_@/]/];function _e(e,n,l){const a=[];{let u;n.slug?n.slug.startsWith("/")?n.slug!=="/"&&n.slug.endsWith("/")?u=e("maker.properties.pathCheckEndWithoutSlash"):/\/{2,}/.test(n.slug)?u=e("maker.properties.pathCheckConsecutiveSlash"):/\s/.test(n.slug)?u=e("maker.properties.pathCheckWhitespace"):Ce.some(f=>f.test(n.slug))?u=e("maker.properties.pathCheckInvalid"):Object.values(l.pages).some(f=>(f==null?void 0:f.id)!==n.id&&(f==null?void 0:f.slug)===n.slug)&&(u=e("maker.properties.pathCheckAlreadyExist")):u=e("maker.properties.pathCheckStartWithSlash"):u=e("maker.properties.pathCheckRequired"),u&&a.push({path:["path"],message:u})}return a.length>0?a:null}function be({errors:e,...n}){return e!=null&&e.length?j.jsx(v.Tooltip,{...n,title:j.jsx(v.Box,{children:e.map((l,a)=>j.jsx(v.Box,{children:l.message},a))})}):null}exports.ErrorView=le;exports.PageErrorTip=be;exports.StoreProvider=xe;exports.api=b;exports.autoResizeImage=he;exports.checkPage=_e;exports.getAllComponents=N;exports.getImageAbsoluteUrl=we;exports.getProjectIdFromPathnameOrWindow=B;exports.getProjectPageVersionKey=de;exports.getWssURL=me;exports.isColorString=Pe;exports.isGradient=V;exports.nextId=C;exports.useAllComponents=Ee;exports.useProjectId=L;exports.useStore=G;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@blocklet/pages-kit-inner-components",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.8",
|
|
4
4
|
"description": "Pages Kit inner components",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -31,6 +31,18 @@
|
|
|
31
31
|
"./components": {
|
|
32
32
|
"import": "./lib/es/components.js",
|
|
33
33
|
"require": "./lib/cjs/components.js"
|
|
34
|
+
},
|
|
35
|
+
"./setting": {
|
|
36
|
+
"import": "./lib/es/setting.js",
|
|
37
|
+
"require": "./lib/cjs/setting.js"
|
|
38
|
+
},
|
|
39
|
+
"./locales": {
|
|
40
|
+
"import": "./lib/es/locales.js",
|
|
41
|
+
"require": "./lib/cjs/locales.js"
|
|
42
|
+
},
|
|
43
|
+
"./uploader": {
|
|
44
|
+
"import": "./lib/es/uploader.js",
|
|
45
|
+
"require": "./lib/cjs/uploader.js"
|
|
34
46
|
}
|
|
35
47
|
},
|
|
36
48
|
"typesVersions": {
|
|
@@ -49,6 +61,15 @@
|
|
|
49
61
|
],
|
|
50
62
|
"components": [
|
|
51
63
|
"./lib/types/components.d.ts"
|
|
64
|
+
],
|
|
65
|
+
"setting": [
|
|
66
|
+
"./lib/types/setting.d.ts"
|
|
67
|
+
],
|
|
68
|
+
"locales": [
|
|
69
|
+
"./lib/types/locales.d.ts"
|
|
70
|
+
],
|
|
71
|
+
"uploader": [
|
|
72
|
+
"./lib/types/uploader.d.ts"
|
|
52
73
|
]
|
|
53
74
|
}
|
|
54
75
|
},
|
|
@@ -64,25 +85,24 @@
|
|
|
64
85
|
"url": "git+https://github.com/blocklet/pages-kit.git"
|
|
65
86
|
},
|
|
66
87
|
"dependencies": {
|
|
67
|
-
"
|
|
68
|
-
"@arcblock/did-auth": "^1.19.6",
|
|
88
|
+
"@arcblock/did-auth": "^1.19.9",
|
|
69
89
|
"@arcblock/did-auth-storage-nedb": "^1.7.1",
|
|
70
|
-
"@arcblock/did-connect": "^2.11.
|
|
71
|
-
"@arcblock/react-hooks": "^2.11.
|
|
72
|
-
"@arcblock/ux": "^2.11.
|
|
73
|
-
"@blocklet/ai-kit": "^0.1.
|
|
74
|
-
"@blocklet/ai-runtime": "^0.4.
|
|
75
|
-
"@blocklet/code-editor": "^0.4.
|
|
76
|
-
"@blocklet/crawler": "^2.1.
|
|
77
|
-
"@blocklet/embed": "^0.2.
|
|
78
|
-
"@blocklet/js-sdk": "^1.16.
|
|
79
|
-
"@blocklet/quickjs": "^0.4.
|
|
80
|
-
"@blocklet/sdk": "^1.16.
|
|
81
|
-
"@blocklet/studio-ui": "^0.4.
|
|
82
|
-
"@blocklet/tracker": "^1.16.
|
|
83
|
-
"@blocklet/ui-react": "^2.11.
|
|
84
|
-
"@blocklet/uploader": "^0.1.
|
|
85
|
-
"@blocklet/uploader-server": "^0.1.
|
|
90
|
+
"@arcblock/did-connect": "^2.11.35",
|
|
91
|
+
"@arcblock/react-hooks": "^2.11.35",
|
|
92
|
+
"@arcblock/ux": "^2.11.35",
|
|
93
|
+
"@blocklet/ai-kit": "^0.1.68",
|
|
94
|
+
"@blocklet/ai-runtime": "^0.4.230",
|
|
95
|
+
"@blocklet/code-editor": "^0.4.230",
|
|
96
|
+
"@blocklet/crawler": "^2.1.160",
|
|
97
|
+
"@blocklet/embed": "^0.2.3",
|
|
98
|
+
"@blocklet/js-sdk": "^1.16.38",
|
|
99
|
+
"@blocklet/quickjs": "^0.4.230",
|
|
100
|
+
"@blocklet/sdk": "^1.16.38",
|
|
101
|
+
"@blocklet/studio-ui": "^0.4.230",
|
|
102
|
+
"@blocklet/tracker": "^1.16.38",
|
|
103
|
+
"@blocklet/ui-react": "^2.11.35",
|
|
104
|
+
"@blocklet/uploader": "^0.1.67",
|
|
105
|
+
"@blocklet/uploader-server": "^0.1.79",
|
|
86
106
|
"@emotion/cache": "^11.13.1",
|
|
87
107
|
"@emotion/css": "^11.13.0",
|
|
88
108
|
"@emotion/react": "^11.13.0",
|
|
@@ -101,9 +121,9 @@
|
|
|
101
121
|
"@mui/styles": "^5.16.7",
|
|
102
122
|
"@mui/utils": "^5.16.6",
|
|
103
123
|
"@mui/x-date-pickers": "^7.13.0",
|
|
104
|
-
"@ocap/client": "^1.19.
|
|
105
|
-
"@ocap/mcrypto": "^1.19.
|
|
106
|
-
"@ocap/wallet": "^1.19.
|
|
124
|
+
"@ocap/client": "^1.19.9",
|
|
125
|
+
"@ocap/mcrypto": "^1.19.9",
|
|
126
|
+
"@ocap/wallet": "^1.19.9",
|
|
107
127
|
"@reactivedata/reactive": "^0.2.2",
|
|
108
128
|
"@syncedstore/core": "^0.6.0",
|
|
109
129
|
"@syncedstore/react": "^0.6.0",
|
|
@@ -139,6 +159,7 @@
|
|
|
139
159
|
"isomorphic-dompurify": "^2.14.0",
|
|
140
160
|
"joi": "^17.13.3",
|
|
141
161
|
"js-cookie": "^3.0.5",
|
|
162
|
+
"js-yaml": "^4.1.0",
|
|
142
163
|
"json-stable-stringify": "^1.1.1",
|
|
143
164
|
"jss": "^10.10.0",
|
|
144
165
|
"lib0": "^0.2.97",
|
|
@@ -201,9 +222,9 @@
|
|
|
201
222
|
"yaml": "^2.5.0",
|
|
202
223
|
"yjs": "^13.6.18",
|
|
203
224
|
"zustand": "^4.5.5",
|
|
204
|
-
"@blocklet/pages-kit
|
|
205
|
-
"@blocklet/pages-kit-block-studio": "^0.0.
|
|
206
|
-
"@blocklet/pages-kit": "^0.
|
|
225
|
+
"@blocklet/pages-kit": "^0.4.8",
|
|
226
|
+
"@blocklet/pages-kit-block-studio": "^0.0.12",
|
|
227
|
+
"@blocklet/pages-kit-runtime": "^0.1.11"
|
|
207
228
|
},
|
|
208
229
|
"peerDependencies": {
|
|
209
230
|
"axios": "^1.7.4",
|
|
@@ -212,17 +233,6 @@
|
|
|
212
233
|
"react-router-dom": "^6.16.0"
|
|
213
234
|
},
|
|
214
235
|
"devDependencies": {
|
|
215
|
-
"@types/js-yaml": "^4.0.9",
|
|
216
|
-
"@types/lodash": "^4.17.7",
|
|
217
|
-
"@types/react-helmet": "^6.1.11",
|
|
218
|
-
"@types/react-scroll-to-bottom": "^4.2.5",
|
|
219
|
-
"@types/react-syntax-highlighter": "^15.5.13",
|
|
220
|
-
"axios": "^1.7.4",
|
|
221
|
-
"react": "^18.3.1",
|
|
222
|
-
"react-dom": "^18.3.1",
|
|
223
|
-
"react-router-dom": "^6.26.1",
|
|
224
|
-
"rimraf": "^6.0.1",
|
|
225
|
-
"vite-plugin-require": "^1.2.14",
|
|
226
236
|
"@trivago/prettier-plugin-sort-imports": "^5.2.1",
|
|
227
237
|
"@types/compression": "^1.7.5",
|
|
228
238
|
"@types/cookie-parser": "^1.4.7",
|
|
@@ -233,8 +243,10 @@
|
|
|
233
243
|
"@types/express-ws": "^3.0.4",
|
|
234
244
|
"@types/file-saver": "^2.0.7",
|
|
235
245
|
"@types/flat": "^5.0.5",
|
|
246
|
+
"@types/js-yaml": "^4.0.9",
|
|
236
247
|
"@types/jsdom": "^21.1.7",
|
|
237
248
|
"@types/json-stable-stringify": "^1.0.36",
|
|
249
|
+
"@types/lodash": "^4.17.7",
|
|
238
250
|
"@types/multer": "^1.4.11",
|
|
239
251
|
"@types/mustache": "^4.2.5",
|
|
240
252
|
"@types/node": "^22.4.2",
|
|
@@ -243,6 +255,9 @@
|
|
|
243
255
|
"@types/react-color": "^3.0.12",
|
|
244
256
|
"@types/react-dom": "^18.3.0",
|
|
245
257
|
"@types/react-frame-component": "^4.1.6",
|
|
258
|
+
"@types/react-helmet": "^6.1.11",
|
|
259
|
+
"@types/react-scroll-to-bottom": "^4.2.5",
|
|
260
|
+
"@types/react-syntax-highlighter": "^15.5.13",
|
|
246
261
|
"@types/react-window": "^1.8.8",
|
|
247
262
|
"@types/tar": "^6.1.13",
|
|
248
263
|
"@types/url-join": "^4.0.3",
|
|
@@ -250,9 +265,14 @@
|
|
|
250
265
|
"@types/ws": "^8.5.12",
|
|
251
266
|
"@vitejs/plugin-legacy": "^5.4.2",
|
|
252
267
|
"@vitejs/plugin-react": "^4.3.1",
|
|
268
|
+
"axios": "^1.7.4",
|
|
253
269
|
"cross-env": "^7.0.3",
|
|
254
270
|
"nodemon": "^3.1.4",
|
|
255
271
|
"npm-run-all": "^4.1.5",
|
|
272
|
+
"react": "^18.3.1",
|
|
273
|
+
"react-dom": "^18.3.1",
|
|
274
|
+
"react-router-dom": "^6.26.1",
|
|
275
|
+
"rimraf": "^6.0.1",
|
|
256
276
|
"rollup-plugin-visualizer": "^5.12.0",
|
|
257
277
|
"ts-node": "^10.9.2",
|
|
258
278
|
"tsc-alias": "^1.8.10",
|
|
@@ -261,16 +281,17 @@
|
|
|
261
281
|
"vite-node": "^2.0.5",
|
|
262
282
|
"vite-plugin-blocklet": "^0.9.14",
|
|
263
283
|
"vite-plugin-pwa": "^0.21.1",
|
|
284
|
+
"vite-plugin-require": "^1.2.14",
|
|
264
285
|
"vite-plugin-svgr": "^4.2.0",
|
|
265
286
|
"vite-tsconfig-paths": "^5.0.1",
|
|
266
287
|
"zx": "^8.1.4",
|
|
267
|
-
"@blocklet/pages-kit-block-studio": "0.0.
|
|
288
|
+
"@blocklet/pages-kit-block-studio": "0.0.12"
|
|
268
289
|
},
|
|
269
290
|
"scripts": {
|
|
270
291
|
"lint": "eslint src --ext .mjs,.js,.jsx,.ts,.tsx",
|
|
271
292
|
"lint:fix": "npm run lint -- --fix",
|
|
272
293
|
"dev": "run-p 'build:* -- -w'",
|
|
273
294
|
"clean": "rimraf lib",
|
|
274
|
-
"build": "node -r dotenv-flow/config -e \"require('@blocklet/pages-kit-block-studio/
|
|
295
|
+
"build": "node -r dotenv-flow/config -e \"require('@blocklet/pages-kit-block-studio/build-lib')\""
|
|
275
296
|
}
|
|
276
297
|
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("react/jsx-runtime"),t=require("./home-DZ1HSzX6.js");function n({children:e}){const r=t.useProjectId();return o.jsx(t.StoreProvider,{url:t.getWssURL(r??""),name:"root",waitingSynced:!0,children:o.jsx(s,{children:e})})}function s({children:e}){const{state:r}=t.useStore();return e({state:r})}exports.default=n;
|