@feedmepos/mf-common 1.6.4 → 1.6.6-rc.1
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/multipart-parser-513ff2e8.js +207 -0
- package/dist/tsconfig.app.tsbuildinfo +1 -1
- package/dist/vite-preset-1fc4fac1.js +3963 -0
- package/dist/vite-preset.d.ts +1 -1
- package/dist/vite-preset.d.ts.map +1 -1
- package/dist/vite-preset.js +14 -141
- package/package.json +2 -1
@@ -0,0 +1,207 @@
|
|
1
|
+
import "node:fs";
|
2
|
+
import "node:path";
|
3
|
+
import { F as k, a as U } from "./vite-preset-1fc4fac1.js";
|
4
|
+
import "path";
|
5
|
+
import "fs";
|
6
|
+
import "node:http";
|
7
|
+
import "node:https";
|
8
|
+
import "node:zlib";
|
9
|
+
import "node:stream";
|
10
|
+
import "node:buffer";
|
11
|
+
import "node:util";
|
12
|
+
import "node:url";
|
13
|
+
import "node:net";
|
14
|
+
let f = 0;
|
15
|
+
const t = {
|
16
|
+
START_BOUNDARY: f++,
|
17
|
+
HEADER_FIELD_START: f++,
|
18
|
+
HEADER_FIELD: f++,
|
19
|
+
HEADER_VALUE_START: f++,
|
20
|
+
HEADER_VALUE: f++,
|
21
|
+
HEADER_VALUE_ALMOST_DONE: f++,
|
22
|
+
HEADERS_ALMOST_DONE: f++,
|
23
|
+
PART_DATA_START: f++,
|
24
|
+
PART_DATA: f++,
|
25
|
+
END: f++
|
26
|
+
};
|
27
|
+
let F = 1;
|
28
|
+
const _ = {
|
29
|
+
PART_BOUNDARY: F,
|
30
|
+
LAST_BOUNDARY: F *= 2
|
31
|
+
}, O = 10, g = 13, w = 32, P = 45, B = 58, V = 97, Y = 122, x = (u) => u | 32, R = () => {
|
32
|
+
};
|
33
|
+
class C {
|
34
|
+
/**
|
35
|
+
* @param {string} boundary
|
36
|
+
*/
|
37
|
+
constructor(o) {
|
38
|
+
this.index = 0, this.flags = 0, this.onHeaderEnd = R, this.onHeaderField = R, this.onHeadersEnd = R, this.onHeaderValue = R, this.onPartBegin = R, this.onPartData = R, this.onPartEnd = R, this.boundaryChars = {}, o = `\r
|
39
|
+
--` + o;
|
40
|
+
const n = new Uint8Array(o.length);
|
41
|
+
for (let r = 0; r < o.length; r++)
|
42
|
+
n[r] = o.charCodeAt(r), this.boundaryChars[n[r]] = !0;
|
43
|
+
this.boundary = n, this.lookbehind = new Uint8Array(this.boundary.length + 8), this.state = t.START_BOUNDARY;
|
44
|
+
}
|
45
|
+
/**
|
46
|
+
* @param {Uint8Array} data
|
47
|
+
*/
|
48
|
+
write(o) {
|
49
|
+
let n = 0;
|
50
|
+
const r = o.length;
|
51
|
+
let E = this.index, { lookbehind: l, boundary: d, boundaryChars: p, index: e, state: i, flags: A } = this;
|
52
|
+
const m = this.boundary.length, S = m - 1, N = o.length;
|
53
|
+
let a, b;
|
54
|
+
const h = (c) => {
|
55
|
+
this[c + "Mark"] = n;
|
56
|
+
}, s = (c) => {
|
57
|
+
delete this[c + "Mark"];
|
58
|
+
}, D = (c, L, T, y) => {
|
59
|
+
(L === void 0 || L !== T) && this[c](y && y.subarray(L, T));
|
60
|
+
}, H = (c, L) => {
|
61
|
+
const T = c + "Mark";
|
62
|
+
T in this && (L ? (D(c, this[T], n, o), delete this[T]) : (D(c, this[T], o.length, o), this[T] = 0));
|
63
|
+
};
|
64
|
+
for (n = 0; n < r; n++)
|
65
|
+
switch (a = o[n], i) {
|
66
|
+
case t.START_BOUNDARY:
|
67
|
+
if (e === d.length - 2) {
|
68
|
+
if (a === P)
|
69
|
+
A |= _.LAST_BOUNDARY;
|
70
|
+
else if (a !== g)
|
71
|
+
return;
|
72
|
+
e++;
|
73
|
+
break;
|
74
|
+
} else if (e - 1 === d.length - 2) {
|
75
|
+
if (A & _.LAST_BOUNDARY && a === P)
|
76
|
+
i = t.END, A = 0;
|
77
|
+
else if (!(A & _.LAST_BOUNDARY) && a === O)
|
78
|
+
e = 0, D("onPartBegin"), i = t.HEADER_FIELD_START;
|
79
|
+
else
|
80
|
+
return;
|
81
|
+
break;
|
82
|
+
}
|
83
|
+
a !== d[e + 2] && (e = -2), a === d[e + 2] && e++;
|
84
|
+
break;
|
85
|
+
case t.HEADER_FIELD_START:
|
86
|
+
i = t.HEADER_FIELD, h("onHeaderField"), e = 0;
|
87
|
+
case t.HEADER_FIELD:
|
88
|
+
if (a === g) {
|
89
|
+
s("onHeaderField"), i = t.HEADERS_ALMOST_DONE;
|
90
|
+
break;
|
91
|
+
}
|
92
|
+
if (e++, a === P)
|
93
|
+
break;
|
94
|
+
if (a === B) {
|
95
|
+
if (e === 1)
|
96
|
+
return;
|
97
|
+
H("onHeaderField", !0), i = t.HEADER_VALUE_START;
|
98
|
+
break;
|
99
|
+
}
|
100
|
+
if (b = x(a), b < V || b > Y)
|
101
|
+
return;
|
102
|
+
break;
|
103
|
+
case t.HEADER_VALUE_START:
|
104
|
+
if (a === w)
|
105
|
+
break;
|
106
|
+
h("onHeaderValue"), i = t.HEADER_VALUE;
|
107
|
+
case t.HEADER_VALUE:
|
108
|
+
a === g && (H("onHeaderValue", !0), D("onHeaderEnd"), i = t.HEADER_VALUE_ALMOST_DONE);
|
109
|
+
break;
|
110
|
+
case t.HEADER_VALUE_ALMOST_DONE:
|
111
|
+
if (a !== O)
|
112
|
+
return;
|
113
|
+
i = t.HEADER_FIELD_START;
|
114
|
+
break;
|
115
|
+
case t.HEADERS_ALMOST_DONE:
|
116
|
+
if (a !== O)
|
117
|
+
return;
|
118
|
+
D("onHeadersEnd"), i = t.PART_DATA_START;
|
119
|
+
break;
|
120
|
+
case t.PART_DATA_START:
|
121
|
+
i = t.PART_DATA, h("onPartData");
|
122
|
+
case t.PART_DATA:
|
123
|
+
if (E = e, e === 0) {
|
124
|
+
for (n += S; n < N && !(o[n] in p); )
|
125
|
+
n += m;
|
126
|
+
n -= S, a = o[n];
|
127
|
+
}
|
128
|
+
if (e < d.length)
|
129
|
+
d[e] === a ? (e === 0 && H("onPartData", !0), e++) : e = 0;
|
130
|
+
else if (e === d.length)
|
131
|
+
e++, a === g ? A |= _.PART_BOUNDARY : a === P ? A |= _.LAST_BOUNDARY : e = 0;
|
132
|
+
else if (e - 1 === d.length)
|
133
|
+
if (A & _.PART_BOUNDARY) {
|
134
|
+
if (e = 0, a === O) {
|
135
|
+
A &= ~_.PART_BOUNDARY, D("onPartEnd"), D("onPartBegin"), i = t.HEADER_FIELD_START;
|
136
|
+
break;
|
137
|
+
}
|
138
|
+
} else
|
139
|
+
A & _.LAST_BOUNDARY && a === P ? (D("onPartEnd"), i = t.END, A = 0) : e = 0;
|
140
|
+
if (e > 0)
|
141
|
+
l[e - 1] = a;
|
142
|
+
else if (E > 0) {
|
143
|
+
const c = new Uint8Array(l.buffer, l.byteOffset, l.byteLength);
|
144
|
+
D("onPartData", 0, E, c), E = 0, h("onPartData"), n--;
|
145
|
+
}
|
146
|
+
break;
|
147
|
+
case t.END:
|
148
|
+
break;
|
149
|
+
default:
|
150
|
+
throw new Error(`Unexpected state entered: ${i}`);
|
151
|
+
}
|
152
|
+
H("onHeaderField"), H("onHeaderValue"), H("onPartData"), this.index = e, this.state = i, this.flags = A;
|
153
|
+
}
|
154
|
+
end() {
|
155
|
+
if (this.state === t.HEADER_FIELD_START && this.index === 0 || this.state === t.PART_DATA && this.index === this.boundary.length)
|
156
|
+
this.onPartEnd();
|
157
|
+
else if (this.state !== t.END)
|
158
|
+
throw new Error("MultipartParser.end(): stream ended unexpectedly");
|
159
|
+
}
|
160
|
+
}
|
161
|
+
function I(u) {
|
162
|
+
const o = u.match(/\bfilename=("(.*?)"|([^()<>@,;:\\"/[\]?={}\s\t]+))($|;\s)/i);
|
163
|
+
if (!o)
|
164
|
+
return;
|
165
|
+
const n = o[2] || o[3] || "";
|
166
|
+
let r = n.slice(n.lastIndexOf("\\") + 1);
|
167
|
+
return r = r.replace(/%22/g, '"'), r = r.replace(/&#(\d{4});/g, (E, l) => String.fromCharCode(l)), r;
|
168
|
+
}
|
169
|
+
async function ee(u, o) {
|
170
|
+
if (!/multipart/i.test(o))
|
171
|
+
throw new TypeError("Failed to fetch");
|
172
|
+
const n = o.match(/boundary=(?:"([^"]+)"|([^;]+))/i);
|
173
|
+
if (!n)
|
174
|
+
throw new TypeError("no or bad content-type header, no multipart boundary");
|
175
|
+
const r = new C(n[1] || n[2]);
|
176
|
+
let E, l, d, p, e, i;
|
177
|
+
const A = [], m = new k(), S = (s) => {
|
178
|
+
d += h.decode(s, { stream: !0 });
|
179
|
+
}, N = (s) => {
|
180
|
+
A.push(s);
|
181
|
+
}, a = () => {
|
182
|
+
const s = new U(A, i, { type: e });
|
183
|
+
m.append(p, s);
|
184
|
+
}, b = () => {
|
185
|
+
m.append(p, d);
|
186
|
+
}, h = new TextDecoder("utf-8");
|
187
|
+
h.decode(), r.onPartBegin = function() {
|
188
|
+
r.onPartData = S, r.onPartEnd = b, E = "", l = "", d = "", p = "", e = "", i = null, A.length = 0;
|
189
|
+
}, r.onHeaderField = function(s) {
|
190
|
+
E += h.decode(s, { stream: !0 });
|
191
|
+
}, r.onHeaderValue = function(s) {
|
192
|
+
l += h.decode(s, { stream: !0 });
|
193
|
+
}, r.onHeaderEnd = function() {
|
194
|
+
if (l += h.decode(), E = E.toLowerCase(), E === "content-disposition") {
|
195
|
+
const s = l.match(/\bname=("([^"]*)"|([^()<>@,;:\\"/[\]?={}\s\t]+))/i);
|
196
|
+
s && (p = s[2] || s[3] || ""), i = I(l), i && (r.onPartData = N, r.onPartEnd = a);
|
197
|
+
} else
|
198
|
+
E === "content-type" && (e = l);
|
199
|
+
l = "", E = "";
|
200
|
+
};
|
201
|
+
for await (const s of u)
|
202
|
+
r.write(s);
|
203
|
+
return r.end(), m;
|
204
|
+
}
|
205
|
+
export {
|
206
|
+
ee as toFormData
|
207
|
+
};
|