summaryrefslogtreecommitdiff
path: root/node_modules/webpack-sources/lib/RawSource.js
diff options
context:
space:
mode:
authorlittleblack111 <littleblack11111@gmail.com>2023-11-05 17:16:09 +0800
committerlittleblack111 <littleblack11111@gmail.com>2023-11-05 17:16:09 +0800
commitd1d9f00b1bd660842addf5e6b1d1b64c852a9eea (patch)
tree60fb37ae73a1109d95301de5ec9b61b5726a4b61 /node_modules/webpack-sources/lib/RawSource.js
parent7c85166c4cbdd862fc4252007d2df5befcbc2a58 (diff)
added hover prefixer
Diffstat (limited to 'node_modules/webpack-sources/lib/RawSource.js')
-rw-r--r--node_modules/webpack-sources/lib/RawSource.js81
1 files changed, 81 insertions, 0 deletions
diff --git a/node_modules/webpack-sources/lib/RawSource.js b/node_modules/webpack-sources/lib/RawSource.js
new file mode 100644
index 00000000..71f1341c
--- /dev/null
+++ b/node_modules/webpack-sources/lib/RawSource.js
@@ -0,0 +1,81 @@
+/*
+ MIT License http://www.opensource.org/licenses/mit-license.php
+ Author Tobias Koppers @sokra
+*/
+
+"use strict";
+
+const streamChunksOfRawSource = require("./helpers/streamChunksOfRawSource");
+const Source = require("./Source");
+
+class RawSource extends Source {
+ constructor(value, convertToString = false) {
+ super();
+ const isBuffer = Buffer.isBuffer(value);
+ if (!isBuffer && typeof value !== "string") {
+ throw new TypeError("argument 'value' must be either string of Buffer");
+ }
+ this._valueIsBuffer = !convertToString && isBuffer;
+ this._value = convertToString && isBuffer ? undefined : value;
+ this._valueAsBuffer = isBuffer ? value : undefined;
+ this._valueAsString = isBuffer ? undefined : value;
+ }
+
+ isBuffer() {
+ return this._valueIsBuffer;
+ }
+
+ source() {
+ if (this._value === undefined) {
+ this._value = this._valueAsBuffer.toString("utf-8");
+ }
+ return this._value;
+ }
+
+ buffer() {
+ if (this._valueAsBuffer === undefined) {
+ this._valueAsBuffer = Buffer.from(this._value, "utf-8");
+ }
+ return this._valueAsBuffer;
+ }
+
+ map(options) {
+ return null;
+ }
+
+ /**
+ * @param {object} options options
+ * @param {function(string, number, number, number, number, number, number): void} onChunk called for each chunk of code
+ * @param {function(number, string, string)} onSource called for each source
+ * @param {function(number, string)} onName called for each name
+ * @returns {void}
+ */
+ streamChunks(options, onChunk, onSource, onName) {
+ if (this._value === undefined) {
+ this._value = Buffer.from(this._valueAsBuffer, "utf-8");
+ }
+ if (this._valueAsString === undefined) {
+ this._valueAsString =
+ typeof this._value === "string"
+ ? this._value
+ : this._value.toString("utf-8");
+ }
+ return streamChunksOfRawSource(
+ this._valueAsString,
+ onChunk,
+ onSource,
+ onName,
+ !!(options && options.finalSource)
+ );
+ }
+
+ updateHash(hash) {
+ if (this._valueAsBuffer === undefined) {
+ this._valueAsBuffer = Buffer.from(this._value, "utf-8");
+ }
+ hash.update("RawSource");
+ hash.update(this._valueAsBuffer);
+ }
+}
+
+module.exports = RawSource;