@forsakringskassan/vite-lib-config 3.4.4 → 3.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +8 -0
- package/dist/tsdoc-metadata.json +1 -1
- package/dist/vite.config.cjs +927 -182
- package/dist/vite.config.d.ts +1 -1
- package/dist/vite.config.mjs +917 -172
- package/package.json +2 -2
package/dist/vite.config.cjs
CHANGED
|
@@ -29,6 +29,717 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
29
29
|
));
|
|
30
30
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
31
31
|
|
|
32
|
+
// node_modules/@leeoniya/ufuzzy/dist/uFuzzy.cjs
|
|
33
|
+
var require_uFuzzy = __commonJS({
|
|
34
|
+
"node_modules/@leeoniya/ufuzzy/dist/uFuzzy.cjs"(exports2, module2) {
|
|
35
|
+
"use strict";
|
|
36
|
+
var cmp = (a, b) => a > b ? 1 : a < b ? -1 : 0;
|
|
37
|
+
var inf = Infinity;
|
|
38
|
+
var escapeRegExp = (str) => str.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
39
|
+
var EXACT_HERE = "eexxaacctt";
|
|
40
|
+
var PUNCT_RE = new RegExp("\\p{P}", "gu");
|
|
41
|
+
var LATIN_UPPER = "A-Z";
|
|
42
|
+
var LATIN_LOWER = "a-z";
|
|
43
|
+
var COLLATE_ARGS = ["en", { numeric: true, sensitivity: "base" }];
|
|
44
|
+
var swapAlpha = (str, upper, lower) => str.replace(LATIN_UPPER, upper).replace(LATIN_LOWER, lower);
|
|
45
|
+
var OPTS = {
|
|
46
|
+
// whether regexps use a /u unicode flag
|
|
47
|
+
unicode: false,
|
|
48
|
+
alpha: null,
|
|
49
|
+
// term segmentation & punct/whitespace merging
|
|
50
|
+
interSplit: "[^A-Za-z\\d']+",
|
|
51
|
+
intraSplit: "[a-z][A-Z]",
|
|
52
|
+
// inter bounds that will be used to increase lft2/rgt2 info counters
|
|
53
|
+
interBound: "[^A-Za-z\\d]",
|
|
54
|
+
// intra bounds that will be used to increase lft1/rgt1 info counters
|
|
55
|
+
intraBound: "[A-Za-z]\\d|\\d[A-Za-z]|[a-z][A-Z]",
|
|
56
|
+
// inter-bounds mode
|
|
57
|
+
// 2 = strict (will only match 'man' on whitepace and punct boundaries: Mega Man, Mega_Man, mega.man)
|
|
58
|
+
// 1 = loose (plus allowance for alpha-num and case-change boundaries: MegaMan, 0007man)
|
|
59
|
+
// 0 = any (will match 'man' as any substring: megamaniac)
|
|
60
|
+
interLft: 0,
|
|
61
|
+
interRgt: 0,
|
|
62
|
+
// allowance between terms
|
|
63
|
+
interChars: ".",
|
|
64
|
+
interIns: inf,
|
|
65
|
+
// allowance between chars in terms
|
|
66
|
+
intraChars: "[a-z\\d']",
|
|
67
|
+
// internally case-insensitive
|
|
68
|
+
intraIns: null,
|
|
69
|
+
intraContr: "'[a-z]{1,2}\\b",
|
|
70
|
+
// multi-insert or single-error mode
|
|
71
|
+
intraMode: 0,
|
|
72
|
+
// single-error bounds for errors within terms, default requires exact first char
|
|
73
|
+
intraSlice: [1, inf],
|
|
74
|
+
// single-error tolerance toggles
|
|
75
|
+
intraSub: null,
|
|
76
|
+
intraTrn: null,
|
|
77
|
+
intraDel: null,
|
|
78
|
+
// can post-filter matches that are too far apart in distance or length
|
|
79
|
+
// (since intraIns is between each char, it can accum to nonsense matches)
|
|
80
|
+
intraFilt: (term, match2, index) => true,
|
|
81
|
+
// should this also accept WIP info?
|
|
82
|
+
toUpper: (str) => str.toLocaleUpperCase(),
|
|
83
|
+
toLower: (str) => str.toLocaleLowerCase(),
|
|
84
|
+
compare: null,
|
|
85
|
+
// final sorting fn
|
|
86
|
+
sort: (info, haystack, needle, compare = cmp) => {
|
|
87
|
+
let {
|
|
88
|
+
idx,
|
|
89
|
+
chars,
|
|
90
|
+
terms,
|
|
91
|
+
interLft2,
|
|
92
|
+
interLft1,
|
|
93
|
+
// interRgt2,
|
|
94
|
+
// interRgt1,
|
|
95
|
+
start,
|
|
96
|
+
intraIns,
|
|
97
|
+
interIns,
|
|
98
|
+
cases
|
|
99
|
+
} = info;
|
|
100
|
+
return idx.map((v, i) => i).sort((ia, ib) => (
|
|
101
|
+
// most contig chars matched
|
|
102
|
+
chars[ib] - chars[ia] || // least char intra-fuzz (most contiguous)
|
|
103
|
+
intraIns[ia] - intraIns[ib] || // most prefix bounds, boosted by full term matches
|
|
104
|
+
terms[ib] + interLft2[ib] + 0.5 * interLft1[ib] - (terms[ia] + interLft2[ia] + 0.5 * interLft1[ia]) || // highest density of match (least span)
|
|
105
|
+
// span[ia] - span[ib] ||
|
|
106
|
+
// highest density of match (least term inter-fuzz)
|
|
107
|
+
interIns[ia] - interIns[ib] || // earliest start of match
|
|
108
|
+
start[ia] - start[ib] || // case match
|
|
109
|
+
cases[ib] - cases[ia] || // alphabetic
|
|
110
|
+
compare(haystack[idx[ia]], haystack[idx[ib]])
|
|
111
|
+
));
|
|
112
|
+
}
|
|
113
|
+
};
|
|
114
|
+
var lazyRepeat = (chars, limit) => limit == 0 ? "" : limit == 1 ? chars + "??" : limit == inf ? chars + "*?" : chars + `{0,${limit}}?`;
|
|
115
|
+
var mode2Tpl = "(?:\\b|_)";
|
|
116
|
+
function uFuzzy2(opts) {
|
|
117
|
+
opts = Object.assign({}, OPTS, opts);
|
|
118
|
+
let {
|
|
119
|
+
unicode,
|
|
120
|
+
interLft,
|
|
121
|
+
interRgt,
|
|
122
|
+
intraMode,
|
|
123
|
+
intraSlice,
|
|
124
|
+
intraIns,
|
|
125
|
+
intraSub,
|
|
126
|
+
intraTrn,
|
|
127
|
+
intraDel,
|
|
128
|
+
intraContr,
|
|
129
|
+
intraSplit: _intraSplit,
|
|
130
|
+
interSplit: _interSplit,
|
|
131
|
+
intraBound: _intraBound,
|
|
132
|
+
interBound: _interBound,
|
|
133
|
+
intraChars,
|
|
134
|
+
toUpper,
|
|
135
|
+
toLower,
|
|
136
|
+
compare
|
|
137
|
+
} = opts;
|
|
138
|
+
intraIns ??= intraMode;
|
|
139
|
+
intraSub ??= intraMode;
|
|
140
|
+
intraTrn ??= intraMode;
|
|
141
|
+
intraDel ??= intraMode;
|
|
142
|
+
compare ??= typeof Intl == "undefined" ? cmp : new Intl.Collator(...COLLATE_ARGS).compare;
|
|
143
|
+
let alpha = opts.letters ?? opts.alpha;
|
|
144
|
+
if (alpha != null) {
|
|
145
|
+
let upper = toUpper(alpha);
|
|
146
|
+
let lower = toLower(alpha);
|
|
147
|
+
_interSplit = swapAlpha(_interSplit, upper, lower);
|
|
148
|
+
_intraSplit = swapAlpha(_intraSplit, upper, lower);
|
|
149
|
+
_interBound = swapAlpha(_interBound, upper, lower);
|
|
150
|
+
_intraBound = swapAlpha(_intraBound, upper, lower);
|
|
151
|
+
intraChars = swapAlpha(intraChars, upper, lower);
|
|
152
|
+
intraContr = swapAlpha(intraContr, upper, lower);
|
|
153
|
+
}
|
|
154
|
+
let uFlag = unicode ? "u" : "";
|
|
155
|
+
const quotedAny = '".+?"';
|
|
156
|
+
const EXACTS_RE = new RegExp(quotedAny, "gi" + uFlag);
|
|
157
|
+
const NEGS_RE = new RegExp(`(?:\\s+|^)-(?:${intraChars}+|${quotedAny})`, "gi" + uFlag);
|
|
158
|
+
let { intraRules } = opts;
|
|
159
|
+
if (intraRules == null) {
|
|
160
|
+
intraRules = (p) => {
|
|
161
|
+
let _intraSlice = OPTS.intraSlice, _intraIns = 0, _intraSub = 0, _intraTrn = 0, _intraDel = 0;
|
|
162
|
+
if (/[^\d]/.test(p)) {
|
|
163
|
+
let plen = p.length;
|
|
164
|
+
if (plen <= 4) {
|
|
165
|
+
if (plen >= 3) {
|
|
166
|
+
_intraTrn = Math.min(intraTrn, 1);
|
|
167
|
+
if (plen == 4)
|
|
168
|
+
_intraIns = Math.min(intraIns, 1);
|
|
169
|
+
}
|
|
170
|
+
} else {
|
|
171
|
+
_intraSlice = intraSlice;
|
|
172
|
+
_intraIns = intraIns, _intraSub = intraSub, _intraTrn = intraTrn, _intraDel = intraDel;
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
return {
|
|
176
|
+
intraSlice: _intraSlice,
|
|
177
|
+
intraIns: _intraIns,
|
|
178
|
+
intraSub: _intraSub,
|
|
179
|
+
intraTrn: _intraTrn,
|
|
180
|
+
intraDel: _intraDel
|
|
181
|
+
};
|
|
182
|
+
};
|
|
183
|
+
}
|
|
184
|
+
let withIntraSplit = !!_intraSplit;
|
|
185
|
+
let intraSplit = new RegExp(_intraSplit, "g" + uFlag);
|
|
186
|
+
let interSplit = new RegExp(_interSplit, "g" + uFlag);
|
|
187
|
+
let trimRe = new RegExp("^" + _interSplit + "|" + _interSplit + "$", "g" + uFlag);
|
|
188
|
+
let contrsRe = new RegExp(intraContr, "gi" + uFlag);
|
|
189
|
+
const split = (needle, keepCase = false) => {
|
|
190
|
+
let exacts = [];
|
|
191
|
+
needle = needle.replace(EXACTS_RE, (m) => {
|
|
192
|
+
exacts.push(m);
|
|
193
|
+
return EXACT_HERE;
|
|
194
|
+
});
|
|
195
|
+
needle = needle.replace(trimRe, "");
|
|
196
|
+
if (!keepCase)
|
|
197
|
+
needle = toLower(needle);
|
|
198
|
+
if (withIntraSplit)
|
|
199
|
+
needle = needle.replace(intraSplit, (m) => m[0] + " " + m[1]);
|
|
200
|
+
let j = 0;
|
|
201
|
+
return needle.split(interSplit).filter((t) => t != "").map((v) => v === EXACT_HERE ? exacts[j++] : v);
|
|
202
|
+
};
|
|
203
|
+
const NUM_OR_ALPHA_RE = /[^\d]+|\d+/g;
|
|
204
|
+
const prepQuery = (needle, capt = 0, interOR = false) => {
|
|
205
|
+
let parts = split(needle);
|
|
206
|
+
if (parts.length == 0)
|
|
207
|
+
return [];
|
|
208
|
+
let contrs = Array(parts.length).fill("");
|
|
209
|
+
parts = parts.map((p, pi) => p.replace(contrsRe, (m) => {
|
|
210
|
+
contrs[pi] = m;
|
|
211
|
+
return "";
|
|
212
|
+
}));
|
|
213
|
+
let reTpl;
|
|
214
|
+
if (intraMode == 1) {
|
|
215
|
+
reTpl = parts.map((p, pi) => {
|
|
216
|
+
if (p[0] === '"')
|
|
217
|
+
return escapeRegExp(p.slice(1, -1));
|
|
218
|
+
let reTpl2 = "";
|
|
219
|
+
for (let m of p.matchAll(NUM_OR_ALPHA_RE)) {
|
|
220
|
+
let p2 = m[0];
|
|
221
|
+
let {
|
|
222
|
+
intraSlice: intraSlice2,
|
|
223
|
+
intraIns: intraIns2,
|
|
224
|
+
intraSub: intraSub2,
|
|
225
|
+
intraTrn: intraTrn2,
|
|
226
|
+
intraDel: intraDel2
|
|
227
|
+
} = intraRules(p2);
|
|
228
|
+
if (intraIns2 + intraSub2 + intraTrn2 + intraDel2 == 0)
|
|
229
|
+
reTpl2 += p2 + contrs[pi];
|
|
230
|
+
else {
|
|
231
|
+
let [lftIdx, rgtIdx] = intraSlice2;
|
|
232
|
+
let lftChar = p2.slice(0, lftIdx);
|
|
233
|
+
let rgtChar = p2.slice(rgtIdx);
|
|
234
|
+
let chars = p2.slice(lftIdx, rgtIdx);
|
|
235
|
+
if (intraIns2 == 1 && lftChar.length == 1 && lftChar != chars[0])
|
|
236
|
+
lftChar += "(?!" + lftChar + ")";
|
|
237
|
+
let numChars = chars.length;
|
|
238
|
+
let variants = [p2];
|
|
239
|
+
if (intraSub2) {
|
|
240
|
+
for (let i = 0; i < numChars; i++)
|
|
241
|
+
variants.push(lftChar + chars.slice(0, i) + intraChars + chars.slice(i + 1) + rgtChar);
|
|
242
|
+
}
|
|
243
|
+
if (intraTrn2) {
|
|
244
|
+
for (let i = 0; i < numChars - 1; i++) {
|
|
245
|
+
if (chars[i] != chars[i + 1])
|
|
246
|
+
variants.push(lftChar + chars.slice(0, i) + chars[i + 1] + chars[i] + chars.slice(i + 2) + rgtChar);
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
if (intraDel2) {
|
|
250
|
+
for (let i = 0; i < numChars; i++)
|
|
251
|
+
variants.push(lftChar + chars.slice(0, i + 1) + "?" + chars.slice(i + 1) + rgtChar);
|
|
252
|
+
}
|
|
253
|
+
if (intraIns2) {
|
|
254
|
+
let intraInsTpl = lazyRepeat(intraChars, 1);
|
|
255
|
+
for (let i = 0; i < numChars; i++)
|
|
256
|
+
variants.push(lftChar + chars.slice(0, i) + intraInsTpl + chars.slice(i) + rgtChar);
|
|
257
|
+
}
|
|
258
|
+
reTpl2 += "(?:" + variants.join("|") + ")" + contrs[pi];
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
return reTpl2;
|
|
262
|
+
});
|
|
263
|
+
} else {
|
|
264
|
+
let intraInsTpl = lazyRepeat(intraChars, intraIns);
|
|
265
|
+
if (capt == 2 && intraIns > 0) {
|
|
266
|
+
intraInsTpl = ")(" + intraInsTpl + ")(";
|
|
267
|
+
}
|
|
268
|
+
reTpl = parts.map((p, pi) => p[0] === '"' ? escapeRegExp(p.slice(1, -1)) : p.split("").map((c, i, chars) => {
|
|
269
|
+
if (intraIns == 1 && i == 0 && chars.length > 1 && c != chars[i + 1])
|
|
270
|
+
c += "(?!" + c + ")";
|
|
271
|
+
return c;
|
|
272
|
+
}).join(intraInsTpl) + contrs[pi]);
|
|
273
|
+
}
|
|
274
|
+
let preTpl = interLft == 2 ? mode2Tpl : "";
|
|
275
|
+
let sufTpl = interRgt == 2 ? mode2Tpl : "";
|
|
276
|
+
let interCharsTpl = sufTpl + lazyRepeat(opts.interChars, opts.interIns) + preTpl;
|
|
277
|
+
if (capt > 0) {
|
|
278
|
+
if (interOR) {
|
|
279
|
+
reTpl = preTpl + "(" + reTpl.join(")" + sufTpl + "|" + preTpl + "(") + ")" + sufTpl;
|
|
280
|
+
} else {
|
|
281
|
+
reTpl = "(" + reTpl.join(")(" + interCharsTpl + ")(") + ")";
|
|
282
|
+
reTpl = "(.??" + preTpl + ")" + reTpl + "(" + sufTpl + ".*)";
|
|
283
|
+
}
|
|
284
|
+
} else {
|
|
285
|
+
reTpl = reTpl.join(interCharsTpl);
|
|
286
|
+
reTpl = preTpl + reTpl + sufTpl;
|
|
287
|
+
}
|
|
288
|
+
return [new RegExp(reTpl, "i" + uFlag), parts, contrs];
|
|
289
|
+
};
|
|
290
|
+
const filter3 = (haystack, needle, idxs) => {
|
|
291
|
+
let [query] = prepQuery(needle);
|
|
292
|
+
if (query == null)
|
|
293
|
+
return null;
|
|
294
|
+
let out = [];
|
|
295
|
+
if (idxs != null) {
|
|
296
|
+
for (let i = 0; i < idxs.length; i++) {
|
|
297
|
+
let idx = idxs[i];
|
|
298
|
+
query.test(haystack[idx]) && out.push(idx);
|
|
299
|
+
}
|
|
300
|
+
} else {
|
|
301
|
+
for (let i = 0; i < haystack.length; i++)
|
|
302
|
+
query.test(haystack[i]) && out.push(i);
|
|
303
|
+
}
|
|
304
|
+
return out;
|
|
305
|
+
};
|
|
306
|
+
let withIntraBound = !!_intraBound;
|
|
307
|
+
let interBound = new RegExp(_interBound, uFlag);
|
|
308
|
+
let intraBound = new RegExp(_intraBound, uFlag);
|
|
309
|
+
const info = (idxs, haystack, needle) => {
|
|
310
|
+
let [query, parts, contrs] = prepQuery(needle, 1);
|
|
311
|
+
let partsCased = split(needle, true);
|
|
312
|
+
let [queryR] = prepQuery(needle, 2);
|
|
313
|
+
let partsLen = parts.length;
|
|
314
|
+
let _terms = Array(partsLen);
|
|
315
|
+
let _termsCased = Array(partsLen);
|
|
316
|
+
for (let j = 0; j < partsLen; j++) {
|
|
317
|
+
let part = parts[j];
|
|
318
|
+
let partCased = partsCased[j];
|
|
319
|
+
let term = part[0] == '"' ? part.slice(1, -1) : part + contrs[j];
|
|
320
|
+
let termCased = partCased[0] == '"' ? partCased.slice(1, -1) : partCased + contrs[j];
|
|
321
|
+
_terms[j] = term;
|
|
322
|
+
_termsCased[j] = termCased;
|
|
323
|
+
}
|
|
324
|
+
let len = idxs.length;
|
|
325
|
+
let field = Array(len).fill(0);
|
|
326
|
+
let info2 = {
|
|
327
|
+
// idx in haystack
|
|
328
|
+
idx: Array(len),
|
|
329
|
+
// start of match
|
|
330
|
+
start: field.slice(),
|
|
331
|
+
// length of match
|
|
332
|
+
// span: field.slice(),
|
|
333
|
+
// contiguous chars matched
|
|
334
|
+
chars: field.slice(),
|
|
335
|
+
// case matched in term (via term.includes(match))
|
|
336
|
+
cases: field.slice(),
|
|
337
|
+
// contiguous (no fuzz) and bounded terms (intra=0, lft2/1, rgt2/1)
|
|
338
|
+
// excludes terms that are contiguous but have < 2 bounds (substrings)
|
|
339
|
+
terms: field.slice(),
|
|
340
|
+
// cumulative length of unmatched chars (fuzz) within span
|
|
341
|
+
interIns: field.slice(),
|
|
342
|
+
// between terms
|
|
343
|
+
intraIns: field.slice(),
|
|
344
|
+
// within terms
|
|
345
|
+
// interLft/interRgt counters
|
|
346
|
+
interLft2: field.slice(),
|
|
347
|
+
interRgt2: field.slice(),
|
|
348
|
+
interLft1: field.slice(),
|
|
349
|
+
interRgt1: field.slice(),
|
|
350
|
+
ranges: Array(len)
|
|
351
|
+
};
|
|
352
|
+
let mayDiscard = interLft == 1 || interRgt == 1;
|
|
353
|
+
let ii = 0;
|
|
354
|
+
for (let i = 0; i < idxs.length; i++) {
|
|
355
|
+
let mhstr = haystack[idxs[i]];
|
|
356
|
+
let m = mhstr.match(query);
|
|
357
|
+
let start = m.index + m[1].length;
|
|
358
|
+
let idxAcc = start;
|
|
359
|
+
let disc = false;
|
|
360
|
+
let lft2 = 0;
|
|
361
|
+
let lft1 = 0;
|
|
362
|
+
let rgt2 = 0;
|
|
363
|
+
let rgt1 = 0;
|
|
364
|
+
let chars = 0;
|
|
365
|
+
let terms = 0;
|
|
366
|
+
let cases = 0;
|
|
367
|
+
let inter = 0;
|
|
368
|
+
let intra = 0;
|
|
369
|
+
let refine = [];
|
|
370
|
+
for (let j = 0, k = 2; j < partsLen; j++, k += 2) {
|
|
371
|
+
let group = toLower(m[k]);
|
|
372
|
+
let term = _terms[j];
|
|
373
|
+
let termCased = _termsCased[j];
|
|
374
|
+
let termLen = term.length;
|
|
375
|
+
let groupLen = group.length;
|
|
376
|
+
let fullMatch = group == term;
|
|
377
|
+
if (m[k] == termCased)
|
|
378
|
+
cases++;
|
|
379
|
+
if (!fullMatch && m[k + 1].length >= termLen) {
|
|
380
|
+
let idxOf = toLower(m[k + 1]).indexOf(term);
|
|
381
|
+
if (idxOf > -1) {
|
|
382
|
+
refine.push(idxAcc, groupLen, idxOf, termLen);
|
|
383
|
+
idxAcc += refineMatch(m, k, idxOf, termLen);
|
|
384
|
+
group = term;
|
|
385
|
+
groupLen = termLen;
|
|
386
|
+
fullMatch = true;
|
|
387
|
+
if (j == 0)
|
|
388
|
+
start = idxAcc;
|
|
389
|
+
}
|
|
390
|
+
}
|
|
391
|
+
if (mayDiscard || fullMatch) {
|
|
392
|
+
let lftCharIdx = idxAcc - 1;
|
|
393
|
+
let rgtCharIdx = idxAcc + groupLen;
|
|
394
|
+
let isPre = false;
|
|
395
|
+
let isSuf = false;
|
|
396
|
+
if (lftCharIdx == -1 || interBound.test(mhstr[lftCharIdx])) {
|
|
397
|
+
fullMatch && lft2++;
|
|
398
|
+
isPre = true;
|
|
399
|
+
} else {
|
|
400
|
+
if (interLft == 2) {
|
|
401
|
+
disc = true;
|
|
402
|
+
break;
|
|
403
|
+
}
|
|
404
|
+
if (withIntraBound && intraBound.test(mhstr[lftCharIdx] + mhstr[lftCharIdx + 1])) {
|
|
405
|
+
fullMatch && lft1++;
|
|
406
|
+
isPre = true;
|
|
407
|
+
} else {
|
|
408
|
+
if (interLft == 1) {
|
|
409
|
+
let junk = m[k + 1];
|
|
410
|
+
let junkIdx = idxAcc + groupLen;
|
|
411
|
+
if (junk.length >= termLen) {
|
|
412
|
+
let idxOf = 0;
|
|
413
|
+
let found = false;
|
|
414
|
+
let re = new RegExp(term, "ig" + uFlag);
|
|
415
|
+
let m2;
|
|
416
|
+
while (m2 = re.exec(junk)) {
|
|
417
|
+
idxOf = m2.index;
|
|
418
|
+
let charIdx = junkIdx + idxOf;
|
|
419
|
+
let lftCharIdx2 = charIdx - 1;
|
|
420
|
+
if (lftCharIdx2 == -1 || interBound.test(mhstr[lftCharIdx2])) {
|
|
421
|
+
lft2++;
|
|
422
|
+
found = true;
|
|
423
|
+
break;
|
|
424
|
+
} else if (intraBound.test(mhstr[lftCharIdx2] + mhstr[charIdx])) {
|
|
425
|
+
lft1++;
|
|
426
|
+
found = true;
|
|
427
|
+
break;
|
|
428
|
+
}
|
|
429
|
+
}
|
|
430
|
+
if (found) {
|
|
431
|
+
isPre = true;
|
|
432
|
+
refine.push(idxAcc, groupLen, idxOf, termLen);
|
|
433
|
+
idxAcc += refineMatch(m, k, idxOf, termLen);
|
|
434
|
+
group = term;
|
|
435
|
+
groupLen = termLen;
|
|
436
|
+
fullMatch = true;
|
|
437
|
+
if (j == 0)
|
|
438
|
+
start = idxAcc;
|
|
439
|
+
}
|
|
440
|
+
}
|
|
441
|
+
if (!isPre) {
|
|
442
|
+
disc = true;
|
|
443
|
+
break;
|
|
444
|
+
}
|
|
445
|
+
}
|
|
446
|
+
}
|
|
447
|
+
}
|
|
448
|
+
if (rgtCharIdx == mhstr.length || interBound.test(mhstr[rgtCharIdx])) {
|
|
449
|
+
fullMatch && rgt2++;
|
|
450
|
+
isSuf = true;
|
|
451
|
+
} else {
|
|
452
|
+
if (interRgt == 2) {
|
|
453
|
+
disc = true;
|
|
454
|
+
break;
|
|
455
|
+
}
|
|
456
|
+
if (withIntraBound && intraBound.test(mhstr[rgtCharIdx - 1] + mhstr[rgtCharIdx])) {
|
|
457
|
+
fullMatch && rgt1++;
|
|
458
|
+
isSuf = true;
|
|
459
|
+
} else {
|
|
460
|
+
if (interRgt == 1) {
|
|
461
|
+
disc = true;
|
|
462
|
+
break;
|
|
463
|
+
}
|
|
464
|
+
}
|
|
465
|
+
}
|
|
466
|
+
if (fullMatch) {
|
|
467
|
+
chars += termLen;
|
|
468
|
+
if (isPre && isSuf)
|
|
469
|
+
terms++;
|
|
470
|
+
}
|
|
471
|
+
}
|
|
472
|
+
if (groupLen > termLen)
|
|
473
|
+
intra += groupLen - termLen;
|
|
474
|
+
if (j > 0)
|
|
475
|
+
inter += m[k - 1].length;
|
|
476
|
+
if (!opts.intraFilt(term, group, idxAcc)) {
|
|
477
|
+
disc = true;
|
|
478
|
+
break;
|
|
479
|
+
}
|
|
480
|
+
if (j < partsLen - 1)
|
|
481
|
+
idxAcc += groupLen + m[k + 1].length;
|
|
482
|
+
}
|
|
483
|
+
if (!disc) {
|
|
484
|
+
info2.idx[ii] = idxs[i];
|
|
485
|
+
info2.interLft2[ii] = lft2;
|
|
486
|
+
info2.interLft1[ii] = lft1;
|
|
487
|
+
info2.interRgt2[ii] = rgt2;
|
|
488
|
+
info2.interRgt1[ii] = rgt1;
|
|
489
|
+
info2.chars[ii] = chars;
|
|
490
|
+
info2.terms[ii] = terms;
|
|
491
|
+
info2.cases[ii] = cases;
|
|
492
|
+
info2.interIns[ii] = inter;
|
|
493
|
+
info2.intraIns[ii] = intra;
|
|
494
|
+
info2.start[ii] = start;
|
|
495
|
+
let m2 = mhstr.match(queryR);
|
|
496
|
+
let idxAcc2 = m2.index + m2[1].length;
|
|
497
|
+
let refLen = refine.length;
|
|
498
|
+
let ri = refLen > 0 ? 0 : Infinity;
|
|
499
|
+
let lastRi = refLen - 4;
|
|
500
|
+
for (let i2 = 2; i2 < m2.length; ) {
|
|
501
|
+
let len2 = m2[i2].length;
|
|
502
|
+
if (ri <= lastRi && refine[ri] == idxAcc2) {
|
|
503
|
+
let groupLen = refine[ri + 1];
|
|
504
|
+
let idxOf = refine[ri + 2];
|
|
505
|
+
let termLen = refine[ri + 3];
|
|
506
|
+
let j = i2;
|
|
507
|
+
let v = "";
|
|
508
|
+
for (let _len = 0; _len < groupLen; j++) {
|
|
509
|
+
v += m2[j];
|
|
510
|
+
_len += m2[j].length;
|
|
511
|
+
}
|
|
512
|
+
m2.splice(i2, j - i2, v);
|
|
513
|
+
idxAcc2 += refineMatch(m2, i2, idxOf, termLen);
|
|
514
|
+
ri += 4;
|
|
515
|
+
} else {
|
|
516
|
+
idxAcc2 += len2;
|
|
517
|
+
i2++;
|
|
518
|
+
}
|
|
519
|
+
}
|
|
520
|
+
idxAcc2 = m2.index + m2[1].length;
|
|
521
|
+
let ranges = info2.ranges[ii] = [];
|
|
522
|
+
let from = idxAcc2;
|
|
523
|
+
let to = idxAcc2;
|
|
524
|
+
for (let i2 = 2; i2 < m2.length; i2++) {
|
|
525
|
+
let len2 = m2[i2].length;
|
|
526
|
+
idxAcc2 += len2;
|
|
527
|
+
if (i2 % 2 == 0)
|
|
528
|
+
to = idxAcc2;
|
|
529
|
+
else if (len2 > 0) {
|
|
530
|
+
ranges.push(from, to);
|
|
531
|
+
from = to = idxAcc2;
|
|
532
|
+
}
|
|
533
|
+
}
|
|
534
|
+
if (to > from)
|
|
535
|
+
ranges.push(from, to);
|
|
536
|
+
ii++;
|
|
537
|
+
}
|
|
538
|
+
}
|
|
539
|
+
if (ii < idxs.length) {
|
|
540
|
+
for (let k in info2)
|
|
541
|
+
info2[k] = info2[k].slice(0, ii);
|
|
542
|
+
}
|
|
543
|
+
return info2;
|
|
544
|
+
};
|
|
545
|
+
const refineMatch = (m, k, idxInNext, termLen) => {
|
|
546
|
+
let prepend = m[k] + m[k + 1].slice(0, idxInNext);
|
|
547
|
+
m[k - 1] += prepend;
|
|
548
|
+
m[k] = m[k + 1].slice(idxInNext, idxInNext + termLen);
|
|
549
|
+
m[k + 1] = m[k + 1].slice(idxInNext + termLen);
|
|
550
|
+
return prepend.length;
|
|
551
|
+
};
|
|
552
|
+
const OOO_TERMS_LIMIT = 5;
|
|
553
|
+
const _search = (haystack, needle, outOfOrder, infoThresh = 1e3, preFiltered) => {
|
|
554
|
+
outOfOrder = !outOfOrder ? 0 : outOfOrder === true ? OOO_TERMS_LIMIT : outOfOrder;
|
|
555
|
+
let needles = null;
|
|
556
|
+
let matches = null;
|
|
557
|
+
let negs = [];
|
|
558
|
+
needle = needle.replace(NEGS_RE, (m) => {
|
|
559
|
+
let neg = m.trim().slice(1);
|
|
560
|
+
neg = neg[0] === '"' ? escapeRegExp(neg.slice(1, -1)) : neg.replace(PUNCT_RE, "");
|
|
561
|
+
if (neg != "")
|
|
562
|
+
negs.push(neg);
|
|
563
|
+
return "";
|
|
564
|
+
});
|
|
565
|
+
let terms = split(needle);
|
|
566
|
+
let negsRe;
|
|
567
|
+
if (negs.length > 0) {
|
|
568
|
+
negsRe = new RegExp(negs.join("|"), "i" + uFlag);
|
|
569
|
+
if (terms.length == 0) {
|
|
570
|
+
let idxs = [];
|
|
571
|
+
for (let i = 0; i < haystack.length; i++) {
|
|
572
|
+
if (!negsRe.test(haystack[i]))
|
|
573
|
+
idxs.push(i);
|
|
574
|
+
}
|
|
575
|
+
return [idxs, null, null];
|
|
576
|
+
}
|
|
577
|
+
} else {
|
|
578
|
+
if (terms.length == 0)
|
|
579
|
+
return [null, null, null];
|
|
580
|
+
}
|
|
581
|
+
if (outOfOrder > 0) {
|
|
582
|
+
let terms2 = split(needle);
|
|
583
|
+
if (terms2.length > 1) {
|
|
584
|
+
let terms22 = terms2.slice().sort((a, b) => b.length - a.length);
|
|
585
|
+
for (let ti = 0; ti < terms22.length; ti++) {
|
|
586
|
+
if (preFiltered?.length == 0)
|
|
587
|
+
return [[], null, null];
|
|
588
|
+
preFiltered = filter3(haystack, terms22[ti], preFiltered);
|
|
589
|
+
}
|
|
590
|
+
if (terms2.length > outOfOrder)
|
|
591
|
+
return [preFiltered, null, null];
|
|
592
|
+
needles = permute(terms2).map((perm) => perm.join(" "));
|
|
593
|
+
matches = [];
|
|
594
|
+
let matchedIdxs = /* @__PURE__ */ new Set();
|
|
595
|
+
for (let ni = 0; ni < needles.length; ni++) {
|
|
596
|
+
if (matchedIdxs.size < preFiltered.length) {
|
|
597
|
+
let preFiltered2 = preFiltered.filter((idx) => !matchedIdxs.has(idx));
|
|
598
|
+
let matched = filter3(haystack, needles[ni], preFiltered2);
|
|
599
|
+
for (let j = 0; j < matched.length; j++)
|
|
600
|
+
matchedIdxs.add(matched[j]);
|
|
601
|
+
matches.push(matched);
|
|
602
|
+
} else
|
|
603
|
+
matches.push([]);
|
|
604
|
+
}
|
|
605
|
+
}
|
|
606
|
+
}
|
|
607
|
+
if (needles == null) {
|
|
608
|
+
needles = [needle];
|
|
609
|
+
matches = [preFiltered?.length > 0 ? preFiltered : filter3(haystack, needle)];
|
|
610
|
+
}
|
|
611
|
+
let retInfo = null;
|
|
612
|
+
let retOrder = null;
|
|
613
|
+
if (negs.length > 0)
|
|
614
|
+
matches = matches.map((idxs) => idxs.filter((idx) => !negsRe.test(haystack[idx])));
|
|
615
|
+
let matchCount = matches.reduce((acc, idxs) => acc + idxs.length, 0);
|
|
616
|
+
if (matchCount <= infoThresh) {
|
|
617
|
+
retInfo = {};
|
|
618
|
+
retOrder = [];
|
|
619
|
+
for (let ni = 0; ni < matches.length; ni++) {
|
|
620
|
+
let idxs = matches[ni];
|
|
621
|
+
if (idxs == null || idxs.length == 0)
|
|
622
|
+
continue;
|
|
623
|
+
let needle2 = needles[ni];
|
|
624
|
+
let _info = info(idxs, haystack, needle2);
|
|
625
|
+
let order = opts.sort(_info, haystack, needle2, compare);
|
|
626
|
+
if (ni > 0) {
|
|
627
|
+
for (let i = 0; i < order.length; i++)
|
|
628
|
+
order[i] += retOrder.length;
|
|
629
|
+
}
|
|
630
|
+
for (let k in _info)
|
|
631
|
+
retInfo[k] = (retInfo[k] ?? []).concat(_info[k]);
|
|
632
|
+
retOrder = retOrder.concat(order);
|
|
633
|
+
}
|
|
634
|
+
}
|
|
635
|
+
return [
|
|
636
|
+
[].concat(...matches),
|
|
637
|
+
retInfo,
|
|
638
|
+
retOrder
|
|
639
|
+
];
|
|
640
|
+
};
|
|
641
|
+
return {
|
|
642
|
+
search: (...args) => {
|
|
643
|
+
let out = _search(...args);
|
|
644
|
+
return out;
|
|
645
|
+
},
|
|
646
|
+
split,
|
|
647
|
+
filter: filter3,
|
|
648
|
+
info,
|
|
649
|
+
sort: opts.sort
|
|
650
|
+
};
|
|
651
|
+
}
|
|
652
|
+
var latinize = (() => {
|
|
653
|
+
let accents = {
|
|
654
|
+
A: "\xC1\xC0\xC3\xC2\xC4\u0104",
|
|
655
|
+
a: "\xE1\xE0\xE3\xE2\xE4\u0105",
|
|
656
|
+
E: "\xC9\xC8\xCA\xCB\u0116",
|
|
657
|
+
e: "\xE9\xE8\xEA\xEB\u0119",
|
|
658
|
+
I: "\xCD\xCC\xCE\xCF\u012E",
|
|
659
|
+
i: "\xED\xEC\xEE\xEF\u012F",
|
|
660
|
+
O: "\xD3\xD2\xD4\xD5\xD6",
|
|
661
|
+
o: "\xF3\xF2\xF4\xF5\xF6",
|
|
662
|
+
U: "\xDA\xD9\xDB\xDC\u016A\u0172",
|
|
663
|
+
u: "\xFA\xF9\xFB\xFC\u016B\u0173",
|
|
664
|
+
C: "\xC7\u010C\u0106",
|
|
665
|
+
c: "\xE7\u010D\u0107",
|
|
666
|
+
L: "\u0141",
|
|
667
|
+
l: "\u0142",
|
|
668
|
+
N: "\xD1\u0143",
|
|
669
|
+
n: "\xF1\u0144",
|
|
670
|
+
S: "\u0160\u015A",
|
|
671
|
+
s: "\u0161\u015B",
|
|
672
|
+
Z: "\u017B\u0179",
|
|
673
|
+
z: "\u017C\u017A"
|
|
674
|
+
};
|
|
675
|
+
let accentsMap = /* @__PURE__ */ new Map();
|
|
676
|
+
let accentsTpl = "";
|
|
677
|
+
for (let r in accents) {
|
|
678
|
+
accents[r].split("").forEach((a) => {
|
|
679
|
+
accentsTpl += a;
|
|
680
|
+
accentsMap.set(a, r);
|
|
681
|
+
});
|
|
682
|
+
}
|
|
683
|
+
let accentsRe = new RegExp(`[${accentsTpl}]`, "g");
|
|
684
|
+
let replacer = (m) => accentsMap.get(m);
|
|
685
|
+
return (strings) => {
|
|
686
|
+
if (typeof strings == "string")
|
|
687
|
+
return strings.replace(accentsRe, replacer);
|
|
688
|
+
let out = Array(strings.length);
|
|
689
|
+
for (let i = 0; i < strings.length; i++)
|
|
690
|
+
out[i] = strings[i].replace(accentsRe, replacer);
|
|
691
|
+
return out;
|
|
692
|
+
};
|
|
693
|
+
})();
|
|
694
|
+
function permute(arr) {
|
|
695
|
+
arr = arr.slice();
|
|
696
|
+
let length = arr.length, result = [arr.slice()], c = new Array(length).fill(0), i = 1, k, p;
|
|
697
|
+
while (i < length) {
|
|
698
|
+
if (c[i] < i) {
|
|
699
|
+
k = i % 2 && c[i];
|
|
700
|
+
p = arr[i];
|
|
701
|
+
arr[i] = arr[k];
|
|
702
|
+
arr[k] = p;
|
|
703
|
+
++c[i];
|
|
704
|
+
i = 1;
|
|
705
|
+
result.push(arr.slice());
|
|
706
|
+
} else {
|
|
707
|
+
c[i] = 0;
|
|
708
|
+
++i;
|
|
709
|
+
}
|
|
710
|
+
}
|
|
711
|
+
return result;
|
|
712
|
+
}
|
|
713
|
+
var _mark = (part, matched) => matched ? `<mark>${part}</mark>` : part;
|
|
714
|
+
var _append = (acc, part) => acc + part;
|
|
715
|
+
function highlight(str, ranges, mark = _mark, accum = "", append = _append) {
|
|
716
|
+
accum = append(accum, mark(str.substring(0, ranges[0]), false)) ?? accum;
|
|
717
|
+
for (let i = 0; i < ranges.length; i += 2) {
|
|
718
|
+
let fr = ranges[i];
|
|
719
|
+
let to = ranges[i + 1];
|
|
720
|
+
accum = append(accum, mark(str.substring(fr, to), true)) ?? accum;
|
|
721
|
+
if (i < ranges.length - 3)
|
|
722
|
+
accum = append(accum, mark(str.substring(ranges[i + 1], ranges[i + 2]), false)) ?? accum;
|
|
723
|
+
}
|
|
724
|
+
accum = append(accum, mark(str.substring(ranges[ranges.length - 1]), false)) ?? accum;
|
|
725
|
+
return accum;
|
|
726
|
+
}
|
|
727
|
+
uFuzzy2.latinize = latinize;
|
|
728
|
+
uFuzzy2.permute = (arr) => {
|
|
729
|
+
let idxs = permute([...Array(arr.length).keys()]).sort((a, b) => {
|
|
730
|
+
for (let i = 0; i < a.length; i++) {
|
|
731
|
+
if (a[i] != b[i])
|
|
732
|
+
return a[i] - b[i];
|
|
733
|
+
}
|
|
734
|
+
return 0;
|
|
735
|
+
});
|
|
736
|
+
return idxs.map((pi) => pi.map((i) => arr[i]));
|
|
737
|
+
};
|
|
738
|
+
uFuzzy2.highlight = highlight;
|
|
739
|
+
module2.exports = uFuzzy2;
|
|
740
|
+
}
|
|
741
|
+
});
|
|
742
|
+
|
|
32
743
|
// node_modules/deepmerge/dist/cjs.js
|
|
33
744
|
var require_cjs = __commonJS({
|
|
34
745
|
"node_modules/deepmerge/dist/cjs.js"(exports2, module2) {
|
|
@@ -4904,176 +5615,11 @@ __export(vite_config_exports, {
|
|
|
4904
5615
|
});
|
|
4905
5616
|
module.exports = __toCommonJS(vite_config_exports);
|
|
4906
5617
|
var import_apimock_express = require("@forsakringskassan/apimock-express");
|
|
5618
|
+
var import_ufuzzy = __toESM(require_uFuzzy());
|
|
4907
5619
|
var import_deepmerge = __toESM(require_cjs());
|
|
4908
5620
|
var import_picocolors = __toESM(require_picocolors());
|
|
4909
5621
|
var import_plugin_vue = __toESM(require_dist());
|
|
4910
5622
|
|
|
4911
|
-
// src/plugins/babel-plugin.ts
|
|
4912
|
-
var babel = __toESM(require("@babel/core"));
|
|
4913
|
-
var filter = /\.(js|ts|vue)$/;
|
|
4914
|
-
function babelPlugin() {
|
|
4915
|
-
return {
|
|
4916
|
-
name: "fk:babel",
|
|
4917
|
-
enforce: "post",
|
|
4918
|
-
apply: "build",
|
|
4919
|
-
async transform(src, id) {
|
|
4920
|
-
const { pathname: filename } = new URL(id, "file://");
|
|
4921
|
-
if (!filter.test(filename)) {
|
|
4922
|
-
return null;
|
|
4923
|
-
}
|
|
4924
|
-
const transformed = await babel.transformAsync(src, {
|
|
4925
|
-
sourceMaps: true,
|
|
4926
|
-
comments: true,
|
|
4927
|
-
filename
|
|
4928
|
-
});
|
|
4929
|
-
if (!transformed) {
|
|
4930
|
-
return null;
|
|
4931
|
-
}
|
|
4932
|
-
const { code, map } = transformed;
|
|
4933
|
-
return {
|
|
4934
|
-
code: code ?? src,
|
|
4935
|
-
map: map ?? null
|
|
4936
|
-
};
|
|
4937
|
-
}
|
|
4938
|
-
};
|
|
4939
|
-
}
|
|
4940
|
-
|
|
4941
|
-
// src/plugins/custom-mapping-plugin.ts
|
|
4942
|
-
var folder = {
|
|
4943
|
-
es: "esm",
|
|
4944
|
-
cjs: "cjs"
|
|
4945
|
-
};
|
|
4946
|
-
function customMappingPlugin() {
|
|
4947
|
-
return {
|
|
4948
|
-
name: "fk:custom-mapping",
|
|
4949
|
-
renderStart(options) {
|
|
4950
|
-
const { format } = options;
|
|
4951
|
-
if (format !== "es" && format !== "cjs") {
|
|
4952
|
-
return;
|
|
4953
|
-
}
|
|
4954
|
-
const replacement = folder[format];
|
|
4955
|
-
options.dir = options.dir?.replace("[custom-format]", replacement);
|
|
4956
|
-
if (typeof options.entryFileNames === "string") {
|
|
4957
|
-
options.entryFileNames = options.entryFileNames.replace(
|
|
4958
|
-
"[custom-format]",
|
|
4959
|
-
replacement
|
|
4960
|
-
);
|
|
4961
|
-
}
|
|
4962
|
-
}
|
|
4963
|
-
};
|
|
4964
|
-
}
|
|
4965
|
-
|
|
4966
|
-
// src/plugins/index-html-plugin.ts
|
|
4967
|
-
var import_promises = __toESM(require("node:fs/promises"));
|
|
4968
|
-
var import_node_path = __toESM(require("node:path"));
|
|
4969
|
-
|
|
4970
|
-
// src/utils/lookupFile.ts
|
|
4971
|
-
var import_node_fs = __toESM(require("node:fs"));
|
|
4972
|
-
var extensions = ["ts", "mts", "mjs", "js"];
|
|
4973
|
-
function lookupFile(nameWithoutExtension) {
|
|
4974
|
-
for (const extension of extensions) {
|
|
4975
|
-
const fileName = `${nameWithoutExtension}.${extension}`;
|
|
4976
|
-
if (import_node_fs.default.existsSync(fileName)) {
|
|
4977
|
-
return fileName;
|
|
4978
|
-
}
|
|
4979
|
-
}
|
|
4980
|
-
return `${nameWithoutExtension}.ts`;
|
|
4981
|
-
}
|
|
4982
|
-
|
|
4983
|
-
// src/plugins/index-html-plugin.ts
|
|
4984
|
-
var templateFile = import_node_path.default.resolve(__dirname, "../assets/index.html");
|
|
4985
|
-
var VIRTUAL_ENTRYPOINT = "index.html";
|
|
4986
|
-
function isHtmlPage(url) {
|
|
4987
|
-
if (!url) {
|
|
4988
|
-
return false;
|
|
4989
|
-
}
|
|
4990
|
-
return url.startsWith(".html") || url === "/";
|
|
4991
|
-
}
|
|
4992
|
-
function middleware(server) {
|
|
4993
|
-
return async (req, res, next) => {
|
|
4994
|
-
const { url } = req;
|
|
4995
|
-
if (isHtmlPage(url)) {
|
|
4996
|
-
try {
|
|
4997
|
-
res.end(await server.transformIndexHtml(url, ""));
|
|
4998
|
-
} catch (err) {
|
|
4999
|
-
console.error(err);
|
|
5000
|
-
res.writeHead(500);
|
|
5001
|
-
res.end("Internal Server Error");
|
|
5002
|
-
}
|
|
5003
|
-
} else {
|
|
5004
|
-
return next();
|
|
5005
|
-
}
|
|
5006
|
-
};
|
|
5007
|
-
}
|
|
5008
|
-
function indexHtmlPlugin() {
|
|
5009
|
-
const templateData = {
|
|
5010
|
-
entrypoint: "/src/vite-dev/app.vue",
|
|
5011
|
-
entrypointLocal: `/${lookupFile("src/local")}`
|
|
5012
|
-
};
|
|
5013
|
-
return {
|
|
5014
|
-
name: "fk:virtual-entrypoint",
|
|
5015
|
-
resolveId: {
|
|
5016
|
-
order: "pre",
|
|
5017
|
-
handler(source) {
|
|
5018
|
-
const { base } = import_node_path.default.parse(source);
|
|
5019
|
-
if (base === "index.html") {
|
|
5020
|
-
return VIRTUAL_ENTRYPOINT;
|
|
5021
|
-
}
|
|
5022
|
-
}
|
|
5023
|
-
},
|
|
5024
|
-
load: {
|
|
5025
|
-
order: "pre",
|
|
5026
|
-
handler(id) {
|
|
5027
|
-
if (id === VIRTUAL_ENTRYPOINT) {
|
|
5028
|
-
return "";
|
|
5029
|
-
}
|
|
5030
|
-
}
|
|
5031
|
-
},
|
|
5032
|
-
transformIndexHtml: {
|
|
5033
|
-
order: "pre",
|
|
5034
|
-
async handler() {
|
|
5035
|
-
const content = await import_promises.default.readFile(templateFile, "utf-8");
|
|
5036
|
-
return content.replace(/{{([^}]+)}}/g, (match2, key) => {
|
|
5037
|
-
return templateData[key.trim()] ?? match2;
|
|
5038
|
-
});
|
|
5039
|
-
}
|
|
5040
|
-
},
|
|
5041
|
-
config(config) {
|
|
5042
|
-
if (config.fk?.entrypoint) {
|
|
5043
|
-
templateData.entrypoint = config.fk.entrypoint;
|
|
5044
|
-
}
|
|
5045
|
-
},
|
|
5046
|
-
configureServer(server) {
|
|
5047
|
-
server.middlewares.use(middleware(server));
|
|
5048
|
-
}
|
|
5049
|
-
};
|
|
5050
|
-
}
|
|
5051
|
-
|
|
5052
|
-
// src/plugins/package-json-plugin.ts
|
|
5053
|
-
var mapping = {
|
|
5054
|
-
es: "module",
|
|
5055
|
-
cjs: "commonjs"
|
|
5056
|
-
};
|
|
5057
|
-
function packageJsonPlugin() {
|
|
5058
|
-
return {
|
|
5059
|
-
name: "fk:package-json",
|
|
5060
|
-
generateBundle(options) {
|
|
5061
|
-
const { format } = options;
|
|
5062
|
-
if (format !== "es" && format !== "cjs") {
|
|
5063
|
-
return;
|
|
5064
|
-
}
|
|
5065
|
-
const pkg = {
|
|
5066
|
-
type: mapping[format]
|
|
5067
|
-
};
|
|
5068
|
-
this.emitFile({
|
|
5069
|
-
type: "asset",
|
|
5070
|
-
fileName: "package.json",
|
|
5071
|
-
source: JSON.stringify(pkg, null, 2)
|
|
5072
|
-
});
|
|
5073
|
-
}
|
|
5074
|
-
};
|
|
5075
|
-
}
|
|
5076
|
-
|
|
5077
5623
|
// node_modules/glob/node_modules/minimatch/dist/esm/index.js
|
|
5078
5624
|
var import_brace_expansion = __toESM(require_brace_expansion(), 1);
|
|
5079
5625
|
|
|
@@ -5745,11 +6291,11 @@ var qmarksTestNoExtDot = ([$0]) => {
|
|
|
5745
6291
|
return (f) => f.length === len && f !== "." && f !== "..";
|
|
5746
6292
|
};
|
|
5747
6293
|
var defaultPlatform = typeof process === "object" && process ? typeof process.env === "object" && process.env && process.env.__MINIMATCH_TESTING_PLATFORM__ || process.platform : "posix";
|
|
5748
|
-
var
|
|
6294
|
+
var path = {
|
|
5749
6295
|
win32: { sep: "\\" },
|
|
5750
6296
|
posix: { sep: "/" }
|
|
5751
6297
|
};
|
|
5752
|
-
var sep = defaultPlatform === "win32" ?
|
|
6298
|
+
var sep = defaultPlatform === "win32" ? path.win32.sep : path.posix.sep;
|
|
5753
6299
|
minimatch.sep = sep;
|
|
5754
6300
|
var GLOBSTAR = Symbol("globstar **");
|
|
5755
6301
|
minimatch.GLOBSTAR = GLOBSTAR;
|
|
@@ -5757,8 +6303,8 @@ var qmark2 = "[^/]";
|
|
|
5757
6303
|
var star2 = qmark2 + "*?";
|
|
5758
6304
|
var twoStarDot = "(?:(?!(?:\\/|^)(?:\\.{1,2})($|\\/)).)*?";
|
|
5759
6305
|
var twoStarNoDot = "(?:(?!(?:\\/|^)\\.).)*?";
|
|
5760
|
-
var
|
|
5761
|
-
minimatch.filter =
|
|
6306
|
+
var filter = (pattern, options = {}) => (p) => minimatch(p, pattern, options);
|
|
6307
|
+
minimatch.filter = filter;
|
|
5762
6308
|
var ext = (a, b = {}) => Object.assign({}, a, b);
|
|
5763
6309
|
var defaults = (def) => {
|
|
5764
6310
|
if (!def || typeof def !== "object" || !Object.keys(def).length) {
|
|
@@ -7684,11 +8230,11 @@ var LRUCache = class _LRUCache {
|
|
|
7684
8230
|
};
|
|
7685
8231
|
|
|
7686
8232
|
// node_modules/path-scurry/dist/esm/index.js
|
|
7687
|
-
var
|
|
8233
|
+
var import_node_path = require("node:path");
|
|
7688
8234
|
var import_node_url = require("node:url");
|
|
7689
8235
|
var import_fs = require("fs");
|
|
7690
8236
|
var actualFS = __toESM(require("node:fs"), 1);
|
|
7691
|
-
var
|
|
8237
|
+
var import_promises = require("node:fs/promises");
|
|
7692
8238
|
|
|
7693
8239
|
// node_modules/minipass/dist/esm/index.js
|
|
7694
8240
|
var import_node_events = require("node:events");
|
|
@@ -8577,10 +9123,10 @@ var defaultFS = {
|
|
|
8577
9123
|
readlinkSync: import_fs.readlinkSync,
|
|
8578
9124
|
realpathSync,
|
|
8579
9125
|
promises: {
|
|
8580
|
-
lstat:
|
|
8581
|
-
readdir:
|
|
8582
|
-
readlink:
|
|
8583
|
-
realpath:
|
|
9126
|
+
lstat: import_promises.lstat,
|
|
9127
|
+
readdir: import_promises.readdir,
|
|
9128
|
+
readlink: import_promises.readlink,
|
|
9129
|
+
realpath: import_promises.realpath
|
|
8584
9130
|
}
|
|
8585
9131
|
};
|
|
8586
9132
|
var fsFromOption = (fsOption) => !fsOption || fsOption === defaultFS || fsOption === actualFS ? defaultFS : {
|
|
@@ -9589,7 +10135,7 @@ var PathWin32 = class _PathWin32 extends PathBase {
|
|
|
9589
10135
|
* @internal
|
|
9590
10136
|
*/
|
|
9591
10137
|
getRootString(path3) {
|
|
9592
|
-
return
|
|
10138
|
+
return import_node_path.win32.parse(path3).root;
|
|
9593
10139
|
}
|
|
9594
10140
|
/**
|
|
9595
10141
|
* @internal
|
|
@@ -10229,7 +10775,7 @@ var PathScurryWin32 = class extends PathScurryBase {
|
|
|
10229
10775
|
sep = "\\";
|
|
10230
10776
|
constructor(cwd = process.cwd(), opts = {}) {
|
|
10231
10777
|
const { nocase = true } = opts;
|
|
10232
|
-
super(cwd,
|
|
10778
|
+
super(cwd, import_node_path.win32, "\\", { ...opts, nocase });
|
|
10233
10779
|
this.nocase = nocase;
|
|
10234
10780
|
for (let p = this.cwd; p; p = p.parent) {
|
|
10235
10781
|
p.nocase = this.nocase;
|
|
@@ -10239,7 +10785,7 @@ var PathScurryWin32 = class extends PathScurryBase {
|
|
|
10239
10785
|
* @internal
|
|
10240
10786
|
*/
|
|
10241
10787
|
parseRootPath(dir) {
|
|
10242
|
-
return
|
|
10788
|
+
return import_node_path.win32.parse(dir).root.toUpperCase();
|
|
10243
10789
|
}
|
|
10244
10790
|
/**
|
|
10245
10791
|
* @internal
|
|
@@ -10261,7 +10807,7 @@ var PathScurryPosix = class extends PathScurryBase {
|
|
|
10261
10807
|
sep = "/";
|
|
10262
10808
|
constructor(cwd = process.cwd(), opts = {}) {
|
|
10263
10809
|
const { nocase = false } = opts;
|
|
10264
|
-
super(cwd,
|
|
10810
|
+
super(cwd, import_node_path.posix, "/", { ...opts, nocase });
|
|
10265
10811
|
this.nocase = nocase;
|
|
10266
10812
|
}
|
|
10267
10813
|
/**
|
|
@@ -11352,6 +11898,172 @@ var glob = Object.assign(glob_, {
|
|
|
11352
11898
|
});
|
|
11353
11899
|
glob.glob = glob;
|
|
11354
11900
|
|
|
11901
|
+
// src/plugins/babel-plugin.ts
|
|
11902
|
+
var babel = __toESM(require("@babel/core"));
|
|
11903
|
+
var filter2 = /\.(js|ts|vue)$/;
|
|
11904
|
+
function babelPlugin() {
|
|
11905
|
+
return {
|
|
11906
|
+
name: "fk:babel",
|
|
11907
|
+
enforce: "post",
|
|
11908
|
+
apply: "build",
|
|
11909
|
+
async transform(src, id) {
|
|
11910
|
+
const { pathname: filename } = new URL(id, "file://");
|
|
11911
|
+
if (!filter2.test(filename)) {
|
|
11912
|
+
return null;
|
|
11913
|
+
}
|
|
11914
|
+
const transformed = await babel.transformAsync(src, {
|
|
11915
|
+
sourceMaps: true,
|
|
11916
|
+
comments: true,
|
|
11917
|
+
filename
|
|
11918
|
+
});
|
|
11919
|
+
if (!transformed) {
|
|
11920
|
+
return null;
|
|
11921
|
+
}
|
|
11922
|
+
const { code, map } = transformed;
|
|
11923
|
+
return {
|
|
11924
|
+
code: code ?? src,
|
|
11925
|
+
map: map ?? null
|
|
11926
|
+
};
|
|
11927
|
+
}
|
|
11928
|
+
};
|
|
11929
|
+
}
|
|
11930
|
+
|
|
11931
|
+
// src/plugins/custom-mapping-plugin.ts
|
|
11932
|
+
var folder = {
|
|
11933
|
+
es: "esm",
|
|
11934
|
+
cjs: "cjs"
|
|
11935
|
+
};
|
|
11936
|
+
function customMappingPlugin() {
|
|
11937
|
+
return {
|
|
11938
|
+
name: "fk:custom-mapping",
|
|
11939
|
+
renderStart(options) {
|
|
11940
|
+
const { format } = options;
|
|
11941
|
+
if (format !== "es" && format !== "cjs") {
|
|
11942
|
+
return;
|
|
11943
|
+
}
|
|
11944
|
+
const replacement = folder[format];
|
|
11945
|
+
options.dir = options.dir?.replace("[custom-format]", replacement);
|
|
11946
|
+
if (typeof options.entryFileNames === "string") {
|
|
11947
|
+
options.entryFileNames = options.entryFileNames.replace(
|
|
11948
|
+
"[custom-format]",
|
|
11949
|
+
replacement
|
|
11950
|
+
);
|
|
11951
|
+
}
|
|
11952
|
+
}
|
|
11953
|
+
};
|
|
11954
|
+
}
|
|
11955
|
+
|
|
11956
|
+
// src/plugins/index-html-plugin.ts
|
|
11957
|
+
var import_promises2 = __toESM(require("node:fs/promises"));
|
|
11958
|
+
var import_node_path2 = __toESM(require("node:path"));
|
|
11959
|
+
|
|
11960
|
+
// src/utils/lookupFile.ts
|
|
11961
|
+
var import_node_fs = __toESM(require("node:fs"));
|
|
11962
|
+
var extensions = ["ts", "mts", "mjs", "js"];
|
|
11963
|
+
function lookupFile(nameWithoutExtension) {
|
|
11964
|
+
for (const extension of extensions) {
|
|
11965
|
+
const fileName = `${nameWithoutExtension}.${extension}`;
|
|
11966
|
+
if (import_node_fs.default.existsSync(fileName)) {
|
|
11967
|
+
return fileName;
|
|
11968
|
+
}
|
|
11969
|
+
}
|
|
11970
|
+
return `${nameWithoutExtension}.ts`;
|
|
11971
|
+
}
|
|
11972
|
+
|
|
11973
|
+
// src/plugins/index-html-plugin.ts
|
|
11974
|
+
var templateFile = import_node_path2.default.resolve(__dirname, "../assets/index.html");
|
|
11975
|
+
var VIRTUAL_ENTRYPOINT = "index.html";
|
|
11976
|
+
function isHtmlPage(url) {
|
|
11977
|
+
if (!url) {
|
|
11978
|
+
return false;
|
|
11979
|
+
}
|
|
11980
|
+
return url.startsWith(".html") || url === "/";
|
|
11981
|
+
}
|
|
11982
|
+
function middleware(server) {
|
|
11983
|
+
return async (req, res, next) => {
|
|
11984
|
+
const { url } = req;
|
|
11985
|
+
if (isHtmlPage(url)) {
|
|
11986
|
+
try {
|
|
11987
|
+
res.end(await server.transformIndexHtml(url, ""));
|
|
11988
|
+
} catch (err) {
|
|
11989
|
+
console.error(err);
|
|
11990
|
+
res.writeHead(500);
|
|
11991
|
+
res.end("Internal Server Error");
|
|
11992
|
+
}
|
|
11993
|
+
} else {
|
|
11994
|
+
return next();
|
|
11995
|
+
}
|
|
11996
|
+
};
|
|
11997
|
+
}
|
|
11998
|
+
function indexHtmlPlugin() {
|
|
11999
|
+
const templateData = {
|
|
12000
|
+
entrypoint: "/src/vite-dev/app.vue",
|
|
12001
|
+
entrypointLocal: `/${lookupFile("src/local")}`
|
|
12002
|
+
};
|
|
12003
|
+
return {
|
|
12004
|
+
name: "fk:virtual-entrypoint",
|
|
12005
|
+
resolveId: {
|
|
12006
|
+
order: "pre",
|
|
12007
|
+
handler(source) {
|
|
12008
|
+
const { base } = import_node_path2.default.parse(source);
|
|
12009
|
+
if (base === "index.html") {
|
|
12010
|
+
return VIRTUAL_ENTRYPOINT;
|
|
12011
|
+
}
|
|
12012
|
+
}
|
|
12013
|
+
},
|
|
12014
|
+
load: {
|
|
12015
|
+
order: "pre",
|
|
12016
|
+
handler(id) {
|
|
12017
|
+
if (id === VIRTUAL_ENTRYPOINT) {
|
|
12018
|
+
return "";
|
|
12019
|
+
}
|
|
12020
|
+
}
|
|
12021
|
+
},
|
|
12022
|
+
transformIndexHtml: {
|
|
12023
|
+
order: "pre",
|
|
12024
|
+
async handler() {
|
|
12025
|
+
const content = await import_promises2.default.readFile(templateFile, "utf-8");
|
|
12026
|
+
return content.replace(/{{([^}]+)}}/g, (match2, key) => {
|
|
12027
|
+
return templateData[key.trim()] ?? match2;
|
|
12028
|
+
});
|
|
12029
|
+
}
|
|
12030
|
+
},
|
|
12031
|
+
config(config) {
|
|
12032
|
+
if (config.fk?.entrypoint) {
|
|
12033
|
+
templateData.entrypoint = config.fk.entrypoint;
|
|
12034
|
+
}
|
|
12035
|
+
},
|
|
12036
|
+
configureServer(server) {
|
|
12037
|
+
server.middlewares.use(middleware(server));
|
|
12038
|
+
}
|
|
12039
|
+
};
|
|
12040
|
+
}
|
|
12041
|
+
|
|
12042
|
+
// src/plugins/package-json-plugin.ts
|
|
12043
|
+
var mapping = {
|
|
12044
|
+
es: "module",
|
|
12045
|
+
cjs: "commonjs"
|
|
12046
|
+
};
|
|
12047
|
+
function packageJsonPlugin() {
|
|
12048
|
+
return {
|
|
12049
|
+
name: "fk:package-json",
|
|
12050
|
+
generateBundle(options) {
|
|
12051
|
+
const { format } = options;
|
|
12052
|
+
if (format !== "es" && format !== "cjs") {
|
|
12053
|
+
return;
|
|
12054
|
+
}
|
|
12055
|
+
const pkg = {
|
|
12056
|
+
type: mapping[format]
|
|
12057
|
+
};
|
|
12058
|
+
this.emitFile({
|
|
12059
|
+
type: "asset",
|
|
12060
|
+
fileName: "package.json",
|
|
12061
|
+
source: JSON.stringify(pkg, null, 2)
|
|
12062
|
+
});
|
|
12063
|
+
}
|
|
12064
|
+
};
|
|
12065
|
+
}
|
|
12066
|
+
|
|
11355
12067
|
// src/utils/read-json-file.ts
|
|
11356
12068
|
var import_node_fs2 = __toESM(require("node:fs"));
|
|
11357
12069
|
function readJsonFile(filename) {
|
|
@@ -11518,6 +12230,28 @@ function vuePlugin(config) {
|
|
|
11518
12230
|
return (0, import_plugin_vue.default)(resolvedConfig);
|
|
11519
12231
|
}
|
|
11520
12232
|
}
|
|
12233
|
+
async function findEntrypoint(pattern) {
|
|
12234
|
+
const defaultEntrypoint = "/src/vite-dev/app.vue";
|
|
12235
|
+
if (!pattern) {
|
|
12236
|
+
return defaultEntrypoint;
|
|
12237
|
+
}
|
|
12238
|
+
const uf = new import_ufuzzy.default({ intraIns: Infinity });
|
|
12239
|
+
const files = await glob("**/*.vue", { posix: true, nodir: true });
|
|
12240
|
+
const idxs = uf.filter(files, pattern);
|
|
12241
|
+
if (!idxs || idxs.length === 0) {
|
|
12242
|
+
throw new Error(`No files matching "${pattern}"`);
|
|
12243
|
+
}
|
|
12244
|
+
const info = uf.info(idxs, files, pattern);
|
|
12245
|
+
const order = uf.sort(info, files, pattern);
|
|
12246
|
+
const matches = order.map((it) => files[info.idx[it]]);
|
|
12247
|
+
if (matches.length > 1) {
|
|
12248
|
+
console.error(
|
|
12249
|
+
`Multiple files matching "${pattern}", using first one from:`,
|
|
12250
|
+
matches
|
|
12251
|
+
);
|
|
12252
|
+
}
|
|
12253
|
+
return matches[0];
|
|
12254
|
+
}
|
|
11521
12255
|
var vueMajor = detectVueMajor();
|
|
11522
12256
|
var packageJson = readJsonFile("package.json");
|
|
11523
12257
|
var dependencies = Object.keys(packageJson.dependencies ?? {});
|
|
@@ -11571,11 +12305,19 @@ var defaultConfig = {
|
|
|
11571
12305
|
function overwriteMerge(_a, b) {
|
|
11572
12306
|
return b;
|
|
11573
12307
|
}
|
|
11574
|
-
function defineConfig(config) {
|
|
11575
|
-
const
|
|
12308
|
+
async function defineConfig(config = {}) {
|
|
12309
|
+
const argv = process.argv.slice(2);
|
|
12310
|
+
const positional = argv.filter((it) => !it.startsWith("-"));
|
|
12311
|
+
config.fk ??= {};
|
|
12312
|
+
const { mocks = [] } = config.fk;
|
|
11576
12313
|
if (mocks.length > 0) {
|
|
11577
12314
|
defaultConfig.plugins.push((0, import_apimock_express.vitePlugin)(mocks));
|
|
11578
12315
|
}
|
|
12316
|
+
const userEntrypoint = positional.length > 0 && !config.fk.entrypoint;
|
|
12317
|
+
if (userEntrypoint) {
|
|
12318
|
+
const entrypoint = await findEntrypoint(positional[0]);
|
|
12319
|
+
config.fk.entrypoint = `/${entrypoint}`;
|
|
12320
|
+
}
|
|
11579
12321
|
let result;
|
|
11580
12322
|
if (config) {
|
|
11581
12323
|
result = (0, import_deepmerge.default)(
|
|
@@ -11601,6 +12343,9 @@ function defineConfig(config) {
|
|
|
11601
12343
|
"Bundled dependencies:",
|
|
11602
12344
|
prettyList(allDependencies, (it) => isBundled(external2, it))
|
|
11603
12345
|
);
|
|
12346
|
+
if (userEntrypoint) {
|
|
12347
|
+
console.log("Entrypoint:", config.fk.entrypoint);
|
|
12348
|
+
}
|
|
11604
12349
|
console.groupEnd();
|
|
11605
12350
|
console.log();
|
|
11606
12351
|
return result;
|