@moneko/core 3.54.0-beta.2 → 3.54.0-beta.3

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 (195) hide show
  1. package/lib/bin/commit-lint.d.mts +1 -42
  2. package/lib/bin/commit-lint.mjs +1 -1
  3. package/lib/bin/file.d.mts +0 -2
  4. package/lib/bin/index.d.mts +1 -5
  5. package/lib/bin/pin.d.mts +4 -38
  6. package/lib/bin/pure-lint.d.mts +1 -31
  7. package/lib/bin/pure-lint.mjs +1 -1
  8. package/lib/bin/setup.d.mts +0 -3
  9. package/lib/bin/utils/convert-solid.d.mts +3 -6
  10. package/lib/bin/utils/convert-solid.mjs +1 -1
  11. package/lib/bin/utils/setup-swcrc.d.mts +1 -3
  12. package/lib/build/common.d.mts +1 -10
  13. package/lib/build/server.d.mts +0 -5
  14. package/lib/build.d.mts +1 -16
  15. package/lib/commom/ca.d.mts +7 -17
  16. package/lib/commom/ca.mjs +1 -1
  17. package/lib/commom/esm.d.mts +1 -1
  18. package/lib/commom/has-pkg.d.mts +0 -1
  19. package/lib/commom/is-ci-environment.d.mts +4 -2
  20. package/lib/commom/log.d.mts +1 -6
  21. package/lib/commom/match-path.d.mts +16 -1
  22. package/lib/commom/parse-module-meta.d.mts +0 -2
  23. package/lib/commom/print-log.d.mts +0 -1
  24. package/lib/commom/require.d.mts +0 -6
  25. package/lib/commom/timer.d.mts +3 -4
  26. package/lib/common.d.mts +1 -14
  27. package/lib/config.d.mts +0 -24
  28. package/lib/dev/generate-progress-html.d.mts +1 -1
  29. package/lib/dev/json-schema.d.mts +3 -3
  30. package/lib/dev/proxy.d.mts +3 -7
  31. package/lib/dev.d.mts +1 -48
  32. package/lib/dev.mjs +2 -2
  33. package/lib/file-system.d.mts +1 -1
  34. package/lib/loader/lightning-css/runtime/api.d.cts +5 -3
  35. package/lib/loader/lightning-css/runtime/get-url.cjs +1 -1
  36. package/lib/loader/lightning-css/runtime/get-url.d.cts +1 -9
  37. package/lib/module.config.d.mts +3 -49
  38. package/lib/module.config.mjs +1 -1
  39. package/lib/options/css-extract.d.mts +0 -5
  40. package/lib/options/modify-vars.d.mts +0 -9
  41. package/lib/options/split-chunk.d.mts +0 -2
  42. package/lib/plugin/eslint.d.mts +6 -14
  43. package/lib/plugin/module-federation.d.mts +1 -19
  44. package/lib/plugin/stylelint.d.mts +6 -14
  45. package/lib/plugins.config.d.mts +1 -10
  46. package/lib/polyfills/replace-children.d.mts +1 -1
  47. package/lib/process-env.d.mts +4 -8
  48. package/lib/utils/compile-dts.d.mts +16 -3
  49. package/lib/utils/create-types.d.mts +0 -13
  50. package/lib/utils/create-types.mjs +1 -1
  51. package/lib/utils/dts.d.mts +12 -5
  52. package/lib/utils/svg-to-data-uri.d.mts +1 -58
  53. package/lib/utils/vts.d.mts +14 -6
  54. package/lib/vm/docs.d.mts +0 -11
  55. package/lib/vm/docs.mjs +1 -1
  56. package/lib/vm/info.d.mts +0 -3
  57. package/lib/vm/locales.d.mts +0 -24
  58. package/lib/vm/modules.d.mts +0 -25
  59. package/lib/vm/render-app.d.mts +0 -9
  60. package/lib/worker/dts.d.mts +1 -2
  61. package/lib/worker/eslint.d.mts +0 -6
  62. package/lib/worker/eslint.mjs +1 -1
  63. package/lib/worker/react-compiler.d.mts +23 -8
  64. package/lib/worker/react-compiler.mjs +1 -1
  65. package/lib/worker/stylelint.d.mts +0 -4
  66. package/lib/worker/swc-minify.d.mts +1 -2
  67. package/package.json +3 -3
  68. package/lib/bin/build-app.d.mts +0 -11
  69. package/lib/bin/build-app.mjs +0 -1
  70. package/lib/bin/build.d.mts +0 -13
  71. package/lib/bin/build.mjs +0 -1
  72. package/lib/bin/changelog.d.mts +0 -12
  73. package/lib/bin/changelog.mjs +0 -4
  74. package/lib/bin/eslint.d.mts +0 -6
  75. package/lib/bin/eslint.mjs +0 -2
  76. package/lib/bin/git-hooks.d.mts +0 -5
  77. package/lib/bin/git-hooks.mjs +0 -2
  78. package/lib/bin/help.d.mts +0 -85
  79. package/lib/bin/help.mjs +0 -13
  80. package/lib/bin/lessc.d.mts +0 -10
  81. package/lib/bin/lessc.mjs +0 -1
  82. package/lib/bin/server.d.mts +0 -14
  83. package/lib/bin/server.mjs +0 -1
  84. package/lib/bin/start.d.mts +0 -5
  85. package/lib/bin/start.mjs +0 -1
  86. package/lib/bin/stylelint.d.mts +0 -7
  87. package/lib/bin/stylelint.mjs +0 -2
  88. package/lib/bin/tsc.d.mts +0 -6
  89. package/lib/bin/tsc.mjs +0 -1
  90. package/lib/bin/utils/bundle-app.d.mts +0 -7
  91. package/lib/bin/utils/bundle-app.mjs +0 -1
  92. package/lib/bin/utils/config.d.mts +0 -13
  93. package/lib/bin/utils/config.mjs +0 -1
  94. package/lib/bin/utils/get-commit-files.d.mts +0 -3
  95. package/lib/bin/utils/get-commit-files.mjs +0 -1
  96. package/lib/commom/check-npm.d.mts +0 -4
  97. package/lib/commom/check-npm.mjs +0 -1
  98. package/lib/commom/corepack.d.mts +0 -12
  99. package/lib/commom/corepack.mjs +0 -1
  100. package/lib/commom/diff-object.d.mts +0 -2
  101. package/lib/commom/diff-object.mjs +0 -1
  102. package/lib/commom/host.d.mts +0 -3
  103. package/lib/commom/host.mjs +0 -19
  104. package/lib/commom/module-resolve.d.mts +0 -3
  105. package/lib/commom/module-resolve.mjs +0 -1
  106. package/lib/commom/net.d.mts +0 -4
  107. package/lib/commom/net.mjs +0 -1
  108. package/lib/commom/open.d.mts +0 -5
  109. package/lib/commom/open.mjs +0 -1
  110. package/lib/commom/paths.d.mts +0 -36
  111. package/lib/commom/paths.mjs +0 -1
  112. package/lib/commom/reactive-object.d.mts +0 -10
  113. package/lib/commom/reactive-object.mjs +0 -1
  114. package/lib/commom/rule.d.mts +0 -20
  115. package/lib/commom/rule.mjs +0 -1
  116. package/lib/commom/setup-env.d.mts +0 -4
  117. package/lib/commom/setup-env.mjs +0 -1
  118. package/lib/commom/sigint-exit.d.mts +0 -3
  119. package/lib/commom/sigint-exit.mjs +0 -1
  120. package/lib/commom/transform-solid-js.d.mts +0 -41
  121. package/lib/commom/transform-solid-js.mjs +0 -1
  122. package/lib/dev/config.d.mts +0 -14
  123. package/lib/dev/config.mjs +0 -2
  124. package/lib/dev/get-cert.d.mts +0 -10
  125. package/lib/dev/get-cert.mjs +0 -1
  126. package/lib/dev/mock.d.mts +0 -61
  127. package/lib/dev/mock.mjs +0 -1
  128. package/lib/dev/server.d.mts +0 -34
  129. package/lib/dev/server.mjs +0 -1
  130. package/lib/loader/css-in-js-minify.cjs +0 -1
  131. package/lib/loader/css-in-js-minify.d.cts +0 -22
  132. package/lib/loader/lightning-css/codegen.cjs +0 -20
  133. package/lib/loader/lightning-css/codegen.d.cts +0 -36
  134. package/lib/loader/lightning-css/loader.cjs +0 -1
  135. package/lib/loader/lightning-css/loader.d.cts +0 -49
  136. package/lib/loader/lightning-css/utils.cjs +0 -1
  137. package/lib/loader/lightning-css/utils.d.cts +0 -26
  138. package/lib/loader/mdx.cjs +0 -1
  139. package/lib/loader/mdx.d.cts +0 -4
  140. package/lib/loader/react-compiler.cjs +0 -1
  141. package/lib/loader/react-compiler.d.cts +0 -21
  142. package/lib/loader/solid.cjs +0 -1
  143. package/lib/loader/solid.d.cts +0 -9
  144. package/lib/loader/ts-doc.cjs +0 -1
  145. package/lib/loader/ts-doc.d.cts +0 -11
  146. package/lib/options/md-to-html.d.mts +0 -5
  147. package/lib/options/md-to-html.mjs +0 -1
  148. package/lib/options/reslove.d.mts +0 -11
  149. package/lib/options/reslove.mjs +0 -1
  150. package/lib/options/swcrc.d.mts +0 -21
  151. package/lib/options/swcrc.mjs +0 -1
  152. package/lib/plugin/compression.d.mts +0 -17
  153. package/lib/plugin/compression.mjs +0 -1
  154. package/lib/plugin/copy.d.mts +0 -21
  155. package/lib/plugin/copy.mjs +0 -1
  156. package/lib/plugin/done.d.mts +0 -11
  157. package/lib/plugin/done.mjs +0 -1
  158. package/lib/plugin/exposes-declararion.d.mts +0 -20
  159. package/lib/plugin/exposes-declararion.mjs +0 -1
  160. package/lib/plugin/external-remotes.d.mts +0 -8
  161. package/lib/plugin/external-remotes.mjs +0 -1
  162. package/lib/plugin/html-plugin.d.mts +0 -48
  163. package/lib/plugin/html-plugin.mjs +0 -1
  164. package/lib/plugin/lightningcss-plugin.d.mts +0 -31
  165. package/lib/plugin/lightningcss-plugin.mjs +0 -1
  166. package/lib/plugin/manifest.d.mts +0 -43
  167. package/lib/plugin/manifest.mjs +0 -1
  168. package/lib/plugin/override-resolve.d.mts +0 -14
  169. package/lib/plugin/override-resolve.mjs +0 -1
  170. package/lib/plugin/swc-minify-plugin.d.mts +0 -13
  171. package/lib/plugin/swc-minify-plugin.mjs +0 -1
  172. package/lib/plugin/virtual-module.d.mts +0 -24
  173. package/lib/plugin/virtual-module.mjs +0 -1
  174. package/lib/polyfills/polyfills.d.mts +0 -7
  175. package/lib/polyfills/polyfills.mjs +0 -1
  176. package/lib/polyfills/targets.d.mts +0 -8
  177. package/lib/polyfills/targets.mjs +0 -1
  178. package/lib/utils/fetch-module-federation-dts.d.mts +0 -6
  179. package/lib/utils/fetch-module-federation-dts.mjs +0 -1
  180. package/lib/utils/index.d.mts +0 -12
  181. package/lib/utils/index.mjs +0 -1
  182. package/lib/utils/run.d.mts +0 -3
  183. package/lib/utils/run.mjs +0 -1
  184. package/lib/utils/seo.d.mts +0 -10
  185. package/lib/utils/seo.mjs +0 -4
  186. package/lib/vm/coverage.d.mts +0 -39
  187. package/lib/vm/coverage.mjs +0 -1
  188. package/lib/vm/example.d.mts +0 -12
  189. package/lib/vm/example.mjs +0 -1
  190. package/lib/vm/generate-doc.d.mts +0 -35
  191. package/lib/vm/generate-doc.mjs +0 -1
  192. package/lib/vm/routes.d.mts +0 -17
  193. package/lib/vm/routes.mjs +0 -1
  194. package/lib/vm/utils.d.mts +0 -5
  195. package/lib/vm/utils.mjs +0 -1
