@8ms/helpers 3.0.8 → 3.0.10
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/_virtual/_rolldown/runtime.cjs +0 -2
- package/dist/_virtual/_rolldown/runtime.mjs +1 -22
- package/dist/aws/s3/server/AwsS3.cjs +2 -2
- package/dist/aws/s3/server/AwsS3.mjs +2 -2
- package/dist/aws/ses/server/SimpleEmail.cjs +12 -9
- package/dist/aws/ses/server/SimpleEmail.d.cts +3 -31
- package/dist/aws/ses/server/SimpleEmail.d.mts +3 -31
- package/dist/aws/ses/server/SimpleEmail.mjs +12 -9
- package/dist/emsApi/awsTs/get.cjs +1 -1
- package/dist/emsApi/awsTs/get.d.cts +1 -1
- package/dist/emsApi/awsTs/get.d.mts +1 -1
- package/dist/emsApi/awsTs/get.mjs +1 -1
- package/dist/emsApi/vercel/get.cjs +1 -1
- package/dist/emsApi/vercel/get.d.cts +1 -1
- package/dist/emsApi/vercel/get.d.mts +1 -1
- package/dist/emsApi/vercel/get.mjs +1 -1
- package/dist/prisma/server/{PrismaNamespace.cjs → Prisma.cjs} +18 -12
- package/dist/prisma/server/{prisma.d.mts → Prisma.d.cts} +15 -11
- package/dist/prisma/server/{prisma.d.cts → Prisma.d.mts} +15 -11
- package/dist/prisma/server/{PrismaNamespace.mjs → Prisma.mjs} +18 -12
- package/dist/prisma/server/index.cjs +2 -4
- package/dist/prisma/server/index.d.cts +2 -3
- package/dist/prisma/server/index.d.mts +2 -3
- package/dist/prisma/server/index.mjs +2 -3
- package/package.json +5 -16
- package/dist/node_modules/data-uri-to-buffer/dist/index.cjs +0 -37
- package/dist/node_modules/data-uri-to-buffer/dist/index.mjs +0 -37
- package/dist/node_modules/fetch-blob/file.cjs +0 -31
- package/dist/node_modules/fetch-blob/file.mjs +0 -31
- package/dist/node_modules/fetch-blob/from.cjs +0 -8
- package/dist/node_modules/fetch-blob/from.mjs +0 -9
- package/dist/node_modules/fetch-blob/index.cjs +0 -171
- package/dist/node_modules/fetch-blob/index.mjs +0 -172
- package/dist/node_modules/fetch-blob/streams.cjs +0 -45
- package/dist/node_modules/fetch-blob/streams.mjs +0 -41
- package/dist/node_modules/formdata-polyfill/esm.min.cjs +0 -83
- package/dist/node_modules/formdata-polyfill/esm.min.mjs +0 -82
- package/dist/node_modules/node-domexception/index.cjs +0 -18
- package/dist/node_modules/node-domexception/index.mjs +0 -15
- package/dist/node_modules/web-streams-polyfill/dist/ponyfill.es2018.cjs +0 -3499
- package/dist/node_modules/web-streams-polyfill/dist/ponyfill.es2018.mjs +0 -3496
- package/dist/prisma/server/PrismaNamespace.d.cts +0 -11
- package/dist/prisma/server/PrismaNamespace.d.mts +0 -11
- package/dist/prisma/server/prisma.cjs +0 -21
- package/dist/prisma/server/prisma.mjs +0 -20
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
//#region node_modules/data-uri-to-buffer/dist/index.js
|
|
2
|
-
/**
|
|
3
|
-
* Returns a `Buffer` instance from the given data URI `uri`.
|
|
4
|
-
*
|
|
5
|
-
* @param {String} uri Data URI to turn into a Buffer instance
|
|
6
|
-
* @returns {Buffer} Buffer instance from Data URI
|
|
7
|
-
* @api public
|
|
8
|
-
*/
|
|
9
|
-
function dataUriToBuffer(uri) {
|
|
10
|
-
if (!/^data:/i.test(uri)) throw new TypeError("`uri` does not appear to be a Data URI (must begin with \"data:\")");
|
|
11
|
-
uri = uri.replace(/\r?\n/g, "");
|
|
12
|
-
const firstComma = uri.indexOf(",");
|
|
13
|
-
if (firstComma === -1 || firstComma <= 4) throw new TypeError("malformed data: URI");
|
|
14
|
-
const meta = uri.substring(5, firstComma).split(";");
|
|
15
|
-
let charset = "";
|
|
16
|
-
let base64 = false;
|
|
17
|
-
const type = meta[0] || "text/plain";
|
|
18
|
-
let typeFull = type;
|
|
19
|
-
for (let i = 1; i < meta.length; i++) if (meta[i] === "base64") base64 = true;
|
|
20
|
-
else if (meta[i]) {
|
|
21
|
-
typeFull += `;${meta[i]}`;
|
|
22
|
-
if (meta[i].indexOf("charset=") === 0) charset = meta[i].substring(8);
|
|
23
|
-
}
|
|
24
|
-
if (!meta[0] && !charset.length) {
|
|
25
|
-
typeFull += ";charset=US-ASCII";
|
|
26
|
-
charset = "US-ASCII";
|
|
27
|
-
}
|
|
28
|
-
const encoding = base64 ? "base64" : "ascii";
|
|
29
|
-
const data = unescape(uri.substring(firstComma + 1));
|
|
30
|
-
const buffer = Buffer.from(data, encoding);
|
|
31
|
-
buffer.type = type;
|
|
32
|
-
buffer.typeFull = typeFull;
|
|
33
|
-
buffer.charset = charset;
|
|
34
|
-
return buffer;
|
|
35
|
-
}
|
|
36
|
-
//#endregion
|
|
37
|
-
exports.default = dataUriToBuffer;
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
//#region node_modules/data-uri-to-buffer/dist/index.js
|
|
2
|
-
/**
|
|
3
|
-
* Returns a `Buffer` instance from the given data URI `uri`.
|
|
4
|
-
*
|
|
5
|
-
* @param {String} uri Data URI to turn into a Buffer instance
|
|
6
|
-
* @returns {Buffer} Buffer instance from Data URI
|
|
7
|
-
* @api public
|
|
8
|
-
*/
|
|
9
|
-
function dataUriToBuffer(uri) {
|
|
10
|
-
if (!/^data:/i.test(uri)) throw new TypeError("`uri` does not appear to be a Data URI (must begin with \"data:\")");
|
|
11
|
-
uri = uri.replace(/\r?\n/g, "");
|
|
12
|
-
const firstComma = uri.indexOf(",");
|
|
13
|
-
if (firstComma === -1 || firstComma <= 4) throw new TypeError("malformed data: URI");
|
|
14
|
-
const meta = uri.substring(5, firstComma).split(";");
|
|
15
|
-
let charset = "";
|
|
16
|
-
let base64 = false;
|
|
17
|
-
const type = meta[0] || "text/plain";
|
|
18
|
-
let typeFull = type;
|
|
19
|
-
for (let i = 1; i < meta.length; i++) if (meta[i] === "base64") base64 = true;
|
|
20
|
-
else if (meta[i]) {
|
|
21
|
-
typeFull += `;${meta[i]}`;
|
|
22
|
-
if (meta[i].indexOf("charset=") === 0) charset = meta[i].substring(8);
|
|
23
|
-
}
|
|
24
|
-
if (!meta[0] && !charset.length) {
|
|
25
|
-
typeFull += ";charset=US-ASCII";
|
|
26
|
-
charset = "US-ASCII";
|
|
27
|
-
}
|
|
28
|
-
const encoding = base64 ? "base64" : "ascii";
|
|
29
|
-
const data = unescape(uri.substring(firstComma + 1));
|
|
30
|
-
const buffer = Buffer.from(data, encoding);
|
|
31
|
-
buffer.type = type;
|
|
32
|
-
buffer.typeFull = typeFull;
|
|
33
|
-
buffer.charset = charset;
|
|
34
|
-
return buffer;
|
|
35
|
-
}
|
|
36
|
-
//#endregion
|
|
37
|
-
export { dataUriToBuffer as default };
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
const require_index = require("./index.cjs");
|
|
2
|
-
/** @type {typeof globalThis.File} */ const File = class File extends require_index.default {
|
|
3
|
-
#lastModified = 0;
|
|
4
|
-
#name = "";
|
|
5
|
-
/**
|
|
6
|
-
* @param {*[]} fileBits
|
|
7
|
-
* @param {string} fileName
|
|
8
|
-
* @param {{lastModified?: number, type?: string}} options
|
|
9
|
-
*/ constructor(fileBits, fileName, options = {}) {
|
|
10
|
-
if (arguments.length < 2) throw new TypeError(`Failed to construct 'File': 2 arguments required, but only ${arguments.length} present.`);
|
|
11
|
-
super(fileBits, options);
|
|
12
|
-
if (options === null) options = {};
|
|
13
|
-
const lastModified = options.lastModified === void 0 ? Date.now() : Number(options.lastModified);
|
|
14
|
-
if (!Number.isNaN(lastModified)) this.#lastModified = lastModified;
|
|
15
|
-
this.#name = String(fileName);
|
|
16
|
-
}
|
|
17
|
-
get name() {
|
|
18
|
-
return this.#name;
|
|
19
|
-
}
|
|
20
|
-
get lastModified() {
|
|
21
|
-
return this.#lastModified;
|
|
22
|
-
}
|
|
23
|
-
get [Symbol.toStringTag]() {
|
|
24
|
-
return "File";
|
|
25
|
-
}
|
|
26
|
-
static [Symbol.hasInstance](object) {
|
|
27
|
-
return !!object && object instanceof require_index.default && /^(File)$/.test(object[Symbol.toStringTag]);
|
|
28
|
-
}
|
|
29
|
-
};
|
|
30
|
-
//#endregion
|
|
31
|
-
exports.default = File;
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import Blob from "./index.mjs";
|
|
2
|
-
/** @type {typeof globalThis.File} */ const File = class File extends Blob {
|
|
3
|
-
#lastModified = 0;
|
|
4
|
-
#name = "";
|
|
5
|
-
/**
|
|
6
|
-
* @param {*[]} fileBits
|
|
7
|
-
* @param {string} fileName
|
|
8
|
-
* @param {{lastModified?: number, type?: string}} options
|
|
9
|
-
*/ constructor(fileBits, fileName, options = {}) {
|
|
10
|
-
if (arguments.length < 2) throw new TypeError(`Failed to construct 'File': 2 arguments required, but only ${arguments.length} present.`);
|
|
11
|
-
super(fileBits, options);
|
|
12
|
-
if (options === null) options = {};
|
|
13
|
-
const lastModified = options.lastModified === void 0 ? Date.now() : Number(options.lastModified);
|
|
14
|
-
if (!Number.isNaN(lastModified)) this.#lastModified = lastModified;
|
|
15
|
-
this.#name = String(fileName);
|
|
16
|
-
}
|
|
17
|
-
get name() {
|
|
18
|
-
return this.#name;
|
|
19
|
-
}
|
|
20
|
-
get lastModified() {
|
|
21
|
-
return this.#lastModified;
|
|
22
|
-
}
|
|
23
|
-
get [Symbol.toStringTag]() {
|
|
24
|
-
return "File";
|
|
25
|
-
}
|
|
26
|
-
static [Symbol.hasInstance](object) {
|
|
27
|
-
return !!object && object instanceof Blob && /^(File)$/.test(object[Symbol.toStringTag]);
|
|
28
|
-
}
|
|
29
|
-
};
|
|
30
|
-
//#endregion
|
|
31
|
-
export { File as default };
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
require("../../_virtual/_rolldown/runtime.cjs");
|
|
2
|
-
require("./index.cjs");
|
|
3
|
-
require("./file.cjs");
|
|
4
|
-
const require_index$1 = require("../node-domexception/index.cjs");
|
|
5
|
-
let node_fs = require("node:fs");
|
|
6
|
-
require_index$1.default;
|
|
7
|
-
const { stat } = node_fs.promises;
|
|
8
|
-
//#endregion
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import "../../_virtual/_rolldown/runtime.mjs";
|
|
2
|
-
import "./index.mjs";
|
|
3
|
-
import "./file.mjs";
|
|
4
|
-
import { require_node_domexception } from "../node-domexception/index.mjs";
|
|
5
|
-
import { promises } from "node:fs";
|
|
6
|
-
require_node_domexception();
|
|
7
|
-
const { stat } = promises;
|
|
8
|
-
//#endregion
|
|
9
|
-
export {};
|
|
@@ -1,171 +0,0 @@
|
|
|
1
|
-
require("./streams.cjs").default;
|
|
2
|
-
const POOL_SIZE = 65536;
|
|
3
|
-
/** @param {(Blob | Uint8Array)[]} parts */
|
|
4
|
-
async function* toIterator(parts, clone = true) {
|
|
5
|
-
for (const part of parts) if ("stream" in part) yield* part.stream();
|
|
6
|
-
else if (ArrayBuffer.isView(part)) if (clone) {
|
|
7
|
-
let position = part.byteOffset;
|
|
8
|
-
const end = part.byteOffset + part.byteLength;
|
|
9
|
-
while (position !== end) {
|
|
10
|
-
const size = Math.min(end - position, POOL_SIZE);
|
|
11
|
-
const chunk = part.buffer.slice(position, position + size);
|
|
12
|
-
position += chunk.byteLength;
|
|
13
|
-
yield new Uint8Array(chunk);
|
|
14
|
-
}
|
|
15
|
-
} else yield part;
|
|
16
|
-
else {
|
|
17
|
-
let position = 0, b = part;
|
|
18
|
-
while (position !== b.size) {
|
|
19
|
-
const buffer = await b.slice(position, Math.min(b.size, position + POOL_SIZE)).arrayBuffer();
|
|
20
|
-
position += buffer.byteLength;
|
|
21
|
-
yield new Uint8Array(buffer);
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
const _Blob = class Blob {
|
|
26
|
-
/** @type {Array.<(Blob|Uint8Array)>} */
|
|
27
|
-
#parts = [];
|
|
28
|
-
#type = "";
|
|
29
|
-
#size = 0;
|
|
30
|
-
#endings = "transparent";
|
|
31
|
-
/**
|
|
32
|
-
* The Blob() constructor returns a new Blob object. The content
|
|
33
|
-
* of the blob consists of the concatenation of the values given
|
|
34
|
-
* in the parameter array.
|
|
35
|
-
*
|
|
36
|
-
* @param {*} blobParts
|
|
37
|
-
* @param {{ type?: string, endings?: string }} [options]
|
|
38
|
-
*/
|
|
39
|
-
constructor(blobParts = [], options = {}) {
|
|
40
|
-
if (typeof blobParts !== "object" || blobParts === null) throw new TypeError("Failed to construct 'Blob': The provided value cannot be converted to a sequence.");
|
|
41
|
-
if (typeof blobParts[Symbol.iterator] !== "function") throw new TypeError("Failed to construct 'Blob': The object must have a callable @@iterator property.");
|
|
42
|
-
if (typeof options !== "object" && typeof options !== "function") throw new TypeError("Failed to construct 'Blob': parameter 2 cannot convert to dictionary.");
|
|
43
|
-
if (options === null) options = {};
|
|
44
|
-
const encoder = new TextEncoder();
|
|
45
|
-
for (const element of blobParts) {
|
|
46
|
-
let part;
|
|
47
|
-
if (ArrayBuffer.isView(element)) part = new Uint8Array(element.buffer.slice(element.byteOffset, element.byteOffset + element.byteLength));
|
|
48
|
-
else if (element instanceof ArrayBuffer) part = new Uint8Array(element.slice(0));
|
|
49
|
-
else if (element instanceof Blob) part = element;
|
|
50
|
-
else part = encoder.encode(`${element}`);
|
|
51
|
-
this.#size += ArrayBuffer.isView(part) ? part.byteLength : part.size;
|
|
52
|
-
this.#parts.push(part);
|
|
53
|
-
}
|
|
54
|
-
this.#endings = `${options.endings === void 0 ? "transparent" : options.endings}`;
|
|
55
|
-
const type = options.type === void 0 ? "" : String(options.type);
|
|
56
|
-
this.#type = /^[\x20-\x7E]*$/.test(type) ? type : "";
|
|
57
|
-
}
|
|
58
|
-
/**
|
|
59
|
-
* The Blob interface's size property returns the
|
|
60
|
-
* size of the Blob in bytes.
|
|
61
|
-
*/
|
|
62
|
-
get size() {
|
|
63
|
-
return this.#size;
|
|
64
|
-
}
|
|
65
|
-
/**
|
|
66
|
-
* The type property of a Blob object returns the MIME type of the file.
|
|
67
|
-
*/
|
|
68
|
-
get type() {
|
|
69
|
-
return this.#type;
|
|
70
|
-
}
|
|
71
|
-
/**
|
|
72
|
-
* The text() method in the Blob interface returns a Promise
|
|
73
|
-
* that resolves with a string containing the contents of
|
|
74
|
-
* the blob, interpreted as UTF-8.
|
|
75
|
-
*
|
|
76
|
-
* @return {Promise<string>}
|
|
77
|
-
*/
|
|
78
|
-
async text() {
|
|
79
|
-
const decoder = new TextDecoder();
|
|
80
|
-
let str = "";
|
|
81
|
-
for await (const part of toIterator(this.#parts, false)) str += decoder.decode(part, { stream: true });
|
|
82
|
-
str += decoder.decode();
|
|
83
|
-
return str;
|
|
84
|
-
}
|
|
85
|
-
/**
|
|
86
|
-
* The arrayBuffer() method in the Blob interface returns a
|
|
87
|
-
* Promise that resolves with the contents of the blob as
|
|
88
|
-
* binary data contained in an ArrayBuffer.
|
|
89
|
-
*
|
|
90
|
-
* @return {Promise<ArrayBuffer>}
|
|
91
|
-
*/
|
|
92
|
-
async arrayBuffer() {
|
|
93
|
-
const data = new Uint8Array(this.size);
|
|
94
|
-
let offset = 0;
|
|
95
|
-
for await (const chunk of toIterator(this.#parts, false)) {
|
|
96
|
-
data.set(chunk, offset);
|
|
97
|
-
offset += chunk.length;
|
|
98
|
-
}
|
|
99
|
-
return data.buffer;
|
|
100
|
-
}
|
|
101
|
-
stream() {
|
|
102
|
-
const it = toIterator(this.#parts, true);
|
|
103
|
-
return new globalThis.ReadableStream({
|
|
104
|
-
type: "bytes",
|
|
105
|
-
async pull(ctrl) {
|
|
106
|
-
const chunk = await it.next();
|
|
107
|
-
chunk.done ? ctrl.close() : ctrl.enqueue(chunk.value);
|
|
108
|
-
},
|
|
109
|
-
async cancel() {
|
|
110
|
-
await it.return();
|
|
111
|
-
}
|
|
112
|
-
});
|
|
113
|
-
}
|
|
114
|
-
/**
|
|
115
|
-
* The Blob interface's slice() method creates and returns a
|
|
116
|
-
* new Blob object which contains data from a subset of the
|
|
117
|
-
* blob on which it's called.
|
|
118
|
-
*
|
|
119
|
-
* @param {number} [start]
|
|
120
|
-
* @param {number} [end]
|
|
121
|
-
* @param {string} [type]
|
|
122
|
-
*/
|
|
123
|
-
slice(start = 0, end = this.size, type = "") {
|
|
124
|
-
const { size } = this;
|
|
125
|
-
let relativeStart = start < 0 ? Math.max(size + start, 0) : Math.min(start, size);
|
|
126
|
-
let relativeEnd = end < 0 ? Math.max(size + end, 0) : Math.min(end, size);
|
|
127
|
-
const span = Math.max(relativeEnd - relativeStart, 0);
|
|
128
|
-
const parts = this.#parts;
|
|
129
|
-
const blobParts = [];
|
|
130
|
-
let added = 0;
|
|
131
|
-
for (const part of parts) {
|
|
132
|
-
if (added >= span) break;
|
|
133
|
-
const size = ArrayBuffer.isView(part) ? part.byteLength : part.size;
|
|
134
|
-
if (relativeStart && size <= relativeStart) {
|
|
135
|
-
relativeStart -= size;
|
|
136
|
-
relativeEnd -= size;
|
|
137
|
-
} else {
|
|
138
|
-
let chunk;
|
|
139
|
-
if (ArrayBuffer.isView(part)) {
|
|
140
|
-
chunk = part.subarray(relativeStart, Math.min(size, relativeEnd));
|
|
141
|
-
added += chunk.byteLength;
|
|
142
|
-
} else {
|
|
143
|
-
chunk = part.slice(relativeStart, Math.min(size, relativeEnd));
|
|
144
|
-
added += chunk.size;
|
|
145
|
-
}
|
|
146
|
-
relativeEnd -= size;
|
|
147
|
-
blobParts.push(chunk);
|
|
148
|
-
relativeStart = 0;
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
const blob = new Blob([], { type: String(type).toLowerCase() });
|
|
152
|
-
blob.#size = span;
|
|
153
|
-
blob.#parts = blobParts;
|
|
154
|
-
return blob;
|
|
155
|
-
}
|
|
156
|
-
get [Symbol.toStringTag]() {
|
|
157
|
-
return "Blob";
|
|
158
|
-
}
|
|
159
|
-
static [Symbol.hasInstance](object) {
|
|
160
|
-
return object && typeof object === "object" && typeof object.constructor === "function" && (typeof object.stream === "function" || typeof object.arrayBuffer === "function") && /^(Blob|File)$/.test(object[Symbol.toStringTag]);
|
|
161
|
-
}
|
|
162
|
-
};
|
|
163
|
-
Object.defineProperties(_Blob.prototype, {
|
|
164
|
-
size: { enumerable: true },
|
|
165
|
-
type: { enumerable: true },
|
|
166
|
-
slice: { enumerable: true }
|
|
167
|
-
});
|
|
168
|
-
/** @type {typeof globalThis.Blob} */
|
|
169
|
-
const Blob = _Blob;
|
|
170
|
-
//#endregion
|
|
171
|
-
exports.default = Blob;
|
|
@@ -1,172 +0,0 @@
|
|
|
1
|
-
import { require_streams } from "./streams.mjs";
|
|
2
|
-
require_streams();
|
|
3
|
-
const POOL_SIZE = 65536;
|
|
4
|
-
/** @param {(Blob | Uint8Array)[]} parts */
|
|
5
|
-
async function* toIterator(parts, clone = true) {
|
|
6
|
-
for (const part of parts) if ("stream" in part) yield* part.stream();
|
|
7
|
-
else if (ArrayBuffer.isView(part)) if (clone) {
|
|
8
|
-
let position = part.byteOffset;
|
|
9
|
-
const end = part.byteOffset + part.byteLength;
|
|
10
|
-
while (position !== end) {
|
|
11
|
-
const size = Math.min(end - position, POOL_SIZE);
|
|
12
|
-
const chunk = part.buffer.slice(position, position + size);
|
|
13
|
-
position += chunk.byteLength;
|
|
14
|
-
yield new Uint8Array(chunk);
|
|
15
|
-
}
|
|
16
|
-
} else yield part;
|
|
17
|
-
else {
|
|
18
|
-
let position = 0, b = part;
|
|
19
|
-
while (position !== b.size) {
|
|
20
|
-
const buffer = await b.slice(position, Math.min(b.size, position + POOL_SIZE)).arrayBuffer();
|
|
21
|
-
position += buffer.byteLength;
|
|
22
|
-
yield new Uint8Array(buffer);
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
const _Blob = class Blob {
|
|
27
|
-
/** @type {Array.<(Blob|Uint8Array)>} */
|
|
28
|
-
#parts = [];
|
|
29
|
-
#type = "";
|
|
30
|
-
#size = 0;
|
|
31
|
-
#endings = "transparent";
|
|
32
|
-
/**
|
|
33
|
-
* The Blob() constructor returns a new Blob object. The content
|
|
34
|
-
* of the blob consists of the concatenation of the values given
|
|
35
|
-
* in the parameter array.
|
|
36
|
-
*
|
|
37
|
-
* @param {*} blobParts
|
|
38
|
-
* @param {{ type?: string, endings?: string }} [options]
|
|
39
|
-
*/
|
|
40
|
-
constructor(blobParts = [], options = {}) {
|
|
41
|
-
if (typeof blobParts !== "object" || blobParts === null) throw new TypeError("Failed to construct 'Blob': The provided value cannot be converted to a sequence.");
|
|
42
|
-
if (typeof blobParts[Symbol.iterator] !== "function") throw new TypeError("Failed to construct 'Blob': The object must have a callable @@iterator property.");
|
|
43
|
-
if (typeof options !== "object" && typeof options !== "function") throw new TypeError("Failed to construct 'Blob': parameter 2 cannot convert to dictionary.");
|
|
44
|
-
if (options === null) options = {};
|
|
45
|
-
const encoder = new TextEncoder();
|
|
46
|
-
for (const element of blobParts) {
|
|
47
|
-
let part;
|
|
48
|
-
if (ArrayBuffer.isView(element)) part = new Uint8Array(element.buffer.slice(element.byteOffset, element.byteOffset + element.byteLength));
|
|
49
|
-
else if (element instanceof ArrayBuffer) part = new Uint8Array(element.slice(0));
|
|
50
|
-
else if (element instanceof Blob) part = element;
|
|
51
|
-
else part = encoder.encode(`${element}`);
|
|
52
|
-
this.#size += ArrayBuffer.isView(part) ? part.byteLength : part.size;
|
|
53
|
-
this.#parts.push(part);
|
|
54
|
-
}
|
|
55
|
-
this.#endings = `${options.endings === void 0 ? "transparent" : options.endings}`;
|
|
56
|
-
const type = options.type === void 0 ? "" : String(options.type);
|
|
57
|
-
this.#type = /^[\x20-\x7E]*$/.test(type) ? type : "";
|
|
58
|
-
}
|
|
59
|
-
/**
|
|
60
|
-
* The Blob interface's size property returns the
|
|
61
|
-
* size of the Blob in bytes.
|
|
62
|
-
*/
|
|
63
|
-
get size() {
|
|
64
|
-
return this.#size;
|
|
65
|
-
}
|
|
66
|
-
/**
|
|
67
|
-
* The type property of a Blob object returns the MIME type of the file.
|
|
68
|
-
*/
|
|
69
|
-
get type() {
|
|
70
|
-
return this.#type;
|
|
71
|
-
}
|
|
72
|
-
/**
|
|
73
|
-
* The text() method in the Blob interface returns a Promise
|
|
74
|
-
* that resolves with a string containing the contents of
|
|
75
|
-
* the blob, interpreted as UTF-8.
|
|
76
|
-
*
|
|
77
|
-
* @return {Promise<string>}
|
|
78
|
-
*/
|
|
79
|
-
async text() {
|
|
80
|
-
const decoder = new TextDecoder();
|
|
81
|
-
let str = "";
|
|
82
|
-
for await (const part of toIterator(this.#parts, false)) str += decoder.decode(part, { stream: true });
|
|
83
|
-
str += decoder.decode();
|
|
84
|
-
return str;
|
|
85
|
-
}
|
|
86
|
-
/**
|
|
87
|
-
* The arrayBuffer() method in the Blob interface returns a
|
|
88
|
-
* Promise that resolves with the contents of the blob as
|
|
89
|
-
* binary data contained in an ArrayBuffer.
|
|
90
|
-
*
|
|
91
|
-
* @return {Promise<ArrayBuffer>}
|
|
92
|
-
*/
|
|
93
|
-
async arrayBuffer() {
|
|
94
|
-
const data = new Uint8Array(this.size);
|
|
95
|
-
let offset = 0;
|
|
96
|
-
for await (const chunk of toIterator(this.#parts, false)) {
|
|
97
|
-
data.set(chunk, offset);
|
|
98
|
-
offset += chunk.length;
|
|
99
|
-
}
|
|
100
|
-
return data.buffer;
|
|
101
|
-
}
|
|
102
|
-
stream() {
|
|
103
|
-
const it = toIterator(this.#parts, true);
|
|
104
|
-
return new globalThis.ReadableStream({
|
|
105
|
-
type: "bytes",
|
|
106
|
-
async pull(ctrl) {
|
|
107
|
-
const chunk = await it.next();
|
|
108
|
-
chunk.done ? ctrl.close() : ctrl.enqueue(chunk.value);
|
|
109
|
-
},
|
|
110
|
-
async cancel() {
|
|
111
|
-
await it.return();
|
|
112
|
-
}
|
|
113
|
-
});
|
|
114
|
-
}
|
|
115
|
-
/**
|
|
116
|
-
* The Blob interface's slice() method creates and returns a
|
|
117
|
-
* new Blob object which contains data from a subset of the
|
|
118
|
-
* blob on which it's called.
|
|
119
|
-
*
|
|
120
|
-
* @param {number} [start]
|
|
121
|
-
* @param {number} [end]
|
|
122
|
-
* @param {string} [type]
|
|
123
|
-
*/
|
|
124
|
-
slice(start = 0, end = this.size, type = "") {
|
|
125
|
-
const { size } = this;
|
|
126
|
-
let relativeStart = start < 0 ? Math.max(size + start, 0) : Math.min(start, size);
|
|
127
|
-
let relativeEnd = end < 0 ? Math.max(size + end, 0) : Math.min(end, size);
|
|
128
|
-
const span = Math.max(relativeEnd - relativeStart, 0);
|
|
129
|
-
const parts = this.#parts;
|
|
130
|
-
const blobParts = [];
|
|
131
|
-
let added = 0;
|
|
132
|
-
for (const part of parts) {
|
|
133
|
-
if (added >= span) break;
|
|
134
|
-
const size = ArrayBuffer.isView(part) ? part.byteLength : part.size;
|
|
135
|
-
if (relativeStart && size <= relativeStart) {
|
|
136
|
-
relativeStart -= size;
|
|
137
|
-
relativeEnd -= size;
|
|
138
|
-
} else {
|
|
139
|
-
let chunk;
|
|
140
|
-
if (ArrayBuffer.isView(part)) {
|
|
141
|
-
chunk = part.subarray(relativeStart, Math.min(size, relativeEnd));
|
|
142
|
-
added += chunk.byteLength;
|
|
143
|
-
} else {
|
|
144
|
-
chunk = part.slice(relativeStart, Math.min(size, relativeEnd));
|
|
145
|
-
added += chunk.size;
|
|
146
|
-
}
|
|
147
|
-
relativeEnd -= size;
|
|
148
|
-
blobParts.push(chunk);
|
|
149
|
-
relativeStart = 0;
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
const blob = new Blob([], { type: String(type).toLowerCase() });
|
|
153
|
-
blob.#size = span;
|
|
154
|
-
blob.#parts = blobParts;
|
|
155
|
-
return blob;
|
|
156
|
-
}
|
|
157
|
-
get [Symbol.toStringTag]() {
|
|
158
|
-
return "Blob";
|
|
159
|
-
}
|
|
160
|
-
static [Symbol.hasInstance](object) {
|
|
161
|
-
return object && typeof object === "object" && typeof object.constructor === "function" && (typeof object.stream === "function" || typeof object.arrayBuffer === "function") && /^(Blob|File)$/.test(object[Symbol.toStringTag]);
|
|
162
|
-
}
|
|
163
|
-
};
|
|
164
|
-
Object.defineProperties(_Blob.prototype, {
|
|
165
|
-
size: { enumerable: true },
|
|
166
|
-
type: { enumerable: true },
|
|
167
|
-
slice: { enumerable: true }
|
|
168
|
-
});
|
|
169
|
-
/** @type {typeof globalThis.Blob} */
|
|
170
|
-
const Blob = _Blob;
|
|
171
|
-
//#endregion
|
|
172
|
-
export { Blob as default };
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
const require_runtime = require("../../_virtual/_rolldown/runtime.cjs");
|
|
2
|
-
const require_ponyfill_es2018$1 = require("../web-streams-polyfill/dist/ponyfill.es2018.cjs");
|
|
3
|
-
//#region node_modules/fetch-blob/streams.cjs
|
|
4
|
-
var require_streams = /* @__PURE__ */ require_runtime.__commonJSMin((() => {
|
|
5
|
-
/* c8 ignore start */
|
|
6
|
-
const POOL_SIZE = 65536;
|
|
7
|
-
if (!globalThis.ReadableStream) try {
|
|
8
|
-
const process = require("node:process");
|
|
9
|
-
const { emitWarning } = process;
|
|
10
|
-
try {
|
|
11
|
-
process.emitWarning = () => {};
|
|
12
|
-
Object.assign(globalThis, require("node:stream/web"));
|
|
13
|
-
process.emitWarning = emitWarning;
|
|
14
|
-
} catch (error) {
|
|
15
|
-
process.emitWarning = emitWarning;
|
|
16
|
-
throw error;
|
|
17
|
-
}
|
|
18
|
-
} catch (error) {
|
|
19
|
-
Object.assign(globalThis, require_ponyfill_es2018$1.default);
|
|
20
|
-
}
|
|
21
|
-
try {
|
|
22
|
-
const { Blob } = require("buffer");
|
|
23
|
-
if (Blob && !Blob.prototype.stream) Blob.prototype.stream = function name(params) {
|
|
24
|
-
let position = 0;
|
|
25
|
-
const blob = this;
|
|
26
|
-
return new ReadableStream({
|
|
27
|
-
type: "bytes",
|
|
28
|
-
async pull(ctrl) {
|
|
29
|
-
const buffer = await blob.slice(position, Math.min(blob.size, position + POOL_SIZE)).arrayBuffer();
|
|
30
|
-
position += buffer.byteLength;
|
|
31
|
-
ctrl.enqueue(new Uint8Array(buffer));
|
|
32
|
-
if (position === blob.size) ctrl.close();
|
|
33
|
-
}
|
|
34
|
-
});
|
|
35
|
-
};
|
|
36
|
-
} catch (error) {}
|
|
37
|
-
}));
|
|
38
|
-
/* c8 ignore end */
|
|
39
|
-
//#endregion
|
|
40
|
-
Object.defineProperty(exports, "default", {
|
|
41
|
-
enumerable: true,
|
|
42
|
-
get: function() {
|
|
43
|
-
return require_streams();
|
|
44
|
-
}
|
|
45
|
-
});
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import { __commonJSMin, __require } from "../../_virtual/_rolldown/runtime.mjs";
|
|
2
|
-
import { require_ponyfill_es2018 } from "../web-streams-polyfill/dist/ponyfill.es2018.mjs";
|
|
3
|
-
//#region node_modules/fetch-blob/streams.cjs
|
|
4
|
-
var require_streams = /* @__PURE__ */ __commonJSMin((() => {
|
|
5
|
-
/* c8 ignore start */
|
|
6
|
-
const POOL_SIZE = 65536;
|
|
7
|
-
if (!globalThis.ReadableStream) try {
|
|
8
|
-
const process = __require("node:process");
|
|
9
|
-
const { emitWarning } = process;
|
|
10
|
-
try {
|
|
11
|
-
process.emitWarning = () => {};
|
|
12
|
-
Object.assign(globalThis, __require("node:stream/web"));
|
|
13
|
-
process.emitWarning = emitWarning;
|
|
14
|
-
} catch (error) {
|
|
15
|
-
process.emitWarning = emitWarning;
|
|
16
|
-
throw error;
|
|
17
|
-
}
|
|
18
|
-
} catch (error) {
|
|
19
|
-
Object.assign(globalThis, require_ponyfill_es2018());
|
|
20
|
-
}
|
|
21
|
-
try {
|
|
22
|
-
const { Blob } = __require("buffer");
|
|
23
|
-
if (Blob && !Blob.prototype.stream) Blob.prototype.stream = function name(params) {
|
|
24
|
-
let position = 0;
|
|
25
|
-
const blob = this;
|
|
26
|
-
return new ReadableStream({
|
|
27
|
-
type: "bytes",
|
|
28
|
-
async pull(ctrl) {
|
|
29
|
-
const buffer = await blob.slice(position, Math.min(blob.size, position + POOL_SIZE)).arrayBuffer();
|
|
30
|
-
position += buffer.byteLength;
|
|
31
|
-
ctrl.enqueue(new Uint8Array(buffer));
|
|
32
|
-
if (position === blob.size) ctrl.close();
|
|
33
|
-
}
|
|
34
|
-
});
|
|
35
|
-
};
|
|
36
|
-
} catch (error) {}
|
|
37
|
-
}));
|
|
38
|
-
/* c8 ignore end */
|
|
39
|
-
//#endregion
|
|
40
|
-
export default require_streams();
|
|
41
|
-
export { require_streams };
|
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
const require_index = require("../fetch-blob/index.cjs");
|
|
2
|
-
const require_file = require("../fetch-blob/file.cjs");
|
|
3
|
-
//#region node_modules/formdata-polyfill/esm.min.js
|
|
4
|
-
/*! formdata-polyfill. MIT License. Jimmy Wärting <https://jimmy.warting.se/opensource> */
|
|
5
|
-
var { toStringTag: t, iterator: i, hasInstance: h } = Symbol, r = Math.random, m = "append,set,get,getAll,delete,keys,values,entries,forEach,constructor".split(","), f = (a, b, c) => (a += "", /^(Blob|File)$/.test(b && b[t]) ? [(c = c !== void 0 ? c + "" : b[t] == "File" ? b.name : "blob", a), b.name !== c || b[t] == "blob" ? new require_file.default([b], c, b) : b] : [a, b + ""]), e = (c, f) => (f ? c : c.replace(/\r?\n|\r/g, "\r\n")).replace(/\n/g, "%0A").replace(/\r/g, "%0D").replace(/"/g, "%22"), x = (n, a, e) => {
|
|
6
|
-
if (a.length < e) throw new TypeError(`Failed to execute '${n}' on 'FormData': ${e} arguments required, but only ${a.length} present.`);
|
|
7
|
-
};
|
|
8
|
-
/** @type {typeof globalThis.FormData} */
|
|
9
|
-
const FormData = class FormData {
|
|
10
|
-
#d = [];
|
|
11
|
-
constructor(...a) {
|
|
12
|
-
if (a.length) throw new TypeError(`Failed to construct 'FormData': parameter 1 is not of type 'HTMLFormElement'.`);
|
|
13
|
-
}
|
|
14
|
-
get [t]() {
|
|
15
|
-
return "FormData";
|
|
16
|
-
}
|
|
17
|
-
[i]() {
|
|
18
|
-
return this.entries();
|
|
19
|
-
}
|
|
20
|
-
static [h](o) {
|
|
21
|
-
return o && typeof o === "object" && o[t] === "FormData" && !m.some((m) => typeof o[m] != "function");
|
|
22
|
-
}
|
|
23
|
-
append(...a) {
|
|
24
|
-
x("append", arguments, 2);
|
|
25
|
-
this.#d.push(f(...a));
|
|
26
|
-
}
|
|
27
|
-
delete(a) {
|
|
28
|
-
x("delete", arguments, 1);
|
|
29
|
-
a += "";
|
|
30
|
-
this.#d = this.#d.filter(([b]) => b !== a);
|
|
31
|
-
}
|
|
32
|
-
get(a) {
|
|
33
|
-
x("get", arguments, 1);
|
|
34
|
-
a += "";
|
|
35
|
-
for (var b = this.#d, l = b.length, c = 0; c < l; c++) if (b[c][0] === a) return b[c][1];
|
|
36
|
-
return null;
|
|
37
|
-
}
|
|
38
|
-
getAll(a, b) {
|
|
39
|
-
x("getAll", arguments, 1);
|
|
40
|
-
b = [];
|
|
41
|
-
a += "";
|
|
42
|
-
this.#d.forEach((c) => c[0] === a && b.push(c[1]));
|
|
43
|
-
return b;
|
|
44
|
-
}
|
|
45
|
-
has(a) {
|
|
46
|
-
x("has", arguments, 1);
|
|
47
|
-
a += "";
|
|
48
|
-
return this.#d.some((b) => b[0] === a);
|
|
49
|
-
}
|
|
50
|
-
forEach(a, b) {
|
|
51
|
-
x("forEach", arguments, 1);
|
|
52
|
-
for (var [c, d] of this) a.call(b, d, c, this);
|
|
53
|
-
}
|
|
54
|
-
set(...a) {
|
|
55
|
-
x("set", arguments, 2);
|
|
56
|
-
var b = [], c = !0;
|
|
57
|
-
a = f(...a);
|
|
58
|
-
this.#d.forEach((d) => {
|
|
59
|
-
d[0] === a[0] ? c && (c = !b.push(a)) : b.push(d);
|
|
60
|
-
});
|
|
61
|
-
c && b.push(a);
|
|
62
|
-
this.#d = b;
|
|
63
|
-
}
|
|
64
|
-
*entries() {
|
|
65
|
-
yield* this.#d;
|
|
66
|
-
}
|
|
67
|
-
*keys() {
|
|
68
|
-
for (var [a] of this) yield a;
|
|
69
|
-
}
|
|
70
|
-
*values() {
|
|
71
|
-
for (var [, a] of this) yield a;
|
|
72
|
-
}
|
|
73
|
-
};
|
|
74
|
-
/** @param {FormData} F */
|
|
75
|
-
function formDataToBlob(F, B = require_index.default) {
|
|
76
|
-
var b = `${r()}${r()}`.replace(/\./g, "").slice(-28).padStart(32, "-"), c = [], p = `--${b}\r\nContent-Disposition: form-data; name="`;
|
|
77
|
-
F.forEach((v, n) => typeof v == "string" ? c.push(p + e(n) + `"\r\n\r\n${v.replace(/\r(?!\n)|(?<!\r)\n/g, "\r\n")}\r\n`) : c.push(p + e(n) + `"; filename="${e(v.name, 1)}"\r\nContent-Type: ${v.type || "application/octet-stream"}\r\n\r\n`, v, "\r\n"));
|
|
78
|
-
c.push(`--${b}--`);
|
|
79
|
-
return new B(c, { type: "multipart/form-data; boundary=" + b });
|
|
80
|
-
}
|
|
81
|
-
//#endregion
|
|
82
|
-
exports.FormData = FormData;
|
|
83
|
-
exports.formDataToBlob = formDataToBlob;
|