@moneko/core 3.55.5 → 3.55.7
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/plugin/compression.d.mts +1 -0
- package/lib/plugin/compression.mjs +1 -1
- package/lib/plugin/eslint.mjs +1 -1
- package/lib/plugin/stylelint.mjs +1 -1
- package/lib/worker/compression.d.mts +1 -0
- package/lib/worker/compression.mjs +1 -0
- package/lib/worker/eslint.mjs +1 -1
- package/lib/worker/stylelint.mjs +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{fileURLToPath as e}from"node:url";import{Worker as s}from"node:worker_threads";export class CompressionPlugin{constructor(t){this.name="CompressionPlugin";let{test:o,algorithm:r="brotli"}=t||{};this.options={test:o,algorithm:r,filename:`[path][base].${"brotli"===r?"br":"gz"}`},this.worker=new s(e(new URL("../worker/compression.mjs",import.meta.url))),this.worker.setMaxListeners(0)}async runCompressionAlgorithm(e,s){return new Promise(t=>{this.worker.postMessage({input:e,filename:s,algorithm:this.options.algorithm}),this.worker.addListener("message",e=>{e[0]===s&&t(Buffer.from(e[1]))})})}async compress(e,s,t){this.worker.removeAllListeners("message");let o=s.getCache(this.name),{RawSource:r}=e.webpack.sources;await Promise.allSettled(Object.keys(t).map(async t=>{let i,a="gzip"===this.options.algorithm?"gzipped":`${this.options.algorithm}ed`,{info:m,source:n}=s.getAsset(t);if(m.compressed||!e.webpack.ModuleFilenameHelpers.matchObject.bind(void 0,this.options)(t)||m.related&&m.related[a])return!1;let p=o.getItemCache(JSON.stringify(`${t}${this.options.algorithm}`),o.getLazyHashedEtag(n)),l=await p.getPromise()||{};if(!l.source){if("function"==typeof n.buffer)i=n.buffer();else{let e=n.source();i=Buffer.isBuffer(e)?e:Buffer.from(e)}if(!l.compressed&&i)try{l.compressed=await this.runCompressionAlgorithm(i,t)}catch(e){s.errors.push(e);return}l.compressed&&(l.source=new r(l.compressed)),await p.storePromise(l)}let h=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,n,{related:{[a]:h}}),s.emitAsset(h,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))}),"development"!==e.options.mode&&e.hooks.done.tap(this.name,()=>{this.worker.terminate()})}}
|
package/lib/plugin/eslint.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{fileURLToPath as
|
|
1
|
+
import{fileURLToPath as e}from"node:url";import{Worker as t}from"node:worker_threads";import s from"webpack";class o extends s.WebpackError{constructor(e){super(`[ESLint] ${e}`),this.name="ESLintError",this.stack=""}}export class ESLintPlugin{constructor(s={files:[]}){this.name="ESLintPlugin",this.options=s,this.worker=new t(e(new URL("../worker/eslint.mjs",import.meta.url))),this.worker.setMaxListeners(0)}apply(e){e.hooks.thisCompilation.tap(this.name,t=>{let s=e.modifiedFiles||new Set,o=e=>{this.report(t,e)};this.worker.on("message",o),t.hooks.finishModules.tap(this.name,e=>{let t=this.options;if(this.options?.lintDirtyModulesOnly){let o=[];for(let t of e){let e=t.resource;s.has(e)&&o.push(e)}t.files=o}this.worker.postMessage({options:t})})}),"development"!==e.options.mode&&e.hooks.done.tap(this.name,()=>{this.worker.terminate()})}report(e,t){t?.length&&e&&(t[0]?.length&&e.warnings.push(new o(t[0])),t[1]?.length&&e.errors.push(new o(t[1])))}}
|
package/lib/plugin/stylelint.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{fileURLToPath as t}from"node:url";import{Worker as e}from"node:worker_threads";import r from"webpack";class
|
|
1
|
+
import{fileURLToPath as t}from"node:url";import{Worker as e}from"node:worker_threads";import r from"webpack";class o extends r.WebpackError{constructor(t){super(`[Stylelint] ${t}`),this.name="StylelintError",this.stack=""}}export class StylelintPlugin{constructor(r={files:[]}){this.name="StylelintPlugin",this.options=r,this.worker=new e(t(new URL("../worker/stylelint.mjs",import.meta.url))),this.worker.setMaxListeners(0)}apply(t){t.hooks.thisCompilation.tap(this.name,t=>{let e=e=>{this.report(e,t)};this.worker.postMessage({options:this.options}),this.worker.on("message",e)}),"development"!==t.options.mode&&t.hooks.done.tap(this.name,()=>{this.worker.terminate()})}report(t,e){t?.length&&e&&(t[0]?.length&&e.warnings.push(new o(t[0])),t[1]?.length&&e.errors.push(new o(t[1])))}}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{isUint8Array as e}from"node:util/types";import{parentPort as r}from"node:worker_threads";import{compression as o}from"@moneko/utils";r?.setMaxListeners(0),r?.on("message",async({input:s,filename:t,algorithm:m})=>{let f=o(Buffer.isBuffer(s)||e(s)?Array.from(s):s,m);r?.postMessage([t,f])});
|
package/lib/worker/eslint.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
let e
|
|
1
|
+
let a,e;import{relative as t}from"node:path";import{parentPort as r}from"node:worker_threads";import{ESLint as o}from"@moneko/eslint";import i from"../commom/paths.mjs";if(!r)throw Error("This file must be run as a worker");r?.setMaxListeners(0),r.on("message",async({options:s})=>{a||(a=new o({cache:s.cache,cacheLocation:s.cacheLocation,cacheStrategy:s.cacheStrategy,fix:s.fix}),e=await a.loadFormatter("stylish"));let m=s.files.map(a=>(s.lintDirtyModulesOnly?t(i.programPath,a):a).replace(/\\/g,"/")),n=await a.lintFiles(m),c=[],l=[];s.fix&&await o.outputFixes(n),n.forEach(a=>{a.errorCount?l.push(a):a.warningCount&&c.push(a)});let h=await Promise.all([e.format(c),e.format(l)]);r.postMessage(h.map(a=>a.replace(/[^\r\n]*(\r?\n)*$/,"")))});
|
package/lib/worker/stylelint.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{parentPort as e}from"node:worker_threads";import{stylelint as r}from"@moneko/stylelint";if(!e)throw Error("This file must be run as a worker");let t=
|
|
1
|
+
import{parentPort as e}from"node:worker_threads";import{stylelint as r}from"@moneko/stylelint";if(!e)throw Error("This file must be run as a worker");let t=await r.formatters.string;e?.setMaxListeners(0),e.on("message",async({options:i})=>{let n=await r.lint({cache:i.cache,cacheLocation:i.cacheLocation,fix:i.fix,files:i.files.map(e=>e.replace(/\\/g,"/")),quietDeprecationWarnings:i.quietDeprecationWarnings,quiet:i.quiet});delete n.output;let a=[],s=[];n.results.forEach(e=>{if(!e.ignored&&(e.errored||e.parseErrors.length||e.invalidOptionWarnings.length||e.deprecations.length)){let r=[],t=[];e.warnings.forEach(e=>{"error"===e.severity?r.push(e):"warning"===e.severity&&t.push(e)}),r.length>0&&a.push({...e,warnings:r}),t.length>0&&s.push({...e,warnings:t})}});let o=[t(s,n),t(a,n)];e.postMessage(o.map(e=>e.replace(/[^\r\n]*(\r?\n)*$/,"")))});
|