@moneko/core 4.2.1 → 4.2.2-beta.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 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 c}from"../../vm/basic.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,c){if(!c)return;let p=this.getPublicPath(n);return c.map(c=>{let h={...c};if(h.src&&!h.src.startsWith("http")){let c=o(r.context,h.src);if(t(c)){let t=e(h.src),o=s(c);n.emitAsset(t,new a.sources.RawSource(o),{javascriptModule:!1}),h.src=i(p,t)}else n.warnings.push(new a.WebpackError(`Asset file ${c} does not exist`))}return h})}apply(t){let s=this.name,{filename:e,start_url:i,icons:o,screenshots:p,...h}=this.options;t.hooks.compilation.tap(s,m=>{m.hooks.processAssets.tap({name:s,stage:a.Compilation.PROCESS_ASSETS_STAGE_SUMMARIZE},s=>{let a={...h,start_url:i??this.getPublicPath(m),screenshots:this.addAsset(t,m,p),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}),c.setData("manifest",a),c.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 o,getAppMergeRouter as t,getAppNormalizeCss as m,getAppPrefixRouter as s,getAppRem as a,getAppSuspense as n}from"@moneko/mdx";import i,{routeDir as p}from"../commom/paths.mjs";import f from"../commom/reactive-object.mjs";import{readJson as d}from"../commom/read-json.mjs";import{CONFIG as c}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 g,SSR as D}from"../process-env.mjs";import C from"../utils/create-types.mjs";import{generateDeclaration as h}from"../utils/dts.mjs";import{convertToCamelCase as b,transformModule as k}from"../utils/index.mjs";import{app_basic as v}from"./basic.mjs";import{vm_dts as $}from"./dts.mjs";import{generateLocales as w}from"./locales.mjs";import z from"./render-app.mjs";import{getRouter as N}from"./routes.mjs";export const app_vm=new f({env:()=>{let e=`${u}:env`,r=k(c.env);return $.setData(e,C(e,h(r,e))),r},info:r=>{let o=e(i.programPath,"package.json"),t=d(o),m=k({...t,projectName:b(t.name),ssr:D,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),$.setData(s,C(s,h(m,s))),m},render:{type:".tsx",source:()=>"react"===x?z:""},entry:()=>r(e(c.alias["@"],"./index.ts"),!!l.length,!!c.rem,!!c.normalizeCss,j,x),fallback:()=>o(c.fallbackCompPath),"merge-router":()=>t(),"prefix-router":()=>s(),suspense:{type:".tsx",source:()=>n(j,x)},routes:e=>(e.addContextDependency(p),N()),locals:r=>{let o=e(c.alias["@"],"./locales");return r.addContextDependency(o),w()},normalize:{type:".css",source:()=>m()},rem:()=>a(c.rem?.designSize||1680),manifest:e=>(e.addContextDependency(c.alias["@"]),`export default ${JSON.stringify(v.getData("manifest"))};`),resource:e=>(e.addContextDependency(c.alias["@"]),`export default ${JSON.stringify(v.getData("resource"))};`)});
@@ -0,0 +1 @@
1
+ import e from"../commom/reactive-object.mjs";export const app_basic=new e({manifest:{},resource:[]});
@@ -0,0 +1,8 @@
1
+ import ReactiveObject from '../commom/reactive-object.mjs';
2
+ import type { WebManifest } from '../plugin/manifest/types.mjs';
3
+ interface AppBasic {
4
+ manifest: WebManifest;
5
+ resource: string[];
6
+ }
7
+ export declare const app_basic: ReactiveObject<AppBasic>;
8
+ export { };
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.1",
4
4
  "description": "core",
5
5
  "main": "lib/index.mjs",
6
6
  "type": "module",
package/lib/vm/dts.mjs DELETED
@@ -1 +0,0 @@
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,5 +0,0 @@
1
- import type { ConfigType } from '../../typings/global.js';
2
- import ReactiveObject from '../commom/reactive-object.mjs';
3
- export declare const dts_path: string;
4
- export declare const vm_dts: ReactiveObject<Record<string, string>>;
5
- export declare function initDts(config: ConfigType): void;