@maizzle/framework 6.0.0-rc.12 → 6.0.0-rc.14

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.
Files changed (99) hide show
  1. package/dist/build.mjs +4 -1
  2. package/dist/build.mjs.map +1 -1
  3. package/dist/components/Button.vue +2 -2
  4. package/dist/components/CodeBlock.vue +2 -1
  5. package/dist/components/Column.vue +28 -22
  6. package/dist/components/Container.vue +47 -9
  7. package/dist/components/Font.vue +96 -0
  8. package/dist/components/Layout.vue +9 -4
  9. package/dist/components/Overlap.vue +75 -18
  10. package/dist/components/Row.vue +40 -19
  11. package/dist/components/Section.vue +35 -8
  12. package/dist/components/utils.d.mts +14 -1
  13. package/dist/components/utils.d.mts.map +1 -1
  14. package/dist/components/utils.mjs +32 -1
  15. package/dist/components/utils.mjs.map +1 -1
  16. package/dist/components/utils.ts +39 -0
  17. package/dist/composables/renderContext.d.mts +8 -1
  18. package/dist/composables/renderContext.d.mts.map +1 -1
  19. package/dist/composables/renderContext.mjs.map +1 -1
  20. package/dist/composables/useFont.d.mts +50 -0
  21. package/dist/composables/useFont.d.mts.map +1 -0
  22. package/dist/composables/useFont.mjs +93 -0
  23. package/dist/composables/useFont.mjs.map +1 -0
  24. package/dist/index.d.mts +2 -1
  25. package/dist/index.mjs +2 -1
  26. package/dist/plugins/postcss/quoteFontFamilies.d.mts +13 -0
  27. package/dist/plugins/postcss/quoteFontFamilies.d.mts.map +1 -0
  28. package/dist/plugins/postcss/quoteFontFamilies.mjs +84 -0
  29. package/dist/plugins/postcss/quoteFontFamilies.mjs.map +1 -0
  30. package/dist/render/createRenderer.mjs +8 -2
  31. package/dist/render/createRenderer.mjs.map +1 -1
  32. package/dist/render/injectFonts.d.mts +15 -0
  33. package/dist/render/injectFonts.d.mts.map +1 -0
  34. package/dist/render/injectFonts.mjs +46 -0
  35. package/dist/render/injectFonts.mjs.map +1 -0
  36. package/dist/serve.d.mts.map +1 -1
  37. package/dist/serve.mjs +28 -12
  38. package/dist/serve.mjs.map +1 -1
  39. package/dist/server/compatibility.d.mts +54 -2
  40. package/dist/server/compatibility.d.mts.map +1 -1
  41. package/dist/server/compatibility.mjs +890 -76
  42. package/dist/server/compatibility.mjs.map +1 -1
  43. package/dist/server/linter.d.mts +15 -2
  44. package/dist/server/linter.d.mts.map +1 -1
  45. package/dist/server/linter.mjs +194 -43
  46. package/dist/server/linter.mjs.map +1 -1
  47. package/dist/server/sfc-utils.d.mts +18 -0
  48. package/dist/server/sfc-utils.d.mts.map +1 -0
  49. package/dist/server/sfc-utils.mjs +184 -0
  50. package/dist/server/sfc-utils.mjs.map +1 -0
  51. package/dist/server/ui/App.vue +27 -50
  52. package/dist/server/ui/components/SidebarClose.vue +12 -0
  53. package/dist/server/ui/components/ui/command/Command.vue +1 -0
  54. package/dist/server/ui/components/ui/input/Input.vue +1 -1
  55. package/dist/server/ui/components/ui/sidebar/SidebarTrigger.vue +1 -1
  56. package/dist/server/ui/components/ui/tags-input/TagsInputInput.vue +1 -1
  57. package/dist/server/ui/lib/emulated-dark-mode.ts +131 -0
  58. package/dist/server/ui/pages/Preview.vue +215 -156
  59. package/dist/transformers/addAttributes.mjs +10 -6
  60. package/dist/transformers/addAttributes.mjs.map +1 -1
  61. package/dist/transformers/columnWidth.d.mts +31 -0
  62. package/dist/transformers/columnWidth.d.mts.map +1 -0
  63. package/dist/transformers/columnWidth.mjs +166 -0
  64. package/dist/transformers/columnWidth.mjs.map +1 -0
  65. package/dist/transformers/index.d.mts.map +1 -1
  66. package/dist/transformers/index.mjs +4 -0
  67. package/dist/transformers/index.mjs.map +1 -1
  68. package/dist/transformers/inlineCSS.mjs +2 -2
  69. package/dist/transformers/inlineCSS.mjs.map +1 -1
  70. package/dist/transformers/msoWidthFromClass.d.mts +19 -0
  71. package/dist/transformers/msoWidthFromClass.d.mts.map +1 -0
  72. package/dist/transformers/msoWidthFromClass.mjs +61 -0
  73. package/dist/transformers/msoWidthFromClass.mjs.map +1 -0
  74. package/dist/transformers/purgeCSS.mjs +1 -1
  75. package/dist/transformers/purgeCSS.mjs.map +1 -1
  76. package/dist/transformers/tailwindcss.d.mts.map +1 -1
  77. package/dist/transformers/tailwindcss.mjs +6 -16
  78. package/dist/transformers/tailwindcss.mjs.map +1 -1
  79. package/dist/types/config.d.mts +42 -2
  80. package/dist/types/config.d.mts.map +1 -1
  81. package/dist/types/index.d.mts +2 -2
  82. package/dist/utils/decodeStyleEntities.d.mts +15 -0
  83. package/dist/utils/decodeStyleEntities.d.mts.map +1 -0
  84. package/dist/utils/decodeStyleEntities.mjs +18 -0
  85. package/dist/utils/decodeStyleEntities.mjs.map +1 -0
  86. package/package.json +2 -3
  87. package/dist/_virtual/_rolldown/runtime.mjs +0 -32
  88. package/dist/node_modules/picomatch/index.mjs +0 -13
  89. package/dist/node_modules/picomatch/index.mjs.map +0 -1
  90. package/dist/node_modules/picomatch/lib/constants.mjs +0 -174
  91. package/dist/node_modules/picomatch/lib/constants.mjs.map +0 -1
  92. package/dist/node_modules/picomatch/lib/parse.mjs +0 -1067
  93. package/dist/node_modules/picomatch/lib/parse.mjs.map +0 -1
  94. package/dist/node_modules/picomatch/lib/picomatch.mjs +0 -304
  95. package/dist/node_modules/picomatch/lib/picomatch.mjs.map +0 -1
  96. package/dist/node_modules/picomatch/lib/scan.mjs +0 -296
  97. package/dist/node_modules/picomatch/lib/scan.mjs.map +0 -1
  98. package/dist/node_modules/picomatch/lib/utils.mjs +0 -53
  99. package/dist/node_modules/picomatch/lib/utils.mjs.map +0 -1
