unplugin-dingtalk 0.1.9 → 0.3.0

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/index.d.cts CHANGED
@@ -1,9 +1,16 @@
1
1
  import * as _unplugin from 'unplugin';
2
2
  import { UnpluginFactory } from 'unplugin';
3
+ import { ChildProcess } from 'node:child_process';
3
4
  import { Options } from './types.cjs';
5
+ import 'webpack-dev-server';
4
6
  import 'vite-plugin-vconsole';
5
7
 
8
+ declare const resovedInfo: {
9
+ devtoolsInstance: ChildProcess | undefined;
10
+ availablePort: number | undefined;
11
+ targetURL: URL | undefined;
12
+ };
6
13
  declare const unpluginFactory: UnpluginFactory<Options | undefined, boolean>;
7
14
  declare const unplugin: _unplugin.UnpluginInstance<Options | undefined, boolean>;
8
15
 
9
- export { unplugin as default, unplugin, unpluginFactory };
16
+ export { unplugin as default, resovedInfo, unplugin, unpluginFactory };
package/dist/index.d.ts CHANGED
@@ -1,9 +1,16 @@
1
1
  import * as _unplugin from 'unplugin';
2
2
  import { UnpluginFactory } from 'unplugin';
3
+ import { ChildProcess } from 'node:child_process';
3
4
  import { Options } from './types.js';
5
+ import 'webpack-dev-server';
4
6
  import 'vite-plugin-vconsole';
5
7
 
8
+ declare const resovedInfo: {
9
+ devtoolsInstance: ChildProcess | undefined;
10
+ availablePort: number | undefined;
11
+ targetURL: URL | undefined;
12
+ };
6
13
  declare const unpluginFactory: UnpluginFactory<Options | undefined, boolean>;
7
14
  declare const unplugin: _unplugin.UnpluginInstance<Options | undefined, boolean>;
8
15
 
9
- export { unplugin as default, unplugin, unpluginFactory };
16
+ export { unplugin as default, resovedInfo, unplugin, unpluginFactory };
package/dist/index.js CHANGED
@@ -1,10 +1,13 @@
1
1
  import {
2
+ resovedInfo,
2
3
  src_default,
3
4
  unplugin,
4
5
  unpluginFactory
5
- } from "./chunk-PSBADVC6.js";
6
+ } from "./chunk-XTDXIGYG.js";
7
+ import "./chunk-PMOTCIQR.js";
6
8
  export {
7
9
  src_default as default,
10
+ resovedInfo,
8
11
  unplugin,
9
12
  unpluginFactory
10
13
  };
