$
This commit is contained in:
22
node_modules/webpack/lib/serialization/ArraySerializer.js
generated
vendored
Normal file
22
node_modules/webpack/lib/serialization/ArraySerializer.js
generated
vendored
Normal file
@@ -0,0 +1,22 @@
|
||||
/*
|
||||
MIT License http://www.opensource.org/licenses/mit-license.php
|
||||
*/
|
||||
|
||||
"use strict";
|
||||
|
||||
class ArraySerializer {
|
||||
serialize(array, { write }) {
|
||||
write(array.length);
|
||||
for (const item of array) write(item);
|
||||
}
|
||||
deserialize({ read }) {
|
||||
const length = read();
|
||||
const array = [];
|
||||
for (let i = 0; i < length; i++) {
|
||||
array.push(read());
|
||||
}
|
||||
return array;
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = ArraySerializer;
|
950
node_modules/webpack/lib/serialization/BinaryMiddleware.js
generated
vendored
Normal file
950
node_modules/webpack/lib/serialization/BinaryMiddleware.js
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
16
node_modules/webpack/lib/serialization/DateObjectSerializer.js
generated
vendored
Normal file
16
node_modules/webpack/lib/serialization/DateObjectSerializer.js
generated
vendored
Normal file
@@ -0,0 +1,16 @@
|
||||
/*
|
||||
MIT License http://www.opensource.org/licenses/mit-license.php
|
||||
*/
|
||||
|
||||
"use strict";
|
||||
|
||||
class DateObjectSerializer {
|
||||
serialize(obj, { write }) {
|
||||
write(obj.getTime());
|
||||
}
|
||||
deserialize({ read }) {
|
||||
return new Date(read());
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = DateObjectSerializer;
|
27
node_modules/webpack/lib/serialization/ErrorObjectSerializer.js
generated
vendored
Normal file
27
node_modules/webpack/lib/serialization/ErrorObjectSerializer.js
generated
vendored
Normal file
@@ -0,0 +1,27 @@
|
||||
/*
|
||||
MIT License http://www.opensource.org/licenses/mit-license.php
|
||||
*/
|
||||
|
||||
"use strict";
|
||||
|
||||
class ErrorObjectSerializer {
|
||||
constructor(Type) {
|
||||
this.Type = Type;
|
||||
}
|
||||
|
||||
serialize(obj, { write }) {
|
||||
write(obj.message);
|
||||
write(obj.stack);
|
||||
}
|
||||
|
||||
deserialize({ read }) {
|
||||
const err = new this.Type();
|
||||
|
||||
err.message = read();
|
||||
err.stack = read();
|
||||
|
||||
return err;
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = ErrorObjectSerializer;
|
665
node_modules/webpack/lib/serialization/FileMiddleware.js
generated
vendored
Normal file
665
node_modules/webpack/lib/serialization/FileMiddleware.js
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
31
node_modules/webpack/lib/serialization/MapObjectSerializer.js
generated
vendored
Normal file
31
node_modules/webpack/lib/serialization/MapObjectSerializer.js
generated
vendored
Normal file
@@ -0,0 +1,31 @@
|
||||
/*
|
||||
MIT License http://www.opensource.org/licenses/mit-license.php
|
||||
*/
|
||||
|
||||
"use strict";
|
||||
|
||||
class MapObjectSerializer {
|
||||
serialize(obj, { write }) {
|
||||
write(obj.size);
|
||||
for (const key of obj.keys()) {
|
||||
write(key);
|
||||
}
|
||||
for (const value of obj.values()) {
|
||||
write(value);
|
||||
}
|
||||
}
|
||||
deserialize({ read }) {
|
||||
let size = read();
|
||||
const map = new Map();
|
||||
const keys = [];
|
||||
for (let i = 0; i < size; i++) {
|
||||
keys.push(read());
|
||||
}
|
||||
for (let i = 0; i < size; i++) {
|
||||
map.set(keys[i], read());
|
||||
}
|
||||
return map;
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = MapObjectSerializer;
|
33
node_modules/webpack/lib/serialization/NullPrototypeObjectSerializer.js
generated
vendored
Normal file
33
node_modules/webpack/lib/serialization/NullPrototypeObjectSerializer.js
generated
vendored
Normal file
@@ -0,0 +1,33 @@
|
||||
/*
|
||||
MIT License http://www.opensource.org/licenses/mit-license.php
|
||||
*/
|
||||
|
||||
"use strict";
|
||||
|
||||
class NullPrototypeObjectSerializer {
|
||||
serialize(obj, { write }) {
|
||||
const keys = Object.keys(obj);
|
||||
for (const key of keys) {
|
||||
write(key);
|
||||
}
|
||||
write(null);
|
||||
for (const key of keys) {
|
||||
write(obj[key]);
|
||||
}
|
||||
}
|
||||
deserialize({ read }) {
|
||||
const obj = Object.create(null);
|
||||
const keys = [];
|
||||
let key = read();
|
||||
while (key !== null) {
|
||||
keys.push(key);
|
||||
key = read();
|
||||
}
|
||||
for (const key of keys) {
|
||||
obj[key] = read();
|
||||
}
|
||||
return obj;
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = NullPrototypeObjectSerializer;
|
734
node_modules/webpack/lib/serialization/ObjectMiddleware.js
generated
vendored
Normal file
734
node_modules/webpack/lib/serialization/ObjectMiddleware.js
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
80
node_modules/webpack/lib/serialization/PlainObjectSerializer.js
generated
vendored
Normal file
80
node_modules/webpack/lib/serialization/PlainObjectSerializer.js
generated
vendored
Normal file
@@ -0,0 +1,80 @@
|
||||
/*
|
||||
MIT License http://www.opensource.org/licenses/mit-license.php
|
||||
*/
|
||||
|
||||
"use strict";
|
||||
|
||||
const cache = new WeakMap();
|
||||
|
||||
class ObjectStructure {
|
||||
constructor() {
|
||||
this.keys = undefined;
|
||||
this.children = undefined;
|
||||
}
|
||||
|
||||
getKeys(keys) {
|
||||
if (this.keys === undefined) this.keys = keys;
|
||||
return this.keys;
|
||||
}
|
||||
|
||||
key(key) {
|
||||
if (this.children === undefined) this.children = new Map();
|
||||
const child = this.children.get(key);
|
||||
if (child !== undefined) return child;
|
||||
const newChild = new ObjectStructure();
|
||||
this.children.set(key, newChild);
|
||||
return newChild;
|
||||
}
|
||||
}
|
||||
|
||||
const getCachedKeys = (keys, cacheAssoc) => {
|
||||
let root = cache.get(cacheAssoc);
|
||||
if (root === undefined) {
|
||||
root = new ObjectStructure();
|
||||
cache.set(cacheAssoc, root);
|
||||
}
|
||||
let current = root;
|
||||
for (const key of keys) {
|
||||
current = current.key(key);
|
||||
}
|
||||
return current.getKeys(keys);
|
||||
};
|
||||
|
||||
class PlainObjectSerializer {
|
||||
serialize(obj, { write }) {
|
||||
const keys = Object.keys(obj);
|
||||
if (keys.length > 128) {
|
||||
// Objects with so many keys are unlikely to share structure
|
||||
// with other objects
|
||||
write(keys);
|
||||
for (const key of keys) {
|
||||
write(obj[key]);
|
||||
}
|
||||
} else if (keys.length > 1) {
|
||||
write(getCachedKeys(keys, write));
|
||||
for (const key of keys) {
|
||||
write(obj[key]);
|
||||
}
|
||||
} else if (keys.length === 1) {
|
||||
const key = keys[0];
|
||||
write(key);
|
||||
write(obj[key]);
|
||||
} else {
|
||||
write(null);
|
||||
}
|
||||
}
|
||||
deserialize({ read }) {
|
||||
const keys = read();
|
||||
const obj = {};
|
||||
if (Array.isArray(keys)) {
|
||||
for (const key of keys) {
|
||||
obj[key] = read();
|
||||
}
|
||||
} else if (keys !== null) {
|
||||
obj[keys] = read();
|
||||
}
|
||||
return obj;
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = PlainObjectSerializer;
|
17
node_modules/webpack/lib/serialization/RegExpObjectSerializer.js
generated
vendored
Normal file
17
node_modules/webpack/lib/serialization/RegExpObjectSerializer.js
generated
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
/*
|
||||
MIT License http://www.opensource.org/licenses/mit-license.php
|
||||
*/
|
||||
|
||||
"use strict";
|
||||
|
||||
class RegExpObjectSerializer {
|
||||
serialize(obj, { write }) {
|
||||
write(obj.source);
|
||||
write(obj.flags);
|
||||
}
|
||||
deserialize({ read }) {
|
||||
return new RegExp(read(), read());
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = RegExpObjectSerializer;
|
46
node_modules/webpack/lib/serialization/Serializer.js
generated
vendored
Normal file
46
node_modules/webpack/lib/serialization/Serializer.js
generated
vendored
Normal file
@@ -0,0 +1,46 @@
|
||||
/*
|
||||
MIT License http://www.opensource.org/licenses/mit-license.php
|
||||
*/
|
||||
|
||||
"use strict";
|
||||
|
||||
class Serializer {
|
||||
constructor(middlewares, context) {
|
||||
this.serializeMiddlewares = middlewares.slice();
|
||||
this.deserializeMiddlewares = middlewares.slice().reverse();
|
||||
this.context = context;
|
||||
}
|
||||
|
||||
serialize(obj, context) {
|
||||
const ctx = { ...context, ...this.context };
|
||||
let current = obj;
|
||||
for (const middleware of this.serializeMiddlewares) {
|
||||
if (current && typeof current.then === "function") {
|
||||
current = current.then(data => data && middleware.serialize(data, ctx));
|
||||
} else if (current) {
|
||||
try {
|
||||
current = middleware.serialize(current, ctx);
|
||||
} catch (err) {
|
||||
current = Promise.reject(err);
|
||||
}
|
||||
} else break;
|
||||
}
|
||||
return current;
|
||||
}
|
||||
|
||||
deserialize(value, context) {
|
||||
const ctx = { ...context, ...this.context };
|
||||
/** @type {any} */
|
||||
let current = value;
|
||||
for (const middleware of this.deserializeMiddlewares) {
|
||||
if (current && typeof current.then === "function") {
|
||||
current = current.then(data => middleware.deserialize(data, ctx));
|
||||
} else {
|
||||
current = middleware.deserialize(current, ctx);
|
||||
}
|
||||
}
|
||||
return current;
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = Serializer;
|
153
node_modules/webpack/lib/serialization/SerializerMiddleware.js
generated
vendored
Normal file
153
node_modules/webpack/lib/serialization/SerializerMiddleware.js
generated
vendored
Normal file
@@ -0,0 +1,153 @@
|
||||
/*
|
||||
MIT License http://www.opensource.org/licenses/mit-license.php
|
||||
*/
|
||||
|
||||
"use strict";
|
||||
|
||||
const memoize = require("../util/memoize");
|
||||
|
||||
const LAZY_TARGET = Symbol("lazy serialization target");
|
||||
const LAZY_SERIALIZED_VALUE = Symbol("lazy serialization data");
|
||||
|
||||
/**
|
||||
* @template DeserializedType
|
||||
* @template SerializedType
|
||||
*/
|
||||
class SerializerMiddleware {
|
||||
/* istanbul ignore next */
|
||||
/**
|
||||
* @abstract
|
||||
* @param {DeserializedType} data data
|
||||
* @param {Object} context context object
|
||||
* @returns {SerializedType|Promise<SerializedType>} serialized data
|
||||
*/
|
||||
serialize(data, context) {
|
||||
const AbstractMethodError = require("../AbstractMethodError");
|
||||
throw new AbstractMethodError();
|
||||
}
|
||||
|
||||
/* istanbul ignore next */
|
||||
/**
|
||||
* @abstract
|
||||
* @param {SerializedType} data data
|
||||
* @param {Object} context context object
|
||||
* @returns {DeserializedType|Promise<DeserializedType>} deserialized data
|
||||
*/
|
||||
deserialize(data, context) {
|
||||
const AbstractMethodError = require("../AbstractMethodError");
|
||||
throw new AbstractMethodError();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {any | function(): Promise<any> | any} value contained value or function to value
|
||||
* @param {SerializerMiddleware<any, any>} target target middleware
|
||||
* @param {object=} options lazy options
|
||||
* @param {any=} serializedValue serialized value
|
||||
* @returns {function(): Promise<any> | any} lazy function
|
||||
*/
|
||||
static createLazy(value, target, options = {}, serializedValue) {
|
||||
if (SerializerMiddleware.isLazy(value, target)) return value;
|
||||
const fn = typeof value === "function" ? value : () => value;
|
||||
fn[LAZY_TARGET] = target;
|
||||
/** @type {any} */ (fn).options = options;
|
||||
fn[LAZY_SERIALIZED_VALUE] = serializedValue;
|
||||
return fn;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {function(): Promise<any> | any} fn lazy function
|
||||
* @param {SerializerMiddleware<any, any>=} target target middleware
|
||||
* @returns {boolean} true, when fn is a lazy function (optionally of that target)
|
||||
*/
|
||||
static isLazy(fn, target) {
|
||||
if (typeof fn !== "function") return false;
|
||||
const t = fn[LAZY_TARGET];
|
||||
return target ? t === target : !!t;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {function(): Promise<any> | any} fn lazy function
|
||||
* @returns {object} options
|
||||
*/
|
||||
static getLazyOptions(fn) {
|
||||
if (typeof fn !== "function") return undefined;
|
||||
return /** @type {any} */ (fn).options;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {function(): Promise<any> | any} fn lazy function
|
||||
* @returns {any} serialized value
|
||||
*/
|
||||
static getLazySerializedValue(fn) {
|
||||
if (typeof fn !== "function") return undefined;
|
||||
return fn[LAZY_SERIALIZED_VALUE];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {function(): Promise<any> | any} fn lazy function
|
||||
* @param {any} value serialized value
|
||||
* @returns {void}
|
||||
*/
|
||||
static setLazySerializedValue(fn, value) {
|
||||
fn[LAZY_SERIALIZED_VALUE] = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {function(): Promise<any> | any} lazy lazy function
|
||||
* @param {function(any): Promise<any> | any} serialize serialize function
|
||||
* @returns {function(): Promise<any> | any} new lazy
|
||||
*/
|
||||
static serializeLazy(lazy, serialize) {
|
||||
const fn = memoize(() => {
|
||||
const r = lazy();
|
||||
if (r && typeof r.then === "function") {
|
||||
return r.then(data => data && serialize(data));
|
||||
}
|
||||
return serialize(r);
|
||||
});
|
||||
fn[LAZY_TARGET] = lazy[LAZY_TARGET];
|
||||
/** @type {any} */ (fn).options = /** @type {any} */ (lazy).options;
|
||||
lazy[LAZY_SERIALIZED_VALUE] = fn;
|
||||
return fn;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {function(): Promise<any> | any} lazy lazy function
|
||||
* @param {function(any): Promise<any> | any} deserialize deserialize function
|
||||
* @returns {function(): Promise<any> | any} new lazy
|
||||
*/
|
||||
static deserializeLazy(lazy, deserialize) {
|
||||
const fn = memoize(() => {
|
||||
const r = lazy();
|
||||
if (r && typeof r.then === "function") {
|
||||
return r.then(data => deserialize(data));
|
||||
}
|
||||
return deserialize(r);
|
||||
});
|
||||
fn[LAZY_TARGET] = lazy[LAZY_TARGET];
|
||||
/** @type {any} */ (fn).options = /** @type {any} */ (lazy).options;
|
||||
fn[LAZY_SERIALIZED_VALUE] = lazy;
|
||||
return fn;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {function(): Promise<any> | any} lazy lazy function
|
||||
* @returns {function(): Promise<any> | any} new lazy
|
||||
*/
|
||||
static unMemoizeLazy(lazy) {
|
||||
if (!SerializerMiddleware.isLazy(lazy)) return lazy;
|
||||
const fn = () => {
|
||||
throw new Error(
|
||||
"A lazy value that has been unmemorized can't be called again"
|
||||
);
|
||||
};
|
||||
fn[LAZY_SERIALIZED_VALUE] = SerializerMiddleware.unMemoizeLazy(
|
||||
lazy[LAZY_SERIALIZED_VALUE]
|
||||
);
|
||||
fn[LAZY_TARGET] = lazy[LAZY_TARGET];
|
||||
fn.options = /** @type {any} */ (lazy).options;
|
||||
return fn;
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = SerializerMiddleware;
|
24
node_modules/webpack/lib/serialization/SetObjectSerializer.js
generated
vendored
Normal file
24
node_modules/webpack/lib/serialization/SetObjectSerializer.js
generated
vendored
Normal file
@@ -0,0 +1,24 @@
|
||||
/*
|
||||
MIT License http://www.opensource.org/licenses/mit-license.php
|
||||
*/
|
||||
|
||||
"use strict";
|
||||
|
||||
class SetObjectSerializer {
|
||||
serialize(obj, { write }) {
|
||||
write(obj.size);
|
||||
for (const value of obj) {
|
||||
write(value);
|
||||
}
|
||||
}
|
||||
deserialize({ read }) {
|
||||
let size = read();
|
||||
const set = new Set();
|
||||
for (let i = 0; i < size; i++) {
|
||||
set.add(read());
|
||||
}
|
||||
return set;
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = SetObjectSerializer;
|
34
node_modules/webpack/lib/serialization/SingleItemMiddleware.js
generated
vendored
Normal file
34
node_modules/webpack/lib/serialization/SingleItemMiddleware.js
generated
vendored
Normal file
@@ -0,0 +1,34 @@
|
||||
/*
|
||||
MIT License http://www.opensource.org/licenses/mit-license.php
|
||||
*/
|
||||
|
||||
"use strict";
|
||||
|
||||
const SerializerMiddleware = require("./SerializerMiddleware");
|
||||
|
||||
/**
|
||||
* @typedef {any} DeserializedType
|
||||
* @typedef {any[]} SerializedType
|
||||
* @extends {SerializerMiddleware<any, any[]>}
|
||||
*/
|
||||
class SingleItemMiddleware extends SerializerMiddleware {
|
||||
/**
|
||||
* @param {DeserializedType} data data
|
||||
* @param {Object} context context object
|
||||
* @returns {SerializedType|Promise<SerializedType>} serialized data
|
||||
*/
|
||||
serialize(data, context) {
|
||||
return [data];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {SerializedType} data data
|
||||
* @param {Object} context context object
|
||||
* @returns {DeserializedType|Promise<DeserializedType>} deserialized data
|
||||
*/
|
||||
deserialize(data, context) {
|
||||
return data[0];
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = SingleItemMiddleware;
|
13
node_modules/webpack/lib/serialization/types.js
generated
vendored
Normal file
13
node_modules/webpack/lib/serialization/types.js
generated
vendored
Normal file
@@ -0,0 +1,13 @@
|
||||
/*
|
||||
MIT License http://www.opensource.org/licenses/mit-license.php
|
||||
*/
|
||||
|
||||
"use strict";
|
||||
|
||||
/** @typedef {undefined|null|number|string|boolean|Buffer|Object|(() => ComplexSerializableType[] | Promise<ComplexSerializableType[]>)} ComplexSerializableType */
|
||||
|
||||
/** @typedef {undefined|null|number|string|boolean|Buffer|(() => PrimitiveSerializableType[] | Promise<PrimitiveSerializableType[]>)} PrimitiveSerializableType */
|
||||
|
||||
/** @typedef {Buffer|(() => BufferSerializableType[] | Promise<BufferSerializableType[]>)} BufferSerializableType */
|
||||
|
||||
module.exports = {};
|
Reference in New Issue
Block a user