@flatjs/evolve 3.0.0 → 3.0.1

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{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,s)=>{const{entryMap:n,projectVirtualPath:i}=s,l=Object.keys(n).sort((e,t)=>t.length-e.length),a=getPackageDir(),m=l.find(e=>{const r=normalizeEvolveEntryName(e,i);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(l)},{name:"module path",value:`${t.path}`}]}).serialize()}const p=n[m],u=p.options,d=getDevServerHostUri(e,m,r),c=u?.templatePath||"./templates/module.html",g=join(s.projectCwd,"./templates/module.html"),h=readFileSync(isAbsolute(c)?c:existsSync(g)?g:join(a,"./templates/module.html"),"utf-8"),f=s.devServer,v=f?.defaultServeGlobalData?await f.defaultServeGlobalData(p,r):{},j={mode:"development",envCdn:urlJoin(r,["public"])},y=getNormalizedEntryName(m,i,e,f),S=normalizePageProxy(f?.pageProxy||"/pages"),P=normalizeTemplateInjectTokens(j,u),H=parseTemplate(h);H.upsertTitleTag(getHtmlPluginConfig("title",j,u?.title));const b=P.favicon;b&&H.upsertFaviconTag(b.href,b.rel,b.attributes);const z=P.headMetaTags||[];H.upsertHeadMetaTags(z);const w=P.headStyles||[],C=getBundleAsset(d,y,".css");w.push({id:C,href:C,position:"end"}),H.upsertHeadStyles(w);const k=P.headScripts||[];getHmrRuntimeChunks(e,m,y,p,s,d).forEach(e=>{k.push({id:e,src:e,position:"end"})}),H.upsertHeadScripts(k);const N=P.headInlineScripts||[];allowPx2remForModule([m,p],s)&&N.push({id:"viewport",content:getHtmlPluginConfig("viewport",j,u?.viewport),position:"end"});const E=getRuntimeCDNBase(s.multiHtmlCdn,s.multiHtmlCdnEnvResolver||function cdnResolver(){});N.push({id:"flatjsMultiCdn",content:E,position:"end"});const M=injectFederationScripts({me:[urlJoin(r,["public"])]},s.multiHtmlCdnEnvResolver);N.push({id:"evolveFetchMicroWidgets",content:M,position:"end"});const T={hostUrl:r,apiBase:urlJoin(r,[o]),virtualPath:join(S,i),moduleName:m.replace(i,"").replace(/^\//,""),...v,...u?.serveGlobalData||{}};N.push({id:"globalData",content:`window.GLOBAL=${JSON.stringify(T)}`,position:"end"}),H.upsertHeadInlineScripts(N);const x=P.headInlineStyles||[];H.upsertHeadInlineStyles(x);const D=P.bodyScripts||[],F=getBundleAsset(d,y,".js");return D.push({id:F,src:F,position:"end"}),H.upsertBodyScripts(D),H.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{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:i}=n,l=Object.keys(s).sort((e,t)=>t.length-e.length),a=getPackageDir(),m=l.find(e=>{const r=normalizeEvolveEntryName(e,i);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(l)},{name:"module path",value:`${t.path}`}]}).serialize()}const p=s[m],u=p.options,d=getDevServerHostUri(e,m,r),c=u?.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,i,e,f),S=normalizePageProxy(f?.pageProxy||"/pages"),P=normalizeTemplateInjectTokens(j,u),H=parseTemplate(h);H.upsertTitleTag(getHtmlPluginConfig("title",j,u?.title));const b=P.favicon;b&&H.upsertFaviconTag(b.href,b.rel,b.attributes);const z=P.headMetaTags||[];H.upsertHeadMetaTags(z);const w=P.headStyles||[],C=getBundleAsset(d,y,".css");w.push({id:C,href:C,position:"end"}),H.upsertHeadStyles(w);const k=P.headScripts||[];getHmrRuntimeChunks(e,m,y,p,n,d).forEach(e=>{k.unshift({id:e,src:e,position:"end"})}),H.upsertHeadScripts(k);const N=P.headInlineScripts||[];allowPx2remForModule([m,p],n)&&N.push({id:"viewport",content:getHtmlPluginConfig("viewport",j,u?.viewport),position:"end"});const E=getRuntimeCDNBase(n.multiHtmlCdn,n.multiHtmlCdnEnvResolver||function cdnResolver(){});N.push({id:"flatjsMultiCdn",content:E,position:"end"});const M=injectFederationScripts({me:[urlJoin(r,["public"])]},n.multiHtmlCdnEnvResolver);N.push({id:"evolveFetchMicroWidgets",content:M,position:"end"});const T={hostUrl:r,apiBase:urlJoin(r,[o]),virtualPath:join(S,i),moduleName:m.replace(i,"").replace(/^\//,""),...v,...u?.serveGlobalData||{}};N.push({id:"globalData",content:`window.GLOBAL=${JSON.stringify(T)}`,position:"end"}),H.upsertHeadInlineScripts(N);const x=P.headInlineStyles||[];H.upsertHeadInlineStyles(x);const D=P.bodyScripts||[],F=getBundleAsset(d,y,".js");return D.push({id:F,src:F,position:"end"}),H.upsertBodyScripts(D),H.serialize()};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@flatjs/evolve",
3
- "version": "3.0.0",
3
+ "version": "3.0.1",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "exports": {