@@ -0,0 +1,368 @@
1
+ import {
2
+ FormData,
3
+ __forAwait,
4
+ file_default
5
+ } from "./chunk-PMOTCIQR.js";
6
+
7
+ // node_modules/.pnpm/node-fetch@3.3.2/node_modules/node-fetch/src/utils/multipart-parser.js
8
+ var s = 0;
9
+ var S = {
10
+ START_BOUNDARY: s++,
11
+ HEADER_FIELD_START: s++,
12
+ HEADER_FIELD: s++,
13
+ HEADER_VALUE_START: s++,
14
+ HEADER_VALUE: s++,
15
+ HEADER_VALUE_ALMOST_DONE: s++,
16
+ HEADERS_ALMOST_DONE: s++,
17
+ PART_DATA_START: s++,
18
+ PART_DATA: s++,
19
+ END: s++
20
+ };
21
+ var f = 1;
22
+ var F = {
23
+ PART_BOUNDARY: f,
24
+ LAST_BOUNDARY: f *= 2
25
+ };
26
+ var LF = 10;
27
+ var CR = 13;
28
+ var SPACE = 32;
29
+ var HYPHEN = 45;
30
+ var COLON = 58;
31
+ var A = 97;
32
+ var Z = 122;
33
+ var lower = (c) => c | 32;
34
+ var noop = () => {
35
+ };
36
+ var MultipartParser = class {
37
+ /**
38
+ * @param {string} boundary
39
+ */
40
+ constructor(boundary) {
41
+ this.index = 0;
42
+ this.flags = 0;
43
+ this.onHeaderEnd = noop;
44
+ this.onHeaderField = noop;
45
+ this.onHeadersEnd = noop;
46
+ this.onHeaderValue = noop;
47
+ this.onPartBegin = noop;
48
+ this.onPartData = noop;
49
+ this.onPartEnd = noop;
50
+ this.boundaryChars = {};
51
+ boundary = "\r\n--" + boundary;
52
+ const ui8a = new Uint8Array(boundary.length);
53
+ for (let i = 0; i < boundary.length; i++) {
54
+ ui8a[i] = boundary.charCodeAt(i);
55
+ this.boundaryChars[ui8a[i]] = true;
56
+ }
57
+ this.boundary = ui8a;
58
+ this.lookbehind = new Uint8Array(this.boundary.length + 8);
59
+ this.state = S.START_BOUNDARY;
60
+ }
61
+ /**
62
+ * @param {Uint8Array} data
63
+ */
64
+ write(data) {
65
+ let i = 0;
66
+ const length_ = data.length;
67
+ let previousIndex = this.index;
68
+ let { lookbehind, boundary, boundaryChars, index, state, flags } = this;
69
+ const boundaryLength = this.boundary.length;
70
+ const boundaryEnd = boundaryLength - 1;
71
+ const bufferLength = data.length;
72
+ let c;
73
+ let cl;
74
+ const mark = (name) => {
75
+ this[name + "Mark"] = i;
76
+ };
77
+ const clear = (name) => {
78
+ delete this[name + "Mark"];
79
+ };
80
+ const callback = (callbackSymbol, start, end, ui8a) => {
81
+ if (start === void 0 || start !== end) {
82
+ this[callbackSymbol](ui8a && ui8a.subarray(start, end));
83
+ }
84
+ };
85
+ const dataCallback = (name, clear2) => {
86
+ const markSymbol = name + "Mark";
87
+ if (!(markSymbol in this)) {
88
+ return;
89
+ }
90
+ if (clear2) {
91
+ callback(name, this[markSymbol], i, data);
92
+ delete this[markSymbol];
93
+ } else {
94
+ callback(name, this[markSymbol], data.length, data);
95
+ this[markSymbol] = 0;
96
+ }
97
+ };
98
+ for (i = 0; i < length_; i++) {
99
+ c = data[i];
100
+ switch (state) {
101
+ case S.START_BOUNDARY:
102
+ if (index === boundary.length - 2) {
103
+ if (c === HYPHEN) {
104
+ flags |= F.LAST_BOUNDARY;
105
+ } else if (c !== CR) {
106
+ return;
107
+ }
108
+ index++;
109
+ break;
110
+ } else if (index - 1 === boundary.length - 2) {
111
+ if (flags & F.LAST_BOUNDARY && c === HYPHEN) {
112
+ state = S.END;
113
+ flags = 0;
114
+ } else if (!(flags & F.LAST_BOUNDARY) && c === LF) {
115
+ index = 0;
116
+ callback("onPartBegin");
117
+ state = S.HEADER_FIELD_START;
118
+ } else {
119
+ return;
120
+ }
121
+ break;
122
+ }
123
+ if (c !== boundary[index + 2]) {
124
+ index = -2;
125
+ }
126
+ if (c === boundary[index + 2]) {
127
+ index++;
128
+ }
129
+ break;
130
+ case S.HEADER_FIELD_START:
131
+ state = S.HEADER_FIELD;
132
+ mark("onHeaderField");
133
+ index = 0;
134
+ case S.HEADER_FIELD:
135
+ if (c === CR) {
136
+ clear("onHeaderField");
137
+ state = S.HEADERS_ALMOST_DONE;
138
+ break;
139
+ }
140
+ index++;
141
+ if (c === HYPHEN) {
142
+ break;
143
+ }
144
+ if (c === COLON) {
145
+ if (index === 1) {
146
+ return;
147
+ }
148
+ dataCallback("onHeaderField", true);
149
+ state = S.HEADER_VALUE_START;
150
+ break;
151
+ }
152
+ cl = lower(c);
153
+ if (cl < A || cl > Z) {
154
+ return;
155
+ }
156
+ break;
157
+ case S.HEADER_VALUE_START:
158
+ if (c === SPACE) {
159
+ break;
160
+ }
161
+ mark("onHeaderValue");
162
+ state = S.HEADER_VALUE;
163
+ case S.HEADER_VALUE:
164
+ if (c === CR) {
165
+ dataCallback("onHeaderValue", true);
166
+ callback("onHeaderEnd");
167
+ state = S.HEADER_VALUE_ALMOST_DONE;
168
+ }
169
+ break;
170
+ case S.HEADER_VALUE_ALMOST_DONE:
171
+ if (c !== LF) {
172
+ return;
173
+ }
174
+ state = S.HEADER_FIELD_START;
175
+ break;
176
+ case S.HEADERS_ALMOST_DONE:
177
+ if (c !== LF) {
178
+ return;
179
+ }
180
+ callback("onHeadersEnd");
181
+ state = S.PART_DATA_START;
182
+ break;
183
+ case S.PART_DATA_START:
184
+ state = S.PART_DATA;
185
+ mark("onPartData");
186
+ case S.PART_DATA:
187
+ previousIndex = index;
188
+ if (index === 0) {
189
+ i += boundaryEnd;
190
+ while (i < bufferLength && !(data[i] in boundaryChars)) {
191
+ i += boundaryLength;
192
+ }
193
+ i -= boundaryEnd;
194
+ c = data[i];
195
+ }
196
+ if (index < boundary.length) {
197
+ if (boundary[index] === c) {
198
+ if (index === 0) {
199
+ dataCallback("onPartData", true);
200
+ }
201
+ index++;
202
+ } else {
203
+ index = 0;
204
+ }
205
+ } else if (index === boundary.length) {
206
+ index++;
207
+ if (c === CR) {
208
+ flags |= F.PART_BOUNDARY;
209
+ } else if (c === HYPHEN) {
210
+ flags |= F.LAST_BOUNDARY;
211
+ } else {
212
+ index = 0;
213
+ }
214
+ } else if (index - 1 === boundary.length) {
215
+ if (flags & F.PART_BOUNDARY) {
216
+ index = 0;
217
+ if (c === LF) {
218
+ flags &= ~F.PART_BOUNDARY;
219
+ callback("onPartEnd");
220
+ callback("onPartBegin");
221
+ state = S.HEADER_FIELD_START;
222
+ break;
223
+ }
224
+ } else if (flags & F.LAST_BOUNDARY) {
225
+ if (c === HYPHEN) {
226
+ callback("onPartEnd");
227
+ state = S.END;
228
+ flags = 0;
229
+ } else {
230
+ index = 0;
231
+ }
232
+ } else {
233
+ index = 0;
234
+ }
235
+ }
236
+ if (index > 0) {
237
+ lookbehind[index - 1] = c;
238
+ } else if (previousIndex > 0) {
239
+ const _lookbehind = new Uint8Array(lookbehind.buffer, lookbehind.byteOffset, lookbehind.byteLength);
240
+ callback("onPartData", 0, previousIndex, _lookbehind);
241
+ previousIndex = 0;
242
+ mark("onPartData");
243
+ i--;
244
+ }
245
+ break;
246
+ case S.END:
247
+ break;
248
+ default:
249
+ throw new Error(`Unexpected state entered: ${state}`);
250
+ }
251
+ }
252
+ dataCallback("onHeaderField");
253
+ dataCallback("onHeaderValue");
254
+ dataCallback("onPartData");
255
+ this.index = index;
256
+ this.state = state;
257
+ this.flags = flags;
258
+ }
259
+ end() {
260
+ if (this.state === S.HEADER_FIELD_START && this.index === 0 || this.state === S.PART_DATA && this.index === this.boundary.length) {
261
+ this.onPartEnd();
262
+ } else if (this.state !== S.END) {
263
+ throw new Error("MultipartParser.end(): stream ended unexpectedly");
264
+ }
265
+ }
266
+ };
267
+ function _fileName(headerValue) {
268
+ const m = headerValue.match(/\bfilename=("(.*?)"|([^()<>@,;:\\"/[\]?={}\s\t]+))($|;\s)/i);
269
+ if (!m) {
270
+ return;
271
+ }
272
+ const match = m[2] || m[3] || "";
273
+ let filename = match.slice(match.lastIndexOf("\\") + 1);
274
+ filename = filename.replace(/%22/g, '"');
275
+ filename = filename.replace(/&#(\d{4});/g, (m2, code) => {
276
+ return String.fromCharCode(code);
277
+ });
278
+ return filename;
279
+ }
280
+ async function toFormData(Body, ct) {
281
+ if (!/multipart/i.test(ct)) {
282
+ throw new TypeError("Failed to fetch");
283
+ }
284
+ const m = ct.match(/boundary=(?:"([^"]+)"|([^;]+))/i);
285
+ if (!m) {
286
+ throw new TypeError("no or bad content-type header, no multipart boundary");
287
+ }
288
+ const parser = new MultipartParser(m[1] || m[2]);
289
+ let headerField;
290
+ let headerValue;
291
+ let entryValue;
292
+ let entryName;
293
+ let contentType;
294
+ let filename;
295
+ const entryChunks = [];
296
+ const formData = new FormData();
297
+ const onPartData = (ui8a) => {
298
+ entryValue += decoder.decode(ui8a, { stream: true });
299
+ };
300
+ const appendToFile = (ui8a) => {
301
+ entryChunks.push(ui8a);
302
+ };
303
+ const appendFileToFormData = () => {
304
+ const file = new file_default(entryChunks, filename, { type: contentType });
305
+ formData.append(entryName, file);
306
+ };
307
+ const appendEntryToFormData = () => {
308
+ formData.append(entryName, entryValue);
309
+ };
310
+ const decoder = new TextDecoder("utf-8");
311
+ decoder.decode();
312
+ parser.onPartBegin = function() {
313
+ parser.onPartData = onPartData;
314
+ parser.onPartEnd = appendEntryToFormData;
315
+ headerField = "";
316
+ headerValue = "";
317
+ entryValue = "";
318
+ entryName = "";
319
+ contentType = "";
320
+ filename = null;
321
+ entryChunks.length = 0;
322
+ };
323
+ parser.onHeaderField = function(ui8a) {
324
+ headerField += decoder.decode(ui8a, { stream: true });
325
+ };
326
+ parser.onHeaderValue = function(ui8a) {
327
+ headerValue += decoder.decode(ui8a, { stream: true });
328
+ };
329
+ parser.onHeaderEnd = function() {
330
+ headerValue += decoder.decode();
331
+ headerField = headerField.toLowerCase();
332
+ if (headerField === "content-disposition") {
333
+ const m2 = headerValue.match(/\bname=("([^"]*)"|([^()<>@,;:\\"/[\]?={}\s\t]+))/i);
334
+ if (m2) {
335
+ entryName = m2[2] || m2[3] || "";
336
+ }
337
+ filename = _fileName(headerValue);
338
+ if (filename) {
339
+ parser.onPartData = appendToFile;
340
+ parser.onPartEnd = appendFileToFormData;
341
+ }
342
+ } else if (headerField === "content-type") {
343
+ contentType = headerValue;
344
+ }
345
+ headerValue = "";
346
+ headerField = "";
347
+ };
348
+ try {
349
+ for (var iter = __forAwait(Body), more, temp, error; more = !(temp = await iter.next()).done; more = false) {
350
+ const chunk = temp.value;
351
+ parser.write(chunk);
352
+ }
353
+ } catch (temp) {
354
+ error = [temp];
355
+ } finally {
356
+ try {
357
+ more && (temp = iter.return) && await temp.call(iter);
358
+ } finally {
359
+ if (error)
360
+ throw error[0];
361
+ }
362
+ }
363
+ parser.end();
364
+ return formData;
365
+ }
366
+ export {
367
+ toFormData
368
+ };