@mgdis/core-ui-helpers 1.1.1 → 1.2.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.
Files changed (37) hide show
  1. package/.turbo/turbo-build.log +16 -16
  2. package/CHANGELOG.md +18 -0
  3. package/dist/playwright/index.cjs +11 -5
  4. package/dist/playwright/index.cjs.map +1 -1
  5. package/dist/playwright/index.d.ts +7 -3
  6. package/dist/playwright/index.js +11 -5
  7. package/dist/playwright/index.js.map +1 -1
  8. package/dist/playwright/index.umd.js +11 -5
  9. package/dist/playwright/index.umd.js.map +1 -1
  10. package/dist/stencil/index.cjs +153 -1682
  11. package/dist/stencil/index.cjs.map +1 -1
  12. package/dist/stencil/index.d.ts +113 -2
  13. package/dist/stencil/index.js +152 -1683
  14. package/dist/stencil/index.js.map +1 -1
  15. package/dist/stencil/index.umd.js +352 -1881
  16. package/dist/stencil/index.umd.js.map +1 -1
  17. package/dist/storybook/index.cjs +168 -1705
  18. package/dist/storybook/index.cjs.map +1 -1
  19. package/dist/storybook/index.js +168 -1705
  20. package/dist/storybook/index.js.map +1 -1
  21. package/dist/storybook/index.umd.js +168 -1705
  22. package/dist/storybook/index.umd.js.map +1 -1
  23. package/json-doc.test.json +13 -2
  24. package/package.json +12 -12
  25. package/src/playwright/utils/__snapshots__/utils.spec.ts.snap +3 -3
  26. package/src/playwright/utils/utils.ts +10 -5
  27. package/src/stencil/ide/__snapshots__/cem.spec.ts.snap +248 -0
  28. package/src/stencil/ide/__snapshots__/ide.spec.ts.snap +11 -124
  29. package/src/stencil/ide/cem.spec.ts +35 -0
  30. package/src/stencil/ide/cem.ts +96 -0
  31. package/src/stencil/ide/ide.ts +33 -26
  32. package/src/stencil/ide/index.ts +1 -0
  33. package/src/stencil/index.ts +1 -0
  34. package/src/stencil/normalize-boolean-attributes/index.ts +1 -0
  35. package/src/stencil/normalize-boolean-attributes/normalize-boolean-attributes.spec.ts +63 -0
  36. package/src/stencil/normalize-boolean-attributes/normalize-boolean-attributes.ts +40 -0
  37. package/src/storybook/stencil/__snapshots__/stencil.spec.ts.snap +1 -1
@@ -1,1674 +1,5 @@
1
1
  'use strict';
2
2
 
