@moneko/core 4.2.1 → 4.2.2-beta.0

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 as t,readFileSync as s}from"node:fs";import{basename as e,join as i,resolve as o}from"node:path";import n from"webpack";import{isDev as r,packageJson as a}from"../../process-env.mjs";export*from"./types.mjs";export class ManifestPlugin{constructor(t){this.name="ManifestPlugin",this.options={filename:"site.webmanifest",name:a.name,description:a.description,scope:"/",display:"standalone",background_color:"#fff",icons:[{src:"https://h5static.dewucdn.com/node-common/718d5e10-576d-8b14-b0b1-e4c58c3b3f40.webp",type:"image/webp",sizes:"512x512"}]},this.options={...this.options,...t}}getPublicPath(t){if(this.options.publicPath)return this.options.publicPath;let s=t.getAssetPath(t.outputOptions.publicPath,{hash:t.hash}),e="auto"===s?"/":s;return e.length&&!e.endsWith("/")&&(e+="/"),e}addAsset(r,a,p){if(!p)return;let c=this.getPublicPath(a);return p.map(p=>{let h={...p};if(h.src&&!h.src.startsWith("http")){let p=o(r.context,h.src);if(t(p)){let t=e(h.src),o=s(p);a.emitAsset(t,new n.sources.RawSource(o),{javascriptModule:!1}),h.src=i(c,t)}else a.warnings.push(new n.WebpackError(`Asset file ${p} does not exist`))}return h})}apply(t){let s=this.name,{filename:e,start_url:i,icons:o,screenshots:p,...c}=this.options;t.hooks.compilation.tap(s,h=>{h.hooks.processAssets.tap({name:s,stage:n.Compilation.PROCESS_ASSETS_STAGE_ADDITIONAL},()=>{let s={...c,start_url:i??this.getPublicPath(h),screenshots:this.addAsset(t,h,p),icons:this.addAsset(t,h,o),version:`${a.version}(${r?"Dev":h.fullHash})`};h.emitAsset(e,new t.webpack.sources.RawSource(JSON.stringify(s)),{javascriptModule:!1})})})}}
1
+ import{existsSync as t,readFileSync as s}from"node:fs";import{basename as e,join as i,resolve as o}from"node:path";import a from"webpack";import{isDev as r,packageJson as n}from"../../process-env.mjs";import{app_basic as p}from"../../vm/app.mjs";export*from"./types.mjs";export class ManifestPlugin{constructor(t){this.name="ManifestPlugin",this.options={filename:"site.webmanifest",name:n.name,description:n.description,scope:"/",display:"standalone",background_color:"#fff",icons:[{src:"https://h5static.dewucdn.com/node-common/718d5e10-576d-8b14-b0b1-e4c58c3b3f40.webp",type:"image/webp",sizes:"512x512"}]},this.options={...this.options,...t}}getPublicPath(t){if(this.options.publicPath)return this.options.publicPath;let s=t.getAssetPath(t.outputOptions.publicPath,{hash:t.hash}),e="auto"===s?"/":s;return e.length&&!e.endsWith("/")&&(e+="/"),e}addAsset(r,n,p){if(!p)return;let c=this.getPublicPath(n);return p.map(p=>{let h={...p};if(h.src&&!h.src.startsWith("http")){let p=o(r.context,h.src);if(t(p)){let t=e(h.src),o=s(p);n.emitAsset(t,new a.sources.RawSource(o),{javascriptModule:!1}),h.src=i(c,t)}else n.warnings.push(new a.WebpackError(`Asset file ${p} does not exist`))}return h})}apply(t){let s=this.name,{filename:e,start_url:i,icons:o,screenshots:c,...h}=this.options;t.hooks.compilation.tap(s,m=>{m.hooks.processAssets.tap({name:s,stage:a.Compilation.PROCESS_ASSETS_STAGE_ADDITIONAL},s=>{let a={...h,start_url:i??this.getPublicPath(m),screenshots:this.addAsset(t,m,c),icons:this.addAsset(t,m,o),version:`${n.version}(${r?"Dev":m.fullHash})`};m.emitAsset(e,new t.webpack.sources.RawSource(JSON.stringify(a)),{javascriptModule:!1}),p.setData("manifest",a),p.setData("resource",Object.keys(s))})})}}
package/lib/vm/app.mjs CHANGED
@@ -1 +1 @@
1
- import{join as e}from"node:path";import{getAppEntry as r,getAppFallback as o,getAppMergeRouter as m,getAppNormalizeCss as t,getAppPrefixRouter as s,getAppRem as a,getAppSuspense as p}from"@moneko/mdx";import n,{routeDir as i}from"../commom/paths.mjs";import f from"../commom/reactive-object.mjs";import{readJson as l}from"../commom/read-json.mjs";import{CONFIG as c}from"../config.mjs";import d from"../plugin/module-federation.mjs";import{app_schema as u,APPTYPE as j,FRAMEWORK as x,framework as y,frameworkVersionStr as g,SSR as h}from"../process-env.mjs";import k from"../utils/create-types.mjs";import{generateDeclaration as v}from"../utils/dts.mjs";import{convertToCamelCase as C,transformModule as b}from"../utils/index.mjs";import{vm_dts as D}from"./dts.mjs";import{generateLocales as w}from"./locales.mjs";import z from"./render-app.mjs";import{getRouter as M}from"./routes.mjs";export const app_vm=new f({env:()=>{let e=`${u}:env`,r=b(c.env);return D.setData(e,k(e,v(r,e))),r},info:r=>{let o=e(n.programPath,"package.json"),m=l(o),t=b({...m,projectName:C(m.name),ssr:h,base:c.basename,type:j,routerMode:c.routerMode,prefixCls:c.prefixCls,theme:c.theme,frameworkVersion:g,framework:y}),s=`${u}:info`;return r?.addDependency(o),D.setData(s,k(s,v(t,s))),t},render:{type:".tsx",source:()=>"react"===x?z:""},entry:()=>r(e(c.alias["@"],"./index.ts"),!!d.length,!!c.rem,!!c.normalizeCss,j,x),fallback:()=>o(c.fallbackCompPath),"merge-router":()=>m(),"prefix-router":()=>s(),suspense:{type:".tsx",source:()=>p(j,x)},routes:e=>(e.addContextDependency(i),M()),locals:r=>{let o=e(c.alias["@"],"./locales");return r.addContextDependency(o),w()},normalize:{type:".css",source:()=>t()},rem:()=>a(c.rem?.designSize||1680)});
1
+ import{join as e}from"node:path";import{getAppEntry as r,getAppFallback as t,getAppMergeRouter as o,getAppNormalizeCss as m,getAppPrefixRouter as s,getAppRem as a,getAppSuspense as n}from"@moneko/mdx";import p,{routeDir as i}from"../commom/paths.mjs";import c from"../commom/reactive-object.mjs";import{readJson as f}from"../commom/read-json.mjs";import{CONFIG as d}from"../config.mjs";import l from"../plugin/module-federation.mjs";import{app_schema as u,APPTYPE as j,FRAMEWORK as x,framework as y,frameworkVersionStr as D,SSR as g}from"../process-env.mjs";import b from"../utils/create-types.mjs";import{generateDeclaration as C}from"../utils/dts.mjs";import{convertToCamelCase as h,transformModule as k}from"../utils/index.mjs";import{vm_dts as v}from"./dts.mjs";import{generateLocales as $}from"./locales.mjs";import w from"./render-app.mjs";import{getRouter as _}from"./routes.mjs";export const app_basic=new c({manifest:{},resource:[]});export const app_vm=new c({env:()=>{let e=`${u}:env`,r=k(d.env);return v.setData(e,b(e,C(r,e))),r},info:r=>{let t=e(p.programPath,"package.json"),o=f(t),m=k({...o,projectName:h(o.name),ssr:g,base:d.basename,type:j,routerMode:d.routerMode,prefixCls:d.prefixCls,theme:d.theme,frameworkVersion:D,framework:y}),s=`${u}:info`;return r?.addDependency(t),v.setData(s,b(s,C(m,s))),m},render:{type:".tsx",source:()=>"react"===x?w:""},entry:()=>r(e(d.alias["@"],"./index.ts"),!!l.length,!!d.rem,!!d.normalizeCss,j,x),fallback:()=>t(d.fallbackCompPath),"merge-router":()=>o(),"prefix-router":()=>s(),suspense:{type:".tsx",source:()=>n(j,x)},routes:e=>(e.addContextDependency(i),_()),locals:r=>{let t=e(d.alias["@"],"./locales");return r.addContextDependency(t),$()},normalize:{type:".css",source:()=>m()},rem:()=>a(d.rem?.designSize||1680),manifest:e=>{let r=`${u}:manifest`,t=`export default ${app_basic.getData("manifest")};`;return v.setData(r,b(r,C(t,r))),e.addContextDependency(d.alias["@"]),t},resource:e=>{let r=`${u}:resource`,t=`export default ${app_basic.getData("resource")};`;return v.setData(r,b(r,C(t,r))),e.addContextDependency(d.alias["@"]),t}});
@@ -1,3 +1,9 @@
1
1
  import ReactiveObject from '../commom/reactive-object.mjs';
