@moneko/core 3.9.17 → 3.9.18-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.
Files changed (155) hide show
  1. package/lib/build/common.d.mts +3 -0
  2. package/lib/build/common.mjs +1 -0
  3. package/lib/build/server.d.mts +3 -0
  4. package/lib/build/server.mjs +1 -0
  5. package/lib/build.mjs +1 -0
  6. package/lib/{common.d.ts → common.d.mts} +1 -1
  7. package/lib/common.mjs +1 -0
  8. package/lib/{config.d.ts → config.d.mts} +1 -1
  9. package/lib/config.mjs +1 -0
  10. package/lib/dev/config.d.mts +6 -0
  11. package/lib/dev/config.mjs +3 -0
  12. package/lib/dev/mock.d.mts +40 -0
  13. package/lib/dev/mock.mjs +1 -0
  14. package/lib/{net.d.ts → dev/net.d.mts} +1 -1
  15. package/lib/dev/net.mjs +1 -0
  16. package/lib/dev/proxy.d.mts +7 -0
  17. package/lib/dev/proxy.mjs +1 -0
  18. package/lib/dev.mjs +1 -0
  19. package/lib/index.d.mts +16 -0
  20. package/lib/index.mjs +1 -0
  21. package/lib/loader/ts-doc.d.cts +1 -1
  22. package/lib/module.config.d.mts +3 -0
  23. package/lib/module.config.mjs +1 -0
  24. package/lib/options/favicon.ico +0 -0
  25. package/lib/{html-plugin-option.d.ts → options/html-plugin-option.d.mts} +1 -1
  26. package/lib/options/html-plugin-option.mjs +11 -0
  27. package/lib/{minify.d.ts → options/js-minify.d.mts} +2 -2
  28. package/lib/options/js-minify.mjs +1 -0
  29. package/lib/options/jsx-dom-expressions.d.mts +10 -0
  30. package/lib/options/jsx-dom-expressions.mjs +1 -0
  31. package/lib/options/modify-vars.mjs +1 -0
  32. package/lib/options/split-chunk.d.mts +4 -0
  33. package/lib/options/split-chunk.mjs +1 -0
  34. package/lib/options/swcrc.d.mts +3 -0
  35. package/lib/options/swcrc.mjs +1 -0
  36. package/lib/{paths.d.ts → paths.d.mts} +4 -2
  37. package/lib/paths.mjs +1 -0
  38. package/lib/plugin/{add-entry-attribute.d.ts → add-entry-attribute.d.mts} +2 -3
  39. package/lib/plugin/add-entry-attribute.mjs +1 -0
  40. package/lib/plugin/{external-remotes.js → external-remotes.mjs} +1 -1
  41. package/lib/plugin/{lightningcss-plugin.d.ts → lightningcss-plugin.d.mts} +2 -2
  42. package/lib/plugin/lightningcss-plugin.mjs +1 -0
  43. package/lib/plugin/module-federation.mjs +1 -0
  44. package/lib/plugin/override-resolve.mjs +1 -0
  45. package/lib/plugin/{virtual-module.d.ts → virtual-module.d.mts} +2 -3
  46. package/lib/plugin/virtual-module.mjs +1 -0
  47. package/lib/plugins.config.mjs +1 -0
  48. package/lib/polyfills/polyfills.mjs +1 -0
  49. package/lib/polyfills/replace-children.mjs +1 -0
  50. package/lib/polyfills/targets.mjs +1 -0
  51. package/lib/{process-env.d.ts → process-env.d.mts} +2 -2
  52. package/lib/process-env.mjs +1 -0
  53. package/lib/rule.d.mts +23 -0
  54. package/lib/rule.mjs +1 -0
  55. package/lib/utils/compiler-listener.d.mts +3 -0
  56. package/lib/utils/compiler-listener.mjs +1 -0
  57. package/lib/utils/esm.d.mts +2 -0
  58. package/lib/utils/esm.mjs +1 -0
  59. package/lib/utils/has-pkg.d.mts +2 -0
  60. package/lib/utils/has-pkg.mjs +1 -0
  61. package/lib/{utils.d.ts → utils/index.d.mts} +0 -4
  62. package/lib/utils/index.mjs +1 -0
  63. package/lib/utils/log.d.mts +2 -0
  64. package/lib/utils/log.mjs +2 -0
  65. package/lib/utils/match-path.d.mts +22 -0
  66. package/lib/utils/match-path.mjs +1 -0
  67. package/lib/utils/read-conf.d.mts +2 -0
  68. package/lib/utils/read-conf.mjs +1 -0
  69. package/lib/utils/run.d.mts +2 -0
  70. package/lib/utils/run.mjs +1 -0
  71. package/lib/utils/seo.mjs +1 -0
  72. package/lib/{svg-to-data-uri.js → utils/svg-to-data-uri.mjs} +1 -1
  73. package/lib/utils/tfc.d.mts +2 -0
  74. package/lib/utils/tfc.mjs +1 -0
  75. package/lib/vm/coverage.mjs +1 -0
  76. package/lib/vm/{docs.d.ts → docs.d.mts} +1 -1
  77. package/lib/vm/docs.mjs +1 -0
  78. package/lib/vm/{example.d.ts → example.d.mts} +1 -1
  79. package/lib/vm/example.mjs +1 -0
  80. package/lib/vm/generate-doc.mjs +1 -0
  81. package/lib/{info.d.ts → vm/info.d.mts} +4 -3
  82. package/lib/vm/info.mjs +1 -0
  83. package/lib/vm/{locales.d.ts → locales.d.mts} +1 -1
  84. package/lib/vm/locales.mjs +2 -0
  85. package/lib/vm/modules.d.mts +17 -0
  86. package/lib/vm/modules.mjs +1 -0
  87. package/lib/vm/{routes.d.ts → routes.d.mts} +1 -1
  88. package/lib/vm/routes.mjs +1 -0
  89. package/package.json +28 -22
  90. package/typings/global.d.ts +58 -157
  91. package/lib/common.js +0 -1
  92. package/lib/config.js +0 -1
  93. package/lib/dev.js +0 -3
  94. package/lib/has-pkg.d.ts +0 -1
  95. package/lib/has-pkg.js +0 -1
  96. package/lib/html-plugin-option.js +0 -1
  97. package/lib/index.d.ts +0 -8
  98. package/lib/index.js +0 -1
  99. package/lib/info.js +0 -1
  100. package/lib/loader/hot-router.cjs +0 -1
  101. package/lib/minify.js +0 -1
  102. package/lib/modify-vars.js +0 -1
  103. package/lib/module-federation.js +0 -1
  104. package/lib/module.config.d.ts +0 -3
  105. package/lib/module.config.js +0 -1
  106. package/lib/net.js +0 -1
  107. package/lib/paths.js +0 -1
  108. package/lib/plugin/add-entry-attribute.js +0 -1
  109. package/lib/plugin/lightningcss-plugin.js +0 -1
  110. package/lib/plugin/override-resolve.js +0 -1
  111. package/lib/plugin/virtual-module.js +0 -1
  112. package/lib/plugins.config.js +0 -1
  113. package/lib/polyfills/replace-children.js +0 -1
  114. package/lib/polyfills.js +0 -1
  115. package/lib/process-env.js +0 -1
  116. package/lib/prod.d.ts +0 -1
  117. package/lib/prod.js +0 -1
  118. package/lib/seo.js +0 -1
  119. package/lib/swcrc.d.ts +0 -4
  120. package/lib/swcrc.js +0 -1
  121. package/lib/targets.js +0 -1
  122. package/lib/tsloader.config.d.ts +0 -8
  123. package/lib/tsloader.config.js +0 -1
  124. package/lib/utils.js +0 -2
  125. package/lib/vm/coverage.js +0 -1
  126. package/lib/vm/docs.js +0 -1
  127. package/lib/vm/example.js +0 -1
  128. package/lib/vm/generate-doc.js +0 -1
  129. package/lib/vm/locales.js +0 -2
  130. package/lib/vm/routes.js +0 -1
  131. package/template/favicon.ico +0 -0
  132. package/template/index.html +0 -25
  133. /package/lib/{dev.d.ts → build.d.mts} +0 -0
  134. /package/lib/{loader/hot-router.d.cts → dev.d.mts} +0 -0
  135. /package/lib/{modify-vars.d.ts → options/modify-vars.d.mts} +0 -0
  136. /package/lib/plugin/{done.d.ts → done.d.mts} +0 -0
  137. /package/lib/plugin/{done.js → done.mjs} +0 -0
  138. /package/lib/plugin/{external-remotes.d.ts → external-remotes.d.mts} +0 -0
  139. /package/lib/{module-federation.d.ts → plugin/module-federation.d.mts} +0 -0
  140. /package/lib/plugin/{override-resolve.d.ts → override-resolve.d.mts} +0 -0
  141. /package/lib/{plugins.config.d.ts → plugins.config.d.mts} +0 -0
  142. /package/lib/{polyfills.d.ts → polyfills/polyfills.d.mts} +0 -0
  143. /package/lib/{targets.d.ts → polyfills/targets.d.mts} +0 -0
  144. /package/lib/{os-tmp-dir.d.ts → utils/os-tmp-dir.d.mts} +0 -0
  145. /package/lib/{os-tmp-dir.js → utils/os-tmp-dir.mjs} +0 -0
  146. /package/lib/{reactive-object.d.ts → utils/reactive-object.d.mts} +0 -0
  147. /package/lib/{reactive-object.js → utils/reactive-object.mjs} +0 -0
  148. /package/lib/{resolver-sync.d.ts → utils/resolver-sync.d.mts} +0 -0
  149. /package/lib/{resolver-sync.js → utils/resolver-sync.mjs} +0 -0
  150. /package/lib/{seo.d.ts → utils/seo.d.mts} +0 -0
  151. /package/lib/{svg-to-data-uri.d.ts → utils/svg-to-data-uri.d.mts} +0 -0
  152. /package/lib/vm/{coverage.d.ts → coverage.d.mts} +0 -0
  153. /package/lib/vm/{generate-doc.d.ts → generate-doc.d.mts} +0 -0
  154. /package/lib/vm/{utils.d.ts → utils.d.mts} +0 -0
  155. /package/lib/vm/{utils.js → utils.mjs} +0 -0
