@modern-js/plugin-data-loader 2.69.5 → 3.0.0-alpha.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/cjs/cli/createRequest.js +122 -141
- package/dist/cjs/cli/data.js +129 -148
- package/dist/cjs/cli/generateClient.js +52 -52
- package/dist/cjs/cli/loader.js +63 -62
- package/dist/cjs/common/constants.js +41 -31
- package/dist/cjs/runtime/errors.js +84 -89
- package/dist/cjs/runtime/index.js +143 -155
- package/dist/cjs/runtime/response.js +66 -77
- package/dist/esm/cli/createRequest.mjs +93 -0
- package/dist/esm/cli/data.mjs +111 -0
- package/dist/esm/cli/generateClient.mjs +22 -0
- package/dist/esm/cli/loader.mjs +34 -0
- package/dist/esm/common/constants.mjs +4 -0
- package/dist/esm/runtime/errors.mjs +52 -0
- package/dist/esm/runtime/index.mjs +114 -0
- package/dist/esm/runtime/response.mjs +42 -0
- package/dist/esm-node/cli/createRequest.mjs +93 -0
- package/dist/esm-node/cli/data.mjs +111 -0
- package/dist/esm-node/cli/generateClient.mjs +22 -0
- package/dist/esm-node/cli/loader.mjs +34 -0
- package/dist/esm-node/common/constants.mjs +4 -0
- package/dist/esm-node/runtime/errors.mjs +52 -0
- package/dist/esm-node/runtime/index.mjs +114 -0
- package/dist/esm-node/runtime/response.mjs +42 -0
- package/dist/types/cli/createRequest.d.ts +1 -2
- package/dist/types/cli/loader.d.ts +2 -2
- package/dist/types/runtime/errors.d.ts +1 -1
- package/dist/types/runtime/response.d.ts +1 -1
- package/package.json +22 -26
- package/rslib.config.mts +4 -0
- package/rstest.config.ts +18 -0
- package/dist/esm/cli/createRequest.js +0 -297
- package/dist/esm/cli/data.js +0 -491
- package/dist/esm/cli/generateClient.js +0 -21
- package/dist/esm/cli/loader.js +0 -93
- package/dist/esm/common/constants.js +0 -8
- package/dist/esm/runtime/errors.js +0 -90
- package/dist/esm/runtime/index.js +0 -191
- package/dist/esm/runtime/response.js +0 -107
- package/dist/esm-node/cli/createRequest.js +0 -126
- package/dist/esm-node/cli/data.js +0 -140
- package/dist/esm-node/cli/generateClient.js +0 -32
- package/dist/esm-node/cli/loader.js +0 -47
- package/dist/esm-node/common/constants.js +0 -8
- package/dist/esm-node/runtime/errors.js +0 -75
- package/dist/esm-node/runtime/index.js +0 -142
- package/dist/esm-node/runtime/response.js +0 -63
package/dist/esm/cli/data.js
DELETED
|
@@ -1,491 +0,0 @@
|
|
|
1
|
-
import { _ as _async_iterator } from "@swc/helpers/_/_async_iterator";
|
|
2
|
-
import { _ as _async_to_generator } from "@swc/helpers/_/_async_to_generator";
|
|
3
|
-
import { _ as _await_async_generator } from "@swc/helpers/_/_await_async_generator";
|
|
4
|
-
import { _ as _object_spread } from "@swc/helpers/_/_object_spread";
|
|
5
|
-
import { _ as _sliced_to_array } from "@swc/helpers/_/_sliced_to_array";
|
|
6
|
-
import { _ as _to_array } from "@swc/helpers/_/_to_array";
|
|
7
|
-
import { _ as _to_consumable_array } from "@swc/helpers/_/_to_consumable_array";
|
|
8
|
-
import { _ as _type_of } from "@swc/helpers/_/_type_of";
|
|
9
|
-
import { _ as _wrap_async_generator } from "@swc/helpers/_/_wrap_async_generator";
|
|
10
|
-
import { _ as _ts_generator } from "@swc/helpers/_/_ts_generator";
|
|
11
|
-
import { AbortedDeferredError, DeferredData } from "@modern-js/runtime-utils/browser";
|
|
12
|
-
var DEFERRED_VALUE_PLACEHOLDER_PREFIX = "__deferred_promise:";
|
|
13
|
-
function parseDeferredReadableStream(stream) {
|
|
14
|
-
return _parseDeferredReadableStream.apply(this, arguments);
|
|
15
|
-
}
|
|
16
|
-
function _parseDeferredReadableStream() {
|
|
17
|
-
_parseDeferredReadableStream = _async_to_generator(function(stream) {
|
|
18
|
-
var deferredData, deferredResolvers, sectionReader, initialSectionResult, initialSection, criticalData, _iteratorNormalCompletion, _didIteratorError, _iteratorError, _loop, _iterator, _step, error, _iteratorNormalCompletion1, _didIteratorError1, _iteratorError1, _iterator1, _step1, resolver;
|
|
19
|
-
return _ts_generator(this, function(_state) {
|
|
20
|
-
switch (_state.label) {
|
|
21
|
-
case 0:
|
|
22
|
-
if (!stream) {
|
|
23
|
-
throw new Error("parseDeferredReadableStream requires stream argument");
|
|
24
|
-
}
|
|
25
|
-
deferredResolvers = {};
|
|
26
|
-
_state.label = 1;
|
|
27
|
-
case 1:
|
|
28
|
-
_state.trys.push([
|
|
29
|
-
1,
|
|
30
|
-
3,
|
|
31
|
-
,
|
|
32
|
-
4
|
|
33
|
-
]);
|
|
34
|
-
sectionReader = readStreamSections(stream);
|
|
35
|
-
return [
|
|
36
|
-
4,
|
|
37
|
-
sectionReader.next()
|
|
38
|
-
];
|
|
39
|
-
case 2:
|
|
40
|
-
initialSectionResult = _state.sent();
|
|
41
|
-
initialSection = initialSectionResult.value;
|
|
42
|
-
if (!initialSection) {
|
|
43
|
-
throw new Error("no critical data");
|
|
44
|
-
}
|
|
45
|
-
criticalData = JSON.parse(initialSection);
|
|
46
|
-
if ((typeof criticalData === "undefined" ? "undefined" : _type_of(criticalData)) === "object" && criticalData !== null) {
|
|
47
|
-
_iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = void 0;
|
|
48
|
-
try {
|
|
49
|
-
_loop = function() {
|
|
50
|
-
var _step_value = _sliced_to_array(_step.value, 2), eventKey = _step_value[0], value = _step_value[1];
|
|
51
|
-
if (typeof value !== "string" || !value.startsWith(DEFERRED_VALUE_PLACEHOLDER_PREFIX)) {
|
|
52
|
-
return "continue";
|
|
53
|
-
}
|
|
54
|
-
deferredData = deferredData || {};
|
|
55
|
-
deferredData[eventKey] = new Promise(function(resolve, reject) {
|
|
56
|
-
deferredResolvers[eventKey] = {
|
|
57
|
-
resolve: function(value2) {
|
|
58
|
-
resolve(value2);
|
|
59
|
-
delete deferredResolvers[eventKey];
|
|
60
|
-
},
|
|
61
|
-
reject: function(error2) {
|
|
62
|
-
reject(error2);
|
|
63
|
-
delete deferredResolvers[eventKey];
|
|
64
|
-
}
|
|
65
|
-
};
|
|
66
|
-
});
|
|
67
|
-
};
|
|
68
|
-
for (_iterator = Object.entries(criticalData)[Symbol.iterator](); !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true)
|
|
69
|
-
_loop();
|
|
70
|
-
} catch (err) {
|
|
71
|
-
_didIteratorError = true;
|
|
72
|
-
_iteratorError = err;
|
|
73
|
-
} finally {
|
|
74
|
-
try {
|
|
75
|
-
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
76
|
-
_iterator.return();
|
|
77
|
-
}
|
|
78
|
-
} finally {
|
|
79
|
-
if (_didIteratorError) {
|
|
80
|
-
throw _iteratorError;
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
_async_to_generator(function() {
|
|
86
|
-
var _iteratorAbruptCompletion, _didIteratorError2, _iteratorError2, _iterator2, _step2, _value, section, _section_split, event, sectionDataStrings, sectionDataString, data, _iteratorNormalCompletion2, _didIteratorError12, _iteratorError12, _iterator12, _step12, _step_value, key, value, _iteratorNormalCompletion12, _didIteratorError22, _iteratorError22, _iterator22, _step22, _step_value1, key1, value1, _$err, err1, _iteratorNormalCompletion22, _didIteratorError3, _iteratorError3, _iterator3, _step3, _step_value2, key2, resolver2, error2, _iteratorNormalCompletion3, _didIteratorError4, _iteratorError4, _iterator4, _step4, resolver1;
|
|
87
|
-
return _ts_generator(this, function(_state2) {
|
|
88
|
-
switch (_state2.label) {
|
|
89
|
-
case 0:
|
|
90
|
-
_state2.trys.push([
|
|
91
|
-
0,
|
|
92
|
-
13,
|
|
93
|
-
,
|
|
94
|
-
14
|
|
95
|
-
]);
|
|
96
|
-
_iteratorAbruptCompletion = false, _didIteratorError2 = false;
|
|
97
|
-
_state2.label = 1;
|
|
98
|
-
case 1:
|
|
99
|
-
_state2.trys.push([
|
|
100
|
-
1,
|
|
101
|
-
6,
|
|
102
|
-
7,
|
|
103
|
-
12
|
|
104
|
-
]);
|
|
105
|
-
_iterator2 = _async_iterator(sectionReader);
|
|
106
|
-
_state2.label = 2;
|
|
107
|
-
case 2:
|
|
108
|
-
return [
|
|
109
|
-
4,
|
|
110
|
-
_iterator2.next()
|
|
111
|
-
];
|
|
112
|
-
case 3:
|
|
113
|
-
if (!(_iteratorAbruptCompletion = !(_step2 = _state2.sent()).done))
|
|
114
|
-
return [
|
|
115
|
-
3,
|
|
116
|
-
5
|
|
117
|
-
];
|
|
118
|
-
_value = _step2.value;
|
|
119
|
-
section = _value;
|
|
120
|
-
_section_split = _to_array(section.split(":")), event = _section_split[0], sectionDataStrings = _section_split.slice(1);
|
|
121
|
-
sectionDataString = sectionDataStrings.join(":");
|
|
122
|
-
data = JSON.parse(sectionDataString);
|
|
123
|
-
if (event === "data") {
|
|
124
|
-
_iteratorNormalCompletion2 = true, _didIteratorError12 = false, _iteratorError12 = void 0;
|
|
125
|
-
try {
|
|
126
|
-
for (_iterator12 = Object.entries(data)[Symbol.iterator](); !(_iteratorNormalCompletion2 = (_step12 = _iterator12.next()).done); _iteratorNormalCompletion2 = true) {
|
|
127
|
-
_step_value = _sliced_to_array(_step12.value, 2), key = _step_value[0], value = _step_value[1];
|
|
128
|
-
if (deferredResolvers[key]) {
|
|
129
|
-
deferredResolvers[key].resolve(value);
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
} catch (err) {
|
|
133
|
-
_didIteratorError12 = true;
|
|
134
|
-
_iteratorError12 = err;
|
|
135
|
-
} finally {
|
|
136
|
-
try {
|
|
137
|
-
if (!_iteratorNormalCompletion2 && _iterator12.return != null) {
|
|
138
|
-
_iterator12.return();
|
|
139
|
-
}
|
|
140
|
-
} finally {
|
|
141
|
-
if (_didIteratorError12) {
|
|
142
|
-
throw _iteratorError12;
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
} else if (event === "error") {
|
|
147
|
-
_iteratorNormalCompletion12 = true, _didIteratorError22 = false, _iteratorError22 = void 0;
|
|
148
|
-
try {
|
|
149
|
-
for (_iterator22 = Object.entries(data)[Symbol.iterator](); !(_iteratorNormalCompletion12 = (_step22 = _iterator22.next()).done); _iteratorNormalCompletion12 = true) {
|
|
150
|
-
_step_value1 = _sliced_to_array(_step22.value, 2), key1 = _step_value1[0], value1 = _step_value1[1];
|
|
151
|
-
_$err = new Error(value1.message);
|
|
152
|
-
_$err.stack = value1.stack;
|
|
153
|
-
if (deferredResolvers[key1]) {
|
|
154
|
-
deferredResolvers[key1].reject(_$err);
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
} catch (err) {
|
|
158
|
-
_didIteratorError22 = true;
|
|
159
|
-
_iteratorError22 = err;
|
|
160
|
-
} finally {
|
|
161
|
-
try {
|
|
162
|
-
if (!_iteratorNormalCompletion12 && _iterator22.return != null) {
|
|
163
|
-
_iterator22.return();
|
|
164
|
-
}
|
|
165
|
-
} finally {
|
|
166
|
-
if (_didIteratorError22) {
|
|
167
|
-
throw _iteratorError22;
|
|
168
|
-
}
|
|
169
|
-
}
|
|
170
|
-
}
|
|
171
|
-
}
|
|
172
|
-
_state2.label = 4;
|
|
173
|
-
case 4:
|
|
174
|
-
_iteratorAbruptCompletion = false;
|
|
175
|
-
return [
|
|
176
|
-
3,
|
|
177
|
-
2
|
|
178
|
-
];
|
|
179
|
-
case 5:
|
|
180
|
-
return [
|
|
181
|
-
3,
|
|
182
|
-
12
|
|
183
|
-
];
|
|
184
|
-
case 6:
|
|
185
|
-
err1 = _state2.sent();
|
|
186
|
-
_didIteratorError2 = true;
|
|
187
|
-
_iteratorError2 = err1;
|
|
188
|
-
return [
|
|
189
|
-
3,
|
|
190
|
-
12
|
|
191
|
-
];
|
|
192
|
-
case 7:
|
|
193
|
-
_state2.trys.push([
|
|
194
|
-
7,
|
|
195
|
-
,
|
|
196
|
-
10,
|
|
197
|
-
11
|
|
198
|
-
]);
|
|
199
|
-
if (!(_iteratorAbruptCompletion && _iterator2.return != null))
|
|
200
|
-
return [
|
|
201
|
-
3,
|
|
202
|
-
9
|
|
203
|
-
];
|
|
204
|
-
return [
|
|
205
|
-
4,
|
|
206
|
-
_iterator2.return()
|
|
207
|
-
];
|
|
208
|
-
case 8:
|
|
209
|
-
_state2.sent();
|
|
210
|
-
_state2.label = 9;
|
|
211
|
-
case 9:
|
|
212
|
-
return [
|
|
213
|
-
3,
|
|
214
|
-
11
|
|
215
|
-
];
|
|
216
|
-
case 10:
|
|
217
|
-
if (_didIteratorError2) {
|
|
218
|
-
throw _iteratorError2;
|
|
219
|
-
}
|
|
220
|
-
return [
|
|
221
|
-
7
|
|
222
|
-
];
|
|
223
|
-
case 11:
|
|
224
|
-
return [
|
|
225
|
-
7
|
|
226
|
-
];
|
|
227
|
-
case 12:
|
|
228
|
-
_iteratorNormalCompletion22 = true, _didIteratorError3 = false, _iteratorError3 = void 0;
|
|
229
|
-
try {
|
|
230
|
-
for (_iterator3 = Object.entries(deferredResolvers)[Symbol.iterator](); !(_iteratorNormalCompletion22 = (_step3 = _iterator3.next()).done); _iteratorNormalCompletion22 = true) {
|
|
231
|
-
_step_value2 = _sliced_to_array(_step3.value, 2), key2 = _step_value2[0], resolver2 = _step_value2[1];
|
|
232
|
-
resolver2.reject(new AbortedDeferredError("Deferred ".concat(key2, " will never resolved")));
|
|
233
|
-
}
|
|
234
|
-
} catch (err) {
|
|
235
|
-
_didIteratorError3 = true;
|
|
236
|
-
_iteratorError3 = err;
|
|
237
|
-
} finally {
|
|
238
|
-
try {
|
|
239
|
-
if (!_iteratorNormalCompletion22 && _iterator3.return != null) {
|
|
240
|
-
_iterator3.return();
|
|
241
|
-
}
|
|
242
|
-
} finally {
|
|
243
|
-
if (_didIteratorError3) {
|
|
244
|
-
throw _iteratorError3;
|
|
245
|
-
}
|
|
246
|
-
}
|
|
247
|
-
}
|
|
248
|
-
return [
|
|
249
|
-
3,
|
|
250
|
-
14
|
|
251
|
-
];
|
|
252
|
-
case 13:
|
|
253
|
-
error2 = _state2.sent();
|
|
254
|
-
_iteratorNormalCompletion3 = true, _didIteratorError4 = false, _iteratorError4 = void 0;
|
|
255
|
-
try {
|
|
256
|
-
for (_iterator4 = Object.values(deferredResolvers)[Symbol.iterator](); !(_iteratorNormalCompletion3 = (_step4 = _iterator4.next()).done); _iteratorNormalCompletion3 = true) {
|
|
257
|
-
resolver1 = _step4.value;
|
|
258
|
-
resolver1.reject(error2);
|
|
259
|
-
}
|
|
260
|
-
} catch (err) {
|
|
261
|
-
_didIteratorError4 = true;
|
|
262
|
-
_iteratorError4 = err;
|
|
263
|
-
} finally {
|
|
264
|
-
try {
|
|
265
|
-
if (!_iteratorNormalCompletion3 && _iterator4.return != null) {
|
|
266
|
-
_iterator4.return();
|
|
267
|
-
}
|
|
268
|
-
} finally {
|
|
269
|
-
if (_didIteratorError4) {
|
|
270
|
-
throw _iteratorError4;
|
|
271
|
-
}
|
|
272
|
-
}
|
|
273
|
-
}
|
|
274
|
-
return [
|
|
275
|
-
3,
|
|
276
|
-
14
|
|
277
|
-
];
|
|
278
|
-
case 14:
|
|
279
|
-
return [
|
|
280
|
-
2
|
|
281
|
-
];
|
|
282
|
-
}
|
|
283
|
-
});
|
|
284
|
-
})();
|
|
285
|
-
return [
|
|
286
|
-
2,
|
|
287
|
-
new DeferredData(_object_spread({}, criticalData, deferredData))
|
|
288
|
-
];
|
|
289
|
-
case 3:
|
|
290
|
-
error = _state.sent();
|
|
291
|
-
_iteratorNormalCompletion1 = true, _didIteratorError1 = false, _iteratorError1 = void 0;
|
|
292
|
-
try {
|
|
293
|
-
for (_iterator1 = Object.values(deferredResolvers)[Symbol.iterator](); !(_iteratorNormalCompletion1 = (_step1 = _iterator1.next()).done); _iteratorNormalCompletion1 = true) {
|
|
294
|
-
resolver = _step1.value;
|
|
295
|
-
resolver.reject(error);
|
|
296
|
-
}
|
|
297
|
-
} catch (err) {
|
|
298
|
-
_didIteratorError1 = true;
|
|
299
|
-
_iteratorError1 = err;
|
|
300
|
-
} finally {
|
|
301
|
-
try {
|
|
302
|
-
if (!_iteratorNormalCompletion1 && _iterator1.return != null) {
|
|
303
|
-
_iterator1.return();
|
|
304
|
-
}
|
|
305
|
-
} finally {
|
|
306
|
-
if (_didIteratorError1) {
|
|
307
|
-
throw _iteratorError1;
|
|
308
|
-
}
|
|
309
|
-
}
|
|
310
|
-
}
|
|
311
|
-
throw error;
|
|
312
|
-
case 4:
|
|
313
|
-
return [
|
|
314
|
-
2
|
|
315
|
-
];
|
|
316
|
-
}
|
|
317
|
-
});
|
|
318
|
-
});
|
|
319
|
-
return _parseDeferredReadableStream.apply(this, arguments);
|
|
320
|
-
}
|
|
321
|
-
function readStreamSections(stream) {
|
|
322
|
-
return _readStreamSections.apply(this, arguments);
|
|
323
|
-
}
|
|
324
|
-
function _readStreamSections() {
|
|
325
|
-
_readStreamSections = _wrap_async_generator(function(stream) {
|
|
326
|
-
var reader, buffer, sections, closed, encoder, decoder, readStreamSection, section;
|
|
327
|
-
return _ts_generator(this, function(_state) {
|
|
328
|
-
switch (_state.label) {
|
|
329
|
-
case 0:
|
|
330
|
-
reader = stream.getReader();
|
|
331
|
-
buffer = [];
|
|
332
|
-
sections = [];
|
|
333
|
-
closed = false;
|
|
334
|
-
encoder = new TextEncoder();
|
|
335
|
-
decoder = new TextDecoder();
|
|
336
|
-
readStreamSection = function() {
|
|
337
|
-
var _ref = _async_to_generator(function() {
|
|
338
|
-
var chunk, bufferedString, splitSections, _sections, bufferedString1;
|
|
339
|
-
return _ts_generator(this, function(_state2) {
|
|
340
|
-
switch (_state2.label) {
|
|
341
|
-
case 0:
|
|
342
|
-
if (sections.length > 0) {
|
|
343
|
-
return [
|
|
344
|
-
2,
|
|
345
|
-
sections.shift()
|
|
346
|
-
];
|
|
347
|
-
}
|
|
348
|
-
_state2.label = 1;
|
|
349
|
-
case 1:
|
|
350
|
-
if (!(!closed && sections.length === 0))
|
|
351
|
-
return [
|
|
352
|
-
3,
|
|
353
|
-
3
|
|
354
|
-
];
|
|
355
|
-
return [
|
|
356
|
-
4,
|
|
357
|
-
reader.read()
|
|
358
|
-
];
|
|
359
|
-
case 2:
|
|
360
|
-
chunk = _state2.sent();
|
|
361
|
-
if (chunk.done) {
|
|
362
|
-
closed = true;
|
|
363
|
-
return [
|
|
364
|
-
3,
|
|
365
|
-
3
|
|
366
|
-
];
|
|
367
|
-
}
|
|
368
|
-
buffer.push(chunk.value);
|
|
369
|
-
try {
|
|
370
|
-
bufferedString = decoder.decode(mergeArrays.apply(void 0, _to_consumable_array(buffer)));
|
|
371
|
-
splitSections = bufferedString.split("\n\n");
|
|
372
|
-
if (splitSections.length >= 2) {
|
|
373
|
-
;
|
|
374
|
-
(_sections = sections).push.apply(_sections, _to_consumable_array(splitSections.slice(0, -1)));
|
|
375
|
-
buffer = [
|
|
376
|
-
encoder.encode(splitSections.slice(-1).join("\n\n"))
|
|
377
|
-
];
|
|
378
|
-
}
|
|
379
|
-
if (sections.length > 0) {
|
|
380
|
-
return [
|
|
381
|
-
3,
|
|
382
|
-
3
|
|
383
|
-
];
|
|
384
|
-
}
|
|
385
|
-
} catch (e) {
|
|
386
|
-
return [
|
|
387
|
-
3,
|
|
388
|
-
1
|
|
389
|
-
];
|
|
390
|
-
}
|
|
391
|
-
return [
|
|
392
|
-
3,
|
|
393
|
-
1
|
|
394
|
-
];
|
|
395
|
-
case 3:
|
|
396
|
-
if (sections.length > 0) {
|
|
397
|
-
return [
|
|
398
|
-
2,
|
|
399
|
-
sections.shift()
|
|
400
|
-
];
|
|
401
|
-
}
|
|
402
|
-
if (buffer.length > 0) {
|
|
403
|
-
bufferedString1 = decoder.decode(mergeArrays.apply(void 0, _to_consumable_array(buffer)));
|
|
404
|
-
sections = bufferedString1.split("\n\n").filter(function(s) {
|
|
405
|
-
return s;
|
|
406
|
-
});
|
|
407
|
-
buffer = [];
|
|
408
|
-
}
|
|
409
|
-
return [
|
|
410
|
-
2,
|
|
411
|
-
sections.shift()
|
|
412
|
-
];
|
|
413
|
-
}
|
|
414
|
-
});
|
|
415
|
-
});
|
|
416
|
-
return function readStreamSection2() {
|
|
417
|
-
return _ref.apply(this, arguments);
|
|
418
|
-
};
|
|
419
|
-
}();
|
|
420
|
-
return [
|
|
421
|
-
4,
|
|
422
|
-
_await_async_generator(readStreamSection())
|
|
423
|
-
];
|
|
424
|
-
case 1:
|
|
425
|
-
section = _state.sent();
|
|
426
|
-
_state.label = 2;
|
|
427
|
-
case 2:
|
|
428
|
-
if (!section)
|
|
429
|
-
return [
|
|
430
|
-
3,
|
|
431
|
-
5
|
|
432
|
-
];
|
|
433
|
-
return [
|
|
434
|
-
4,
|
|
435
|
-
section
|
|
436
|
-
];
|
|
437
|
-
case 3:
|
|
438
|
-
_state.sent();
|
|
439
|
-
return [
|
|
440
|
-
4,
|
|
441
|
-
_await_async_generator(readStreamSection())
|
|
442
|
-
];
|
|
443
|
-
case 4:
|
|
444
|
-
section = _state.sent();
|
|
445
|
-
return [
|
|
446
|
-
3,
|
|
447
|
-
2
|
|
448
|
-
];
|
|
449
|
-
case 5:
|
|
450
|
-
return [
|
|
451
|
-
2
|
|
452
|
-
];
|
|
453
|
-
}
|
|
454
|
-
});
|
|
455
|
-
});
|
|
456
|
-
return _readStreamSections.apply(this, arguments);
|
|
457
|
-
}
|
|
458
|
-
function mergeArrays() {
|
|
459
|
-
for (var _len = arguments.length, arrays = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
460
|
-
arrays[_key] = arguments[_key];
|
|
461
|
-
}
|
|
462
|
-
var out = new Uint8Array(arrays.reduce(function(total, arr2) {
|
|
463
|
-
return total + arr2.length;
|
|
464
|
-
}, 0));
|
|
465
|
-
var offset = 0;
|
|
466
|
-
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = void 0;
|
|
467
|
-
try {
|
|
468
|
-
for (var _iterator = arrays[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
|
|
469
|
-
var arr = _step.value;
|
|
470
|
-
out.set(arr, offset);
|
|
471
|
-
offset += arr.length;
|
|
472
|
-
}
|
|
473
|
-
} catch (err) {
|
|
474
|
-
_didIteratorError = true;
|
|
475
|
-
_iteratorError = err;
|
|
476
|
-
} finally {
|
|
477
|
-
try {
|
|
478
|
-
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
479
|
-
_iterator.return();
|
|
480
|
-
}
|
|
481
|
-
} finally {
|
|
482
|
-
if (_didIteratorError) {
|
|
483
|
-
throw _iteratorError;
|
|
484
|
-
}
|
|
485
|
-
}
|
|
486
|
-
}
|
|
487
|
-
return out;
|
|
488
|
-
}
|
|
489
|
-
export {
|
|
490
|
-
parseDeferredReadableStream
|
|
491
|
-
};
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import path from "path";
|
|
2
|
-
var generateClient = function(param) {
|
|
3
|
-
var inline = param.inline, action = param.action, routeId = param.routeId;
|
|
4
|
-
var requestCode = "";
|
|
5
|
-
var requestCreatorPath = path.join(__dirname, "./createRequest").replace("/cjs/cli/", "/esm/cli/").replace(/\\/g, "/");
|
|
6
|
-
var importCode = "\n import { createRequest, createActionRequest } from '".concat(requestCreatorPath, "';\n ");
|
|
7
|
-
if (inline) {
|
|
8
|
-
if (action) {
|
|
9
|
-
requestCode = "\n export const loader = createRequest('".concat(routeId, "');\n export const action = createActionRequest('").concat(routeId, "')\n ");
|
|
10
|
-
} else {
|
|
11
|
-
requestCode = "\n export const loader = createRequest('".concat(routeId, "');\n ");
|
|
12
|
-
}
|
|
13
|
-
} else {
|
|
14
|
-
requestCode = "\n export default createRequest('".concat(routeId, "');\n ");
|
|
15
|
-
}
|
|
16
|
-
var generatedCode = "\n ".concat(importCode, "\n ").concat(requestCode, "\n ");
|
|
17
|
-
return generatedCode;
|
|
18
|
-
};
|
|
19
|
-
export {
|
|
20
|
-
generateClient
|
|
21
|
-
};
|
package/dist/esm/cli/loader.js
DELETED
|
@@ -1,93 +0,0 @@
|
|
|
1
|
-
import { _ as _async_to_generator } from "@swc/helpers/_/_async_to_generator";
|
|
2
|
-
import { _ as _sliced_to_array } from "@swc/helpers/_/_sliced_to_array";
|
|
3
|
-
import { _ as _ts_generator } from "@swc/helpers/_/_ts_generator";
|
|
4
|
-
import { promisify } from "util";
|
|
5
|
-
import { logger } from "@modern-js/utils/logger";
|
|
6
|
-
import { generateClient } from "./generateClient";
|
|
7
|
-
function loader(source) {
|
|
8
|
-
return _loader.apply(this, arguments);
|
|
9
|
-
}
|
|
10
|
-
function _loader() {
|
|
11
|
-
_loader = _async_to_generator(function(source) {
|
|
12
|
-
var _this__compiler, target, shouldSkip, resourceQuery, options, readFile, clientDataPath, clientDataContent, error, code;
|
|
13
|
-
return _ts_generator(this, function(_state) {
|
|
14
|
-
switch (_state.label) {
|
|
15
|
-
case 0:
|
|
16
|
-
this.cacheable();
|
|
17
|
-
target = (_this__compiler = this._compiler) === null || _this__compiler === void 0 ? void 0 : _this__compiler.options.target;
|
|
18
|
-
shouldSkip = function(compileTarget) {
|
|
19
|
-
return target === compileTarget || Array.isArray(target) && target.includes(compileTarget);
|
|
20
|
-
};
|
|
21
|
-
if (shouldSkip("node") || shouldSkip("webworker") || shouldSkip("async-node")) {
|
|
22
|
-
return [
|
|
23
|
-
2,
|
|
24
|
-
source
|
|
25
|
-
];
|
|
26
|
-
}
|
|
27
|
-
resourceQuery = this.resourceQuery;
|
|
28
|
-
options = resourceQuery.slice(1).split("&").reduce(function(pre, cur) {
|
|
29
|
-
var _cur_split = _sliced_to_array(cur.split("="), 2), key = _cur_split[0], value = _cur_split[1];
|
|
30
|
-
if (key && value) {
|
|
31
|
-
pre[key] = value === "true" ? true : value === "false" ? false : value;
|
|
32
|
-
}
|
|
33
|
-
return pre;
|
|
34
|
-
}, {});
|
|
35
|
-
if (!options.loaderId || options.retain) {
|
|
36
|
-
return [
|
|
37
|
-
2,
|
|
38
|
-
source
|
|
39
|
-
];
|
|
40
|
-
}
|
|
41
|
-
if (!options.clientData)
|
|
42
|
-
return [
|
|
43
|
-
3,
|
|
44
|
-
4
|
|
45
|
-
];
|
|
46
|
-
readFile = promisify(this.fs.readFile);
|
|
47
|
-
_state.label = 1;
|
|
48
|
-
case 1:
|
|
49
|
-
_state.trys.push([
|
|
50
|
-
1,
|
|
51
|
-
3,
|
|
52
|
-
,
|
|
53
|
-
4
|
|
54
|
-
]);
|
|
55
|
-
clientDataPath = this.resourcePath.includes(".loader.") ? this.resourcePath.replace(".loader.", ".data.client.") : this.resourcePath.replace(".data.", ".data.client.");
|
|
56
|
-
this.addDependency(clientDataPath);
|
|
57
|
-
return [
|
|
58
|
-
4,
|
|
59
|
-
readFile(clientDataPath)
|
|
60
|
-
];
|
|
61
|
-
case 2:
|
|
62
|
-
clientDataContent = _state.sent();
|
|
63
|
-
return [
|
|
64
|
-
2,
|
|
65
|
-
clientDataContent
|
|
66
|
-
];
|
|
67
|
-
case 3:
|
|
68
|
-
error = _state.sent();
|
|
69
|
-
if (process.env.NODE_ENV === "development") {
|
|
70
|
-
logger.error("Failed to read the clientData file ".concat(options.clientData));
|
|
71
|
-
}
|
|
72
|
-
return [
|
|
73
|
-
3,
|
|
74
|
-
4
|
|
75
|
-
];
|
|
76
|
-
case 4:
|
|
77
|
-
code = generateClient({
|
|
78
|
-
inline: options.inline,
|
|
79
|
-
action: options.action,
|
|
80
|
-
routeId: options.routeId
|
|
81
|
-
});
|
|
82
|
-
return [
|
|
83
|
-
2,
|
|
84
|
-
code
|
|
85
|
-
];
|
|
86
|
-
}
|
|
87
|
-
});
|
|
88
|
-
});
|
|
89
|
-
return _loader.apply(this, arguments);
|
|
90
|
-
}
|
|
91
|
-
export {
|
|
92
|
-
loader as default
|
|
93
|
-
};
|