From 9bce51f651aad297ef9eb6df832bfdaf1de05d84 Mon Sep 17 00:00:00 2001
From: WXL <wl_5969728@163.com>
Date: 星期三, 22 四月 2026 14:27:54 +0800
Subject: [PATCH] 青岛推送
---
node_modules/webpack/lib/runtime/ToBinaryRuntimeModule.js | 21 +++++++++++++++------
1 files changed, 15 insertions(+), 6 deletions(-)
diff --git a/node_modules/webpack/lib/runtime/ToBinaryRuntimeModule.js b/node_modules/webpack/lib/runtime/ToBinaryRuntimeModule.js
index 38cfbaf..a5febf0 100644
--- a/node_modules/webpack/lib/runtime/ToBinaryRuntimeModule.js
+++ b/node_modules/webpack/lib/runtime/ToBinaryRuntimeModule.js
@@ -17,6 +17,7 @@
}
/**
+ * Generates runtime code for this runtime module.
* @returns {string | null} runtime code
*/
generate() {
@@ -29,30 +30,38 @@
const isNodePlatform = compilation.compiler.platform.node;
const isWebPlatform = compilation.compiler.platform.web;
const isNeutralPlatform = runtimeTemplate.isNeutralPlatform();
+ const toImmutableBytes = runtimeTemplate.basicFunction("value", [
+ runtimeTemplate.destructureObject(["buffer"], "value"),
+ `${runtimeTemplate.renderConst()} throwErr = ${runtimeTemplate.basicFunction("", ["throw new TypeError('ArrayBuffer is immutable');"])};`,
+ "Object.defineProperties(buffer, { immutable: { value: true }, resize: { value: throwErr }, transfer: { value: throwErr }, transferToFixedLength: { value: throwErr } });",
+ "Object.freeze(buffer);",
+ "return value;"
+ ]);
return Template.asString([
"// define to binary helper",
+ `${runtimeTemplate.renderConst()} toImmutableBytes = ${toImmutableBytes}`,
`${fn} = ${isNeutralPlatform ? "typeof Buffer !== 'undefined' ? " : ""}${
isNodePlatform || isNeutralPlatform
- ? `${runtimeTemplate.returningFunction("new Uint8Array(Buffer.from(base64, 'base64'))", "base64")}`
+ ? `${runtimeTemplate.returningFunction("toImmutableBytes(new Uint8Array(Buffer.from(base64, 'base64')))", "base64")}`
: ""
} ${isNeutralPlatform ? ": " : ""}${
isWebPlatform || isNeutralPlatform
? `(${runtimeTemplate.basicFunction("", [
- "var table = new Uint8Array(128);",
+ `${runtimeTemplate.renderConst()} table = new Uint8Array(128);`,
"for (var i = 0; i < 64; i++) table[i < 26 ? i + 65 : i < 52 ? i + 71 : i < 62 ? i - 4 : i * 4 - 205] = i;",
`return ${runtimeTemplate.basicFunction("base64", [
- "var n = base64.length, bytes = new Uint8Array((n - (base64[n - 1] == '=') - (base64[n - 2] == '=')) * 3 / 4 | 0);",
+ `${runtimeTemplate.renderConst()} n = base64.length, bytes = new Uint8Array((n - (base64[n - 1] == '=') - (base64[n - 2] == '=')) * 3 / 4 | 0);`,
"for (var i = 0, j = 0; i < n;) {",
Template.indent([
- "var c0 = table[base64.charCodeAt(i++)], c1 = table[base64.charCodeAt(i++)];",
- "var c2 = table[base64.charCodeAt(i++)], c3 = table[base64.charCodeAt(i++)];",
+ `${runtimeTemplate.renderConst()} c0 = table[base64.charCodeAt(i++)], c1 = table[base64.charCodeAt(i++)];`,
+ `${runtimeTemplate.renderConst()} c2 = table[base64.charCodeAt(i++)], c3 = table[base64.charCodeAt(i++)];`,
"bytes[j++] = (c0 << 2) | (c1 >> 4);",
"bytes[j++] = (c1 << 4) | (c2 >> 2);",
"bytes[j++] = (c2 << 6) | c3;"
]),
"}",
- "return bytes"
+ "return toImmutableBytes(bytes)"
])}`
])})();`
: ""
--
Gitblit v1.9.3