@moneko/core 4.2.2-beta.1 → 4.2.2-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.
- package/lib/vm/dts.mjs +1 -0
- package/lib/vm/dts.mjs.d.ts +5 -0
- package/package.json +1 -1
package/lib/vm/dts.mjs
ADDED
|
@@ -0,0 +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 u,virtual_schema as c}from"../process-env.mjs";import v 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=v(`${a}:env`,j(_(t.env),`${a}:env`));vm_dts.setData(`${a}:env`,m);let x=v(`${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`,v(`${a}:resource`,"const resource: string[];export default resource;")),vm_dts.setData(`${a}:manifest`,v(`${a}:manifest`,'import type { WebManifest } from "@moneko/core";export default WebManifest;')),t.virtualModule&&Object.keys(t.virtualModule).map(e=>{let o=_(t.virtualModule[e]),s=`${c}:${e}`;vm_dts.setData(s,v(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`)]}}))}
|
|
@@ -0,0 +1,5 @@
|
|
|
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;
|