vite 6.3.5 → 7.1.5
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 +81 -314
- package/bin/openChrome.js +68 -0
- package/bin/vite.js +7 -7
- package/dist/client/client.mjs +886 -922
- package/dist/client/env.mjs +14 -19
- package/dist/node/chunks/dep-BuoK8Wda.js +377 -0
- package/dist/node/chunks/dep-BvyJBvVx.js +4 -0
- package/dist/node/chunks/dep-Cs9lwdKu.js +4 -0
- package/dist/node/chunks/dep-DCVhRpiz.js +5595 -0
- package/dist/node/chunks/dep-DDbTn5rw.js +482 -0
- package/dist/node/chunks/dep-D_YDhiNx.js +4 -0
- package/dist/node/chunks/dep-M_KD0XSK.js +36707 -0
- package/dist/node/chunks/dep-SmwnYDP9.js +320 -0
- package/dist/node/chunks/dep-cWFO4sv4.js +4 -0
- package/dist/node/chunks/dep-lCKrEJQm.js +31 -0
- package/dist/node/chunks/dep-sDKrrA4S.js +6814 -0
- package/dist/node/chunks/dep-yxQqhtZq.js +4 -0
- package/dist/node/cli.js +624 -865
- package/dist/node/index.d.ts +2723 -3277
- package/dist/node/index.js +24 -188
- package/dist/node/module-runner.d.ts +256 -234
- package/dist/node/module-runner.js +1000 -1178
- package/dist/node/moduleRunnerTransport-BWUZBVLX.d.ts +88 -0
- package/package.json +52 -55
- package/types/importGlob.d.ts +14 -0
- package/types/internal/cssPreprocessorOptions.d.ts +3 -22
- package/types/internal/terserOptions.d.ts +11 -0
- package/types/metadata.d.ts +0 -2
- package/bin/openChrome.applescript +0 -95
- package/dist/node/chunks/dep-3RmXg9uo.js +0 -553
- package/dist/node/chunks/dep-AiMcmC_f.js +0 -822
- package/dist/node/chunks/dep-CvfTChi5.js +0 -8218
- package/dist/node/chunks/dep-DBxKXgDP.js +0 -49496
- package/dist/node/chunks/dep-SgSik2vo.js +0 -7113
- package/dist/node/constants.js +0 -149
- package/dist/node/moduleRunnerTransport.d-DJ_mE5sf.d.ts +0 -87
- package/dist/node-cjs/publicUtils.cjs +0 -3986
- package/index.cjs +0 -96
- package/index.d.cts +0 -6
@@ -0,0 +1,482 @@
|
|
1
|
+
import { __commonJS, __require } from "./dep-lCKrEJQm.js";
|
2
|
+
import { require_lib } from "./dep-BuoK8Wda.js";
|
3
|
+
|
4
|
+
//#region ../../node_modules/.pnpm/postcss-import@16.1.1_postcss@8.5.6/node_modules/postcss-import/lib/format-import-prelude.js
|
5
|
+
var require_format_import_prelude = /* @__PURE__ */ __commonJS({ "../../node_modules/.pnpm/postcss-import@16.1.1_postcss@8.5.6/node_modules/postcss-import/lib/format-import-prelude.js": ((exports, module) => {
|
6
|
+
module.exports = function formatImportPrelude$2(layer, media, supports) {
|
7
|
+
const parts = [];
|
8
|
+
if (typeof layer !== "undefined") {
|
9
|
+
let layerParams = "layer";
|
10
|
+
if (layer) layerParams = `layer(${layer})`;
|
11
|
+
parts.push(layerParams);
|
12
|
+
}
|
13
|
+
if (typeof supports !== "undefined") parts.push(`supports(${supports})`);
|
14
|
+
if (typeof media !== "undefined") parts.push(media);
|
15
|
+
return parts.join(" ");
|
16
|
+
};
|
17
|
+
}) });
|
18
|
+
|
19
|
+
//#endregion
|
20
|
+
//#region ../../node_modules/.pnpm/postcss-import@16.1.1_postcss@8.5.6/node_modules/postcss-import/lib/base64-encoded-import.js
|
21
|
+
var require_base64_encoded_import = /* @__PURE__ */ __commonJS({ "../../node_modules/.pnpm/postcss-import@16.1.1_postcss@8.5.6/node_modules/postcss-import/lib/base64-encoded-import.js": ((exports, module) => {
|
22
|
+
const formatImportPrelude$1 = require_format_import_prelude();
|
23
|
+
module.exports = function base64EncodedConditionalImport$1(prelude, conditions) {
|
24
|
+
if (!conditions?.length) return prelude;
|
25
|
+
conditions.reverse();
|
26
|
+
const first = conditions.pop();
|
27
|
+
let params = `${prelude} ${formatImportPrelude$1(first.layer, first.media, first.supports)}`;
|
28
|
+
for (const condition of conditions) params = `'data:text/css;base64,${Buffer.from(`@import ${params}`).toString("base64")}' ${formatImportPrelude$1(condition.layer, condition.media, condition.supports)}`;
|
29
|
+
return params;
|
30
|
+
};
|
31
|
+
}) });
|
32
|
+
|
33
|
+
//#endregion
|
34
|
+
//#region ../../node_modules/.pnpm/postcss-import@16.1.1_postcss@8.5.6/node_modules/postcss-import/lib/apply-conditions.js
|
35
|
+
var require_apply_conditions = /* @__PURE__ */ __commonJS({ "../../node_modules/.pnpm/postcss-import@16.1.1_postcss@8.5.6/node_modules/postcss-import/lib/apply-conditions.js": ((exports, module) => {
|
36
|
+
const base64EncodedConditionalImport = require_base64_encoded_import();
|
37
|
+
module.exports = function applyConditions$1(bundle, atRule) {
|
38
|
+
const firstImportStatementIndex = bundle.findIndex((stmt) => stmt.type === "import");
|
39
|
+
const lastImportStatementIndex = bundle.findLastIndex((stmt) => stmt.type === "import");
|
40
|
+
bundle.forEach((stmt, index) => {
|
41
|
+
if (stmt.type === "charset" || stmt.type === "warning") return;
|
42
|
+
if (stmt.type === "layer" && (index < lastImportStatementIndex && stmt.conditions?.length || index > firstImportStatementIndex && index < lastImportStatementIndex)) {
|
43
|
+
stmt.type = "import";
|
44
|
+
stmt.node = stmt.node.clone({
|
45
|
+
name: "import",
|
46
|
+
params: base64EncodedConditionalImport(`'data:text/css;base64,${Buffer.from(stmt.node.toString()).toString("base64")}'`, stmt.conditions)
|
47
|
+
});
|
48
|
+
return;
|
49
|
+
}
|
50
|
+
if (!stmt.conditions?.length) return;
|
51
|
+
if (stmt.type === "import") {
|
52
|
+
stmt.node.params = base64EncodedConditionalImport(stmt.fullUri, stmt.conditions);
|
53
|
+
return;
|
54
|
+
}
|
55
|
+
let nodes;
|
56
|
+
let parent;
|
57
|
+
if (stmt.type === "layer") {
|
58
|
+
nodes = [stmt.node];
|
59
|
+
parent = stmt.node.parent;
|
60
|
+
} else {
|
61
|
+
nodes = stmt.nodes;
|
62
|
+
parent = nodes[0].parent;
|
63
|
+
}
|
64
|
+
const atRules = [];
|
65
|
+
for (const condition of stmt.conditions) {
|
66
|
+
if (typeof condition.media !== "undefined") {
|
67
|
+
const mediaNode = atRule({
|
68
|
+
name: "media",
|
69
|
+
params: condition.media,
|
70
|
+
source: parent.source
|
71
|
+
});
|
72
|
+
atRules.push(mediaNode);
|
73
|
+
}
|
74
|
+
if (typeof condition.supports !== "undefined") {
|
75
|
+
const supportsNode = atRule({
|
76
|
+
name: "supports",
|
77
|
+
params: `(${condition.supports})`,
|
78
|
+
source: parent.source
|
79
|
+
});
|
80
|
+
atRules.push(supportsNode);
|
81
|
+
}
|
82
|
+
if (typeof condition.layer !== "undefined") {
|
83
|
+
const layerNode = atRule({
|
84
|
+
name: "layer",
|
85
|
+
params: condition.layer,
|
86
|
+
source: parent.source
|
87
|
+
});
|
88
|
+
atRules.push(layerNode);
|
89
|
+
}
|
90
|
+
}
|
91
|
+
const outerAtRule = atRules.shift();
|
92
|
+
const innerAtRule = atRules.reduce((previous, next) => {
|
93
|
+
previous.append(next);
|
94
|
+
return next;
|
95
|
+
}, outerAtRule);
|
96
|
+
parent.insertBefore(nodes[0], outerAtRule);
|
97
|
+
nodes.forEach((node) => {
|
98
|
+
node.parent = void 0;
|
99
|
+
});
|
100
|
+
nodes[0].raws.before = nodes[0].raws.before || "\n";
|
101
|
+
innerAtRule.append(nodes);
|
102
|
+
stmt.type = "nodes";
|
103
|
+
stmt.nodes = [outerAtRule];
|
104
|
+
delete stmt.node;
|
105
|
+
});
|
106
|
+
};
|
107
|
+
}) });
|
108
|
+
|
109
|
+
//#endregion
|
110
|
+
//#region ../../node_modules/.pnpm/postcss-import@16.1.1_postcss@8.5.6/node_modules/postcss-import/lib/apply-raws.js
|
111
|
+
var require_apply_raws = /* @__PURE__ */ __commonJS({ "../../node_modules/.pnpm/postcss-import@16.1.1_postcss@8.5.6/node_modules/postcss-import/lib/apply-raws.js": ((exports, module) => {
|
112
|
+
module.exports = function applyRaws$1(bundle) {
|
113
|
+
bundle.forEach((stmt, index) => {
|
114
|
+
if (index === 0) return;
|
115
|
+
if (stmt.parent) {
|
116
|
+
const { before } = stmt.parent.node.raws;
|
117
|
+
if (stmt.type === "nodes") stmt.nodes[0].raws.before = before;
|
118
|
+
else stmt.node.raws.before = before;
|
119
|
+
} else if (stmt.type === "nodes") stmt.nodes[0].raws.before = stmt.nodes[0].raws.before || "\n";
|
120
|
+
});
|
121
|
+
};
|
122
|
+
}) });
|
123
|
+
|
124
|
+
//#endregion
|
125
|
+
//#region ../../node_modules/.pnpm/postcss-import@16.1.1_postcss@8.5.6/node_modules/postcss-import/lib/apply-styles.js
|
126
|
+
var require_apply_styles = /* @__PURE__ */ __commonJS({ "../../node_modules/.pnpm/postcss-import@16.1.1_postcss@8.5.6/node_modules/postcss-import/lib/apply-styles.js": ((exports, module) => {
|
127
|
+
module.exports = function applyStyles$1(bundle, styles) {
|
128
|
+
styles.nodes = [];
|
129
|
+
bundle.forEach((stmt) => {
|
130
|
+
if ([
|
131
|
+
"charset",
|
132
|
+
"import",
|
133
|
+
"layer"
|
134
|
+
].includes(stmt.type)) {
|
135
|
+
stmt.node.parent = void 0;
|
136
|
+
styles.append(stmt.node);
|
137
|
+
} else if (stmt.type === "nodes") stmt.nodes.forEach((node) => {
|
138
|
+
node.parent = void 0;
|
139
|
+
styles.append(node);
|
140
|
+
});
|
141
|
+
});
|
142
|
+
};
|
143
|
+
}) });
|
144
|
+
|
145
|
+
//#endregion
|
146
|
+
//#region ../../node_modules/.pnpm/postcss-import@16.1.1_postcss@8.5.6/node_modules/postcss-import/lib/data-url.js
|
147
|
+
var require_data_url = /* @__PURE__ */ __commonJS({ "../../node_modules/.pnpm/postcss-import@16.1.1_postcss@8.5.6/node_modules/postcss-import/lib/data-url.js": ((exports, module) => {
|
148
|
+
const anyDataURLRegexp = /^data:text\/css(?:;(base64|plain))?,/i;
|
149
|
+
const base64DataURLRegexp = /^data:text\/css;base64,/i;
|
150
|
+
const plainDataURLRegexp = /^data:text\/css;plain,/i;
|
151
|
+
function isValid(url) {
|
152
|
+
return anyDataURLRegexp.test(url);
|
153
|
+
}
|
154
|
+
function contents(url) {
|
155
|
+
if (base64DataURLRegexp.test(url)) return Buffer.from(url.slice(21), "base64").toString();
|
156
|
+
if (plainDataURLRegexp.test(url)) return decodeURIComponent(url.slice(20));
|
157
|
+
return decodeURIComponent(url.slice(14));
|
158
|
+
}
|
159
|
+
module.exports = {
|
160
|
+
isValid,
|
161
|
+
contents
|
162
|
+
};
|
163
|
+
}) });
|
164
|
+
|
165
|
+
//#endregion
|
166
|
+
//#region ../../node_modules/.pnpm/postcss-import@16.1.1_postcss@8.5.6/node_modules/postcss-import/lib/parse-statements.js
|
167
|
+
var require_parse_statements = /* @__PURE__ */ __commonJS({ "../../node_modules/.pnpm/postcss-import@16.1.1_postcss@8.5.6/node_modules/postcss-import/lib/parse-statements.js": ((exports, module) => {
|
168
|
+
const valueParser = require_lib();
|
169
|
+
const { stringify } = valueParser;
|
170
|
+
module.exports = function parseStatements$1(result, styles, conditions, from) {
|
171
|
+
const statements = [];
|
172
|
+
let nodes = [];
|
173
|
+
let encounteredNonImportNodes = false;
|
174
|
+
styles.each((node) => {
|
175
|
+
let stmt;
|
176
|
+
if (node.type === "atrule") {
|
177
|
+
if (node.name === "import") stmt = parseImport(result, node, conditions, from);
|
178
|
+
else if (node.name === "charset") stmt = parseCharset(result, node, conditions, from);
|
179
|
+
else if (node.name === "layer" && !encounteredNonImportNodes && !node.nodes) stmt = parseLayer(result, node, conditions, from);
|
180
|
+
} else if (node.type !== "comment") encounteredNonImportNodes = true;
|
181
|
+
if (stmt) {
|
182
|
+
if (nodes.length) {
|
183
|
+
statements.push({
|
184
|
+
type: "nodes",
|
185
|
+
nodes,
|
186
|
+
conditions: [...conditions],
|
187
|
+
from
|
188
|
+
});
|
189
|
+
nodes = [];
|
190
|
+
}
|
191
|
+
statements.push(stmt);
|
192
|
+
} else nodes.push(node);
|
193
|
+
});
|
194
|
+
if (nodes.length) statements.push({
|
195
|
+
type: "nodes",
|
196
|
+
nodes,
|
197
|
+
conditions: [...conditions],
|
198
|
+
from
|
199
|
+
});
|
200
|
+
return statements;
|
201
|
+
};
|
202
|
+
function parseCharset(result, atRule, conditions, from) {
|
203
|
+
if (atRule.prev()) return result.warn("@charset must precede all other statements", { node: atRule });
|
204
|
+
return {
|
205
|
+
type: "charset",
|
206
|
+
node: atRule,
|
207
|
+
conditions: [...conditions],
|
208
|
+
from
|
209
|
+
};
|
210
|
+
}
|
211
|
+
function parseImport(result, atRule, conditions, from) {
|
212
|
+
let prev = atRule.prev();
|
213
|
+
if (prev) do {
|
214
|
+
if (prev.type === "comment" || prev.type === "atrule" && prev.name === "import") {
|
215
|
+
prev = prev.prev();
|
216
|
+
continue;
|
217
|
+
}
|
218
|
+
break;
|
219
|
+
} while (prev);
|
220
|
+
if (prev) do {
|
221
|
+
if (prev.type === "comment" || prev.type === "atrule" && (prev.name === "charset" || prev.name === "layer" && !prev.nodes)) {
|
222
|
+
prev = prev.prev();
|
223
|
+
continue;
|
224
|
+
}
|
225
|
+
return result.warn("@import must precede all other statements (besides @charset or empty @layer)", { node: atRule });
|
226
|
+
} while (prev);
|
227
|
+
if (atRule.nodes) return result.warn("It looks like you didn't end your @import statement correctly. Child nodes are attached to it.", { node: atRule });
|
228
|
+
const params = valueParser(atRule.params).nodes;
|
229
|
+
const stmt = {
|
230
|
+
type: "import",
|
231
|
+
uri: "",
|
232
|
+
fullUri: "",
|
233
|
+
node: atRule,
|
234
|
+
conditions: [...conditions],
|
235
|
+
from
|
236
|
+
};
|
237
|
+
let layer;
|
238
|
+
let media;
|
239
|
+
let supports;
|
240
|
+
for (let i = 0; i < params.length; i++) {
|
241
|
+
const node = params[i];
|
242
|
+
if (node.type === "space" || node.type === "comment") continue;
|
243
|
+
if (node.type === "string") {
|
244
|
+
if (stmt.uri) return result.warn(`Multiple url's in '${atRule.toString()}'`, { node: atRule });
|
245
|
+
if (!node.value) return result.warn(`Unable to find uri in '${atRule.toString()}'`, { node: atRule });
|
246
|
+
stmt.uri = node.value;
|
247
|
+
stmt.fullUri = stringify(node);
|
248
|
+
continue;
|
249
|
+
}
|
250
|
+
if (node.type === "function" && /^url$/i.test(node.value)) {
|
251
|
+
if (stmt.uri) return result.warn(`Multiple url's in '${atRule.toString()}'`, { node: atRule });
|
252
|
+
if (!node.nodes?.[0]?.value) return result.warn(`Unable to find uri in '${atRule.toString()}'`, { node: atRule });
|
253
|
+
stmt.uri = node.nodes[0].value;
|
254
|
+
stmt.fullUri = stringify(node);
|
255
|
+
continue;
|
256
|
+
}
|
257
|
+
if (!stmt.uri) return result.warn(`Unable to find uri in '${atRule.toString()}'`, { node: atRule });
|
258
|
+
if ((node.type === "word" || node.type === "function") && /^layer$/i.test(node.value)) {
|
259
|
+
if (typeof layer !== "undefined") return result.warn(`Multiple layers in '${atRule.toString()}'`, { node: atRule });
|
260
|
+
if (typeof supports !== "undefined") return result.warn(`layers must be defined before support conditions in '${atRule.toString()}'`, { node: atRule });
|
261
|
+
if (node.nodes) layer = stringify(node.nodes);
|
262
|
+
else layer = "";
|
263
|
+
continue;
|
264
|
+
}
|
265
|
+
if (node.type === "function" && /^supports$/i.test(node.value)) {
|
266
|
+
if (typeof supports !== "undefined") return result.warn(`Multiple support conditions in '${atRule.toString()}'`, { node: atRule });
|
267
|
+
supports = stringify(node.nodes);
|
268
|
+
continue;
|
269
|
+
}
|
270
|
+
media = stringify(params.slice(i));
|
271
|
+
break;
|
272
|
+
}
|
273
|
+
if (!stmt.uri) return result.warn(`Unable to find uri in '${atRule.toString()}'`, { node: atRule });
|
274
|
+
if (typeof media !== "undefined" || typeof layer !== "undefined" || typeof supports !== "undefined") stmt.conditions.push({
|
275
|
+
layer,
|
276
|
+
media,
|
277
|
+
supports
|
278
|
+
});
|
279
|
+
return stmt;
|
280
|
+
}
|
281
|
+
function parseLayer(result, atRule, conditions, from) {
|
282
|
+
return {
|
283
|
+
type: "layer",
|
284
|
+
node: atRule,
|
285
|
+
conditions: [...conditions],
|
286
|
+
from
|
287
|
+
};
|
288
|
+
}
|
289
|
+
}) });
|
290
|
+
|
291
|
+
//#endregion
|
292
|
+
//#region ../../node_modules/.pnpm/postcss-import@16.1.1_postcss@8.5.6/node_modules/postcss-import/lib/process-content.js
|
293
|
+
var require_process_content = /* @__PURE__ */ __commonJS({ "../../node_modules/.pnpm/postcss-import@16.1.1_postcss@8.5.6/node_modules/postcss-import/lib/process-content.js": ((exports, module) => {
|
294
|
+
const path$2 = __require("path");
|
295
|
+
let sugarss;
|
296
|
+
module.exports = function processContent$1(result, content, filename, options, postcss) {
|
297
|
+
const { plugins } = options;
|
298
|
+
const ext = path$2.extname(filename);
|
299
|
+
const parserList = [];
|
300
|
+
if (ext === ".sss") {
|
301
|
+
if (!sugarss)
|
302
|
+
/* c8 ignore next 3 */
|
303
|
+
try {
|
304
|
+
sugarss = __require("sugarss");
|
305
|
+
} catch {}
|
306
|
+
if (sugarss) return runPostcss(postcss, content, filename, plugins, [sugarss]);
|
307
|
+
}
|
308
|
+
if (result.opts.syntax?.parse) parserList.push(result.opts.syntax.parse);
|
309
|
+
if (result.opts.parser) parserList.push(result.opts.parser);
|
310
|
+
parserList.push(null);
|
311
|
+
return runPostcss(postcss, content, filename, plugins, parserList);
|
312
|
+
};
|
313
|
+
function runPostcss(postcss, content, filename, plugins, parsers, index) {
|
314
|
+
if (!index) index = 0;
|
315
|
+
return postcss(plugins).process(content, {
|
316
|
+
from: filename,
|
317
|
+
parser: parsers[index]
|
318
|
+
}).catch((err) => {
|
319
|
+
index++;
|
320
|
+
if (index === parsers.length) throw err;
|
321
|
+
return runPostcss(postcss, content, filename, plugins, parsers, index);
|
322
|
+
});
|
323
|
+
}
|
324
|
+
}) });
|
325
|
+
|
326
|
+
//#endregion
|
327
|
+
//#region ../../node_modules/.pnpm/postcss-import@16.1.1_postcss@8.5.6/node_modules/postcss-import/lib/parse-styles.js
|
328
|
+
var require_parse_styles = /* @__PURE__ */ __commonJS({ "../../node_modules/.pnpm/postcss-import@16.1.1_postcss@8.5.6/node_modules/postcss-import/lib/parse-styles.js": ((exports, module) => {
|
329
|
+
const path$1 = __require("path");
|
330
|
+
const dataURL = require_data_url();
|
331
|
+
const parseStatements = require_parse_statements();
|
332
|
+
const processContent = require_process_content();
|
333
|
+
const resolveId$1 = (id) => id;
|
334
|
+
const formatImportPrelude = require_format_import_prelude();
|
335
|
+
async function parseStyles$1(result, styles, options, state, conditions, from, postcss) {
|
336
|
+
const statements = parseStatements(result, styles, conditions, from);
|
337
|
+
for (const stmt of statements) {
|
338
|
+
if (stmt.type !== "import" || !isProcessableURL(stmt.uri)) continue;
|
339
|
+
if (options.filter && !options.filter(stmt.uri)) continue;
|
340
|
+
await resolveImportId(result, stmt, options, state, postcss);
|
341
|
+
}
|
342
|
+
let charset;
|
343
|
+
const beforeBundle = [];
|
344
|
+
const bundle = [];
|
345
|
+
function handleCharset(stmt) {
|
346
|
+
if (!charset) charset = stmt;
|
347
|
+
else if (stmt.node.params.toLowerCase() !== charset.node.params.toLowerCase()) throw stmt.node.error(`Incompatible @charset statements:
|
348
|
+
${stmt.node.params} specified in ${stmt.node.source.input.file}
|
349
|
+
${charset.node.params} specified in ${charset.node.source.input.file}`);
|
350
|
+
}
|
351
|
+
statements.forEach((stmt) => {
|
352
|
+
if (stmt.type === "charset") handleCharset(stmt);
|
353
|
+
else if (stmt.type === "import") if (stmt.children) stmt.children.forEach((child, index) => {
|
354
|
+
if (child.type === "import") beforeBundle.push(child);
|
355
|
+
else if (child.type === "layer") beforeBundle.push(child);
|
356
|
+
else if (child.type === "charset") handleCharset(child);
|
357
|
+
else bundle.push(child);
|
358
|
+
if (index === 0) child.parent = stmt;
|
359
|
+
});
|
360
|
+
else beforeBundle.push(stmt);
|
361
|
+
else if (stmt.type === "layer") beforeBundle.push(stmt);
|
362
|
+
else if (stmt.type === "nodes") bundle.push(stmt);
|
363
|
+
});
|
364
|
+
return charset ? [charset, ...beforeBundle.concat(bundle)] : beforeBundle.concat(bundle);
|
365
|
+
}
|
366
|
+
async function resolveImportId(result, stmt, options, state, postcss) {
|
367
|
+
if (dataURL.isValid(stmt.uri)) {
|
368
|
+
stmt.children = await loadImportContent(result, stmt, stmt.uri, options, state, postcss);
|
369
|
+
return;
|
370
|
+
} else if (dataURL.isValid(stmt.from.slice(-1))) throw stmt.node.error(`Unable to import '${stmt.uri}' from a stylesheet that is embedded in a data url`);
|
371
|
+
const atRule = stmt.node;
|
372
|
+
let sourceFile;
|
373
|
+
if (atRule.source?.input?.file) sourceFile = atRule.source.input.file;
|
374
|
+
const base = sourceFile ? path$1.dirname(atRule.source.input.file) : options.root;
|
375
|
+
const paths = [await options.resolve(stmt.uri, base, options, atRule)].flat();
|
376
|
+
const resolved = await Promise.all(paths.map((file) => {
|
377
|
+
return !path$1.isAbsolute(file) ? resolveId$1(file, base, options, atRule) : file;
|
378
|
+
}));
|
379
|
+
resolved.forEach((file) => {
|
380
|
+
result.messages.push({
|
381
|
+
type: "dependency",
|
382
|
+
plugin: "postcss-import",
|
383
|
+
file,
|
384
|
+
parent: sourceFile
|
385
|
+
});
|
386
|
+
});
|
387
|
+
const importedContent = await Promise.all(resolved.map((file) => {
|
388
|
+
return loadImportContent(result, stmt, file, options, state, postcss);
|
389
|
+
}));
|
390
|
+
stmt.children = importedContent.flat().filter((x) => !!x);
|
391
|
+
}
|
392
|
+
async function loadImportContent(result, stmt, filename, options, state, postcss) {
|
393
|
+
const atRule = stmt.node;
|
394
|
+
const { conditions, from } = stmt;
|
395
|
+
const stmtDuplicateCheckKey = conditions.map((condition) => formatImportPrelude(condition.layer, condition.media, condition.supports)).join(":");
|
396
|
+
if (options.skipDuplicates) {
|
397
|
+
if (state.importedFiles[filename]?.[stmtDuplicateCheckKey]) return;
|
398
|
+
if (!state.importedFiles[filename]) state.importedFiles[filename] = {};
|
399
|
+
state.importedFiles[filename][stmtDuplicateCheckKey] = true;
|
400
|
+
}
|
401
|
+
if (from.includes(filename)) return;
|
402
|
+
const content = await options.load(filename, options);
|
403
|
+
if (content.trim() === "" && options.warnOnEmpty) {
|
404
|
+
result.warn(`${filename} is empty`, { node: atRule });
|
405
|
+
return;
|
406
|
+
}
|
407
|
+
if (options.skipDuplicates && state.hashFiles[content]?.[stmtDuplicateCheckKey]) return;
|
408
|
+
const importedResult = await processContent(result, content, filename, options, postcss);
|
409
|
+
const styles = importedResult.root;
|
410
|
+
result.messages = result.messages.concat(importedResult.messages);
|
411
|
+
if (options.skipDuplicates) {
|
412
|
+
const hasImport = styles.some((child) => {
|
413
|
+
return child.type === "atrule" && child.name === "import";
|
414
|
+
});
|
415
|
+
if (!hasImport) {
|
416
|
+
if (!state.hashFiles[content]) state.hashFiles[content] = {};
|
417
|
+
state.hashFiles[content][stmtDuplicateCheckKey] = true;
|
418
|
+
}
|
419
|
+
}
|
420
|
+
return parseStyles$1(result, styles, options, state, conditions, [...from, filename], postcss);
|
421
|
+
}
|
422
|
+
function isProcessableURL(uri) {
|
423
|
+
if (/^(?:[a-z]+:)?\/\//i.test(uri)) return false;
|
424
|
+
try {
|
425
|
+
const url = new URL(uri, "https://example.com");
|
426
|
+
if (url.search) return false;
|
427
|
+
} catch {}
|
428
|
+
return true;
|
429
|
+
}
|
430
|
+
module.exports = parseStyles$1;
|
431
|
+
}) });
|
432
|
+
|
433
|
+
//#endregion
|
434
|
+
//#region ../../node_modules/.pnpm/postcss-import@16.1.1_postcss@8.5.6/node_modules/postcss-import/index.js
|
435
|
+
var require_postcss_import = /* @__PURE__ */ __commonJS({ "../../node_modules/.pnpm/postcss-import@16.1.1_postcss@8.5.6/node_modules/postcss-import/index.js": ((exports, module) => {
|
436
|
+
const path = __require("path");
|
437
|
+
const applyConditions = require_apply_conditions();
|
438
|
+
const applyRaws = require_apply_raws();
|
439
|
+
const applyStyles = require_apply_styles();
|
440
|
+
const loadContent = () => "";
|
441
|
+
const parseStyles = require_parse_styles();
|
442
|
+
const resolveId = (id) => id;
|
443
|
+
function AtImport(options) {
|
444
|
+
options = {
|
445
|
+
root: process.cwd(),
|
446
|
+
path: [],
|
447
|
+
skipDuplicates: true,
|
448
|
+
resolve: resolveId,
|
449
|
+
load: loadContent,
|
450
|
+
plugins: [],
|
451
|
+
addModulesDirectories: [],
|
452
|
+
warnOnEmpty: true,
|
453
|
+
...options
|
454
|
+
};
|
455
|
+
options.root = path.resolve(options.root);
|
456
|
+
if (typeof options.path === "string") options.path = [options.path];
|
457
|
+
if (!Array.isArray(options.path)) options.path = [];
|
458
|
+
options.path = options.path.map((p) => path.resolve(options.root, p));
|
459
|
+
return {
|
460
|
+
postcssPlugin: "postcss-import",
|
461
|
+
async Once(styles, { result, atRule, postcss }) {
|
462
|
+
const state = {
|
463
|
+
importedFiles: {},
|
464
|
+
hashFiles: {}
|
465
|
+
};
|
466
|
+
if (styles.source?.input?.file) state.importedFiles[styles.source.input.file] = {};
|
467
|
+
if (options.plugins && !Array.isArray(options.plugins)) throw new Error("plugins option must be an array");
|
468
|
+
const bundle = await parseStyles(result, styles, options, state, [], [], postcss);
|
469
|
+
applyRaws(bundle);
|
470
|
+
applyConditions(bundle, atRule);
|
471
|
+
applyStyles(bundle, styles);
|
472
|
+
}
|
473
|
+
};
|
474
|
+
}
|
475
|
+
AtImport.postcss = true;
|
476
|
+
module.exports = AtImport;
|
477
|
+
}) });
|
478
|
+
|
479
|
+
//#endregion
|
480
|
+
export default require_postcss_import();
|
481
|
+
|
482
|
+
export { };
|