@mgdis/core-ui-helpers 1.1.0 → 1.1.2

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.
@@ -7,264 +7,24 @@
7
7
  // src/app-data/index.ts
8
8
  var BUILD = {
9
9
  updatable: true,
10
- slotRelocation: true,
11
- // TODO(STENCIL-914): remove this option when `experimentalSlotFixes` is the default behavior
12
- experimentalSlotFixes: false
13
- };
10
+ slotRelocation: true};
14
11
 
15
12
  /*
16
- Stencil Client Platform v4.40.1 | MIT Licensed | https://stenciljs.com
13
+ Stencil Client Platform v4.43.4 | MIT Licensed | https://stenciljs.com
17
14
  */
18
- var __create = Object.create;
19
- var __defProp = Object.defineProperty;
20
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
21
- var __getOwnPropNames = Object.getOwnPropertyNames;
22
- var __getProtoOf = Object.getPrototypeOf;
23
- var __hasOwnProp = Object.prototype.hasOwnProperty;
24
- var __typeError = (msg) => {
25
- throw TypeError(msg);
26
- };
27
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
28
- var __commonJS = (cb, mod) => function __require() {
29
- return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
30
- };
31
- var __export = (target, all) => {
32
- for (var name in all)
33
- __defProp(target, name, { get: all[name], enumerable: true });
34
- };
35
- var __copyProps = (to, from, except, desc) => {
36
- if (from && typeof from === "object" || typeof from === "function") {
37
- for (let key of __getOwnPropNames(from))
38
- if (!__hasOwnProp.call(to, key) && key !== except)
39
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
40
- }
41
- return to;
42
- };
43
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
44
- // If the importer is in node compatibility mode or this is not an ESM
45
- // file that has been converted to a CommonJS file using a Babel-
46
- // compatible transform (i.e. "__esModule" has not been set), then set
47
- // "default" to the CommonJS "module.exports" for node compatibility.
48
- __defProp(target, "default", { value: mod, enumerable: true }) ,
49
- mod
50
- ));
51
- var __publicField = (obj, key, value) => __defNormalProp(obj, key + "" , value);
52
- var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg);
53
- var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
54
- 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);
55
- var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), member.set(obj, value), value);
56
- var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "access private method"), method);
57
-
58
- // node_modules/balanced-match/index.js
59
- var require_balanced_match = __commonJS({
60
- "node_modules/balanced-match/index.js"(exports$1, module) {
61
- module.exports = balanced;
62
- function balanced(a, b, str) {
63
- if (a instanceof RegExp) a = maybeMatch(a, str);
64
- if (b instanceof RegExp) b = maybeMatch(b, str);
65
- var r = range(a, b, str);
66
- return r && {
67
- start: r[0],
68
- end: r[1],
69
- pre: str.slice(0, r[0]),
70
- body: str.slice(r[0] + a.length, r[1]),
71
- post: str.slice(r[1] + b.length)
72
- };
73
- }
74
- function maybeMatch(reg, str) {
75
- var m = str.match(reg);
76
- return m ? m[0] : null;
77
- }
78
- balanced.range = range;
79
- function range(a, b, str) {
80
- var begs, beg, left, right, result;
81
- var ai = str.indexOf(a);
82
- var bi = str.indexOf(b, ai + 1);
83
- var i2 = ai;
84
- if (ai >= 0 && bi > 0) {
85
- if (a === b) {
86
- return [ai, bi];
87
- }
88
- begs = [];
89
- left = str.length;
90
- while (i2 >= 0 && !result) {
91
- if (i2 == ai) {
92
- begs.push(i2);
93
- ai = str.indexOf(a, i2 + 1);
94
- } else if (begs.length == 1) {
95
- result = [begs.pop(), bi];
96
- } else {
97
- beg = begs.pop();
98
- if (beg < left) {
99
- left = beg;
100
- right = bi;
101
- }
102
- bi = str.indexOf(b, i2 + 1);
103
- }
104
- i2 = ai < bi && ai >= 0 ? ai : bi;
105
- }
106
- if (begs.length) {
107
- result = [left, right];
108
- }
109
- }
110
- return result;
111
- }
112
- }
113
- });
114
-
115
- // node_modules/brace-expansion/index.js
116
- var require_brace_expansion = __commonJS({
117
- "node_modules/brace-expansion/index.js"(exports$1, module) {
118
- var balanced = require_balanced_match();
119
- module.exports = expandTop;
120
- var escSlash = "\0SLASH" + Math.random() + "\0";
121
- var escOpen = "\0OPEN" + Math.random() + "\0";
122
- var escClose = "\0CLOSE" + Math.random() + "\0";
123
- var escComma = "\0COMMA" + Math.random() + "\0";
124
- var escPeriod = "\0PERIOD" + Math.random() + "\0";
125
- function numeric(str) {
126
- return parseInt(str, 10) == str ? parseInt(str, 10) : str.charCodeAt(0);
127
- }
128
- function escapeBraces(str) {
129
- return str.split("\\\\").join(escSlash).split("\\{").join(escOpen).split("\\}").join(escClose).split("\\,").join(escComma).split("\\.").join(escPeriod);
130
- }
131
- function unescapeBraces(str) {
132
- return str.split(escSlash).join("\\").split(escOpen).join("{").split(escClose).join("}").split(escComma).join(",").split(escPeriod).join(".");
133
- }
134
- function parseCommaParts(str) {
135
- if (!str)
136
- return [""];
137
- var parts = [];
138
- var m = balanced("{", "}", str);
139
- if (!m)
140
- return str.split(",");
141
- var pre = m.pre;
142
- var body = m.body;
143
- var post = m.post;
144
- var p = pre.split(",");
145
- p[p.length - 1] += "{" + body + "}";
146
- var postParts = parseCommaParts(post);
147
- if (post.length) {
148
- p[p.length - 1] += postParts.shift();
149
- p.push.apply(p, postParts);
150
- }
151
- parts.push.apply(parts, p);
152
- return parts;
153
- }
154
- function expandTop(str) {
155
- if (!str)
156
- return [];
157
- if (str.substr(0, 2) === "{}") {
158
- str = "\\{\\}" + str.substr(2);
159
- }
160
- return expand2(escapeBraces(str), true).map(unescapeBraces);
161
- }
162
- function embrace(str) {
163
- return "{" + str + "}";
164
- }
165
- function isPadded(el) {
166
- return /^-?0\d/.test(el);
167
- }
168
- function lte(i2, y) {
169
- return i2 <= y;
170
- }
171
- function gte(i2, y) {
172
- return i2 >= y;
173
- }
174
- function expand2(str, isTop) {
175
- var expansions = [];
176
- var m = balanced("{", "}", str);
177
- if (!m) return [str];
178
- var pre = m.pre;
179
- var post = m.post.length ? expand2(m.post, false) : [""];
180
- if (/\$$/.test(m.pre)) {
181
- for (var k = 0; k < post.length; k++) {
182
- var expansion = pre + "{" + m.body + "}" + post[k];
183
- expansions.push(expansion);
184
- }
185
- } else {
186
- var isNumericSequence = /^-?\d+\.\.-?\d+(?:\.\.-?\d+)?$/.test(m.body);
187
- var isAlphaSequence = /^[a-zA-Z]\.\.[a-zA-Z](?:\.\.-?\d+)?$/.test(m.body);
188
- var isSequence = isNumericSequence || isAlphaSequence;
189
- var isOptions = m.body.indexOf(",") >= 0;
190
- if (!isSequence && !isOptions) {
191
- if (m.post.match(/,(?!,).*\}/)) {
192
- str = m.pre + "{" + m.body + escClose + m.post;
193
- return expand2(str);
194
- }
195
- return [str];
196
- }
197
- var n;
198
- if (isSequence) {
199
- n = m.body.split(/\.\./);
200
- } else {
201
- n = parseCommaParts(m.body);
202
- if (n.length === 1) {
203
- n = expand2(n[0], false).map(embrace);
204
- if (n.length === 1) {
205
- return post.map(function(p) {
206
- return m.pre + n[0] + p;
207
- });
208
- }
209
- }
210
- }
211
- var N;
212
- if (isSequence) {
213
- var x = numeric(n[0]);
214
- var y = numeric(n[1]);
215
- var width = Math.max(n[0].length, n[1].length);
216
- var incr = n.length == 3 ? Math.abs(numeric(n[2])) : 1;
217
- var test = lte;
218
- var reverse = y < x;
219
- if (reverse) {
220
- incr *= -1;
221
- test = gte;
222
- }
223
- var pad = n.some(isPadded);
224
- N = [];
225
- for (var i2 = x; test(i2, y); i2 += incr) {
226
- var c;
227
- if (isAlphaSequence) {
228
- c = String.fromCharCode(i2);
229
- if (c === "\\")
230
- c = "";
231
- } else {
232
- c = String(i2);
233
- if (pad) {
234
- var need = width - c.length;
235
- if (need > 0) {
236
- var z = new Array(need + 1).join("0");
237
- if (i2 < 0)
238
- c = "-" + z + c.slice(1);
239
- else
240
- c = z + c;
241
- }
242
- }
243
- }
244
- N.push(c);
245
- }
246
- } else {
247
- N = [];
248
- for (var j = 0; j < n.length; j++) {
249
- N.push.apply(N, expand2(n[j], false));
250
- }
251
- }
252
- for (var j = 0; j < N.length; j++) {
253
- for (var k = 0; k < post.length; k++) {
254
- var expansion = pre + N[j] + post[k];
255
- if (!isTop || isSequence || expansion)
256
- expansions.push(expansion);
257
- }
258
- }
259
- }
260
- return expansions;
261
- }
262
- }
263
- });
15
+
264
16
 
265
17
  // src/utils/constants.ts
266
18
  var SVG_NS = "http://www.w3.org/2000/svg";
267
19
  var HTML_NS = "http://www.w3.org/1999/xhtml";
20
+
21
+ // src/client/client-host-ref.ts
22
+ var getHostRef = (ref) => {
23
+ if (ref.__stencil__getHostRef) {
24
+ return ref.__stencil__getHostRef();
25
+ }
26
+ return void 0;
27
+ };
268
28
  var isMemberInElement = (elm, memberName) => memberName in elm;
269
29
  var XLINK_NS = "http://www.w3.org/1999/xlink";
270
30
  var win = typeof window !== "undefined" ? window : {};
@@ -277,1420 +37,6 @@
277
37
  rel: (el, eventName, listener, opts) => el.removeEventListener(eventName, listener, opts),
278
38
  ce: (eventName, opts) => new CustomEvent(eventName, opts)
279
39
  };