@@ -1,61 +0,0 @@
1
- import http, { IncomingMessage, ServerResponse } from 'node:http';
2
- import { StringDecoder } from 'node:string_decoder';
3
- import { URL } from 'node:url';
4
- import { directoryExists, ink, print } from '@moneko/utils';
5
- import { watch } from 'chokidar';
6
- import { merge } from 'webpack-merge';
7
- import log from '../commom/log.mjs';
8
- import matchPath from '../commom/match-path.mjs';
9
- import printLog, { METHOD_COLOR } from '../commom/print-log.mjs';
10
- import require from '../commom/require.mjs';
11
- import { jsonSchema } from './json-schema.mjs';
12
- declare function shouldHaveBody(req: IncomingMessage);
13
- export declare function cacheBody(req: RequestFormData & {
14
- _bodyCached?: boolean;
15
- _dataChunks?: Uint8Array[];
16
- });
17
- declare function parseBody(chunks: Uint8Array[], contentType: string);
18
- declare async function getRequestBody(req: IncomingMessage & {
19
- _dataChunks?: Uint8Array[];
20
- });
21
- export interface RequestFormData extends IncomingMessage {
22
- files?: {
23
- fieldname: string;
24
- originalname: string;
25
- encoding: string;
26
- mimetype: string;
27
- buffer: Buffer;
28
- size: number;
29
- }[];
30
- params?: Record<string, string>;
31
- query?: Record<string, string>;
32
- body?: Promise<BodyInit | null>;
33
- }
34
- export interface MockServerResponse extends ServerResponse<IncomingMessage> {
35
- req: IncomingMessage;
36
- send<T>(chunk: T): ReturnType<ServerResponse<IncomingMessage>['end']>;
37
- }
38
- export type ProxyFuncType = (req: RequestFormData, res: MockServerResponse) => void | Promise<void>;
39
- export type MockConfiguration = Record<string, ProxyFuncType | Record<string, any> | null>;
40
- declare function clearProxy(iproxy: MockConfiguration, path: string, old: MockConfiguration);
41
- export type YApiOptionBySchema = {
42
- host: string;
43
- id: string;
44
- token: string;
45
- };
46
- type Any = any;
47
- export declare const yApiSchemaMock: <T extends Any>(option: YApiOptionBySchema, data?: T) => Promise<T>;
48
- export type YApiOption = {
49
- host: string;
50
- projectId: number;
51
- pathRewrite: string;
52
- };
53
- export declare const yApiMock: (req: RequestFormData, yapi: YApiOption) => Promise<Any>;
54
- export interface MockPluginOptions {
55
- directory: string;
56
- }
57
- export declare const oldMock: MockConfiguration;
58
- export declare let nextMock: MockConfiguration;
59
- export declare function containMockUrl(url: string): string | undefined;
60
- declare const setupMock: (options: MockPluginOptions) => any;
61
- export default setupMock;
package/lib/dev/mock.mjs DELETED
@@ -1 +0,0 @@
1
- import e from"node:http";import{StringDecoder as t}from"node:string_decoder";import{URL as r}from"node:url";import{directoryExists as n,ink as o,print as a}from"@moneko/utils";import{watch as c}from"chokidar";import{merge as i}from"webpack-merge";import s from"../commom/log.mjs";import d from"../commom/match-path.mjs";import l,{METHOD_COLOR as m}from"../commom/print-log.mjs";import u from"../commom/require.mjs";import{jsonSchema as p}from"./json-schema.mjs";function f(e){return!["GET","HEAD","OPTIONS"].includes(e.method?.toUpperCase()||"")}export function cacheBody(e){if(!e._bodyCached&&f(e)&&!e.readableEnded){e._bodyCached=!0;try{let t=[],r=e.on.bind(e),n=e.emit.bind(e),o=!1;e.on=function(e,n){return"data"!==e||o||(o=!0,r("data",e=>{t.push(e)})),r(e,n)};let a=!1;e.emit=function(r,...o){return"end"===r&&!a&&(a=!0,t.length>0&&(e._dataChunks=t)),n.call(this,r,...o)}}catch(e){s(e)}}}function h(e,r){try{let n=Buffer.concat(e);if(r.includes("application/json")){let e=new t("utf-8").write(n);return JSON.parse(e)}if(r.includes("application/octet-stream")||r.startsWith("image/"));else if(r.includes("text/"))return n.toString("utf-8");else if(r.includes("application/x-www-form-urlencoded"))return Object.fromEntries(new URLSearchParams(n.toString("utf8")));return n}catch(e){return s(e),null}}async function g(e){return new Promise(t=>{if(!f(e)){t(null);return}let r=e.headers["content-type"]||"",n=e.headers["content-length"],o=e.headers["transfer-encoding"],a=[];if(void 0!==e._dataChunks){t(h(e._dataChunks,r));return}if(!n&&!o){t(null);return}e.on("data",e=>{a.push(e)}),e.on("end",()=>{t(h(a,r))}),e.on("error",e=>{t(null),s(e)})})}function y(e,t,r){if(delete u.cache[t],r[t]){for(let n in r[t])Object.prototype.hasOwnProperty.call(r[t],n)&&(e[n]=null,delete e[n]);r[t]=null,delete r[t]}}export const yApiSchemaMock=(t,r)=>new Promise(n=>{e.get(`${t.host}/api/interface/get?id=${t.id}&token=${t.token}`,e=>{e.setEncoding("utf8");let t="";e.on("data",e=>{t+=e}),e.on("end",()=>{try{let e=JSON.parse(t);if(e?.data?.res_body_is_json_schema){let t=JSON.parse(e.data.res_body),o=p(t);void 0!==r?n(i(o,r)):n(o)}}catch(e){s(e)}})})});export const yApiMock=(t,n)=>new Promise((o,a)=>{let c=new r(n.host),i={hostname:c.hostname,port:c.port,path:t.url?.replace(new RegExp(n.pathRewrite),`/mock/${n.projectId}/`),method:t.method,headers:t.headers,query:Object.fromEntries(c.searchParams)},d=e.request(i,e=>{e.setEncoding("utf8");let t="";e.on("data",e=>{t+=e}),e.on("end",()=>{try{o(JSON.parse(t))}catch(e){s(e)}})});d.on("error",e=>{a(e.message)}),d.write(JSON.stringify(t.body)),d.end()});export const oldMock={};export let nextMock={};export function containMockUrl(e){return Object.keys(nextMock).find(t=>RegExp(`^${t.replace(/(:\w*)[^/]/g,"((?!/).)")}*$`).test(e))}export default(e=>{if(!n(e.directory))return;let t=!0;return c(e.directory).on("all",async function(e,r){if("string"==typeof r){switch(a(o("Updating mock...","245"),!0),e){case"add":case"change":try{y(nextMock,r,oldMock);let e=u(r).default;oldMock[r]=e,nextMock=Object.assign(nextMock,e)}catch(e){s(e)}break;case"unlink":y(nextMock,r,oldMock)}t?t=!1:a(o("Mock update successful","245"),!0)}}),(e,t)=>{if(t.writableEnded)return t;let n=new r(`http://localhost:3000${e.url}`),o=e.method||"GET",a=`${o} ${n.pathname}`,c=containMockUrl(a)||a,i=nextMock[c];if(i){if(l(o,n.pathname,{note:"MOCK",labelAlign:"center",labelLen:8,labelForegroundColor:m[o].fg,labelBackgroundColor:m[o].bg}),t.send=e=>t.end("string"==typeof e?e:JSON.stringify(e)),t.writeHead(200,{"Content-Type":e.headers["content-type"]}),"function"==typeof i){let r=d(c.split(" ")[1],n.pathname);n.searchParams&&Object.assign(e,{query:Object.fromEntries(n.searchParams)}),r&&Object.assign(e,{params:r.params}),e.body=g(e);try{i(e,t)}catch(e){s(e)}return!0}return t.end("string"==typeof i?i:JSON.stringify(i)),!0}return!1}});
@@ -1,34 +0,0 @@
1
- import type { createReadStream, existsSync } from 'node:fs';
2
- import { createServer, type IncomingMessage, type Server as HttpServer, type ServerResponse } from 'node:http';
3
- import { createServer as createHttpsServer, type Server as HttpsServer } from 'node:https';
4
- import { extname, join } from 'node:path';
5
- import type { OutputFileSystem } from 'webpack';
6
- import mime from '../commom/mime.mjs';
7
- import open from '../commom/open.mjs';
8
- import paths from '../commom/paths.mjs';
9
- import { CONFIG } from '../config.mjs';
10
- import getCert, { type CertOption } from '../dev/get-cert.mjs';
11
- import { setupProxy } from '../dev/proxy.mjs';
12
- import setupMock, { cacheBody } from './mock.mjs';
13
- export type FileSystem = OutputFileSystem & {
14
- existsSync: typeof existsSync;
15
- createReadStream: typeof createReadStream;
16
- };
17
- declare const normalHeaders: Record<string, string>;
18
- type HttpServerResponse = ServerResponse<IncomingMessage> & {
19
- req: IncomingMessage;
20
- };
21
- interface ServerOption {
22
- port: number;
23
- root_dir: string;
24
- fileSystem: FileSystem;
25
- onRequest?(req: IncomingMessage, res: HttpServerResponse): boolean | void;
26
- headers?: Record<string, string>;
27
- basename?: string;
28
- https?: CertOption | boolean;
29
- host: string;
30
- open?: boolean;
31
- }
32
- export type Server = HttpServer | HttpsServer;
33
- declare async function server(option: ServerOption);
34
- export default server;
@@ -1 +0,0 @@
1
- import{createServer as e}from"node:http";import{createServer as t}from"node:https";import{extname as o,join as r}from"node:path";import n from"../commom/mime.mjs";import i from"../commom/open.mjs";import a from"../commom/paths.mjs";import{CONFIG as s}from"../config.mjs";import m from"../dev/get-cert.mjs";import{setupProxy as c}from"../dev/proxy.mjs";import l,{cacheBody as d}from"./mock.mjs";let p={"Access-Control-Allow-Credentials":"true","Access-Control-Allow-Headers":"Authorization, Content-Type, Accept, X-Requested-With, Origin, DNT, User-Agent, Cache-Control, X-CSRF-Token, X-API-Key, X-Client-Version, X-Device-ID, Content-Language, Accept-Language, X-Custom-Header, X-Mx-ReqToken, Keep-Alive, If-Modified-Since","Access-Control-Allow-Methods":"GET, DELETE, HEAD, OPTIONS, POST, PUT, PATCH, PURGE, LINK, UNLINK, PROPFIND, PROPPATCH, MKCOL, COPY, MOVE, LOCK, UNLOCK, REPORT, SEARCH, CONNECT, TRACE","Access-Control-Allow-Origin":"*","Cache-Control":"no-store, no-cache, must-revalidate, proxy-revalidate",Pragma:"no-cache",Expires:"0"};async function C(C){let h=r(C.root_dir,"index.html"),f=l({directory:a.mockPath});function u(e,t,r){let i=e.headers["accept-encoding"],a=i?.includes("br"),s=`${r}.${a?"br":"gz"}`,m=C.fileSystem.existsSync(s);m&&t.setHeader("Content-Encoding",a?"br":"gzip");let c=C.fileSystem.createReadStream(m?s:r,{autoClose:!0});c.on("open",()=>{t.writeHead(200,Object.assign({},p,C.headers,{"Access-Control-Allow-Origin":e.headers.origin??"*","Content-Type":n[o(r)]||"application/octet-stream"}))}),c.on("error",e=>{switch(c.destroy(),e.code){case"ENOENT":t.writeHead(301,{Location:"/index.html"}),t.end();break;case"EACCES":t.writeHead(403,{"Content-Type":"text/plain"}),t.end(`Forbidden: ${e.message}`);break;default:t.writeHead(500,{"Content-Type":"text/plain"}),t.end(`Internal Server Error: ${e.message}`)}}),c.pipe(t)}async function A(e,t){if(d(e),!(C.onRequest&&C.onRequest(e,t)||s.proxy&&await c(e,t,s.proxy)||t.writableEnded||f&&f(e,t))&&!t.writableEnded){if("GET"===e.method){let o="/"===e.url?h:decodeURIComponent(r(C.root_dir,e.url.replace(C.basename??"/","/")));if(C.fileSystem.existsSync(o))return u(e,t,o)}if(e.headers.accept?.includes("text/html"))return u(e,t,h);t.writeHead(404,{"Content-Type":"text/plain"}),t.end("File Not Found")}}let E=C.https?t(await m(C.host,!0===C.https?{install:!0}:C.https),A):e(A);return E.listen(C.port),C.open&&i(`${C.https?"https:":"http:"}//${C.host}:${C.port}${"/"===C.basename?"":C.basename}`),E}export default C;
@@ -1 +0,0 @@
1
- "use strict";var e;Object.defineProperty(exports,"__esModule",{value:!0}),Object.defineProperty(exports,"default",{enumerable:!0,get:function(){return i}});const t=require("@swc/core"),r=require("stylis"),n=(e=require("../commom/log.mjs"))&&e.__esModule?e:{default:e};function l(e){return{type:"iTemplateElement",span:{start:0,end:0,ctxt:0},tail:!1,cooked:e,raw:e}}function a(e,t){if("Identifier"===e.tag.type&&t.includes(e.tag.value)){let t=e.template,n=function(e){let t=e.quasis.map(e=>e.cooked);return t.reduce((e,r,n)=>(e.push(r),n!==t.length-1&&e.push(`xxx${n}:xxx`),e),[]).join("").trim()}(t),a=function e(t){return t.map(t=>{switch(t.type){case"import":case"decl":return t.value;case"comm":return"/"===t.props&&t.value.includes("@")?t.value:"";case"rule":return`${t.value.replace(/&\f/g,"&")}{${e(t.children)}}`;default:return`${t.value}{${e(t.children)}}`}}).join("")}(function e(t,r){for(let n=0;n<t.length;n++){let l=t[n],a=l.parent,i=l.children;a?!function(e){var t;return"rule"===e.type&&e.parent&&(t=e.parent,e.line===t.line&&e.column===t.column)}(l)&&a.children.push(l):r.push(l),Array.isArray(i)&&(l.children=[],e(i,r))}return r}((0,r.compile)(n),[])),i=function(e,t){let r=function(e){let t;let r=/xxx(\d+):xxx/gm,n=[];for(;null!==(t=r.exec(e));)n.push({value:t[0],p1:parseInt(t[1],10),index:t.index});return n}(e);if(0===r.length)return""===e?[]:[l(e)];let n=[],a=[],i=0;return r.forEach(({value:s,p1:u,index:p},o)=>{let c=e.substring(i,p);i=i+c.length+s.length,c||0!==o?n.push(l(c)):n.push(l("")),a.push(t[u]),o===r.length-1&&n.push(l(e.substring(p+s.length)))}),a.reduce((e,t,r)=>e.concat([t],n[r+1]),[n[0]]).filter(e=>""!==e.raw)}(a,t.expressions);if(a.length>1){let e=[],r=[];i.forEach((t,n)=>{"iTemplateElement"===t.type?e.push({...t,type:"TemplateElement",tail:n===i.length-1}):r.push(t)}),t.quasis=e,t.expressions=r}}}async function i(e){let r=this.async(),{moduleName:l,allowFuncs:i}=this.getOptions()||{};this.cacheable&&this.cacheable();try{let n=await (0,t.parse)(e,{syntax:"ecmascript"}),s=[];n.body.forEach(e=>{"ImportDeclaration"===e.type&&e.source.value===l&&e.specifiers.forEach(e=>{"ImportSpecifier"===e.type&&(e.imported&&i.includes(e.imported.value)?s.push(e.local.value):i.includes(e.local.value)&&s.push(e.local.value))})}),n.body.forEach(e=>{!function(e){if("ExportDeclaration"===e.type||"ExpressionStatement"===e.type){let t="declaration"in e?e.declaration:e.expression;t&&"CallExpression"===t.type&&t.arguments.forEach(e=>{e.expression&&"TaggedTemplateExpression"===e.expression.type&&a(e.expression,s)}),t&&"VariableDeclaration"===t.type&&t.declarations.forEach(e=>{e.init?.type==="TaggedTemplateExpression"&&a(e.init,s)})}else"CallExpression"===e.type&&e.arguments.forEach(e=>{e.expression&&"TaggedTemplateExpression"===e.expression.type&&a(e.expression,s)})}(e)});let{code:u}=await (0,t.print)(n);r(null,u)}catch(e){r(e),(0,n.default)(e)}}
@@ -1,22 +0,0 @@
1
- import { type Expression, type ModuleItem, parse, print, type TaggedTemplateExpression, type TemplateElement, type TemplateLiteral } from '@swc/core';
2
- import { compile, type Element } from 'stylis';
3
- import type { LoaderContext } from 'webpack';
4
- import log from '../commom/log.mjs';
5
- export interface CssInJsMinifyOption {
6
- moduleName: string;
7
- allowFuncs: string[];
8
- }
9
- declare function haveSameLocation(element1: Element, element2: Element);
10
- declare function isAutoInsertedRule(element: Element);
11
- declare function toInputTree(elements: Element[], tree: Element[]);
12
- declare function stringifyTree(elements: Element[]);
13
- declare function getDynamicMatches(str: string);
14
- declare function interleave(strings: (ITemplateElement | Expression)[], interpolations: Expression[]);
15
- declare function createRawStringFromTemplateLiteral(template: TemplateLiteral);
16
- interface ITemplateElement extends Omit<TemplateElement, 'type'> {
17
- type: 'iTemplateElement';
18
- }
19
- declare function createTemplateElement(raw: string): ITemplateElement;
20
- declare function replacePlaceholdersWithExpressions(str: string, expressions: Expression[]);
21
- declare function transform(expression: TaggedTemplateExpression, names: string[]);
22
- export default async function cssInJsMinifyLoader(this: LoaderContext<CssInJsMinifyOption>, sourceCode: string);
@@ -1,20 +0,0 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),function(e,t){for(var o in t)Object.defineProperty(e,o,{enumerable:!0,get:t[o]})}(exports,{getExportCode:function(){return r},getImportCode:function(){return t},getModuleCode:function(){return o}});const e=require("./utils.cjs");function t(e,t){let o="";for(let r of e){let{importName:e,url:s,icss:_}=r;t.esModule?_&&t.modules?.namedExport?o+=`import ${t.modules.exportOnlyLocals?"":`${e}, `}* as ${e}_NAMED___ from ${s};
2
- `:o+=`import ${e} from ${s};
3
- `:o+=`var ${e} = require(${s});
4
- `}return o?`// Imports
5
- ${o}`:""}function o(t,o,r,s,_){if(s.modules?.exportOnlyLocals===!0)return"";let l=s.sourceMap?`,${(0,e.normalizeSourceMapForRuntime)(t.map,_)}`:"",a=JSON.stringify(t.css),n=`var ___CSS_LOADER_EXPORT___ = ___CSS_LOADER_API_IMPORT___(${s.sourceMap});
6
- `;for(let e of o){let{url:t,media:o,dedupe:r}=e;n+=t?`___CSS_LOADER_EXPORT___.push([module.id, ${JSON.stringify(`@import url(${t});`)}${o?`, ${JSON.stringify(o)}`:""}]);
7
- `:`___CSS_LOADER_EXPORT___.i(${e.importName}${o?`, ${JSON.stringify(o)}`:r?', ""':""}${r?", true":""});
8
- `}for(let t of r){let{replacementName:o,importName:r,localName:_}=t;if(_)a=a.replace(RegExp(o,"g"),()=>s.modules?.namedExport?`" + ${r}_NAMED___[${JSON.stringify((0,e.camelCase)(_))}] + "`:`" + ${r}.locals[${JSON.stringify(_)}] + "`);else{let{hash:e,needQuotes:s}=t,_=[...e?[`hash: ${JSON.stringify(e)}`]:[],...s?"needQuotes: true":[]],l=_.length>0?`, { ${_.join(", ")} }`:"";n+=`var ${o} = ___CSS_LOADER_GET_URL_IMPORT___(${r}${l});
9
- `,a=a.replace(RegExp(o,"g"),()=>`" + ${o} + "`)}}return`${n}// Module
10
- ___CSS_LOADER_EXPORT___.push([module.id, ${a}, ""${l}]);
11
- `}function r(t,o,r){let s="// Exports\n",_="",l=(t,o)=>{r.modules?.namedExport?_+=`export const ${(0,e.camelCase)(t)} = ${JSON.stringify(o)};
12
- `:(_&&(_+=`,
13
- `),_+=` ${JSON.stringify(t)}: ${JSON.stringify(o)}`)};for(let{name:o,value:s}of t)switch(r.modules?.exportLocalsConvention){case"camelCase":{l(o,s);let t=(0,e.camelCase)(o);t!==o&&l(t,s);break}case"camelCaseOnly":l((0,e.camelCase)(o),s);break;case"dashes":{l(o,s);let t=(0,e.dashesCamelCase)(o);t!==o&&l(t,s);break}case"dashesOnly":l((0,e.dashesCamelCase)(o),s);break;default:l(o,s)}for(let t of o){let{replacementName:o,localName:s}=t;if(s){let{importName:l}=t;_=_.replace(RegExp(o,"g"),()=>r.modules?.namedExport?`" + ${l}_NAMED___[${JSON.stringify((0,e.camelCase)(s))}] + "`:r.modules?.exportOnlyLocals?`" + ${l}[${JSON.stringify(s)}] + "`:`" + ${l}.locals[${JSON.stringify(s)}] + "`)}else _=_.replace(RegExp(o,"g"),()=>`" + ${o} + "`)}return r.modules?.exportOnlyLocals?s+=r.modules.namedExport?_:`${r.esModule?"export default":"module.exports ="} {
14
- ${_}
15
- };
16
- `:(_&&(s+=r.modules?.namedExport?_:`___CSS_LOADER_EXPORT___.locals = {
17
- ${_}
18
- };
19
- `),s+=`${r.esModule?"export default":"module.exports ="} ___CSS_LOADER_EXPORT___;
20
- `)}
@@ -1,36 +0,0 @@
1
- import type { LoaderContext } from 'webpack';
2
- import type { LightningCssLoaderOption } from './loader.cjs';
3
- import { camelCase, dashesCamelCase, normalizeSourceMapForRuntime } from './utils.cjs';
4
- export interface CssImport {
5
- icss?: boolean;
6
- importName: string;
7
- url: string;
8
- type?: 'url' | string;
9
- index?: number;
10
- }
11
- export interface CssExport {
12
- name: string;
13
- value: string;
14
- }
15
- export interface ApiParam {
16
- url?: string;
17
- importName?: string;
18
- layer?: string;
19
- supports?: string;
20
- media?: string;
21
- dedupe?: boolean;
22
- index?: number;
23
- }
24
- export interface ApiReplacement {
25
- replacementName: string;
26
- localName?: string;
27
- importName: string;
28
- needQuotes?: boolean;
29
- hash?: string;
30
- }
31
- export declare function getImportCode(imports: CssImport[], options: LightningCssLoaderOption);
32
- export declare function getModuleCode(result: {
33
- map: void | Uint8Array;
34
- css: string;
35
- }, api: ApiParam[], replacements: ApiReplacement[], options: LightningCssLoaderOption, loaderContext: LoaderContext<LightningCssLoaderOption>);
36
- export declare function getExportCode(exports: CssExport[], replacements: ApiReplacement[], options: LightningCssLoaderOption);
@@ -1 +0,0 @@
1
- "use strict";var e;Object.defineProperty(exports,"__esModule",{value:!0}),Object.defineProperty(exports,"default",{enumerable:!0,get:function(){return _}});const t=require("lightningcss"),r=(e=require("../../commom/log.mjs"))&&e.__esModule?e:{default:e},s=require("../../process-env.mjs"),i=require("./codegen.cjs"),o=require("./utils.cjs");function l(e,t){return JSON.stringify(e.utils.contextify(e.context||e.rootContext,t))}const n=new TextEncoder,u={Declaration:{custom(e){if("content"===e.name&&1===e.value.length){let t=e.value[0];if("token"===t.type&&"string"===t.value.type)return[{property:e.name,raw:JSON.stringify(t.value.value.replace(/[\u4e00-\u9faF]/g,function(e){return`\\${e.charCodeAt(0).toString(16)}`}))}]}}}};async function _(e,_){let a=this.async();this.cacheable&&this.cacheable();let{implementation:p,visitor:c,rem:f,...m}=this.getOptions(),d=!!m.modules?.auto?.(this.resourcePath);if(d&&void 0===m.modules.namedExport&&(m.modules.namedExport=!0),p&&"function"!=typeof p.transform){a(TypeError(`[lightning-loader]: implementation.transform must be an 'lightningcss' transform function. Received ${typeof p.transform}`));return}let h=[],R=[],S=[],g=[],L=[];m.modules?.exportOnlyLocals!==!0&&R.unshift({type:"api_import",importName:"___CSS_LOADER_API_IMPORT___",url:l(this,require.resolve("./runtime/api.cjs"))});let O=p?.transform?p.transform:t.transform,y=new Map,E=new Map,v=new Map,C=function(e,t,r,s,i,l){let n=new Map,u=!1,_=new Map,a=new Map,p=-1,c=-1;return{Rule:{import(s){let i;if(e.importFilter&&!e.importFilter(s.value.url,s.value.media))return s;let u=s.value.url;c++,l.set(c,u),u=`__MO_LIGHTNINGCSS_LOADER_IMPORT_URL_REPLACE_${c}__`;let _=s.value.media.mediaQueries.length?JSON.stringify(s.value.media.mediaQueries):void 0,a=(0,o.isUrlRequestable)(u);if(a){let e=u.split("!");e.length>1&&(u=e.pop(),i=e.join("!"))}if(!a)return t.push({url:u,media:_}),{type:"ignored",value:""};let p=i?`${i}!${u}`:u,f=n.get(p);if(!f){f=`___CSS_LOADER_AT_RULE_IMPORT_${n.size}___`,n.set(p,f);let t=e.urlHandler(p);r.push({type:"rule_import",importName:f,url:t})}return t.push({importName:f,media:_}),{type:"ignored",value:""}}},Url:t=>(function(t){let l,n=t.url;if(!e.urlFilter(n)||n.startsWith("#")||(0,o.isDataUrl)(n))return t;p++,i.set(p,n);let[,c,f]=(n=`__MO_LIGHTNINGCSS_LOADER_URL_REPLACE_${p}__`).split(/(\?)?#/,3),m=n.split("!");m.length>1&&(n=m.pop(),l=m.join("!"));let d=c?"?":"";d+=f?`#${f}`:"",u||(r.push({type:"get_url_import",importName:"___CSS_LOADER_GET_URL_IMPORT___",url:JSON.stringify(require.resolve("./runtime/get-url.cjs")),index:-1}),u=!0);let h=l?`${l}!${n}`:n,R=_.get(h);R||(R=`___CSS_LOADER_URL_IMPORT_${_.size}___`,_.set(h,R),r.push({type:"url",importName:R,url:JSON.stringify(h),index:p}));let S=JSON.stringify({newUrl:h,hash:d,needQuotes:!1}),g=a.get(S);return g||(g=`___CSS_LOADER_URL_REPLACEMENT_${a.size}___`,a.set(S,g),s.push({replacementName:g,importName:R,hash:d,needQuotes:!1})),{loc:t.loc,url:g}})(t)}}({urlHandler:e=>l(this,(0,o.getPreRequester)(this)(m.importLoaders??0)+e),urlFilter:(0,o.getFilter)(m.url,this.resourcePath),importFilter:(0,o.getFilter)(m.import,this.resourcePath),context:this.context},g,R,L,y,v),M=function({apis:e,imports:t,replacements:r,replacedUrls:s,urlHandler:i}){let o=-1,l=-1;return{Declaration:{composes(n){if("unparsed"===n.property)return;let u=n.value.from;if(u?.type!=="file")return;let _=u.value;if(!_)return;o++,s.set(o,_),_=`__MO_LIGHTNINGCSS_LOADER_ICSS_URL_REPLACE_${o}__`;let a=`___CSS_LOADER_ICSS_IMPORT_${t.length}___`;t.push({type:"icss_import",importName:a,icss:!0,url:i(_),index:o}),e.push({importName:a,dedupe:!0,index:o});let p=[];for(let e of n.value.names){l++;let t=`___CSS_LOADER_ICSS_IMPORT_${o}_REPLACEMENT_${l}___`;r.push({replacementName:t,importName:a,localName:e}),p.push(t)}return{property:"composes",value:{loc:n.value.loc,names:p,from:u}}}}}}({apis:g,imports:S,replacements:L,replacedUrls:E,urlHandler:e=>l(this,(0,o.getPreRequester)(this)(m.importLoaders)+e)});try{f&&!u.Length&&(u.Length=function(e){if("px"===e.unit)return{unit:"rem",value:e.value/16}});let{code:t,map:r,exports:l}=O({filename:this.resourcePath,code:n.encode(e),minify:!0,visitor:{...u,...C,...M,...c},cssModules:!!d&&{pattern:m.modules.localIdentName},sourceMap:this.sourceMap,inputSourceMap:this.sourceMap&&_?JSON.stringify(_):void 0,analyzeDependencies:!1,drafts:{customMedia:!0},include:1,errorRecovery:!1,unusedSymbols:[],...m}),p=t.toString();if(l){for(let e in l)if(Object.prototype.hasOwnProperty.call(l,e)){let t=l[e],r=t.name;for(let e of t.composes)r+=` ${e.name}`;h.push({name:e,value:r})}m.modules.getJSON?.({resourcePath:this.resourcePath,exports:h})}if(0!==y.size){if(s.IS_WINDOW)for(let[e,t]of y.entries())for(let r of R)r.url=r.url.replace(`__MO_LIGHTNINGCSS_LOADER_URL_REPLACE_${e}__`,t);else{let e=this.getResolve({conditionNames:["asset"],mainFields:["asset"],mainFiles:[],extensions:[]});for(let[t,r]of y.entries()){let[s]=r.split(/(\?)?#/,3),i=(0,o.requestify)(s,this.rootContext),l=await (0,o.resolveRequests)(e,this.context,[...new Set([i,r])]);for(let e of R)e.url=e.url.replace(`__MO_LIGHTNINGCSS_LOADER_URL_REPLACE_${t}__`,l??r)}}}if(0!==v.size){let e=this.getResolve({conditionNames:["style"],extensions:[".css"],mainFields:["css","style","main","..."],mainFiles:["index","..."],restrictions:[/\.css$/i]});for(let[t,r]of v.entries()){let[s]=r.split(/(\?)?#/,3),i=(0,o.requestify)(s,this.rootContext),l=await (0,o.resolveRequests)(e,this.context,[...new Set([i,r])]);for(let e of R)e.url=e.url.replace(`__MO_LIGHTNINGCSS_LOADER_IMPORT_URL_REPLACE_${t}__`,l??r)}}if(0!==E.size){let e=this.getResolve({conditionNames:["style"],extensions:[],mainFields:["css","style","main","..."],mainFiles:["index","..."]});for(let[t,r]of E.entries()){let[s]=r.split(/(\?)?#/,3),i=(0,o.requestify)(s,this.rootContext),l=await (0,o.resolveRequests)(e,this.context,[...new Set([r,i])]);for(let e of S)e.url=e.url.replace(`__MO_LIGHTNINGCSS_LOADER_ICSS_URL_REPLACE_${t}__`,l??r)}}R.push(...S);let N=(0,i.getImportCode)(R,m),I=(0,i.getModuleCode)({css:p,map:r},g,L,m,this),P=(0,i.getExportCode)(h,L,m);a(null,`${N}${I}${P}`,r&&JSON.parse(r.toString()))}catch(e){a(e),(0,r.default)(e)}}
@@ -1,49 +0,0 @@
1
- import { type CustomAtRules, transform as _transform, type TransformOptions, type Url, type Visitor } from 'lightningcss';
2
- import type { LoaderContext } from 'webpack';
3
- import log from '../../commom/log.mjs';
4
- import { IS_WINDOW } from '../../process-env.mjs';
5
- import { type ApiParam, type ApiReplacement, type CssExport, type CssImport, getExportCode, getImportCode, getModuleCode } from './codegen.cjs';
6
- import { getFilter, getPreRequester, isDataUrl, isUrlRequestable, requestify, resolveRequests } from './utils.cjs';
7
- declare function stringifyRequest(loaderContext: LoaderContext<unknown>, request: string);
8
- declare const encoder: TextEncoder;
9
- declare function createUrlAndImportVisitor(visitorOptions: {
10
- urlHandler(url: string): string;
11
- urlFilter(...args: (string | undefined)[]): unknown;
12
- importFilter(...args: unknown[]): unknown;
13
- context: string;
14
- }, apis: ApiParam[], imports: CssImport[], replacements: ApiReplacement[], replacedUrls: Map<number, string>, replacedImportUrls: Map<number, string>): Visitor<CustomAtRules>;
15
- declare function createIcssVisitor({ apis, imports, replacements, replacedUrls, urlHandler }: {
16
- apis: ApiParam[];
17
- imports: CssImport[];
18
- replacements: ApiReplacement[];
19
- replacedUrls: Map<number, string>;
20
- urlHandler: (url: string) => string;
21
- }): Visitor<CustomAtRules>;
22
- type ExportLocalsConvention = 'asIs' | 'camelCase' | 'camelCaseOnly' | 'dashes' | 'dashesOnly' | ((name: string) => string);
23
- type Mode = 'local' | 'global' | 'pure' | 'icss' | ((resourcePath: string, resourceQuery: string, resourceFragment: string) => 'local' | 'global' | 'pure' | 'icss');
24
- export interface LightningCssLoaderOption extends Omit<TransformOptions<CustomAtRules>, 'filename' | 'code' | 'inputSourceMap'> {
25
- rem?: boolean;
26
- implementation?: typeof import('lightningcss');
27
- esModule?: boolean;
28
- modules?: {
29
- auto?(path: string): boolean;
30
- localIdentName?: string;
31
- exportOnlyLocals?: boolean;
32
- getJSON?(params: {
33
- resourcePath: string;
34
- exports: {
35
- name: string;
36
- value: string;
37
- }[];
38
- }): void;
39
- namedExport?: boolean;
40
- exportLocalsConvention?: ExportLocalsConvention;
41
- mode?: Mode;
42
- };
43
- importLoaders?: number;
44
- url?: string;
45
- import?(...args: unknown[]): boolean;
46
- }
47
- declare const normalVisitor: Visitor<CustomAtRules>;
48
- declare const LOADER_NAME: string;
49
- export default async function LightningCssLoader(this: LoaderContext<LightningCssLoaderOption>, source: string, prevMap?: string);
@@ -1 +0,0 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),function(e,t){for(var r in t)Object.defineProperty(e,r,{enumerable:!0,get:t[r]})}(exports,{camelCase:function(){return d},dashesCamelCase:function(){return h},getFilter:function(){return i},getPreRequester:function(){return u},isDataUrl:function(){return l},isUrlRequestable:function(){return n},normalizeSourceMapForRuntime:function(){return f},requestify:function(){return s},resolveRequests:function(){return o},urlToRequest:function(){return a}});const e=require("node:path"),t=require("node:url"),r=/^[A-Z]:[/\\]|^\\\\/i;function a(e,t){let a;if(""===e)return"";let o=/^[^?]*~/;if(r.test(e))a=e;else if(void 0!==t&&!1!==t&&e.startsWith("/"))switch(typeof t){case"string":a=o.test(t)?t.replace(/([^~/])$/,"$1/")+e.slice(1):t+e;break;case"boolean":a=e;break;default:throw Error(`Unexpected parameters to loader-utils 'urlToRequest': url = ${e}, root = ${t}.`)}else a=/^\.\.?\//.test(e)?e:`./${e}`;return o.test(a)&&(a=a.replace(o,"")),a}async function o(e,t,r){return e(t,r[0]).then(e=>e).catch(a=>{let[,...s]=r;if(0===s.length)throw a;return o(e,t,s)})}function s(e,r){return/^file:/i.test(e)?(0,t.fileURLToPath)(e):/^[a-z][a-z0-9+.-]*:/i.test(e)?e:"/"===e.charAt(0)?a(e,r):a(e)}function n(e){return!(e.startsWith("//")||/^(https?:)?\/\//.test(e))&&(!!(/^file:/i.test(e)||/^[a-z][a-z0-9+.-]*:/i.test(e))||!e.startsWith("#"))}function l(e){return!!/^data:/i.test(e)}function u({loaders:e,loaderIndex:t}){let r=Object.create(null);return a=>{if(r[a])return r[a];if(!1===a)r[a]="";else{let o=e.slice(t,t+1+("number"!=typeof a?0:a)).map(e=>e.request).join("!");r[a]=`-!${o}!`}return r[a]}}function i(e,t){return(...r)=>"function"!=typeof e||e(...r,t)}const c=/^[a-z]:[/\\]|^\\\\/i,p=/^[a-z0-9+\-.]+:/i;function f(t,r){let a=t?t.toJSON():null;return a&&(delete a.file,a.sourceRoot="",a.sources=a.sources?.map(t=>{var a;if(t.startsWith("<")||"path-relative"!=("/"===t[0]?"/"===t[1]?"scheme-relative":"path-absolute":c.test(t)?"path-absolute":p.test(t)?"absolute":"path-relative"))return t;let o=(0,e.dirname)(r.resourcePath),s=(0,e.resolve)(o,t),n=(a=(0,e.relative)(r.rootContext,s),"\\"===e.sep?a.replace(/\\/g,"/"):a);return`moneko://${n}`})),JSON.stringify(a)}function h(e){return e.replace(/-+(\w)/g,(e,t)=>t.toUpperCase())}const C=(e,t)=>{let r=!1,a=!1,o=!1;for(let s=0;s<e.length;s++){let n=e[s];r&&/[\p{Lu}]/u.test(n)?(e=`${e.slice(0,s)}-${e.slice(s)}`,r=!1,o=a,a=!0,s++):a&&o&&/[\p{Ll}]/u.test(n)?(e=`${e.slice(0,s-1)}-${e.slice(s-1)}`,o=a,a=!1,r=!0):(r=n.toLocaleLowerCase(t)===n&&n.toLocaleUpperCase(t)!==n,o=a,a=n.toLocaleUpperCase(t)===n&&n.toLocaleLowerCase(t)!==n)}return e},L=e=>e.replace(/^[\p{Lu}](?![\p{Lu}])/gu,e=>e.toLowerCase()),g=(e,t)=>e.replace(/[_.\- ]+([\p{Alpha}\p{N}_]|$)/gu,(e,r)=>r.toLocaleUpperCase(t.locale)).replace(/\d+([\p{Alpha}\p{N}_]|$)/gu,e=>e.toLocaleUpperCase(t.locale)),d=(e,t)=>{if(!("string"==typeof e||Array.isArray(e)))throw TypeError("Expected the input to be `string | string[]`");return(t={pascalCase:!1,preserveConsecutiveUppercase:!1,...t},0===(e=Array.isArray(e)?e.map(e=>e.trim()).filter(e=>e.length).join("-"):e.trim()).length)?"":1===e.length?t.pascalCase?e.toLocaleUpperCase(t.locale):e.toLocaleLowerCase(t.locale):(e!==e.toLocaleLowerCase(t.locale)&&(e=C(e,t.locale)),e=e.replace(/^[_.\- ]+/,""),e=t.preserveConsecutiveUppercase?L(e):e.toLocaleLowerCase(),t.pascalCase&&(e=e.charAt(0).toLocaleUpperCase(t.locale)+e.slice(1)),g(e,t))};
@@ -1,26 +0,0 @@
1
- import { dirname, relative, resolve, sep } from 'node:path';
2
- import { fileURLToPath } from 'node:url';
3
- import type { LoaderContext } from 'webpack';
4
- declare const t: RegExp;
5
- export declare function urlToRequest(e: string, i?: string | boolean);
6
- export declare async function resolveRequests(resolve: (arg0: any, arg1: any) => Promise<any>, context: any, possibleRequests: any[]): Promise<any>;
7
- export declare function requestify(url: string, rootContext: string);
8
- export declare function isUrlRequestable(url: string);
9
- export declare function isDataUrl(url: string);
10
- export declare function getPreRequester({ loaders, loaderIndex }: {
11
- loaders: {
12
- request: unknown;
13
- }[];
14
- loaderIndex: number;
15
- });
16
- export declare function getFilter<T>(filter: T, resourcePath: string);
17
- declare function normalizePath(file: string);
18
- declare const IS_NATIVE_WIN32_PATH: RegExp;
19
- declare const ABSOLUTE_SCHEME: RegExp;
20
- declare function getURLType(source: string);
21
- export declare function normalizeSourceMapForRuntime(map: any, loaderContext: LoaderContext<unknown>);
22
- export declare function dashesCamelCase(str: string);
23
- declare const preserveCamelCase: (string: string, locale: string) => any;
24
- declare const preserveConsecutiveUppercase: (input: string) => any;
25
- declare const postProcess: (input: string, options: any) => any;
26
- export declare const camelCase: (input: string | string[], options?: Record<string, unknown>) => any;
@@ -1 +0,0 @@
1
- "use strict";var e;Object.defineProperty(exports,"__esModule",{value:!0}),Object.defineProperty(exports,"default",{enumerable:!0,get:function(){return o}});const t=require("@moneko/mdx"),c=(e=require("../commom/log.mjs"))&&e.__esModule?e:{default:e};async function o(e){let o=this.async();this.cacheable&&this.cacheable(),(0,t.mdx)({value:e,filepath:this.resourcePath,...this.getOptions()}).then(e=>{o(null,e.code)}).catch(e=>{o(e),(0,c.default)(e)})}
@@ -1,4 +0,0 @@
1
- import { mdx, type MdxOptions } from '@moneko/mdx';
2
- import type { LoaderContext } from 'webpack';
3
- import log from '../commom/log.mjs';
4
- export default async function(this: LoaderContext<Omit<MdxOptions, 'value'>>, value: string);
@@ -1 +0,0 @@
1
- "use strict";var e;Object.defineProperty(exports,"__esModule",{value:!0}),Object.defineProperty(exports,"default",{enumerable:!0,get:function(){return r}});const t=require("@moneko/eslint/babel-core"),s=require("@moneko/eslint/react-compiler"),o=(e=require("../commom/log.mjs"))&&e.__esModule?e:{default:e};function r(e){let r=this.async();this.cacheable&&this.cacheable();let i=this.getOptions();("annotation"===i.compilationMode?e.includes("use memo")||e.includes("use forget"):e.includes("react")||this.resourcePath.endsWith(".tsx")||this.resourcePath.endsWith(".jsx"))?(0,t.transformAsync)(e,{sourceFileName:this.resourcePath,filename:this.resourcePath,sourceMaps:"inline",plugins:[[s.BabelPluginReactCompiler,i]],cloneInputAst:!1,ast:!1,configFile:!1,babelrc:!1}).then(t=>{null===t?r(Error(`Failed to transform "${this.resourcePath}"`),e):r(null,t.code??void 0,t.map??void 0)}).catch(t=>{t&&((0,o.default)(t),r(t,e))}):r(null,e)}
@@ -1,21 +0,0 @@
1
- import { transformAsync } from '@moneko/eslint/babel-core';
2
- import { BabelPluginReactCompiler } from '@moneko/eslint/react-compiler';
3
- import type { LoaderContext } from 'webpack';
4
- import log from '../commom/log.mjs';
5
- export interface ReactCompilerOption {
6
- target?: '17' | '18' | '19';
7
- sources?(filename: string): boolean;
8
- compilationMode?: 'annotation' | 'infer' | 'syntax' | 'all';
9
- logger?: {
10
- logEvent?: (fileName: string, event: MessageEvent) => void;
11
- };
12
- noEmit?: boolean;
13
- flowSuppressions?: boolean;
14
- ignoreUseNoForget?: boolean;
15
- enableReanimatedCheck?: boolean;
16
- panicThreshold?: string;
17
- environment?: unknown;
18
- gating?: null;
19
- eslintSuppressionRules?: Record<string, string | boolean | number>;
20
- }
21
- export default function reactCompilerLoader(this: LoaderContext<ReactCompilerOption>, sourceCode: string);
@@ -1 +0,0 @@
1
- "use strict";var e;Object.defineProperty(exports,"__esModule",{value:!0}),function(e,t){for(var r in t)Object.defineProperty(e,r,{enumerable:!0,get:t[r]})}(exports,{custom:function(){return n},default:function(){return s}});const t=(e=require("../commom/log.mjs"))&&e.__esModule?e:{default:e},r=require("../commom/transform-solid-js.mjs");async function o(e){let o=this.async();this.cacheable&&this.cacheable();let n=this.getOptions();(0,r.transformSolidJs)(e,{...n,filename:this.resourcePath}).then(t=>{null===t?o(Error(`Failed to transform "${this.resourcePath}"`),e):o(null,t.code??void 0,t.map??void 0)}).catch(r=>{r&&((0,t.default)(r),o(r,e))})}function n(e){return o.bind(this,e)}const s=o;
@@ -1,9 +0,0 @@
1
- import type { TransformOptions } from '@moneko/eslint/babel-core';
2
- import type { LoaderContext } from 'webpack';
3
- import log from '../commom/log.mjs';
4
- import { transformSolidJs, TransformSolidJsOption } from '../commom/transform-solid-js.mjs';
5
- declare async function solidLoader(this: LoaderContext<TransformSolidJsOption>, sourceCode: string);
6
- export declare function custom(this: LoaderContext<TransformOptions & {
7
- refresh?: boolean;
8
- }>, sourceCode: string);
9
- export default solidLoader;
@@ -1 +0,0 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),Object.defineProperty(exports,"default",{enumerable:!0,get:function(){return u}});const e=require("fs"),t=s(require("../commom/log.mjs")),r=s(require("../commom/parse-module-meta.mjs"));function s(e){return e&&e.__esModule?e:{default:e}}const i={};function u(s){this.cacheable&&this.cacheable();let u=this.resourcePath;if(u.endsWith(".d.ts"))return s;try{let t=(0,e.statSync)(u).mtime.getTime();if(i[u]!==t){Object.assign(i,{[u]:t});let{comment:e,generateDoc:a,getCommentPath:c}=this.getOptions(),{file:n,pkg:o,meta:l}=(0,r.default)(c(u));e.setData(n,a(s,u)),e.setData(o,l)}}catch(e){(0,t.default)(e)}return s}
@@ -1,11 +0,0 @@
1
- import { statSync } from 'fs';
2
- import type { LoaderContext } from 'webpack';
3
- import log from '../commom/log.mjs';
4
- import parseModuleMeta from '../commom/parse-module-meta.mjs';
5
- import type ReactiveObject from '../commom/reactive-object.mjs';
6
- declare const metadata: Record<string, number>;
7
- export default function(this: LoaderContext<{
8
- comment: ReactiveObject<Record<string, string>>;
9
- generateDoc(content: string, path: string): string;
10
- getCommentPath(filepath: string): string;
11
- }>, value: string);
@@ -1,5 +0,0 @@
1
- import marked from 'marked-completed';
2
- declare function setup();
3
- declare let initial: boolean;
4
- declare function mdToHtml(text: string);
5
- export default mdToHtml;
@@ -1 +0,0 @@
1
- import e from"marked-completed";let r=!0;export default function(t){return r&&(r=!1,function(){let r=new e.Renderer;r.code=(e,r)=>"treeview"===r?`<n-tree data="${e}" />`:`<n-code class="n-code" toolbar="${JSON.stringify(["copy"])}" language="${r}" line-number="true">${encodeURIComponent(e)}</n-code>`,r.image=(e,r,t)=>`<n-img lazy="true" role="img" src="${e}" alt="${t}" ${r?`title="${r}"`:""}></n-img>`,e.use({langToolbar:["copy"],headerPrefix:"# ",breaks:!0,pedantic:!1,smartLists:!0,smartypants:!0,xhtml:!0,renderer:r})}()),e.parse(t)}
@@ -1,11 +0,0 @@
1
- import hasPkg from '../commom/has-pkg.mjs';
2
- import require from '../commom/require.mjs';
3
- declare const reslove: {
4
- readonly styleLoader;
5
- readonly sassLoader;
6
- readonly lessLoader;
7
- readonly swcLoader;
8
- readonly transformImports;
9
- readonly hotMiddlewareClient;
10
- };
11
- export default reslove;
@@ -1 +0,0 @@
1
- import e from"../commom/has-pkg.mjs";import o from"../commom/require.mjs";let r={styleLoader:o.resolve("style-loader"),sassLoader:e("sass-loader"),lessLoader:o.resolve("less-loader"),swcLoader:o.resolve("swc-loader"),transformImports:e("@moneko/transform-imports"),hotMiddlewareClient:o.resolve("webpack-hot-middleware/client.js")};export default r;
@@ -1,21 +0,0 @@
1
- import type { Config as SwcConfig, EnvConfig, JscConfig } from '@swc/core';
2
- import { merge } from 'webpack-merge';
3
- import paths from '../commom/paths.mjs';
4
- import { CONFIG } from '../config.mjs';
5
- import type { SwcImportOnDemandTransform } from '../index.mjs';
6
- import polyfills, { coreJsVersion } from '../polyfills/polyfills.mjs';
7
- import { isDev, isReact, jsxImportSource } from '../process-env.mjs';
8
- import reslove from './reslove.mjs';
9
- declare function transformConfigs(config: SwcImportOnDemandTransform);
10
- declare const importOnDemand: SwcImportOnDemandTransform;
11
- declare const env: EnvConfig;
12
- export type SwcOption = SwcConfig & {
13
- module?: {
14
- resolveFully: boolean;
15
- };
16
- parseMap?: boolean;
17
- sync?: boolean;
18
- };
19
- declare const _dts_1: (ssr: boolean, other: {
20
- }) => any;
21
- export default _dts_1;
@@ -1 +0,0 @@
1
- import{merge as e}from"webpack-merge";import r from"../commom/paths.mjs";import{CONFIG as t}from"../config.mjs";import o,{coreJsVersion as s}from"../polyfills/polyfills.mjs";import{isDev as m,isReact as l,jsxImportSource as a}from"../process-env.mjs";import p from"./reslove.mjs";let c=function(e){for(let r=0,t=Object.keys(e),o=t.length;r<o;r++)e[t[r]].transform=`${t[r]}/${e[t[r]].transform}`,e[t[r]].style&&(e[t[r]].style=`${t[r]}/${e[t[r]].style}`);return e}(t.importOnDemand||{}),i={include:o(),mode:"entry",coreJs:s};export default((o,s={})=>e({module:{type:"es6",resolveFully:!0},sync:!0,jsc:{parser:{syntax:"typescript",tsx:l,decorators:!0,dynamicImport:!0},loose:!0,target:t.polyfill?void 0:"es2017",externalHelpers:!1,transform:{legacyDecorator:!0,decoratorMetadata:!0,react:{runtime:t.reactJsxRuntime||"automatic",throwIfNamespace:!0,refresh:l&&m,development:m,importSource:a},optimizer:{simplify:!1}},experimental:{emitAssertForImportAttributes:!0,cacheRoot:r.swcCachePath,plugins:[[p.transformImports,c]].filter(Boolean)}},env:t.polyfill?i:void 0,sourceMaps:!0,parseMap:!0},"function"==typeof t.swcrc?t.swcrc(m):t.swcrc||{},s));
@@ -1,17 +0,0 @@
1
- import { compression } from '@moneko/utils';
2
- import { type AssetInfo, type Compilation, type Compiler, type sources, type WebpackError } from 'webpack';
3
- type Source = sources.Source;
4
- export interface CompressionPluginOptions {
5
- test: RegExp;
6
- algorithm: 'gzip' | 'brotli';
7
- }
8
- export declare class CompressionPlugin {
9
- private name: string;
10
- private options: CompressionPluginOptions & {
11
- filename: string;
12
- };
13
- constructor(options: CompressionPluginOptions);
14
- private runCompressionAlgorithm(input: Buffer): Buffer;
15
- async compress(compiler: Compiler, compilation: Compilation, assets: Record<string, Source>);
16
- apply(compiler: Compiler);
17
- }
@@ -1 +0,0 @@
1
- import{compression as e}from"@moneko/utils";export class CompressionPlugin{constructor(e){this.name="compression-plugin";let{test:s,algorithm:t="brotli"}=e||{};this.options={test:s,algorithm:t,filename:`[path][base].${"brotli"===t?"br":"gz"}`}}runCompressionAlgorithm(s){return Buffer.from(e(Buffer.isBuffer(s)?Array.from(s):s,this.options.algorithm))}async compress(e,s,t){let o=s.getCache(this.name),{RawSource:i}=e.webpack.sources;await Promise.all(Object.keys(t).map(async t=>{let r;let a="gzip"===this.options.algorithm?"gzipped":`${this.options.algorithm}ed`,{info:m,source:p}=s.getAsset(t);if(m.compressed||!e.webpack.ModuleFilenameHelpers.matchObject.bind(void 0,this.options)(t)||m.related&&m.related[a])return!1;let n=o.getItemCache(JSON.stringify(`${t}${this.options.algorithm}`),o.getLazyHashedEtag(p)),l=await n.getPromise()||{};if(!l.source){if("function"==typeof p.buffer)r=p.buffer();else{let e=p.source();r=Buffer.isBuffer(e)?e:Buffer.from(e)}if(!l.compressed&&r)try{l.compressed=this.runCompressionAlgorithm(r)}catch(e){s.errors.push(e);return}l.compressed&&(l.source=new i(l.compressed)),await n.storePromise(l)}let f=s.getPath(this.options.filename,{filename:t}),c={compressed:!0};m.immutable&&/(\[name]|\[base]|\[file])/.test(this.options.filename)&&(c.immutable=!0),s.updateAsset(t,p,{related:{[a]:f}}),s.emitAsset(f,l.source,c)}))}apply(e){let s=this.name;e.hooks.thisCompilation.tap(s,t=>{t.hooks.processAssets.tapPromise({name:s,stage:e.webpack.Compilation.PROCESS_ASSETS_STAGE_OPTIMIZE_TRANSFER,additionalAssets:!0},s=>this.compress(e,t,s))})}}
@@ -1,21 +0,0 @@
1
- import { statSync } from 'node:fs';
2
- import { resolve } from 'node:path';
3
- import { loadFileRaw, scanFolderSync } from '@moneko/utils';
4
- import webpack, { type Compiler, type sources } from 'webpack';
5
- import log from '../commom/log.mjs';
6
- export interface CopyPluginOption {
7
- files?: string[];
8
- dirs?: string[];
9
- }
10
- declare const PLUGIN_NAME: string;
11
- declare const RawSource: typeof webpack.sources.RawSource;
12
- export declare class CopyPlugin {
13
- private readonly baseFiles: Set<string>;
14
- private readonly dirs: Set<string>;
15
- private cacheFiles: string[];
16
- private fileTimestamps: Map<string, number>;
17
- constructor(option: CopyPluginOption);
18
- private getFiles();
19
- private hasFileChanged(filePath: string): boolean;
20
- apply(compiler: Compiler);
21
- }
@@ -1 +0,0 @@
1
- import{statSync as e}from"node:fs";import{resolve as t}from"node:path";import{loadFileRaw as s,scanFolderSync as i}from"@moneko/utils";import a from"webpack";import l from"../commom/log.mjs";let o="CopyPlugin",m=a.sources.RawSource;export class CopyPlugin{constructor(e){this.cacheFiles=[],this.fileTimestamps=new Map,this.baseFiles=new Set(e.files?.map(e=>t(e))||[]),this.dirs=new Set(e.dirs||[])}getFiles(){let e=new Set(this.baseFiles);for(let t of this.dirs)i(t,["\\.*"]).forEach(t=>e.add(t));let t={deleted:[],files:[...e]};for(let s of new Set(this.cacheFiles))e.has(s)||t.deleted.push(s);return this.cacheFiles=t.files,t}hasFileChanged(t){try{let s=e(t).mtimeMs,i=this.fileTimestamps.get(t)||0;return this.fileTimestamps.set(t,s),s>i}catch(e){return l(e),!0}}apply(e){e.hooks.thisCompilation.tap({name:o,stage:e.webpack.Compilation.PROCESS_ASSETS_STAGE_ADDITIONS},e=>{let t=e.getCache(o);e.hooks.processAssets.tapPromise(o,async()=>{let i=this.getFiles();await Promise.all(i.files.map(async i=>{let a=this.hasFileChanged(i),l=t.getItemCache(i,null),o=await l.getPromise();if(o&&!a){e.emitAsset(i,o.source);return}let r=await s(i);if(null!==r){let t=new m(Buffer.from(r));await l.storePromise({source:t,timestamp:this.fileTimestamps.get(i)}),e.emitAsset(i,t)}})),i.deleted.forEach(t=>{e.deleteAsset(t),this.fileTimestamps.delete(t)})})})}}
@@ -1,11 +0,0 @@
1
- import type { Compiler, Stats } from 'webpack';
2
- export type DoneCallback = (stats: Stats) => void;
3
- export declare class DonePlugin {
4
- private name: string;
5
- private options;
6
- constructor(options: {
7
- done: DoneCallback;
8
- });
9
- apply(compiler: Compiler);
10
- }
11
- export type DonePluginOption = ConstructorParameters<typeof DonePlugin>[0]['done'];
@@ -1 +0,0 @@
1
- export class DonePlugin{constructor(o){this.name="DonePlugin",this.options=Object.assign({},o)}apply(o){o.hooks.done.tap(this.name,o=>{this.options.done(o)})}}
@@ -1,20 +0,0 @@
1
- import { join, parse, resolve } from 'node:path';
2
- import { fileURLToPath } from 'node:url';
3
- import { loadFile } from '@moneko/utils';
4
- import webpack, { type Compilation, type Compiler } from 'webpack';
5
- import { Worker } from 'worker_threads';
6
- import createTypes from '../utils/create-types.mjs';
7
- interface ModuleFederationExposesDeclarationPluginOptions {
8
- name: string;
9
- exposes: Record<string, string>;
10
- }
11
- declare const PLUGIN_NAME: string;
12
- export declare class ModuleFederationExposesDeclarationPlugin {
13
- private name: string;
14
- private assetName: string;
15
- private dts: string;
16
- private option: ModuleFederationExposesDeclarationPluginOptions;
17
- private worker: Worker;
18
- constructor(option: ModuleFederationExposesDeclarationPluginOptions);
19
- apply(compiler: Compiler);
20
- }
@@ -1 +0,0 @@
1
- import{join as e,parse as t,resolve as o}from"node:path";import{fileURLToPath as s}from"node:url";import{loadFile as i}from"@moneko/utils";import r from"webpack";import{Worker as a}from"worker_threads";import n from"../utils/create-types.mjs";let m="ModuleFederationExposesDeclarationPlugin";export class ModuleFederationExposesDeclarationPlugin{constructor(e){this.name="ModuleFederationExposesDeclarationPlugin",this.assetName="module-federation.d.ts",this.dts="",this.option=e,this.worker=new a(s(new URL("../worker/dts.mjs",import.meta.url))),this.worker.postMessage({options:{compilerOptions:{outFile:this.assetName},include:Object.values(e.exposes)}}),this.worker.once("message",e=>{this.dts=e,this.worker.terminate()})}apply(s){let{exposes:a}=this.option,p=Object.keys(a).map(e=>{let t=e.replace(/\.tsx?$/i,"");return{key:e,name:t,path:o(`types/${this.option.name}/${t}.d.ts`),originPath:a[e]}});s.hooks.thisCompilation.tap({name:m,stage:s.webpack.Compilation.PROCESS_ASSETS_STAGE_ADDITIONS},o=>{o.hooks.processAssets.tapPromise(m,async()=>{let s=p.map(async o=>{if(null!==await i(o.originPath)){let s=t(o.originPath);return`${n(e(this.option.name,o.name),`export * from '${t(s.dir).name}/${s.name}'`)}`}return""}),a=await Promise.all(s);a.unshift(this.dts),o.emitAsset("module-federation.d.ts",new r.sources.RawSource(a.join("\n")),{javascriptModule:!1})})})}}
@@ -1,8 +0,0 @@
1
- import webpack, { type Compilation, type Compiler, type ExternalModule, type Module } from 'webpack';
2
- declare const sources: typeof webpack.sources;
3
- declare const PLUGIN_NAME: string;
4
- declare function toExpression(templateUrl: string);
5
- declare function extractUrlAndGlobal(urlAndGlobal: string);
6
- export declare class ExternalRemotesPlugin {
7
- apply(compiler: Compiler);
8
- }
@@ -1 +0,0 @@
1
- import e from"webpack";let t=e.sources,r="ExternalRemotesPlugin";export class ExternalRemotesPlugin{apply(e){e.hooks.make.tap(r,e=>{let n=[];e.hooks.buildModule.tap(r,e=>{"ExternalModule"===e.constructor.name&&"script"===e.externalType&&n.push(e)}),e.hooks.afterCodeGeneration.tap(r,function(){n.map(r=>{let n=function(e){let t=e.indexOf("@");if(t<=0||t===e.length-1)throw Error(`Invalid request "${e}"`);return[e.substring(t+1),e.substring(0,t)]}(r.request)[0],o=function(e){let t=[],r=[],n=!1,o=!1;for(let s of e)if("["===s){if(n){o=!0;break}n=!0,r.length&&(t.push(`"${r.join("")}"`),r.length=0)}else if("]"===s){if(!n){o=!0;break}n=!1,r.length&&(t.push(`${r.join("")}`),r.length=0),r.length=0}else r.push(s);if(n||o)throw Error(`Invalid template URL "${e}"`);return r.length&&t.push(`"${r.join("")}"`),t.join(" + ")}(n),s=e.codeGenerationResults.get(r,void 0).sources,l=s.get("javascript")?.source();l&&s.set("javascript",new t.RawSource(l.replace(`"${n}"`,o)))})})})}}
@@ -1,48 +0,0 @@
1
- import { existsSync, readFileSync } from 'node:fs';
2
- import { basename, resolve } from 'node:path';
3
- import webpack, { type Compilation, type Compiler } from 'webpack';
4
- export interface HtmlMeta {
5
- [key: string]: string | undefined | HtmlMeta;
6
- }
7
- export interface HtmlPluginOption {
8
- favicon?: string | false;
9
- title?: string;
10
- template?: string;
11
- filename?: string | ((entryName: string) => string);
12
- inject?: boolean | 'head' | 'body';
13
- templateContent?: (options: HtmlPluginOption) => string;
14
- tags?: {
15
- textContent?: string;
16
- tag?: string;
17
- inject?: 'body' | 'head';
18
- [key: string]: string | null | boolean | number | undefined;
19
- }[];
20
- meta?: HtmlMeta;
21
- }
22
- export declare class HtmlPlugin {
23
- private options: HtmlPluginOption;
24
- private AddEntry: RegExp;
25
- private faviconPath: string;
26
- private name: string;
27
- private cachedMetaTags: string | null;
28
- private cachedCustomTags: {
29
- head: string;
30
- body: string;
31
- } | null;
32
- constructor(options: HtmlPluginOption = {});
33
- apply(compiler: Compiler);
34
- private generateDefaultTemplate(): string;
35
- private generateMetaTags(): string;
36
- private generateCustomTags(): {
37
- head: string;
38
- body: string;
39
- };
40
- private getAssets(compilation: Compilation): {
41
- js: string[];
42
- css: string[];
43
- };
44
- private injectAssets(templateHtml: string, assets: {
45
- js: string[];
46
- css: string[];
47
- }, inject: boolean | 'head' | 'body'): string;
48
- }
@@ -1 +0,0 @@
1
- import{existsSync as t,readFileSync as e}from"node:fs";import{basename as s,resolve as i}from"node:path";import o from"webpack";export class HtmlPlugin{constructor(t={}){this.AddEntry=/(?:.*\/)?main\.[a-zA-Z0-9]+\.bundle\.js$/,this.faviconPath="",this.name="HtmlPlugin",this.cachedMetaTags=null,this.cachedCustomTags=null,this.options={title:"WebApp",filename:"index.html",inject:"head",...t}}apply(n){n.hooks.compilation.tap(this.name,a=>{a.hooks.processAssets.tap({name:this.name,stage:o.Compilation.PROCESS_ASSETS_STAGE_ADDITIONAL},()=>{let h;if(this.options.favicon){let h=i(n.context,this.options.favicon);if(t(h)){let t=s(this.options.favicon),i=e(h);a.emitAsset(t,new o.sources.RawSource(i),{javascriptModule:!1});let n=a.outputOptions.publicPath||"";this.faviconPath=("auto"===n?"":n)+t}else a.warnings.push(new o.WebpackError(`Favicon file ${h} does not exist`))}if(h=this.options.templateContent?this.options.templateContent(this.options):this.options.template?e(i(n.context,this.options.template),{encoding:"utf-8"}):this.generateDefaultTemplate(),this.options.inject){let t=this.getAssets(a);h=this.injectAssets(h,t,this.options.inject)}let l="function"==typeof this.options.filename?this.options.filename("index"):this.options.filename||"index.html";a.emitAsset(l,new o.sources.RawSource(h),{javascriptModule:!1})})})}generateDefaultTemplate(){let t=this.generateMetaTags();return`<!DOCTYPE html><html><head><meta charset="utf-8">${t}<title>${this.options.title}</title><link rel="icon" type="image/x-icon" href="${this.faviconPath}"></head><body><div id="root"></div></body></html>`}generateMetaTags(){if(null!==this.cachedMetaTags)return this.cachedMetaTags;if(!this.options.meta)return this.cachedMetaTags="","";let t=Object.entries(this.options.meta).map(([t,e])=>{if("string"==typeof e)return`<meta name="${t}" content="${e}">`;if(void 0===e)return"";let s=Object.entries(e).map(([t,e])=>`${t}="${e}"`).join(" ");return`<meta ${s}>`}).join("");return this.cachedMetaTags=t,t}generateCustomTags(){if(null!==this.cachedCustomTags)return this.cachedCustomTags;let t={head:"",body:""};if(!this.options.tags)return this.cachedCustomTags=t,t;let e=[],s=[];return this.options.tags.forEach(t=>{let{tag:i="script",textContent:o="",inject:n=this.options.inject,...a}=t,h=Object.entries(a).filter(([,t])=>null!=t).map(([t,e])=>!0===e?t:`${t}="${e}"`).join(" "),l=`<${i} ${h}>${o}</${i}>`;"head"===n?e.push(l):s.push(l)}),t.head=e.join(""),t.body=s.join(""),this.cachedCustomTags=t,t}getAssets(t){let e={js:[],css:[]},s=t.outputOptions.publicPath||"",i="auto"===s?"":s;for(let s of t.entrypoints.values())for(let t of s.chunks)for(let s of t.files)s.endsWith(".js")?e.js.push(i+s):s.endsWith(".css")&&e.css.push(i+s);return e}injectAssets(t,e,s){let i=e.css.length?e.css.map(t=>`<link href="${t}" rel="stylesheet" />`).join(""):"",o=e.js.length?e.js.map(t=>`<script defer ${this.AddEntry.test(t)?'entry="true" ':""}src="${t}"></script>`).join(""):"",n=this.generateCustomTags(),a=t.split("</head>");if(2===a.length){let[t,e]=a,h=e.split("</body>");return"head"===s?`${t}${i}${o}${n.head}</head>${h[0]}${n.body}</body>${h[1]||""}`:`${t}${n.head}</head>${h[0]}${i}${o}${n.body}</body>${h[1]||""}`}return t}}