@@ -1 +0,0 @@
1
- import{join as o}from"path";import{getAppEntry as t,getAppFallback as e,getAppMdxScope as p,getAppMergeRouter as r,getAppNormalizeCss as a,getAppPrefixRouter as s,getAppRem as i,getAppSuspense as m}from"@moneko/mdx";import n from"webpack-virtual-modules";import{CONFIG as f}from"../config.js";import l from"../info.js";import c from"../paths.js";import{APPTYPE as h,FRAMEWORK as d,isLibrary as g}from"../process-env.js";import{resolveNodeModulesPath as u,resolveProgramPath as x}from"../utils.js";import j from"../vm/coverage.js";import{comment as v,docs as y,docsModuleName as k}from"../vm/docs.js";import{exampleModuleName as b,examples as w}from"../vm/example.js";import{locales as O,localesModuleName as P}from"../vm/locales.js";import{route as z,routesModuleName as D}from"../vm/routes.js";export default class{constructor(o){this.options=o,this.hasTapped=!1}apply(S){let T=new n({[u("@app/info")]:`export default ${JSON.stringify(l)}`,[u("@app/entry")]:t(o(f.alias["@"],"./index.ts"),!!f.rem,!!f.normalizeCss,h,d),[u("@app/rem")]:i(f.rem?.designSize||1680),[u("@app/fallback")]:e(f.fallbackCompPath),[u("@app/coverage")]:j(c.coveragePath),[u("@app/merge-router")]:r(),[u("@app/prefix-router")]:s(),[u("@app/normalize/index.css")]:a(),[u("@app/suspense/index.tsx")]:m(h,d),[u("@app/mdx-scope")]:p(x("site/mdx-scope.ts")),[u(D)]:z.getData(D),[u(b)]:"export default []",[u(P)]:O.getData(P),[u(k)]:y.getData(k)});function C(o,t){let e=u(o);T.writeModule(e,t||"")}T.apply(S),z.on("change",C),O.on("change",C),g&&(w.on("change",C),y.on("change",C),v.on("change",C)),S.hooks.compilation.tap("VirtualModuleWebpackPlugin",()=>{if(!this.hasTapped){for(let o in this.hasTapped=!0,this.options)if(Object.prototype.hasOwnProperty.call(this.options,o)){let t=this.options[o];C(o,"string"==typeof t?t:`export default ${JSON.stringify(t)}`)}for(let o of w)C(...o);for(let o of y)C(...o);for(let o of v)C(...o)}})}}
@@ -1 +0,0 @@
1
- import e from"add-asset-html-webpack-plugin";import t from"html-webpack-plugin";import l from"webpack";import{CONFIG as o}from"./config.js";import i from"./html-plugin-option.js";import r from"./module-federation.js";import n from"./plugin/add-entry-attribute.js";import p from"./plugin/virtual-module.js";import{isMicro as a}from"./process-env.js";let{AutomaticPrefetchPlugin:s,DefinePlugin:m,SourceMapDevToolPlugin:c,IgnorePlugin:h}=l,u=o.basename.split("/").filter(Boolean).length,f=`${Array(u).fill("..").join("/")+(u?"/":"")}404.html`,{pathSegmentsToKeep:d=u,path:w=f}=o.fixBrowserRouter||{},g=o.assetHtml.map(e=>({publicPath:"",...e})),j=[...r,new p(o.virtualModule),new s,o.htmlPluginOption&&new t(i),o.fixBrowserRouter&&new t({filename:w,inject:!1,templateContent:()=>`<html lang="en"><head><title>${i.title}</title><script>const pathKeep = ${d||u};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>`}),new e(g),a&&new n({test:/main\.bundle\.js$/}),new m({"process.env":JSON.stringify(o.env)}),new h({resourceRegExp:/\/__tests__\//}),o.sourceMap&&new c(o.sourceMap),...o.plugins].filter(e=>!!e);export default j;
@@ -1 +0,0 @@
1
- function e(...t){let o=this,r=t.length,l=Array(r);for(let e=0;e<r;e++)l[e]=t[e];for(;o.firstChild;)o.removeChild(o.firstChild);l.forEach(function(e){o.appendChild("string"==typeof e?document.createTextNode(e):e)})}Element.prototype.replaceChildren||(Element.prototype.replaceChildren=e),ShadowRoot.prototype.replaceChildren||(ShadowRoot.prototype.replaceChildren=e);
package/lib/polyfills.js DELETED
@@ -1 +0,0 @@
1
- import t from"core-js-compat";import{getBrowsersTargets as r}from"./targets.js";export default function(){return t({targets:r(),version:"3.34"}).list}
@@ -1 +0,0 @@
1
- import o from"./paths.js";export const APPTYPE=process.env.APPTYPE;export const FRAMEWORK=process.env.FRAMEWORK;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 mainDirectory=isLibrary?"site":"src";export const jsxImportSource={react:"react",solid:"solid-js/h"}[FRAMEWORK];export const PACKAGENAME=process.env.npm_package_name;export const PACKAGEVERSION=process.env.npm_package_version;export const coreName="@moneko/core";export const isDev="development"===process.env.NODE_ENV;export const routeDir=isLibrary?o.componentsPath:o.pagesPath;
package/lib/prod.d.ts DELETED
@@ -1 +0,0 @@
1
- export {};
package/lib/prod.js DELETED
@@ -1 +0,0 @@
1
- import{removeDirAll as e}from"@moneko/mdx";import o from"mini-css-extract-plugin";import m from"terser-webpack-plugin";import n from"webpack";import{BundleAnalyzerPlugin as i}from"webpack-bundle-analyzer";import{merge as r}from"webpack-merge";import t from"webpackbar";import{clientConfig as p}from"./common.js";import{CONFIG as s}from"./config.js";import{getMinifyOption as l}from"./minify.js";import u from"./paths.js";import a from"./plugin/done.js";import c from"./plugin/lightningcss-plugin.js";import f from"./seo.js";let{optimize:{MinChunkSizePlugin:d,ModuleConcatenationPlugin:h}}=n,k=[];s.minifier&&(k.push(new m(l(s.minifier?.type||"swc",s.minifier?.options))),k.push(new c));let w={splitChunks:s.splitChunk,runtimeChunk:s.runtimeChunk,chunkIds:"named",moduleIds:"named",removeAvailableModules:!0,removeEmptyChunks:!0,mergeDuplicateChunks:!0,mangleWasmImports:!0,minimize:!0,minimizer:k};n(r(p,{devtool:!1===s.devtool||s.devtool?s.devtool:"cheap-module-source-map",mode:"production",optimization:w,plugins:[new h,new o({filename:"style/[name].bundle.css",chunkFilename:"style/[name].chunk.css",experimentalUseImportModule:!0}),s.splitChunk&&new d({minChunkSize:1e4}),s.bundleAnalyzer&&new i(s.bundleAnalyzer),s.bar&&new t(s.bar),new a({done:e=>{s.done?.(e),s.seo&&f()}})].filter(Boolean)})).run(e=>{if(e)throw e}),process.on("exit",function(){e(u.cachePath)});
package/lib/seo.js DELETED
@@ -1 +0,0 @@
1
- import{join as o}from"path";import{saveFileSync as t,scanRouter as m,sitemap as r}from"@moneko/mdx";import{outputConfig as e}from"./common.js";import{CONFIG as p}from"./config.js";import{isLibrary as i,routeDir as s}from"./process-env.js";import{resolveProgramPath as f}from"./utils.js";export default(()=>{let{domain:n,nojekyll:a,path:j}=p.seo||{},l=j&&f(j)||e?.path;if(!n||!l)return;let x=`https://${n}${p.basename}`;t(o(l,"CNAME"),n),t(o(l,"robots"),`Sitemap: ${x}/sitemap.txt`),t(o(l,"sitemap.txt"),r(s,x,m(s,i)).join("\n")),a&&t(o(l,".nojekyll"),"")});
package/lib/swcrc.d.ts DELETED
@@ -1,4 +0,0 @@
1
- import type { JsMinifyOptions, Config as SwcConfig } from '@swc/core';
2
- export declare const swcMinifyOption: JsMinifyOptions;
3
- declare const _default: SwcConfig;
4
- export default _default;
package/lib/swcrc.js DELETED
@@ -1 +0,0 @@
1
- import{merge as e}from"webpack-merge";import{CONFIG as o}from"./config.js";import r from"./paths.js";import s from"./polyfills.js";import{isDev as t,isReact as n,isSolid as i,jsxImportSource as p}from"./process-env.js";export const swcMinifyOption={compress:{top_retain:[],keep_infinity:!0,global_defs:{"@alert":"console.log"},pure_funcs:["console.log","console.warn","console.error","console.info"],toplevel:!1,drop_console:!0,drop_debugger:!0,module:!1,ecma:2015,ie8:!1,keep_classnames:void 0,keep_fnames:!1},mangle:!0};let c={module:{type:"es6",resolveFully:!0},jsc:{parser:{syntax:"typescript",tsx:!0,decorators:!0,dynamicImport:!0},loose:!0,target:"es2017",externalHelpers:!1,transform:{legacyDecorator:!0,decoratorMetadata:!0,react:{runtime:"automatic",throwIfNamespace:!0,refresh:n&&t,development:t,importSource:p},optimizer:{simplify:!1}},minify:t?void 0:swcMinifyOption,experimental:{emitAssertForImportAttributes:!0,cacheRoot:r.swcCachePath,plugins:[["swc-plugin-another-transform-imports",function(e){for(let o=0,r=Object.keys(e),s=r.length;o<s;o++)e[r[o]].transform=`${r[o]}/${e[r[o]].transform}`,e[r[o]].style&&(e[r[o]].style=`${r[o]}/${e[r[o]].style}`);return e}(o.importOnDemand||{})],i&&["@moneko/jsx-dom-expressions",o.jsxDomExpressions||{}]].filter(Boolean)}},sourceMaps:!0,parseMap:!0};o.polyfill&&(c.jsc.target=void 0,c.env={include:s(),mode:"entry",coreJs:"3.34"});export default e(c,"function"==typeof o.swcrc?o.swcrc(t):o.swcrc||{});
package/lib/targets.js DELETED
@@ -1 +0,0 @@
1
- let r,t;import e from"browserslist";import{browserslistToTargets as s}from"lightningcss";import o from"./paths.js";export function getBrowsersTargets(){return r||(r=e(void 0,{path:o.programPath,env:process.env.NODE_ENV}).filter(r=>!r.endsWith(" TP"))),r}export function getLightningCssTargets(){return t||(t=s(getBrowsersTargets())),t}
@@ -1,8 +0,0 @@
1
- import type { Node, SourceFile, TransformerFactory } from 'typescript';
2
- declare let tsLoaderConfig: {
3
- transpileOnly: boolean;
4
- getCustomTransformers: () => {
5
- before: (Node | TransformerFactory<SourceFile>)[];
6
- };
7
- };
8
- export default tsLoaderConfig;
@@ -1 +0,0 @@
1
- import{fileExists as r}from"@moneko/mdx";import t from"ts-import-plugin";import o from"webpack-merge";import{CONFIG as e}from"./config.js";import{isFunction as m,readConf as i,resolveProgramPath as a}from"./utils.js";let s=[];Array.isArray(e.importOnDemand)&&Object.assign(s,e.importOnDemand.map(r=>t(r)));let p=[...s],f={transpileOnly:!0,getCustomTransformers:()=>({before:p})},n=a("tsloader.config.ts");if(r(n))try{let r=(await i(n,"tsloader.config")).default;f=o(f,m(r)?r(process):r)}catch(r){}export default f;
package/lib/utils.js DELETED
@@ -1,2 +0,0 @@
1
- import{resolve as t}from"path";import o from"readline";import{saveFileSync as r}from"@moneko/mdx";import{transformFileSync as e}from"@swc/core";import n from"./paths.js";import c from"./resolver-sync.js";export function esm(t,...o){let r=t.raw[0];for(let e=0;e<o.length;e++)r+=o[e]+t.raw[e+1];return`data:text/javascript;base64,${Buffer.from(r).toString("base64")}`}let p={inputSourceMap:!1,sourceMaps:!1,module:{type:"es6"},jsc:{parser:{syntax:"typescript"},loose:!1}};export function log(t){Array.isArray(t)?t.forEach(t=>{log(`${t}
2
- `)}):(o.cursorTo(process.stdout,0),process.stdout.write(t))}export function tfc(t){return e(t,p).code||"{}"}export function readConf(t,o){let e=`${n.cachePath}/${o}.mjs`;return r(e,tfc(t)),import(e)}export function toUpperCaseString(t){return t?.replace(/\b\w/g,t=>t.toUpperCase()).replace(/\./g," ")}export function resolveProgramPath(o){return t(n.programPath,`./${o}`)}export const resolveNodeModulesPath=t=>`${n.nodeModules}/${t}`;export const realResolve=t=>c.resolveSync({},n.programPath,t)||t;export function isObject(t){let o=typeof t;return null!==t&&("object"==o||"function"==o)}export function isFunction(t){if(!isObject(t))return!1;let o=Object.prototype.toString.call(t);return"[object Function]"==o||"[object AsyncFunction]"==o||"[object GeneratorFunction]"==o||"[object Proxy]"==o}export function empty(){}
@@ -1 +0,0 @@
1
- import{fileExists as e,loadFileSync as r}from"@moneko/mdx";import{Parser as t}from"xml2js";import{PACKAGENAME as o}from"../process-env.js";export default function(c){let a={},i="export default {}";if(e(c))try{let e=r(c);(0,new t({explicitArray:!1,async:!1}).parseString)(e,(e,r)=>{e||(Object.assign(a,{[o]:r.coverage.project.metrics.$}),r.coverage.project.package.forEach(e=>{Object.assign(a,{[e.$.name]:e.metrics.$})})),i=`export default ${JSON.stringify(a)}`})}catch(e){}return i}
package/lib/vm/docs.js DELETED
@@ -1 +0,0 @@
1
- import{loadFileSync as e,scanFolder as t}from"@moneko/mdx";import o from"./generate-doc.js";import{CONFIG as r}from"../config.js";import{FRAMEWORK as n,isLibrary as a,isReact as s,isSolid as p}from"../process-env.js";import m from"../reactive-object.js";let l={react:"createElement",solid:"createComponent"}[n];export const docsModuleName="@app/docs";export const docs=new m({[docsModuleName]:"export default {}"});export const comment=new m({});export const getCommentPath=function(){let e=/^\/?(.+?)\.tsx?$/,t=r.alias["@pkg"].length;return o=>o.substring(t).replace(e,"@app/comment/$1.md")}();if(a){let a={},m=`import { ${l}${p?",Dynamic":""} } from "${{react:"react",solid:"solid-js"}[n]}${p?"/web":""}";import SuspenseComp from "@app/suspense";function call_then(res) {return {default: ${s?"() =>":""}${l}(${p?"Dynamic":"'n-md'"}, {text: res.default, ${p?"component: 'n-md', ":""}css: 'table td a {display:inline-flex;align-items:center;gap:2px;}table td a n-img{display:inline-block;overflow:hidden;border-radius:var(--border-radius);inline-size:18px;block-size:18px;}' })};}`,c=(e,t)=>{let o=e.replace(/^@app\/comment\//,"").split("/"),r=o.pop(),n=o.join("/");a[n]||(a[n]={}),t?a[n][r]&&delete a[n][r]:a[n][r]=`rr(() => ${l}(SuspenseComp, { comp: () => import(/* webpackChunkName: '${e}' */ '${e}?raw').then(call_then)}))rr`;let s={};for(let e in a)Object.prototype.hasOwnProperty.call(a,e)&&(s[e]=Object.values(a[e]));docs.setData(docsModuleName,`${m}export default ${JSON.stringify(s).replace(/"rr\((.+?)\)rr"/g,"$1")}`)};comment.on("change",(e,t)=>{c(e,t?.length<0)}),t(r.alias["@pkg"]).filter(e=>/^(?![._]).*(?<!\.test)\.(tsx?)$/i.test(e)).forEach(t=>{let r=e(t);r&&comment.setData(getCommentPath(t),o(r,t))})}
package/lib/vm/example.js DELETED
@@ -1 +0,0 @@
1
- import{generateExample as e}from"@moneko/mdx";import{watchFiles as o}from"./utils.js";import t from"../paths.js";import{isDev as r,isLibrary as p}from"../process-env.js";import m from"../reactive-object.js";export const exampleModuleName="@app/example";function a(){try{return JSON.parse(e(t.componentsPath,"@app/example/"))}catch(e){return{}}}export const examples=new m(p?a():{});export function generatorDemo(){let e=a();for(let o in e)Object.prototype.hasOwnProperty.call(e,o)&&examples.setData(o,e[o])}p&&r&&o(t.componentsPath,/(?<!\/examples\/(.+)\.md)$/,generatorDemo);
@@ -1 +0,0 @@
1
- import{dirname as e}from"path";import t from"typescript";import{CONFIG as n}from"../config.js";let{ScriptKind:r,ScriptTarget:l,SyntaxKind:o,createSourceFile:i,forEachChild:a,getLeadingCommentRanges:c,isInterfaceDeclaration:u,isQuestionToken:s,isPropertySignature:f,isFunctionTypeNode:p,isUnionTypeNode:m,isMethodSignature:g}=t,$={};function h(e){let t=c(e.getSourceFile().text,e.pos);if(t){let n=e.getSourceFile().text.substring(t[0].pos,t[0].end).match(/\/\*\*([\s\S]*?)\*\//);if(n)return n[1].replace(/^\s*\* ?/gm,"").replace(/\s+$/,"").trim()}return null}function b(e){if(!e)return null;let t=e.match(/@since\s+([^\n]+)/);return t?t[1].trim():null}function d(e){if(!e)return null;let t=e.match(/@author (\w+)\s*(?:<([^>]+)>)?/);if(t?.length){let e=t[1].trim(),n=t[2]?.trim(),r=/^[\w-]+(\.[\w-]+)*@[\w-]+(\.[\w-]+)+$/.test(n);return n?r&&(n=`mailto:${n}`):n=`https://github.com/${e}`,`[![${e}](https://avatars.githubusercontent.com/${e}?s=64)${e}](${n})`}return null}function y(e){if(!e)return null;let t=e.match(/@ignore\s+([^\n]+)/);return t?t[1].trim():null}let x=/(?<!['"])(unknown|any|void|bigint|object|undefined|null|boolean|number|string|symbol)(?!['"])/g;function j(e,t){if(!e)return null;let r=e.replace(/\b([A-Z][a-zA-Z0-9]*)\b/g,e=>{if($[e]){let r=`/${[n.basename,$[e]].join("/").split("/").filter(Boolean).join("/")}`;return t?`[\\color{#009688}{${e}}](${r})`:`[${e}](${r})`}return t?`\\color{#009688}{${e}}`:e});return t&&(r=r.replace(x,e=>`\\color{#009688}{${e}}`)),r}function T(e){return(function(e){let t;if(!e)return null;let n=[];for(;t=/\\color{([^|}]*)\|?([^|}]*)\|?([^|}]*)\|?([^}]*)}{([^}]*)}/g.exec(e);)n.push(t[0]);return e.replace(/[{}[\]()=>]|keyof|typeof|true|false/g,e=>n.some(t=>t.includes(e))?e:`\\color{#569cd6}{${e}}`)})(e)?.replace(/^\s*\|\s*|\s*\|\s*$/gm,"").replace(/\n/g,"<br/>").replace(/\*/g,"\\*").replace(/\|/g,"\\|").replace(/(['"])((?:(?!\1).)*)\1/g,"\\color{#ce9178}{$1$2$1}")}function B(e){return e?e.replace(/^@[a-z].+/gm,"").replace(/(\n\s+)+/g,"<br />").replace(/\n/g,"<br />").replace(/(<br \/>)$/g,""):null}export default function k(c,x){let k=i(x,c,l.Latest,!0,r.TS),w="";return a(k,r=>{u(r)?w+=function(r){let l=r.name.text;Object.assign($,{[r.name.text]:e(r.getSourceFile().fileName).replace(n.alias["@pkg"],"")});let i=h(r),a=b(i),c=B(i),u=y(i)?.split("|")||[],x=u.includes("comment"),k=u.includes("initial"),w=u.includes("optional"),E=u.includes("version"),S=u.includes("author"),v=c?`\\color{|4||0.45}{${l}}`:l,F=(function(e){let n=[];if(e.heritageClauses){for(let r of e.heritageClauses)if(r.token===t.SyntaxKind.ExtendsKeyword)for(let e of r.types)n.push(e.getText())}return n})(r)?.map(e=>`<n-tag color="#4c81db" css=".tag{gap:0px;}">${j(T(e))}</n-tag>`),z=[c,v,a&&`\\color{#52c11b|1||0.9}{${a}}`,F.length>0&&`<sub>\`extends\`</sub> ${F.join(" ")}`].filter(Boolean).join(" "),K=`## ${z}`,N=r.members.filter(e=>f(e)&&e.type?.kind!==o.NeverKeyword||g(e)),q=[];if(N.length){N.forEach(e=>{let t=j(T(g(e)?`(${e.parameters.map(e=>`${e.name.getText()}: ${e.type?.getText()||"any"}`).join(", ")}): ${e.type?.getText()||"any"}`:e.type?.getText()||"any"),!0),n=h(e),r=T(e.name.getText());!r||r.startsWith("\\color")||(g(e)||function(e){if(e.type){if(!m(e.type))return p(e.type);for(let t of e.type.types)if(p(t))return!0}return!1}(e)||t?.includes("=>")?r=`\\color{#f9a913}{${r}}`:/^["'](.+)["']$/.test(r)||(r=`\\color{#4c81db}{${r}}`));let l=e.questionToken&&s(e.questionToken);q.push([r,!w&&`\\color{${l?"#f9a913":"#52c11b"}\\|\\|\\|0.9}{${l?"✘":"✔"}}`,!x&&T(B(n)),t,!k&&T(function(e){if(!e)return null;let t=e.match(/@default\s+([^\n]+)/);return t?t[1].trim():null}(n)),!E&&T(b(n)),!S&&(d(n)||d(i))])});let e=!1,t=!1,n=!1,r=!1;q.forEach(l=>{!x&&l[2]&&(r=!0),!k&&l[4]&&(n=!0),!E&&l[5]&&(t=!0),!S&&l[6]&&(e=!0)}),K+="\n";let l=["属性",!w&&"必要",r&&"说明","类型",n&&"默认值",t&&"版本",e&&"作者"].filter(Boolean).join("|");K+=`|${l}|`;let o=[":-",!w&&":-",r&&":-",":-",n&&":-",t&&":-",e&&":-"].filter(Boolean);K+="\n";let a=o.join("|");K+=`|${a}|`,q.forEach(l=>{K+="\n";let o=[l[0]||"-",!w&&(l[1]||"-"),r&&(l[2]||"-"),l[3]||"-",n&&(l[4]||"-"),t&&(l[5]||"-"),e&&(l[6]||"-")].filter(Boolean).join("|");K+=`|${o}|`}),K+="\n"}return K+="\n"}(r):t.isEnumDeclaration(r)&&(w+=function(r){let l=r.name.text,o=h(r),i=B(o),a=b(o);Object.assign($,{[r.name.text]:e(r.getSourceFile().fileName).replace(n.alias["@pkg"],"")});let c=i?`\\color{|4||0.45}{${l}}`:l,u=[i,c,a&&`\\color{#52c11b|1||0.9}{${a}}`].filter(Boolean).join(" "),s=y(o)?.split("|")||[],f=s.includes("comment"),p=s.includes("version"),m=s.includes("author"),g=`## ${u}`;if(r.members.length){let e=[];r.members.forEach(n=>{let r=T(n.name.getText()),l=h(n),i=T(function(e){let n=e.initializer;return n&&t.isStringLiteral(n)?` '${n.text}'`:null}(n)),a=T(b(l)),c=T(B(l));!r||r.startsWith("\\color")||/^["'](.+)["']$/.test(r)||(r=`\\color{#4c81db}{${r}}`),e.push([r,!f&&c,i,!p&&a,!m&&(d(l)||d(o))])});let n=!1,l=!1,i=!1;e.forEach(e=>{!f&&e[1]&&(i=!0),!p&&e[3]&&(l=!0),!m&&e[4]&&(n=!0)}),g+="\n";let a=["属性",i&&"说明","值",l&&"版本",n&&"作者"].filter(Boolean).join("|");g+=`|${a}|`;let c=[":-",i&&":-",":-",l&&":-",n&&":-"].filter(Boolean);g+="\n";let u=c.join("|");g+=`|${u}|`,e.forEach(e=>{g+="\n";let t=[e[0]||"-",i&&(e[1]||"-"),e[2]||"-",l&&(e[3]||"-"),n&&(e[4]||"-")].filter(Boolean).join("|");g+=`|${t}|`})}return g+="\n\n"}(r))}),w}
package/lib/vm/locales.js DELETED
@@ -1,2 +0,0 @@
1
- import{basename as e,join as t}from"path";import{directoryExists as o,scanFolder as a}from"@moneko/mdx";import{watch as l}from"chokidar";import{CONFIG as r}from"../config.js";import{FRAMEWORK as n,isDev as s}from"../process-env.js";import c from"../reactive-object.js";import{esm as i,tfc as g}from"../utils.js";let u={react:'import sso from "shared-store-object";',solid:'import { createEffect, createRoot, getOwner } from "solid-js";import { createStore } from "solid-js/store";'},f={react:'let storageKey="localizable.language",language=localStorage.getItem(storageKey)||"zh_CN",{translation:a,...defaultLocale}=Object.assign({title:"简体中文",language:"zh_CN",translation:{}},resources[language]||resources.zh_CN),localizable=sso({lang:defaultLocale,t:a});export function setLang(a){let{translation:e,...l}=resources[a]||{};e&&(localizable.lang=l,localizable.t=e,localStorage.setItem(storageKey,l.language))}export default localizable;',solid:'let locale=createRoot(()=>{let e="localizable.language",a=localStorage.getItem(e)||"zh_CN",{translation:l,...o}=Object.assign({title:"简体中文",language:"zh_CN",translation:{}},resources[a]||resources.zh_CN),[n,c]=createStore({lang:o,t:l});return createEffect(()=>{let a=resources[n.lang.language]?.translation;a&&(c("t",a),localStorage.setItem(e,n.lang.language))}),{localizable:n,setLocalizable:c,setLang:function(e){let{translation:a,...l}=resources[e]||{};a&&c("lang",l)}}},getOwner());export const setLocalizable=locale.setLocalizable;export const t=locale.localizable.t;export const lang=locale.localizable.lang;export const setLang=locale.setLang;'}[n];function p(e,t){return`${u[n]}
2
- export function interpolateString(r,n){return r.replace(/\\\${\\w+}/g,function(r){var t=r.slice(2,-1);var e=n[t];return e!==void 0?e.toString():""})}function deepFreeze(o) { const p = Reflect.ownKeys(o);for (const k of p) {const v = o[k];if ((v && typeof v === "object") || typeof v === "function") {deepFreeze(v);}}return Object.freeze(o);}export const locales = ${JSON.stringify(e)};const _res = ${JSON.stringify(t)};const resources = deepFreeze(_res);${f}`}export const localesModuleName="@app/locales";export const locales=new c({[localesModuleName]:p([],{})});let d={};async function m(t,o){let a=e(t).replace(/\.[^.]+$/,"");"deleted"===o?delete d[a]:Object.assign(d,{[a]:(await import(i`${g(t)}`)).default});let l=[],r={};for(let e in d)if(Object.prototype.hasOwnProperty.call(d,e)){let{language:t=a,title:o=t,icon:n,translation:s={}}=d[e];l.push({language:t,title:o,icon:n}),r[t]={language:t,title:o,icon:n,translation:s}}locales.setData(localesModuleName,p(l,r))}let z=t(r.alias["@"],"./locales");o(z)&&(a(z).filter(e=>!/^\..*/.test(e)&&!/!\.ts$/.test(e)&&!/\.d\.ts$/.test(e)).forEach(e=>{m(e,"added")}),s&&function(e,t){let o=l(e,{ignored:t,persistent:!0,ignoreInitial:!0});function a(){o.unwatch(e),o.close()}o.on("add",e=>{m(e,"added")}),o.on("change",e=>{m(e,"change")}),o.on("unlink",e=>{m(e,"deleted")}),o.once("ready",()=>{s||a()}),process.on("SIGINT",a)}(z,[/^\..*/,/!\.ts$/,/\.d\.ts$/]));
package/lib/vm/routes.js DELETED
@@ -1 +0,0 @@
1
- import{generateRouter as o}from"@moneko/mdx";import{watchFiles as e}from"./utils.js";import{CONFIG as t}from"../config.js";import{FRAMEWORK as r,isDev as s,isLibrary as m,routeDir as u}from"../process-env.js";import n from"../reactive-object.js";let i=m?"@pkg":"@/pages";export const routesModuleName="@app/routes";function p(){return o(u,`${t.alias["@"]}/router/index.ts`,r,i,m)}export const route=new n({[routesModuleName]:p()});export function generatorRouter(){route.setData(routesModuleName,p())}s&&e(u,m?/(?<!README\.mdx?)$/:/(?<!index\.tsx?)$/,generatorRouter);
Binary file
@@ -1,25 +0,0 @@
1
- <!DOCTYPE html>
2
- <html lang="en">
3
- <head>
4
- <title><%= htmlWebpackPlugin.options.title %></title>
5
- <%
6
- var customTag="";
7
- if (htmlWebpackPlugin.options.tags) {
8
- htmlWebpackPlugin.options.tags.forEach(function(item){
9
- var { tag = "script", textContent = "", ...attrs } = item;
10
- var _attrs = "";
11
- for (const key in attrs) {
12
- if (attrs.hasOwnProperty(key)) {
13
- _attrs += `${key}="${attrs[key]}" `;
14
- }
15
- }
16
- customTag += `<${tag} ${_attrs}>${textContent}</${tag}>`;
17
- });
18
- }
19
- %>
20
- <%= customTag %>
21
- </head>
22
- <body>
23
- <div id="root"></div>
24
- </body>
25
- </html>
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes