@rspack/core 1.0.10 → 1.0.11
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/dist/builtin-plugin/css-extract/utils.d.ts +1 -0
- package/dist/config/types.d.ts +309 -0
- package/dist/config/zod.d.ts +22 -534
- package/dist/cssExtractHmr.js +224 -0
- package/dist/cssExtractLoader.js +277 -0
- package/dist/index.js +23347 -31
- package/dist/{builtin-plugin/css-extract/hmr/hotModuleReplacement.d.ts → runtime/cssExtractHmr.d.ts} +1 -0
- package/dist/runtime/moduleFederationDefaultRuntime.d.ts +2 -0
- package/dist/stats/statsFactoryUtils.d.ts +1 -0
- package/package.json +8 -5
- package/compiled/json-parse-even-better-errors/index.d.ts +0 -1
- package/compiled/json-parse-even-better-errors/index.js +0 -193
- package/compiled/json-parse-even-better-errors/package.json +0 -1
- package/compiled/neo-async/index.d.ts +0 -685
- package/compiled/neo-async/index.js +0 -9207
- package/compiled/neo-async/license +0 -22
- package/compiled/neo-async/package.json +0 -1
- package/compiled/zod-validation-error/index.d.ts +0 -41
- package/compiled/zod-validation-error/index.js +0 -335
- package/compiled/zod-validation-error/license +0 -9
- package/compiled/zod-validation-error/package.json +0 -1
- package/dist/Chunk.js +0 -118
- package/dist/ChunkGraph.js +0 -27
- package/dist/ChunkGroup.js +0 -76
- package/dist/Compilation.js +0 -854
- package/dist/Compiler.js +0 -925
- package/dist/ContextModuleFactory.js +0 -36
- package/dist/DependenciesBlock.js +0 -30
- package/dist/Dependency.js +0 -43
- package/dist/Entrypoint.js +0 -21
- package/dist/ErrorHelpers.js +0 -62
- package/dist/ExecuteModulePlugin.js +0 -46
- package/dist/FileSystem.js +0 -34
- package/dist/FileSystemInfo.js +0 -2
- package/dist/Module.js +0 -226
- package/dist/ModuleTypeConstants.js +0 -92
- package/dist/MultiCompiler.js +0 -440
- package/dist/MultiStats.js +0 -161
- package/dist/MultiWatching.js +0 -62
- package/dist/NormalModule.js +0 -97
- package/dist/NormalModuleFactory.js +0 -43
- package/dist/Resolver.js +0 -39
- package/dist/ResolverFactory.js +0 -61
- package/dist/RspackError.js +0 -21
- package/dist/RuleSetCompiler.js +0 -10
- package/dist/RuntimeGlobals.js +0 -357
- package/dist/RuntimeModule.js +0 -58
- package/dist/Stats.js +0 -161
- package/dist/Template.js +0 -206
- package/dist/Watching.js +0 -290
- package/dist/builtin-loader/index.js +0 -17
- package/dist/builtin-loader/lightningcss/index.js +0 -175
- package/dist/builtin-loader/swc/index.js +0 -5
- package/dist/builtin-loader/swc/pluginImport.js +0 -35
- package/dist/builtin-loader/swc/react.js +0 -7
- package/dist/builtin-loader/swc/types.js +0 -2
- package/dist/builtin-plugin/APIPlugin.js +0 -6
- package/dist/builtin-plugin/ArrayPushCallbackChunkFormatPlugin.js +0 -6
- package/dist/builtin-plugin/AssetModulesPlugin.js +0 -6
- package/dist/builtin-plugin/AsyncWebAssemblyModulesPlugin.js +0 -6
- package/dist/builtin-plugin/BannerPlugin.js +0 -22
- package/dist/builtin-plugin/BundlerInfoRspackPlugin.js +0 -12
- package/dist/builtin-plugin/ChunkPrefetchPreloadPlugin.js +0 -6
- package/dist/builtin-plugin/CommonJsChunkFormatPlugin.js +0 -6
- package/dist/builtin-plugin/ContextReplacementPlugin.js +0 -43
- package/dist/builtin-plugin/CopyRspackPlugin.js +0 -21
- package/dist/builtin-plugin/CssModulesPlugin.js +0 -6
- package/dist/builtin-plugin/DataUriPlugin.js +0 -6
- package/dist/builtin-plugin/DefinePlugin.js +0 -44
- package/dist/builtin-plugin/DeterministicChunkIdsPlugin.js +0 -6
- package/dist/builtin-plugin/DeterministicModuleIdsPlugin.js +0 -6
- package/dist/builtin-plugin/DynamicEntryPlugin.js +0 -36
- package/dist/builtin-plugin/ElectronTargetPlugin.js +0 -6
- package/dist/builtin-plugin/EnableChunkLoadingPlugin.js +0 -6
- package/dist/builtin-plugin/EnableLibraryPlugin.js +0 -39
- package/dist/builtin-plugin/EnableWasmLoadingPlugin.js +0 -6
- package/dist/builtin-plugin/EnsureChunkConditionsPlugin.js +0 -6
- package/dist/builtin-plugin/EntryPlugin.js +0 -34
- package/dist/builtin-plugin/EvalDevToolModulePlugin.js +0 -6
- package/dist/builtin-plugin/EvalSourceMapDevToolPlugin.js +0 -16
- package/dist/builtin-plugin/ExternalsPlugin.js +0 -51
- package/dist/builtin-plugin/FetchCompileAsyncWasmPlugin.js +0 -6
- package/dist/builtin-plugin/FileUriPlugin.js +0 -6
- package/dist/builtin-plugin/FlagDependencyExportsPlugin.js +0 -6
- package/dist/builtin-plugin/FlagDependencyUsagePlugin.js +0 -6
- package/dist/builtin-plugin/HotModuleReplacementPlugin.js +0 -18
- package/dist/builtin-plugin/HtmlRspackPlugin.js +0 -285
- package/dist/builtin-plugin/HttpExternalsRspackPlugin.js +0 -11
- package/dist/builtin-plugin/IgnorePlugin.js +0 -20
- package/dist/builtin-plugin/InferAsyncModulesPlugin.js +0 -6
- package/dist/builtin-plugin/JavascriptModulesPlugin.js +0 -55
- package/dist/builtin-plugin/JsLoaderRspackPlugin.js +0 -9
- package/dist/builtin-plugin/JsonModulesPlugin.js +0 -6
- package/dist/builtin-plugin/LightningCssMiminizerRspackPlugin.js +0 -30
- package/dist/builtin-plugin/LimitChunkCountPlugin.js +0 -8
- package/dist/builtin-plugin/MangleExportsPlugin.js +0 -6
- package/dist/builtin-plugin/MergeDuplicateChunksPlugin.js +0 -6
- package/dist/builtin-plugin/ModuleChunkFormatPlugin.js +0 -6
- package/dist/builtin-plugin/ModuleConcatenationPlugin.js +0 -6
- package/dist/builtin-plugin/NamedChunkIdsPlugin.js +0 -6
- package/dist/builtin-plugin/NamedModuleIdsPlugin.js +0 -6
- package/dist/builtin-plugin/NaturalChunkIdsPlugin.js +0 -6
- package/dist/builtin-plugin/NaturalModuleIdsPlugin.js +0 -6
- package/dist/builtin-plugin/NoEmitOnErrorsPlugin.js +0 -6
- package/dist/builtin-plugin/NodeTargetPlugin.js +0 -6
- package/dist/builtin-plugin/ProgressPlugin.js +0 -15
- package/dist/builtin-plugin/ProvidePlugin.js +0 -14
- package/dist/builtin-plugin/RealContentHashPlugin.js +0 -6
- package/dist/builtin-plugin/RemoveEmptyChunksPlugin.js +0 -6
- package/dist/builtin-plugin/RuntimeChunkPlugin.js +0 -6
- package/dist/builtin-plugin/RuntimePlugin.js +0 -6
- package/dist/builtin-plugin/SideEffectsFlagPlugin.js +0 -6
- package/dist/builtin-plugin/SizeLimitsPlugin.js +0 -9
- package/dist/builtin-plugin/SourceMapDevToolPlugin.js +0 -14
- package/dist/builtin-plugin/SplitChunksPlugin.js +0 -92
- package/dist/builtin-plugin/SwcJsMinimizerPlugin.js +0 -80
- package/dist/builtin-plugin/WarnCaseSensitiveModulesPlugin.js +0 -6
- package/dist/builtin-plugin/WebWorkerTemplatePlugin.js +0 -6
- package/dist/builtin-plugin/WorkerPlugin.js +0 -31
- package/dist/builtin-plugin/base.js +0 -58
- package/dist/builtin-plugin/css-extract/hmr/hotModuleReplacement.js +0 -182
- package/dist/builtin-plugin/css-extract/hmr/normalizeUrl.d.ts +0 -2
- package/dist/builtin-plugin/css-extract/hmr/normalizeUrl.js +0 -31
- package/dist/builtin-plugin/css-extract/index.js +0 -105
- package/dist/builtin-plugin/css-extract/loader.js +0 -204
- package/dist/builtin-plugin/css-extract/utils.js +0 -51
- package/dist/builtin-plugin/index.js +0 -84
- package/dist/builtin-plugin/lazy-compilation/backend.js +0 -139
- package/dist/builtin-plugin/lazy-compilation/lazyCompilation.js +0 -6
- package/dist/builtin-plugin/lazy-compilation/plugin.js +0 -60
- package/dist/config/adapter.js +0 -691
- package/dist/config/adapterRuleUse.js +0 -107
- package/dist/config/browserslistTargetHandler.js +0 -345
- package/dist/config/defaults.js +0 -876
- package/dist/config/index.js +0 -20
- package/dist/config/normalization.js +0 -299
- package/dist/config/target.js +0 -318
- package/dist/config/types.js +0 -3
- package/dist/config/zod.js +0 -1030
- package/dist/container/ContainerPlugin.js +0 -50
- package/dist/container/ContainerReferencePlugin.js +0 -49
- package/dist/container/ModuleFederationPlugin.js +0 -137
- package/dist/container/ModuleFederationPluginV1.js +0 -63
- package/dist/container/ModuleFederationRuntimePlugin.js +0 -6
- package/dist/container/options.js +0 -48
- package/dist/error/ConcurrentCompilationError.js +0 -20
- package/dist/exports.js +0 -183
- package/dist/lib/AbstractMethodError.js +0 -51
- package/dist/lib/Cache.js +0 -111
- package/dist/lib/CacheFacade.js +0 -321
- package/dist/lib/Dependency.js +0 -11
- package/dist/lib/EntryOptionPlugin.js +0 -89
- package/dist/lib/EnvironmentPlugin.js +0 -57
- package/dist/lib/HookWebpackError.js +0 -83
- package/dist/lib/IgnoreWarningsPlugin.js +0 -35
- package/dist/lib/LoaderOptionsPlugin.js +0 -74
- package/dist/lib/LoaderTargetPlugin.js +0 -37
- package/dist/lib/ModuleFilenameHelpers.js +0 -83
- package/dist/lib/NormalModuleReplacementPlugin.js +0 -85
- package/dist/lib/WebpackError.js +0 -20
- package/dist/lib/cache/MemoryCachePlugin.js +0 -40
- package/dist/lib/cache/getLazyHashedEtag.js +0 -73
- package/dist/lib/cache/mergeEtags.js +0 -74
- package/dist/lib/formatLocation.js +0 -64
- package/dist/loader-runner/LoaderLoadingError.js +0 -19
- package/dist/loader-runner/index.js +0 -735
- package/dist/loader-runner/loadLoader.js +0 -64
- package/dist/logging/Logger.js +0 -143
- package/dist/logging/createConsoleLogger.js +0 -176
- package/dist/logging/runtime.js +0 -37
- package/dist/logging/truncateArgs.js +0 -81
- package/dist/node/NodeEnvironmentPlugin.js +0 -50
- package/dist/node/NodeTemplatePlugin.js +0 -26
- package/dist/node/NodeWatchFileSystem.js +0 -144
- package/dist/node/nodeConsole.js +0 -146
- package/dist/rspack.js +0 -123
- package/dist/rspackOptionsApply.js +0 -274
- package/dist/sharing/ConsumeSharedPlugin.js +0 -69
- package/dist/sharing/ProvideSharedPlugin.js +0 -50
- package/dist/sharing/SharePlugin.js +0 -66
- package/dist/sharing/ShareRuntimePlugin.js +0 -26
- package/dist/sharing/utils.js +0 -8
- package/dist/stats/DefaultStatsFactoryPlugin.js +0 -1173
- package/dist/stats/DefaultStatsPresetPlugin.js +0 -305
- package/dist/stats/DefaultStatsPrinterPlugin.js +0 -1069
- package/dist/stats/StatsFactory.js +0 -167
- package/dist/stats/StatsPrinter.js +0 -142
- package/dist/stats/statsFactoryUtils.js +0 -341
- package/dist/util/ArrayQueue.js +0 -108
- package/dist/util/AssetInfo.js +0 -39
- package/dist/util/IterableHelpers.js +0 -35
- package/dist/util/MergeCaller.js +0 -24
- package/dist/util/SizeFormatHelpers.js +0 -24
- package/dist/util/SplitChunkSize.js +0 -18
- package/dist/util/assertNotNil.js +0 -9
- package/dist/util/assetCondition.js +0 -2
- package/dist/util/bindingVersionCheck.js +0 -124
- package/dist/util/cleverMerge.js +0 -504
- package/dist/util/comparators.js +0 -108
- package/dist/util/createHash.js +0 -161
- package/dist/util/createReadonlyMap.js +0 -29
- package/dist/util/fake.js +0 -28
- package/dist/util/fs.js +0 -120
- package/dist/util/hash/BatchedHash.js +0 -69
- package/dist/util/hash/index.js +0 -39
- package/dist/util/hash/md4.js +0 -27
- package/dist/util/hash/wasm-hash.js +0 -167
- package/dist/util/hash/xxhash64.js +0 -27
- package/dist/util/identifier.js +0 -330
- package/dist/util/index.js +0 -123
- package/dist/util/memoize.js +0 -61
- package/dist/util/scheme.js +0 -57
- package/dist/util/smartGrouping.js +0 -148
- package/dist/util/source.js +0 -42
- package/dist/util/validate.js +0 -77
- package/dist/util/webpack.js +0 -27
- /package/dist/{container/default.runtime.js → moduleFederationDefaultRuntime.js} +0 -0
package/dist/util/createHash.js
DELETED
|
@@ -1,161 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* The following code is modified based on
|
|
4
|
-
* https://github.com/webpack/webpack/blob/4b4ca3b/lib/util/createHash.js
|
|
5
|
-
*
|
|
6
|
-
* MIT Licensed
|
|
7
|
-
* Author Tobias Koppers @sokra
|
|
8
|
-
* Copyright (c) JS Foundation and other contributors
|
|
9
|
-
* https://github.com/webpack/webpack/blob/main/LICENSE
|
|
10
|
-
*/
|
|
11
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
-
};
|
|
14
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
exports.createHash = void 0;
|
|
16
|
-
const node_crypto_1 = __importDefault(require("node:crypto"));
|
|
17
|
-
const hash_1 = __importDefault(require("./hash"));
|
|
18
|
-
const BatchedHash_1 = __importDefault(require("./hash/BatchedHash"));
|
|
19
|
-
const md4_1 = __importDefault(require("./hash/md4"));
|
|
20
|
-
const xxhash64_1 = __importDefault(require("./hash/xxhash64"));
|
|
21
|
-
const BULK_SIZE = 2000;
|
|
22
|
-
// We are using an object instead of a Map as this will stay static during the runtime
|
|
23
|
-
// so access to it can be optimized by v8
|
|
24
|
-
const digestCaches = {};
|
|
25
|
-
class BulkUpdateDecorator extends hash_1.default {
|
|
26
|
-
/**
|
|
27
|
-
* @param hashOrFactory function to create a hash
|
|
28
|
-
* @param hashKey key for caching
|
|
29
|
-
*/
|
|
30
|
-
constructor(hashOrFactory, hashKey) {
|
|
31
|
-
super();
|
|
32
|
-
this.hashKey = hashKey;
|
|
33
|
-
if (typeof hashOrFactory === "function") {
|
|
34
|
-
this.hashFactory = hashOrFactory;
|
|
35
|
-
this.hash = undefined;
|
|
36
|
-
}
|
|
37
|
-
else {
|
|
38
|
-
this.hashFactory = undefined;
|
|
39
|
-
this.hash = hashOrFactory;
|
|
40
|
-
}
|
|
41
|
-
this.buffer = "";
|
|
42
|
-
}
|
|
43
|
-
/**
|
|
44
|
-
* Update hash {@link https://nodejs.org/api/crypto.html#crypto_hash_update_data_inputencoding}
|
|
45
|
-
* @param data data
|
|
46
|
-
* @param inputEncoding data encoding
|
|
47
|
-
* @returns updated hash
|
|
48
|
-
*/
|
|
49
|
-
update(data, inputEncoding) {
|
|
50
|
-
if (inputEncoding !== undefined ||
|
|
51
|
-
typeof data !== "string" ||
|
|
52
|
-
data.length > BULK_SIZE) {
|
|
53
|
-
if (this.hash === undefined)
|
|
54
|
-
this.hash = this.hashFactory();
|
|
55
|
-
if (this.buffer.length > 0) {
|
|
56
|
-
this.hash.update(this.buffer);
|
|
57
|
-
this.buffer = "";
|
|
58
|
-
}
|
|
59
|
-
this.hash.update(data, inputEncoding);
|
|
60
|
-
}
|
|
61
|
-
else {
|
|
62
|
-
this.buffer += data;
|
|
63
|
-
if (this.buffer.length > BULK_SIZE) {
|
|
64
|
-
if (this.hash === undefined)
|
|
65
|
-
this.hash = this.hashFactory();
|
|
66
|
-
this.hash.update(this.buffer);
|
|
67
|
-
this.buffer = "";
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
return this;
|
|
71
|
-
}
|
|
72
|
-
/**
|
|
73
|
-
* Calculates the digest {@link https://nodejs.org/api/crypto.html#crypto_hash_digest_encoding}
|
|
74
|
-
* @param encoding encoding of the return value
|
|
75
|
-
* @returns digest
|
|
76
|
-
*/
|
|
77
|
-
digest(encoding) {
|
|
78
|
-
let digestCache;
|
|
79
|
-
const buffer = this.buffer;
|
|
80
|
-
if (this.hash === undefined) {
|
|
81
|
-
// short data for hash, we can use caching
|
|
82
|
-
const cacheKey = `${this.hashKey}-${encoding}`;
|
|
83
|
-
digestCache = digestCaches[cacheKey];
|
|
84
|
-
if (digestCache === undefined) {
|
|
85
|
-
digestCache = digestCaches[cacheKey] = new Map();
|
|
86
|
-
}
|
|
87
|
-
const cacheEntry = digestCache.get(buffer);
|
|
88
|
-
if (cacheEntry !== undefined)
|
|
89
|
-
return cacheEntry;
|
|
90
|
-
this.hash = this.hashFactory();
|
|
91
|
-
}
|
|
92
|
-
if (buffer.length > 0) {
|
|
93
|
-
this.hash.update(buffer);
|
|
94
|
-
}
|
|
95
|
-
const digestResult = this.hash.digest(encoding);
|
|
96
|
-
const result = typeof digestResult === "string" ? digestResult : digestResult.toString();
|
|
97
|
-
if (digestCache !== undefined) {
|
|
98
|
-
digestCache.set(buffer, result);
|
|
99
|
-
}
|
|
100
|
-
return result;
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
/* istanbul ignore next */
|
|
104
|
-
class DebugHash extends hash_1.default {
|
|
105
|
-
constructor() {
|
|
106
|
-
super();
|
|
107
|
-
this.string = "";
|
|
108
|
-
}
|
|
109
|
-
/**
|
|
110
|
-
* Update hash {@link https://nodejs.org/api/crypto.html#crypto_hash_update_data_inputencoding}
|
|
111
|
-
* @param data data
|
|
112
|
-
* @param _inputEncoding data encoding
|
|
113
|
-
* @returns updated hash
|
|
114
|
-
*/
|
|
115
|
-
update(data, _inputEncoding) {
|
|
116
|
-
let normalizedData;
|
|
117
|
-
if (typeof data !== "string") {
|
|
118
|
-
normalizedData = data.toString("utf-8");
|
|
119
|
-
}
|
|
120
|
-
else {
|
|
121
|
-
normalizedData = data;
|
|
122
|
-
}
|
|
123
|
-
if (normalizedData.startsWith("debug-digest-")) {
|
|
124
|
-
normalizedData = Buffer.from(normalizedData.slice("debug-digest-".length), "hex").toString();
|
|
125
|
-
}
|
|
126
|
-
this.string += `[${normalizedData}](${new Error().stack?.split("\n", 3)[2]})\n`;
|
|
127
|
-
return this;
|
|
128
|
-
}
|
|
129
|
-
/**
|
|
130
|
-
* Calculates the digest {@link https://nodejs.org/api/crypto.html#crypto_hash_digest_encoding}
|
|
131
|
-
* @param encoding encoding of the return value
|
|
132
|
-
* @returns digest
|
|
133
|
-
*/
|
|
134
|
-
digest(encoding) {
|
|
135
|
-
return `debug-digest-${Buffer.from(this.string).toString(encoding || "hex")}`;
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
/**
|
|
139
|
-
* Creates a hash by name or function
|
|
140
|
-
* @param algorithm the algorithm name or a constructor creating a hash
|
|
141
|
-
* @returns the hash
|
|
142
|
-
*/
|
|
143
|
-
const createHash = (algorithm) => {
|
|
144
|
-
if (typeof algorithm === "function") {
|
|
145
|
-
return new BulkUpdateDecorator(() => new algorithm());
|
|
146
|
-
}
|
|
147
|
-
switch (algorithm) {
|
|
148
|
-
// TODO add non-cryptographic algorithm here
|
|
149
|
-
case "debug":
|
|
150
|
-
return new DebugHash();
|
|
151
|
-
case "xxhash64":
|
|
152
|
-
return new BatchedHash_1.default((0, xxhash64_1.default)());
|
|
153
|
-
case "md4":
|
|
154
|
-
return new BatchedHash_1.default((0, md4_1.default)());
|
|
155
|
-
case "native-md4":
|
|
156
|
-
return new BulkUpdateDecorator(() => node_crypto_1.default.createHash("md4"), "md4");
|
|
157
|
-
default:
|
|
158
|
-
return new BulkUpdateDecorator(() => node_crypto_1.default.createHash(algorithm), algorithm);
|
|
159
|
-
}
|
|
160
|
-
};
|
|
161
|
-
exports.createHash = createHash;
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.createReadonlyMap = void 0;
|
|
4
|
-
function createReadonlyMap(obj) {
|
|
5
|
-
return {
|
|
6
|
-
...obj,
|
|
7
|
-
*values() {
|
|
8
|
-
const keys = this.keys();
|
|
9
|
-
for (const key of keys) {
|
|
10
|
-
yield this.get(key);
|
|
11
|
-
}
|
|
12
|
-
},
|
|
13
|
-
*entries() {
|
|
14
|
-
const keys = this.keys();
|
|
15
|
-
for (const key of keys) {
|
|
16
|
-
yield [key, this.get(key)];
|
|
17
|
-
}
|
|
18
|
-
},
|
|
19
|
-
forEach(callback, thisArg) {
|
|
20
|
-
for (const [key, value] of this) {
|
|
21
|
-
callback.call(thisArg, value, key, this);
|
|
22
|
-
}
|
|
23
|
-
},
|
|
24
|
-
[Symbol.iterator]() {
|
|
25
|
-
return this.entries();
|
|
26
|
-
}
|
|
27
|
-
};
|
|
28
|
-
}
|
|
29
|
-
exports.createReadonlyMap = createReadonlyMap;
|
package/dist/util/fake.js
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.createFakeCompilationDependencies = void 0;
|
|
7
|
-
const MergeCaller_1 = __importDefault(require("./MergeCaller"));
|
|
8
|
-
function createFakeCompilationDependencies(getDeps, addDeps) {
|
|
9
|
-
const addDepsCaller = new MergeCaller_1.default(addDeps, 10);
|
|
10
|
-
return {
|
|
11
|
-
*[Symbol.iterator]() {
|
|
12
|
-
const deps = getDeps();
|
|
13
|
-
for (const dep of deps) {
|
|
14
|
-
yield dep;
|
|
15
|
-
}
|
|
16
|
-
},
|
|
17
|
-
has(dep) {
|
|
18
|
-
return getDeps().includes(dep);
|
|
19
|
-
},
|
|
20
|
-
add: (dep) => {
|
|
21
|
-
addDepsCaller.push(dep);
|
|
22
|
-
},
|
|
23
|
-
addAll: (deps) => {
|
|
24
|
-
addDepsCaller.push(...deps);
|
|
25
|
-
}
|
|
26
|
-
};
|
|
27
|
-
}
|
|
28
|
-
exports.createFakeCompilationDependencies = createFakeCompilationDependencies;
|
package/dist/util/fs.js
DELETED
|
@@ -1,120 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* The following code is modified based on
|
|
4
|
-
* https://github.com/webpack/webpack/blob/4b4ca3b/lib/util/fs.js
|
|
5
|
-
*
|
|
6
|
-
* MIT Licensed
|
|
7
|
-
* Author Tobias Koppers @sokra
|
|
8
|
-
* Copyright (c) JS Foundation and other contributors
|
|
9
|
-
* https://github.com/webpack/webpack/blob/main/LICENSE
|
|
10
|
-
*/
|
|
11
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
-
};
|
|
14
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
exports.mkdirp = exports.rmrf = void 0;
|
|
16
|
-
const node_assert_1 = __importDefault(require("node:assert"));
|
|
17
|
-
const node_path_1 = __importDefault(require("node:path"));
|
|
18
|
-
function rmrf(fs, p, callback) {
|
|
19
|
-
fs.stat(p, (err, stats) => {
|
|
20
|
-
if (err) {
|
|
21
|
-
if (err.code === "ENOENT") {
|
|
22
|
-
return callback();
|
|
23
|
-
}
|
|
24
|
-
return callback(err);
|
|
25
|
-
}
|
|
26
|
-
if (stats.isDirectory()) {
|
|
27
|
-
fs.readdir(p, (err, files) => {
|
|
28
|
-
if (err) {
|
|
29
|
-
return callback(err);
|
|
30
|
-
}
|
|
31
|
-
let count = files.length;
|
|
32
|
-
if (count === 0) {
|
|
33
|
-
fs.rmdir(p, callback);
|
|
34
|
-
}
|
|
35
|
-
else {
|
|
36
|
-
for (const file of files) {
|
|
37
|
-
(0, node_assert_1.default)(typeof file === "string");
|
|
38
|
-
const fullPath = join(fs, p, file);
|
|
39
|
-
rmrf(fs, fullPath, err => {
|
|
40
|
-
if (err) {
|
|
41
|
-
return callback(err);
|
|
42
|
-
}
|
|
43
|
-
count--;
|
|
44
|
-
if (count === 0) {
|
|
45
|
-
fs.rmdir(p, callback);
|
|
46
|
-
}
|
|
47
|
-
});
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
});
|
|
51
|
-
}
|
|
52
|
-
else {
|
|
53
|
-
fs.unlink(p, callback);
|
|
54
|
-
}
|
|
55
|
-
});
|
|
56
|
-
}
|
|
57
|
-
exports.rmrf = rmrf;
|
|
58
|
-
const join = (fs, rootPath, filename) => {
|
|
59
|
-
if (fs?.join) {
|
|
60
|
-
return fs.join(rootPath, filename);
|
|
61
|
-
}
|
|
62
|
-
if (node_path_1.default.posix.isAbsolute(rootPath)) {
|
|
63
|
-
return node_path_1.default.posix.join(rootPath, filename);
|
|
64
|
-
}
|
|
65
|
-
if (node_path_1.default.win32.isAbsolute(rootPath)) {
|
|
66
|
-
return node_path_1.default.win32.join(rootPath, filename);
|
|
67
|
-
}
|
|
68
|
-
throw new Error(`${rootPath} is neither a posix nor a windows path, and there is no 'join' method defined in the file system`);
|
|
69
|
-
};
|
|
70
|
-
const dirname = (fs, absPath) => {
|
|
71
|
-
if (fs?.dirname) {
|
|
72
|
-
return fs.dirname(absPath);
|
|
73
|
-
}
|
|
74
|
-
if (node_path_1.default.posix.isAbsolute(absPath)) {
|
|
75
|
-
return node_path_1.default.posix.dirname(absPath);
|
|
76
|
-
}
|
|
77
|
-
if (node_path_1.default.win32.isAbsolute(absPath)) {
|
|
78
|
-
return node_path_1.default.win32.dirname(absPath);
|
|
79
|
-
}
|
|
80
|
-
throw new Error(`${absPath} is neither a posix nor a windows path, and there is no 'dirname' method defined in the file system`);
|
|
81
|
-
};
|
|
82
|
-
const mkdirp = (fs, p, callback) => {
|
|
83
|
-
fs.mkdir(p, err => {
|
|
84
|
-
if (err) {
|
|
85
|
-
if (err.code === "ENOENT") {
|
|
86
|
-
const dir = dirname(fs, p);
|
|
87
|
-
if (dir === p) {
|
|
88
|
-
callback(err);
|
|
89
|
-
return;
|
|
90
|
-
}
|
|
91
|
-
(0, exports.mkdirp)(fs, dir, err => {
|
|
92
|
-
if (err) {
|
|
93
|
-
callback(err);
|
|
94
|
-
return;
|
|
95
|
-
}
|
|
96
|
-
fs.mkdir(p, err => {
|
|
97
|
-
if (err) {
|
|
98
|
-
if (err.code === "EEXIST") {
|
|
99
|
-
callback();
|
|
100
|
-
return;
|
|
101
|
-
}
|
|
102
|
-
callback(err);
|
|
103
|
-
return;
|
|
104
|
-
}
|
|
105
|
-
callback();
|
|
106
|
-
});
|
|
107
|
-
});
|
|
108
|
-
return;
|
|
109
|
-
}
|
|
110
|
-
if (err.code === "EEXIST") {
|
|
111
|
-
callback();
|
|
112
|
-
return;
|
|
113
|
-
}
|
|
114
|
-
callback(err);
|
|
115
|
-
return;
|
|
116
|
-
}
|
|
117
|
-
callback();
|
|
118
|
-
});
|
|
119
|
-
};
|
|
120
|
-
exports.mkdirp = mkdirp;
|
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
/**
|
|
7
|
-
* The following code is modified based on
|
|
8
|
-
* https://github.com/webpack/webpack/blob/4b4ca3b/lib/util/hash/BatchedHash.js
|
|
9
|
-
*
|
|
10
|
-
* MIT Licensed
|
|
11
|
-
* Author Tobias Koppers @sokra
|
|
12
|
-
* Copyright (c) JS Foundation and other contributors
|
|
13
|
-
* https://github.com/webpack/webpack/blob/main/LICENSE
|
|
14
|
-
*/
|
|
15
|
-
const _1 = __importDefault(require("."));
|
|
16
|
-
const wasm_hash_1 = require("./wasm-hash");
|
|
17
|
-
class BatchedHash extends _1.default {
|
|
18
|
-
constructor(hash) {
|
|
19
|
-
super();
|
|
20
|
-
this.string = undefined;
|
|
21
|
-
this.encoding = undefined;
|
|
22
|
-
this.hash = hash;
|
|
23
|
-
}
|
|
24
|
-
/**
|
|
25
|
-
* Update hash {@link https://nodejs.org/api/crypto.html#crypto_hash_update_data_inputencoding}
|
|
26
|
-
* @param data data
|
|
27
|
-
* @param inputEncoding data encoding
|
|
28
|
-
* @returns updated hash
|
|
29
|
-
*/
|
|
30
|
-
update(data, inputEncoding) {
|
|
31
|
-
if (this.string !== undefined) {
|
|
32
|
-
if (typeof data === "string" &&
|
|
33
|
-
inputEncoding === this.encoding &&
|
|
34
|
-
this.string.length + data.length < wasm_hash_1.MAX_SHORT_STRING) {
|
|
35
|
-
this.string += data;
|
|
36
|
-
return this;
|
|
37
|
-
}
|
|
38
|
-
this.hash.update(this.string, this.encoding);
|
|
39
|
-
this.string = undefined;
|
|
40
|
-
}
|
|
41
|
-
if (typeof data === "string") {
|
|
42
|
-
if (data.length < wasm_hash_1.MAX_SHORT_STRING &&
|
|
43
|
-
// base64 encoding is not valid since it may contain padding chars
|
|
44
|
-
(!inputEncoding || !inputEncoding.startsWith("ba"))) {
|
|
45
|
-
this.string = data;
|
|
46
|
-
this.encoding = inputEncoding;
|
|
47
|
-
}
|
|
48
|
-
else {
|
|
49
|
-
this.hash.update(data, inputEncoding);
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
else {
|
|
53
|
-
this.hash.update(data);
|
|
54
|
-
}
|
|
55
|
-
return this;
|
|
56
|
-
}
|
|
57
|
-
/**
|
|
58
|
-
* Calculates the digest {@link https://nodejs.org/api/crypto.html#crypto_hash_digest_encoding}
|
|
59
|
-
* @param encoding encoding of the return value
|
|
60
|
-
* @returns digest
|
|
61
|
-
*/
|
|
62
|
-
digest(encoding) {
|
|
63
|
-
if (this.string !== undefined) {
|
|
64
|
-
this.hash.update(this.string, this.encoding);
|
|
65
|
-
}
|
|
66
|
-
return this.hash.digest(encoding);
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
exports.default = BatchedHash;
|
package/dist/util/hash/index.js
DELETED
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
/**
|
|
7
|
-
* The following code is modified based on
|
|
8
|
-
* https://github.com/webpack/webpack/tree/4b4ca3bb53f36a5b8fc6bc1bd976ed7af161bd80/lib/util/hash
|
|
9
|
-
*
|
|
10
|
-
* MIT Licensed
|
|
11
|
-
* Author Tobias Koppers @sokra
|
|
12
|
-
* Copyright (c) JS Foundation and other contributors
|
|
13
|
-
* https://github.com/webpack/webpack/blob/main/LICENSE
|
|
14
|
-
*/
|
|
15
|
-
const AbstractMethodError_1 = __importDefault(require("../../lib/AbstractMethodError"));
|
|
16
|
-
class Hash {
|
|
17
|
-
/* istanbul ignore next */
|
|
18
|
-
/**
|
|
19
|
-
* Update hash {@link https://nodejs.org/api/crypto.html#crypto_hash_update_data_inputencoding}
|
|
20
|
-
* @abstract
|
|
21
|
-
* @param data data
|
|
22
|
-
* @param inputEncoding data encoding
|
|
23
|
-
* @returns updated hash
|
|
24
|
-
*/
|
|
25
|
-
update(data, inputEncoding) {
|
|
26
|
-
throw new AbstractMethodError_1.default();
|
|
27
|
-
}
|
|
28
|
-
/* istanbul ignore next */
|
|
29
|
-
/**
|
|
30
|
-
* Calculates the digest {@link https://nodejs.org/api/crypto.html#crypto_hash_digest_encoding}
|
|
31
|
-
* @abstract
|
|
32
|
-
* @param encoding encoding of the return value
|
|
33
|
-
* @returns digest
|
|
34
|
-
*/
|
|
35
|
-
digest(encoding) {
|
|
36
|
-
throw new AbstractMethodError_1.default();
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
exports.default = Hash;
|
package/dist/util/hash/md4.js
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* The following code is modified based on
|
|
4
|
-
* https://github.com/webpack/webpack/blob/4b4ca3b/lib/util/hash/md4.js
|
|
5
|
-
*
|
|
6
|
-
* MIT Licensed
|
|
7
|
-
* Author Tobias Koppers @sokra
|
|
8
|
-
* Copyright (c) JS Foundation and other contributors
|
|
9
|
-
* https://github.com/webpack/webpack/blob/main/LICENSE
|
|
10
|
-
*/
|
|
11
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
-
};
|
|
14
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
const wasm_hash_1 = __importDefault(require("./wasm-hash"));
|
|
16
|
-
let createMd4;
|
|
17
|
-
exports.default = () => {
|
|
18
|
-
if (!createMd4) {
|
|
19
|
-
//#region wasm code: md4 (../../../assembly/hash/md4.asm.ts) --initialMemory 1
|
|
20
|
-
const md4 = new WebAssembly.Module(Buffer.from(
|
|
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AyAENwMAIAIQAUEAIwGtIgRC//8DgyAEQoCA/P8Pg0IQhoQiBEL/gYCA8B+DIARCgP6DgIDgP4NCCIaEIgRCj4C8gPCBwAeDQgiGIARC8IHAh4CegPgAg0IEiIQiBEKGjJiw4MCBgwZ8QgSIQoGChIiQoMCAAYNCJ34gBEKw4MCBg4aMmDCEfDcDAEEIIwKtIgRC//8DgyAEQoCA/P8Pg0IQhoQiBEL/gYCA8B+DIARCgP6DgIDgP4NCCIaEIgRCj4C8gPCBwAeDQgiGIARC8IHAh4CegPgAg0IEiIQiBEKGjJiw4MCBgwZ8QgSIQoGChIiQoMCAAYNCJ34gBEKw4MCBg4aMmDCEfDcDAEEQIwOtIgRC//8DgyAEQoCA/P8Pg0IQhoQiBEL/gYCA8B+DIARCgP6DgIDgP4NCCIaEIgRCj4C8gPCBwAeDQgiGIARC8IHAh4CegPgAg0IEiIQiBEKGjJiw4MCBgwZ8QgSIQoGChIiQoMCAAYNCJ34gBEKw4MCBg4aMmDCEfDcDAEEYIwStIgRC//8DgyAEQoCA/P8Pg0IQhoQiBEL/gYCA8B+DIARCgP6DgIDgP4NCCIaEIgRCj4C8gPCBwAeDQgiGIARC8IHAh4CegPgAg0IEiIQiBEKGjJiw4MCBgwZ8QgSIQoGChIiQoMCAAYNCJ34gBEKw4MCBg4aMmDCEfDcDAAs=", "base64"));
|
|
23
|
-
//#endregion
|
|
24
|
-
createMd4 = wasm_hash_1.default.bind(null, md4, [], 64, 32);
|
|
25
|
-
}
|
|
26
|
-
return createMd4();
|
|
27
|
-
};
|
|
@@ -1,167 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* The following code is modified based on
|
|
4
|
-
* https://github.com/webpack/webpack/blob/4b4ca3b/lib/util/hash/wasm-hash.js
|
|
5
|
-
*
|
|
6
|
-
* MIT Licensed
|
|
7
|
-
* Author Tobias Koppers @sokra
|
|
8
|
-
* Copyright (c) JS Foundation and other contributors
|
|
9
|
-
* https://github.com/webpack/webpack/blob/main/LICENSE
|
|
10
|
-
*/
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.WasmHash = exports.MAX_SHORT_STRING = void 0;
|
|
13
|
-
// 65536 is the size of a wasm memory page
|
|
14
|
-
// 64 is the maximum chunk size for every possible wasm hash implementation
|
|
15
|
-
// 4 is the maximum number of bytes per char for string encoding (max is utf-8)
|
|
16
|
-
// ~3 makes sure that it's always a block of 4 chars, so avoid partially encoded bytes for base64
|
|
17
|
-
exports.MAX_SHORT_STRING = Math.floor((65536 - 64) / 4) & ~3;
|
|
18
|
-
class WasmHash {
|
|
19
|
-
/**
|
|
20
|
-
* @param instance wasm instance
|
|
21
|
-
* @param instancesPool pool of instances
|
|
22
|
-
* @param chunkSize size of data chunks passed to wasm
|
|
23
|
-
* @param digestSize size of digest returned by wasm
|
|
24
|
-
*/
|
|
25
|
-
constructor(instance, instancesPool, chunkSize, digestSize) {
|
|
26
|
-
const exports = instance.exports;
|
|
27
|
-
exports.init();
|
|
28
|
-
this.exports = exports;
|
|
29
|
-
this.mem = Buffer.from(exports.memory.buffer, 0, 65536);
|
|
30
|
-
this.buffered = 0;
|
|
31
|
-
this.instancesPool = instancesPool;
|
|
32
|
-
this.chunkSize = chunkSize;
|
|
33
|
-
this.digestSize = digestSize;
|
|
34
|
-
}
|
|
35
|
-
reset() {
|
|
36
|
-
this.buffered = 0;
|
|
37
|
-
this.exports.init();
|
|
38
|
-
}
|
|
39
|
-
/**
|
|
40
|
-
* @param data data
|
|
41
|
-
* @param encoding encoding
|
|
42
|
-
* @returns itself
|
|
43
|
-
*/
|
|
44
|
-
update(data, encoding) {
|
|
45
|
-
if (typeof data === "string") {
|
|
46
|
-
let normalizedData = data;
|
|
47
|
-
while (normalizedData.length > exports.MAX_SHORT_STRING) {
|
|
48
|
-
this._updateWithShortString(normalizedData.slice(0, exports.MAX_SHORT_STRING), encoding);
|
|
49
|
-
normalizedData = normalizedData.slice(exports.MAX_SHORT_STRING);
|
|
50
|
-
}
|
|
51
|
-
this._updateWithShortString(normalizedData, encoding);
|
|
52
|
-
return this;
|
|
53
|
-
}
|
|
54
|
-
this._updateWithBuffer(data);
|
|
55
|
-
return this;
|
|
56
|
-
}
|
|
57
|
-
/**
|
|
58
|
-
* @param {string} data data
|
|
59
|
-
* @param {BufferEncoding=} encoding encoding
|
|
60
|
-
* @returns {void}
|
|
61
|
-
*/
|
|
62
|
-
_updateWithShortString(data, encoding) {
|
|
63
|
-
const { exports, buffered, mem, chunkSize } = this;
|
|
64
|
-
let endPos;
|
|
65
|
-
if (data.length < 70) {
|
|
66
|
-
if (!encoding || encoding === "utf-8" || encoding === "utf8") {
|
|
67
|
-
endPos = buffered;
|
|
68
|
-
for (let i = 0; i < data.length; i++) {
|
|
69
|
-
const cc = data.charCodeAt(i);
|
|
70
|
-
if (cc < 0x80)
|
|
71
|
-
mem[endPos++] = cc;
|
|
72
|
-
else if (cc < 0x800) {
|
|
73
|
-
mem[endPos] = (cc >> 6) | 0xc0;
|
|
74
|
-
mem[endPos + 1] = (cc & 0x3f) | 0x80;
|
|
75
|
-
endPos += 2;
|
|
76
|
-
}
|
|
77
|
-
else {
|
|
78
|
-
// bail-out for weird chars
|
|
79
|
-
endPos += mem.write(data.slice(i), endPos, encoding);
|
|
80
|
-
break;
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
else if (encoding === "latin1") {
|
|
85
|
-
endPos = buffered;
|
|
86
|
-
for (let i = 0; i < data.length; i++) {
|
|
87
|
-
const cc = data.charCodeAt(i);
|
|
88
|
-
mem[endPos++] = cc;
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
else {
|
|
92
|
-
endPos = buffered + mem.write(data, buffered, encoding);
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
else {
|
|
96
|
-
endPos = buffered + mem.write(data, buffered, encoding);
|
|
97
|
-
}
|
|
98
|
-
if (endPos < chunkSize) {
|
|
99
|
-
this.buffered = endPos;
|
|
100
|
-
}
|
|
101
|
-
else {
|
|
102
|
-
const l = endPos & ~(this.chunkSize - 1);
|
|
103
|
-
exports.update(l);
|
|
104
|
-
const newBuffered = endPos - l;
|
|
105
|
-
this.buffered = newBuffered;
|
|
106
|
-
if (newBuffered > 0)
|
|
107
|
-
mem.copyWithin(0, l, endPos);
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
/**
|
|
111
|
-
* @param data data
|
|
112
|
-
* @returns
|
|
113
|
-
*/
|
|
114
|
-
_updateWithBuffer(data) {
|
|
115
|
-
const { exports, buffered, mem } = this;
|
|
116
|
-
const length = data.length;
|
|
117
|
-
if (buffered + length < this.chunkSize) {
|
|
118
|
-
data.copy(mem, buffered, 0, length);
|
|
119
|
-
this.buffered += length;
|
|
120
|
-
}
|
|
121
|
-
else {
|
|
122
|
-
const l = (buffered + length) & ~(this.chunkSize - 1);
|
|
123
|
-
if (l > 65536) {
|
|
124
|
-
let i = 65536 - buffered;
|
|
125
|
-
data.copy(mem, buffered, 0, i);
|
|
126
|
-
exports.update(65536);
|
|
127
|
-
const stop = l - buffered - 65536;
|
|
128
|
-
while (i < stop) {
|
|
129
|
-
data.copy(mem, 0, i, i + 65536);
|
|
130
|
-
exports.update(65536);
|
|
131
|
-
i += 65536;
|
|
132
|
-
}
|
|
133
|
-
data.copy(mem, 0, i, l - buffered);
|
|
134
|
-
exports.update(l - buffered - i);
|
|
135
|
-
}
|
|
136
|
-
else {
|
|
137
|
-
data.copy(mem, buffered, 0, l - buffered);
|
|
138
|
-
exports.update(l);
|
|
139
|
-
}
|
|
140
|
-
const newBuffered = length + buffered - l;
|
|
141
|
-
this.buffered = newBuffered;
|
|
142
|
-
if (newBuffered > 0)
|
|
143
|
-
data.copy(mem, 0, length - newBuffered, length);
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
digest(type) {
|
|
147
|
-
const { exports, buffered, mem, digestSize } = this;
|
|
148
|
-
exports.final(buffered);
|
|
149
|
-
this.instancesPool.push(this);
|
|
150
|
-
const hex = mem.toString("latin1", 0, digestSize);
|
|
151
|
-
if (type === "hex")
|
|
152
|
-
return hex;
|
|
153
|
-
if (type === "binary" || !type)
|
|
154
|
-
return Buffer.from(hex, "hex");
|
|
155
|
-
return Buffer.from(hex, "hex").toString(type);
|
|
156
|
-
}
|
|
157
|
-
}
|
|
158
|
-
exports.WasmHash = WasmHash;
|
|
159
|
-
const create = (wasmModule, instancesPool, chunkSize, digestSize) => {
|
|
160
|
-
if (instancesPool.length > 0) {
|
|
161
|
-
const old = instancesPool.pop();
|
|
162
|
-
old.reset();
|
|
163
|
-
return old;
|
|
164
|
-
}
|
|
165
|
-
return new WasmHash(new WebAssembly.Instance(wasmModule), instancesPool, chunkSize, digestSize);
|
|
166
|
-
};
|
|
167
|
-
exports.default = create;
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* The following code is modified based on
|
|
4
|
-
* https://github.com/webpack/webpack/blob/4b4ca3b/lib/util/hash/xxhash64.js
|
|
5
|
-
*
|
|
6
|
-
* MIT Licensed
|
|
7
|
-
* Author Tobias Koppers @sokra
|
|
8
|
-
* Copyright (c) JS Foundation and other contributors
|
|
9
|
-
* https://github.com/webpack/webpack/blob/main/LICENSE
|
|
10
|
-
*/
|
|
11
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
-
};
|
|
14
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
const wasm_hash_1 = __importDefault(require("./wasm-hash"));
|
|
16
|
-
let createXxhash64;
|
|
17
|
-
exports.default = () => {
|
|
18
|
-
if (!createXxhash64) {
|
|
19
|
-
//#region wasm code: xxhash64 (../../../assembly/hash/xxhash64.asm.ts) --initialMemory 1
|
|
20
|
-
const xxhash64 = new WebAssembly.Module(Buffer.from(
|
|
21
|
-
// 1170 bytes
|
|
22
|
-
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55/fiECIAFBAWohAQwBCwtBACACIAJCIYiFQs/W077Sx6vZQn4iAkIdiCAChUL5893xmfaZqxZ+IgJCIIggAoUiAkIgiCIDQv//A4NCIIYgA0KAgPz/D4NCEIiEIgNC/4GAgPAfg0IQhiADQoD+g4CA4D+DQgiIhCIDQo+AvIDwgcAHg0IIhiADQvCBwIeAnoD4AINCBIiEIgNChoyYsODAgYMGfEIEiEKBgoSIkKDAgAGDQid+IANCsODAgYOGjJgwhHw3AwBBCCACQv////8PgyICQv//A4NCIIYgAkKAgPz/D4NCEIiEIgJC/4GAgPAfg0IQhiACQoD+g4CA4D+DQgiIhCICQo+AvIDwgcAHg0IIhiACQvCBwIeAnoD4AINCBIiEIgJChoyYsODAgYMGfEIEiEKBgoSIkKDAgAGDQid+IAJCsODAgYOGjJgwhHw3AwAL", "base64"));
|
|
23
|
-
//#endregion
|
|
24
|
-
createXxhash64 = wasm_hash_1.default.bind(null, xxhash64, [], 32, 16);
|
|
25
|
-
}
|
|
26
|
-
return createXxhash64();
|
|
27
|
-
};
|