3
- /*
4
- Stencil Client Platform v4.40.1 | MIT Licensed | https://stenciljs.com
5
- */
6
- var __create = Object.create;
7
- var __defProp = Object.defineProperty;
8
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
9
- var __getOwnPropNames = Object.getOwnPropertyNames;
10
- var __getProtoOf = Object.getPrototypeOf;
11
- var __hasOwnProp = Object.prototype.hasOwnProperty;
12
- var __typeError = (msg) => {
13
- throw TypeError(msg);
14
- };
15
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
16
- var __commonJS = (cb, mod) => function __require() {
17
- return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
18
- };
19
- var __export = (target, all) => {
20
- for (var name in all)
21
- __defProp(target, name, { get: all[name], enumerable: true });
22
- };
23
- var __copyProps = (to, from, except, desc) => {
24
- if (from && typeof from === "object" || typeof from === "function") {
25
- for (let key of __getOwnPropNames(from))
26
- if (!__hasOwnProp.call(to, key) && key !== except)
27
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
28
- }
29
- return to;
30
- };
31
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
32
- // If the importer is in node compatibility mode or this is not an ESM
33
- // file that has been converted to a CommonJS file using a Babel-
34
- // compatible transform (i.e. "__esModule" has not been set), then set
35
- // "default" to the CommonJS "module.exports" for node compatibility.
36
- __defProp(target, "default", { value: mod, enumerable: true }) ,
37
- mod
38
- ));
39
- var __publicField = (obj, key, value) => __defNormalProp(obj, key + "" , value);
40
- var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg);
41
- var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
42
- var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
43
- var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), member.set(obj, value), value);
44
- var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "access private method"), method);
45
-
46
- // node_modules/balanced-match/index.js
47
- var require_balanced_match = __commonJS({
48
- "node_modules/balanced-match/index.js"(exports$1, module) {
49
- module.exports = balanced;
50
- function balanced(a, b, str) {
51
- if (a instanceof RegExp) a = maybeMatch(a, str);
52
- if (b instanceof RegExp) b = maybeMatch(b, str);
53
- var r = range(a, b, str);
54
- return r && {
55
- start: r[0],
56
- end: r[1],
57
- pre: str.slice(0, r[0]),
58
- body: str.slice(r[0] + a.length, r[1]),
59
- post: str.slice(r[1] + b.length)
60
- };
61
- }
62
- function maybeMatch(reg, str) {
63
- var m = str.match(reg);
64
- return m ? m[0] : null;
65
- }
66
- balanced.range = range;
67
- function range(a, b, str) {
68
- var begs, beg, left, right, result;
69
- var ai = str.indexOf(a);
70
- var bi = str.indexOf(b, ai + 1);
71
- var i2 = ai;
72
- if (ai >= 0 && bi > 0) {
73
- if (a === b) {
74
- return [ai, bi];
75
- }
76
- begs = [];
77
- left = str.length;
78
- while (i2 >= 0 && !result) {
79
- if (i2 == ai) {
80
- begs.push(i2);
81
- ai = str.indexOf(a, i2 + 1);
82
- } else if (begs.length == 1) {
83
- result = [begs.pop(), bi];
84
- } else {
85
- beg = begs.pop();
86
- if (beg < left) {
87
- left = beg;
88
- right = bi;
89
- }
90
- bi = str.indexOf(b, i2 + 1);
91
- }
92
- i2 = ai < bi && ai >= 0 ? ai : bi;
93
- }
94
- if (begs.length) {
95
- result = [left, right];
96
- }
97
- }
98
- return result;
99
- }
100
- }
101
- });
102
-
103
- // node_modules/brace-expansion/index.js
104
- var require_brace_expansion = __commonJS({
105
- "node_modules/brace-expansion/index.js"(exports$1, module) {
106
- var balanced = require_balanced_match();
107
- module.exports = expandTop;
108
- var escSlash = "\0SLASH" + Math.random() + "\0";
109
- var escOpen = "\0OPEN" + Math.random() + "\0";
110
- var escClose = "\0CLOSE" + Math.random() + "\0";
111
- var escComma = "\0COMMA" + Math.random() + "\0";
112
- var escPeriod = "\0PERIOD" + Math.random() + "\0";
113
- function numeric(str) {
114
- return parseInt(str, 10) == str ? parseInt(str, 10) : str.charCodeAt(0);
115
- }
116
- function escapeBraces(str) {
117
- return str.split("\\\\").join(escSlash).split("\\{").join(escOpen).split("\\}").join(escClose).split("\\,").join(escComma).split("\\.").join(escPeriod);
118
- }
119
- function unescapeBraces(str) {
120
- return str.split(escSlash).join("\\").split(escOpen).join("{").split(escClose).join("}").split(escComma).join(",").split(escPeriod).join(".");
121
- }
122
- function parseCommaParts(str) {
123
- if (!str)
124
- return [""];
125
- var parts = [];
126
- var m = balanced("{", "}", str);
127
- if (!m)
128
- return str.split(",");
129
- var pre = m.pre;
130
- var body = m.body;
131
- var post = m.post;
132
- var p = pre.split(",");
133
- p[p.length - 1] += "{" + body + "}";
134
- var postParts = parseCommaParts(post);
135
- if (post.length) {
136
- p[p.length - 1] += postParts.shift();
137
- p.push.apply(p, postParts);
138
- }
139
- parts.push.apply(parts, p);
140
- return parts;
141
- }
142
- function expandTop(str) {
143
- if (!str)
144
- return [];
145
- if (str.substr(0, 2) === "{}") {
146
- str = "\\{\\}" + str.substr(2);
147
- }
148
- return expand2(escapeBraces(str), true).map(unescapeBraces);
149
- }
150
- function embrace(str) {
151
- return "{" + str + "}";
152
- }
153
- function isPadded(el) {
154
- return /^-?0\d/.test(el);
155
- }
156
- function lte(i2, y) {
157
- return i2 <= y;
158
- }
159
- function gte(i2, y) {
160
- return i2 >= y;
161
- }
162
- function expand2(str, isTop) {
163
- var expansions = [];
164
- var m = balanced("{", "}", str);
165
- if (!m) return [str];
166
- var pre = m.pre;
167
- var post = m.post.length ? expand2(m.post, false) : [""];
168
- if (/\$$/.test(m.pre)) {
169
- for (var k = 0; k < post.length; k++) {
170
- var expansion = pre + "{" + m.body + "}" + post[k];
171
- expansions.push(expansion);
172
- }
173
- } else {
174
- var isNumericSequence = /^-?\d+\.\.-?\d+(?:\.\.-?\d+)?$/.test(m.body);
175
- var isAlphaSequence = /^[a-zA-Z]\.\.[a-zA-Z](?:\.\.-?\d+)?$/.test(m.body);
176
- var isSequence = isNumericSequence || isAlphaSequence;
177
- var isOptions = m.body.indexOf(",") >= 0;
178
- if (!isSequence && !isOptions) {
179
- if (m.post.match(/,(?!,).*\}/)) {
180
- str = m.pre + "{" + m.body + escClose + m.post;
181
- return expand2(str);
182
- }
183
- return [str];
184
- }
185
- var n;
186
- if (isSequence) {
187
- n = m.body.split(/\.\./);
188
- } else {
189
- n = parseCommaParts(m.body);
190
- if (n.length === 1) {
191
- n = expand2(n[0], false).map(embrace);
192
- if (n.length === 1) {
193
- return post.map(function(p) {
194
- return m.pre + n[0] + p;
195
- });
196
- }
197
- }
198
- }
199
- var N;
200
- if (isSequence) {
201
- var x = numeric(n[0]);
202
- var y = numeric(n[1]);
203
- var width = Math.max(n[0].length, n[1].length);
204
- var incr = n.length == 3 ? Math.abs(numeric(n[2])) : 1;
205
- var test = lte;
206
- var reverse = y < x;
207
- if (reverse) {
208
- incr *= -1;
209
- test = gte;
210
- }
211
- var pad = n.some(isPadded);
212
- N = [];
213
- for (var i2 = x; test(i2, y); i2 += incr) {
214
- var c;
215
- if (isAlphaSequence) {
216
- c = String.fromCharCode(i2);
217
- if (c === "\\")
218
- c = "";
219
- } else {
220
- c = String(i2);
221
- if (pad) {
222
- var need = width - c.length;
223
- if (need > 0) {
224
- var z = new Array(need + 1).join("0");
225
- if (i2 < 0)
226
- c = "-" + z + c.slice(1);
227
- else
228
- c = z + c;
229
- }
230
- }
231
- }
232
- N.push(c);
233
- }
234
- } else {
235
- N = [];
236
- for (var j = 0; j < n.length; j++) {
237
- N.push.apply(N, expand2(n[j], false));
238
- }
239
- }
240
- for (var j = 0; j < N.length; j++) {
241
- for (var k = 0; k < post.length; k++) {
242
- var expansion = pre + N[j] + post[k];
243
- if (!isTop || isSequence || expansion)
244
- expansions.push(expansion);
245
- }
246
- }
247
- }
248
- return expansions;
249
- }
250
- }
251
- });
252
-
253
- // node_modules/minimatch/dist/esm/index.js
254
- var import_brace_expansion = __toESM(require_brace_expansion());
255
-
256
- // node_modules/minimatch/dist/esm/assert-valid-pattern.js
257
- var MAX_PATTERN_LENGTH = 1024 * 64;
258
- var assertValidPattern = (pattern) => {
259
- if (typeof pattern !== "string") {
260
- throw new TypeError("invalid pattern");
261
- }
262
- if (pattern.length > MAX_PATTERN_LENGTH) {
263
- throw new TypeError("pattern is too long");
264
- }
265
- };
266
-
267
- // node_modules/minimatch/dist/esm/brace-expressions.js
268
- var posixClasses = {
269
- "[:alnum:]": ["\\p{L}\\p{Nl}\\p{Nd}", true],
270
- "[:alpha:]": ["\\p{L}\\p{Nl}", true],
271
- "[:ascii:]": ["\\x00-\\x7f", false],
272
- "[:blank:]": ["\\p{Zs}\\t", true],
273
- "[:cntrl:]": ["\\p{Cc}", true],
274
- "[:digit:]": ["\\p{Nd}", true],
275
- "[:graph:]": ["\\p{Z}\\p{C}", true, true],
276
- "[:lower:]": ["\\p{Ll}", true],
277
- "[:print:]": ["\\p{C}", true],
278
- "[:punct:]": ["\\p{P}", true],
279
- "[:space:]": ["\\p{Z}\\t\\r\\n\\v\\f", true],
280
- "[:upper:]": ["\\p{Lu}", true],
281
- "[:word:]": ["\\p{L}\\p{Nl}\\p{Nd}\\p{Pc}", true],
282
- "[:xdigit:]": ["A-Fa-f0-9", false]
283
- };
284
- var braceEscape = (s) => s.replace(/[[\]\\-]/g, "\\$&");
285
- var regexpEscape = (s) => s.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&");
286
- var rangesToString = (ranges) => ranges.join("");
287
- var parseClass = (glob, position) => {
288
- const pos = position;
289
- if (glob.charAt(pos) !== "[") {
290
- throw new Error("not in a brace expression");
291
- }
292
- const ranges = [];
293
- const negs = [];
294
- let i2 = pos + 1;
295
- let sawStart = false;
296
- let uflag = false;
297
- let escaping = false;
298
- let negate = false;
299
- let endPos = pos;
300
- let rangeStart = "";
301
- WHILE: while (i2 < glob.length) {
302
- const c = glob.charAt(i2);
303
- if ((c === "!" || c === "^") && i2 === pos + 1) {
304
- negate = true;
305
- i2++;
306
- continue;
307
- }
308
- if (c === "]" && sawStart && !escaping) {
309
- endPos = i2 + 1;
310
- break;
311
- }
312
- sawStart = true;
313
- if (c === "\\") {
314
- if (!escaping) {
315
- escaping = true;
316
- i2++;
317
- continue;
318
- }
319
- }
320
- if (c === "[" && !escaping) {
321
- for (const [cls, [unip, u, neg]] of Object.entries(posixClasses)) {
322
- if (glob.startsWith(cls, i2)) {
323
- if (rangeStart) {
324
- return ["$.", false, glob.length - pos, true];
325
- }
326
- i2 += cls.length;
327
- if (neg)
328
- negs.push(unip);
329
- else
330
- ranges.push(unip);
331
- uflag = uflag || u;
332
- continue WHILE;
333
- }
334
- }
335
- }
336
- escaping = false;
337
- if (rangeStart) {
338
- if (c > rangeStart) {
339
- ranges.push(braceEscape(rangeStart) + "-" + braceEscape(c));
340
- } else if (c === rangeStart) {
341
- ranges.push(braceEscape(c));
342
- }
343
- rangeStart = "";
344
- i2++;
345
- continue;
346
- }
347
- if (glob.startsWith("-]", i2 + 1)) {
348
- ranges.push(braceEscape(c + "-"));
349
- i2 += 2;
350
- continue;
351
- }
352
- if (glob.startsWith("-", i2 + 1)) {
353
- rangeStart = c;
354
- i2 += 2;
355
- continue;
356
- }
357
- ranges.push(braceEscape(c));
358
- i2++;
359
- }
360
- if (endPos < i2) {
361
- return ["", false, 0, false];
362
- }
363
- if (!ranges.length && !negs.length) {
364
- return ["$.", false, glob.length - pos, true];
365
- }
366
- if (negs.length === 0 && ranges.length === 1 && /^\\?.$/.test(ranges[0]) && !negate) {
367
- const r = ranges[0].length === 2 ? ranges[0].slice(-1) : ranges[0];
368
- return [regexpEscape(r), false, endPos - pos, false];
369
- }
370
- const sranges = "[" + (negate ? "^" : "") + rangesToString(ranges) + "]";
371
- const snegs = "[" + (negate ? "" : "^") + rangesToString(negs) + "]";
372
- const comb = ranges.length && negs.length ? "(" + sranges + "|" + snegs + ")" : ranges.length ? sranges : snegs;
373
- return [comb, uflag, endPos - pos, true];
374
- };
375
-
376
- // node_modules/minimatch/dist/esm/unescape.js
377
- var unescape = (s, { windowsPathsNoEscape = false } = {}) => {
378
- return windowsPathsNoEscape ? s.replace(/\[([^\/\\])\]/g, "$1") : s.replace(/((?!\\).|^)\[([^\/\\])\]/g, "$1$2").replace(/\\([^\/])/g, "$1");
379
- };
380
-
381
- // node_modules/minimatch/dist/esm/ast.js
382
- var types = /* @__PURE__ */ new Set(["!", "?", "+", "*", "@"]);
383
- var isExtglobType = (c) => types.has(c);
384
- var startNoTraversal = "(?!(?:^|/)\\.\\.?(?:$|/))";
385
- var startNoDot = "(?!\\.)";
386
- var addPatternStart = /* @__PURE__ */ new Set(["[", "."]);
387
- var justDots = /* @__PURE__ */ new Set(["..", "."]);
388
- var reSpecials = new Set("().*{}+?[]^$\\!");
389
- var regExpEscape = (s) => s.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&");
390
- var qmark = "[^/]";
391
- var star = qmark + "*?";
392
- var starNoEmpty = qmark + "+?";
393
- var _root, _hasMagic, _uflag, _parts, _parent, _parentIndex, _negs, _filledNegs, _options, _toString, _emptyExt, _AST_instances, fillNegs_fn, _AST_static, parseAST_fn, partsToRegExp_fn, parseGlob_fn;
394
- var _AST = class _AST {
395
- constructor(type, parent, options = {}) {
396
- __privateAdd(this, _AST_instances);
397
- __publicField(this, "type");
398
- __privateAdd(this, _root);
399
- __privateAdd(this, _hasMagic);
400
- __privateAdd(this, _uflag, false);
401
- __privateAdd(this, _parts, []);
402
- __privateAdd(this, _parent);
403
- __privateAdd(this, _parentIndex);
404
- __privateAdd(this, _negs);
405
- __privateAdd(this, _filledNegs, false);
406
- __privateAdd(this, _options);
407
- __privateAdd(this, _toString);
408
- // set to true if it's an extglob with no children
409
- // (which really means one child of '')
410
- __privateAdd(this, _emptyExt, false);
411
- this.type = type;
412
- if (type)
413
- __privateSet(this, _hasMagic, true);
414
- __privateSet(this, _parent, parent);
415
- __privateSet(this, _root, __privateGet(this, _parent) ? __privateGet(__privateGet(this, _parent), _root) : this);
416
- __privateSet(this, _options, __privateGet(this, _root) === this ? options : __privateGet(__privateGet(this, _root), _options));
417
- __privateSet(this, _negs, __privateGet(this, _root) === this ? [] : __privateGet(__privateGet(this, _root), _negs));
418
- if (type === "!" && !__privateGet(__privateGet(this, _root), _filledNegs))
419
- __privateGet(this, _negs).push(this);
420
- __privateSet(this, _parentIndex, __privateGet(this, _parent) ? __privateGet(__privateGet(this, _parent), _parts).length : 0);
421
- }
422
- get hasMagic() {
423
- if (__privateGet(this, _hasMagic) !== void 0)
424
- return __privateGet(this, _hasMagic);
425
- for (const p of __privateGet(this, _parts)) {
426
- if (typeof p === "string")
427
- continue;
428
- if (p.type || p.hasMagic)
429
- return __privateSet(this, _hasMagic, true);
430
- }
431
- return __privateGet(this, _hasMagic);
432
- }
433
- // reconstructs the pattern
434
- toString() {
435
- if (__privateGet(this, _toString) !== void 0)
436
- return __privateGet(this, _toString);
437
- if (!this.type) {
438
- return __privateSet(this, _toString, __privateGet(this, _parts).map((p) => String(p)).join(""));
439
- } else {
440
- return __privateSet(this, _toString, this.type + "(" + __privateGet(this, _parts).map((p) => String(p)).join("|") + ")");
441
- }
442
- }
443
- push(...parts) {
444
- for (const p of parts) {
445
- if (p === "")
446
- continue;
447
- if (typeof p !== "string" && !(p instanceof _AST && __privateGet(p, _parent) === this)) {
448
- throw new Error("invalid part: " + p);
449
- }
450
- __privateGet(this, _parts).push(p);
451
- }
452
- }
453
- toJSON() {
454
- var _a;
455
- const ret = this.type === null ? __privateGet(this, _parts).slice().map((p) => typeof p === "string" ? p : p.toJSON()) : [this.type, ...__privateGet(this, _parts).map((p) => p.toJSON())];
456
- if (this.isStart() && !this.type)
457
- ret.unshift([]);
458
- if (this.isEnd() && (this === __privateGet(this, _root) || __privateGet(__privateGet(this, _root), _filledNegs) && ((_a = __privateGet(this, _parent)) == null ? void 0 : _a.type) === "!")) {
459
- ret.push({});
460
- }
461
- return ret;
462
- }
463
- isStart() {
464
- var _a;
465
- if (__privateGet(this, _root) === this)
466
- return true;
467
- if (!((_a = __privateGet(this, _parent)) == null ? void 0 : _a.isStart()))
468
- return false;
469
- if (__privateGet(this, _parentIndex) === 0)
470
- return true;
471
- const p = __privateGet(this, _parent);
472
- for (let i2 = 0; i2 < __privateGet(this, _parentIndex); i2++) {
473
- const pp = __privateGet(p, _parts)[i2];
474
- if (!(pp instanceof _AST && pp.type === "!")) {
475
- return false;
476
- }
477
- }
478
- return true;
479
- }
480
- isEnd() {
481
- var _a, _b, _c;
482
- if (__privateGet(this, _root) === this)
483
- return true;
484
- if (((_a = __privateGet(this, _parent)) == null ? void 0 : _a.type) === "!")
485
- return true;
486
- if (!((_b = __privateGet(this, _parent)) == null ? void 0 : _b.isEnd()))
487
- return false;
488
- if (!this.type)
489
- return (_c = __privateGet(this, _parent)) == null ? void 0 : _c.isEnd();
490
- const pl = __privateGet(this, _parent) ? __privateGet(__privateGet(this, _parent), _parts).length : 0;
491
- return __privateGet(this, _parentIndex) === pl - 1;
492
- }
493
- copyIn(part) {
494
- if (typeof part === "string")
495
- this.push(part);
496
- else
497
- this.push(part.clone(this));
498
- }
499
- clone(parent) {
500
- const c = new _AST(this.type, parent);
501
- for (const p of __privateGet(this, _parts)) {
502
- c.copyIn(p);
503
- }
504
- return c;
505
- }
506
- static fromGlob(pattern, options = {}) {
507
- var _a;
508
- const ast = new _AST(null, void 0, options);
509
- __privateMethod(_a = _AST, _AST_static, parseAST_fn).call(_a, pattern, ast, 0, options);
510
- return ast;
511
- }
512
- // returns the regular expression if there's magic, or the unescaped
513
- // string if not.
514
- toMMPattern() {
515
- if (this !== __privateGet(this, _root))
516
- return __privateGet(this, _root).toMMPattern();
517
- const glob = this.toString();
518
- const [re, body, hasMagic, uflag] = this.toRegExpSource();
519
- const anyMagic = hasMagic || __privateGet(this, _hasMagic) || __privateGet(this, _options).nocase && !__privateGet(this, _options).nocaseMagicOnly && glob.toUpperCase() !== glob.toLowerCase();
520
- if (!anyMagic) {
521
- return body;
522
- }
523
- const flags = (__privateGet(this, _options).nocase ? "i" : "") + (uflag ? "u" : "");
524
- return Object.assign(new RegExp(`^${re}$`, flags), {
525
- _src: re,
526
- _glob: glob
527
- });
528
- }
529
- get options() {
530
- return __privateGet(this, _options);
531
- }
532
- // returns the string match, the regexp source, whether there's magic
533
- // in the regexp (so a regular expression is required) and whether or
534
- // not the uflag is needed for the regular expression (for posix classes)
535
- // TODO: instead of injecting the start/end at this point, just return
536
- // the BODY of the regexp, along with the start/end portions suitable
537
- // for binding the start/end in either a joined full-path makeRe context
538
- // (where we bind to (^|/), or a standalone matchPart context (where
539
- // we bind to ^, and not /). Otherwise slashes get duped!
540
- //
541
- // In part-matching mode, the start is:
542
- // - if not isStart: nothing
543
- // - if traversal possible, but not allowed: ^(?!\.\.?$)
544
- // - if dots allowed or not possible: ^
545
- // - if dots possible and not allowed: ^(?!\.)
546
- // end is:
547
- // - if not isEnd(): nothing
548
- // - else: $
549
- //
550
- // In full-path matching mode, we put the slash at the START of the
551
- // pattern, so start is:
552
- // - if first pattern: same as part-matching mode
553
- // - if not isStart(): nothing
554
- // - if traversal possible, but not allowed: /(?!\.\.?(?:$|/))
555
- // - if dots allowed or not possible: /
556
- // - if dots possible and not allowed: /(?!\.)
557
- // end is:
558
- // - if last pattern, same as part-matching mode
559
- // - else nothing
560
- //
561
- // Always put the (?:$|/) on negated tails, though, because that has to be
562
- // there to bind the end of the negated pattern portion, and it's easier to
563
- // just stick it in now rather than try to inject it later in the middle of
564
- // the pattern.
565
- //
566
- // We can just always return the same end, and leave it up to the caller
567
- // to know whether it's going to be used joined or in parts.
568
- // And, if the start is adjusted slightly, can do the same there:
569
- // - if not isStart: nothing
570
- // - if traversal possible, but not allowed: (?:/|^)(?!\.\.?$)
571
- // - if dots allowed or not possible: (?:/|^)
572
- // - if dots possible and not allowed: (?:/|^)(?!\.)
573
- //
574
- // But it's better to have a simpler binding without a conditional, for
575
- // performance, so probably better to return both start options.
576
- //
577
- // Then the caller just ignores the end if it's not the first pattern,
578
- // and the start always gets applied.
579
- //
580
- // But that's always going to be $ if it's the ending pattern, or nothing,
581
- // so the caller can just attach $ at the end of the pattern when building.
582
- //
583
- // So the todo is:
584
- // - better detect what kind of start is needed
585
- // - return both flavors of starting pattern
586
- // - attach $ at the end of the pattern when creating the actual RegExp
587
- //
588
- // Ah, but wait, no, that all only applies to the root when the first pattern
589
- // is not an extglob. If the first pattern IS an extglob, then we need all
590
- // that dot prevention biz to live in the extglob portions, because eg
591
- // +(*|.x*) can match .xy but not .yx.
592
- //
593
- // So, return the two flavors if it's #root and the first child is not an
594
- // AST, otherwise leave it to the child AST to handle it, and there,
595
- // use the (?:^|/) style of start binding.
596
- //
597
- // Even simplified further:
598
- // - Since the start for a join is eg /(?!\.) and the start for a part
599
- // is ^(?!\.), we can just prepend (?!\.) to the pattern (either root
600
- // or start or whatever) and prepend ^ or / at the Regexp construction.
601
- toRegExpSource(allowDot) {
602
- var _a;
603
- const dot = allowDot != null ? allowDot : !!__privateGet(this, _options).dot;
604
- if (__privateGet(this, _root) === this)
605
- __privateMethod(this, _AST_instances, fillNegs_fn).call(this);
606
- if (!this.type) {
607
- const noEmpty = this.isStart() && this.isEnd();
608
- const src = __privateGet(this, _parts).map((p) => {
609
- var _a2;
610
- const [re, _, hasMagic, uflag] = typeof p === "string" ? __privateMethod(_a2 = _AST, _AST_static, parseGlob_fn).call(_a2, p, __privateGet(this, _hasMagic), noEmpty) : p.toRegExpSource(allowDot);
611
- __privateSet(this, _hasMagic, __privateGet(this, _hasMagic) || hasMagic);
612
- __privateSet(this, _uflag, __privateGet(this, _uflag) || uflag);
613
- return re;
614
- }).join("");
615
- let start2 = "";
616
- if (this.isStart()) {
617
- if (typeof __privateGet(this, _parts)[0] === "string") {
618
- const dotTravAllowed = __privateGet(this, _parts).length === 1 && justDots.has(__privateGet(this, _parts)[0]);
619
- if (!dotTravAllowed) {
620
- const aps = addPatternStart;
621
- const needNoTrav = (
622
- // dots are allowed, and the pattern starts with [ or .
623
- dot && aps.has(src.charAt(0)) || // the pattern starts with \., and then [ or .
624
- src.startsWith("\\.") && aps.has(src.charAt(2)) || // the pattern starts with \.\., and then [ or .
625
- src.startsWith("\\.\\.") && aps.has(src.charAt(4))
626
- );
627
- const needNoDot = !dot && !allowDot && aps.has(src.charAt(0));
628
- start2 = needNoTrav ? startNoTraversal : needNoDot ? startNoDot : "";
629
- }
630
- }
631
- }
632
- let end = "";
633
- if (this.isEnd() && __privateGet(__privateGet(this, _root), _filledNegs) && ((_a = __privateGet(this, _parent)) == null ? void 0 : _a.type) === "!") {
634
- end = "(?:$|\\/)";
635
- }
636
- const final2 = start2 + src + end;
637
- return [
638
- final2,
639
- unescape(src),
640
- __privateSet(this, _hasMagic, !!__privateGet(this, _hasMagic)),
641
- __privateGet(this, _uflag)
642
- ];
643
- }
644
- const repeated = this.type === "*" || this.type === "+";
645
- const start = this.type === "!" ? "(?:(?!(?:" : "(?:";
646
- let body = __privateMethod(this, _AST_instances, partsToRegExp_fn).call(this, dot);
647
- if (this.isStart() && this.isEnd() && !body && this.type !== "!") {
648
- const s = this.toString();
649
- __privateSet(this, _parts, [s]);
650
- this.type = null;
651
- __privateSet(this, _hasMagic, void 0);
652
- return [s, unescape(this.toString()), false, false];
653
- }
654
- let bodyDotAllowed = !repeated || allowDot || dot || !startNoDot ? "" : __privateMethod(this, _AST_instances, partsToRegExp_fn).call(this, true);
655
- if (bodyDotAllowed === body) {
656
- bodyDotAllowed = "";
657
- }
658
- if (bodyDotAllowed) {
659
- body = `(?:${body})(?:${bodyDotAllowed})*?`;
660
- }
661
- let final = "";
662
- if (this.type === "!" && __privateGet(this, _emptyExt)) {
663
- final = (this.isStart() && !dot ? startNoDot : "") + starNoEmpty;
664
- } else {
665
- const close = this.type === "!" ? (
666
- // !() must match something,but !(x) can match ''
667
- "))" + (this.isStart() && !dot && !allowDot ? startNoDot : "") + star + ")"
668
- ) : this.type === "@" ? ")" : this.type === "?" ? ")?" : this.type === "+" && bodyDotAllowed ? ")" : this.type === "*" && bodyDotAllowed ? `)?` : `)${this.type}`;
669
- final = start + body + close;
670
- }
671
- return [
672
- final,
673
- unescape(body),
674
- __privateSet(this, _hasMagic, !!__privateGet(this, _hasMagic)),
675
- __privateGet(this, _uflag)
676
- ];
677
- }
678
- };
679
- _root = new WeakMap();
680
- _hasMagic = new WeakMap();
681
- _uflag = new WeakMap();
682
- _parts = new WeakMap();
683
- _parent = new WeakMap();
684
- _parentIndex = new WeakMap();
685
- _negs = new WeakMap();
686
- _filledNegs = new WeakMap();
687
- _options = new WeakMap();
688
- _toString = new WeakMap();
689
- _emptyExt = new WeakMap();
690
- _AST_instances = new WeakSet();
691
- fillNegs_fn = function() {
692
- if (this !== __privateGet(this, _root))
693
- throw new Error("should only call on root");
694
- if (__privateGet(this, _filledNegs))
695
- return this;
696
- this.toString();
697
- __privateSet(this, _filledNegs, true);
698
- let n;
699
- while (n = __privateGet(this, _negs).pop()) {
700
- if (n.type !== "!")
701
- continue;
702
- let p = n;
703
- let pp = __privateGet(p, _parent);
704
- while (pp) {
705
- for (let i2 = __privateGet(p, _parentIndex) + 1; !pp.type && i2 < __privateGet(pp, _parts).length; i2++) {
706
- for (const part of __privateGet(n, _parts)) {
707
- if (typeof part === "string") {
708
- throw new Error("string part in extglob AST??");
709
- }
710
- part.copyIn(__privateGet(pp, _parts)[i2]);
711
- }
712
- }
713
- p = pp;
714
- pp = __privateGet(p, _parent);
715
- }
716
- }
717
- return this;
718
- };
719
- _AST_static = new WeakSet();
720
- parseAST_fn = function(str, ast, pos, opt) {
721
- var _a, _b;
722
- let escaping = false;
723
- let inBrace = false;
724
- let braceStart = -1;
725
- let braceNeg = false;
726
- if (ast.type === null) {
727
- let i3 = pos;
728
- let acc2 = "";
729
- while (i3 < str.length) {
730
- const c = str.charAt(i3++);
731
- if (escaping || c === "\\") {
732
- escaping = !escaping;
733
- acc2 += c;
734
- continue;
735
- }
736
- if (inBrace) {
737
- if (i3 === braceStart + 1) {
738
- if (c === "^" || c === "!") {
739
- braceNeg = true;
740
- }
741
- } else if (c === "]" && !(i3 === braceStart + 2 && braceNeg)) {
742
- inBrace = false;
743
- }
744
- acc2 += c;
745
- continue;
746
- } else if (c === "[") {
747
- inBrace = true;
748
- braceStart = i3;
749
- braceNeg = false;
750
- acc2 += c;
751
- continue;
752
- }
753
- if (!opt.noext && isExtglobType(c) && str.charAt(i3) === "(") {
754
- ast.push(acc2);
755
- acc2 = "";
756
- const ext2 = new _AST(c, ast);
757
- i3 = __privateMethod(_a = _AST, _AST_static, parseAST_fn).call(_a, str, ext2, i3, opt);
758
- ast.push(ext2);
759
- continue;
760
- }
761
- acc2 += c;
762
- }
763
- ast.push(acc2);
764
- return i3;
765
- }
766
- let i2 = pos + 1;
767
- let part = new _AST(null, ast);
768
- const parts = [];
769
- let acc = "";
770
- while (i2 < str.length) {
771
- const c = str.charAt(i2++);
772
- if (escaping || c === "\\") {
773
- escaping = !escaping;
774
- acc += c;
775
- continue;
776
- }
777
- if (inBrace) {
778
- if (i2 === braceStart + 1) {
779
- if (c === "^" || c === "!") {
780
- braceNeg = true;
781
- }
782
- } else if (c === "]" && !(i2 === braceStart + 2 && braceNeg)) {
783
- inBrace = false;
784
- }
785
- acc += c;
786
- continue;
787
- } else if (c === "[") {
788
- inBrace = true;
789
- braceStart = i2;
790
- braceNeg = false;
791
- acc += c;
792
- continue;
793
- }
794
- if (isExtglobType(c) && str.charAt(i2) === "(") {
795
- part.push(acc);
796
- acc = "";
797
- const ext2 = new _AST(c, part);
798
- part.push(ext2);
799
- i2 = __privateMethod(_b = _AST, _AST_static, parseAST_fn).call(_b, str, ext2, i2, opt);
800
- continue;
801
- }
802
- if (c === "|") {
803
- part.push(acc);
804
- acc = "";
805
- parts.push(part);
806
- part = new _AST(null, ast);
807
- continue;
808
- }
809
- if (c === ")") {
810
- if (acc === "" && __privateGet(ast, _parts).length === 0) {
811
- __privateSet(ast, _emptyExt, true);
812
- }
813
- part.push(acc);
814
- acc = "";
815
- ast.push(...parts, part);
816
- return i2;
817
- }
818
- acc += c;
819
- }
820
- ast.type = null;
821
- __privateSet(ast, _hasMagic, void 0);
822
- __privateSet(ast, _parts, [str.substring(pos - 1)]);
823
- return i2;
824
- };
825
- partsToRegExp_fn = function(dot) {
826
- return __privateGet(this, _parts).map((p) => {
827
- if (typeof p === "string") {
828
- throw new Error("string type in extglob ast??");
829
- }
830
- const [re, _, _hasMagic2, uflag] = p.toRegExpSource(dot);
831
- __privateSet(this, _uflag, __privateGet(this, _uflag) || uflag);
832
- return re;
833
- }).filter((p) => !(this.isStart() && this.isEnd()) || !!p).join("|");
834
- };
835
- parseGlob_fn = function(glob, hasMagic, noEmpty = false) {
836
- let escaping = false;
837
- let re = "";
838
- let uflag = false;
839
- for (let i2 = 0; i2 < glob.length; i2++) {
840
- const c = glob.charAt(i2);
841
- if (escaping) {
842
- escaping = false;
843
- re += (reSpecials.has(c) ? "\\" : "") + c;
844
- continue;
845
- }
846
- if (c === "\\") {
847
- if (i2 === glob.length - 1) {
848
- re += "\\\\";
849
- } else {
850
- escaping = true;
851
- }
852
- continue;
853
- }
854
- if (c === "[") {
855
- const [src, needUflag, consumed, magic] = parseClass(glob, i2);
856
- if (consumed) {
857
- re += src;
858
- uflag = uflag || needUflag;
859
- i2 += consumed - 1;
860
- hasMagic = hasMagic || magic;
861
- continue;
862
- }
863
- }
864
- if (c === "*") {
865
- if (noEmpty && glob === "*")
866
- re += starNoEmpty;
867
- else
868
- re += star;
869
- hasMagic = true;
870
- continue;
871
- }
872
- if (c === "?") {
873
- re += qmark;
874
- hasMagic = true;
875
- continue;
876
- }
877
- re += regExpEscape(c);
878
- }
879
- return [re, unescape(glob), !!hasMagic, uflag];
880
- };
881
- __privateAdd(_AST, _AST_static);
882
- var AST = _AST;
883
-
884
- // node_modules/minimatch/dist/esm/escape.js
885
- var escape = (s, { windowsPathsNoEscape = false } = {}) => {
886
- return windowsPathsNoEscape ? s.replace(/[?*()[\]]/g, "[$&]") : s.replace(/[?*()[\]\\]/g, "\\$&");
887
- };
888
-
889
- // node_modules/minimatch/dist/esm/index.js
890
- var minimatch = (p, pattern, options = {}) => {
891
- assertValidPattern(pattern);
892
- if (!options.nocomment && pattern.charAt(0) === "#") {
893
- return false;
894
- }
895
- return new Minimatch(pattern, options).match(p);
896
- };
897
- var starDotExtRE = /^\*+([^+@!?\*\[\(]*)$/;
898
- var starDotExtTest = (ext2) => (f) => !f.startsWith(".") && f.endsWith(ext2);
899
- var starDotExtTestDot = (ext2) => (f) => f.endsWith(ext2);
900
- var starDotExtTestNocase = (ext2) => {
901
- ext2 = ext2.toLowerCase();
902
- return (f) => !f.startsWith(".") && f.toLowerCase().endsWith(ext2);
903
- };
904
- var starDotExtTestNocaseDot = (ext2) => {
905
- ext2 = ext2.toLowerCase();
906
- return (f) => f.toLowerCase().endsWith(ext2);
907
- };
908
- var starDotStarRE = /^\*+\.\*+$/;
909
- var starDotStarTest = (f) => !f.startsWith(".") && f.includes(".");
910
- var starDotStarTestDot = (f) => f !== "." && f !== ".." && f.includes(".");
911
- var dotStarRE = /^\.\*+$/;
912
- var dotStarTest = (f) => f !== "." && f !== ".." && f.startsWith(".");
913
- var starRE = /^\*+$/;
914
- var starTest = (f) => f.length !== 0 && !f.startsWith(".");
915
- var starTestDot = (f) => f.length !== 0 && f !== "." && f !== "..";
916
- var qmarksRE = /^\?+([^+@!?\*\[\(]*)?$/;
917
- var qmarksTestNocase = ([$0, ext2 = ""]) => {
918
- const noext = qmarksTestNoExt([$0]);
919
- if (!ext2)
920
- return noext;
921
- ext2 = ext2.toLowerCase();
922
- return (f) => noext(f) && f.toLowerCase().endsWith(ext2);
923
- };
924
- var qmarksTestNocaseDot = ([$0, ext2 = ""]) => {
925
- const noext = qmarksTestNoExtDot([$0]);
926
- if (!ext2)
927
- return noext;
928
- ext2 = ext2.toLowerCase();
929
- return (f) => noext(f) && f.toLowerCase().endsWith(ext2);
930
- };
931
- var qmarksTestDot = ([$0, ext2 = ""]) => {
932
- const noext = qmarksTestNoExtDot([$0]);
933
- return !ext2 ? noext : (f) => noext(f) && f.endsWith(ext2);
934
- };
935
- var qmarksTest = ([$0, ext2 = ""]) => {
936
- const noext = qmarksTestNoExt([$0]);
937
- return !ext2 ? noext : (f) => noext(f) && f.endsWith(ext2);
938
- };
939
- var qmarksTestNoExt = ([$0]) => {
940
- const len = $0.length;
941
- return (f) => f.length === len && !f.startsWith(".");
942
- };
943
- var qmarksTestNoExtDot = ([$0]) => {
944
- const len = $0.length;
945
- return (f) => f.length === len && f !== "." && f !== "..";
946
- };
947
- var defaultPlatform = typeof process === "object" && process ? typeof process.env === "object" && process.env && process.env.__MINIMATCH_TESTING_PLATFORM__ || process.platform : "posix";
948
- var path = {
949
- win32: { sep: "\\" },
950
- posix: { sep: "/" }
951
- };
952
- var sep = defaultPlatform === "win32" ? path.win32.sep : path.posix.sep;
953
- minimatch.sep = sep;
954
- var GLOBSTAR = Symbol("globstar **");
955
- minimatch.GLOBSTAR = GLOBSTAR;
956
- var qmark2 = "[^/]";
957
- var star2 = qmark2 + "*?";
958
- var twoStarDot = "(?:(?!(?:\\/|^)(?:\\.{1,2})($|\\/)).)*?";
959
- var twoStarNoDot = "(?:(?!(?:\\/|^)\\.).)*?";
960
- var filter = (pattern, options = {}) => (p) => minimatch(p, pattern, options);
961
- minimatch.filter = filter;
962
- var ext = (a, b = {}) => Object.assign({}, a, b);
963
- var defaults = (def) => {
964
- if (!def || typeof def !== "object" || !Object.keys(def).length) {
965
- return minimatch;
966
- }
967
- const orig = minimatch;
968
- const m = (p, pattern, options = {}) => orig(p, pattern, ext(def, options));
969
- return Object.assign(m, {
970
- Minimatch: class Minimatch extends orig.Minimatch {
971
- constructor(pattern, options = {}) {
972
- super(pattern, ext(def, options));
973
- }
974
- static defaults(options) {
975
- return orig.defaults(ext(def, options)).Minimatch;
976
- }
977
- },
978
- AST: class AST extends orig.AST {
979
- /* c8 ignore start */
980
- constructor(type, parent, options = {}) {
981
- super(type, parent, ext(def, options));
982
- }
983
- /* c8 ignore stop */
984
- static fromGlob(pattern, options = {}) {
985
- return orig.AST.fromGlob(pattern, ext(def, options));
986
- }
987
- },
988
- unescape: (s, options = {}) => orig.unescape(s, ext(def, options)),
989
- escape: (s, options = {}) => orig.escape(s, ext(def, options)),
990
- filter: (pattern, options = {}) => orig.filter(pattern, ext(def, options)),
991
- defaults: (options) => orig.defaults(ext(def, options)),
992
- makeRe: (pattern, options = {}) => orig.makeRe(pattern, ext(def, options)),
993
- braceExpand: (pattern, options = {}) => orig.braceExpand(pattern, ext(def, options)),
994
- match: (list, pattern, options = {}) => orig.match(list, pattern, ext(def, options)),
995
- sep: orig.sep,
996
- GLOBSTAR
997
- });
998
- };
999
- minimatch.defaults = defaults;
1000
- var braceExpand = (pattern, options = {}) => {
1001
- assertValidPattern(pattern);
1002
- if (options.nobrace || !/\{(?:(?!\{).)*\}/.test(pattern)) {
1003
- return [pattern];
1004
- }
1005
- return (0, import_brace_expansion.default)(pattern);
1006
- };
1007
- minimatch.braceExpand = braceExpand;
1008
- var makeRe = (pattern, options = {}) => new Minimatch(pattern, options).makeRe();
1009
- minimatch.makeRe = makeRe;
1010
- var match = (list, pattern, options = {}) => {
1011
- const mm = new Minimatch(pattern, options);
1012
- list = list.filter((f) => mm.match(f));
1013
- if (mm.options.nonull && !list.length) {
1014
- list.push(pattern);
1015
- }
1016
- return list;
1017
- };
1018
- minimatch.match = match;
1019
- var globMagic = /[?*]|[+@!]\(.*?\)|\[|\]/;
1020
- var regExpEscape2 = (s) => s.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&");
1021
- var Minimatch = class {
1022
- options;
1023
- set;
1024
- pattern;
1025
- windowsPathsNoEscape;
1026
- nonegate;
1027
- negate;
1028
- comment;
1029
- empty;
1030
- preserveMultipleSlashes;
1031
- partial;
1032
- globSet;
1033
- globParts;
1034
- nocase;
1035
- isWindows;
1036
- platform;
1037
- windowsNoMagicRoot;
1038
- regexp;
1039
- constructor(pattern, options = {}) {
1040
- assertValidPattern(pattern);
1041
- options = options || {};
1042
- this.options = options;
1043
- this.pattern = pattern;
1044
- this.platform = options.platform || defaultPlatform;
1045
- this.isWindows = this.platform === "win32";
1046
- this.windowsPathsNoEscape = !!options.windowsPathsNoEscape || options.allowWindowsEscape === false;
1047
- if (this.windowsPathsNoEscape) {
1048
- this.pattern = this.pattern.replace(/\\/g, "/");
1049
- }
1050
- this.preserveMultipleSlashes = !!options.preserveMultipleSlashes;
1051
- this.regexp = null;
1052
- this.negate = false;
1053
- this.nonegate = !!options.nonegate;
1054
- this.comment = false;
1055
- this.empty = false;
1056
- this.partial = !!options.partial;
1057
- this.nocase = !!this.options.nocase;
1058
- this.windowsNoMagicRoot = options.windowsNoMagicRoot !== void 0 ? options.windowsNoMagicRoot : !!(this.isWindows && this.nocase);
1059
- this.globSet = [];
1060
- this.globParts = [];
1061
- this.set = [];
1062
- this.make();
1063
- }
1064
- hasMagic() {
1065
- if (this.options.magicalBraces && this.set.length > 1) {
1066
- return true;
1067
- }
1068
- for (const pattern of this.set) {
1069
- for (const part of pattern) {
1070
- if (typeof part !== "string")
1071
- return true;
1072
- }
1073
- }
1074
- return false;
1075
- }
1076
- debug(..._) {
1077
- }
1078
- make() {
1079
- const pattern = this.pattern;
1080
- const options = this.options;
1081
- if (!options.nocomment && pattern.charAt(0) === "#") {
1082
- this.comment = true;
1083
- return;
1084
- }
1085
- if (!pattern) {
1086
- this.empty = true;
1087
- return;
1088
- }
1089
- this.parseNegate();
1090
- this.globSet = [...new Set(this.braceExpand())];
1091
- if (options.debug) {
1092
- this.debug = (...args) => console.error(...args);
1093
- }
1094
- this.debug(this.pattern, this.globSet);
1095
- const rawGlobParts = this.globSet.map((s) => this.slashSplit(s));
1096
- this.globParts = this.preprocess(rawGlobParts);
1097
- this.debug(this.pattern, this.globParts);
1098
- let set = this.globParts.map((s, _, __) => {
1099
- if (this.isWindows && this.windowsNoMagicRoot) {
1100
- const isUNC = s[0] === "" && s[1] === "" && (s[2] === "?" || !globMagic.test(s[2])) && !globMagic.test(s[3]);
1101
- const isDrive = /^[a-z]:/i.test(s[0]);
1102
- if (isUNC) {
1103
- return [...s.slice(0, 4), ...s.slice(4).map((ss) => this.parse(ss))];
1104
- } else if (isDrive) {
1105
- return [s[0], ...s.slice(1).map((ss) => this.parse(ss))];
1106
- }
1107
- }
1108
- return s.map((ss) => this.parse(ss));
1109
- });
1110
- this.debug(this.pattern, set);
1111
- this.set = set.filter((s) => s.indexOf(false) === -1);
1112
- if (this.isWindows) {
1113
- for (let i2 = 0; i2 < this.set.length; i2++) {
1114
- const p = this.set[i2];
1115
- if (p[0] === "" && p[1] === "" && this.globParts[i2][2] === "?" && typeof p[3] === "string" && /^[a-z]:$/i.test(p[3])) {
1116
- p[2] = "?";
1117
- }
1118
- }
1119
- }
1120
- this.debug(this.pattern, this.set);
1121
- }
1122
- // various transforms to equivalent pattern sets that are
1123
- // faster to process in a filesystem walk. The goal is to
1124
- // eliminate what we can, and push all ** patterns as far
1125
- // to the right as possible, even if it increases the number
1126
- // of patterns that we have to process.
1127
- preprocess(globParts) {
1128
- if (this.options.noglobstar) {
1129
- for (let i2 = 0; i2 < globParts.length; i2++) {
1130
- for (let j = 0; j < globParts[i2].length; j++) {
1131
- if (globParts[i2][j] === "**") {
1132
- globParts[i2][j] = "*";
1133
- }
1134
- }
1135
- }
1136
- }
1137
- const { optimizationLevel = 1 } = this.options;
1138
- if (optimizationLevel >= 2) {
1139
- globParts = this.firstPhasePreProcess(globParts);
1140
- globParts = this.secondPhasePreProcess(globParts);
1141
- } else if (optimizationLevel >= 1) {
1142
- globParts = this.levelOneOptimize(globParts);
1143
- } else {
1144
- globParts = this.adjascentGlobstarOptimize(globParts);
1145
- }
1146
- return globParts;
1147
- }
1148
- // just get rid of adjascent ** portions
1149
- adjascentGlobstarOptimize(globParts) {
1150
- return globParts.map((parts) => {
1151
- let gs = -1;
1152
- while (-1 !== (gs = parts.indexOf("**", gs + 1))) {
1153
- let i2 = gs;
1154
- while (parts[i2 + 1] === "**") {
1155
- i2++;
1156
- }
1157
- if (i2 !== gs) {
1158
- parts.splice(gs, i2 - gs);
1159
- }
1160
- }
1161
- return parts;
1162
- });
1163
- }
1164
- // get rid of adjascent ** and resolve .. portions
1165
- levelOneOptimize(globParts) {
1166
- return globParts.map((parts) => {
1167
- parts = parts.reduce((set, part) => {
1168
- const prev = set[set.length - 1];
1169
- if (part === "**" && prev === "**") {
1170
- return set;
1171
- }
1172
- if (part === "..") {
1173
- if (prev && prev !== ".." && prev !== "." && prev !== "**") {
1174
- set.pop();
1175
- return set;
1176
- }
1177
- }
1178
- set.push(part);
1179
- return set;
1180
- }, []);
1181
- return parts.length === 0 ? [""] : parts;
1182
- });
1183
- }
1184
- levelTwoFileOptimize(parts) {
1185
- if (!Array.isArray(parts)) {
1186
- parts = this.slashSplit(parts);
1187
- }
1188
- let didSomething = false;
1189
- do {
1190
- didSomething = false;
1191
- if (!this.preserveMultipleSlashes) {
1192
- for (let i2 = 1; i2 < parts.length - 1; i2++) {
1193
- const p = parts[i2];
1194
- if (i2 === 1 && p === "" && parts[0] === "")
1195
- continue;
1196
- if (p === "." || p === "") {
1197
- didSomething = true;
1198
- parts.splice(i2, 1);
1199
- i2--;
1200
- }
1201
- }
1202
- if (parts[0] === "." && parts.length === 2 && (parts[1] === "." || parts[1] === "")) {
1203
- didSomething = true;
1204
- parts.pop();
1205
- }
1206
- }
1207
- let dd = 0;
1208
- while (-1 !== (dd = parts.indexOf("..", dd + 1))) {
1209
- const p = parts[dd - 1];
1210
- if (p && p !== "." && p !== ".." && p !== "**") {
1211
- didSomething = true;
1212
- parts.splice(dd - 1, 2);
1213
- dd -= 2;
1214
- }
1215
- }
1216
- } while (didSomething);
1217
- return parts.length === 0 ? [""] : parts;
1218
- }
1219
- // First phase: single-pattern processing
1220
- // <pre> is 1 or more portions
1221
- // <rest> is 1 or more portions
1222
- // <p> is any portion other than ., .., '', or **
1223
- // <e> is . or ''
1224
- //
1225
- // **/.. is *brutal* for filesystem walking performance, because
1226
- // it effectively resets the recursive walk each time it occurs,
1227
- // and ** cannot be reduced out by a .. pattern part like a regexp
1228
- // or most strings (other than .., ., and '') can be.
1229
- //
1230
- // <pre>/**/../<p>/<p>/<rest> -> {<pre>/../<p>/<p>/<rest>,<pre>/**/<p>/<p>/<rest>}
1231
- // <pre>/<e>/<rest> -> <pre>/<rest>
1232
- // <pre>/<p>/../<rest> -> <pre>/<rest>
1233
- // **/**/<rest> -> **/<rest>
1234
- //
1235
- // **/*/<rest> -> */**/<rest> <== not valid because ** doesn't follow
1236
- // this WOULD be allowed if ** did follow symlinks, or * didn't
1237
- firstPhasePreProcess(globParts) {
1238
- let didSomething = false;
1239
- do {
1240
- didSomething = false;
1241
- for (let parts of globParts) {
1242
- let gs = -1;
1243
- while (-1 !== (gs = parts.indexOf("**", gs + 1))) {
1244
- let gss = gs;
1245
- while (parts[gss + 1] === "**") {
1246
- gss++;
1247
- }
1248
- if (gss > gs) {
1249
- parts.splice(gs + 1, gss - gs);
1250
- }
1251
- let next = parts[gs + 1];
1252
- const p = parts[gs + 2];
1253
- const p2 = parts[gs + 3];
1254
- if (next !== "..")
1255
- continue;
1256
- if (!p || p === "." || p === ".." || !p2 || p2 === "." || p2 === "..") {
1257
- continue;
1258
- }
1259
- didSomething = true;
1260
- parts.splice(gs, 1);
1261
- const other = parts.slice(0);
1262
- other[gs] = "**";
1263
- globParts.push(other);
1264
- gs--;
1265
- }
1266
- if (!this.preserveMultipleSlashes) {
1267
- for (let i2 = 1; i2 < parts.length - 1; i2++) {
1268
- const p = parts[i2];
1269
- if (i2 === 1 && p === "" && parts[0] === "")
1270
- continue;
1271
- if (p === "." || p === "") {
1272
- didSomething = true;
1273
- parts.splice(i2, 1);
1274
- i2--;
1275
- }
1276
- }
1277
- if (parts[0] === "." && parts.length === 2 && (parts[1] === "." || parts[1] === "")) {
1278
- didSomething = true;
1279
- parts.pop();
1280
- }
1281
- }
1282
- let dd = 0;
1283
- while (-1 !== (dd = parts.indexOf("..", dd + 1))) {
1284
- const p = parts[dd - 1];
1285
- if (p && p !== "." && p !== ".." && p !== "**") {
1286
- didSomething = true;
1287
- const needDot = dd === 1 && parts[dd + 1] === "**";
1288
- const splin = needDot ? ["."] : [];
1289
- parts.splice(dd - 1, 2, ...splin);
1290
- if (parts.length === 0)
1291
- parts.push("");
1292
- dd -= 2;
1293
- }
1294
- }
1295
- }
1296
- } while (didSomething);
1297
- return globParts;
1298
- }
1299
- // second phase: multi-pattern dedupes
1300
- // {<pre>/*/<rest>,<pre>/<p>/<rest>} -> <pre>/*/<rest>
1301
- // {<pre>/<rest>,<pre>/<rest>} -> <pre>/<rest>
1302
- // {<pre>/**/<rest>,<pre>/<rest>} -> <pre>/**/<rest>
1303
- //
1304
- // {<pre>/**/<rest>,<pre>/**/<p>/<rest>} -> <pre>/**/<rest>
1305
- // ^-- not valid because ** doens't follow symlinks
1306
- secondPhasePreProcess(globParts) {
1307
- for (let i2 = 0; i2 < globParts.length - 1; i2++) {
1308
- for (let j = i2 + 1; j < globParts.length; j++) {
1309
- const matched = this.partsMatch(globParts[i2], globParts[j], !this.preserveMultipleSlashes);
1310
- if (!matched)
1311
- continue;
1312
- globParts[i2] = matched;
1313
- globParts[j] = [];
1314
- }
1315
- }
1316
- return globParts.filter((gs) => gs.length);
1317
- }
1318
- partsMatch(a, b, emptyGSMatch = false) {
1319
- let ai = 0;
1320
- let bi = 0;
1321
- let result = [];
1322
- let which = "";
1323
- while (ai < a.length && bi < b.length) {
1324
- if (a[ai] === b[bi]) {
1325
- result.push(which === "b" ? b[bi] : a[ai]);
1326
- ai++;
1327
- bi++;
1328
- } else if (emptyGSMatch && a[ai] === "**" && b[bi] === a[ai + 1]) {
1329
- result.push(a[ai]);
1330
- ai++;
1331
- } else if (emptyGSMatch && b[bi] === "**" && a[ai] === b[bi + 1]) {
1332
- result.push(b[bi]);
1333
- bi++;
1334
- } else if (a[ai] === "*" && b[bi] && (this.options.dot || !b[bi].startsWith(".")) && b[bi] !== "**") {
1335
- if (which === "b")
1336
- return false;
1337
- which = "a";
1338
- result.push(a[ai]);
1339
- ai++;
1340
- bi++;
1341
- } else if (b[bi] === "*" && a[ai] && (this.options.dot || !a[ai].startsWith(".")) && a[ai] !== "**") {
1342
- if (which === "a")
1343
- return false;
1344
- which = "b";
1345
- result.push(b[bi]);
1346
- ai++;
1347
- bi++;
1348
- } else {
1349
- return false;
1350
- }
1351
- }
1352
- return a.length === b.length && result;
1353
- }
1354
- parseNegate() {
1355
- if (this.nonegate)
1356
- return;
1357
- const pattern = this.pattern;
1358
- let negate = false;
1359
- let negateOffset = 0;
1360
- for (let i2 = 0; i2 < pattern.length && pattern.charAt(i2) === "!"; i2++) {
1361
- negate = !negate;
1362
- negateOffset++;
1363
- }
1364
- if (negateOffset)
1365
- this.pattern = pattern.slice(negateOffset);
1366
- this.negate = negate;
1367
- }
1368
- // set partial to true to test if, for example,
1369
- // "/a/b" matches the start of "/*/b/*/d"
1370
- // Partial means, if you run out of file before you run
1371
- // out of pattern, then that's fine, as long as all
1372
- // the parts match.
1373
- matchOne(file, pattern, partial = false) {
1374
- const options = this.options;
1375
- if (this.isWindows) {
1376
- const fileDrive = typeof file[0] === "string" && /^[a-z]:$/i.test(file[0]);
1377
- const fileUNC = !fileDrive && file[0] === "" && file[1] === "" && file[2] === "?" && /^[a-z]:$/i.test(file[3]);
1378
- const patternDrive = typeof pattern[0] === "string" && /^[a-z]:$/i.test(pattern[0]);
1379
- const patternUNC = !patternDrive && pattern[0] === "" && pattern[1] === "" && pattern[2] === "?" && typeof pattern[3] === "string" && /^[a-z]:$/i.test(pattern[3]);
1380
- const fdi = fileUNC ? 3 : fileDrive ? 0 : void 0;
1381
- const pdi = patternUNC ? 3 : patternDrive ? 0 : void 0;
1382
- if (typeof fdi === "number" && typeof pdi === "number") {
1383
- const [fd, pd] = [file[fdi], pattern[pdi]];
1384
- if (fd.toLowerCase() === pd.toLowerCase()) {
1385
- pattern[pdi] = fd;
1386
- if (pdi > fdi) {
1387
- pattern = pattern.slice(pdi);
1388
- } else if (fdi > pdi) {
1389
- file = file.slice(fdi);
1390
- }
1391
- }
1392
- }
1393
- }
1394
- const { optimizationLevel = 1 } = this.options;
1395
- if (optimizationLevel >= 2) {
1396
- file = this.levelTwoFileOptimize(file);
1397
- }
1398
- this.debug("matchOne", this, { file, pattern });
1399
- this.debug("matchOne", file.length, pattern.length);
1400
- for (var fi = 0, pi = 0, fl = file.length, pl = pattern.length; fi < fl && pi < pl; fi++, pi++) {
1401
- this.debug("matchOne loop");
1402
- var p = pattern[pi];
1403
- var f = file[fi];
1404
- this.debug(pattern, p, f);
1405
- if (p === false) {
1406
- return false;
1407
- }
1408
- if (p === GLOBSTAR) {
1409
- this.debug("GLOBSTAR", [pattern, p, f]);
1410
- var fr = fi;
1411
- var pr = pi + 1;
1412
- if (pr === pl) {
1413
- this.debug("** at the end");
1414
- for (; fi < fl; fi++) {
1415
- if (file[fi] === "." || file[fi] === ".." || !options.dot && file[fi].charAt(0) === ".")
1416
- return false;
1417
- }
1418
- return true;
1419
- }
1420
- while (fr < fl) {
1421
- var swallowee = file[fr];
1422
- this.debug("\nglobstar while", file, fr, pattern, pr, swallowee);
1423
- if (this.matchOne(file.slice(fr), pattern.slice(pr), partial)) {
1424
- this.debug("globstar found match!", fr, fl, swallowee);
1425
- return true;
1426
- } else {
1427
- if (swallowee === "." || swallowee === ".." || !options.dot && swallowee.charAt(0) === ".") {
1428
- this.debug("dot detected!", file, fr, pattern, pr);
1429
- break;
1430
- }
1431
- this.debug("globstar swallow a segment, and continue");
1432
- fr++;
1433
- }
1434
- }
1435
- if (partial) {
1436
- this.debug("\n>>> no match, partial?", file, fr, pattern, pr);
1437
- if (fr === fl) {
1438
- return true;
1439
- }
1440
- }
1441
- return false;
1442
- }
1443
- let hit;
1444
- if (typeof p === "string") {
1445
- hit = f === p;
1446
- this.debug("string match", p, f, hit);
1447
- } else {
1448
- hit = p.test(f);
1449
- this.debug("pattern match", p, f, hit);
1450
- }
1451
- if (!hit)
1452
- return false;
1453
- }
1454
- if (fi === fl && pi === pl) {
1455
- return true;
1456
- } else if (fi === fl) {
1457
- return partial;
1458
- } else if (pi === pl) {
1459
- return fi === fl - 1 && file[fi] === "";
1460
- } else {
1461
- throw new Error("wtf?");
1462
- }
1463
- }
1464
- braceExpand() {
1465
- return braceExpand(this.pattern, this.options);
1466
- }
1467
- parse(pattern) {
1468
- assertValidPattern(pattern);
1469
- const options = this.options;
1470
- if (pattern === "**")
1471
- return GLOBSTAR;
1472
- if (pattern === "")
1473
- return "";
1474
- let m;
1475
- let fastTest = null;
1476
- if (m = pattern.match(starRE)) {
1477
- fastTest = options.dot ? starTestDot : starTest;
1478
- } else if (m = pattern.match(starDotExtRE)) {
1479
- fastTest = (options.nocase ? options.dot ? starDotExtTestNocaseDot : starDotExtTestNocase : options.dot ? starDotExtTestDot : starDotExtTest)(m[1]);
1480
- } else if (m = pattern.match(qmarksRE)) {
1481
- fastTest = (options.nocase ? options.dot ? qmarksTestNocaseDot : qmarksTestNocase : options.dot ? qmarksTestDot : qmarksTest)(m);
1482
- } else if (m = pattern.match(starDotStarRE)) {
1483
- fastTest = options.dot ? starDotStarTestDot : starDotStarTest;
1484
- } else if (m = pattern.match(dotStarRE)) {
1485
- fastTest = dotStarTest;
1486
- }
1487
- const re = AST.fromGlob(pattern, this.options).toMMPattern();
1488
- if (fastTest && typeof re === "object") {
1489
- Reflect.defineProperty(re, "test", { value: fastTest });
1490
- }
1491
- return re;
1492
- }
1493
- makeRe() {
1494
- if (this.regexp || this.regexp === false)
1495
- return this.regexp;
1496
- const set = this.set;
1497
- if (!set.length) {
1498
- this.regexp = false;
1499
- return this.regexp;
1500
- }
1501
- const options = this.options;
1502
- const twoStar = options.noglobstar ? star2 : options.dot ? twoStarDot : twoStarNoDot;
1503
- const flags = new Set(options.nocase ? ["i"] : []);
1504
- let re = set.map((pattern) => {
1505
- const pp = pattern.map((p) => {
1506
- if (p instanceof RegExp) {
1507
- for (const f of p.flags.split(""))
1508
- flags.add(f);
1509
- }
1510
- return typeof p === "string" ? regExpEscape2(p) : p === GLOBSTAR ? GLOBSTAR : p._src;
1511
- });
1512
- pp.forEach((p, i2) => {
1513
- const next = pp[i2 + 1];
1514
- const prev = pp[i2 - 1];
1515
- if (p !== GLOBSTAR || prev === GLOBSTAR) {
1516
- return;
1517
- }
1518
- if (prev === void 0) {
1519
- if (next !== void 0 && next !== GLOBSTAR) {
1520
- pp[i2 + 1] = "(?:\\/|" + twoStar + "\\/)?" + next;
1521
- } else {
1522
- pp[i2] = twoStar;
1523
- }
1524
- } else if (next === void 0) {
1525
- pp[i2 - 1] = prev + "(?:\\/|" + twoStar + ")?";
1526
- } else if (next !== GLOBSTAR) {
1527
- pp[i2 - 1] = prev + "(?:\\/|\\/" + twoStar + "\\/)" + next;
1528
- pp[i2 + 1] = GLOBSTAR;
1529
- }
1530
- });
1531
- return pp.filter((p) => p !== GLOBSTAR).join("/");
1532
- }).join("|");
1533
- const [open, close] = set.length > 1 ? ["(?:", ")"] : ["", ""];
1534
- re = "^" + open + re + close + "$";
1535
- if (this.negate)
1536
- re = "^(?!" + re + ").+$";
1537
- try {
1538
- this.regexp = new RegExp(re, [...flags].join(""));
1539
- } catch (ex) {
1540
- this.regexp = false;
1541
- }
1542
- return this.regexp;
1543
- }
1544
- slashSplit(p) {
1545
- if (this.preserveMultipleSlashes) {
1546
- return p.split("/");
1547
- } else if (this.isWindows && /^\/\/[^\/]+/.test(p)) {
1548
- return ["", ...p.split(/\/+/)];
1549
- } else {
1550
- return p.split(/\/+/);
1551
- }
1552
- }
1553
- match(f, partial = this.partial) {
1554
- this.debug("match", f, this.pattern);
1555
- if (this.comment) {
1556
- return false;
1557
- }
1558
- if (this.empty) {
1559
- return f === "";
1560
- }
1561
- if (f === "/" && partial) {
1562
- return true;
1563
- }
1564
- const options = this.options;
1565
- if (this.isWindows) {
1566
- f = f.split("\\").join("/");
1567
- }
1568
- const ff = this.slashSplit(f);
1569
- this.debug(this.pattern, "split", ff);
1570
- const set = this.set;
1571
- this.debug(this.pattern, "set", set);
1572
- let filename = ff[ff.length - 1];
1573
- if (!filename) {
1574
- for (let i2 = ff.length - 2; !filename && i2 >= 0; i2--) {
1575
- filename = ff[i2];
1576
- }
1577
- }
1578
- for (let i2 = 0; i2 < set.length; i2++) {
1579
- const pattern = set[i2];
1580
- let file = ff;
1581
- if (options.matchBase && pattern.length === 1) {
1582
- file = [filename];
1583
- }
1584
- const hit = this.matchOne(file, pattern, partial);
1585
- if (hit) {
1586
- if (options.flipNegate) {
1587
- return true;
1588
- }
1589
- return !this.negate;
1590
- }
1591
- }
1592
- if (options.flipNegate) {
1593
- return false;
1594
- }
1595
- return this.negate;
1596
- }
1597
- static defaults(def) {
1598
- return minimatch.defaults(def).Minimatch;
1599
- }
1600
- };
1601
- minimatch.AST = AST;
1602
- minimatch.Minimatch = Minimatch;
1603
- minimatch.escape = escape;
1604
- minimatch.unescape = unescape;
1605
-
1606
- // src/utils/regular-expression.ts
1607
- var escapeRegExpSpecialCharacters = (text) => {
1608
- return text.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
1609
- };
1610
-
1611
- // src/utils/result.ts
1612
- var result_exports = {};
1613
- __export(result_exports, {
1614
- err: () => err,
1615
- map: () => map,
1616
- ok: () => ok,
1617
- unwrap: () => unwrap,
1618
- unwrapErr: () => unwrapErr
1619
- });
1620
- var ok = (value) => ({
1621
- isOk: true,
1622
- isErr: false,
1623
- value
1624
- });
1625
- var err = (value) => ({
1626
- isOk: false,
1627
- isErr: true,
1628
- value
1629
- });
1630
- function map(result, fn) {
1631
- if (result.isOk) {
1632
- const val = fn(result.value);
1633
- if (val instanceof Promise) {
1634
- return val.then((newVal) => ok(newVal));
1635
- } else {
1636
- return ok(val);
1637
- }
1638
- }
1639
- if (result.isErr) {
1640
- const value = result.value;
1641
- return err(value);
1642
- }
1643
- throw "should never get here";
1644
- }
1645
- var unwrap = (result) => {
1646
- if (result.isOk) {
1647
- return result.value;
1648
- } else {
1649
- throw result.value;
1650
- }
1651
- };
1652
- var unwrapErr = (result) => {
1653
- if (result.isErr) {
1654
- return result.value;
1655
- } else {
1656
- throw result.value;
1657
- }
1658
- };
1659
- var createSupportsRuleRe = (selector) => {
1660
- const safeSelector2 = escapeRegExpSpecialCharacters(selector);
1661
- return new RegExp(
1662
- // First capture group: match any context before the selector that's not inside @supports selector()
1663
- // Using negative lookahead to avoid matching inside @supports selector(...) condition
1664
- `(^|[^@]|@(?!supports\\s+selector\\s*\\([^{]*?${safeSelector2}))(${safeSelector2}\\b)`,
1665
- "g"
1666
- );
1667
- };
1668
- createSupportsRuleRe("::slotted");
1669
- createSupportsRuleRe(":host");
1670
- createSupportsRuleRe(":host-context");
1671
-
1672
3
  /**
1673
4
  * Retrieve Component Storybook URL from file path
1674
5
  * @param storybookBaseUrl - Storybook Base URL
@@ -1696,52 +27,55 @@ const getSourcesUrl = (sourcesBaseUrl, filePath) => {
1696
27
  return `${sourcesBaseUrl}${filePath}`;
1697
28
  };
1698
29
  /**
1699
- * Get Component element description
30
+ * Get Component element description.
31
+ *
32
+ * Neither WebStorm nor VS Code render the structured `attributes` /
33
+ * `js.properties` arrays in the tag-level quick-doc — they only show this
34
+ * markdown description. So the attribute and property listings have to live
35
+ * here, even though they're redundant with the structured arrays used by the
36
+ * inline autocomplete.
1700
37
  * @param component - Component
1701
38
  * @returns Component element description
1702
39
  */
1703
40
  const getElementDescription = (component) => {
1704
- // Init description
1705
41
  let description = component.overview ? `${component.overview}\n\n` : '';
1706
- // Attributes
1707
42
  const attributes = component.props.filter(({ attr }) => attr !== undefined);
1708
43
  if (attributes.length) {
1709
44
  description += `Attributes:\n`;
1710
45
  description += attributes.map(({ attr, docs }) => `- \`${attr}\`: ${docs}\n`).join('');
1711
46
  description += '\n';
1712
47
  }
1713
- // Properties
1714
48
  const properties = component.props.filter(({ attr }) => attr === undefined);
1715
49
  if (properties.length) {
1716
50
  description += `Properties:\n`;
1717
51
  description += properties.map(({ name, docs }) => `- \`${name}\`: ${docs}\n`).join('');
1718
52
  description += '\n';
1719
53
  }
1720
- // Methods
1721
54
  if (component.methods.length) {
1722
55
  description += `Methods:\n`;
1723
56
  description += component.methods.map(({ name, docs }) => `- \`${name}\`: ${docs}\n`).join('');
1724
57
  description += '\n';
1725
58
  }
1726
- // Events
1727
59
  if (component.events.length) {
1728
60
  description += `Events:\n`;
1729
61
  description += component.events.map(({ event, docs }) => `- \`${event}\`: ${docs}\n`).join('');
1730
62
  description += '\n';
1731
63
  }
1732
- // Listeners
1733
64
  if (component.listeners.length) {
1734
65
  description += `Listeners:\n`;
1735
66
  description += component.listeners.map(({ event }) => `- \`${event}\`\n`).join('');
1736
67
  description += '\n';
1737
68
  }
1738
- // Slots
1739
69
  if (component.slots.length) {
1740
70
  description += `Slots:\n`;
1741
- description += component.slots.map(({ name, docs }) => `- \`${name}\`: ${docs}\n`).join('');
71
+ description += component.slots
72
+ .map(({ name, docs }) => {
73
+ const label = name ? `\`${name}\`` : 'default';
74
+ return `- ${label}: ${docs}\n`;
75
+ })
76
+ .join('');
1742
77
  description += '\n';
1743
78
  }
1744
- // Return
1745
79
  return description;
1746
80
  };
1747
81
  /**
@@ -1790,7 +124,9 @@ const webTypesGenerator = (name, version, jsonDocs, storybookBaseUrl) => ({
1790
124
  },
1791
125
  })),
1792
126
  'js': {
1793
- properties: component.props.map(prop => ({
127
+ properties: component.props
128
+ .filter(prop => prop.attr === undefined)
129
+ .map(prop => ({
1794
130
  'name': prop.name,
1795
131
  'description': getAttributeDescription(prop),
1796
132
  'doc-url': docUrl,
@@ -1857,8 +193,10 @@ const vsCodeGenerator = (jsonDocs, storybookBaseUrl, sourceBaseUrl) => ({
1857
193
  return {
1858
194
  name: component.tag,
1859
195
  description: getElementDescription(component),
1860
- attributes: component.props.map(prop => ({
1861
- name: prop.attr ?? prop.name,
196
+ attributes: component.props
197
+ .filter(prop => prop.attr !== undefined)
198
+ .map(prop => ({
199
+ name: prop.attr,
1862
200
  description: getAttributeDescription(prop),
1863
201
  values: getValues(prop),
1864
202
  references,
@@ -1886,6 +224,139 @@ const vsCodeCssGenerator = (jsonDocs) => ({
1886
224
  }))),
1887
225
  });
1888
226
 
227
+ /**
228
+ * Convert a Stencil component's JsonDocs into a CEM v2 module entry.
229
+ * @param component - Stencil component doc
230
+ * @returns CEM module
231
+ */
232
+ const componentToModule = (component) => {
233
+ const className = component.tag
234
+ .split('-')
235
+ .map(part => part.charAt(0).toUpperCase() + part.slice(1))
236
+ .join('');
237
+ const attributes = component.props
238
+ .filter(prop => prop.attr !== undefined)
239
+ .map(prop => ({
240
+ name: prop.attr,
241
+ description: prop.docs,
242
+ type: { text: prop.type },
243
+ ...(prop.default !== undefined && { default: prop.default }),
244
+ fieldName: prop.name,
245
+ }));
246
+ const fieldMembers = component.props.map(prop => ({
247
+ kind: 'field',
248
+ name: prop.name,
249
+ description: prop.docs,
250
+ type: { text: prop.type },
251
+ ...(prop.default !== undefined && { default: prop.default }),
252
+ ...(prop.attr !== undefined && { attribute: prop.attr }),
253
+ }));
254
+ const methodMembers = component.methods.map(method => ({
255
+ kind: 'method',
256
+ name: method.name,
257
+ description: method.docs,
258
+ }));
259
+ return {
260
+ kind: 'javascript-module',
261
+ path: component.filePath ?? '',
262
+ declarations: [
263
+ {
264
+ kind: 'class',
265
+ name: className,
266
+ tagName: component.tag,
267
+ customElement: true,
268
+ description: component.overview ?? '',
269
+ attributes,
270
+ members: [...fieldMembers, ...methodMembers],
271
+ events: component.events.map(event => ({
272
+ name: event.event,
273
+ description: event.docs,
274
+ type: { text: `CustomEvent<${event.detail}>` },
275
+ })),
276
+ slots: component.slots.map(slot => ({
277
+ name: slot.name,
278
+ description: slot.docs,
279
+ })),
280
+ cssProperties: component.styles.map(style => ({
281
+ name: style.name,
282
+ description: style.docs,
283
+ })),
284
+ cssParts: component.parts.map(part => ({
285
+ name: part.name,
286
+ description: part.docs,
287
+ })),
288
+ },
289
+ ],
290
+ exports: [
291
+ {
292
+ kind: 'custom-element-definition',
293
+ name: component.tag,
294
+ declaration: {
295
+ name: className,
296
+ module: component.filePath ?? '',
297
+ },
298
+ },
299
+ ],
300
+ };
301
+ };
302
+ /**
303
+ * Generate a Custom Elements Manifest v2 from Stencil JSON docs.
304
+ * @param jsonDocs - Stencil JSON doc
305
+ * @returns CEM v2
306
+ * @example
307
+ * ```ts
308
+ * const cem = cemGenerator(jsonDocs);
309
+ * ```
310
+ */
311
+ const cemGenerator = (jsonDocs) => ({
312
+ schemaVersion: '2.0.0',
313
+ readme: '',
314
+ modules: jsonDocs.components.map(componentToModule),
315
+ });
316
+
317
+ /**
318
+ * Per the HTML spec, a boolean attribute is `true` whenever it is present on the
319
+ * element, regardless of its value (including `="false"`). Stencil's default Prop
320
+ * parser converts the string `"false"` to the boolean `false`, which breaks this
321
+ * contract for consumers writing markup. Call this helper from `componentWillLoad`
322
+ * to re-normalize every present attribute that maps to a boolean-typed Prop.
323
+ *
324
+ * Iterates the host element's attributes and, for each one whose camelCase name
325
+ * matches a `typeof === 'boolean'` Prop on the instance, rewrites the attribute
326
+ * to `''` — Stencil's parser then turns that into `true` via the standard
327
+ * attribute → prop pipeline (no need for `mutable: true` on the Prop, since the
328
+ * write goes through Stencil's internal setter, not through user code).
329
+ *
330
+ * Non-boolean Props and non-Prop attributes (`class`, `id`, ...) are skipped
331
+ * naturally by the type check.
332
+ *
333
+ * @param target - the component instance (must expose `element` via `@Element()`)
334
+ *
335
+ * @example
336
+ * ```typescript
337
+ * @Component({ tag: 'my-input' })
338
+ * export class MyInput {
339
+ * @Element() element: HTMLMyInputElement;
340
+ * @Prop() readonly = false;
341
+ * @Prop() disabled = false;
342
+ *
343
+ * componentWillLoad() {
344
+ * normalizeBooleanAttributes(this);
345
+ * }
346
+ * }
347
+ * ```
348
+ */
349
+ const normalizeBooleanAttributes = (target) => {
350
+ for (const attr of Array.from(target.element.attributes)) {
351
+ const propName = attr.name.replace(/-([a-z])/g, (_, c) => c.toUpperCase());
352
+ if (typeof target[propName] === 'boolean') {
353
+ target.element.setAttribute(attr.name, '');
354
+ }
355
+ }
356
+ };
357
+
358
+ exports.cemGenerator = cemGenerator;
359
+ exports.normalizeBooleanAttributes = normalizeBooleanAttributes;
1889
360
  exports.vsCodeCssGenerator = vsCodeCssGenerator;
1890
361
  exports.vsCodeGenerator = vsCodeGenerator;
1891
362
  exports.webTypesGenerator = webTypesGenerator;