@@ -1,1067 +0,0 @@
1
- import { __commonJSMin } from "../../../_virtual/_rolldown/runtime.mjs";
2
- import { require_constants } from "./constants.mjs";
3
- import { require_utils } from "./utils.mjs";
4
-
5
- //#region node_modules/picomatch/lib/parse.js
6
- var require_parse = /* @__PURE__ */ __commonJSMin(((exports, module) => {
7
- const constants = require_constants();
8
- const utils = require_utils();
9
- /**
10
- * Constants
11
- */
12
- const { MAX_LENGTH, POSIX_REGEX_SOURCE, REGEX_NON_SPECIAL_CHARS, REGEX_SPECIAL_CHARS_BACKREF, REPLACEMENTS } = constants;
13
- /**
14
- * Helpers
15
- */
16
- const expandRange = (args, options) => {
17
- if (typeof options.expandRange === "function") return options.expandRange(...args, options);
18
- args.sort();
19
- const value = `[${args.join("-")}]`;
20
- try {
21
- new RegExp(value);
22
- } catch (ex) {
23
- return args.map((v) => utils.escapeRegex(v)).join("..");
24
- }
25
- return value;
26
- };
27
- /**
28
- * Create the message for a syntax error
29
- */
30
- const syntaxError = (type, char) => {
31
- return `Missing ${type}: "${char}" - use "\\\\${char}" to match literal characters`;
32
- };
33
- const splitTopLevel = (input) => {
34
- const parts = [];
35
- let bracket = 0;
36
- let paren = 0;
37
- let quote = 0;
38
- let value = "";
39
- let escaped = false;
40
- for (const ch of input) {
41
- if (escaped === true) {
42
- value += ch;
43
- escaped = false;
44
- continue;
45
- }
46
- if (ch === "\\") {
47
- value += ch;
48
- escaped = true;
49
- continue;
50
- }
51
- if (ch === "\"") {
52
- quote = quote === 1 ? 0 : 1;
53
- value += ch;
54
- continue;
55
- }
56
- if (quote === 0) {
57
- if (ch === "[") bracket++;
58
- else if (ch === "]" && bracket > 0) bracket--;
59
- else if (bracket === 0) {
60
- if (ch === "(") paren++;
61
- else if (ch === ")" && paren > 0) paren--;
62
- else if (ch === "|" && paren === 0) {
63
- parts.push(value);
64
- value = "";
65
- continue;
66
- }
67
- }
68
- }
69
- value += ch;
70
- }
71
- parts.push(value);
72
- return parts;
73
- };
74
- const isPlainBranch = (branch) => {
75
- let escaped = false;
76
- for (const ch of branch) {
77
- if (escaped === true) {
78
- escaped = false;
79
- continue;
80
- }
81
- if (ch === "\\") {
82
- escaped = true;
83
- continue;
84
- }
85
- if (/[?*+@!()[\]{}]/.test(ch)) return false;
86
- }
87
- return true;
88
- };
89
- const normalizeSimpleBranch = (branch) => {
90
- let value = branch.trim();
91
- let changed = true;
92
- while (changed === true) {
93
- changed = false;
94
- if (/^@\([^\\()[\]{}|]+\)$/.test(value)) {
95
- value = value.slice(2, -1);
96
- changed = true;
97
- }
98
- }
99
- if (!isPlainBranch(value)) return;
100
- return value.replace(/\\(.)/g, "$1");
101
- };
102
- const hasRepeatedCharPrefixOverlap = (branches) => {
103
- const values = branches.map(normalizeSimpleBranch).filter(Boolean);
104
- for (let i = 0; i < values.length; i++) for (let j = i + 1; j < values.length; j++) {
105
- const a = values[i];
106
- const b = values[j];
107
- const char = a[0];
108
- if (!char || a !== char.repeat(a.length) || b !== char.repeat(b.length)) continue;
109
- if (a === b || a.startsWith(b) || b.startsWith(a)) return true;
110
- }
111
- return false;
112
- };
113
- const parseRepeatedExtglob = (pattern, requireEnd = true) => {
114
- if (pattern[0] !== "+" && pattern[0] !== "*" || pattern[1] !== "(") return;
115
- let bracket = 0;
116
- let paren = 0;
117
- let quote = 0;
118
- let escaped = false;
119
- for (let i = 1; i < pattern.length; i++) {
120
- const ch = pattern[i];
121
- if (escaped === true) {
122
- escaped = false;
123
- continue;
124
- }
125
- if (ch === "\\") {
126
- escaped = true;
127
- continue;
128
- }
129
- if (ch === "\"") {
130
- quote = quote === 1 ? 0 : 1;
131
- continue;
132
- }
133
- if (quote === 1) continue;
134
- if (ch === "[") {
135
- bracket++;
136
- continue;
137
- }
138
- if (ch === "]" && bracket > 0) {
139
- bracket--;
140
- continue;
141
- }
142
- if (bracket > 0) continue;
143
- if (ch === "(") {
144
- paren++;
145
- continue;
146
- }
147
- if (ch === ")") {
148
- paren--;
149
- if (paren === 0) {
150
- if (requireEnd === true && i !== pattern.length - 1) return;
151
- return {
152
- type: pattern[0],
153
- body: pattern.slice(2, i),
154
- end: i
155
- };
156
- }
157
- }
158
- }
159
- };
160
- const getStarExtglobSequenceOutput = (pattern) => {
161
- let index = 0;
162
- const chars = [];
163
- while (index < pattern.length) {
164
- const match = parseRepeatedExtglob(pattern.slice(index), false);
165
- if (!match || match.type !== "*") return;
166
- const branches = splitTopLevel(match.body).map((branch) => branch.trim());
167
- if (branches.length !== 1) return;
168
- const branch = normalizeSimpleBranch(branches[0]);
169
- if (!branch || branch.length !== 1) return;
170
- chars.push(branch);
171
- index += match.end + 1;
172
- }
173
- if (chars.length < 1) return;
174
- return `${chars.length === 1 ? utils.escapeRegex(chars[0]) : `[${chars.map((ch) => utils.escapeRegex(ch)).join("")}]`}*`;
175
- };
176
- const repeatedExtglobRecursion = (pattern) => {
177
- let depth = 0;
178
- let value = pattern.trim();
179
- let match = parseRepeatedExtglob(value);
180
- while (match) {
181
- depth++;
182
- value = match.body.trim();
183
- match = parseRepeatedExtglob(value);
184
- }
185
- return depth;
186
- };
187
- const analyzeRepeatedExtglob = (body, options) => {
188
- if (options.maxExtglobRecursion === false) return { risky: false };
189
- const max = typeof options.maxExtglobRecursion === "number" ? options.maxExtglobRecursion : constants.DEFAULT_MAX_EXTGLOB_RECURSION;
190
- const branches = splitTopLevel(body).map((branch) => branch.trim());
191
- if (branches.length > 1) {
192
- if (branches.some((branch) => branch === "") || branches.some((branch) => /^[*?]+$/.test(branch)) || hasRepeatedCharPrefixOverlap(branches)) return { risky: true };
193
- }
194
- for (const branch of branches) {
195
- const safeOutput = getStarExtglobSequenceOutput(branch);
196
- if (safeOutput) return {
197
- risky: true,
198
- safeOutput
199
- };
200
- if (repeatedExtglobRecursion(branch) > max) return { risky: true };
201
- }
202
- return { risky: false };
203
- };
204
- /**
205
- * Parse the given input string.
206
- * @param {String} input
207
- * @param {Object} options
208
- * @return {Object}
209
- */
210
- const parse = (input, options) => {
211
- if (typeof input !== "string") throw new TypeError("Expected a string");
212
- input = REPLACEMENTS[input] || input;
213
- const opts = { ...options };
214
- const max = typeof opts.maxLength === "number" ? Math.min(MAX_LENGTH, opts.maxLength) : MAX_LENGTH;
215
- let len = input.length;
216
- if (len > max) throw new SyntaxError(`Input length: ${len}, exceeds maximum allowed length: ${max}`);
217
- const bos = {
218
- type: "bos",
219
- value: "",
220
- output: opts.prepend || ""
221
- };
222
- const tokens = [bos];
223
- const capture = opts.capture ? "" : "?:";
224
- const win32 = utils.isWindows(options);
225
- const PLATFORM_CHARS = constants.globChars(win32);
226
- const EXTGLOB_CHARS = constants.extglobChars(PLATFORM_CHARS);
227
- const { DOT_LITERAL, PLUS_LITERAL, SLASH_LITERAL, ONE_CHAR, DOTS_SLASH, NO_DOT, NO_DOT_SLASH, NO_DOTS_SLASH, QMARK, QMARK_NO_DOT, STAR, START_ANCHOR } = PLATFORM_CHARS;
228
- const globstar = (opts) => {
229
- return `(${capture}(?:(?!${START_ANCHOR}${opts.dot ? DOTS_SLASH : DOT_LITERAL}).)*?)`;
230
- };
231
- const nodot = opts.dot ? "" : NO_DOT;
232
- const qmarkNoDot = opts.dot ? QMARK : QMARK_NO_DOT;
233
- let star = opts.bash === true ? globstar(opts) : STAR;
234
- if (opts.capture) star = `(${star})`;
235
- if (typeof opts.noext === "boolean") opts.noextglob = opts.noext;
236
- const state = {
237
- input,
238
- index: -1,
239
- start: 0,
240
- dot: opts.dot === true,
241
- consumed: "",
242
- output: "",
243
- prefix: "",
244
- backtrack: false,
245
- negated: false,
246
- brackets: 0,
247
- braces: 0,
248
- parens: 0,
249
- quotes: 0,
250
- globstar: false,
251
- tokens
252
- };
253
- input = utils.removePrefix(input, state);
254
- len = input.length;
255
- const extglobs = [];
256
- const braces = [];
257
- const stack = [];
258
- let prev = bos;
259
- let value;
260
- /**
261
- * Tokenizing helpers
262
- */
263
- const eos = () => state.index === len - 1;
264
- const peek = state.peek = (n = 1) => input[state.index + n];
265
- const advance = state.advance = () => input[++state.index] || "";
266
- const remaining = () => input.slice(state.index + 1);
267
- const consume = (value = "", num = 0) => {
268
- state.consumed += value;
269
- state.index += num;
270
- };
271
- const append = (token) => {
272
- state.output += token.output != null ? token.output : token.value;
273
- consume(token.value);
274
- };
275
- const negate = () => {
276
- let count = 1;
277
- while (peek() === "!" && (peek(2) !== "(" || peek(3) === "?")) {
278
- advance();
279
- state.start++;
280
- count++;
281
- }
282
- if (count % 2 === 0) return false;
283
- state.negated = true;
284
- state.start++;
285
- return true;
286
- };
287
- const increment = (type) => {
288
- state[type]++;
289
- stack.push(type);
290
- };
291
- const decrement = (type) => {
292
- state[type]--;
293
- stack.pop();
294
- };
295
- /**
296
- * Push tokens onto the tokens array. This helper speeds up
297
- * tokenizing by 1) helping us avoid backtracking as much as possible,
298
- * and 2) helping us avoid creating extra tokens when consecutive
299
- * characters are plain text. This improves performance and simplifies
300
- * lookbehinds.
301
- */
302
- const push = (tok) => {
303
- if (prev.type === "globstar") {
304
- const isBrace = state.braces > 0 && (tok.type === "comma" || tok.type === "brace");
305
- const isExtglob = tok.extglob === true || extglobs.length && (tok.type === "pipe" || tok.type === "paren");
306
- if (tok.type !== "slash" && tok.type !== "paren" && !isBrace && !isExtglob) {
307
- state.output = state.output.slice(0, -prev.output.length);
308
- prev.type = "star";
309
- prev.value = "*";
310
- prev.output = star;
311
- state.output += prev.output;
312
- }
313
- }
314
- if (extglobs.length && tok.type !== "paren") extglobs[extglobs.length - 1].inner += tok.value;
315
- if (tok.value || tok.output) append(tok);
316
- if (prev && prev.type === "text" && tok.type === "text") {
317
- prev.value += tok.value;
318
- prev.output = (prev.output || "") + tok.value;
319
- return;
320
- }
321
- tok.prev = prev;
322
- tokens.push(tok);
323
- prev = tok;
324
- };
325
- const extglobOpen = (type, value) => {
326
- const token = {
327
- ...EXTGLOB_CHARS[value],
328
- conditions: 1,
329
- inner: ""
330
- };
331
- token.prev = prev;
332
- token.parens = state.parens;
333
- token.output = state.output;
334
- token.startIndex = state.index;
335
- token.tokensIndex = tokens.length;
336
- const output = (opts.capture ? "(" : "") + token.open;
337
- increment("parens");
338
- push({
339
- type,
340
- value,
341
- output: state.output ? "" : ONE_CHAR
342
- });
343
- push({
344
- type: "paren",
345
- extglob: true,
346
- value: advance(),
347
- output
348
- });
349
- extglobs.push(token);
350
- };
351
- const extglobClose = (token) => {
352
- const literal = input.slice(token.startIndex, state.index + 1);
353
- const analysis = analyzeRepeatedExtglob(input.slice(token.startIndex + 2, state.index), opts);
354
- if ((token.type === "plus" || token.type === "star") && analysis.risky) {
355
- const safeOutput = analysis.safeOutput ? (token.output ? "" : ONE_CHAR) + (opts.capture ? `(${analysis.safeOutput})` : analysis.safeOutput) : void 0;
356
- const open = tokens[token.tokensIndex];
357
- open.type = "text";
358
- open.value = literal;
359
- open.output = safeOutput || utils.escapeRegex(literal);
360
- for (let i = token.tokensIndex + 1; i < tokens.length; i++) {
361
- tokens[i].value = "";
362
- tokens[i].output = "";
363
- delete tokens[i].suffix;
364
- }
365
- state.output = token.output + open.output;
366
- state.backtrack = true;
367
- push({
368
- type: "paren",
369
- extglob: true,
370
- value,
371
- output: ""
372
- });
373
- decrement("parens");
374
- return;
375
- }
376
- let output = token.close + (opts.capture ? ")" : "");
377
- let rest;
378
- if (token.type === "negate") {
379
- let extglobStar = star;
380
- if (token.inner && token.inner.length > 1 && token.inner.includes("/")) extglobStar = globstar(opts);
381
- if (extglobStar !== star || eos() || /^\)+$/.test(remaining())) output = token.close = `)$))${extglobStar}`;
382
- if (token.inner.includes("*") && (rest = remaining()) && /^\.[^\\/.]+$/.test(rest)) output = token.close = `)${parse(rest, {
383
- ...options,
384
- fastpaths: false
385
- }).output})${extglobStar})`;
386
- if (token.prev.type === "bos") state.negatedExtglob = true;
387
- }
388
- push({
389
- type: "paren",
390
- extglob: true,
391
- value,
392
- output
393
- });
394
- decrement("parens");
395
- };
396
- /**
397
- * Fast paths
398
- */
399
- if (opts.fastpaths !== false && !/(^[*!]|[/()[\]{}"])/.test(input)) {
400
- let backslashes = false;
401
- let output = input.replace(REGEX_SPECIAL_CHARS_BACKREF, (m, esc, chars, first, rest, index) => {
402
- if (first === "\\") {
403
- backslashes = true;
404
- return m;
405
- }
406
- if (first === "?") {
407
- if (esc) return esc + first + (rest ? QMARK.repeat(rest.length) : "");
408
- if (index === 0) return qmarkNoDot + (rest ? QMARK.repeat(rest.length) : "");
409
- return QMARK.repeat(chars.length);
410
- }
411
- if (first === ".") return DOT_LITERAL.repeat(chars.length);
412
- if (first === "*") {
413
- if (esc) return esc + first + (rest ? star : "");
414
- return star;
415
- }
416
- return esc ? m : `\\${m}`;
417
- });
418
- if (backslashes === true) if (opts.unescape === true) output = output.replace(/\\/g, "");
419
- else output = output.replace(/\\+/g, (m) => {
420
- return m.length % 2 === 0 ? "\\\\" : m ? "\\" : "";
421
- });
422
- if (output === input && opts.contains === true) {
423
- state.output = input;
424
- return state;
425
- }
426
- state.output = utils.wrapOutput(output, state, options);
427
- return state;
428
- }
429
- /**
430
- * Tokenize input until we reach end-of-string
431
- */
432
- while (!eos()) {
433
- value = advance();
434
- if (value === "\0") continue;
435
- /**
436
- * Escaped characters
437
- */
438
- if (value === "\\") {
439
- const next = peek();
440
- if (next === "/" && opts.bash !== true) continue;
441
- if (next === "." || next === ";") continue;
442
- if (!next) {
443
- value += "\\";
444
- push({
445
- type: "text",
446
- value
447
- });
448
- continue;
449
- }
450
- const match = /^\\+/.exec(remaining());
451
- let slashes = 0;
452
- if (match && match[0].length > 2) {
453
- slashes = match[0].length;
454
- state.index += slashes;
455
- if (slashes % 2 !== 0) value += "\\";
456
- }
457
- if (opts.unescape === true) value = advance();
458
- else value += advance();
459
- if (state.brackets === 0) {
460
- push({
461
- type: "text",
462
- value
463
- });
464
- continue;
465
- }
466
- }
467
- /**
468
- * If we're inside a regex character class, continue
469
- * until we reach the closing bracket.
470
- */
471
- if (state.brackets > 0 && (value !== "]" || prev.value === "[" || prev.value === "[^")) {
472
- if (opts.posix !== false && value === ":") {
473
- const inner = prev.value.slice(1);
474
- if (inner.includes("[")) {
475
- prev.posix = true;
476
- if (inner.includes(":")) {
477
- const idx = prev.value.lastIndexOf("[");
478
- const pre = prev.value.slice(0, idx);
479
- const posix = POSIX_REGEX_SOURCE[prev.value.slice(idx + 2)];
480
- if (posix) {
481
- prev.value = pre + posix;
482
- state.backtrack = true;
483
- advance();
484
- if (!bos.output && tokens.indexOf(prev) === 1) bos.output = ONE_CHAR;
485
- continue;
486
- }
487
- }
488
- }
489
- }
490
- if (value === "[" && peek() !== ":" || value === "-" && peek() === "]") value = `\\${value}`;
491
- if (value === "]" && (prev.value === "[" || prev.value === "[^")) value = `\\${value}`;
492
- if (opts.posix === true && value === "!" && prev.value === "[") value = "^";
493
- prev.value += value;
494
- append({ value });
495
- continue;
496
- }
497
- /**
498
- * If we're inside a quoted string, continue
499
- * until we reach the closing double quote.
500
- */
501
- if (state.quotes === 1 && value !== "\"") {
502
- value = utils.escapeRegex(value);
503
- prev.value += value;
504
- append({ value });
505
- continue;
506
- }
507
- /**
508
- * Double quotes
509
- */
510
- if (value === "\"") {
511
- state.quotes = state.quotes === 1 ? 0 : 1;
512
- if (opts.keepQuotes === true) push({
513
- type: "text",
514
- value
515
- });
516
- continue;
517
- }
518
- /**
519
- * Parentheses
520
- */
521
- if (value === "(") {
522
- increment("parens");
523
- push({
524
- type: "paren",
525
- value
526
- });
527
- continue;
528
- }
529
- if (value === ")") {
530
- if (state.parens === 0 && opts.strictBrackets === true) throw new SyntaxError(syntaxError("opening", "("));
531
- const extglob = extglobs[extglobs.length - 1];
532
- if (extglob && state.parens === extglob.parens + 1) {
533
- extglobClose(extglobs.pop());
534
- continue;
535
- }
536
- push({
537
- type: "paren",
538
- value,
539
- output: state.parens ? ")" : "\\)"
540
- });
541
- decrement("parens");
542
- continue;
543
- }
544
- /**
545
- * Square brackets
546
- */
547
- if (value === "[") {
548
- if (opts.nobracket === true || !remaining().includes("]")) {
549
- if (opts.nobracket !== true && opts.strictBrackets === true) throw new SyntaxError(syntaxError("closing", "]"));
550
- value = `\\${value}`;
551
- } else increment("brackets");
552
- push({
553
- type: "bracket",
554
- value
555
- });
556
- continue;
557
- }
558
- if (value === "]") {
559
- if (opts.nobracket === true || prev && prev.type === "bracket" && prev.value.length === 1) {
560
- push({
561
- type: "text",
562
- value,
563
- output: `\\${value}`
564
- });
565
- continue;
566
- }
567
- if (state.brackets === 0) {
568
- if (opts.strictBrackets === true) throw new SyntaxError(syntaxError("opening", "["));
569
- push({
570
- type: "text",
571
- value,
572
- output: `\\${value}`
573
- });
574
- continue;
575
- }
576
- decrement("brackets");
577
- const prevValue = prev.value.slice(1);
578
- if (prev.posix !== true && prevValue[0] === "^" && !prevValue.includes("/")) value = `/${value}`;
579
- prev.value += value;
580
- append({ value });
581
- if (opts.literalBrackets === false || utils.hasRegexChars(prevValue)) continue;
582
- const escaped = utils.escapeRegex(prev.value);
583
- state.output = state.output.slice(0, -prev.value.length);
584
- if (opts.literalBrackets === true) {
585
- state.output += escaped;
586
- prev.value = escaped;
587
- continue;
588
- }
589
- prev.value = `(${capture}${escaped}|${prev.value})`;
590
- state.output += prev.value;
591
- continue;
592
- }
593
- /**
594
- * Braces
595
- */
596
- if (value === "{" && opts.nobrace !== true) {
597
- increment("braces");
598
- const open = {
599
- type: "brace",
600
- value,
601
- output: "(",
602
- outputIndex: state.output.length,
603
- tokensIndex: state.tokens.length
604
- };
605
- braces.push(open);
606
- push(open);
607
- continue;
608
- }
609
- if (value === "}") {
610
- const brace = braces[braces.length - 1];
611
- if (opts.nobrace === true || !brace) {
612
- push({
613
- type: "text",
614
- value,
615
- output: value
616
- });
617
- continue;
618
- }
619
- let output = ")";
620
- if (brace.dots === true) {
621
- const arr = tokens.slice();
622
- const range = [];
623
- for (let i = arr.length - 1; i >= 0; i--) {
624
- tokens.pop();
625
- if (arr[i].type === "brace") break;
626
- if (arr[i].type !== "dots") range.unshift(arr[i].value);
627
- }
628
- output = expandRange(range, opts);
629
- state.backtrack = true;
630
- }
631
- if (brace.comma !== true && brace.dots !== true) {
632
- const out = state.output.slice(0, brace.outputIndex);
633
- const toks = state.tokens.slice(brace.tokensIndex);
634
- brace.value = brace.output = "\\{";
635
- value = output = "\\}";
636
- state.output = out;
637
- for (const t of toks) state.output += t.output || t.value;
638
- }
639
- push({
640
- type: "brace",
641
- value,
642
- output
643
- });
644
- decrement("braces");
645
- braces.pop();
646
- continue;
647
- }
648
- /**
649
- * Pipes
650
- */
651
- if (value === "|") {
652
- if (extglobs.length > 0) extglobs[extglobs.length - 1].conditions++;
653
- push({
654
- type: "text",
655
- value
656
- });
657
- continue;
658
- }
659
- /**
660
- * Commas
661
- */
662
- if (value === ",") {
663
- let output = value;
664
- const brace = braces[braces.length - 1];
665
- if (brace && stack[stack.length - 1] === "braces") {
666
- brace.comma = true;
667
- output = "|";
668
- }
669
- push({
670
- type: "comma",
671
- value,
672
- output
673
- });
674
- continue;
675
- }
676
- /**
677
- * Slashes
678
- */
679
- if (value === "/") {
680
- if (prev.type === "dot" && state.index === state.start + 1) {
681
- state.start = state.index + 1;
682
- state.consumed = "";
683
- state.output = "";
684
- tokens.pop();
685
- prev = bos;
686
- continue;
687
- }
688
- push({
689
- type: "slash",
690
- value,
691
- output: SLASH_LITERAL
692
- });
693
- continue;
694
- }
695
- /**
696
- * Dots
697
- */
698
- if (value === ".") {
699
- if (state.braces > 0 && prev.type === "dot") {
700
- if (prev.value === ".") prev.output = DOT_LITERAL;
701
- const brace = braces[braces.length - 1];
702
- prev.type = "dots";
703
- prev.output += value;
704
- prev.value += value;
705
- brace.dots = true;
706
- continue;
707
- }
708
- if (state.braces + state.parens === 0 && prev.type !== "bos" && prev.type !== "slash") {
709
- push({
710
- type: "text",
711
- value,
712
- output: DOT_LITERAL
713
- });
714
- continue;
715
- }
716
- push({
717
- type: "dot",
718
- value,
719
- output: DOT_LITERAL
720
- });
721
- continue;
722
- }
723
- /**
724
- * Question marks
725
- */
726
- if (value === "?") {
727
- if (!(prev && prev.value === "(") && opts.noextglob !== true && peek() === "(" && peek(2) !== "?") {
728
- extglobOpen("qmark", value);
729
- continue;
730
- }
731
- if (prev && prev.type === "paren") {
732
- const next = peek();
733
- let output = value;
734
- if (next === "<" && !utils.supportsLookbehinds()) throw new Error("Node.js v10 or higher is required for regex lookbehinds");
735
- if (prev.value === "(" && !/[!=<:]/.test(next) || next === "<" && !/<([!=]|\w+>)/.test(remaining())) output = `\\${value}`;
736
- push({
737
- type: "text",
738
- value,
739
- output
740
- });
741
- continue;
742
- }
743
- if (opts.dot !== true && (prev.type === "slash" || prev.type === "bos")) {
744
- push({
745
- type: "qmark",
746
- value,
747
- output: QMARK_NO_DOT
748
- });
749
- continue;
750
- }
751
- push({
752
- type: "qmark",
753
- value,
754
- output: QMARK
755
- });
756
- continue;
757
- }
758
- /**
759
- * Exclamation
760
- */
761
- if (value === "!") {
762
- if (opts.noextglob !== true && peek() === "(") {
763
- if (peek(2) !== "?" || !/[!=<:]/.test(peek(3))) {
764
- extglobOpen("negate", value);
765
- continue;
766
- }
767
- }
768
- if (opts.nonegate !== true && state.index === 0) {
769
- negate();
770
- continue;
771
- }
772
- }
773
- /**
774
- * Plus
775
- */
776
- if (value === "+") {
777
- if (opts.noextglob !== true && peek() === "(" && peek(2) !== "?") {
778
- extglobOpen("plus", value);
779
- continue;
780
- }
781
- if (prev && prev.value === "(" || opts.regex === false) {
782
- push({
783
- type: "plus",
784
- value,
785
- output: PLUS_LITERAL
786
- });
787
- continue;
788
- }
789
- if (prev && (prev.type === "bracket" || prev.type === "paren" || prev.type === "brace") || state.parens > 0) {
790
- push({
791
- type: "plus",
792
- value
793
- });
794
- continue;
795
- }
796
- push({
797
- type: "plus",
798
- value: PLUS_LITERAL
799
- });
800
- continue;
801
- }
802
- /**
803
- * Plain text
804
- */
805
- if (value === "@") {
806
- if (opts.noextglob !== true && peek() === "(" && peek(2) !== "?") {
807
- push({
808
- type: "at",
809
- extglob: true,
810
- value,
811
- output: ""
812
- });
813
- continue;
814
- }
815
- push({
816
- type: "text",
817
- value
818
- });
819
- continue;
820
- }
821
- /**
822
- * Plain text
823
- */
824
- if (value !== "*") {
825
- if (value === "$" || value === "^") value = `\\${value}`;
826
- const match = REGEX_NON_SPECIAL_CHARS.exec(remaining());
827
- if (match) {
828
- value += match[0];
829
- state.index += match[0].length;
830
- }
831
- push({
832
- type: "text",
833
- value
834
- });
835
- continue;
836
- }
837
- /**
838
- * Stars
839
- */
840
- if (prev && (prev.type === "globstar" || prev.star === true)) {
841
- prev.type = "star";
842
- prev.star = true;
843
- prev.value += value;
844
- prev.output = star;
845
- state.backtrack = true;
846
- state.globstar = true;
847
- consume(value);
848
- continue;
849
- }
850
- let rest = remaining();
851
- if (opts.noextglob !== true && /^\([^?]/.test(rest)) {
852
- extglobOpen("star", value);
853
- continue;
854
- }
855
- if (prev.type === "star") {
856
- if (opts.noglobstar === true) {
857
- consume(value);
858
- continue;
859
- }
860
- const prior = prev.prev;
861
- const before = prior.prev;
862
- const isStart = prior.type === "slash" || prior.type === "bos";
863
- const afterStar = before && (before.type === "star" || before.type === "globstar");
864
- if (opts.bash === true && (!isStart || rest[0] && rest[0] !== "/")) {
865
- push({
866
- type: "star",
867
- value,
868
- output: ""
869
- });
870
- continue;
871
- }
872
- const isBrace = state.braces > 0 && (prior.type === "comma" || prior.type === "brace");
873
- const isExtglob = extglobs.length && (prior.type === "pipe" || prior.type === "paren");
874
- if (!isStart && prior.type !== "paren" && !isBrace && !isExtglob) {
875
- push({
876
- type: "star",
877
- value,
878
- output: ""
879
- });
880
- continue;
881
- }
882
- while (rest.slice(0, 3) === "/**") {
883
- const after = input[state.index + 4];
884
- if (after && after !== "/") break;
885
- rest = rest.slice(3);
886
- consume("/**", 3);
887
- }
888
- if (prior.type === "bos" && eos()) {
889
- prev.type = "globstar";
890
- prev.value += value;
891
- prev.output = globstar(opts);
892
- state.output = prev.output;
893
- state.globstar = true;
894
- consume(value);
895
- continue;
896
- }
897
- if (prior.type === "slash" && prior.prev.type !== "bos" && !afterStar && eos()) {
898
- state.output = state.output.slice(0, -(prior.output + prev.output).length);
899
- prior.output = `(?:${prior.output}`;
900
- prev.type = "globstar";
901
- prev.output = globstar(opts) + (opts.strictSlashes ? ")" : "|$)");
902
- prev.value += value;
903
- state.globstar = true;
904
- state.output += prior.output + prev.output;
905
- consume(value);
906
- continue;
907
- }
908
- if (prior.type === "slash" && prior.prev.type !== "bos" && rest[0] === "/") {
909
- const end = rest[1] !== void 0 ? "|$" : "";
910
- state.output = state.output.slice(0, -(prior.output + prev.output).length);
911
- prior.output = `(?:${prior.output}`;
912
- prev.type = "globstar";
913
- prev.output = `${globstar(opts)}${SLASH_LITERAL}|${SLASH_LITERAL}${end})`;
914
- prev.value += value;
915
- state.output += prior.output + prev.output;
916
- state.globstar = true;
917
- consume(value + advance());
918
- push({
919
- type: "slash",
920
- value: "/",
921
- output: ""
922
- });
923
- continue;
924
- }
925
- if (prior.type === "bos" && rest[0] === "/") {
926
- prev.type = "globstar";
927
- prev.value += value;
928
- prev.output = `(?:^|${SLASH_LITERAL}|${globstar(opts)}${SLASH_LITERAL})`;
929
- state.output = prev.output;
930
- state.globstar = true;
931
- consume(value + advance());
932
- push({
933
- type: "slash",
934
- value: "/",
935
- output: ""
936
- });
937
- continue;
938
- }
939
- state.output = state.output.slice(0, -prev.output.length);
940
- prev.type = "globstar";
941
- prev.output = globstar(opts);
942
- prev.value += value;
943
- state.output += prev.output;
944
- state.globstar = true;
945
- consume(value);
946
- continue;
947
- }
948
- const token = {
949
- type: "star",
950
- value,
951
- output: star
952
- };
953
- if (opts.bash === true) {
954
- token.output = ".*?";
955
- if (prev.type === "bos" || prev.type === "slash") token.output = nodot + token.output;
956
- push(token);
957
- continue;
958
- }
959
- if (prev && (prev.type === "bracket" || prev.type === "paren") && opts.regex === true) {
960
- token.output = value;
961
- push(token);
962
- continue;
963
- }
964
- if (state.index === state.start || prev.type === "slash" || prev.type === "dot") {
965
- if (prev.type === "dot") {
966
- state.output += NO_DOT_SLASH;
967
- prev.output += NO_DOT_SLASH;
968
- } else if (opts.dot === true) {
969
- state.output += NO_DOTS_SLASH;
970
- prev.output += NO_DOTS_SLASH;
971
- } else {
972
- state.output += nodot;
973
- prev.output += nodot;
974
- }
975
- if (peek() !== "*") {
976
- state.output += ONE_CHAR;
977
- prev.output += ONE_CHAR;
978
- }
979
- }
980
- push(token);
981
- }
982
- while (state.brackets > 0) {
983
- if (opts.strictBrackets === true) throw new SyntaxError(syntaxError("closing", "]"));
984
- state.output = utils.escapeLast(state.output, "[");
985
- decrement("brackets");
986
- }
987
- while (state.parens > 0) {
988
- if (opts.strictBrackets === true) throw new SyntaxError(syntaxError("closing", ")"));
989
- state.output = utils.escapeLast(state.output, "(");
990
- decrement("parens");
991
- }
992
- while (state.braces > 0) {
993
- if (opts.strictBrackets === true) throw new SyntaxError(syntaxError("closing", "}"));
994
- state.output = utils.escapeLast(state.output, "{");
995
- decrement("braces");
996
- }
997
- if (opts.strictSlashes !== true && (prev.type === "star" || prev.type === "bracket")) push({
998
- type: "maybe_slash",
999
- value: "",
1000
- output: `${SLASH_LITERAL}?`
1001
- });
1002
- if (state.backtrack === true) {
1003
- state.output = "";
1004
- for (const token of state.tokens) {
1005
- state.output += token.output != null ? token.output : token.value;
1006
- if (token.suffix) state.output += token.suffix;
1007
- }
1008
- }
1009
- return state;
1010
- };
1011
- /**
1012
- * Fast paths for creating regular expressions for common glob patterns.
1013
- * This can significantly speed up processing and has very little downside
1014
- * impact when none of the fast paths match.
1015
- */
1016
- parse.fastpaths = (input, options) => {
1017
- const opts = { ...options };
1018
- const max = typeof opts.maxLength === "number" ? Math.min(MAX_LENGTH, opts.maxLength) : MAX_LENGTH;
1019
- const len = input.length;
1020
- if (len > max) throw new SyntaxError(`Input length: ${len}, exceeds maximum allowed length: ${max}`);
1021
- input = REPLACEMENTS[input] || input;
1022
- const win32 = utils.isWindows(options);
1023
- const { DOT_LITERAL, SLASH_LITERAL, ONE_CHAR, DOTS_SLASH, NO_DOT, NO_DOTS, NO_DOTS_SLASH, STAR, START_ANCHOR } = constants.globChars(win32);
1024
- const nodot = opts.dot ? NO_DOTS : NO_DOT;
1025
- const slashDot = opts.dot ? NO_DOTS_SLASH : NO_DOT;
1026
- const capture = opts.capture ? "" : "?:";
1027
- const state = {
1028
- negated: false,
1029
- prefix: ""
1030
- };
1031
- let star = opts.bash === true ? ".*?" : STAR;
1032
- if (opts.capture) star = `(${star})`;
1033
- const globstar = (opts) => {
1034
- if (opts.noglobstar === true) return star;
1035
- return `(${capture}(?:(?!${START_ANCHOR}${opts.dot ? DOTS_SLASH : DOT_LITERAL}).)*?)`;
1036
- };
1037
- const create = (str) => {
1038
- switch (str) {
1039
- case "*": return `${nodot}${ONE_CHAR}${star}`;
1040
- case ".*": return `${DOT_LITERAL}${ONE_CHAR}${star}`;
1041
- case "*.*": return `${nodot}${star}${DOT_LITERAL}${ONE_CHAR}${star}`;
1042
- case "*/*": return `${nodot}${star}${SLASH_LITERAL}${ONE_CHAR}${slashDot}${star}`;
1043
- case "**": return nodot + globstar(opts);
1044
- case "**/*": return `(?:${nodot}${globstar(opts)}${SLASH_LITERAL})?${slashDot}${ONE_CHAR}${star}`;
1045
- case "**/*.*": return `(?:${nodot}${globstar(opts)}${SLASH_LITERAL})?${slashDot}${star}${DOT_LITERAL}${ONE_CHAR}${star}`;
1046
- case "**/.*": return `(?:${nodot}${globstar(opts)}${SLASH_LITERAL})?${DOT_LITERAL}${ONE_CHAR}${star}`;
1047
- default: {
1048
- const match = /^(.*?)\.(\w+)$/.exec(str);
1049
- if (!match) return;
1050
- const source = create(match[1]);
1051
- if (!source) return;
1052
- return source + DOT_LITERAL + match[2];
1053
- }
1054
- }
1055
- };
1056
- let source = create(utils.removePrefix(input, state));
1057
- if (source && opts.strictSlashes !== true) source += `${SLASH_LITERAL}?`;
1058
- return source;
1059
- };
1060
- module.exports = parse;
1061
- }));
1062
-
1063
- //#endregion
1064
- export default require_parse();
1065
-
1066
- export { require_parse };
1067
- //# sourceMappingURL=parse.mjs.map