2
+ import type { WebManifest } from '../plugin/manifest/types.mjs';
2
3
  import type { VirtualModules } from '../plugin/virtual-module.mjs';
4
+ export declare const app_basic: ReactiveObject<{
5
+ manifest: WebManifest & {
6
+ resource: string[];
7
+ };
8
+ }>;
3
9
  export declare const app_vm: ReactiveObject<VirtualModules>;
package/lib/vm/dts.mjs CHANGED
@@ -1 +1 @@
1
- import{join as e}from"node:path";import{updateFile as t,updateFileSync as o}from"@moneko/utils";import s from"../commom/paths.mjs";import m from"../commom/reactive-object.mjs";import{readJson as r}from"../commom/read-json.mjs";import{app_schema as a,APPTYPE as n,CACHE_NAME as i,FRAMEWORK as d,framework as p,frameworkVersionStr as l,packageJson as f,SSR as v,virtual_schema as u}from"../process-env.mjs";import c from"../utils/create-types.mjs";import{generateDeclaration as j}from"../utils/dts.mjs";import{convertToCamelCase as $,transformModule as y}from"../utils/index.mjs";export const dts_path=e(s.nodeModules,"@types",i,"index.d.ts");export const vm_dts=new m({});vm_dts.on("change",()=>{let e=Object.values(vm_dts.data).join("\n");t(dts_path,e)});export function initDts(t){let m=c(`${a}:env`,j(y(t.env),`${a}:env`));vm_dts.setData(`${a}:env`,m);let _=c(`${a}:info`,j(y({...r(e(s.programPath,"package.json")),projectName:$(f.name),ssr:v,type:n,frameworkVersion:l,framework:p,base:t.basename,routerMode:t.routerMode,prefixCls:t.prefixCls,theme:t.theme}),`${a}:info`));vm_dts.setData(`${a}:info`,_),t.virtualModule&&Object.keys(t.virtualModule).map(e=>{let o=y(t.virtualModule[e]),s=`${u}:${e}`;vm_dts.setData(s,c(s,j(o,s)))});let h=t.moduleFederation?.flatMap(e=>Array.isArray(e.remotes)?e.remotes.map(e=>e.name):[]).filter(Boolean);o(dts_path,Object.values(vm_dts.data).join("\n")),o(e(s.nodeModules,"@moneko/init.d.json"),JSON.stringify({extends:`@moneko/${d}/base`,compilerOptions:{types:[`@moneko/${d}/env.d.ts`,`@types/${i}/index.d.ts`,...h.map(e=>`@types/${i}/${e}.d.ts`)]}}))}
1
+ import{join as e}from"node:path";import{updateFile as t,updateFileSync as o}from"@moneko/utils";import s from"../commom/paths.mjs";import m from"../commom/reactive-object.mjs";import{readJson as r}from"../commom/read-json.mjs";import{app_schema as a,APPTYPE as n,CACHE_NAME as i,FRAMEWORK as d,framework as p,frameworkVersionStr as l,packageJson as f,SSR as u,virtual_schema as v}from"../process-env.mjs";import c from"../utils/create-types.mjs";import{generateDeclaration as j}from"../utils/dts.mjs";import{convertToCamelCase as $,transformModule as _}from"../utils/index.mjs";export const dts_path=e(s.nodeModules,"@types",i,"index.d.ts");export const vm_dts=new m({});vm_dts.on("change",()=>{let e=Object.values(vm_dts.data).join("\n");t(dts_path,e)});export function initDts(t){let m=c(`${a}:env`,j(_(t.env),`${a}:env`));vm_dts.setData(`${a}:env`,m);let x=c(`${a}:info`,j(_({...r(e(s.programPath,"package.json")),projectName:$(f.name),ssr:u,type:n,frameworkVersion:l,framework:p,base:t.basename,routerMode:t.routerMode,prefixCls:t.prefixCls,theme:t.theme}),`${a}:info`));vm_dts.setData(`${a}:info`,x),vm_dts.setData(`${a}:resource`,"export default string[];"),vm_dts.setData(`${a}:manifest`,"export default WebManifest;"),t.virtualModule&&Object.keys(t.virtualModule).map(e=>{let o=_(t.virtualModule[e]),s=`${v}:${e}`;vm_dts.setData(s,c(s,j(o,s)))});let y=t.moduleFederation?.flatMap(e=>Array.isArray(e.remotes)?e.remotes.map(e=>e.name):[]).filter(Boolean);o(dts_path,Object.values(vm_dts.data).join("\n")),o(e(s.nodeModules,"@moneko/init.d.json"),JSON.stringify({extends:`@moneko/${d}/base`,compilerOptions:{types:[`@moneko/${d}/env.d.ts`,`@types/${i}/index.d.ts`,...y.map(e=>`@types/${i}/${e}.d.ts`)]}}))}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@moneko/core",
3
- "version": "4.2.1",
3
+ "version": "4.2.2-beta.0",
4
4
  "description": "core",
5
5
  "main": "lib/index.mjs",
6
6
  "type": "module",