@flatjs/evolve 3.0.5 → 3.0.6

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 +1 @@
1
- import{existsSync,readFileSync}from"node:fs";import{isAbsolute,join}from"node:path";import{ensureSlash,urlJoin}from"@flatjs/common";import{parseTemplate}from"@hyperse/html-webpack-plugin-loader";import{allowPx2remForModule}from"../../helpers/allow-px2rem-for-module.js";import{checkHtmlTemplateOptions}from"../../helpers/check-html-template-options.js";import{getHtmlMaxOrder,getHtmlMinOrder}from"../../helpers/get-html-max-order.js";import{getHtmlPluginConfig}from"../../helpers/get-html-plugin-config.js";import{getPackageDir}from"../../helpers/get-pacakge-dir.js";import{getRuntimeCDNBase}from"../../helpers/get-runtime-cdn-base.js";import{normalizeEvolveEntryName}from"../../helpers/normalize-entry-map.js";import{normalizePageProxy}from"../../helpers/normalize-page-proxy.js";import{normalizeTemplateInjectTokens}from"../../helpers/normalize-template-inject-tokens.js";import{injectFederationScripts}from"../../helpers/script-injects.js";import{ErrorModuleParser}from"./error-module-parser.js";import{getBundleAsset}from"./get-bundle-asset.js";import{getDevServerHostUri}from"./get-dev-server-host-uri.js";import{getHmrRuntimeChunks}from"./get-hmr-runtime-chunks.js";import{getNormalizedEntryName}from"./get-normalized-entry-name.js";export const getPageModuleHtml=async(e,t,r,o,n)=>{const{entryMap:s,projectVirtualPath:l}=n,i=Object.keys(s).sort((e,t)=>t.length-e.length),a=getPackageDir(),m=i.find(e=>{const r=normalizeEvolveEntryName(e,l);return ensureSlash(t.path.replace(/^\//,""),!0).startsWith(ensureSlash(r,!0))});if(!m){const e=readFileSync(join(a,"./templates/module-404.html"),"utf-8");return new ErrorModuleParser(e,{title:"404 Not Found",errorMeta:[{name:"@flatjs/evolve workspace",value:a},{name:"served entry names",value:JSON.stringify(i)},{name:"module path",value:`${t.path}`}]}).serialize()}const p=s[m],d=p.options,u=getDevServerHostUri(e,m,r),c=d?.templatePath||"./templates/module.html",g=join(n.projectCwd,"./templates/module.html"),h=readFileSync(isAbsolute(c)?c:existsSync(g)?g:join(a,"./templates/module.html"),"utf-8"),f=n.devServer,v=f?.defaultServeGlobalData?await f.defaultServeGlobalData(p,r):{},j={mode:"development",envCdn:urlJoin(r,["public"])},y=getNormalizedEntryName(m,l,e,f),S=normalizePageProxy(f?.pageProxy||"/pages"),H=normalizeTemplateInjectTokens(j,d);checkHtmlTemplateOptions(H);const M=parseTemplate(h);M.upsertTitleTag(getHtmlPluginConfig("title",j,d?.title));const P=H.favicon;P&&M.upsertFaviconTag(P.href,P.rel,P.attributes);const x=H.headMetaTags||[];M.upsertHeadMetaTags(x);const k=H.headStyles||[],b=getHtmlMaxOrder(k),z=getBundleAsset(u,y,".css");k.push({id:z,href:z,position:"end",order:b+1}),M.upsertHeadStyles(k);const O=H.headScripts||[],w=getHtmlMaxOrder(O),C=getHtmlMinOrder(O);getHmrRuntimeChunks(e,m,y,p,n,u).forEach(e=>{O.unshift({id:e,src:e,position:"end",order:w-1})}),M.upsertHeadScripts(O);const T=H.headInlineScripts||[],N=getHtmlMaxOrder(T),E=getHtmlMinOrder(T),D=Math.min(E,C),F={hostUrl:r,apiBase:urlJoin(r,[o]),virtualPath:join(S,l),moduleName:m.replace(l,"").replace(/^\//,""),...v,...d?.serveGlobalData||{}};T.push({id:"globalData",content:`window.GLOBAL=${JSON.stringify(F)}`,position:"end",order:D-2}),allowPx2remForModule([m,p],n)&&T.push({id:"viewport",content:getHtmlPluginConfig("viewport",j,d?.viewport),position:"end",order:E-1});const B=getRuntimeCDNBase(n.multiHtmlCdn,n.multiHtmlCdnEnvResolver||function cdnResolver(){});T.push({id:"flatjsMultiCdn",content:B,position:"end",order:N+1});const R=injectFederationScripts({me:[urlJoin(r,["public"])]},n.multiHtmlCdnEnvResolver);T.push({id:"evolveFetchMicroWidgets",content:R,position:"end",order:N+2}),M.upsertHeadInlineScripts(T);const A=H.headInlineStyles||[];M.upsertHeadInlineStyles(A);const I=H.bodyScripts||[],J=getHtmlMaxOrder(I),G=getBundleAsset(u,y,".js");return I.push({id:G,src:G,position:"end",order:J+1}),M.upsertBodyScripts(I),M.serialize()};
1
+ import{existsSync,readFileSync}from"node:fs";import{isAbsolute,join}from"node:path";import{ensureSlash,urlJoin}from"@flatjs/common";import{parseTemplate}from"@hyperse/html-webpack-plugin-loader";import{allowPx2remForModule}from"../../helpers/allow-px2rem-for-module.js";import{checkHtmlTemplateOptions}from"../../helpers/check-html-template-options.js";import{getHtmlMaxOrder,getHtmlMinOrder}from"../../helpers/get-html-max-order.js";import{getHtmlPluginConfig}from"../../helpers/get-html-plugin-config.js";import{getPackageDir}from"../../helpers/get-pacakge-dir.js";import{getRuntimeCDNBase}from"../../helpers/get-runtime-cdn-base.js";import{normalizeEvolveEntryName}from"../../helpers/normalize-entry-map.js";import{normalizePageProxy}from"../../helpers/normalize-page-proxy.js";import{normalizeTemplateInjectTokens}from"../../helpers/normalize-template-inject-tokens.js";import{injectFederationScripts}from"../../helpers/script-injects.js";import{ErrorModuleParser}from"./error-module-parser.js";import{getBundleAsset}from"./get-bundle-asset.js";import{getDevServerHostUri}from"./get-dev-server-host-uri.js";import{getHmrRuntimeChunks}from"./get-hmr-runtime-chunks.js";import{getNormalizedEntryName}from"./get-normalized-entry-name.js";export const getPageModuleHtml=async(e,t,r,o,n)=>{const{entryMap:s,projectVirtualPath:l}=n,i=Object.keys(s).sort((e,t)=>t.length-e.length),a=getPackageDir(),m=i.find(e=>{const r=normalizeEvolveEntryName(e,l);return ensureSlash(t.path.replace(/^\//,""),!0).startsWith(ensureSlash(r,!0))});if(!m){const e=readFileSync(join(a,"./templates/module-404.html"),"utf-8");return new ErrorModuleParser(e,{title:"404 Not Found",errorMeta:[{name:"@flatjs/evolve workspace",value:a},{name:"served entry names",value:JSON.stringify(i)},{name:"module path",value:`${t.path}`}]}).serialize()}const p=s[m],d=p.options,u=getDevServerHostUri(e,m,r),c=d?.templatePath||"./templates/module.html",g=join(n.projectCwd,"./templates/module.html"),h=readFileSync(isAbsolute(c)?c:existsSync(g)?g:join(a,"./templates/module.html"),"utf-8"),f=n.devServer,v=f?.defaultServeGlobalData?await f.defaultServeGlobalData(p,r):{},j={mode:"development",envCdn:urlJoin(r,["public"])},y=getNormalizedEntryName(m,l,e,f),S=normalizePageProxy(f?.pageProxy||"/pages"),H=normalizeTemplateInjectTokens(j,d);checkHtmlTemplateOptions(H);const M=parseTemplate(h);M.upsertTitleTag(getHtmlPluginConfig("title",j,d?.title));const P=H.favicon;P&&M.upsertFaviconTag(P.href,P.rel,P.attributes);const k=H.headMetaTags||[];M.upsertHeadMetaTags(k);const x=H.headStyles||[],b=getHtmlMaxOrder(x),z=getBundleAsset(u,y,".css");x.push({id:z,href:z,position:"end",order:b+1}),M.upsertHeadStyles(x);const w=H.headScripts||[],C=getHtmlMinOrder(w);getHmrRuntimeChunks(e,m,y,p,n,u).forEach(e=>{w.unshift({id:e,src:e,position:"end",order:C-1})}),M.upsertHeadScripts(w);const O=H.headInlineScripts||[],T=getHtmlMaxOrder(O),N=getHtmlMinOrder(O),E=Math.min(N,C),D={hostUrl:r,apiBase:urlJoin(r,[o]),virtualPath:join(S,l),moduleName:m.replace(l,"").replace(/^\//,""),...v,...d?.serveGlobalData||{}};O.push({id:"globalData",content:`window.GLOBAL=${JSON.stringify(D)}`,position:"end",order:E-2}),allowPx2remForModule([m,p],n)&&O.push({id:"viewport",content:getHtmlPluginConfig("viewport",j,d?.viewport),position:"end",order:N-1});const F=getRuntimeCDNBase(n.multiHtmlCdn,n.multiHtmlCdnEnvResolver||function cdnResolver(){});O.push({id:"flatjsMultiCdn",content:F,position:"end",order:T+1});const B=injectFederationScripts({me:[urlJoin(r,["public"])]},n.multiHtmlCdnEnvResolver);O.push({id:"evolveFetchMicroWidgets",content:B,position:"end",order:T+2}),M.upsertHeadInlineScripts(O);const R=H.headInlineStyles||[];M.upsertHeadInlineStyles(R);const A=H.bodyScripts||[],I=getHtmlMaxOrder(A),J=getBundleAsset(u,y,".js");return A.push({id:J,src:J,position:"end",order:I+1}),M.upsertBodyScripts(A),M.serialize()};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@flatjs/evolve",
3
- "version": "3.0.5",
3
+ "version": "3.0.6",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "exports": {