@moneko/core 4.4.4-beta.0 → 4.4.4-beta.2

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{join as e,parse as t,resolve as s}from"node:path";import{fileURLToPath as o}from"node:url";import{Worker as i}from"node:worker_threads";import{fileExists as r,loadFile as a}from"@moneko/utils";import n from"webpack";import m from"../utils/create-types.mjs";export class ModuleFederationExposesDeclarationPlugin{constructor(e){this.name="ModuleFederationExposesDeclarationPlugin",this.assetName="module-federation.d.ts",this.dts="",this.option=e,this.worker=new i(o(new URL("../worker/dts.mjs",import.meta.url))),this.worker.setMaxListeners(0),this.worker.postMessage({options:{compilerOptions:{isolatedModules:!1,outFile:this.assetName,verbatimModuleSyntax:!1},include:[...Object.values(e.exposes),"typings/**/*.d.ts"]}}),this.worker.once("message",e=>{this.dts=e,this.worker.terminate()})}apply(o){let{exposes:i}=this.option,p=Object.keys(i).map(e=>{let t=e.replace(/\.tsx?$/i,"");return{key:e,name:t,path:s(`types/${this.option.name}/${t}.d.ts`),originPath:i[e]}});o.hooks.thisCompilation.tap({name:this.name,stage:o.webpack.Compilation.PROCESS_ASSETS_STAGE_ADDITIONS},s=>{s.hooks.processAssets.tapPromise(this.name,async()=>{let o=p.map(async s=>{if(r(s.originPath)){let o=t(s.originPath),i=`export * from '${t(o.dir).name}/${o.name}'`;if("public-path"===o.name){let e=await a(s.originPath.replace(/\.mjs$/,".d.mts"));e&&(i=e)}return`${m(e(this.option.name,s.name),i)}`}return""}),i=await Promise.all(o);i.unshift(this.dts),s.emitAsset("module-federation.d.ts",new n.sources.RawSource(i.join("\n")),{javascriptModule:!1})})})}}
1
+ import{join as e,parse as t,resolve as o,sep as s}from"node:path";import{fileURLToPath as i}from"node:url";import{Worker as r}from"node:worker_threads";import{fileExists as a,loadFile as n}from"@moneko/utils";import m from"webpack";import{module_federation_schema as p}from"../process-env.mjs";import l from"../utils/create-types.mjs";export class ModuleFederationExposesDeclarationPlugin{constructor(e){this.name="ModuleFederationExposesDeclarationPlugin",this.assetName="module-federation.d.ts",this.dts="",this.option=e,this.worker=new r(i(new URL("../worker/dts.mjs",import.meta.url))),this.worker.setMaxListeners(0),this.worker.postMessage({options:{compilerOptions:{isolatedModules:!1,outFile:this.assetName,verbatimModuleSyntax:!1},include:[...Object.values(e.exposes),"typings/**/*.d.ts"]}}),this.worker.once("message",e=>{this.dts=e,this.worker.terminate()})}apply(i){let{exposes:r}=this.option,h=Object.keys(r).map(e=>{let t=e.replace(/\.tsx?$/i,"");return{key:e,name:t,path:o(`types/${this.option.name}/${t}.d.ts`),originPath:r[e]}});i.hooks.thisCompilation.tap({name:this.name,stage:i.webpack.Compilation.PROCESS_ASSETS_STAGE_ADDITIONS},o=>{o.hooks.processAssets.tapPromise(this.name,async()=>{let i=h.map(async o=>{if(a(o.originPath)){let i=t(o.originPath),r=`export * from '${t(i.dir).name}/${i.name}'`;if("public-path"===i.name){let e=await n(o.originPath.replace(/\.mjs$/,".d.mts"));e&&(r=e)}return[l(e(this.option.name,o.name),r),l(e(p,this.option.name,o.name).replace(s,":"),r)].join("\n")}return""}),r=await Promise.all(i);r.unshift(this.dts),o.emitAsset("module-federation.d.ts",new m.sources.RawSource(r.join("\n")),{javascriptModule:!1})})})}}
@@ -1 +1 @@
1
- import{join as e,relative as t}from"node:path";import r from"webpack";import o from"../commom/module-resolve.mjs";import s from"../commom/paths.mjs";import{CONFIG as m}from"../config.mjs";import a from"../utils/fetch-module-federation-dts.mjs";import{resolveProgram as l}from"../utils/index.mjs";import{ModuleFederationExposesDeclarationPlugin as i}from"./exposes-declararion.mjs";import{ExternalRemotesPlugin as p}from"./external-remotes.mjs";let n=r.NormalModuleReplacementPlugin,h=r.container.ModuleFederationPlugin,f={},u=[],c=m.moduleFederation?.map(r=>{let m={},p={},n={};if(Array.isArray(r.remotes))for(let e=0,t=r.remotes.length;e<t;e++){let t=r.remotes[e],o=t.alias||t.name,s=t.filename||"remote_entry.js";if(p[o]=`${t.name}@${t.host}/${s}`,Array.isArray(t.library))for(let e=0,r=t.library.length;e<r;e++)f[t.library[e]]=`${o}/${t.library[e]}`;a(t.host,t.name)}if(Array.isArray(r.exposes)){r.exposes.length>0&&!r.exposes.find(e=>"public-path"===e)&&r.exposes.push({name:"public-path",path:`./${t(s.programPath,e(s.corePath,"./polyfills/public-path.mjs"))}`});for(let e=0,t=r.exposes.length;e<t;e++){let t=r.exposes[e];if("string"==typeof t){let e=t.startsWith(".");m[`./${t}`]=o(e?l(t):t),e&&(n[t]=m[`./${t}`])}else if("[object Object]"===Object.prototype.toString.call(t)){let e=t.path.startsWith(".");m[`./${t.name}`]=o(e?l(t.path):t.path),e&&(n[`./${t.name}`]=m[`./${t.name}`])}}r.exposes?.length&&u.push(new i({exposes:n,name:r.name}))}return new h({filename:"remote_entry.js",...r,remotes:p,exposes:m})});c.length>0&&(c.push(new p),c.push(new n(/(.*)/,e=>{f[e.request]&&(e.request=f[e.request])})),u.forEach(e=>c.push(e))),m.env.injectRemoteReactRefresh=Object.keys(f).includes("react-dom");export default c;
1
+ import{join as e,parse as t,relative as r}from"node:path";import o from"webpack";import s from"../commom/module-resolve.mjs";import m from"../commom/paths.mjs";import{CONFIG as a}from"../config.mjs";import l from"../utils/fetch-module-federation-dts.mjs";import{resolveProgram as i}from"../utils/index.mjs";import{ModuleFederationExposesDeclarationPlugin as n}from"./exposes-declararion.mjs";import{ExternalRemotesPlugin as p}from"./external-remotes.mjs";let f=o.NormalModuleReplacementPlugin,h=o.container.ModuleFederationPlugin,c={},u=[];function d(e,r){let o=e.replace(/\.tsx?$/i,""),s=t(r);mf_vm.setData(o,{type:".tsx",source:()=>`export * from '${t(s.dir).name}/${s.name}'`})}let y=a.moduleFederation?.map(t=>{let o={},a={},p={};if(Array.isArray(t.remotes))for(let e=0,r=t.remotes.length;e<r;e++){let r=t.remotes[e],o=r.alias||r.name,s=r.filename||"remote_entry.js";if(a[o]=`${r.name}@${r.host}/${s}`,Array.isArray(r.library))for(let e=0,t=r.library.length;e<t;e++)c[r.library[e]]=`${o}/${r.library[e]}`;l(r.host,r.name)}if(Array.isArray(t.exposes)){t.exposes.length>0&&!t.exposes.find(e=>"public-path"===e)&&t.exposes.push({name:"public-path",path:`./${r(m.programPath,e(m.corePath,"./polyfills/public-path.mjs"))}`});for(let e=0,r=t.exposes.length;e<r;e++){let r=t.exposes[e];if("string"==typeof r){let e=r.startsWith(".");o[`./${r}`]=s(e?i(r):r),e&&(p[r]=o[`./${r}`],d(r,p[r]))}else if("[object Object]"===Object.prototype.toString.call(r)){let e=r.path.startsWith(".");o[`./${r.name}`]=s(e?i(r.path):r.path),e&&(p[`./${r.name}`]=o[`./${r.name}`],d(`./${r.name}`,p[`./${r.name}`]))}}t.exposes?.length&&u.push(new n({exposes:p,name:t.name}))}return new h({filename:"remote_entry.js",...t,remotes:a,exposes:o})});y.length>0&&(y.push(new p),y.push(new f(/(.*)/,e=>{c[e.request]&&(e.request=c[e.request])})),u.forEach(e=>y.push(e))),a.env.injectRemoteReactRefresh=Object.keys(c).includes("react-dom");export default y;
@@ -1 +1 @@
1
- import e from"webpack";import{CompressionPlugin as t}from"./plugin/compression.mjs";import{CopyPlugin as o}from"./plugin/copy.mjs";import{CssModuleDtsPlugin as i}from"./plugin/css-module-dts.mjs";import{HtmlPlugin as r}from"./plugin/html-plugin.mjs";import{ManifestPlugin as n}from"./plugin/manifest/index.mjs";import p from"./plugin/module-federation.mjs";import{VirtualModulePlugin as s}from"./plugin/virtual-module.mjs";import{app_vm as m}from"./vm/app.mjs";import{docs_vm as l}from"./vm/docs.mjs";import{example_vm as a}from"./vm/example.mjs";import{scope_vm as c}from"./vm/scope.mjs";import{sw_vm as h}from"./vm/sw.mjs";import{virtual_vm as f}from"./vm/virtual.mjs";import{CONFIG as u}from"./config.mjs";import{app_schema as g,docs_schema as d,example_schema as w,isLibrary as j,packageJson as v,scope_schema as b,service_worker_schema as y,virtual_schema as x}from"./process-env.mjs";let P="object"==typeof u.compression?u.compression:{},O=[...p,new s(m,g),new s(h,y),j&&new s(l,d),j&&new s(a,w),j&&new s(c,b),u.virtualModule&&new s(f,x),new o(u.copy),new e.EnvironmentPlugin(u.env),new e.DefinePlugin({"process.env":JSON.stringify(u.env)}),new e.IgnorePlugin({resourceRegExp:/\.d\.tsx?$/,contextRegExp:/\/(__(tests|mocks)__|test|spec|e2e)\//}),new i,...u.plugins].filter(Boolean);if(u.compression&&O.push(new t({algorithm:u.devServer.https?"brotli":"gzip",test:/\.(js|css|html|svg|ttf|woff|woff2|png|jpg|jpeg)$/,...P})),u.manifest&&O.push(new n(u.manifest)),u.htmlPluginOption){let e={charset:"UTF-8","X-UA-Compatible":{"http-equiv":"X-UA-Compatible",content:"IE=edge,Chrome=1"},HandheldFriendly:"true",MobileOptimized:"320","screen-orientation":"portrait","x5-orientation":"portrait",browsermode:"application","x5-page-mode":"app","msapplication-tap-highlight":"no","mobile-web-app-capable":"yes",renderer:"webkit",description:v.description,keywords:Array.isArray(v.keywords)?v.keywords.toString():"","http-equiv":"refresh",viewport:"width=device-width, initial-scale=1"};u.seo&&(e.relCanonical={rel:"canonical",href:`https://${u.seo.domain}${u.basename}`}),u.htmlPluginOption.meta&&Object.assign(e,u.htmlPluginOption.meta),O.push(new r({...u.htmlPluginOption,meta:e}))}if(u.fixBrowserRouter){let e=u.basename.split("/").filter(Boolean).length,t=`${Array(e).fill("..").join("/")+(e?"/":"")}404.html`,o=u.fixBrowserRouter.pathSegmentsToKeep??e;O.push(new r({filename:u.fixBrowserRouter.path??t,inject:!1,templateContent:()=>`<html lang="en"><head><title>Redirect</title><script>const pathKeep = ${o};const l = window.location;l.replace(l.protocol + '//' + l.hostname + (l.port ? ':' + l.port : '') + l.pathname.split('/').slice(0, 1 + pathKeep).join('/') + '/?/' + l.pathname.slice(1).split('/').slice(pathKeep).join('/').replace(/&/g, '~and~') + (l.search ? '&' + l.search.slice(1).replace(/&/g, '~and~') : '') + l.hash);</script></head><body></body></html>`}))}u.sourceMap&&O.push(new e.SourceMapDevToolPlugin(u.sourceMap));export default O;
1
+ import e from"webpack";import{CompressionPlugin as t}from"./plugin/compression.mjs";import{CopyPlugin as o}from"./plugin/copy.mjs";import{CssModuleDtsPlugin as i}from"./plugin/css-module-dts.mjs";import{HtmlPlugin as r}from"./plugin/html-plugin.mjs";import{ManifestPlugin as n}from"./plugin/manifest/index.mjs";import p from"./plugin/module-federation.mjs";import{VirtualModulePlugin as m}from"./plugin/virtual-module.mjs";import{app_vm as s}from"./vm/app.mjs";import{docs_vm as l}from"./vm/docs.mjs";import{example_vm as a}from"./vm/example.mjs";import{mf_vm as c}from"./vm/mf.mjs";import{scope_vm as h}from"./vm/scope.mjs";import{sw_vm as f}from"./vm/sw.mjs";import{virtual_vm as u}from"./vm/virtual.mjs";import{CONFIG as g}from"./config.mjs";import{app_schema as d,docs_schema as w,example_schema as j,isLibrary as v,module_federation_schema as b,packageJson as y,scope_schema as x,service_worker_schema as P,virtual_schema as O}from"./process-env.mjs";let k="object"==typeof g.compression?g.compression:{},R=[...p,new m(c,b),new m(s,d),new m(f,P),v&&new m(l,w),v&&new m(a,j),v&&new m(h,x),g.virtualModule&&new m(u,O),new o(g.copy),new e.EnvironmentPlugin(g.env),new e.DefinePlugin({"process.env":JSON.stringify(g.env)}),new e.IgnorePlugin({resourceRegExp:/\.d\.tsx?$/,contextRegExp:/\/(__(tests|mocks)__|test|spec|e2e)\//}),new i,...g.plugins].filter(Boolean);if(g.compression&&R.push(new t({algorithm:g.devServer.https?"brotli":"gzip",test:/\.(js|css|html|svg|ttf|woff|woff2|png|jpg|jpeg)$/,...k})),g.manifest&&R.push(new n(g.manifest)),g.htmlPluginOption){let e={charset:"UTF-8","X-UA-Compatible":{"http-equiv":"X-UA-Compatible",content:"IE=edge,Chrome=1"},HandheldFriendly:"true",MobileOptimized:"320","screen-orientation":"portrait","x5-orientation":"portrait",browsermode:"application","x5-page-mode":"app","msapplication-tap-highlight":"no","mobile-web-app-capable":"yes",renderer:"webkit",description:y.description,keywords:Array.isArray(y.keywords)?y.keywords.toString():"","http-equiv":"refresh",viewport:"width=device-width, initial-scale=1"};g.seo&&(e.relCanonical={rel:"canonical",href:`https://${g.seo.domain}${g.basename}`}),g.htmlPluginOption.meta&&Object.assign(e,g.htmlPluginOption.meta),R.push(new r({...g.htmlPluginOption,meta:e}))}if(g.fixBrowserRouter){let e=g.basename.split("/").filter(Boolean).length,t=`${Array(e).fill("..").join("/")+(e?"/":"")}404.html`,o=g.fixBrowserRouter.pathSegmentsToKeep??e;R.push(new r({filename:g.fixBrowserRouter.path??t,inject:!1,templateContent:()=>`<html lang="en"><head><title>Redirect</title><script>const pathKeep = ${o};const l = window.location;l.replace(l.protocol + '//' + l.hostname + (l.port ? ':' + l.port : '') + l.pathname.split('/').slice(0, 1 + pathKeep).join('/') + '/?/' + l.pathname.slice(1).split('/').slice(pathKeep).join('/').replace(/&/g, '~and~') + (l.search ? '&' + l.search.slice(1).replace(/&/g, '~and~') : '') + l.hash);</script></head><body></body></html>`}))}g.sourceMap&&R.push(new e.SourceMapDevToolPlugin(g.sourceMap));export default R;
@@ -19,6 +19,7 @@ export declare const docs_schema = 'docs';
19
19
  export declare const example_schema = 'example';
20
20
  export declare const scope_schema = 'scope';
21
21
  export declare const service_worker_schema = 'sw';
22
+ export declare const module_federation_schema = 'mf';
22
23
  /** 项目主要文件夹 */ export declare const mainDirectory: 'site' | 'src';
23
24
  export declare const jsxImportSource: string;
24
25
  export declare const framework: 'react' | 'solid-js';
@@ -1 +1 @@
1
- import o from"node:process";import e from"./commom/has-pkg.mjs";import r from"./commom/is-ci-environment.mjs";import{CUSTOMCONFIG as s}from"./commom/paths.mjs";import{readJson as t}from"./commom/read-json.mjs";import{convertToCamelCase as c,digest as p}from"./utils/index.mjs";export const packageJson=t(`${o.cwd()}/package.json`);delete packageJson.scripts;export const IS_WINDOW="win32"===o.platform;export const APPTYPE=o.env.APPTYPE;export const FRAMEWORK=o.env.FRAMEWORK??"react";export const NODE_ENV=o.env.NODE_ENV;export const isLibrary="library"===APPTYPE;export const isMicro="micro"===APPTYPE;export const isMobile="mobile"===APPTYPE;export const isReact="react"===FRAMEWORK;export const isSolid="solid"===FRAMEWORK;export const SSR="true"===o.env.SSR;export const app_schema="app";export const virtual_schema="vm";export const docs_schema="docs";export const example_schema="example";export const scope_schema="scope";export const service_worker_schema="sw";export const mainDirectory=isLibrary?"site":"src";export const jsxImportSource={react:"react",solid:"solid-js/h"}[FRAMEWORK];export const framework={react:"react",solid:"solid-js"}[FRAMEWORK];export const frameworkVersionStr=framework?t(`${framework}/package.json`).version:19;export const frameworkVersion=parseFloat(frameworkVersionStr);export const PACKAGENAME=packageJson.name;export const projectNameCamelCase=c(PACKAGENAME);export const coreName="@moneko/core";export const isDev="development"===NODE_ENV;export const refresh=!!(isDev&&e("solid"===FRAMEWORK?"solid-refresh":"react-refresh"));export const isCI=r();export const CACHE_NAME=p(`${PACKAGENAME}${s}${NODE_ENV}${o.argv[2]}`);
1
+ import o from"node:process";import e from"./commom/has-pkg.mjs";import r from"./commom/is-ci-environment.mjs";import{CUSTOMCONFIG as s}from"./commom/paths.mjs";import{readJson as t}from"./commom/read-json.mjs";import{convertToCamelCase as c,digest as m}from"./utils/index.mjs";export const packageJson=t(`${o.cwd()}/package.json`);delete packageJson.scripts;export const IS_WINDOW="win32"===o.platform;export const APPTYPE=o.env.APPTYPE;export const FRAMEWORK=o.env.FRAMEWORK??"react";export const NODE_ENV=o.env.NODE_ENV;export const isLibrary="library"===APPTYPE;export const isMicro="micro"===APPTYPE;export const isMobile="mobile"===APPTYPE;export const isReact="react"===FRAMEWORK;export const isSolid="solid"===FRAMEWORK;export const SSR="true"===o.env.SSR;export const app_schema="app";export const virtual_schema="vm";export const docs_schema="docs";export const example_schema="example";export const scope_schema="scope";export const service_worker_schema="sw";export const module_federation_schema="mf";export const mainDirectory=isLibrary?"site":"src";export const jsxImportSource={react:"react",solid:"solid-js/h"}[FRAMEWORK];export const framework={react:"react",solid:"solid-js"}[FRAMEWORK];export const frameworkVersionStr=framework?t(`${framework}/package.json`).version:19;export const frameworkVersion=parseFloat(frameworkVersionStr);export const PACKAGENAME=packageJson.name;export const projectNameCamelCase=c(PACKAGENAME);export const coreName="@moneko/core";export const isDev="development"===NODE_ENV;export const refresh=!!(isDev&&e("solid"===FRAMEWORK?"solid-refresh":"react-refresh"));export const isCI=r();export const CACHE_NAME=m(`${PACKAGENAME}${s}${NODE_ENV}${o.argv[2]}`);
@@ -1 +1 @@
1
- import{projectName as t,version as e}from"app:info";let a=self;export async function precaching(){let i=`${t}-core-${e}`,n=`${t}-runtime-${e}`;async function s(t){let e=await caches.open(n),a=await e.match(t);if(a)return a;let i=await fetch(t);return i.ok&&"basic"===i.type&&e.put(t,i.clone()),i}async function c(t){let e=await caches.open(n);try{let a=await fetch(t);return a.ok&&"basic"===a.type&&e.put(t,a.clone()),a}catch{let a=await e.match(t);if(a)return a;return new Response("Offline",{status:503,statusText:"Offline"})}}a.addEventListener("install",t=>{t.waitUntil((async()=>{let t=await caches.open(i),e=await fetch("/app-resource.json").then(t=>t.json()),n=(await Promise.allSettled(e.map(t=>t.startsWith("/")?t:`/${t}`).map(e=>t.add(e)))).filter(t=>"fulfilled"===t.status).length;console.info(`[SW] Precaching ${n}/${e.length} assets`),await a.skipWaiting()})())}),a.addEventListener("activate",t=>{t.waitUntil((async()=>{let t=await caches.keys();await Promise.all(t.filter(t=>![i,n].includes(t)).map(t=>caches.delete(t))),await a.clients.claim(),(await a.clients.matchAll({type:"window"})).forEach(t=>{t.postMessage({type:"SW_UPDATED",version:e})})})())}),a.addEventListener("fetch",t=>{let{request:e}=t;if("GET"!==e.method)return;let a=new URL(e.url);"navigate"===e.mode?t.respondWith(c(e)):a.origin===location.origin&&/\.(js|css|png|jpg|jpeg|svg|webp|woff2?)$/.test(a.pathname)&&t.respondWith(s(e))}),a.addEventListener("message",t=>{t.data?.type==="SKIP_WAITING"&&a.skipWaiting()})}
1
+ import{projectName as t,version as e}from"app:info";let a=self;export async function precaching(){let i=`${t}-core-${e}`,n=`${t}-runtime-${e}`;async function s(t){let e=await caches.open(n),a=await e.match(t);if(a)return a;let i=await fetch(t);return i.ok&&"basic"===i.type&&e.put(t,i.clone()),i}async function c(t){let e=await caches.open(n);try{let a=await fetch(t);return a.ok&&"basic"===a.type&&e.put(t,a.clone()),a}catch{let a=await e.match(t);if(a)return a;return new Response("Offline",{status:503,statusText:"Offline"})}}a.addEventListener("install",t=>{t.waitUntil((async()=>{let t=await caches.open(i),e=await fetch(new URL("/app-resource.json",__webpack_public_path__)).then(t=>t.json()),n=(await Promise.allSettled(e.filter(t=>!t.endsWith(".map")).map(t=>t.startsWith("/")?t:`/${t}`).map(e=>t.add(e)))).filter(t=>"fulfilled"===t.status).length;console.info(`[SW] Precaching ${n}/${e.length} assets`),await a.skipWaiting()})())}),a.addEventListener("activate",t=>{t.waitUntil((async()=>{let t=await caches.keys();await Promise.all(t.filter(t=>![i,n].includes(t)).map(t=>caches.delete(t))),await a.clients.claim(),(await a.clients.matchAll({type:"window"})).forEach(t=>{t.postMessage({type:"SW_UPDATED",version:e})})})())}),a.addEventListener("fetch",t=>{let{request:e}=t;if("GET"!==e.method)return;let a=new URL(e.url);"navigate"===e.mode?t.respondWith(c(e)):a.origin===location.origin&&/\.(js|css|png|jpg|jpeg|svg|webp|woff2?)$/.test(a.pathname)&&t.respondWith(s(e))}),a.addEventListener("message",t=>{t.data?.type==="SKIP_WAITING"&&a.skipWaiting()})}
package/lib/vm/dts.mjs CHANGED
@@ -1 +1 @@
1
- import{join as e}from"node:path";import{loadFileSync as t,updateFile as o,updateFileSync as r}from"@moneko/utils";import s from"../commom/paths.mjs";import n from"../commom/reactive-object.mjs";import{readJson as m}from"../commom/read-json.mjs";import{app_schema as a,APPTYPE as i,CACHE_NAME as p,FRAMEWORK as d,framework as c,frameworkVersionStr as f,packageJson as l,service_worker_schema as v,SSR as u,virtual_schema as $}from"../process-env.mjs";import j from"../utils/create-types.mjs";import{generateDeclaration as y}from"../utils/dts.mjs";import{convertToCamelCase as M,transformModule as g}from"../utils/index.mjs";export const dts_path=e(s.nodeModules,"@types",p,"index.d.ts");export const vm_dts=new n({});export function getEnvDts(e){return`${e};declare global {import AppEnv from '${a}:env';type ImportMetaEnv = Readonly<typeof AppEnv>;interface ImportMeta {readonly env: ImportMetaEnv;}namespace NodeJS {interface ProcessEnv extends ImportMetaEnv {readonly [key: string]: string | number | boolean | undefined;}}}`}vm_dts.on("change",()=>{let e=Object.values(vm_dts.data).join("\n");o(dts_path,e)});export function initDts(o){let n=j(`${a}:env`,y(getEnvDts(g(o.env)),`${a}:env`));vm_dts.setData(`${a}:env`,n);let h=j(`${a}:info`,y(g({...m(e(s.programPath,"package.json")),projectName:M(l.name),ssr:u,type:i,frameworkVersion:f,framework:c,base:o.basename,routerMode:o.routerMode,prefixCls:o.prefixCls,theme:o.theme}),`${a}:info`));vm_dts.setData(`${a}:info`,h),vm_dts.setData(`${a}:resource`,j(`${a}:resource`,"const resource: string[];export default resource;")),vm_dts.setData(`${a}:manifest`,j(`${a}:manifest`,'import type { WebManifest } from "@moneko/core";const manifest: WebManifest;export default manifest;')),vm_dts.setData(`${v}:precaching`,j(`${v}:precaching`,t(e(s.corePath,"./service-worker/precaching.js.d.ts"))||"")),o.virtualModule&&Object.keys(o.virtualModule).map(e=>{let t=g(o.virtualModule[e]),r=`${$}:${e}`;vm_dts.setData(r,j(r,y(t,r)))});let x=o.moduleFederation?.flatMap(e=>Array.isArray(e.remotes)?e.remotes.map(e=>e.name):[]).filter(Boolean);r(dts_path,Object.values(vm_dts.data).join("\n")),r(e(s.nodeModules,"@moneko/init.d.json"),JSON.stringify({extends:`@moneko/${d}/base`,compilerOptions:{types:[`@moneko/${d}/env.d.ts`,`@types/${p}/index.d.ts`,...x.map(e=>`@types/${p}/${e}.d.ts`)]}}))}
1
+ import{join as e}from"node:path";import{loadFileSync as t,updateFile as o,updateFileSync as r}from"@moneko/utils";import s from"../commom/paths.mjs";import n from"../commom/reactive-object.mjs";import{readJson as m}from"../commom/read-json.mjs";import{app_schema as a,APPTYPE as i,CACHE_NAME as p,FRAMEWORK as d,framework as l,frameworkVersionStr as c,packageJson as v,service_worker_schema as f,SSR as u,virtual_schema as j}from"../process-env.mjs";import $ from"../utils/create-types.mjs";import{generateDeclaration as y}from"../utils/dts.mjs";import{convertToCamelCase as h,transformModule as g}from"../utils/index.mjs";export const dts_path=e(s.nodeModules,"@types",p,"index.d.ts");export const vm_dts=new n({});export function getEnvDts(e){return`${e};declare global {import AppEnv from '${a}:env';type ImportMetaEnv = Readonly<typeof AppEnv>;interface ImportMeta {readonly env: ImportMetaEnv;}namespace NodeJS {interface ProcessEnv extends ImportMetaEnv {readonly [key: string]: string | number | boolean | undefined;}}}`}vm_dts.on("change",()=>{let e=Object.values(vm_dts.data).join("\n");o(dts_path,e)});export function initDts(o){let n=$(`${a}:env`,y(getEnvDts(g(o.env)),`${a}:env`));vm_dts.setData(`${a}:env`,n);let M=$(`${a}:info`,y(g({...m(e(s.programPath,"package.json")),projectName:h(v.name),ssr:u,type:i,frameworkVersion:c,framework:l,base:o.basename,routerMode:o.routerMode,prefixCls:o.prefixCls,theme:o.theme}),`${a}:info`));vm_dts.setData(`${a}:info`,M),vm_dts.setData(`${f}:precaching`,$(`${f}:precaching`,t(e(s.corePath,"./service-worker/precaching.d.ts"))||"")),o.virtualModule&&Object.keys(o.virtualModule).map(e=>{let t=g(o.virtualModule[e]),r=`${j}:${e}`;vm_dts.setData(r,$(r,y(t,r)))});let x=o.moduleFederation?.flatMap(e=>Array.isArray(e.remotes)?e.remotes.map(e=>e.name):[]).filter(Boolean);r(dts_path,Object.values(vm_dts.data).join("\n")),r(e(s.nodeModules,"@moneko/init.d.json"),JSON.stringify({extends:`@moneko/${d}/base`,compilerOptions:{types:[`@moneko/${d}/env.d.ts`,`@types/${p}/index.d.ts`,...x.map(e=>`@types/${p}/${e}.d.ts`)]}}))}
@@ -0,0 +1,3 @@
1
+ import ReactiveObject from '../commom/reactive-object.mjs';
2
+ import type { VirtualModules } from '../plugin/virtual-module.mjs';
3
+ export declare const mf_vm: ReactiveObject<VirtualModules>;
package/lib/vm/mf.mjs ADDED
@@ -0,0 +1 @@
1
+ import m from"../commom/reactive-object.mjs";export const mf_vm=new m({});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@moneko/core",
3
- "version": "4.4.4-beta.0",
3
+ "version": "4.4.4-beta.2",
4
4
  "description": "core",
5
5
  "main": "lib/index.mjs",
6
6
  "type": "module",
@@ -583,14 +583,18 @@ declare interface HttpUriOptions {
583
583
  }
584
584
 
585
585
  type ModuleFederationPluginOption = ConstructorParameters<typeof container.ModuleFederationPlugin>[number];
586
- export declare interface ModuleFederationOption extends ModuleFederationPluginOption {
586
+
587
+ type RequiredModuleFederationPluginOption = Required<ModuleFederationPluginOption>;
588
+ type LibraryOption = RequiredModuleFederationPluginOption['library'];
589
+ interface LibraryOptions extends LibraryOption {
590
+ type: 'var' | 'module' | 'assign' | 'assign-properties' | 'this' | 'window' | 'self' | 'global' | 'commonjs' | 'commonjs2' | 'commonjs-module' | 'commonjs-static' | 'amd' | 'amd-require' | 'umd' | 'umd2' | 'jsonp' | 'system';
591
+ }
592
+ export declare interface ModuleFederationOption extends Omit<ModuleFederationPluginOption, 'remotes' | 'exposes' | 'library'> {
587
593
  /** 模块名称,唯一性,不能重名 */
588
594
  name: string;
589
595
  /** 打包的模块文件名 默认: remote_entry.js */
590
596
  filename?: string;
591
- library?: {
592
- type: 'var' | 'module' | 'assign' | 'assign-properties' | 'this' | 'window' | 'self' | 'global' | 'commonjs' | 'commonjs2' | 'commonjs-module' | 'commonjs-static' | 'amd' | 'amd-require' | 'umd' | 'umd2' | 'jsonp' | 'system';
593
- };
597
+ library?: LibraryOptions;
594
598
  /** 表示作为 Host 时, 去消费哪些 Remote */
595
599
  remotes?: {
596
600
  /** 远程模块名称 */