update
This commit is contained in:
+13
@@ -2,6 +2,19 @@
|
||||
|
||||
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
|
||||
|
||||
## [4.9.0](https://github.com/faceyspacey/extract-css-chunks-webpack-plugin/compare/v4.8.0...v4.9.0) (2020-12-07)
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* adding federated stats ([#303](https://github.com/faceyspacey/extract-css-chunks-webpack-plugin/issues/303)) ([c17d755](https://github.com/faceyspacey/extract-css-chunks-webpack-plugin/commit/c17d75547a5efb5971d03555163ea4d685080706))
|
||||
* adding federated stats ([#304](https://github.com/faceyspacey/extract-css-chunks-webpack-plugin/issues/304)) ([1eab2d0](https://github.com/faceyspacey/extract-css-chunks-webpack-plugin/commit/1eab2d0b8868837de8f89f68c1ad14be741f3e78))
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* Check if bestMatch exists before pop() ([#294](https://github.com/faceyspacey/extract-css-chunks-webpack-plugin/issues/294)) ([ef82da9](https://github.com/faceyspacey/extract-css-chunks-webpack-plugin/commit/ef82da9068bd699344774d39f61b7ead8cf682cb))
|
||||
|
||||
### [0.9.0](https://github.com/webpack-contrib/extract-css-chunks-webpack-plugin/compare/v0.8.2...v0.9.0) (2019-12-20)
|
||||
|
||||
|
||||
|
||||
+3
-1
@@ -282,7 +282,8 @@ class ExtractCssChunksPlugin {
|
||||
const {
|
||||
insert
|
||||
} = this.options;
|
||||
return Template.asString([source, '', `// ${pluginName} CSS loading`, `var cssChunks = ${JSON.stringify(chunkMap)};`, 'if(installedCssChunks[chunkId]) promises.push(installedCssChunks[chunkId]);', 'else if(installedCssChunks[chunkId] !== 0 && cssChunks[chunkId]) {', Template.indent(['promises.push(installedCssChunks[chunkId] = new Promise(function(resolve, reject) {', Template.indent([`var href = ${linkHrefPath};`, `var fullhref = ${mainTemplate.requireFn}.p + href;`, 'var existingLinkTags = document.getElementsByTagName("link");', 'for(var i = 0; i < existingLinkTags.length; i++) {', Template.indent(['var tag = existingLinkTags[i];', 'var dataHref = tag.getAttribute("data-href") || tag.getAttribute("href");', 'if(tag.rel === "stylesheet" && (dataHref === href || dataHref === fullhref)) return resolve();']), '}', 'var existingStyleTags = document.getElementsByTagName("style");', 'for(var i = 0; i < existingStyleTags.length; i++) {', Template.indent(['var tag = existingStyleTags[i];', 'var dataHref = tag.getAttribute("data-href");', 'if(dataHref === href || dataHref === fullhref) return resolve();']), '}', 'var linkTag = document.createElement("link");', 'linkTag.rel = "stylesheet";', 'linkTag.type = "text/css";', 'linkTag.onload = resolve;', 'linkTag.onerror = function(event) {', Template.indent(['var request = event && event.target && event.target.src || fullhref;', 'var err = new Error("Loading CSS chunk " + chunkId + " failed.\\n(" + request + ")");', 'err.code = "CSS_CHUNK_LOAD_FAILED";', 'err.request = request;', 'delete installedCssChunks[chunkId]', 'linkTag.parentNode.removeChild(linkTag)', 'reject(err);']), '};', 'linkTag.href = fullhref;', crossOriginLoading ? Template.asString([`if (linkTag.href.indexOf(window.location.origin + '/') !== 0) {`, Template.indent(`linkTag.crossOrigin = ${JSON.stringify(crossOriginLoading)};`), '}']) : '', insert ? 'insert(linkTag);' : 'var head = document.getElementsByTagName("head")[0]; head.appendChild(linkTag)']), '}).then(function() {', Template.indent(['installedCssChunks[chunkId] = 0;']), '}));']), '}']);
|
||||
const supportsPreload = '(function() { try { return document.createElement("link").relList.supports("preload"); } catch(e) { return false; }}());';
|
||||
return Template.asString([source, '', `// ${pluginName} CSS loading`, `var supportsPreload = ${supportsPreload}`, `var cssChunks = ${JSON.stringify(chunkMap)};`, 'if(installedCssChunks[chunkId]) promises.push(installedCssChunks[chunkId]);', 'else if(installedCssChunks[chunkId] !== 0 && cssChunks[chunkId]) {', Template.indent(['promises.push(installedCssChunks[chunkId] = new Promise(function(resolve, reject) {', Template.indent([`var href = ${linkHrefPath};`, `var fullhref = ${mainTemplate.requireFn}.p + href;`, 'var existingLinkTags = document.getElementsByTagName("link");', 'for(var i = 0; i < existingLinkTags.length; i++) {', Template.indent(['var tag = existingLinkTags[i];', 'var dataHref = tag.getAttribute("data-href") || tag.getAttribute("href");', 'if((tag.rel === "stylesheet" || tag.rel === "preload") && (dataHref === href || dataHref === fullhref)) return resolve();']), '}', 'var existingStyleTags = document.getElementsByTagName("style");', 'for(var i = 0; i < existingStyleTags.length; i++) {', Template.indent(['var tag = existingStyleTags[i];', 'var dataHref = tag.getAttribute("data-href");', 'if(dataHref === href || dataHref === fullhref) return resolve();']), '}', 'var linkTag = document.createElement("link");', 'linkTag.rel = supportsPreload ? "preload": "stylesheet";', 'supportsPreload ? linkTag.as = "style" : linkTag.type = "text/css";', 'linkTag.onload = resolve;', 'linkTag.onerror = function(event) {', Template.indent(['var request = event && event.target && event.target.src || fullhref;', 'var err = new Error("Loading CSS chunk " + chunkId + " failed.\\n(" + request + ")");', 'err.code = "CSS_CHUNK_LOAD_FAILED";', 'err.request = request;', 'delete installedCssChunks[chunkId]', 'linkTag.parentNode.removeChild(linkTag)', 'reject(err);']), '};', 'linkTag.href = fullhref;', crossOriginLoading ? Template.asString([`if (linkTag.href.indexOf(window.location.origin + '/') !== 0) {`, Template.indent(`linkTag.crossOrigin = ${JSON.stringify(crossOriginLoading)};`), '}']) : '', insert ? `var insert = ${insert};\ninsert(linkTag);` : 'var head = document.getElementsByTagName("head")[0]; head.appendChild(linkTag)']), '}).then(function() {', Template.indent(['installedCssChunks[chunkId] = 0;', 'if(supportsPreload) {', Template.indent(['var execLinkTag = document.createElement("link");', `execLinkTag.href = ${mainTemplate.requireFn}.p + ${linkHrefPath};`, 'execLinkTag.rel = "stylesheet";', 'execLinkTag.type = "text/css";', 'document.body.appendChild(execLinkTag);']), '}']), '}));']), '}']);
|
||||
}
|
||||
|
||||
return source;
|
||||
@@ -381,6 +382,7 @@ class ExtractCssChunksPlugin {
|
||||
// no module found => there is a conflict
|
||||
// use list with fewest failed deps
|
||||
// and emit a warning
|
||||
if (!bestMatch) break;
|
||||
const fallbackModule = bestMatch.pop();
|
||||
|
||||
if (!this.options.ignoreOrder) {
|
||||
|
||||
+1
-1
@@ -43,7 +43,7 @@ function hotLoader(content, context) {
|
||||
return `${content}
|
||||
if(module.hot) {
|
||||
// ${Date.now()}
|
||||
var cssReload = require(${_loaderUtils.default.stringifyRequest(context.context, _path.default.join(__dirname, 'hmr/hotModuleReplacement.js'))})(module.id, ${JSON.stringify(_objectSpread({}, context.options, {
|
||||
var cssReload = require(${_loaderUtils.default.stringifyRequest(context.context, _path.default.join(__dirname, 'hmr/hotModuleReplacement.js'))})(module.id, ${JSON.stringify(_objectSpread(_objectSpread({}, context.options), {}, {
|
||||
locals: !!context.locals
|
||||
}))});
|
||||
module.hot.dispose(cssReload);
|
||||
|
||||
+36
@@ -0,0 +1,36 @@
|
||||
declare module 'extract-css-chunks-webpack-plugin' {
|
||||
import { ChunkData, Plugin } from 'webpack';
|
||||
|
||||
class ExtractCssChunksPlugin extends Plugin {
|
||||
static loader: string;
|
||||
|
||||
constructor(options?: ExtractCssChunksPlugin.PluginOptions);
|
||||
}
|
||||
|
||||
namespace ExtractCssChunksPlugin {
|
||||
interface PluginOptions {
|
||||
/**
|
||||
* The filename of the entry chunk.
|
||||
*/
|
||||
filename?: string;
|
||||
/**
|
||||
* The filename of non-entry chunks.
|
||||
*/
|
||||
chunkFilename?: string;
|
||||
/**
|
||||
* Generates a file name (or template) based on chunk data.
|
||||
*/
|
||||
moduleFilename?: (chunk: ChunkData) => string;
|
||||
/**
|
||||
* Remove warnings about conflicting order.
|
||||
*/
|
||||
ignoreOrder?: boolean;
|
||||
/**
|
||||
* Inserts `<link>` at the given position (https://github.com/faceyspacey/extract-css-chunks-webpack-pluginn#insert).
|
||||
*/
|
||||
insert?: string | Function;
|
||||
}
|
||||
}
|
||||
|
||||
export = ExtractCssChunksPlugin;
|
||||
}
|
||||
Generated
Vendored
+25
-3
@@ -39,11 +39,34 @@ function encodeBufferToBase(buffer, base) {
|
||||
return output;
|
||||
}
|
||||
|
||||
let createMd4 = undefined;
|
||||
let BatchedHash = undefined;
|
||||
|
||||
function getHashDigest(buffer, hashType, digestType, maxLength) {
|
||||
hashType = hashType || 'md4';
|
||||
maxLength = maxLength || 9999;
|
||||
|
||||
const hash = require('crypto').createHash(hashType);
|
||||
let hash;
|
||||
|
||||
try {
|
||||
hash = require('crypto').createHash(hashType);
|
||||
} catch (error) {
|
||||
if (error.code === 'ERR_OSSL_EVP_UNSUPPORTED' && hashType === 'md4') {
|
||||
if (createMd4 === undefined) {
|
||||
createMd4 = require('./hash/md4');
|
||||
|
||||
if (BatchedHash === undefined) {
|
||||
BatchedHash = require('./hash/BatchedHash');
|
||||
}
|
||||
}
|
||||
|
||||
hash = new BatchedHash(createMd4());
|
||||
}
|
||||
|
||||
if (!hash) {
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
hash.update(buffer);
|
||||
|
||||
@@ -54,8 +77,7 @@ function getHashDigest(buffer, hashType, digestType, maxLength) {
|
||||
digestType === 'base49' ||
|
||||
digestType === 'base52' ||
|
||||
digestType === 'base58' ||
|
||||
digestType === 'base62' ||
|
||||
digestType === 'base64'
|
||||
digestType === 'base62'
|
||||
) {
|
||||
return encodeBufferToBase(hash.digest(), digestType.substr(4)).substr(
|
||||
0,
|
||||
|
||||
Generated
Vendored
+64
@@ -0,0 +1,64 @@
|
||||
const MAX_SHORT_STRING = require('./wasm-hash').MAX_SHORT_STRING;
|
||||
|
||||
class BatchedHash {
|
||||
constructor(hash) {
|
||||
this.string = undefined;
|
||||
this.encoding = undefined;
|
||||
this.hash = hash;
|
||||
}
|
||||
|
||||
/**
|
||||
* Update hash {@link https://nodejs.org/api/crypto.html#crypto_hash_update_data_inputencoding}
|
||||
* @param {string|Buffer} data data
|
||||
* @param {string=} inputEncoding data encoding
|
||||
* @returns {this} updated hash
|
||||
*/
|
||||
update(data, inputEncoding) {
|
||||
if (this.string !== undefined) {
|
||||
if (
|
||||
typeof data === 'string' &&
|
||||
inputEncoding === this.encoding &&
|
||||
this.string.length + data.length < MAX_SHORT_STRING
|
||||
) {
|
||||
this.string += data;
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
this.hash.update(this.string, this.encoding);
|
||||
this.string = undefined;
|
||||
}
|
||||
|
||||
if (typeof data === 'string') {
|
||||
if (
|
||||
data.length < MAX_SHORT_STRING &&
|
||||
// base64 encoding is not valid since it may contain padding chars
|
||||
(!inputEncoding || !inputEncoding.startsWith('ba'))
|
||||
) {
|
||||
this.string = data;
|
||||
this.encoding = inputEncoding;
|
||||
} else {
|
||||
this.hash.update(data, inputEncoding);
|
||||
}
|
||||
} else {
|
||||
this.hash.update(data);
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculates the digest {@link https://nodejs.org/api/crypto.html#crypto_hash_digest_encoding}
|
||||
* @param {string=} encoding encoding of the return value
|
||||
* @returns {string|Buffer} digest
|
||||
*/
|
||||
digest(encoding) {
|
||||
if (this.string !== undefined) {
|
||||
this.hash.update(this.string, this.encoding);
|
||||
}
|
||||
|
||||
return this.hash.digest(encoding);
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = BatchedHash;
|
||||
Generated
Vendored
+20
@@ -0,0 +1,20 @@
|
||||
/*
|
||||
MIT License http://www.opensource.org/licenses/mit-license.php
|
||||
Author Tobias Koppers @sokra
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
const create = require('./wasm-hash');
|
||||
|
||||
//#region wasm code: md4 (../../../assembly/hash/md4.asm.ts) --initialMemory 1
|
||||
const md4 = new WebAssembly.Module(
|
||||
Buffer.from(
|
||||
// 2150 bytes
|
||||
'AGFzbQEAAAABCAJgAX8AYAAAAwUEAQAAAAUDAQABBhoFfwFBAAt/AUEAC38BQQALfwFBAAt/AUEACwciBARpbml0AAAGdXBkYXRlAAIFZmluYWwAAwZtZW1vcnkCAAqFEAQmAEGBxpS6BiQBQYnXtv5+JAJB/rnrxXkkA0H2qMmBASQEQQAkAAvMCgEYfyMBIQojAiEGIwMhByMEIQgDQCAAIAVLBEAgBSgCCCINIAcgBiAFKAIEIgsgCCAHIAUoAgAiDCAKIAggBiAHIAhzcXNqakEDdyIDIAYgB3Nxc2pqQQd3IgEgAyAGc3FzampBC3chAiAFKAIUIg8gASACIAUoAhAiCSADIAEgBSgCDCIOIAYgAyACIAEgA3Nxc2pqQRN3IgQgASACc3FzampBA3ciAyACIARzcXNqakEHdyEBIAUoAiAiEiADIAEgBSgCHCIRIAQgAyAFKAIYIhAgAiAEIAEgAyAEc3FzampBC3ciAiABIANzcXNqakETdyIEIAEgAnNxc2pqQQN3IQMgBSgCLCIVIAQgAyAFKAIoIhQgAiAEIAUoAiQiEyABIAIgAyACIARzcXNqakEHdyIBIAMgBHNxc2pqQQt3IgIgASADc3FzampBE3chBCAPIBAgCSAVIBQgEyAFKAI4IhYgAiAEIAUoAjQiFyABIAIgBSgCMCIYIAMgASAEIAEgAnNxc2pqQQN3IgEgAiAEc3FzampBB3ciAiABIARzcXNqakELdyIDIAkgAiAMIAEgBSgCPCIJIAQgASADIAEgAnNxc2pqQRN3IgEgAiADcnEgAiADcXJqakGZ84nUBWpBA3ciAiABIANycSABIANxcmpqQZnzidQFakEFdyIEIAEgAnJxIAEgAnFyaiASakGZ84nUBWpBCXciAyAPIAQgCyACIBggASADIAIgBHJxIAIgBHFyampBmfOJ1AVqQQ13IgEgAyAEcnEgAyAEcXJqakGZ84nUBWpBA3ciAiABIANycSABIANxcmpqQZnzidQFakEFdyIEIAEgAnJxIAEgAnFyampBmfOJ1AVqQQl3IgMgECAEIAIgFyABIAMgAiAEcnEgAiAEcXJqakGZ84nUBWpBDXciASADIARycSADIARxcmogDWpBmfOJ1AVqQQN3IgIgASADcnEgASADcXJqakGZ84nUBWpBBXciBCABIAJycSABIAJxcmpqQZnzidQFakEJdyIDIBEgBCAOIAIgFiABIAMgAiAEcnEgAiAEcXJqakGZ84nUBWpBDXciASADIARycSADIARxcmpqQZnzidQFakEDdyICIAEgA3JxIAEgA3FyampBmfOJ1AVqQQV3IgQgASACcnEgASACcXJqakGZ84nUBWpBCXciAyAMIAIgAyAJIAEgAyACIARycSACIARxcmpqQZnzidQFakENdyIBcyAEc2pqQaHX5/YGakEDdyICIAQgASACcyADc2ogEmpBodfn9gZqQQl3IgRzIAFzampBodfn9gZqQQt3IgMgAiADIBggASADIARzIAJzampBodfn9gZqQQ93IgFzIARzaiANakGh1+f2BmpBA3ciAiAUIAQgASACcyADc2pqQaHX5/YGakEJdyIEcyABc2pqQaHX5/YGakELdyIDIAsgAiADIBYgASADIARzIAJzampBodfn9gZqQQ93IgFzIARzampBodfn9gZqQQN3IgIgEyAEIAEgAnMgA3NqakGh1+f2BmpBCXciBHMgAXNqakGh1+f2BmpBC3chAyAKIA4gAiADIBcgASADIARzIAJzampBodfn9gZqQQ93IgFzIARzampBodfn9gZqQQN3IgJqIQogBiAJIAEgESADIAIgFSAEIAEgAnMgA3NqakGh1+f2BmpBCXciBHMgAXNqakGh1+f2BmpBC3ciAyAEcyACc2pqQaHX5/YGakEPd2ohBiADIAdqIQcgBCAIaiEIIAVBQGshBQwBCwsgCiQBIAYkAiAHJAMgCCQECw0AIAAQASMAIABqJAAL/wQCA38BfiMAIABqrUIDhiEEIABByABqQUBxIgJBCGshAyAAIgFBAWohACABQYABOgAAA0AgACACSUEAIABBB3EbBEAgAEEAOgAAIABBAWohAAwBCwsDQCAAIAJJBEAgAEIANwMAIABBCGohAAwBCwsgAyAENwMAIAIQAUEAIwGtIgRC//8DgyAEQoCA/P8Pg0IQhoQiBEL/gYCA8B+DIARCgP6DgIDgP4NCCIaEIgRCj4C8gPCBwAeDQgiGIARC8IHAh4CegPgAg0IEiIQiBEKGjJiw4MCBgwZ8QgSIQoGChIiQoMCAAYNCJ34gBEKw4MCBg4aMmDCEfDcDAEEIIwKtIgRC//8DgyAEQoCA/P8Pg0IQhoQiBEL/gYCA8B+DIARCgP6DgIDgP4NCCIaEIgRCj4C8gPCBwAeDQgiGIARC8IHAh4CegPgAg0IEiIQiBEKGjJiw4MCBgwZ8QgSIQoGChIiQoMCAAYNCJ34gBEKw4MCBg4aMmDCEfDcDAEEQIwOtIgRC//8DgyAEQoCA/P8Pg0IQhoQiBEL/gYCA8B+DIARCgP6DgIDgP4NCCIaEIgRCj4C8gPCBwAeDQgiGIARC8IHAh4CegPgAg0IEiIQiBEKGjJiw4MCBgwZ8QgSIQoGChIiQoMCAAYNCJ34gBEKw4MCBg4aMmDCEfDcDAEEYIwStIgRC//8DgyAEQoCA/P8Pg0IQhoQiBEL/gYCA8B+DIARCgP6DgIDgP4NCCIaEIgRCj4C8gPCBwAeDQgiGIARC8IHAh4CegPgAg0IEiIQiBEKGjJiw4MCBgwZ8QgSIQoGChIiQoMCAAYNCJ34gBEKw4MCBg4aMmDCEfDcDAAs=',
|
||||
'base64'
|
||||
)
|
||||
);
|
||||
//#endregion
|
||||
|
||||
module.exports = create.bind(null, md4, [], 64, 32);
|
||||
Generated
Vendored
+208
@@ -0,0 +1,208 @@
|
||||
/*
|
||||
MIT License http://www.opensource.org/licenses/mit-license.php
|
||||
Author Tobias Koppers @sokra
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
// 65536 is the size of a wasm memory page
|
||||
// 64 is the maximum chunk size for every possible wasm hash implementation
|
||||
// 4 is the maximum number of bytes per char for string encoding (max is utf-8)
|
||||
// ~3 makes sure that it's always a block of 4 chars, so avoid partially encoded bytes for base64
|
||||
const MAX_SHORT_STRING = Math.floor((65536 - 64) / 4) & ~3;
|
||||
|
||||
class WasmHash {
|
||||
/**
|
||||
* @param {WebAssembly.Instance} instance wasm instance
|
||||
* @param {WebAssembly.Instance[]} instancesPool pool of instances
|
||||
* @param {number} chunkSize size of data chunks passed to wasm
|
||||
* @param {number} digestSize size of digest returned by wasm
|
||||
*/
|
||||
constructor(instance, instancesPool, chunkSize, digestSize) {
|
||||
const exports = /** @type {any} */ (instance.exports);
|
||||
|
||||
exports.init();
|
||||
|
||||
this.exports = exports;
|
||||
this.mem = Buffer.from(exports.memory.buffer, 0, 65536);
|
||||
this.buffered = 0;
|
||||
this.instancesPool = instancesPool;
|
||||
this.chunkSize = chunkSize;
|
||||
this.digestSize = digestSize;
|
||||
}
|
||||
|
||||
reset() {
|
||||
this.buffered = 0;
|
||||
this.exports.init();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {Buffer | string} data data
|
||||
* @param {BufferEncoding=} encoding encoding
|
||||
* @returns {this} itself
|
||||
*/
|
||||
update(data, encoding) {
|
||||
if (typeof data === 'string') {
|
||||
while (data.length > MAX_SHORT_STRING) {
|
||||
this._updateWithShortString(data.slice(0, MAX_SHORT_STRING), encoding);
|
||||
data = data.slice(MAX_SHORT_STRING);
|
||||
}
|
||||
|
||||
this._updateWithShortString(data, encoding);
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
this._updateWithBuffer(data);
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} data data
|
||||
* @param {BufferEncoding=} encoding encoding
|
||||
* @returns {void}
|
||||
*/
|
||||
_updateWithShortString(data, encoding) {
|
||||
const { exports, buffered, mem, chunkSize } = this;
|
||||
|
||||
let endPos;
|
||||
|
||||
if (data.length < 70) {
|
||||
if (!encoding || encoding === 'utf-8' || encoding === 'utf8') {
|
||||
endPos = buffered;
|
||||
for (let i = 0; i < data.length; i++) {
|
||||
const cc = data.charCodeAt(i);
|
||||
|
||||
if (cc < 0x80) {
|
||||
mem[endPos++] = cc;
|
||||
} else if (cc < 0x800) {
|
||||
mem[endPos] = (cc >> 6) | 0xc0;
|
||||
mem[endPos + 1] = (cc & 0x3f) | 0x80;
|
||||
endPos += 2;
|
||||
} else {
|
||||
// bail-out for weird chars
|
||||
endPos += mem.write(data.slice(i), endPos, encoding);
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else if (encoding === 'latin1') {
|
||||
endPos = buffered;
|
||||
|
||||
for (let i = 0; i < data.length; i++) {
|
||||
const cc = data.charCodeAt(i);
|
||||
|
||||
mem[endPos++] = cc;
|
||||
}
|
||||
} else {
|
||||
endPos = buffered + mem.write(data, buffered, encoding);
|
||||
}
|
||||
} else {
|
||||
endPos = buffered + mem.write(data, buffered, encoding);
|
||||
}
|
||||
|
||||
if (endPos < chunkSize) {
|
||||
this.buffered = endPos;
|
||||
} else {
|
||||
const l = endPos & ~(this.chunkSize - 1);
|
||||
|
||||
exports.update(l);
|
||||
|
||||
const newBuffered = endPos - l;
|
||||
|
||||
this.buffered = newBuffered;
|
||||
|
||||
if (newBuffered > 0) {
|
||||
mem.copyWithin(0, l, endPos);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {Buffer} data data
|
||||
* @returns {void}
|
||||
*/
|
||||
_updateWithBuffer(data) {
|
||||
const { exports, buffered, mem } = this;
|
||||
const length = data.length;
|
||||
|
||||
if (buffered + length < this.chunkSize) {
|
||||
data.copy(mem, buffered, 0, length);
|
||||
|
||||
this.buffered += length;
|
||||
} else {
|
||||
const l = (buffered + length) & ~(this.chunkSize - 1);
|
||||
|
||||
if (l > 65536) {
|
||||
let i = 65536 - buffered;
|
||||
|
||||
data.copy(mem, buffered, 0, i);
|
||||
exports.update(65536);
|
||||
|
||||
const stop = l - buffered - 65536;
|
||||
|
||||
while (i < stop) {
|
||||
data.copy(mem, 0, i, i + 65536);
|
||||
exports.update(65536);
|
||||
i += 65536;
|
||||
}
|
||||
|
||||
data.copy(mem, 0, i, l - buffered);
|
||||
|
||||
exports.update(l - buffered - i);
|
||||
} else {
|
||||
data.copy(mem, buffered, 0, l - buffered);
|
||||
|
||||
exports.update(l);
|
||||
}
|
||||
|
||||
const newBuffered = length + buffered - l;
|
||||
|
||||
this.buffered = newBuffered;
|
||||
|
||||
if (newBuffered > 0) {
|
||||
data.copy(mem, 0, length - newBuffered, length);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
digest(type) {
|
||||
const { exports, buffered, mem, digestSize } = this;
|
||||
|
||||
exports.final(buffered);
|
||||
|
||||
this.instancesPool.push(this);
|
||||
|
||||
const hex = mem.toString('latin1', 0, digestSize);
|
||||
|
||||
if (type === 'hex') {
|
||||
return hex;
|
||||
}
|
||||
|
||||
if (type === 'binary' || !type) {
|
||||
return Buffer.from(hex, 'hex');
|
||||
}
|
||||
|
||||
return Buffer.from(hex, 'hex').toString(type);
|
||||
}
|
||||
}
|
||||
|
||||
const create = (wasmModule, instancesPool, chunkSize, digestSize) => {
|
||||
if (instancesPool.length > 0) {
|
||||
const old = instancesPool.pop();
|
||||
|
||||
old.reset();
|
||||
|
||||
return old;
|
||||
} else {
|
||||
return new WasmHash(
|
||||
new WebAssembly.Instance(wasmModule),
|
||||
instancesPool,
|
||||
chunkSize,
|
||||
digestSize
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
module.exports = create;
|
||||
module.exports.MAX_SHORT_STRING = MAX_SHORT_STRING;
|
||||
Generated
Vendored
+12
-12
@@ -1,32 +1,32 @@
|
||||
{
|
||||
"_args": [
|
||||
[
|
||||
"loader-utils@2.0.0",
|
||||
"/mnt/Foxconn/Digitalent/Deverloper/liff-push_2series"
|
||||
"loader-utils@2.0.2",
|
||||
"/home/node/nuxt"
|
||||
]
|
||||
],
|
||||
"_from": "loader-utils@2.0.0",
|
||||
"_id": "loader-utils@2.0.0",
|
||||
"_from": "loader-utils@2.0.2",
|
||||
"_id": "loader-utils@2.0.2",
|
||||
"_inBundle": false,
|
||||
"_integrity": "sha512-rP4F0h2RaWSvPEkD7BLDFQnvSf+nK+wr3ESUjNTyAGobqrijmW92zc+SO6d4p4B1wh7+B/Jg1mkQe5NYUEHtHQ==",
|
||||
"_integrity": "sha512-TM57VeHptv569d/GKh6TAYdzKblwDNiumOdkFnejjD0XwTH87K90w3O7AiJRqdQoXygvi1VQTJTLGhJl7WqA7A==",
|
||||
"_location": "/extract-css-chunks-webpack-plugin/loader-utils",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"type": "version",
|
||||
"registry": true,
|
||||
"raw": "loader-utils@2.0.0",
|
||||
"raw": "loader-utils@2.0.2",
|
||||
"name": "loader-utils",
|
||||
"escapedName": "loader-utils",
|
||||
"rawSpec": "2.0.0",
|
||||
"rawSpec": "2.0.2",
|
||||
"saveSpec": null,
|
||||
"fetchSpec": "2.0.0"
|
||||
"fetchSpec": "2.0.2"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/extract-css-chunks-webpack-plugin"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/loader-utils/-/loader-utils-2.0.0.tgz",
|
||||
"_spec": "2.0.0",
|
||||
"_where": "/mnt/Foxconn/Digitalent/Deverloper/liff-push_2series",
|
||||
"_resolved": "https://registry.npmjs.org/loader-utils/-/loader-utils-2.0.2.tgz",
|
||||
"_spec": "2.0.2",
|
||||
"_where": "/home/node/nuxt",
|
||||
"author": {
|
||||
"name": "Tobias Koppers @sokra"
|
||||
},
|
||||
@@ -69,5 +69,5 @@
|
||||
"test": "jest",
|
||||
"test:ci": "jest --coverage"
|
||||
},
|
||||
"version": "2.0.0"
|
||||
"version": "2.0.2"
|
||||
}
|
||||
|
||||
+22
-25
@@ -1,43 +1,39 @@
|
||||
{
|
||||
"_args": [
|
||||
[
|
||||
"extract-css-chunks-webpack-plugin@4.7.5",
|
||||
"/mnt/Foxconn/Digitalent/Deverloper/liff-push_2series"
|
||||
"extract-css-chunks-webpack-plugin@4.9.0",
|
||||
"/home/node/nuxt"
|
||||
]
|
||||
],
|
||||
"_from": "extract-css-chunks-webpack-plugin@4.7.5",
|
||||
"_id": "extract-css-chunks-webpack-plugin@4.7.5",
|
||||
"_from": "extract-css-chunks-webpack-plugin@4.9.0",
|
||||
"_id": "extract-css-chunks-webpack-plugin@4.9.0",
|
||||
"_inBundle": false,
|
||||
"_integrity": "sha512-7XlPj/OW+vpIdMcm1H/mo5hgJubMKXlWF5Pgq9F/db39b19A+XlRWppyAZHNaJChC8kJKQl5n8PbfwouIl9AJQ==",
|
||||
"_integrity": "sha512-HNuNPCXRMqJDQ1OHAUehoY+0JVCnw9Y/H22FQzYVwo8Ulgew98AGDu0grnY5c7xwiXHjQa6yJ/1dxLCI/xqTyQ==",
|
||||
"_location": "/extract-css-chunks-webpack-plugin",
|
||||
"_phantomChildren": {
|
||||
"ajv": "6.12.3",
|
||||
"ajv": "6.12.6",
|
||||
"ajv-errors": "1.0.1",
|
||||
"ajv-keywords": "3.5.1",
|
||||
"ajv-keywords": "3.5.2",
|
||||
"big.js": "5.2.2",
|
||||
"emojis-list": "3.0.0",
|
||||
"json5": "2.1.3",
|
||||
"object-assign": "4.1.1",
|
||||
"prepend-http": "1.0.4",
|
||||
"query-string": "4.3.4",
|
||||
"sort-keys": "1.1.2"
|
||||
"json5": "2.2.1"
|
||||
},
|
||||
"_requested": {
|
||||
"type": "version",
|
||||
"registry": true,
|
||||
"raw": "extract-css-chunks-webpack-plugin@4.7.5",
|
||||
"raw": "extract-css-chunks-webpack-plugin@4.9.0",
|
||||
"name": "extract-css-chunks-webpack-plugin",
|
||||
"escapedName": "extract-css-chunks-webpack-plugin",
|
||||
"rawSpec": "4.7.5",
|
||||
"rawSpec": "4.9.0",
|
||||
"saveSpec": null,
|
||||
"fetchSpec": "4.7.5"
|
||||
"fetchSpec": "4.9.0"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/@nuxt/webpack"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/extract-css-chunks-webpack-plugin/-/extract-css-chunks-webpack-plugin-4.7.5.tgz",
|
||||
"_spec": "4.7.5",
|
||||
"_where": "/mnt/Foxconn/Digitalent/Deverloper/liff-push_2series",
|
||||
"_resolved": "https://registry.npmjs.org/extract-css-chunks-webpack-plugin/-/extract-css-chunks-webpack-plugin-4.9.0.tgz",
|
||||
"_spec": "4.9.0",
|
||||
"_where": "/home/node/nuxt",
|
||||
"author": {
|
||||
"name": "James Gillmore",
|
||||
"email": "james@faceyspacey.com"
|
||||
@@ -61,7 +57,6 @@
|
||||
"loader-utils": "^2.0.0",
|
||||
"normalize-url": "1.9.1",
|
||||
"schema-utils": "^1.0.0",
|
||||
"webpack-external-import": "^2.2.4",
|
||||
"webpack-sources": "^1.1.0"
|
||||
},
|
||||
"description": "Extract CSS from chunks into stylesheets + HMR. Supports Webpack 4 + SSR",
|
||||
@@ -74,7 +69,7 @@
|
||||
"@webpack-contrib/defaults": "6.3.0",
|
||||
"@webpack-contrib/eslint-config-webpack": "3.0.0",
|
||||
"babel-eslint": "10.1.0",
|
||||
"babel-jest": "25.1.0",
|
||||
"babel-jest": "25.5.1",
|
||||
"commitizen": "4.0.4",
|
||||
"commitlint-azure-pipelines-cli": "1.0.3",
|
||||
"cross-env": "7.0.2",
|
||||
@@ -89,7 +84,7 @@
|
||||
"eslint-plugin-prettier": "3.1.2",
|
||||
"file-loader": "6.0.0",
|
||||
"husky": "4.2.3",
|
||||
"jest": "25.1.0",
|
||||
"jest": "25.5.4",
|
||||
"jest-dev-server": "4.4.0",
|
||||
"jest-junit": "10.0.0",
|
||||
"jest-puppeteer": "4.4.0",
|
||||
@@ -100,8 +95,8 @@
|
||||
"prettier": "1.19.1",
|
||||
"puppeteer": "2.1.1",
|
||||
"serve": "11.3.0",
|
||||
"standard-version": "7.1.0",
|
||||
"webpack": "4.42.0",
|
||||
"standard-version": "8.0.1",
|
||||
"webpack": "4.43.0",
|
||||
"webpack-cli": "3.3.11",
|
||||
"webpack-dev-server": "3.10.3"
|
||||
},
|
||||
@@ -109,7 +104,8 @@
|
||||
"node": ">= 6.9.0"
|
||||
},
|
||||
"files": [
|
||||
"dist"
|
||||
"dist",
|
||||
"index.d.ts"
|
||||
],
|
||||
"homepage": "http://github.com/faceyspacey/extract-css-chunks-webpack-plugin",
|
||||
"keywords": [
|
||||
@@ -159,5 +155,6 @@
|
||||
"test:watch": "cross-env NODE_ENV=test jest --watch",
|
||||
"travis": "npm run ci:coverage"
|
||||
},
|
||||
"version": "4.7.5"
|
||||
"types": "index.d.ts",
|
||||
"version": "4.9.0"
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user