@ohos-ports/vite 8.3.0-beta.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/LICENSE.md +2322 -0
- package/README.md +20 -0
- package/bin/openChrome.js +68 -0
- package/bin/vite.js +90 -0
- package/client.d.ts +285 -0
- package/dist/client/bundledDevClient.mjs +1864 -0
- package/dist/client/client.mjs +1272 -0
- package/dist/client/env.mjs +18 -0
- package/dist/node/chunks/build.js +5494 -0
- package/dist/node/chunks/dist.js +6732 -0
- package/dist/node/chunks/lib.js +371 -0
- package/dist/node/chunks/moduleRunnerTransport.d.ts +95 -0
- package/dist/node/chunks/node.js +37603 -0
- package/dist/node/chunks/postcss-import.js +465 -0
- package/dist/node/cli.js +839 -0
- package/dist/node/index.d.ts +4060 -0
- package/dist/node/index.js +2 -0
- package/dist/node/internal.d.ts +2 -0
- package/dist/node/internal.js +2 -0
- package/dist/node/module-runner.d.ts +313 -0
- package/dist/node/module-runner.js +1285 -0
- package/misc/false.js +1 -0
- package/misc/true.js +1 -0
- package/package.json +194 -0
- package/types/customEvent.d.ts +83 -0
- package/types/hmrPayload.d.ts +96 -0
- package/types/hot.d.ts +39 -0
- package/types/import-meta.d.ts +5 -0
- package/types/importGlob.d.ts +131 -0
- package/types/importMeta.d.ts +30 -0
- package/types/internal/cssPreprocessorOptions.d.ts +44 -0
- package/types/internal/devtoolsOptions.d.ts +9 -0
- package/types/internal/esbuildOptions.d.ts +28 -0
- package/types/internal/lightningcssOptions.d.ts +18 -0
- package/types/internal/rollupTypeCompat.d.ts +24 -0
- package/types/internal/terserOptions.d.ts +11 -0
- package/types/metadata.d.ts +47 -0
|
@@ -0,0 +1,371 @@
|
|
|
1
|
+
import { ft as __commonJSMin } from "./node.js";
|
|
2
|
+
//#region ../../node_modules/.pnpm/postcss-value-parser@4.2.0/node_modules/postcss-value-parser/lib/parse.js
|
|
3
|
+
var require_parse = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
4
|
+
var openParentheses = "(".charCodeAt(0);
|
|
5
|
+
var closeParentheses = ")".charCodeAt(0);
|
|
6
|
+
var singleQuote = "'".charCodeAt(0);
|
|
7
|
+
var doubleQuote = "\"".charCodeAt(0);
|
|
8
|
+
var backslash = "\\".charCodeAt(0);
|
|
9
|
+
var slash = "/".charCodeAt(0);
|
|
10
|
+
var comma = ",".charCodeAt(0);
|
|
11
|
+
var colon = ":".charCodeAt(0);
|
|
12
|
+
var star = "*".charCodeAt(0);
|
|
13
|
+
var uLower = "u".charCodeAt(0);
|
|
14
|
+
var uUpper = "U".charCodeAt(0);
|
|
15
|
+
var plus = "+".charCodeAt(0);
|
|
16
|
+
var isUnicodeRange = /^[a-f0-9?-]+$/i;
|
|
17
|
+
module.exports = function(input) {
|
|
18
|
+
var tokens = [];
|
|
19
|
+
var value = input;
|
|
20
|
+
var next, quote, prev, token, escape, escapePos, whitespacePos, parenthesesOpenPos;
|
|
21
|
+
var pos = 0;
|
|
22
|
+
var code = value.charCodeAt(pos);
|
|
23
|
+
var max = value.length;
|
|
24
|
+
var stack = [{ nodes: tokens }];
|
|
25
|
+
var balanced = 0;
|
|
26
|
+
var parent;
|
|
27
|
+
var name = "";
|
|
28
|
+
var before = "";
|
|
29
|
+
var after = "";
|
|
30
|
+
while (pos < max) if (code <= 32) {
|
|
31
|
+
next = pos;
|
|
32
|
+
do {
|
|
33
|
+
next += 1;
|
|
34
|
+
code = value.charCodeAt(next);
|
|
35
|
+
} while (code <= 32);
|
|
36
|
+
token = value.slice(pos, next);
|
|
37
|
+
prev = tokens[tokens.length - 1];
|
|
38
|
+
if (code === closeParentheses && balanced) after = token;
|
|
39
|
+
else if (prev && prev.type === "div") {
|
|
40
|
+
prev.after = token;
|
|
41
|
+
prev.sourceEndIndex += token.length;
|
|
42
|
+
} else if (code === comma || code === colon || code === slash && value.charCodeAt(next + 1) !== star && (!parent || parent && parent.type === "function" && parent.value !== "calc")) before = token;
|
|
43
|
+
else tokens.push({
|
|
44
|
+
type: "space",
|
|
45
|
+
sourceIndex: pos,
|
|
46
|
+
sourceEndIndex: next,
|
|
47
|
+
value: token
|
|
48
|
+
});
|
|
49
|
+
pos = next;
|
|
50
|
+
} else if (code === singleQuote || code === doubleQuote) {
|
|
51
|
+
next = pos;
|
|
52
|
+
quote = code === singleQuote ? "'" : "\"";
|
|
53
|
+
token = {
|
|
54
|
+
type: "string",
|
|
55
|
+
sourceIndex: pos,
|
|
56
|
+
quote
|
|
57
|
+
};
|
|
58
|
+
do {
|
|
59
|
+
escape = false;
|
|
60
|
+
next = value.indexOf(quote, next + 1);
|
|
61
|
+
if (~next) {
|
|
62
|
+
escapePos = next;
|
|
63
|
+
while (value.charCodeAt(escapePos - 1) === backslash) {
|
|
64
|
+
escapePos -= 1;
|
|
65
|
+
escape = !escape;
|
|
66
|
+
}
|
|
67
|
+
} else {
|
|
68
|
+
value += quote;
|
|
69
|
+
next = value.length - 1;
|
|
70
|
+
token.unclosed = true;
|
|
71
|
+
}
|
|
72
|
+
} while (escape);
|
|
73
|
+
token.value = value.slice(pos + 1, next);
|
|
74
|
+
token.sourceEndIndex = token.unclosed ? next : next + 1;
|
|
75
|
+
tokens.push(token);
|
|
76
|
+
pos = next + 1;
|
|
77
|
+
code = value.charCodeAt(pos);
|
|
78
|
+
} else if (code === slash && value.charCodeAt(pos + 1) === star) {
|
|
79
|
+
next = value.indexOf("*/", pos);
|
|
80
|
+
token = {
|
|
81
|
+
type: "comment",
|
|
82
|
+
sourceIndex: pos,
|
|
83
|
+
sourceEndIndex: next + 2
|
|
84
|
+
};
|
|
85
|
+
if (next === -1) {
|
|
86
|
+
token.unclosed = true;
|
|
87
|
+
next = value.length;
|
|
88
|
+
token.sourceEndIndex = next;
|
|
89
|
+
}
|
|
90
|
+
token.value = value.slice(pos + 2, next);
|
|
91
|
+
tokens.push(token);
|
|
92
|
+
pos = next + 2;
|
|
93
|
+
code = value.charCodeAt(pos);
|
|
94
|
+
} else if ((code === slash || code === star) && parent && parent.type === "function" && parent.value === "calc") {
|
|
95
|
+
token = value[pos];
|
|
96
|
+
tokens.push({
|
|
97
|
+
type: "word",
|
|
98
|
+
sourceIndex: pos - before.length,
|
|
99
|
+
sourceEndIndex: pos + token.length,
|
|
100
|
+
value: token
|
|
101
|
+
});
|
|
102
|
+
pos += 1;
|
|
103
|
+
code = value.charCodeAt(pos);
|
|
104
|
+
} else if (code === slash || code === comma || code === colon) {
|
|
105
|
+
token = value[pos];
|
|
106
|
+
tokens.push({
|
|
107
|
+
type: "div",
|
|
108
|
+
sourceIndex: pos - before.length,
|
|
109
|
+
sourceEndIndex: pos + token.length,
|
|
110
|
+
value: token,
|
|
111
|
+
before,
|
|
112
|
+
after: ""
|
|
113
|
+
});
|
|
114
|
+
before = "";
|
|
115
|
+
pos += 1;
|
|
116
|
+
code = value.charCodeAt(pos);
|
|
117
|
+
} else if (openParentheses === code) {
|
|
118
|
+
next = pos;
|
|
119
|
+
do {
|
|
120
|
+
next += 1;
|
|
121
|
+
code = value.charCodeAt(next);
|
|
122
|
+
} while (code <= 32);
|
|
123
|
+
parenthesesOpenPos = pos;
|
|
124
|
+
token = {
|
|
125
|
+
type: "function",
|
|
126
|
+
sourceIndex: pos - name.length,
|
|
127
|
+
value: name,
|
|
128
|
+
before: value.slice(parenthesesOpenPos + 1, next)
|
|
129
|
+
};
|
|
130
|
+
pos = next;
|
|
131
|
+
if (name === "url" && code !== singleQuote && code !== doubleQuote) {
|
|
132
|
+
next -= 1;
|
|
133
|
+
do {
|
|
134
|
+
escape = false;
|
|
135
|
+
next = value.indexOf(")", next + 1);
|
|
136
|
+
if (~next) {
|
|
137
|
+
escapePos = next;
|
|
138
|
+
while (value.charCodeAt(escapePos - 1) === backslash) {
|
|
139
|
+
escapePos -= 1;
|
|
140
|
+
escape = !escape;
|
|
141
|
+
}
|
|
142
|
+
} else {
|
|
143
|
+
value += ")";
|
|
144
|
+
next = value.length - 1;
|
|
145
|
+
token.unclosed = true;
|
|
146
|
+
}
|
|
147
|
+
} while (escape);
|
|
148
|
+
whitespacePos = next;
|
|
149
|
+
do {
|
|
150
|
+
whitespacePos -= 1;
|
|
151
|
+
code = value.charCodeAt(whitespacePos);
|
|
152
|
+
} while (code <= 32);
|
|
153
|
+
if (parenthesesOpenPos < whitespacePos) {
|
|
154
|
+
if (pos !== whitespacePos + 1) token.nodes = [{
|
|
155
|
+
type: "word",
|
|
156
|
+
sourceIndex: pos,
|
|
157
|
+
sourceEndIndex: whitespacePos + 1,
|
|
158
|
+
value: value.slice(pos, whitespacePos + 1)
|
|
159
|
+
}];
|
|
160
|
+
else token.nodes = [];
|
|
161
|
+
if (token.unclosed && whitespacePos + 1 !== next) {
|
|
162
|
+
token.after = "";
|
|
163
|
+
token.nodes.push({
|
|
164
|
+
type: "space",
|
|
165
|
+
sourceIndex: whitespacePos + 1,
|
|
166
|
+
sourceEndIndex: next,
|
|
167
|
+
value: value.slice(whitespacePos + 1, next)
|
|
168
|
+
});
|
|
169
|
+
} else {
|
|
170
|
+
token.after = value.slice(whitespacePos + 1, next);
|
|
171
|
+
token.sourceEndIndex = next;
|
|
172
|
+
}
|
|
173
|
+
} else {
|
|
174
|
+
token.after = "";
|
|
175
|
+
token.nodes = [];
|
|
176
|
+
}
|
|
177
|
+
pos = next + 1;
|
|
178
|
+
token.sourceEndIndex = token.unclosed ? next : pos;
|
|
179
|
+
code = value.charCodeAt(pos);
|
|
180
|
+
tokens.push(token);
|
|
181
|
+
} else {
|
|
182
|
+
balanced += 1;
|
|
183
|
+
token.after = "";
|
|
184
|
+
token.sourceEndIndex = pos + 1;
|
|
185
|
+
tokens.push(token);
|
|
186
|
+
stack.push(token);
|
|
187
|
+
tokens = token.nodes = [];
|
|
188
|
+
parent = token;
|
|
189
|
+
}
|
|
190
|
+
name = "";
|
|
191
|
+
} else if (closeParentheses === code && balanced) {
|
|
192
|
+
pos += 1;
|
|
193
|
+
code = value.charCodeAt(pos);
|
|
194
|
+
parent.after = after;
|
|
195
|
+
parent.sourceEndIndex += after.length;
|
|
196
|
+
after = "";
|
|
197
|
+
balanced -= 1;
|
|
198
|
+
stack[stack.length - 1].sourceEndIndex = pos;
|
|
199
|
+
stack.pop();
|
|
200
|
+
parent = stack[balanced];
|
|
201
|
+
tokens = parent.nodes;
|
|
202
|
+
} else {
|
|
203
|
+
next = pos;
|
|
204
|
+
do {
|
|
205
|
+
if (code === backslash) next += 1;
|
|
206
|
+
next += 1;
|
|
207
|
+
code = value.charCodeAt(next);
|
|
208
|
+
} while (next < max && !(code <= 32 || code === singleQuote || code === doubleQuote || code === comma || code === colon || code === slash || code === openParentheses || code === star && parent && parent.type === "function" && parent.value === "calc" || code === slash && parent.type === "function" && parent.value === "calc" || code === closeParentheses && balanced));
|
|
209
|
+
token = value.slice(pos, next);
|
|
210
|
+
if (openParentheses === code) name = token;
|
|
211
|
+
else if ((uLower === token.charCodeAt(0) || uUpper === token.charCodeAt(0)) && plus === token.charCodeAt(1) && isUnicodeRange.test(token.slice(2))) tokens.push({
|
|
212
|
+
type: "unicode-range",
|
|
213
|
+
sourceIndex: pos,
|
|
214
|
+
sourceEndIndex: next,
|
|
215
|
+
value: token
|
|
216
|
+
});
|
|
217
|
+
else tokens.push({
|
|
218
|
+
type: "word",
|
|
219
|
+
sourceIndex: pos,
|
|
220
|
+
sourceEndIndex: next,
|
|
221
|
+
value: token
|
|
222
|
+
});
|
|
223
|
+
pos = next;
|
|
224
|
+
}
|
|
225
|
+
for (pos = stack.length - 1; pos; pos -= 1) {
|
|
226
|
+
stack[pos].unclosed = true;
|
|
227
|
+
stack[pos].sourceEndIndex = value.length;
|
|
228
|
+
}
|
|
229
|
+
return stack[0].nodes;
|
|
230
|
+
};
|
|
231
|
+
}));
|
|
232
|
+
//#endregion
|
|
233
|
+
//#region ../../node_modules/.pnpm/postcss-value-parser@4.2.0/node_modules/postcss-value-parser/lib/walk.js
|
|
234
|
+
var require_walk = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
235
|
+
module.exports = function walk(nodes, cb, bubble) {
|
|
236
|
+
var i, max, node, result;
|
|
237
|
+
for (i = 0, max = nodes.length; i < max; i += 1) {
|
|
238
|
+
node = nodes[i];
|
|
239
|
+
if (!bubble) result = cb(node, i, nodes);
|
|
240
|
+
if (result !== false && node.type === "function" && Array.isArray(node.nodes)) walk(node.nodes, cb, bubble);
|
|
241
|
+
if (bubble) cb(node, i, nodes);
|
|
242
|
+
}
|
|
243
|
+
};
|
|
244
|
+
}));
|
|
245
|
+
//#endregion
|
|
246
|
+
//#region ../../node_modules/.pnpm/postcss-value-parser@4.2.0/node_modules/postcss-value-parser/lib/stringify.js
|
|
247
|
+
var require_stringify = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
248
|
+
function stringifyNode(node, custom) {
|
|
249
|
+
var type = node.type;
|
|
250
|
+
var value = node.value;
|
|
251
|
+
var buf;
|
|
252
|
+
var customResult;
|
|
253
|
+
if (custom && (customResult = custom(node)) !== void 0) return customResult;
|
|
254
|
+
else if (type === "word" || type === "space") return value;
|
|
255
|
+
else if (type === "string") {
|
|
256
|
+
buf = node.quote || "";
|
|
257
|
+
return buf + value + (node.unclosed ? "" : buf);
|
|
258
|
+
} else if (type === "comment") return "/*" + value + (node.unclosed ? "" : "*/");
|
|
259
|
+
else if (type === "div") return (node.before || "") + value + (node.after || "");
|
|
260
|
+
else if (Array.isArray(node.nodes)) {
|
|
261
|
+
buf = stringify(node.nodes, custom);
|
|
262
|
+
if (type !== "function") return buf;
|
|
263
|
+
return value + "(" + (node.before || "") + buf + (node.after || "") + (node.unclosed ? "" : ")");
|
|
264
|
+
}
|
|
265
|
+
return value;
|
|
266
|
+
}
|
|
267
|
+
function stringify(nodes, custom) {
|
|
268
|
+
var result, i;
|
|
269
|
+
if (Array.isArray(nodes)) {
|
|
270
|
+
result = "";
|
|
271
|
+
for (i = nodes.length - 1; ~i; i -= 1) result = stringifyNode(nodes[i], custom) + result;
|
|
272
|
+
return result;
|
|
273
|
+
}
|
|
274
|
+
return stringifyNode(nodes, custom);
|
|
275
|
+
}
|
|
276
|
+
module.exports = stringify;
|
|
277
|
+
}));
|
|
278
|
+
//#endregion
|
|
279
|
+
//#region ../../node_modules/.pnpm/postcss-value-parser@4.2.0/node_modules/postcss-value-parser/lib/unit.js
|
|
280
|
+
var require_unit = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
281
|
+
var minus = "-".charCodeAt(0);
|
|
282
|
+
var plus = "+".charCodeAt(0);
|
|
283
|
+
var dot = ".".charCodeAt(0);
|
|
284
|
+
var exp = "e".charCodeAt(0);
|
|
285
|
+
var EXP = "E".charCodeAt(0);
|
|
286
|
+
function likeNumber(value) {
|
|
287
|
+
var code = value.charCodeAt(0);
|
|
288
|
+
var nextCode;
|
|
289
|
+
if (code === plus || code === minus) {
|
|
290
|
+
nextCode = value.charCodeAt(1);
|
|
291
|
+
if (nextCode >= 48 && nextCode <= 57) return true;
|
|
292
|
+
var nextNextCode = value.charCodeAt(2);
|
|
293
|
+
if (nextCode === dot && nextNextCode >= 48 && nextNextCode <= 57) return true;
|
|
294
|
+
return false;
|
|
295
|
+
}
|
|
296
|
+
if (code === dot) {
|
|
297
|
+
nextCode = value.charCodeAt(1);
|
|
298
|
+
if (nextCode >= 48 && nextCode <= 57) return true;
|
|
299
|
+
return false;
|
|
300
|
+
}
|
|
301
|
+
if (code >= 48 && code <= 57) return true;
|
|
302
|
+
return false;
|
|
303
|
+
}
|
|
304
|
+
module.exports = function(value) {
|
|
305
|
+
var pos = 0;
|
|
306
|
+
var length = value.length;
|
|
307
|
+
var code;
|
|
308
|
+
var nextCode;
|
|
309
|
+
var nextNextCode;
|
|
310
|
+
if (length === 0 || !likeNumber(value)) return false;
|
|
311
|
+
code = value.charCodeAt(pos);
|
|
312
|
+
if (code === plus || code === minus) pos++;
|
|
313
|
+
while (pos < length) {
|
|
314
|
+
code = value.charCodeAt(pos);
|
|
315
|
+
if (code < 48 || code > 57) break;
|
|
316
|
+
pos += 1;
|
|
317
|
+
}
|
|
318
|
+
code = value.charCodeAt(pos);
|
|
319
|
+
nextCode = value.charCodeAt(pos + 1);
|
|
320
|
+
if (code === dot && nextCode >= 48 && nextCode <= 57) {
|
|
321
|
+
pos += 2;
|
|
322
|
+
while (pos < length) {
|
|
323
|
+
code = value.charCodeAt(pos);
|
|
324
|
+
if (code < 48 || code > 57) break;
|
|
325
|
+
pos += 1;
|
|
326
|
+
}
|
|
327
|
+
}
|
|
328
|
+
code = value.charCodeAt(pos);
|
|
329
|
+
nextCode = value.charCodeAt(pos + 1);
|
|
330
|
+
nextNextCode = value.charCodeAt(pos + 2);
|
|
331
|
+
if ((code === exp || code === EXP) && (nextCode >= 48 && nextCode <= 57 || (nextCode === plus || nextCode === minus) && nextNextCode >= 48 && nextNextCode <= 57)) {
|
|
332
|
+
pos += nextCode === plus || nextCode === minus ? 3 : 2;
|
|
333
|
+
while (pos < length) {
|
|
334
|
+
code = value.charCodeAt(pos);
|
|
335
|
+
if (code < 48 || code > 57) break;
|
|
336
|
+
pos += 1;
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
return {
|
|
340
|
+
number: value.slice(0, pos),
|
|
341
|
+
unit: value.slice(pos)
|
|
342
|
+
};
|
|
343
|
+
};
|
|
344
|
+
}));
|
|
345
|
+
//#endregion
|
|
346
|
+
//#region ../../node_modules/.pnpm/postcss-value-parser@4.2.0/node_modules/postcss-value-parser/lib/index.js
|
|
347
|
+
var require_lib = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
348
|
+
var parse = require_parse();
|
|
349
|
+
var walk = require_walk();
|
|
350
|
+
var stringify = require_stringify();
|
|
351
|
+
function ValueParser(value) {
|
|
352
|
+
if (this instanceof ValueParser) {
|
|
353
|
+
this.nodes = parse(value);
|
|
354
|
+
return this;
|
|
355
|
+
}
|
|
356
|
+
return new ValueParser(value);
|
|
357
|
+
}
|
|
358
|
+
ValueParser.prototype.toString = function() {
|
|
359
|
+
return Array.isArray(this.nodes) ? stringify(this.nodes) : "";
|
|
360
|
+
};
|
|
361
|
+
ValueParser.prototype.walk = function(cb, bubble) {
|
|
362
|
+
walk(this.nodes, cb, bubble);
|
|
363
|
+
return this;
|
|
364
|
+
};
|
|
365
|
+
ValueParser.unit = require_unit();
|
|
366
|
+
ValueParser.walk = walk;
|
|
367
|
+
ValueParser.stringify = stringify;
|
|
368
|
+
module.exports = ValueParser;
|
|
369
|
+
}));
|
|
370
|
+
//#endregion
|
|
371
|
+
export { require_lib as t };
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { HotPayload } from "#types/hmrPayload";
|
|
2
|
+
//#region src/shared/invokeMethods.d.ts
|
|
3
|
+
interface FetchFunctionOptions {
|
|
4
|
+
cached?: boolean;
|
|
5
|
+
startOffset?: number;
|
|
6
|
+
}
|
|
7
|
+
type FetchResult = CachedFetchResult | ExternalFetchResult | ViteFetchResult;
|
|
8
|
+
interface CachedFetchResult {
|
|
9
|
+
/**
|
|
10
|
+
* If the module is cached in the runner, this confirms
|
|
11
|
+
* it was not invalidated on the server side.
|
|
12
|
+
*/
|
|
13
|
+
cache: true;
|
|
14
|
+
}
|
|
15
|
+
interface ExternalFetchResult {
|
|
16
|
+
/**
|
|
17
|
+
* The path to the externalized module starting with file://.
|
|
18
|
+
* By default this will be imported via a dynamic "import"
|
|
19
|
+
* instead of being transformed by Vite and loaded with the Vite runner.
|
|
20
|
+
*/
|
|
21
|
+
externalize: string;
|
|
22
|
+
/**
|
|
23
|
+
* Type of the module. Used to determine if the import statement is correct.
|
|
24
|
+
* For example, if Vite needs to throw an error if a variable is not actually exported.
|
|
25
|
+
*/
|
|
26
|
+
type: "module" | "commonjs" | "builtin" | "network";
|
|
27
|
+
}
|
|
28
|
+
interface ViteFetchResult {
|
|
29
|
+
/**
|
|
30
|
+
* Code that will be evaluated by the Vite runner.
|
|
31
|
+
* By default this will be wrapped in an async function.
|
|
32
|
+
*/
|
|
33
|
+
code: string;
|
|
34
|
+
/**
|
|
35
|
+
* File path of the module on disk.
|
|
36
|
+
* This will be resolved as import.meta.url/filename.
|
|
37
|
+
* Will be `null` for virtual modules.
|
|
38
|
+
*/
|
|
39
|
+
file: string | null;
|
|
40
|
+
/**
|
|
41
|
+
* Module ID in the server module graph.
|
|
42
|
+
*/
|
|
43
|
+
id: string;
|
|
44
|
+
/**
|
|
45
|
+
* Module URL used in the import.
|
|
46
|
+
*/
|
|
47
|
+
url: string;
|
|
48
|
+
/**
|
|
49
|
+
* Invalidate module on the client side.
|
|
50
|
+
*/
|
|
51
|
+
invalidate: boolean;
|
|
52
|
+
}
|
|
53
|
+
type InvokeMethods = {
|
|
54
|
+
fetchModule: (id: string, importer?: string, options?: FetchFunctionOptions) => Promise<FetchResult>;
|
|
55
|
+
getBuiltins: () => Promise<Array<{
|
|
56
|
+
type: "string";
|
|
57
|
+
value: string;
|
|
58
|
+
} | {
|
|
59
|
+
type: "RegExp";
|
|
60
|
+
source: string;
|
|
61
|
+
flags: string;
|
|
62
|
+
}>>;
|
|
63
|
+
};
|
|
64
|
+
//#endregion
|
|
65
|
+
//#region src/shared/moduleRunnerTransport.d.ts
|
|
66
|
+
type ModuleRunnerTransportHandlers = {
|
|
67
|
+
onMessage: (data: HotPayload) => void;
|
|
68
|
+
onDisconnection: () => void;
|
|
69
|
+
};
|
|
70
|
+
/**
|
|
71
|
+
* "send and connect" or "invoke" must be implemented
|
|
72
|
+
*/
|
|
73
|
+
interface ModuleRunnerTransport {
|
|
74
|
+
connect?(handlers: ModuleRunnerTransportHandlers): Promise<void> | void;
|
|
75
|
+
disconnect?(): Promise<void> | void;
|
|
76
|
+
send?(data: HotPayload): Promise<void> | void;
|
|
77
|
+
invoke?(data: HotPayload): Promise<{
|
|
78
|
+
result: any;
|
|
79
|
+
} | {
|
|
80
|
+
error: any;
|
|
81
|
+
}>;
|
|
82
|
+
timeout?: number;
|
|
83
|
+
}
|
|
84
|
+
interface NormalizedModuleRunnerTransport {
|
|
85
|
+
connect?(onMessage?: (data: HotPayload) => void): Promise<void> | void;
|
|
86
|
+
disconnect?(): Promise<void> | void;
|
|
87
|
+
send(data: HotPayload): Promise<void>;
|
|
88
|
+
invoke<T extends keyof InvokeMethods>(name: T, data: Parameters<InvokeMethods[T]>): Promise<ReturnType<Awaited<InvokeMethods[T]>>>;
|
|
89
|
+
}
|
|
90
|
+
declare const createWebSocketModuleRunnerTransport: (options: {
|
|
91
|
+
createConnection: () => WebSocket;
|
|
92
|
+
pingInterval?: number;
|
|
93
|
+
}) => Required<Pick<ModuleRunnerTransport, "connect" | "disconnect" | "send">>;
|
|
94
|
+
//#endregion
|
|
95
|
+
export { ExternalFetchResult as a, ViteFetchResult as c, createWebSocketModuleRunnerTransport as i, ModuleRunnerTransportHandlers as n, FetchFunctionOptions as o, NormalizedModuleRunnerTransport as r, FetchResult as s, ModuleRunnerTransport as t };
|