280
-
281
- // src/utils/helpers.ts
282
- var isDef = (v) => v != null && v !== void 0;
283
- var isComplexType = (o) => {
284
- o = typeof o;
285
- return o === "object" || o === "function";
286
- };
287
-
288
- // node_modules/minimatch/dist/esm/index.js
289
- var import_brace_expansion = __toESM(require_brace_expansion());
290
-
291
- // node_modules/minimatch/dist/esm/assert-valid-pattern.js
292
- var MAX_PATTERN_LENGTH = 1024 * 64;
293
- var assertValidPattern = (pattern) => {
294
- if (typeof pattern !== "string") {
295
- throw new TypeError("invalid pattern");
296
- }
297
- if (pattern.length > MAX_PATTERN_LENGTH) {
298
- throw new TypeError("pattern is too long");
299
- }
300
- };
301
-
302
- // node_modules/minimatch/dist/esm/brace-expressions.js
303
- var posixClasses = {
304
- "[:alnum:]": ["\\p{L}\\p{Nl}\\p{Nd}", true],
305
- "[:alpha:]": ["\\p{L}\\p{Nl}", true],
306
- "[:ascii:]": ["\\x00-\\x7f", false],
307
- "[:blank:]": ["\\p{Zs}\\t", true],
308
- "[:cntrl:]": ["\\p{Cc}", true],
309
- "[:digit:]": ["\\p{Nd}", true],
310
- "[:graph:]": ["\\p{Z}\\p{C}", true, true],
311
- "[:lower:]": ["\\p{Ll}", true],
312
- "[:print:]": ["\\p{C}", true],
313
- "[:punct:]": ["\\p{P}", true],
314
- "[:space:]": ["\\p{Z}\\t\\r\\n\\v\\f", true],
315
- "[:upper:]": ["\\p{Lu}", true],
316
- "[:word:]": ["\\p{L}\\p{Nl}\\p{Nd}\\p{Pc}", true],
317
- "[:xdigit:]": ["A-Fa-f0-9", false]
318
- };
319
- var braceEscape = (s) => s.replace(/[[\]\\-]/g, "\\$&");
320
- var regexpEscape = (s) => s.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&");
321
- var rangesToString = (ranges) => ranges.join("");
322
- var parseClass = (glob, position) => {
323
- const pos = position;
324
- if (glob.charAt(pos) !== "[") {
325
- throw new Error("not in a brace expression");
326
- }
327
- const ranges = [];
328
- const negs = [];
329
- let i2 = pos + 1;
330
- let sawStart = false;
331
- let uflag = false;
332
- let escaping = false;
333
- let negate = false;
334
- let endPos = pos;
335
- let rangeStart = "";
336
- WHILE: while (i2 < glob.length) {
337
- const c = glob.charAt(i2);
338
- if ((c === "!" || c === "^") && i2 === pos + 1) {
339
- negate = true;
340
- i2++;
341
- continue;
342
- }
343
- if (c === "]" && sawStart && !escaping) {
344
- endPos = i2 + 1;
345
- break;
346
- }
347
- sawStart = true;
348
- if (c === "\\") {
349
- if (!escaping) {
350
- escaping = true;
351
- i2++;
352
- continue;
353
- }
354
- }
355
- if (c === "[" && !escaping) {
356
- for (const [cls, [unip, u, neg]] of Object.entries(posixClasses)) {
357
- if (glob.startsWith(cls, i2)) {
358
- if (rangeStart) {
359
- return ["$.", false, glob.length - pos, true];
360
- }
361
- i2 += cls.length;
362
- if (neg)
363
- negs.push(unip);
364
- else
365
- ranges.push(unip);
366
- uflag = uflag || u;
367
- continue WHILE;
368
- }
369
- }
370
- }
371
- escaping = false;
372
- if (rangeStart) {
373
- if (c > rangeStart) {
374
- ranges.push(braceEscape(rangeStart) + "-" + braceEscape(c));
375
- } else if (c === rangeStart) {
376
- ranges.push(braceEscape(c));
377
- }
378
- rangeStart = "";
379
- i2++;
380
- continue;
381
- }
382
- if (glob.startsWith("-]", i2 + 1)) {
383
- ranges.push(braceEscape(c + "-"));
384
- i2 += 2;
385
- continue;
386
- }
387
- if (glob.startsWith("-", i2 + 1)) {
388
- rangeStart = c;
389
- i2 += 2;
390
- continue;
391
- }
392
- ranges.push(braceEscape(c));
393
- i2++;
394
- }
395
- if (endPos < i2) {
396
- return ["", false, 0, false];
397
- }
398
- if (!ranges.length && !negs.length) {
399
- return ["$.", false, glob.length - pos, true];
400
- }
401
- if (negs.length === 0 && ranges.length === 1 && /^\\?.$/.test(ranges[0]) && !negate) {
402
- const r = ranges[0].length === 2 ? ranges[0].slice(-1) : ranges[0];
403
- return [regexpEscape(r), false, endPos - pos, false];
404
- }
405
- const sranges = "[" + (negate ? "^" : "") + rangesToString(ranges) + "]";
406
- const snegs = "[" + (negate ? "" : "^") + rangesToString(negs) + "]";
407
- const comb = ranges.length && negs.length ? "(" + sranges + "|" + snegs + ")" : ranges.length ? sranges : snegs;
408
- return [comb, uflag, endPos - pos, true];
409
- };
410
-
411
- // node_modules/minimatch/dist/esm/unescape.js
412
- var unescape = (s, { windowsPathsNoEscape = false } = {}) => {
413
- return windowsPathsNoEscape ? s.replace(/\[([^\/\\])\]/g, "$1") : s.replace(/((?!\\).|^)\[([^\/\\])\]/g, "$1$2").replace(/\\([^\/])/g, "$1");
414
- };
415
-
416
- // node_modules/minimatch/dist/esm/ast.js
417
- var types = /* @__PURE__ */ new Set(["!", "?", "+", "*", "@"]);
418
- var isExtglobType = (c) => types.has(c);
419
- var startNoTraversal = "(?!(?:^|/)\\.\\.?(?:$|/))";
420
- var startNoDot = "(?!\\.)";
421
- var addPatternStart = /* @__PURE__ */ new Set(["[", "."]);
422
- var justDots = /* @__PURE__ */ new Set(["..", "."]);
423
- var reSpecials = new Set("().*{}+?[]^$\\!");
424
- var regExpEscape = (s) => s.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&");
425
- var qmark = "[^/]";
426
- var star = qmark + "*?";
427
- var starNoEmpty = qmark + "+?";
428
- var _root, _hasMagic, _uflag, _parts, _parent, _parentIndex, _negs, _filledNegs, _options, _toString, _emptyExt, _AST_instances, fillNegs_fn, _AST_static, parseAST_fn, partsToRegExp_fn, parseGlob_fn;
429
- var _AST = class _AST {
430
- constructor(type, parent, options = {}) {
431
- __privateAdd(this, _AST_instances);
432
- __publicField(this, "type");
433
- __privateAdd(this, _root);
434
- __privateAdd(this, _hasMagic);
435
- __privateAdd(this, _uflag, false);
436
- __privateAdd(this, _parts, []);
437
- __privateAdd(this, _parent);
438
- __privateAdd(this, _parentIndex);
439
- __privateAdd(this, _negs);
440
- __privateAdd(this, _filledNegs, false);
441
- __privateAdd(this, _options);
442
- __privateAdd(this, _toString);
443
- // set to true if it's an extglob with no children
444
- // (which really means one child of '')
445
- __privateAdd(this, _emptyExt, false);
446
- this.type = type;
447
- if (type)
448
- __privateSet(this, _hasMagic, true);
449
- __privateSet(this, _parent, parent);
450
- __privateSet(this, _root, __privateGet(this, _parent) ? __privateGet(__privateGet(this, _parent), _root) : this);
451
- __privateSet(this, _options, __privateGet(this, _root) === this ? options : __privateGet(__privateGet(this, _root), _options));
452
- __privateSet(this, _negs, __privateGet(this, _root) === this ? [] : __privateGet(__privateGet(this, _root), _negs));
453
- if (type === "!" && !__privateGet(__privateGet(this, _root), _filledNegs))
454
- __privateGet(this, _negs).push(this);
455
- __privateSet(this, _parentIndex, __privateGet(this, _parent) ? __privateGet(__privateGet(this, _parent), _parts).length : 0);
456
- }
457
- get hasMagic() {
458
- if (__privateGet(this, _hasMagic) !== void 0)
459
- return __privateGet(this, _hasMagic);
460
- for (const p of __privateGet(this, _parts)) {
461
- if (typeof p === "string")
462
- continue;
463
- if (p.type || p.hasMagic)
464
- return __privateSet(this, _hasMagic, true);
465
- }
466
- return __privateGet(this, _hasMagic);
467
- }
468
- // reconstructs the pattern
469
- toString() {
470
- if (__privateGet(this, _toString) !== void 0)
471
- return __privateGet(this, _toString);
472
- if (!this.type) {
473
- return __privateSet(this, _toString, __privateGet(this, _parts).map((p) => String(p)).join(""));
474
- } else {
475
- return __privateSet(this, _toString, this.type + "(" + __privateGet(this, _parts).map((p) => String(p)).join("|") + ")");
476
- }
477
- }
478
- push(...parts) {
479
- for (const p of parts) {
480
- if (p === "")
481
- continue;
482
- if (typeof p !== "string" && !(p instanceof _AST && __privateGet(p, _parent) === this)) {
483
- throw new Error("invalid part: " + p);
484
- }
485
- __privateGet(this, _parts).push(p);
486
- }
487
- }
488
- toJSON() {
489
- var _a;
490
- 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())];
491
- if (this.isStart() && !this.type)
492
- ret.unshift([]);
493
- if (this.isEnd() && (this === __privateGet(this, _root) || __privateGet(__privateGet(this, _root), _filledNegs) && ((_a = __privateGet(this, _parent)) == null ? void 0 : _a.type) === "!")) {
494
- ret.push({});
495
- }
496
- return ret;
497
- }
498
- isStart() {
499
- var _a;
500
- if (__privateGet(this, _root) === this)
501
- return true;
502
- if (!((_a = __privateGet(this, _parent)) == null ? void 0 : _a.isStart()))
503
- return false;
504
- if (__privateGet(this, _parentIndex) === 0)
505
- return true;
506
- const p = __privateGet(this, _parent);
507
- for (let i2 = 0; i2 < __privateGet(this, _parentIndex); i2++) {
508
- const pp = __privateGet(p, _parts)[i2];
509
- if (!(pp instanceof _AST && pp.type === "!")) {
510
- return false;
511
- }
512
- }
513
- return true;
514
- }
515
- isEnd() {
516
- var _a, _b, _c;
517
- if (__privateGet(this, _root) === this)
518
- return true;
519
- if (((_a = __privateGet(this, _parent)) == null ? void 0 : _a.type) === "!")
520
- return true;
521
- if (!((_b = __privateGet(this, _parent)) == null ? void 0 : _b.isEnd()))
522
- return false;
523
- if (!this.type)
524
- return (_c = __privateGet(this, _parent)) == null ? void 0 : _c.isEnd();
525
- const pl = __privateGet(this, _parent) ? __privateGet(__privateGet(this, _parent), _parts).length : 0;
526
- return __privateGet(this, _parentIndex) === pl - 1;
527
- }
528
- copyIn(part) {
529
- if (typeof part === "string")
530
- this.push(part);
531
- else
532
- this.push(part.clone(this));
533
- }
534
- clone(parent) {
535
- const c = new _AST(this.type, parent);
536
- for (const p of __privateGet(this, _parts)) {
537
- c.copyIn(p);
538
- }
539
- return c;
540
- }
541
- static fromGlob(pattern, options = {}) {
542
- var _a;
543
- const ast = new _AST(null, void 0, options);
544
- __privateMethod(_a = _AST, _AST_static, parseAST_fn).call(_a, pattern, ast, 0, options);
545
- return ast;
546
- }
547
- // returns the regular expression if there's magic, or the unescaped
548
- // string if not.
549
- toMMPattern() {
550
- if (this !== __privateGet(this, _root))
551
- return __privateGet(this, _root).toMMPattern();
552
- const glob = this.toString();
553
- const [re, body, hasMagic, uflag] = this.toRegExpSource();
554
- const anyMagic = hasMagic || __privateGet(this, _hasMagic) || __privateGet(this, _options).nocase && !__privateGet(this, _options).nocaseMagicOnly && glob.toUpperCase() !== glob.toLowerCase();
555
- if (!anyMagic) {
556
- return body;
557
- }
558
- const flags = (__privateGet(this, _options).nocase ? "i" : "") + (uflag ? "u" : "");
559
- return Object.assign(new RegExp(`^${re}$`, flags), {
560
- _src: re,
561
- _glob: glob
562
- });
563
- }
564
- get options() {
565
- return __privateGet(this, _options);
566
- }
567
- // returns the string match, the regexp source, whether there's magic
568
- // in the regexp (so a regular expression is required) and whether or
569
- // not the uflag is needed for the regular expression (for posix classes)
570
- // TODO: instead of injecting the start/end at this point, just return
571
- // the BODY of the regexp, along with the start/end portions suitable
572
- // for binding the start/end in either a joined full-path makeRe context
573
- // (where we bind to (^|/), or a standalone matchPart context (where
574
- // we bind to ^, and not /). Otherwise slashes get duped!
575
- //
576
- // In part-matching mode, the start is:
577
- // - if not isStart: nothing
578
- // - if traversal possible, but not allowed: ^(?!\.\.?$)
579
- // - if dots allowed or not possible: ^
580
- // - if dots possible and not allowed: ^(?!\.)
581
- // end is:
582
- // - if not isEnd(): nothing
583
- // - else: $
584
- //
585
- // In full-path matching mode, we put the slash at the START of the
586
- // pattern, so start is:
587
- // - if first pattern: same as part-matching mode
588
- // - if not isStart(): nothing
589
- // - if traversal possible, but not allowed: /(?!\.\.?(?:$|/))
590
- // - if dots allowed or not possible: /
591
- // - if dots possible and not allowed: /(?!\.)
592
- // end is:
593
- // - if last pattern, same as part-matching mode
594
- // - else nothing
595
- //
596
- // Always put the (?:$|/) on negated tails, though, because that has to be
597
- // there to bind the end of the negated pattern portion, and it's easier to
598
- // just stick it in now rather than try to inject it later in the middle of
599
- // the pattern.
600
- //
601
- // We can just always return the same end, and leave it up to the caller
602
- // to know whether it's going to be used joined or in parts.
603
- // And, if the start is adjusted slightly, can do the same there:
604
- // - if not isStart: nothing
605
- // - if traversal possible, but not allowed: (?:/|^)(?!\.\.?$)
606
- // - if dots allowed or not possible: (?:/|^)
607
- // - if dots possible and not allowed: (?:/|^)(?!\.)
608
- //
609
- // But it's better to have a simpler binding without a conditional, for
610
- // performance, so probably better to return both start options.
611
- //
612
- // Then the caller just ignores the end if it's not the first pattern,
613
- // and the start always gets applied.
614
- //
615
- // But that's always going to be $ if it's the ending pattern, or nothing,
616
- // so the caller can just attach $ at the end of the pattern when building.
617
- //
618
- // So the todo is:
619
- // - better detect what kind of start is needed
620
- // - return both flavors of starting pattern
621
- // - attach $ at the end of the pattern when creating the actual RegExp
622
- //
623
- // Ah, but wait, no, that all only applies to the root when the first pattern
624
- // is not an extglob. If the first pattern IS an extglob, then we need all
625
- // that dot prevention biz to live in the extglob portions, because eg
626
- // +(*|.x*) can match .xy but not .yx.
627
- //
628
- // So, return the two flavors if it's #root and the first child is not an
629
- // AST, otherwise leave it to the child AST to handle it, and there,
630
- // use the (?:^|/) style of start binding.
631
- //
632
- // Even simplified further:
633
- // - Since the start for a join is eg /(?!\.) and the start for a part
634
- // is ^(?!\.), we can just prepend (?!\.) to the pattern (either root
635
- // or start or whatever) and prepend ^ or / at the Regexp construction.
636
- toRegExpSource(allowDot) {
637
- var _a;
638
- const dot = allowDot != null ? allowDot : !!__privateGet(this, _options).dot;
639
- if (__privateGet(this, _root) === this)
640
- __privateMethod(this, _AST_instances, fillNegs_fn).call(this);
641
- if (!this.type) {
642
- const noEmpty = this.isStart() && this.isEnd();
643
- const src = __privateGet(this, _parts).map((p) => {
644
- var _a2;
645
- const [re, _, hasMagic, uflag] = typeof p === "string" ? __privateMethod(_a2 = _AST, _AST_static, parseGlob_fn).call(_a2, p, __privateGet(this, _hasMagic), noEmpty) : p.toRegExpSource(allowDot);
646
- __privateSet(this, _hasMagic, __privateGet(this, _hasMagic) || hasMagic);
647
- __privateSet(this, _uflag, __privateGet(this, _uflag) || uflag);
648
- return re;
649
- }).join("");
650
- let start2 = "";
651
- if (this.isStart()) {
652
- if (typeof __privateGet(this, _parts)[0] === "string") {
653
- const dotTravAllowed = __privateGet(this, _parts).length === 1 && justDots.has(__privateGet(this, _parts)[0]);
654
- if (!dotTravAllowed) {
655
- const aps = addPatternStart;
656
- const needNoTrav = (
657
- // dots are allowed, and the pattern starts with [ or .
658
- dot && aps.has(src.charAt(0)) || // the pattern starts with \., and then [ or .
659
- src.startsWith("\\.") && aps.has(src.charAt(2)) || // the pattern starts with \.\., and then [ or .
660
- src.startsWith("\\.\\.") && aps.has(src.charAt(4))
661
- );
662
- const needNoDot = !dot && !allowDot && aps.has(src.charAt(0));
663
- start2 = needNoTrav ? startNoTraversal : needNoDot ? startNoDot : "";
664
- }
665
- }
666
- }
667
- let end = "";
668
- if (this.isEnd() && __privateGet(__privateGet(this, _root), _filledNegs) && ((_a = __privateGet(this, _parent)) == null ? void 0 : _a.type) === "!") {
669
- end = "(?:$|\\/)";
670
- }
671
- const final2 = start2 + src + end;
672
- return [
673
- final2,
674
- unescape(src),
675
- __privateSet(this, _hasMagic, !!__privateGet(this, _hasMagic)),
676
- __privateGet(this, _uflag)
677
- ];
678
- }
679
- const repeated = this.type === "*" || this.type === "+";
680
- const start = this.type === "!" ? "(?:(?!(?:" : "(?:";
681
- let body = __privateMethod(this, _AST_instances, partsToRegExp_fn).call(this, dot);
682
- if (this.isStart() && this.isEnd() && !body && this.type !== "!") {
683
- const s = this.toString();
684
- __privateSet(this, _parts, [s]);
685
- this.type = null;
686
- __privateSet(this, _hasMagic, void 0);
687
- return [s, unescape(this.toString()), false, false];
688
- }
689
- let bodyDotAllowed = !repeated || allowDot || dot || !startNoDot ? "" : __privateMethod(this, _AST_instances, partsToRegExp_fn).call(this, true);
690
- if (bodyDotAllowed === body) {
691
- bodyDotAllowed = "";
692
- }
693
- if (bodyDotAllowed) {
694
- body = `(?:${body})(?:${bodyDotAllowed})*?`;
695
- }
696
- let final = "";
697
- if (this.type === "!" && __privateGet(this, _emptyExt)) {
698
- final = (this.isStart() && !dot ? startNoDot : "") + starNoEmpty;
699
- } else {
700
- const close = this.type === "!" ? (
701
- // !() must match something,but !(x) can match ''
702
- "))" + (this.isStart() && !dot && !allowDot ? startNoDot : "") + star + ")"
703
- ) : this.type === "@" ? ")" : this.type === "?" ? ")?" : this.type === "+" && bodyDotAllowed ? ")" : this.type === "*" && bodyDotAllowed ? `)?` : `)${this.type}`;
704
- final = start + body + close;
705
- }
706
- return [
707
- final,
708
- unescape(body),
709
- __privateSet(this, _hasMagic, !!__privateGet(this, _hasMagic)),
710
- __privateGet(this, _uflag)
711
- ];
712
- }
713
- };
714
- _root = new WeakMap();
715
- _hasMagic = new WeakMap();
716
- _uflag = new WeakMap();
717
- _parts = new WeakMap();
718
- _parent = new WeakMap();
719
- _parentIndex = new WeakMap();
720
- _negs = new WeakMap();
721
- _filledNegs = new WeakMap();
722
- _options = new WeakMap();
723
- _toString = new WeakMap();
724
- _emptyExt = new WeakMap();
725
- _AST_instances = new WeakSet();
726
- fillNegs_fn = function() {
727
- if (this !== __privateGet(this, _root))
728
- throw new Error("should only call on root");
729
- if (__privateGet(this, _filledNegs))
730
- return this;
731
- this.toString();
732
- __privateSet(this, _filledNegs, true);
733
- let n;
734
- while (n = __privateGet(this, _negs).pop()) {
735
- if (n.type !== "!")
736
- continue;
737
- let p = n;
738
- let pp = __privateGet(p, _parent);
739
- while (pp) {
740
- for (let i2 = __privateGet(p, _parentIndex) + 1; !pp.type && i2 < __privateGet(pp, _parts).length; i2++) {
741
- for (const part of __privateGet(n, _parts)) {
742
- if (typeof part === "string") {
743
- throw new Error("string part in extglob AST??");
744
- }
745
- part.copyIn(__privateGet(pp, _parts)[i2]);
746
- }
747
- }
748
- p = pp;
749
- pp = __privateGet(p, _parent);
750
- }
751
- }
752
- return this;
753
- };
754
- _AST_static = new WeakSet();
755
- parseAST_fn = function(str, ast, pos, opt) {
756
- var _a, _b;
757
- let escaping = false;
758
- let inBrace = false;
759
- let braceStart = -1;
760
- let braceNeg = false;
761
- if (ast.type === null) {
762
- let i3 = pos;
763
- let acc2 = "";
764
- while (i3 < str.length) {
765
- const c = str.charAt(i3++);
766
- if (escaping || c === "\\") {
767
- escaping = !escaping;
768
- acc2 += c;
769
- continue;
770
- }
771
- if (inBrace) {
772
- if (i3 === braceStart + 1) {
773
- if (c === "^" || c === "!") {
774
- braceNeg = true;
775
- }
776
- } else if (c === "]" && !(i3 === braceStart + 2 && braceNeg)) {
777
- inBrace = false;
778
- }
779
- acc2 += c;
780
- continue;
781
- } else if (c === "[") {
782
- inBrace = true;
783
- braceStart = i3;
784
- braceNeg = false;
785
- acc2 += c;
786
- continue;
787
- }
788
- if (!opt.noext && isExtglobType(c) && str.charAt(i3) === "(") {
789
- ast.push(acc2);
790
- acc2 = "";
791
- const ext2 = new _AST(c, ast);
792
- i3 = __privateMethod(_a = _AST, _AST_static, parseAST_fn).call(_a, str, ext2, i3, opt);
793
- ast.push(ext2);
794
- continue;
795
- }
796
- acc2 += c;
797
- }
798
- ast.push(acc2);
799
- return i3;
800
- }
801
- let i2 = pos + 1;
802
- let part = new _AST(null, ast);
803
- const parts = [];
804
- let acc = "";
805
- while (i2 < str.length) {
806
- const c = str.charAt(i2++);
807
- if (escaping || c === "\\") {
808
- escaping = !escaping;
809
- acc += c;
810
- continue;
811
- }
812
- if (inBrace) {
813
- if (i2 === braceStart + 1) {
814
- if (c === "^" || c === "!") {
815
- braceNeg = true;
816
- }
817
- } else if (c === "]" && !(i2 === braceStart + 2 && braceNeg)) {
818
- inBrace = false;
819
- }
820
- acc += c;
821
- continue;
822
- } else if (c === "[") {
823
- inBrace = true;
824
- braceStart = i2;
825
- braceNeg = false;
826
- acc += c;
827
- continue;
828
- }
829
- if (isExtglobType(c) && str.charAt(i2) === "(") {
830
- part.push(acc);
831
- acc = "";
832
- const ext2 = new _AST(c, part);
833
- part.push(ext2);
834
- i2 = __privateMethod(_b = _AST, _AST_static, parseAST_fn).call(_b, str, ext2, i2, opt);
835
- continue;
836
- }
837
- if (c === "|") {
838
- part.push(acc);
839
- acc = "";
840
- parts.push(part);
841
- part = new _AST(null, ast);
842
- continue;
843
- }
844
- if (c === ")") {
845
- if (acc === "" && __privateGet(ast, _parts).length === 0) {
846
- __privateSet(ast, _emptyExt, true);
847
- }
848
- part.push(acc);
849
- acc = "";
850
- ast.push(...parts, part);
851
- return i2;
852
- }
853
- acc += c;
854
- }
855
- ast.type = null;
856
- __privateSet(ast, _hasMagic, void 0);
857
- __privateSet(ast, _parts, [str.substring(pos - 1)]);
858
- return i2;
859
- };
860
- partsToRegExp_fn = function(dot) {
861
- return __privateGet(this, _parts).map((p) => {
862
- if (typeof p === "string") {
863
- throw new Error("string type in extglob ast??");
864
- }
865
- const [re, _, _hasMagic2, uflag] = p.toRegExpSource(dot);
866
- __privateSet(this, _uflag, __privateGet(this, _uflag) || uflag);
867
- return re;
868
- }).filter((p) => !(this.isStart() && this.isEnd()) || !!p).join("|");
869
- };
870
- parseGlob_fn = function(glob, hasMagic, noEmpty = false) {
871
- let escaping = false;
872
- let re = "";
873
- let uflag = false;
874
- for (let i2 = 0; i2 < glob.length; i2++) {
875
- const c = glob.charAt(i2);
876
- if (escaping) {
877
- escaping = false;
878
- re += (reSpecials.has(c) ? "\\" : "") + c;
879
- continue;
880
- }
881
- if (c === "\\") {
882
- if (i2 === glob.length - 1) {
883
- re += "\\\\";
884
- } else {
885
- escaping = true;
886
- }
887
- continue;
888
- }
889
- if (c === "[") {
890
- const [src, needUflag, consumed, magic] = parseClass(glob, i2);
891
- if (consumed) {
892
- re += src;
893
- uflag = uflag || needUflag;
894
- i2 += consumed - 1;
895
- hasMagic = hasMagic || magic;
896
- continue;
897
- }
898
- }
899
- if (c === "*") {
900
- if (noEmpty && glob === "*")
901
- re += starNoEmpty;
902
- else
903
- re += star;
904
- hasMagic = true;
905
- continue;
906
- }
907
- if (c === "?") {
908
- re += qmark;
909
- hasMagic = true;
910
- continue;
911
- }
912
- re += regExpEscape(c);
913
- }
914
- return [re, unescape(glob), !!hasMagic, uflag];
915
- };
916
- __privateAdd(_AST, _AST_static);
917
- var AST = _AST;
918
-
919
- // node_modules/minimatch/dist/esm/escape.js
920
- var escape = (s, { windowsPathsNoEscape = false } = {}) => {
921
- return windowsPathsNoEscape ? s.replace(/[?*()[\]]/g, "[$&]") : s.replace(/[?*()[\]\\]/g, "\\$&");
922
- };
923
-
924
- // node_modules/minimatch/dist/esm/index.js
925
- var minimatch = (p, pattern, options = {}) => {
926
- assertValidPattern(pattern);
927
- if (!options.nocomment && pattern.charAt(0) === "#") {
928
- return false;
929
- }
930
- return new Minimatch(pattern, options).match(p);
931
- };
932
- var starDotExtRE = /^\*+([^+@!?\*\[\(]*)$/;
933
- var starDotExtTest = (ext2) => (f) => !f.startsWith(".") && f.endsWith(ext2);
934
- var starDotExtTestDot = (ext2) => (f) => f.endsWith(ext2);
935
- var starDotExtTestNocase = (ext2) => {
936
- ext2 = ext2.toLowerCase();
937
- return (f) => !f.startsWith(".") && f.toLowerCase().endsWith(ext2);
938
- };
939
- var starDotExtTestNocaseDot = (ext2) => {
940
- ext2 = ext2.toLowerCase();
941
- return (f) => f.toLowerCase().endsWith(ext2);
942
- };
943
- var starDotStarRE = /^\*+\.\*+$/;
944
- var starDotStarTest = (f) => !f.startsWith(".") && f.includes(".");
945
- var starDotStarTestDot = (f) => f !== "." && f !== ".." && f.includes(".");
946
- var dotStarRE = /^\.\*+$/;
947
- var dotStarTest = (f) => f !== "." && f !== ".." && f.startsWith(".");
948
- var starRE = /^\*+$/;
949
- var starTest = (f) => f.length !== 0 && !f.startsWith(".");
950
- var starTestDot = (f) => f.length !== 0 && f !== "." && f !== "..";
951
- var qmarksRE = /^\?+([^+@!?\*\[\(]*)?$/;
952
- var qmarksTestNocase = ([$0, ext2 = ""]) => {
953
- const noext = qmarksTestNoExt([$0]);
954
- if (!ext2)
955
- return noext;
956
- ext2 = ext2.toLowerCase();
957
- return (f) => noext(f) && f.toLowerCase().endsWith(ext2);
958
- };
959
- var qmarksTestNocaseDot = ([$0, ext2 = ""]) => {
960
- const noext = qmarksTestNoExtDot([$0]);
961
- if (!ext2)
962
- return noext;
963
- ext2 = ext2.toLowerCase();
964
- return (f) => noext(f) && f.toLowerCase().endsWith(ext2);
965
- };
966
- var qmarksTestDot = ([$0, ext2 = ""]) => {
967
- const noext = qmarksTestNoExtDot([$0]);
968
- return !ext2 ? noext : (f) => noext(f) && f.endsWith(ext2);
969
- };
970
- var qmarksTest = ([$0, ext2 = ""]) => {
971
- const noext = qmarksTestNoExt([$0]);
972
- return !ext2 ? noext : (f) => noext(f) && f.endsWith(ext2);
973
- };
974
- var qmarksTestNoExt = ([$0]) => {
975
- const len = $0.length;
976
- return (f) => f.length === len && !f.startsWith(".");
977
- };
978
- var qmarksTestNoExtDot = ([$0]) => {
979
- const len = $0.length;
980
- return (f) => f.length === len && f !== "." && f !== "..";
981
- };
982
- var defaultPlatform = typeof process === "object" && process ? typeof process.env === "object" && process.env && process.env.__MINIMATCH_TESTING_PLATFORM__ || process.platform : "posix";
983
- var path = {
984
- win32: { sep: "\\" },
985
- posix: { sep: "/" }
986
- };
987
- var sep = defaultPlatform === "win32" ? path.win32.sep : path.posix.sep;
988
- minimatch.sep = sep;
989
- var GLOBSTAR = Symbol("globstar **");
990
- minimatch.GLOBSTAR = GLOBSTAR;
991
- var qmark2 = "[^/]";
992
- var star2 = qmark2 + "*?";
993
- var twoStarDot = "(?:(?!(?:\\/|^)(?:\\.{1,2})($|\\/)).)*?";
994
- var twoStarNoDot = "(?:(?!(?:\\/|^)\\.).)*?";
995
- var filter = (pattern, options = {}) => (p) => minimatch(p, pattern, options);
996
- minimatch.filter = filter;
997
- var ext = (a, b = {}) => Object.assign({}, a, b);
998
- var defaults = (def) => {
999
- if (!def || typeof def !== "object" || !Object.keys(def).length) {
1000
- return minimatch;
1001
- }
1002
- const orig = minimatch;
1003
- const m = (p, pattern, options = {}) => orig(p, pattern, ext(def, options));
1004
- return Object.assign(m, {
1005
- Minimatch: class Minimatch extends orig.Minimatch {
1006
- constructor(pattern, options = {}) {
1007
- super(pattern, ext(def, options));
1008
- }
1009
- static defaults(options) {
1010
- return orig.defaults(ext(def, options)).Minimatch;
1011
- }
1012
- },
1013
- AST: class AST extends orig.AST {
1014
- /* c8 ignore start */
1015
- constructor(type, parent, options = {}) {
1016
- super(type, parent, ext(def, options));
1017
- }
1018
- /* c8 ignore stop */
1019
- static fromGlob(pattern, options = {}) {
1020
- return orig.AST.fromGlob(pattern, ext(def, options));
1021
- }
1022
- },
1023
- unescape: (s, options = {}) => orig.unescape(s, ext(def, options)),
1024
- escape: (s, options = {}) => orig.escape(s, ext(def, options)),
1025
- filter: (pattern, options = {}) => orig.filter(pattern, ext(def, options)),
1026
- defaults: (options) => orig.defaults(ext(def, options)),
1027
- makeRe: (pattern, options = {}) => orig.makeRe(pattern, ext(def, options)),
1028
- braceExpand: (pattern, options = {}) => orig.braceExpand(pattern, ext(def, options)),
1029
- match: (list, pattern, options = {}) => orig.match(list, pattern, ext(def, options)),
1030
- sep: orig.sep,
1031
- GLOBSTAR
1032
- });
1033
- };
1034
- minimatch.defaults = defaults;
1035
- var braceExpand = (pattern, options = {}) => {
1036
- assertValidPattern(pattern);
1037
- if (options.nobrace || !/\{(?:(?!\{).)*\}/.test(pattern)) {
1038
- return [pattern];
1039
- }
1040
- return (0, import_brace_expansion.default)(pattern);
1041
- };
1042
- minimatch.braceExpand = braceExpand;
1043
- var makeRe = (pattern, options = {}) => new Minimatch(pattern, options).makeRe();
1044
- minimatch.makeRe = makeRe;
1045
- var match = (list, pattern, options = {}) => {
1046
- const mm = new Minimatch(pattern, options);
1047
- list = list.filter((f) => mm.match(f));
1048
- if (mm.options.nonull && !list.length) {
1049
- list.push(pattern);
1050
- }
1051
- return list;
1052
- };
1053
- minimatch.match = match;
1054
- var globMagic = /[?*]|[+@!]\(.*?\)|\[|\]/;
1055
- var regExpEscape2 = (s) => s.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&");
1056
- var Minimatch = class {
1057
- options;
1058
- set;
1059
- pattern;
1060
- windowsPathsNoEscape;
1061
- nonegate;
1062
- negate;
1063
- comment;
1064
- empty;
1065
- preserveMultipleSlashes;
1066
- partial;
1067
- globSet;
1068
- globParts;
1069
- nocase;
1070
- isWindows;
1071
- platform;
1072
- windowsNoMagicRoot;
1073
- regexp;
1074
- constructor(pattern, options = {}) {
1075
- assertValidPattern(pattern);
1076
- options = options || {};
1077
- this.options = options;
1078
- this.pattern = pattern;
1079
- this.platform = options.platform || defaultPlatform;
1080
- this.isWindows = this.platform === "win32";
1081
- this.windowsPathsNoEscape = !!options.windowsPathsNoEscape || options.allowWindowsEscape === false;
1082
- if (this.windowsPathsNoEscape) {
1083
- this.pattern = this.pattern.replace(/\\/g, "/");
1084
- }
1085
- this.preserveMultipleSlashes = !!options.preserveMultipleSlashes;
1086
- this.regexp = null;
1087
- this.negate = false;
1088
- this.nonegate = !!options.nonegate;
1089
- this.comment = false;
1090
- this.empty = false;
1091
- this.partial = !!options.partial;
1092
- this.nocase = !!this.options.nocase;
1093
- this.windowsNoMagicRoot = options.windowsNoMagicRoot !== void 0 ? options.windowsNoMagicRoot : !!(this.isWindows && this.nocase);
1094
- this.globSet = [];
1095
- this.globParts = [];
1096
- this.set = [];
1097
- this.make();
1098
- }
1099
- hasMagic() {
1100
- if (this.options.magicalBraces && this.set.length > 1) {
1101
- return true;
1102
- }
1103
- for (const pattern of this.set) {
1104
- for (const part of pattern) {
1105
- if (typeof part !== "string")
1106
- return true;
1107
- }
1108
- }
1109
- return false;
1110
- }
1111
- debug(..._) {
1112
- }
1113
- make() {
1114
- const pattern = this.pattern;
1115
- const options = this.options;
1116
- if (!options.nocomment && pattern.charAt(0) === "#") {
1117
- this.comment = true;
1118
- return;
1119
- }
1120
- if (!pattern) {
1121
- this.empty = true;
1122
- return;
1123
- }
1124
- this.parseNegate();
1125
- this.globSet = [...new Set(this.braceExpand())];
1126
- if (options.debug) {
1127
- this.debug = (...args) => console.error(...args);
1128
- }
1129
- this.debug(this.pattern, this.globSet);
1130
- const rawGlobParts = this.globSet.map((s) => this.slashSplit(s));
1131
- this.globParts = this.preprocess(rawGlobParts);
1132
- this.debug(this.pattern, this.globParts);
1133
- let set = this.globParts.map((s, _, __) => {
1134
- if (this.isWindows && this.windowsNoMagicRoot) {
1135
- const isUNC = s[0] === "" && s[1] === "" && (s[2] === "?" || !globMagic.test(s[2])) && !globMagic.test(s[3]);
1136
- const isDrive = /^[a-z]:/i.test(s[0]);
1137
- if (isUNC) {
1138
- return [...s.slice(0, 4), ...s.slice(4).map((ss) => this.parse(ss))];
1139
- } else if (isDrive) {
1140
- return [s[0], ...s.slice(1).map((ss) => this.parse(ss))];
1141
- }
1142
- }
1143
- return s.map((ss) => this.parse(ss));
1144
- });
1145
- this.debug(this.pattern, set);
1146
- this.set = set.filter((s) => s.indexOf(false) === -1);
1147
- if (this.isWindows) {
1148
- for (let i2 = 0; i2 < this.set.length; i2++) {
1149
- const p = this.set[i2];
1150
- if (p[0] === "" && p[1] === "" && this.globParts[i2][2] === "?" && typeof p[3] === "string" && /^[a-z]:$/i.test(p[3])) {
1151
- p[2] = "?";
1152
- }
1153
- }
1154
- }
1155
- this.debug(this.pattern, this.set);
1156
- }
1157
- // various transforms to equivalent pattern sets that are
1158
- // faster to process in a filesystem walk. The goal is to
1159
- // eliminate what we can, and push all ** patterns as far
1160
- // to the right as possible, even if it increases the number
1161
- // of patterns that we have to process.
1162
- preprocess(globParts) {
1163
- if (this.options.noglobstar) {
1164
- for (let i2 = 0; i2 < globParts.length; i2++) {
1165
- for (let j = 0; j < globParts[i2].length; j++) {
1166
- if (globParts[i2][j] === "**") {
1167
- globParts[i2][j] = "*";
1168
- }
1169
- }
1170
- }
1171
- }
1172
- const { optimizationLevel = 1 } = this.options;
1173
- if (optimizationLevel >= 2) {
1174
- globParts = this.firstPhasePreProcess(globParts);
1175
- globParts = this.secondPhasePreProcess(globParts);
1176
- } else if (optimizationLevel >= 1) {
1177
- globParts = this.levelOneOptimize(globParts);
1178
- } else {
1179
- globParts = this.adjascentGlobstarOptimize(globParts);
1180
- }
1181
- return globParts;
1182
- }
1183
- // just get rid of adjascent ** portions
1184
- adjascentGlobstarOptimize(globParts) {
1185
- return globParts.map((parts) => {
1186
- let gs = -1;
1187
- while (-1 !== (gs = parts.indexOf("**", gs + 1))) {
1188
- let i2 = gs;
1189
- while (parts[i2 + 1] === "**") {
1190
- i2++;
1191
- }
1192
- if (i2 !== gs) {
1193
- parts.splice(gs, i2 - gs);
1194
- }
1195
- }
1196
- return parts;
1197
- });
1198
- }
1199
- // get rid of adjascent ** and resolve .. portions
1200
- levelOneOptimize(globParts) {
1201
- return globParts.map((parts) => {
1202
- parts = parts.reduce((set, part) => {
1203
- const prev = set[set.length - 1];
1204
- if (part === "**" && prev === "**") {
1205
- return set;
1206
- }
1207
- if (part === "..") {
1208
- if (prev && prev !== ".." && prev !== "." && prev !== "**") {
1209
- set.pop();
1210
- return set;
1211
- }
1212
- }
1213
- set.push(part);
1214
- return set;
1215
- }, []);
1216
- return parts.length === 0 ? [""] : parts;
1217
- });
1218
- }
1219
- levelTwoFileOptimize(parts) {
1220
- if (!Array.isArray(parts)) {
1221
- parts = this.slashSplit(parts);
1222
- }
1223
- let didSomething = false;
1224
- do {
1225
- didSomething = false;
1226
- if (!this.preserveMultipleSlashes) {
1227
- for (let i2 = 1; i2 < parts.length - 1; i2++) {
1228
- const p = parts[i2];
1229
- if (i2 === 1 && p === "" && parts[0] === "")
1230
- continue;
1231
- if (p === "." || p === "") {
1232
- didSomething = true;
1233
- parts.splice(i2, 1);
1234
- i2--;
1235
- }
1236
- }
1237
- if (parts[0] === "." && parts.length === 2 && (parts[1] === "." || parts[1] === "")) {
1238
- didSomething = true;
1239
- parts.pop();
1240
- }
1241
- }
1242
- let dd = 0;
1243
- while (-1 !== (dd = parts.indexOf("..", dd + 1))) {
1244
- const p = parts[dd - 1];
1245
- if (p && p !== "." && p !== ".." && p !== "**") {
1246
- didSomething = true;
1247
- parts.splice(dd - 1, 2);
1248
- dd -= 2;
1249
- }
1250
- }
1251
- } while (didSomething);
1252
- return parts.length === 0 ? [""] : parts;
1253
- }
1254
- // First phase: single-pattern processing
1255
- // <pre> is 1 or more portions
1256
- // <rest> is 1 or more portions
1257
- // <p> is any portion other than ., .., '', or **
1258
- // <e> is . or ''
1259
- //
1260
- // **/.. is *brutal* for filesystem walking performance, because
1261
- // it effectively resets the recursive walk each time it occurs,
1262
- // and ** cannot be reduced out by a .. pattern part like a regexp
1263
- // or most strings (other than .., ., and '') can be.
1264
- //
1265
- // <pre>/**/../<p>/<p>/<rest> -> {<pre>/../<p>/<p>/<rest>,<pre>/**/<p>/<p>/<rest>}
1266
- // <pre>/<e>/<rest> -> <pre>/<rest>
1267
- // <pre>/<p>/../<rest> -> <pre>/<rest>
1268
- // **/**/<rest> -> **/<rest>
1269
- //
1270
- // **/*/<rest> -> */**/<rest> <== not valid because ** doesn't follow
1271
- // this WOULD be allowed if ** did follow symlinks, or * didn't
1272
- firstPhasePreProcess(globParts) {
1273
- let didSomething = false;
1274
- do {
1275
- didSomething = false;
1276
- for (let parts of globParts) {
1277
- let gs = -1;
1278
- while (-1 !== (gs = parts.indexOf("**", gs + 1))) {
1279
- let gss = gs;
1280
- while (parts[gss + 1] === "**") {
1281
- gss++;
1282
- }
1283
- if (gss > gs) {
1284
- parts.splice(gs + 1, gss - gs);
1285
- }
1286
- let next = parts[gs + 1];
1287
- const p = parts[gs + 2];
1288
- const p2 = parts[gs + 3];
1289
- if (next !== "..")
1290
- continue;
1291
- if (!p || p === "." || p === ".." || !p2 || p2 === "." || p2 === "..") {
1292
- continue;
1293
- }
1294
- didSomething = true;
1295
- parts.splice(gs, 1);
1296
- const other = parts.slice(0);
1297
- other[gs] = "**";
1298
- globParts.push(other);
1299
- gs--;
1300
- }
1301
- if (!this.preserveMultipleSlashes) {
1302
- for (let i2 = 1; i2 < parts.length - 1; i2++) {
1303
- const p = parts[i2];
1304
- if (i2 === 1 && p === "" && parts[0] === "")
1305
- continue;
1306
- if (p === "." || p === "") {
1307
- didSomething = true;
1308
- parts.splice(i2, 1);
1309
- i2--;
1310
- }
1311
- }
1312
- if (parts[0] === "." && parts.length === 2 && (parts[1] === "." || parts[1] === "")) {
1313
- didSomething = true;
1314
- parts.pop();
1315
- }
1316
- }
1317
- let dd = 0;
1318
- while (-1 !== (dd = parts.indexOf("..", dd + 1))) {
1319
- const p = parts[dd - 1];
1320
- if (p && p !== "." && p !== ".." && p !== "**") {
1321
- didSomething = true;
1322
- const needDot = dd === 1 && parts[dd + 1] === "**";
1323
- const splin = needDot ? ["."] : [];
1324
- parts.splice(dd - 1, 2, ...splin);
1325
- if (parts.length === 0)
1326
- parts.push("");
1327
- dd -= 2;
1328
- }
1329
- }
1330
- }
1331
- } while (didSomething);
1332
- return globParts;
1333
- }
1334
- // second phase: multi-pattern dedupes
1335
- // {<pre>/*/<rest>,<pre>/<p>/<rest>} -> <pre>/*/<rest>
1336
- // {<pre>/<rest>,<pre>/<rest>} -> <pre>/<rest>
1337
- // {<pre>/**/<rest>,<pre>/<rest>} -> <pre>/**/<rest>
1338
- //
1339
- // {<pre>/**/<rest>,<pre>/**/<p>/<rest>} -> <pre>/**/<rest>
1340
- // ^-- not valid because ** doens't follow symlinks
1341
- secondPhasePreProcess(globParts) {
1342
- for (let i2 = 0; i2 < globParts.length - 1; i2++) {
1343
- for (let j = i2 + 1; j < globParts.length; j++) {
1344
- const matched = this.partsMatch(globParts[i2], globParts[j], !this.preserveMultipleSlashes);
1345
- if (!matched)
1346
- continue;
1347
- globParts[i2] = matched;
1348
- globParts[j] = [];
1349
- }
1350
- }
1351
- return globParts.filter((gs) => gs.length);
1352
- }
1353
- partsMatch(a, b, emptyGSMatch = false) {
1354
- let ai = 0;
1355
- let bi = 0;
1356
- let result = [];
1357
- let which = "";
1358
- while (ai < a.length && bi < b.length) {
1359
- if (a[ai] === b[bi]) {
1360
- result.push(which === "b" ? b[bi] : a[ai]);
1361
- ai++;
1362
- bi++;
1363
- } else if (emptyGSMatch && a[ai] === "**" && b[bi] === a[ai + 1]) {
1364
- result.push(a[ai]);
1365
- ai++;
1366
- } else if (emptyGSMatch && b[bi] === "**" && a[ai] === b[bi + 1]) {
1367
- result.push(b[bi]);
1368
- bi++;
1369
- } else if (a[ai] === "*" && b[bi] && (this.options.dot || !b[bi].startsWith(".")) && b[bi] !== "**") {
1370
- if (which === "b")
1371
- return false;
1372
- which = "a";
1373
- result.push(a[ai]);
1374
- ai++;
1375
- bi++;
1376
- } else if (b[bi] === "*" && a[ai] && (this.options.dot || !a[ai].startsWith(".")) && a[ai] !== "**") {
1377
- if (which === "a")
1378
- return false;
1379
- which = "b";
1380
- result.push(b[bi]);
1381
- ai++;
1382
- bi++;
1383
- } else {
1384
- return false;
1385
- }
1386
- }
1387
- return a.length === b.length && result;
1388
- }
1389
- parseNegate() {
1390
- if (this.nonegate)
1391
- return;
1392
- const pattern = this.pattern;
1393
- let negate = false;
1394
- let negateOffset = 0;
1395
- for (let i2 = 0; i2 < pattern.length && pattern.charAt(i2) === "!"; i2++) {
1396
- negate = !negate;
1397
- negateOffset++;
1398
- }
1399
- if (negateOffset)
1400
- this.pattern = pattern.slice(negateOffset);
1401
- this.negate = negate;
1402
- }
1403
- // set partial to true to test if, for example,
1404
- // "/a/b" matches the start of "/*/b/*/d"
1405
- // Partial means, if you run out of file before you run
1406
- // out of pattern, then that's fine, as long as all
1407
- // the parts match.
1408
- matchOne(file, pattern, partial = false) {
1409
- const options = this.options;
1410
- if (this.isWindows) {
1411
- const fileDrive = typeof file[0] === "string" && /^[a-z]:$/i.test(file[0]);
1412
- const fileUNC = !fileDrive && file[0] === "" && file[1] === "" && file[2] === "?" && /^[a-z]:$/i.test(file[3]);
1413
- const patternDrive = typeof pattern[0] === "string" && /^[a-z]:$/i.test(pattern[0]);
1414
- const patternUNC = !patternDrive && pattern[0] === "" && pattern[1] === "" && pattern[2] === "?" && typeof pattern[3] === "string" && /^[a-z]:$/i.test(pattern[3]);
1415
- const fdi = fileUNC ? 3 : fileDrive ? 0 : void 0;
1416
- const pdi = patternUNC ? 3 : patternDrive ? 0 : void 0;
1417
- if (typeof fdi === "number" && typeof pdi === "number") {
1418
- const [fd, pd] = [file[fdi], pattern[pdi]];
1419
- if (fd.toLowerCase() === pd.toLowerCase()) {
1420
- pattern[pdi] = fd;
1421
- if (pdi > fdi) {
1422
- pattern = pattern.slice(pdi);
1423
- } else if (fdi > pdi) {
1424
- file = file.slice(fdi);
1425
- }
1426
- }
1427
- }
1428
- }
1429
- const { optimizationLevel = 1 } = this.options;
1430
- if (optimizationLevel >= 2) {
1431
- file = this.levelTwoFileOptimize(file);
1432
- }
1433
- this.debug("matchOne", this, { file, pattern });
1434
- this.debug("matchOne", file.length, pattern.length);
1435
- for (var fi = 0, pi = 0, fl = file.length, pl = pattern.length; fi < fl && pi < pl; fi++, pi++) {
1436
- this.debug("matchOne loop");
1437
- var p = pattern[pi];
1438
- var f = file[fi];
1439
- this.debug(pattern, p, f);
1440
- if (p === false) {
1441
- return false;
1442
- }
1443
- if (p === GLOBSTAR) {
1444
- this.debug("GLOBSTAR", [pattern, p, f]);
1445
- var fr = fi;
1446
- var pr = pi + 1;
1447
- if (pr === pl) {
1448
- this.debug("** at the end");
1449
- for (; fi < fl; fi++) {
1450
- if (file[fi] === "." || file[fi] === ".." || !options.dot && file[fi].charAt(0) === ".")
1451
- return false;
1452
- }
1453
- return true;
1454
- }
1455
- while (fr < fl) {
1456
- var swallowee = file[fr];
1457
- this.debug("\nglobstar while", file, fr, pattern, pr, swallowee);
1458
- if (this.matchOne(file.slice(fr), pattern.slice(pr), partial)) {
1459
- this.debug("globstar found match!", fr, fl, swallowee);
1460
- return true;
1461
- } else {
1462
- if (swallowee === "." || swallowee === ".." || !options.dot && swallowee.charAt(0) === ".") {
1463
- this.debug("dot detected!", file, fr, pattern, pr);
1464
- break;
1465
- }
1466
- this.debug("globstar swallow a segment, and continue");
1467
- fr++;
1468
- }
1469
- }
1470
- if (partial) {
1471
- this.debug("\n>>> no match, partial?", file, fr, pattern, pr);
1472
- if (fr === fl) {
1473
- return true;
1474
- }
1475
- }
1476
- return false;
1477
- }
1478
- let hit;
1479
- if (typeof p === "string") {
1480
- hit = f === p;
1481
- this.debug("string match", p, f, hit);
1482
- } else {
1483
- hit = p.test(f);
1484
- this.debug("pattern match", p, f, hit);
1485
- }
1486
- if (!hit)
1487
- return false;
1488
- }
1489
- if (fi === fl && pi === pl) {
1490
- return true;
1491
- } else if (fi === fl) {
1492
- return partial;
1493
- } else if (pi === pl) {
1494
- return fi === fl - 1 && file[fi] === "";
1495
- } else {
1496
- throw new Error("wtf?");
1497
- }
1498
- }
1499
- braceExpand() {
1500
- return braceExpand(this.pattern, this.options);
1501
- }
1502
- parse(pattern) {
1503
- assertValidPattern(pattern);
1504
- const options = this.options;
1505
- if (pattern === "**")
1506
- return GLOBSTAR;
1507
- if (pattern === "")
1508
- return "";
1509
- let m;
1510
- let fastTest = null;
1511
- if (m = pattern.match(starRE)) {
1512
- fastTest = options.dot ? starTestDot : starTest;
1513
- } else if (m = pattern.match(starDotExtRE)) {
1514
- fastTest = (options.nocase ? options.dot ? starDotExtTestNocaseDot : starDotExtTestNocase : options.dot ? starDotExtTestDot : starDotExtTest)(m[1]);
1515
- } else if (m = pattern.match(qmarksRE)) {
1516
- fastTest = (options.nocase ? options.dot ? qmarksTestNocaseDot : qmarksTestNocase : options.dot ? qmarksTestDot : qmarksTest)(m);
1517
- } else if (m = pattern.match(starDotStarRE)) {
1518
- fastTest = options.dot ? starDotStarTestDot : starDotStarTest;
1519
- } else if (m = pattern.match(dotStarRE)) {
1520
- fastTest = dotStarTest;
1521
- }
1522
- const re = AST.fromGlob(pattern, this.options).toMMPattern();
1523
- if (fastTest && typeof re === "object") {
1524
- Reflect.defineProperty(re, "test", { value: fastTest });
1525
- }
1526
- return re;
1527
- }
1528
- makeRe() {
1529
- if (this.regexp || this.regexp === false)
1530
- return this.regexp;
1531
- const set = this.set;
1532
- if (!set.length) {
1533
- this.regexp = false;
1534
- return this.regexp;
1535
- }
1536
- const options = this.options;
1537
- const twoStar = options.noglobstar ? star2 : options.dot ? twoStarDot : twoStarNoDot;
1538
- const flags = new Set(options.nocase ? ["i"] : []);
1539
- let re = set.map((pattern) => {
1540
- const pp = pattern.map((p) => {
1541
- if (p instanceof RegExp) {
1542
- for (const f of p.flags.split(""))
1543
- flags.add(f);
1544
- }
1545
- return typeof p === "string" ? regExpEscape2(p) : p === GLOBSTAR ? GLOBSTAR : p._src;
1546
- });
1547
- pp.forEach((p, i2) => {
1548
- const next = pp[i2 + 1];
1549
- const prev = pp[i2 - 1];
1550
- if (p !== GLOBSTAR || prev === GLOBSTAR) {
1551
- return;
1552
- }
1553
- if (prev === void 0) {
1554
- if (next !== void 0 && next !== GLOBSTAR) {
1555
- pp[i2 + 1] = "(?:\\/|" + twoStar + "\\/)?" + next;
1556
- } else {
1557
- pp[i2] = twoStar;
1558
- }
1559
- } else if (next === void 0) {
1560
- pp[i2 - 1] = prev + "(?:\\/|" + twoStar + ")?";
1561
- } else if (next !== GLOBSTAR) {
1562
- pp[i2 - 1] = prev + "(?:\\/|\\/" + twoStar + "\\/)" + next;
1563
- pp[i2 + 1] = GLOBSTAR;
1564
- }
1565
- });
1566
- return pp.filter((p) => p !== GLOBSTAR).join("/");
1567
- }).join("|");
1568
- const [open, close] = set.length > 1 ? ["(?:", ")"] : ["", ""];
1569
- re = "^" + open + re + close + "$";
1570
- if (this.negate)
1571
- re = "^(?!" + re + ").+$";
1572
- try {
1573
- this.regexp = new RegExp(re, [...flags].join(""));
1574
- } catch (ex) {
1575
- this.regexp = false;
1576
- }
1577
- return this.regexp;
1578
- }
1579
- slashSplit(p) {
1580
- if (this.preserveMultipleSlashes) {
1581
- return p.split("/");
1582
- } else if (this.isWindows && /^\/\/[^\/]+/.test(p)) {
1583
- return ["", ...p.split(/\/+/)];
1584
- } else {
1585
- return p.split(/\/+/);
1586
- }
1587
- }
1588
- match(f, partial = this.partial) {
1589
- this.debug("match", f, this.pattern);
1590
- if (this.comment) {
1591
- return false;
1592
- }
1593
- if (this.empty) {
1594
- return f === "";
1595
- }
1596
- if (f === "/" && partial) {
1597
- return true;
1598
- }
1599
- const options = this.options;
1600
- if (this.isWindows) {
1601
- f = f.split("\\").join("/");
1602
- }
1603
- const ff = this.slashSplit(f);
1604
- this.debug(this.pattern, "split", ff);
1605
- const set = this.set;
1606
- this.debug(this.pattern, "set", set);
1607
- let filename = ff[ff.length - 1];
1608
- if (!filename) {
1609
- for (let i2 = ff.length - 2; !filename && i2 >= 0; i2--) {
1610
- filename = ff[i2];
1611
- }
1612
- }
1613
- for (let i2 = 0; i2 < set.length; i2++) {
1614
- const pattern = set[i2];
1615
- let file = ff;
1616
- if (options.matchBase && pattern.length === 1) {
1617
- file = [filename];
1618
- }
1619
- const hit = this.matchOne(file, pattern, partial);
1620
- if (hit) {
1621
- if (options.flipNegate) {
1622
- return true;
1623
- }
1624
- return !this.negate;
1625
- }
1626
- }
1627
- if (options.flipNegate) {
1628
- return false;
1629
- }
1630
- return this.negate;
1631
- }
1632
- static defaults(def) {
1633
- return minimatch.defaults(def).Minimatch;
1634
- }
1635
- };
1636
- minimatch.AST = AST;
1637
- minimatch.Minimatch = Minimatch;
1638
- minimatch.escape = escape;
1639
- minimatch.unescape = unescape;
1640
-
1641
- // src/utils/regular-expression.ts
1642
- var escapeRegExpSpecialCharacters = (text) => {
1643
- return text.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
1644
- };
1645
-
1646
- // src/utils/result.ts
1647
- var result_exports = {};
1648
- __export(result_exports, {
1649
- err: () => err,
1650
- map: () => map,
1651
- ok: () => ok,
1652
- unwrap: () => unwrap,
1653
- unwrapErr: () => unwrapErr
1654
- });
1655
- var ok = (value) => ({
1656
- isOk: true,
1657
- isErr: false,
1658
- value
1659
- });
1660
- var err = (value) => ({
1661
- isOk: false,
1662
- isErr: true,
1663
- value
1664
- });
1665
- function map(result, fn) {
1666
- if (result.isOk) {
1667
- const val = fn(result.value);
1668
- if (val instanceof Promise) {
1669
- return val.then((newVal) => ok(newVal));
1670
- } else {
1671
- return ok(val);
1672
- }
1673
- }
1674
- if (result.isErr) {
1675
- const value = result.value;
1676
- return err(value);
1677
- }
1678
- throw "should never get here";
1679
- }
1680
- var unwrap = (result) => {
1681
- if (result.isOk) {
1682
- return result.value;
1683
- } else {
1684
- throw result.value;
1685
- }
1686
- };
1687
- var unwrapErr = (result) => {
1688
- if (result.isErr) {
1689
- return result.value;
1690
- } else {
1691
- throw result.value;
1692
- }
1693
- };
1694
40
  var updateFallbackSlotVisibility = (elm) => {
1695
41
  const childNodes = internalCall(elm, "childNodes");
1696
42
  if (elm.tagName && elm.tagName.includes("-") && elm["s-cr"] && elm.tagName !== "SLOT-FB") {
@@ -1728,8 +74,9 @@
1728
74
  let childNode;
1729
75
  for (; i2 < childNodes.length; i2++) {
1730
76
  childNode = childNodes[i2];
1731
- if (childNode["s-sr"] && (!hostName || childNode["s-hn"] === hostName) && (slotName === void 0)) {
77
+ if (childNode["s-sr"] && (!hostName || childNode["s-hn"] === hostName) && (slotName === void 0 || getSlotName(childNode) === slotName)) {
1732
78
  slottedNodes.push(childNode);
79
+ if (typeof slotName !== "undefined") return slottedNodes;
1733
80
  }
1734
81
  slottedNodes = [...slottedNodes, ...getHostSlotNodes(childNode.childNodes, hostName, slotName)];
1735
82
  }
@@ -1787,6 +134,18 @@
1787
134
  node.assignedElements = assignedFactory(true);
1788
135
  node.assignedNodes = assignedFactory(false);
1789
136
  }
137
+ function dispatchSlotChangeEvent(elm) {
138
+ elm.dispatchEvent(new CustomEvent("slotchange", { bubbles: false, cancelable: false, composed: false }));
139
+ }
140
+ function findSlotFromSlottedNode(slottedNode, parentHost) {
141
+ var _a;
142
+ parentHost = parentHost || ((_a = slottedNode["s-ol"]) == null ? void 0 : _a.parentElement);
143
+ if (!parentHost) return { slotNode: null, slotName: "" };
144
+ const slotName = slottedNode["s-sn"] = getSlotName(slottedNode) || "";
145
+ const childNodes = internalCall(parentHost, "childNodes");
146
+ const slotNode = getHostSlotNodes(childNodes, parentHost.tagName, slotName)[0];
147
+ return { slotNode, slotName };
148
+ }
1790
149
  function internalCall(node, method) {
1791
150
  if ("__" + method in node) {
1792
151
  const toReturn = node["__" + method];
@@ -1797,6 +156,15 @@
1797
156
  return node[method].bind(node);
1798
157
  }
1799
158
  }
159
+
160
+ // src/utils/helpers.ts
161
+ var isDef = (v) => v != null && v !== void 0;
162
+ var isComplexType = (o) => {
163
+ o = typeof o;
164
+ return o === "object" || o === "function";
165
+ };
166
+
167
+ // src/runtime/vdom/h.ts
1800
168
  var h = (nodeName, vnodeData, ...children) => {
1801
169
  let child = null;
1802
170
  let key = null;
@@ -1840,7 +208,8 @@
1840
208
  const vnode = {
1841
209
  $flags$: 0,
1842
210
  $tag$: tag,
1843
- $text$: text,
211
+ // Normalize undefined to null to prevent rendering "undefined" as text
212
+ $text$: text != null ? text : null,
1844
213
  $elm$: null,
1845
214
  $children$: null
1846
215
  };
@@ -1857,18 +226,6 @@
1857
226
  };
1858
227
  var Host = {};
1859
228
  var isHost = (node) => node && node.$tag$ === Host;
1860
- var createSupportsRuleRe = (selector) => {
1861
- const safeSelector2 = escapeRegExpSpecialCharacters(selector);
1862
- return new RegExp(
1863
- // First capture group: match any context before the selector that's not inside @supports selector()
1864
- // Using negative lookahead to avoid matching inside @supports selector(...) condition
1865
- `(^|[^@]|@(?!supports\\s+selector\\s*\\([^{]*?${safeSelector2}))(${safeSelector2}\\b)`,
1866
- "g"
1867
- );
1868
- };
1869
- createSupportsRuleRe("::slotted");
1870
- createSupportsRuleRe(":host");
1871
- createSupportsRuleRe(":host-context");
1872
229
  var setAccessor = (elm, memberName, oldValue, newValue, isSvg, flags, initialRender) => {
1873
230
  if (oldValue === newValue) {
1874
231
  return;
@@ -1906,7 +263,7 @@
1906
263
  }
1907
264
  } else if (memberName === "key") ; else if (memberName === "ref") {
1908
265
  if (newValue) {
1909
- newValue(elm);
266
+ queueRefAttachment(newValue, elm);
1910
267
  }
1911
268
  } else if ((!elm.__lookupSetter__(memberName)) && memberName[0] === "o" && memberName[1] === "n") {
1912
269
  if (memberName[2] === "-") {
@@ -1926,6 +283,36 @@
1926
283
  plt.ael(elm, memberName, newValue, capture);
1927
284
  }
1928
285
  }
286
+ } else if (memberName[0] === "a" && memberName.startsWith("attr:")) {
287
+ const propName = memberName.slice(5);
288
+ let attrName;
289
+ {
290
+ const hostRef = getHostRef(elm);
291
+ if (hostRef && hostRef.$cmpMeta$ && hostRef.$cmpMeta$.$members$) {
292
+ const memberMeta = hostRef.$cmpMeta$.$members$[propName];
293
+ if (memberMeta && memberMeta[1]) {
294
+ attrName = memberMeta[1];
295
+ }
296
+ }
297
+ }
298
+ if (!attrName) {
299
+ attrName = propName.replace(/([a-z0-9])([A-Z])/g, "$1-$2").toLowerCase();
300
+ }
301
+ if (newValue == null || newValue === false) {
302
+ if (newValue !== false || elm.getAttribute(attrName) === "") {
303
+ elm.removeAttribute(attrName);
304
+ }
305
+ } else {
306
+ elm.setAttribute(attrName, newValue === true ? "" : newValue);
307
+ }
308
+ return;
309
+ } else if (memberName[0] === "p" && memberName.startsWith("prop:")) {
310
+ const propName = memberName.slice(5);
311
+ try {
312
+ elm[propName] = newValue;
313
+ } catch (e) {
314
+ }
315
+ return;
1929
316
  } else {
1930
317
  const isComplex = isComplexType(newValue);
1931
318
  if ((isProp || isComplex && newValue !== null) && !isSvg) {
@@ -1934,7 +321,7 @@
1934
321
  const n = newValue == null ? "" : newValue;
1935
322
  if (memberName === "list") {
1936
323
  isProp = false;
1937
- } else if (oldValue == null || elm[memberName] != n) {
324
+ } else if (oldValue == null || elm[memberName] !== n) {
1938
325
  if (typeof elm.__lookupSetter__(memberName) === "function") {
1939
326
  elm[memberName] = n;
1940
327
  } else {
@@ -2031,6 +418,8 @@
2031
418
  var checkSlotFallbackVisibility = false;
2032
419
  var checkSlotRelocate = false;
2033
420
  var isSvgMode = false;
421
+ var refCallbacksToRemove = [];
422
+ var refCallbacksToAttach = [];
2034
423
  var createElm = (oldParentVNode, newParentVNode, childIndex) => {
2035
424
  var _a;
2036
425
  const newVNode2 = newParentVNode.$children$[childIndex];
@@ -2053,7 +442,7 @@
2053
442
  );
2054
443
  }
2055
444
  }
2056
- if (newVNode2.$text$ !== null) {
445
+ if (newVNode2.$text$ != null) {
2057
446
  elm = newVNode2.$elm$ = win.document.createTextNode(newVNode2.$text$);
2058
447
  } else if (newVNode2.$flags$ & 1 /* isSlotReference */) {
2059
448
  elm = newVNode2.$elm$ = win.document.createTextNode("");
@@ -2065,9 +454,7 @@
2065
454
  isSvgMode = newVNode2.$tag$ === "svg";
2066
455
  }
2067
456
  if (!win.document) {
2068
- throw new Error(
2069
- "You are trying to render a Stencil component in an environment that doesn't support the DOM. Make sure to populate the [`window`](https://developer.mozilla.org/en-US/docs/Web/API/Window/window) object before rendering a component."
2070
- );
457
+ throw new Error("You are trying to render a Stencil component in an environment that doesn't support the DOM.");
2071
458
  }
2072
459
  elm = newVNode2.$elm$ = win.document.createElementNS(
2073
460
  isSvgMode ? SVG_NS : HTML_NS,
@@ -2109,9 +496,7 @@
2109
496
  patchSlotNode(elm);
2110
497
  oldVNode = oldParentVNode && oldParentVNode.$children$ && oldParentVNode.$children$[childIndex];
2111
498
  if (oldVNode && oldVNode.$tag$ === newVNode2.$tag$ && oldParentVNode.$elm$) {
2112
- {
2113
- putBackInOriginalLocation(oldParentVNode.$elm$, false);
2114
- }
499
+ relocateToHostRoot(oldParentVNode.$elm$);
2115
500
  }
2116
501
  {
2117
502
  addRemoveSlotScopedClass(contentRef, elm, newParentVNode.$elm$, oldParentVNode == null ? void 0 : oldParentVNode.$elm$);
@@ -2120,10 +505,37 @@
2120
505
  }
2121
506
  return elm;
2122
507
  };
508
+ var relocateToHostRoot = (parentElm) => {
509
+ plt.$flags$ |= 1 /* isTmpDisconnected */;
510
+ const host = parentElm.closest(hostTagName.toLowerCase());
511
+ if (host != null) {
512
+ const contentRefNode = Array.from(host.__childNodes || host.childNodes).find(
513
+ (ref) => ref["s-cr"]
514
+ );
515
+ const childNodeArray = Array.from(
516
+ parentElm.__childNodes || parentElm.childNodes
517
+ );
518
+ for (const childNode of contentRefNode ? childNodeArray.reverse() : childNodeArray) {
519
+ if (childNode["s-sh"] != null) {
520
+ insertBefore(host, childNode, contentRefNode != null ? contentRefNode : null);
521
+ childNode["s-sh"] = void 0;
522
+ checkSlotRelocate = true;
523
+ }
524
+ }
525
+ }
526
+ plt.$flags$ &= -2 /* isTmpDisconnected */;
527
+ };
2123
528
  var putBackInOriginalLocation = (parentElm, recursive) => {
2124
529
  plt.$flags$ |= 1 /* isTmpDisconnected */;
2125
530
  const oldSlotChildNodes = Array.from(parentElm.__childNodes || parentElm.childNodes);
2126
- if (parentElm["s-sr"] && BUILD.experimentalSlotFixes) ;
531
+ if (parentElm["s-sr"]) {
532
+ let node = parentElm;
533
+ while (node = node.nextSibling) {
534
+ if (node && node["s-sn"] === parentElm["s-sn"] && node["s-sh"] === hostTagName) {
535
+ oldSlotChildNodes.push(node);
536
+ }
537
+ }
538
+ }
2127
539
  for (let i2 = oldSlotChildNodes.length - 1; i2 >= 0; i2--) {
2128
540
  const childNode = oldSlotChildNodes[i2];
2129
541
  if (childNode["s-hn"] !== hostTagName && childNode["s-ol"]) {
@@ -2296,11 +708,17 @@
2296
708
  const tag = newVNode2.$tag$;
2297
709
  const text = newVNode2.$text$;
2298
710
  let defaultHolder;
2299
- if (text === null) {
711
+ if (text == null) {
2300
712
  {
2301
713
  isSvgMode = tag === "svg" ? true : tag === "foreignObject" ? false : isSvgMode;
2302
714
  }
2303
715
  {
716
+ if (tag === "slot" && !useNativeShadowDom) {
717
+ if (oldVNode.$name$ !== newVNode2.$name$) {
718
+ newVNode2.$elm$["s-sn"] = newVNode2.$name$ || "";
719
+ relocateToHostRoot(newVNode2.$elm$.parentElement);
720
+ }
721
+ }
2304
722
  updateElement(oldVNode, newVNode2, isSvgMode);
2305
723
  }
2306
724
  if (oldChildren !== null && newChildren !== null) {
@@ -2337,7 +755,7 @@
2337
755
  const slotName = childNode["s-sn"];
2338
756
  for (j = hostContentNodes.length - 1; j >= 0; j--) {
2339
757
  node = hostContentNodes[j];
2340
- if (!node["s-cn"] && !node["s-nr"] && node["s-hn"] !== childNode["s-hn"] && (true)) {
758
+ if (!node["s-cn"] && !node["s-nr"] && node["s-hn"] !== childNode["s-hn"] && (!node["s-sh"] || node["s-sh"] !== childNode["s-hn"])) {
2341
759
  if (isNodeLocatedInSlot(node, slotName)) {
2342
760
  let relocateNodeData = relocateNodes.find((r) => r.$nodeToRelocate$ === node);
2343
761
  checkSlotFallbackVisibility = true;
@@ -2377,15 +795,39 @@
2377
795
  };
2378
796
  var nullifyVNodeRefs = (vNode) => {
2379
797
  {
2380
- vNode.$attrs$ && vNode.$attrs$.ref && vNode.$attrs$.ref(null);
798
+ if (vNode.$attrs$ && vNode.$attrs$.ref) {
799
+ refCallbacksToRemove.push(() => vNode.$attrs$.ref(null));
800
+ }
2381
801
  vNode.$children$ && vNode.$children$.map(nullifyVNodeRefs);
2382
802
  }
2383
803
  };
2384
- var insertBefore = (parent, newNode, reference) => {
2385
- if (typeof newNode["s-sn"] === "string" && !!newNode["s-sr"] && !!newNode["s-cr"]) {
2386
- addRemoveSlotScopedClass(newNode["s-cr"], newNode, parent, newNode.parentElement);
804
+ var queueRefAttachment = (refCallback, elm) => {
805
+ {
806
+ refCallbacksToAttach.push(() => refCallback(elm));
2387
807
  }
808
+ };
809
+ var flushQueuedRefCallbacks = () => {
2388
810
  {
811
+ refCallbacksToRemove.forEach((cb) => cb());
812
+ refCallbacksToRemove.length = 0;
813
+ refCallbacksToAttach.forEach((cb) => cb());
814
+ refCallbacksToAttach.length = 0;
815
+ }
816
+ };
817
+ var insertBefore = (parent, newNode, reference, isInitialLoad) => {
818
+ {
819
+ if (typeof newNode["s-sn"] === "string" && !!newNode["s-sr"] && !!newNode["s-cr"]) {
820
+ addRemoveSlotScopedClass(newNode["s-cr"], newNode, parent, newNode.parentElement);
821
+ } else if (typeof newNode["s-sn"] === "string") {
822
+ parent.insertBefore(newNode, reference);
823
+ const { slotNode } = findSlotFromSlottedNode(newNode);
824
+ if (slotNode && !isInitialLoad) dispatchSlotChangeEvent(slotNode);
825
+ return newNode;
826
+ }
827
+ }
828
+ if (parent.__insertBefore) {
829
+ return parent.__insertBefore(newNode, reference);
830
+ } else {
2389
831
  return parent == null ? void 0 : parent.insertBefore(newNode, reference);
2390
832
  }
2391
833
  };
@@ -2457,7 +899,12 @@
2457
899
  if (!nodeToRelocate["s-ol"] && win.document) {
2458
900
  const orgLocationNode = win.document.createTextNode("");
2459
901
  orgLocationNode["s-nr"] = nodeToRelocate;
2460
- insertBefore(nodeToRelocate.parentNode, nodeToRelocate["s-ol"] = orgLocationNode, nodeToRelocate);
902
+ insertBefore(
903
+ nodeToRelocate.parentNode,
904
+ nodeToRelocate["s-ol"] = orgLocationNode,
905
+ nodeToRelocate,
906
+ isInitialLoad
907
+ );
2461
908
  }
2462
909
  }
2463
910
  for (const relocateData of relocateNodes) {
@@ -2469,7 +916,7 @@
2469
916
  if (slotRefNode) {
2470
917
  const parentNodeRef = slotRefNode.parentNode;
2471
918
  let insertBeforeNode = slotRefNode.nextSibling;
2472
- {
919
+ if (insertBeforeNode && insertBeforeNode.nodeType === 1 /* ElementNode */) {
2473
920
  let orgLocationNode = (_b = nodeToRelocate["s-ol"]) == null ? void 0 : _b.previousSibling;
2474
921
  while (orgLocationNode) {
2475
922
  let refNode = (_c = orgLocationNode["s-nr"]) != null ? _c : null;
@@ -2490,10 +937,18 @@
2490
937
  const nextSibling = nodeToRelocate.__nextSibling || nodeToRelocate.nextSibling;
2491
938
  if (!insertBeforeNode && parentNodeRef !== parent || nextSibling !== insertBeforeNode) {
2492
939
  if (nodeToRelocate !== insertBeforeNode) {
2493
- if (!nodeToRelocate["s-hn"] && nodeToRelocate["s-ol"]) {
2494
- nodeToRelocate["s-hn"] = nodeToRelocate["s-ol"].parentNode.nodeName;
940
+ insertBefore(parentNodeRef, nodeToRelocate, insertBeforeNode, isInitialLoad);
941
+ if (nodeToRelocate.nodeType === 8 /* CommentNode */ && nodeToRelocate.nodeValue.startsWith("s-nt-")) {
942
+ const textNode = win.document.createTextNode(nodeToRelocate.nodeValue.replace(/^s-nt-/, ""));
943
+ textNode["s-hn"] = nodeToRelocate["s-hn"];
944
+ textNode["s-sn"] = nodeToRelocate["s-sn"];
945
+ textNode["s-sh"] = nodeToRelocate["s-sh"];
946
+ textNode["s-sr"] = nodeToRelocate["s-sr"];
947
+ textNode["s-ol"] = nodeToRelocate["s-ol"];
948
+ textNode["s-ol"]["s-nr"] = textNode;
949
+ insertBefore(nodeToRelocate.parentNode, textNode, nodeToRelocate, isInitialLoad);
950
+ nodeToRelocate.parentNode.removeChild(nodeToRelocate);
2495
951
  }
2496
- insertBefore(parentNodeRef, nodeToRelocate, insertBeforeNode);
2497
952
  if (nodeToRelocate.nodeType === 1 /* ElementNode */ && nodeToRelocate.tagName !== "SLOT-FB") {
2498
953
  nodeToRelocate.hidden = (_d = nodeToRelocate["s-ih"]) != null ? _d : false;
2499
954
  }
@@ -2511,18 +966,26 @@
2511
966
  plt.$flags$ &= -2 /* isTmpDisconnected */;
2512
967
  relocateNodes.length = 0;
2513
968
  }
2514
- if (BUILD.experimentalScopedSlotChanges && cmpMeta.$flags$ & 2 /* scopedCssEncapsulation */) {
969
+ if (!useNativeShadowDom && !(cmpMeta.$flags$ & 1 /* shadowDomEncapsulation */) && hostElm["s-cr"]) {
2515
970
  const children = rootVnode.$elm$.__childNodes || rootVnode.$elm$.childNodes;
2516
971
  for (const childNode of children) {
2517
- if (childNode["s-hn"] !== hostTagName && !childNode["s-sh"] && childNode.nodeType === 1 /* ElementNode */) {
972
+ if (childNode["s-hn"] !== hostTagName && !childNode["s-sh"]) {
2518
973
  if (isInitialLoad && childNode["s-ih"] == null) {
2519
974
  childNode["s-ih"] = (_e = childNode.hidden) != null ? _e : false;
2520
975
  }
2521
- childNode.hidden = true;
976
+ if (childNode.nodeType === 1 /* ElementNode */) {
977
+ childNode.hidden = true;
978
+ } else if (childNode.nodeType === 3 /* TextNode */ && !!childNode.nodeValue.trim()) {
979
+ const textCommentNode = win.document.createComment("s-nt-" + childNode.nodeValue);
980
+ textCommentNode["s-sn"] = childNode["s-sn"];
981
+ insertBefore(childNode.parentNode, textCommentNode, childNode, isInitialLoad);
982
+ childNode.parentNode.removeChild(childNode);
983
+ }
2522
984
  }
2523
985
  }
2524
986
  }
2525
987
  contentRef = void 0;
988
+ flushQueuedRefCallbacks();
2526
989
  };
2527
990
 
2528
991
  /**
@@ -3308,7 +1771,7 @@
3308
1771
  *
3309
1772
  * @returns {string}
3310
1773
  */
3311
- const process$1 = () => {
1774
+ const process = () => {
3312
1775
  const { config, constants } = getState();
3313
1776
  const step = " ".repeat(config.tab_size);
3314
1777
  const tag_wrap = config.tag_wrap;
@@ -3525,7 +1988,7 @@
3525
1988
 
3526
1989
  html = minify(html);
3527
1990
  enqueue(html);
3528
- html = process$1();
1991
+ html = process();
3529
1992
 
3530
1993
  /* Revert html text within attribute values. */
3531
1994
  html = unsetIgnoreAttribute(html);