@moneko/core 3.55.3-beta.1 → 3.55.3-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.
- package/lib/commom/css-in-js-minify.d.mts +13 -0
- package/lib/commom/css-in-js-minify.mjs +1 -0
- package/lib/index.d.mts +1 -1
- package/lib/loader/css-in-js-minify.cjs +1 -1
- package/lib/loader/css-in-js-minify.d.cts +1 -12
- package/lib/worker/css-in-js-minify.d.mts +1 -0
- package/lib/worker/css-in-js-minify.mjs +1 -0
- package/package.json +1 -1
- package/typings/global.d.ts +6 -1
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export interface CssInJsMinifyOption {
|
|
2
|
+
/**
|
|
3
|
+
* css in js 使用的模块
|
|
4
|
+
* @default '@moneko/css'
|
|
5
|
+
*/
|
|
6
|
+
moduleName: string;
|
|
7
|
+
/**
|
|
8
|
+
* css in js 字符串模版函数
|
|
9
|
+
* @default ['css', 'injectGlobal']
|
|
10
|
+
*/
|
|
11
|
+
allowFuncs: string[];
|
|
12
|
+
}
|
|
13
|
+
export declare function cssInJsMinify(sourceCode: string, options: CssInJsMinifyOption): Promise<import("@swc/core").Output>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{parse as e,print as t}from"@swc/core";import{compile as r}from"stylis";import n from"./log.mjs";function a(e){return{type:"iTemplateElement",span:{start:0,end:0,ctxt:0},tail:!1,cooked:e,raw:e}}function i(e,t){if("Identifier"===e.tag.type&&t.includes(e.tag.value)){let t=e.template,n=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 a=t[n],i=a.parent,l=a.children;i?!function(e){var t;return"rule"===e.type&&e.parent&&(t=e.parent,e.line===t.line&&e.column===t.column)}(a)&&i.children.push(a):r.push(a),Array.isArray(l)&&(a.children=[],e(l,r))}return r}(r(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)),[])),i=function(e,t){let r=function(e){let t,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?[]:[a(e)];let n=[],i=[],l=0;return r.forEach(({value:s,p1:p,index:o},u)=>{let c=e.substring(l,o);l=l+c.length+s.length,c||0!==u?n.push(a(c)):n.push(a("")),i.push(t[p]),u===r.length-1&&n.push(a(e.substring(o+s.length)))}),i.reduce((e,t,r)=>e.concat([t],n[r+1]),[n[0]]).filter(e=>""!==e.raw)}(n,t.expressions);if(n.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}}}export async function cssInJsMinify(r,a){let{moduleName:l,allowFuncs:s}=a||{};try{let n=await e(r,{syntax:"ecmascript"}),a=[];return n.body.forEach(e=>{"ImportDeclaration"===e.type&&e.source.value===l&&e.specifiers.forEach(e=>{"ImportSpecifier"===e.type&&(e.imported&&s.includes(e.imported.value)?a.push(e.local.value):s.includes(e.local.value)&&a.push(e.local.value))})}),n.body.forEach(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&&i(e.expression,a)}),t&&"VariableDeclaration"===t.type&&t.declarations.forEach(e=>{e.init?.type==="TaggedTemplateExpression"&&i(e.init,a)})}else"CallExpression"===e.type&&e.arguments.forEach(e=>{e.expression&&"TaggedTemplateExpression"===e.expression.type&&i(e.expression,a)})}),await t(n)}catch(e){return n(e),{code:r,map:void 0}}}
|
package/lib/index.d.mts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export type * from '../typings/global.js';
|
|
2
|
+
export type { cssInJsMinify, CssInJsMinifyOption } from './commom/css-in-js-minify.mjs';
|
|
2
3
|
export { default as hasPkg } from './commom/has-pkg.mjs';
|
|
3
4
|
export { getIPv4, getPort } from './commom/net.mjs';
|
|
4
5
|
export { default as open } from './commom/open.mjs';
|
|
@@ -10,7 +11,6 @@ export { default as Rule } from './commom/rule.mjs';
|
|
|
10
11
|
export { default as timer } from './commom/timer.mjs';
|
|
11
12
|
export { type MockConfiguration, type ProxyFuncType, type RequestFormData, yApiMock, type YApiOption, type YApiOptionBySchema, yApiSchemaMock, } from './dev/mock.mjs';
|
|
12
13
|
export type { ProxyConfig } from './dev/proxy.mjs';
|
|
13
|
-
export type { CssInJsMinifyOption } from './loader/css-in-js-minify.cjs';
|
|
14
14
|
export type { ReactCompilerOption } from './loader/react-compiler.cjs';
|
|
15
15
|
export { type JsxDomExpressions, default as jsxDomExpressions, } from './options/jsx-dom-expressions.mjs';
|
|
16
16
|
export { type OptimizationSplitChunksOptions, default as splitChunk, } from './options/split-chunk.mjs';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),Object.defineProperty(exports,"default",{enumerable:!0,get:function(){return
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),Object.defineProperty(exports,"default",{enumerable:!0,get:function(){return t}});const e=require("node:path"),s=new(require("node:worker_threads")).Worker((0,e.join)(__dirname,"../worker/css-in-js-minify.mjs"));async function t(e){this.cacheable&&this.cacheable(),this._compiler?.options.mode!=="development"&&this._compiler?.hooks.done.tap("css-in-js-minify-loader",()=>{s.terminate()});let t=this.async(),i=this.getOptions(),o=this.resourcePath;s.postMessage({options:i,code:e,filename:o}),s.addListener("message",function e(i){o===i[0]&&(t(i[1],i[2]),s.removeListener("message",e))})}s.setMaxListeners(0);
|
|
@@ -1,14 +1,3 @@
|
|
|
1
1
|
import type { LoaderContext } from 'webpack';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* css in js 使用的模块
|
|
5
|
-
* @default '@moneko/css'
|
|
6
|
-
*/
|
|
7
|
-
moduleName: string;
|
|
8
|
-
/**
|
|
9
|
-
* css in js 字符串模版函数
|
|
10
|
-
* @default ['css', 'injectGlobal']
|
|
11
|
-
*/
|
|
12
|
-
allowFuncs: string[];
|
|
13
|
-
}
|
|
2
|
+
import type { CssInJsMinifyOption } from '../commom/css-in-js-minify.mjs' with { 'resolution-mode': 'import' };
|
|
14
3
|
export default function cssInJsMinifyLoader(this: LoaderContext<CssInJsMinifyOption>, sourceCode: string): Promise<void>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{parentPort as s}from"node:worker_threads";import{cssInJsMinify as e}from"../commom/css-in-js-minify.mjs";s?.setMaxListeners(0),s?.on("message",async({code:o,filename:m,options:r})=>{try{let t=await e(o,r);s?.postMessage([m,null,t?.code??o,t.map])}catch(e){s?.postMessage([m,e,o,void 0])}});
|
package/package.json
CHANGED
package/typings/global.d.ts
CHANGED
|
@@ -22,7 +22,7 @@ import type { BundleAnalyzerOption } from './bundle-analyzer.d.ts';
|
|
|
22
22
|
import type { ESLintOption } from '../lib/plugin/eslint.mjs';
|
|
23
23
|
import type { StylelintOption } from '../lib/plugin/stylelint.mjs';
|
|
24
24
|
import type { SwcImportOnDemandTransform } from '../lib/commom/transfer-import-on-demand.mjs';
|
|
25
|
-
import type { CssInJsMinifyOption } from '../lib/
|
|
25
|
+
import type { CssInJsMinifyOption } from '../lib/commom/css-in-js-minify.mjs';
|
|
26
26
|
import type { ReactCompilerOption } from '../lib/loader/react-compiler.cjs';
|
|
27
27
|
import type { CompressionPluginOptions } from '../lib/plugin/compression.mjs';
|
|
28
28
|
import type { JsxDomExpressions } from '../lib/options/jsx-dom-expressions.mjs';
|
|
@@ -235,6 +235,11 @@ export declare type ConfigType = {
|
|
|
235
235
|
/**
|
|
236
236
|
* 使用 HTTPS 服务器作为开发服务器
|
|
237
237
|
* @description
|
|
238
|
+
* 如果你是macOS用户, 当启用 https 时, 第一次启动需要通过 `sudo ...` 启动提权以便安装证书;
|
|
239
|
+
* ```bash
|
|
240
|
+
* sudo npm start
|
|
241
|
+
* ```
|
|
242
|
+
* @description
|
|
238
243
|
* 配置 HTTPS 开发服务器的密钥和证书路径。
|
|
239
244
|
*
|
|
240
245
|
* `key` 和 `cert` 参数指定了私钥和证书文件的位置。
|