@vercel/remix-builder 5.2.2 → 5.2.4
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/dist/index.js +104 -829
- package/package.json +4 -3
package/dist/index.js
CHANGED
|
@@ -2442,826 +2442,6 @@ var require_semver2 = __commonJS({
|
|
|
2442
2442
|
}
|
|
2443
2443
|
});
|
|
2444
2444
|
|
|
2445
|
-
// ../../node_modules/.pnpm/path-to-regexp@6.1.0/node_modules/path-to-regexp/dist/index.js
|
|
2446
|
-
var require_dist = __commonJS({
|
|
2447
|
-
"../../node_modules/.pnpm/path-to-regexp@6.1.0/node_modules/path-to-regexp/dist/index.js"(exports) {
|
|
2448
|
-
"use strict";
|
|
2449
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
2450
|
-
function lexer(str) {
|
|
2451
|
-
var tokens = [];
|
|
2452
|
-
var i = 0;
|
|
2453
|
-
while (i < str.length) {
|
|
2454
|
-
var char = str[i];
|
|
2455
|
-
if (char === "*" || char === "+" || char === "?") {
|
|
2456
|
-
tokens.push({ type: "MODIFIER", index: i, value: str[i++] });
|
|
2457
|
-
continue;
|
|
2458
|
-
}
|
|
2459
|
-
if (char === "\\") {
|
|
2460
|
-
tokens.push({ type: "ESCAPED_CHAR", index: i++, value: str[i++] });
|
|
2461
|
-
continue;
|
|
2462
|
-
}
|
|
2463
|
-
if (char === "{") {
|
|
2464
|
-
tokens.push({ type: "OPEN", index: i, value: str[i++] });
|
|
2465
|
-
continue;
|
|
2466
|
-
}
|
|
2467
|
-
if (char === "}") {
|
|
2468
|
-
tokens.push({ type: "CLOSE", index: i, value: str[i++] });
|
|
2469
|
-
continue;
|
|
2470
|
-
}
|
|
2471
|
-
if (char === ":") {
|
|
2472
|
-
var name = "";
|
|
2473
|
-
var j = i + 1;
|
|
2474
|
-
while (j < str.length) {
|
|
2475
|
-
var code = str.charCodeAt(j);
|
|
2476
|
-
if (
|
|
2477
|
-
// `0-9`
|
|
2478
|
-
code >= 48 && code <= 57 || // `A-Z`
|
|
2479
|
-
code >= 65 && code <= 90 || // `a-z`
|
|
2480
|
-
code >= 97 && code <= 122 || // `_`
|
|
2481
|
-
code === 95
|
|
2482
|
-
) {
|
|
2483
|
-
name += str[j++];
|
|
2484
|
-
continue;
|
|
2485
|
-
}
|
|
2486
|
-
break;
|
|
2487
|
-
}
|
|
2488
|
-
if (!name)
|
|
2489
|
-
throw new TypeError("Missing parameter name at " + i);
|
|
2490
|
-
tokens.push({ type: "NAME", index: i, value: name });
|
|
2491
|
-
i = j;
|
|
2492
|
-
continue;
|
|
2493
|
-
}
|
|
2494
|
-
if (char === "(") {
|
|
2495
|
-
var count = 1;
|
|
2496
|
-
var pattern = "";
|
|
2497
|
-
var j = i + 1;
|
|
2498
|
-
if (str[j] === "?") {
|
|
2499
|
-
throw new TypeError('Pattern cannot start with "?" at ' + j);
|
|
2500
|
-
}
|
|
2501
|
-
while (j < str.length) {
|
|
2502
|
-
if (str[j] === "\\") {
|
|
2503
|
-
pattern += str[j++] + str[j++];
|
|
2504
|
-
continue;
|
|
2505
|
-
}
|
|
2506
|
-
if (str[j] === ")") {
|
|
2507
|
-
count--;
|
|
2508
|
-
if (count === 0) {
|
|
2509
|
-
j++;
|
|
2510
|
-
break;
|
|
2511
|
-
}
|
|
2512
|
-
} else if (str[j] === "(") {
|
|
2513
|
-
count++;
|
|
2514
|
-
if (str[j + 1] !== "?") {
|
|
2515
|
-
throw new TypeError("Capturing groups are not allowed at " + j);
|
|
2516
|
-
}
|
|
2517
|
-
}
|
|
2518
|
-
pattern += str[j++];
|
|
2519
|
-
}
|
|
2520
|
-
if (count)
|
|
2521
|
-
throw new TypeError("Unbalanced pattern at " + i);
|
|
2522
|
-
if (!pattern)
|
|
2523
|
-
throw new TypeError("Missing pattern at " + i);
|
|
2524
|
-
tokens.push({ type: "PATTERN", index: i, value: pattern });
|
|
2525
|
-
i = j;
|
|
2526
|
-
continue;
|
|
2527
|
-
}
|
|
2528
|
-
tokens.push({ type: "CHAR", index: i, value: str[i++] });
|
|
2529
|
-
}
|
|
2530
|
-
tokens.push({ type: "END", index: i, value: "" });
|
|
2531
|
-
return tokens;
|
|
2532
|
-
}
|
|
2533
|
-
function parse(str, options) {
|
|
2534
|
-
if (options === void 0) {
|
|
2535
|
-
options = {};
|
|
2536
|
-
}
|
|
2537
|
-
var tokens = lexer(str);
|
|
2538
|
-
var _a = options.prefixes, prefixes = _a === void 0 ? "./" : _a;
|
|
2539
|
-
var defaultPattern = "[^" + escapeString(options.delimiter || "/#?") + "]+?";
|
|
2540
|
-
var result = [];
|
|
2541
|
-
var key = 0;
|
|
2542
|
-
var i = 0;
|
|
2543
|
-
var path = "";
|
|
2544
|
-
var tryConsume = function(type) {
|
|
2545
|
-
if (i < tokens.length && tokens[i].type === type)
|
|
2546
|
-
return tokens[i++].value;
|
|
2547
|
-
};
|
|
2548
|
-
var mustConsume = function(type) {
|
|
2549
|
-
var value2 = tryConsume(type);
|
|
2550
|
-
if (value2 !== void 0)
|
|
2551
|
-
return value2;
|
|
2552
|
-
var _a2 = tokens[i], nextType = _a2.type, index = _a2.index;
|
|
2553
|
-
throw new TypeError("Unexpected " + nextType + " at " + index + ", expected " + type);
|
|
2554
|
-
};
|
|
2555
|
-
var consumeText = function() {
|
|
2556
|
-
var result2 = "";
|
|
2557
|
-
var value2;
|
|
2558
|
-
while (value2 = tryConsume("CHAR") || tryConsume("ESCAPED_CHAR")) {
|
|
2559
|
-
result2 += value2;
|
|
2560
|
-
}
|
|
2561
|
-
return result2;
|
|
2562
|
-
};
|
|
2563
|
-
while (i < tokens.length) {
|
|
2564
|
-
var char = tryConsume("CHAR");
|
|
2565
|
-
var name = tryConsume("NAME");
|
|
2566
|
-
var pattern = tryConsume("PATTERN");
|
|
2567
|
-
if (name || pattern) {
|
|
2568
|
-
var prefix = char || "";
|
|
2569
|
-
if (prefixes.indexOf(prefix) === -1) {
|
|
2570
|
-
path += prefix;
|
|
2571
|
-
prefix = "";
|
|
2572
|
-
}
|
|
2573
|
-
if (path) {
|
|
2574
|
-
result.push(path);
|
|
2575
|
-
path = "";
|
|
2576
|
-
}
|
|
2577
|
-
result.push({
|
|
2578
|
-
name: name || key++,
|
|
2579
|
-
prefix,
|
|
2580
|
-
suffix: "",
|
|
2581
|
-
pattern: pattern || defaultPattern,
|
|
2582
|
-
modifier: tryConsume("MODIFIER") || ""
|
|
2583
|
-
});
|
|
2584
|
-
continue;
|
|
2585
|
-
}
|
|
2586
|
-
var value = char || tryConsume("ESCAPED_CHAR");
|
|
2587
|
-
if (value) {
|
|
2588
|
-
path += value;
|
|
2589
|
-
continue;
|
|
2590
|
-
}
|
|
2591
|
-
if (path) {
|
|
2592
|
-
result.push(path);
|
|
2593
|
-
path = "";
|
|
2594
|
-
}
|
|
2595
|
-
var open = tryConsume("OPEN");
|
|
2596
|
-
if (open) {
|
|
2597
|
-
var prefix = consumeText();
|
|
2598
|
-
var name_1 = tryConsume("NAME") || "";
|
|
2599
|
-
var pattern_1 = tryConsume("PATTERN") || "";
|
|
2600
|
-
var suffix = consumeText();
|
|
2601
|
-
mustConsume("CLOSE");
|
|
2602
|
-
result.push({
|
|
2603
|
-
name: name_1 || (pattern_1 ? key++ : ""),
|
|
2604
|
-
pattern: name_1 && !pattern_1 ? defaultPattern : pattern_1,
|
|
2605
|
-
prefix,
|
|
2606
|
-
suffix,
|
|
2607
|
-
modifier: tryConsume("MODIFIER") || ""
|
|
2608
|
-
});
|
|
2609
|
-
continue;
|
|
2610
|
-
}
|
|
2611
|
-
mustConsume("END");
|
|
2612
|
-
}
|
|
2613
|
-
return result;
|
|
2614
|
-
}
|
|
2615
|
-
exports.parse = parse;
|
|
2616
|
-
function compile(str, options) {
|
|
2617
|
-
return tokensToFunction(parse(str, options), options);
|
|
2618
|
-
}
|
|
2619
|
-
exports.compile = compile;
|
|
2620
|
-
function tokensToFunction(tokens, options) {
|
|
2621
|
-
if (options === void 0) {
|
|
2622
|
-
options = {};
|
|
2623
|
-
}
|
|
2624
|
-
var reFlags = flags(options);
|
|
2625
|
-
var _a = options.encode, encode = _a === void 0 ? function(x) {
|
|
2626
|
-
return x;
|
|
2627
|
-
} : _a, _b = options.validate, validate = _b === void 0 ? true : _b;
|
|
2628
|
-
var matches = tokens.map(function(token) {
|
|
2629
|
-
if (typeof token === "object") {
|
|
2630
|
-
return new RegExp("^(?:" + token.pattern + ")$", reFlags);
|
|
2631
|
-
}
|
|
2632
|
-
});
|
|
2633
|
-
return function(data) {
|
|
2634
|
-
var path = "";
|
|
2635
|
-
for (var i = 0; i < tokens.length; i++) {
|
|
2636
|
-
var token = tokens[i];
|
|
2637
|
-
if (typeof token === "string") {
|
|
2638
|
-
path += token;
|
|
2639
|
-
continue;
|
|
2640
|
-
}
|
|
2641
|
-
var value = data ? data[token.name] : void 0;
|
|
2642
|
-
var optional = token.modifier === "?" || token.modifier === "*";
|
|
2643
|
-
var repeat = token.modifier === "*" || token.modifier === "+";
|
|
2644
|
-
if (Array.isArray(value)) {
|
|
2645
|
-
if (!repeat) {
|
|
2646
|
-
throw new TypeError('Expected "' + token.name + '" to not repeat, but got an array');
|
|
2647
|
-
}
|
|
2648
|
-
if (value.length === 0) {
|
|
2649
|
-
if (optional)
|
|
2650
|
-
continue;
|
|
2651
|
-
throw new TypeError('Expected "' + token.name + '" to not be empty');
|
|
2652
|
-
}
|
|
2653
|
-
for (var j = 0; j < value.length; j++) {
|
|
2654
|
-
var segment = encode(value[j], token);
|
|
2655
|
-
if (validate && !matches[i].test(segment)) {
|
|
2656
|
-
throw new TypeError('Expected all "' + token.name + '" to match "' + token.pattern + '", but got "' + segment + '"');
|
|
2657
|
-
}
|
|
2658
|
-
path += token.prefix + segment + token.suffix;
|
|
2659
|
-
}
|
|
2660
|
-
continue;
|
|
2661
|
-
}
|
|
2662
|
-
if (typeof value === "string" || typeof value === "number") {
|
|
2663
|
-
var segment = encode(String(value), token);
|
|
2664
|
-
if (validate && !matches[i].test(segment)) {
|
|
2665
|
-
throw new TypeError('Expected "' + token.name + '" to match "' + token.pattern + '", but got "' + segment + '"');
|
|
2666
|
-
}
|
|
2667
|
-
path += token.prefix + segment + token.suffix;
|
|
2668
|
-
continue;
|
|
2669
|
-
}
|
|
2670
|
-
if (optional)
|
|
2671
|
-
continue;
|
|
2672
|
-
var typeOfMessage = repeat ? "an array" : "a string";
|
|
2673
|
-
throw new TypeError('Expected "' + token.name + '" to be ' + typeOfMessage);
|
|
2674
|
-
}
|
|
2675
|
-
return path;
|
|
2676
|
-
};
|
|
2677
|
-
}
|
|
2678
|
-
exports.tokensToFunction = tokensToFunction;
|
|
2679
|
-
function match(str, options) {
|
|
2680
|
-
var keys = [];
|
|
2681
|
-
var re = pathToRegexp2(str, keys, options);
|
|
2682
|
-
return regexpToFunction(re, keys, options);
|
|
2683
|
-
}
|
|
2684
|
-
exports.match = match;
|
|
2685
|
-
function regexpToFunction(re, keys, options) {
|
|
2686
|
-
if (options === void 0) {
|
|
2687
|
-
options = {};
|
|
2688
|
-
}
|
|
2689
|
-
var _a = options.decode, decode = _a === void 0 ? function(x) {
|
|
2690
|
-
return x;
|
|
2691
|
-
} : _a;
|
|
2692
|
-
return function(pathname) {
|
|
2693
|
-
var m = re.exec(pathname);
|
|
2694
|
-
if (!m)
|
|
2695
|
-
return false;
|
|
2696
|
-
var path = m[0], index = m.index;
|
|
2697
|
-
var params = /* @__PURE__ */ Object.create(null);
|
|
2698
|
-
var _loop_1 = function(i2) {
|
|
2699
|
-
if (m[i2] === void 0)
|
|
2700
|
-
return "continue";
|
|
2701
|
-
var key = keys[i2 - 1];
|
|
2702
|
-
if (key.modifier === "*" || key.modifier === "+") {
|
|
2703
|
-
params[key.name] = m[i2].split(key.prefix + key.suffix).map(function(value) {
|
|
2704
|
-
return decode(value, key);
|
|
2705
|
-
});
|
|
2706
|
-
} else {
|
|
2707
|
-
params[key.name] = decode(m[i2], key);
|
|
2708
|
-
}
|
|
2709
|
-
};
|
|
2710
|
-
for (var i = 1; i < m.length; i++) {
|
|
2711
|
-
_loop_1(i);
|
|
2712
|
-
}
|
|
2713
|
-
return { path, index, params };
|
|
2714
|
-
};
|
|
2715
|
-
}
|
|
2716
|
-
exports.regexpToFunction = regexpToFunction;
|
|
2717
|
-
function escapeString(str) {
|
|
2718
|
-
return str.replace(/([.+*?=^!:${}()[\]|/\\])/g, "\\$1");
|
|
2719
|
-
}
|
|
2720
|
-
function flags(options) {
|
|
2721
|
-
return options && options.sensitive ? "" : "i";
|
|
2722
|
-
}
|
|
2723
|
-
function regexpToRegexp(path, keys) {
|
|
2724
|
-
if (!keys)
|
|
2725
|
-
return path;
|
|
2726
|
-
var groups = path.source.match(/\((?!\?)/g);
|
|
2727
|
-
if (groups) {
|
|
2728
|
-
for (var i = 0; i < groups.length; i++) {
|
|
2729
|
-
keys.push({
|
|
2730
|
-
name: i,
|
|
2731
|
-
prefix: "",
|
|
2732
|
-
suffix: "",
|
|
2733
|
-
modifier: "",
|
|
2734
|
-
pattern: ""
|
|
2735
|
-
});
|
|
2736
|
-
}
|
|
2737
|
-
}
|
|
2738
|
-
return path;
|
|
2739
|
-
}
|
|
2740
|
-
function arrayToRegexp(paths, keys, options) {
|
|
2741
|
-
var parts = paths.map(function(path) {
|
|
2742
|
-
return pathToRegexp2(path, keys, options).source;
|
|
2743
|
-
});
|
|
2744
|
-
return new RegExp("(?:" + parts.join("|") + ")", flags(options));
|
|
2745
|
-
}
|
|
2746
|
-
function stringToRegexp(path, keys, options) {
|
|
2747
|
-
return tokensToRegexp(parse(path, options), keys, options);
|
|
2748
|
-
}
|
|
2749
|
-
function tokensToRegexp(tokens, keys, options) {
|
|
2750
|
-
if (options === void 0) {
|
|
2751
|
-
options = {};
|
|
2752
|
-
}
|
|
2753
|
-
var _a = options.strict, strict = _a === void 0 ? false : _a, _b = options.start, start = _b === void 0 ? true : _b, _c = options.end, end = _c === void 0 ? true : _c, _d = options.encode, encode = _d === void 0 ? function(x) {
|
|
2754
|
-
return x;
|
|
2755
|
-
} : _d;
|
|
2756
|
-
var endsWith = "[" + escapeString(options.endsWith || "") + "]|$";
|
|
2757
|
-
var delimiter = "[" + escapeString(options.delimiter || "/#?") + "]";
|
|
2758
|
-
var route = start ? "^" : "";
|
|
2759
|
-
for (var _i = 0, tokens_1 = tokens; _i < tokens_1.length; _i++) {
|
|
2760
|
-
var token = tokens_1[_i];
|
|
2761
|
-
if (typeof token === "string") {
|
|
2762
|
-
route += escapeString(encode(token));
|
|
2763
|
-
} else {
|
|
2764
|
-
var prefix = escapeString(encode(token.prefix));
|
|
2765
|
-
var suffix = escapeString(encode(token.suffix));
|
|
2766
|
-
if (token.pattern) {
|
|
2767
|
-
if (keys)
|
|
2768
|
-
keys.push(token);
|
|
2769
|
-
if (prefix || suffix) {
|
|
2770
|
-
if (token.modifier === "+" || token.modifier === "*") {
|
|
2771
|
-
var mod = token.modifier === "*" ? "?" : "";
|
|
2772
|
-
route += "(?:" + prefix + "((?:" + token.pattern + ")(?:" + suffix + prefix + "(?:" + token.pattern + "))*)" + suffix + ")" + mod;
|
|
2773
|
-
} else {
|
|
2774
|
-
route += "(?:" + prefix + "(" + token.pattern + ")" + suffix + ")" + token.modifier;
|
|
2775
|
-
}
|
|
2776
|
-
} else {
|
|
2777
|
-
route += "(" + token.pattern + ")" + token.modifier;
|
|
2778
|
-
}
|
|
2779
|
-
} else {
|
|
2780
|
-
route += "(?:" + prefix + suffix + ")" + token.modifier;
|
|
2781
|
-
}
|
|
2782
|
-
}
|
|
2783
|
-
}
|
|
2784
|
-
if (end) {
|
|
2785
|
-
if (!strict)
|
|
2786
|
-
route += delimiter + "?";
|
|
2787
|
-
route += !options.endsWith ? "$" : "(?=" + endsWith + ")";
|
|
2788
|
-
} else {
|
|
2789
|
-
var endToken = tokens[tokens.length - 1];
|
|
2790
|
-
var isEndDelimited = typeof endToken === "string" ? delimiter.indexOf(endToken[endToken.length - 1]) > -1 : (
|
|
2791
|
-
// tslint:disable-next-line
|
|
2792
|
-
endToken === void 0
|
|
2793
|
-
);
|
|
2794
|
-
if (!strict) {
|
|
2795
|
-
route += "(?:" + delimiter + "(?=" + endsWith + "))?";
|
|
2796
|
-
}
|
|
2797
|
-
if (!isEndDelimited) {
|
|
2798
|
-
route += "(?=" + delimiter + "|" + endsWith + ")";
|
|
2799
|
-
}
|
|
2800
|
-
}
|
|
2801
|
-
return new RegExp(route, flags(options));
|
|
2802
|
-
}
|
|
2803
|
-
exports.tokensToRegexp = tokensToRegexp;
|
|
2804
|
-
function pathToRegexp2(path, keys, options) {
|
|
2805
|
-
if (path instanceof RegExp)
|
|
2806
|
-
return regexpToRegexp(path, keys);
|
|
2807
|
-
if (Array.isArray(path))
|
|
2808
|
-
return arrayToRegexp(path, keys, options);
|
|
2809
|
-
return stringToRegexp(path, keys, options);
|
|
2810
|
-
}
|
|
2811
|
-
exports.pathToRegexp = pathToRegexp2;
|
|
2812
|
-
}
|
|
2813
|
-
});
|
|
2814
|
-
|
|
2815
|
-
// ../../node_modules/.pnpm/path-to-regexp@6.3.0/node_modules/path-to-regexp/dist/index.js
|
|
2816
|
-
var require_dist2 = __commonJS({
|
|
2817
|
-
"../../node_modules/.pnpm/path-to-regexp@6.3.0/node_modules/path-to-regexp/dist/index.js"(exports) {
|
|
2818
|
-
"use strict";
|
|
2819
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
2820
|
-
exports.pathToRegexp = exports.tokensToRegexp = exports.regexpToFunction = exports.match = exports.tokensToFunction = exports.compile = exports.parse = void 0;
|
|
2821
|
-
function lexer(str) {
|
|
2822
|
-
var tokens = [];
|
|
2823
|
-
var i = 0;
|
|
2824
|
-
while (i < str.length) {
|
|
2825
|
-
var char = str[i];
|
|
2826
|
-
if (char === "*" || char === "+" || char === "?") {
|
|
2827
|
-
tokens.push({ type: "MODIFIER", index: i, value: str[i++] });
|
|
2828
|
-
continue;
|
|
2829
|
-
}
|
|
2830
|
-
if (char === "\\") {
|
|
2831
|
-
tokens.push({ type: "ESCAPED_CHAR", index: i++, value: str[i++] });
|
|
2832
|
-
continue;
|
|
2833
|
-
}
|
|
2834
|
-
if (char === "{") {
|
|
2835
|
-
tokens.push({ type: "OPEN", index: i, value: str[i++] });
|
|
2836
|
-
continue;
|
|
2837
|
-
}
|
|
2838
|
-
if (char === "}") {
|
|
2839
|
-
tokens.push({ type: "CLOSE", index: i, value: str[i++] });
|
|
2840
|
-
continue;
|
|
2841
|
-
}
|
|
2842
|
-
if (char === ":") {
|
|
2843
|
-
var name = "";
|
|
2844
|
-
var j = i + 1;
|
|
2845
|
-
while (j < str.length) {
|
|
2846
|
-
var code = str.charCodeAt(j);
|
|
2847
|
-
if (
|
|
2848
|
-
// `0-9`
|
|
2849
|
-
code >= 48 && code <= 57 || // `A-Z`
|
|
2850
|
-
code >= 65 && code <= 90 || // `a-z`
|
|
2851
|
-
code >= 97 && code <= 122 || // `_`
|
|
2852
|
-
code === 95
|
|
2853
|
-
) {
|
|
2854
|
-
name += str[j++];
|
|
2855
|
-
continue;
|
|
2856
|
-
}
|
|
2857
|
-
break;
|
|
2858
|
-
}
|
|
2859
|
-
if (!name)
|
|
2860
|
-
throw new TypeError("Missing parameter name at ".concat(i));
|
|
2861
|
-
tokens.push({ type: "NAME", index: i, value: name });
|
|
2862
|
-
i = j;
|
|
2863
|
-
continue;
|
|
2864
|
-
}
|
|
2865
|
-
if (char === "(") {
|
|
2866
|
-
var count = 1;
|
|
2867
|
-
var pattern = "";
|
|
2868
|
-
var j = i + 1;
|
|
2869
|
-
if (str[j] === "?") {
|
|
2870
|
-
throw new TypeError('Pattern cannot start with "?" at '.concat(j));
|
|
2871
|
-
}
|
|
2872
|
-
while (j < str.length) {
|
|
2873
|
-
if (str[j] === "\\") {
|
|
2874
|
-
pattern += str[j++] + str[j++];
|
|
2875
|
-
continue;
|
|
2876
|
-
}
|
|
2877
|
-
if (str[j] === ")") {
|
|
2878
|
-
count--;
|
|
2879
|
-
if (count === 0) {
|
|
2880
|
-
j++;
|
|
2881
|
-
break;
|
|
2882
|
-
}
|
|
2883
|
-
} else if (str[j] === "(") {
|
|
2884
|
-
count++;
|
|
2885
|
-
if (str[j + 1] !== "?") {
|
|
2886
|
-
throw new TypeError("Capturing groups are not allowed at ".concat(j));
|
|
2887
|
-
}
|
|
2888
|
-
}
|
|
2889
|
-
pattern += str[j++];
|
|
2890
|
-
}
|
|
2891
|
-
if (count)
|
|
2892
|
-
throw new TypeError("Unbalanced pattern at ".concat(i));
|
|
2893
|
-
if (!pattern)
|
|
2894
|
-
throw new TypeError("Missing pattern at ".concat(i));
|
|
2895
|
-
tokens.push({ type: "PATTERN", index: i, value: pattern });
|
|
2896
|
-
i = j;
|
|
2897
|
-
continue;
|
|
2898
|
-
}
|
|
2899
|
-
tokens.push({ type: "CHAR", index: i, value: str[i++] });
|
|
2900
|
-
}
|
|
2901
|
-
tokens.push({ type: "END", index: i, value: "" });
|
|
2902
|
-
return tokens;
|
|
2903
|
-
}
|
|
2904
|
-
function parse(str, options) {
|
|
2905
|
-
if (options === void 0) {
|
|
2906
|
-
options = {};
|
|
2907
|
-
}
|
|
2908
|
-
var tokens = lexer(str);
|
|
2909
|
-
var _a = options.prefixes, prefixes = _a === void 0 ? "./" : _a, _b = options.delimiter, delimiter = _b === void 0 ? "/#?" : _b;
|
|
2910
|
-
var result = [];
|
|
2911
|
-
var key = 0;
|
|
2912
|
-
var i = 0;
|
|
2913
|
-
var path = "";
|
|
2914
|
-
var tryConsume = function(type) {
|
|
2915
|
-
if (i < tokens.length && tokens[i].type === type)
|
|
2916
|
-
return tokens[i++].value;
|
|
2917
|
-
};
|
|
2918
|
-
var mustConsume = function(type) {
|
|
2919
|
-
var value2 = tryConsume(type);
|
|
2920
|
-
if (value2 !== void 0)
|
|
2921
|
-
return value2;
|
|
2922
|
-
var _a2 = tokens[i], nextType = _a2.type, index = _a2.index;
|
|
2923
|
-
throw new TypeError("Unexpected ".concat(nextType, " at ").concat(index, ", expected ").concat(type));
|
|
2924
|
-
};
|
|
2925
|
-
var consumeText = function() {
|
|
2926
|
-
var result2 = "";
|
|
2927
|
-
var value2;
|
|
2928
|
-
while (value2 = tryConsume("CHAR") || tryConsume("ESCAPED_CHAR")) {
|
|
2929
|
-
result2 += value2;
|
|
2930
|
-
}
|
|
2931
|
-
return result2;
|
|
2932
|
-
};
|
|
2933
|
-
var isSafe = function(value2) {
|
|
2934
|
-
for (var _i = 0, delimiter_1 = delimiter; _i < delimiter_1.length; _i++) {
|
|
2935
|
-
var char2 = delimiter_1[_i];
|
|
2936
|
-
if (value2.indexOf(char2) > -1)
|
|
2937
|
-
return true;
|
|
2938
|
-
}
|
|
2939
|
-
return false;
|
|
2940
|
-
};
|
|
2941
|
-
var safePattern = function(prefix2) {
|
|
2942
|
-
var prev = result[result.length - 1];
|
|
2943
|
-
var prevText = prefix2 || (prev && typeof prev === "string" ? prev : "");
|
|
2944
|
-
if (prev && !prevText) {
|
|
2945
|
-
throw new TypeError('Must have text between two parameters, missing text after "'.concat(prev.name, '"'));
|
|
2946
|
-
}
|
|
2947
|
-
if (!prevText || isSafe(prevText))
|
|
2948
|
-
return "[^".concat(escapeString(delimiter), "]+?");
|
|
2949
|
-
return "(?:(?!".concat(escapeString(prevText), ")[^").concat(escapeString(delimiter), "])+?");
|
|
2950
|
-
};
|
|
2951
|
-
while (i < tokens.length) {
|
|
2952
|
-
var char = tryConsume("CHAR");
|
|
2953
|
-
var name = tryConsume("NAME");
|
|
2954
|
-
var pattern = tryConsume("PATTERN");
|
|
2955
|
-
if (name || pattern) {
|
|
2956
|
-
var prefix = char || "";
|
|
2957
|
-
if (prefixes.indexOf(prefix) === -1) {
|
|
2958
|
-
path += prefix;
|
|
2959
|
-
prefix = "";
|
|
2960
|
-
}
|
|
2961
|
-
if (path) {
|
|
2962
|
-
result.push(path);
|
|
2963
|
-
path = "";
|
|
2964
|
-
}
|
|
2965
|
-
result.push({
|
|
2966
|
-
name: name || key++,
|
|
2967
|
-
prefix,
|
|
2968
|
-
suffix: "",
|
|
2969
|
-
pattern: pattern || safePattern(prefix),
|
|
2970
|
-
modifier: tryConsume("MODIFIER") || ""
|
|
2971
|
-
});
|
|
2972
|
-
continue;
|
|
2973
|
-
}
|
|
2974
|
-
var value = char || tryConsume("ESCAPED_CHAR");
|
|
2975
|
-
if (value) {
|
|
2976
|
-
path += value;
|
|
2977
|
-
continue;
|
|
2978
|
-
}
|
|
2979
|
-
if (path) {
|
|
2980
|
-
result.push(path);
|
|
2981
|
-
path = "";
|
|
2982
|
-
}
|
|
2983
|
-
var open = tryConsume("OPEN");
|
|
2984
|
-
if (open) {
|
|
2985
|
-
var prefix = consumeText();
|
|
2986
|
-
var name_1 = tryConsume("NAME") || "";
|
|
2987
|
-
var pattern_1 = tryConsume("PATTERN") || "";
|
|
2988
|
-
var suffix = consumeText();
|
|
2989
|
-
mustConsume("CLOSE");
|
|
2990
|
-
result.push({
|
|
2991
|
-
name: name_1 || (pattern_1 ? key++ : ""),
|
|
2992
|
-
pattern: name_1 && !pattern_1 ? safePattern(prefix) : pattern_1,
|
|
2993
|
-
prefix,
|
|
2994
|
-
suffix,
|
|
2995
|
-
modifier: tryConsume("MODIFIER") || ""
|
|
2996
|
-
});
|
|
2997
|
-
continue;
|
|
2998
|
-
}
|
|
2999
|
-
mustConsume("END");
|
|
3000
|
-
}
|
|
3001
|
-
return result;
|
|
3002
|
-
}
|
|
3003
|
-
exports.parse = parse;
|
|
3004
|
-
function compile(str, options) {
|
|
3005
|
-
return tokensToFunction(parse(str, options), options);
|
|
3006
|
-
}
|
|
3007
|
-
exports.compile = compile;
|
|
3008
|
-
function tokensToFunction(tokens, options) {
|
|
3009
|
-
if (options === void 0) {
|
|
3010
|
-
options = {};
|
|
3011
|
-
}
|
|
3012
|
-
var reFlags = flags(options);
|
|
3013
|
-
var _a = options.encode, encode = _a === void 0 ? function(x) {
|
|
3014
|
-
return x;
|
|
3015
|
-
} : _a, _b = options.validate, validate = _b === void 0 ? true : _b;
|
|
3016
|
-
var matches = tokens.map(function(token) {
|
|
3017
|
-
if (typeof token === "object") {
|
|
3018
|
-
return new RegExp("^(?:".concat(token.pattern, ")$"), reFlags);
|
|
3019
|
-
}
|
|
3020
|
-
});
|
|
3021
|
-
return function(data) {
|
|
3022
|
-
var path = "";
|
|
3023
|
-
for (var i = 0; i < tokens.length; i++) {
|
|
3024
|
-
var token = tokens[i];
|
|
3025
|
-
if (typeof token === "string") {
|
|
3026
|
-
path += token;
|
|
3027
|
-
continue;
|
|
3028
|
-
}
|
|
3029
|
-
var value = data ? data[token.name] : void 0;
|
|
3030
|
-
var optional = token.modifier === "?" || token.modifier === "*";
|
|
3031
|
-
var repeat = token.modifier === "*" || token.modifier === "+";
|
|
3032
|
-
if (Array.isArray(value)) {
|
|
3033
|
-
if (!repeat) {
|
|
3034
|
-
throw new TypeError('Expected "'.concat(token.name, '" to not repeat, but got an array'));
|
|
3035
|
-
}
|
|
3036
|
-
if (value.length === 0) {
|
|
3037
|
-
if (optional)
|
|
3038
|
-
continue;
|
|
3039
|
-
throw new TypeError('Expected "'.concat(token.name, '" to not be empty'));
|
|
3040
|
-
}
|
|
3041
|
-
for (var j = 0; j < value.length; j++) {
|
|
3042
|
-
var segment = encode(value[j], token);
|
|
3043
|
-
if (validate && !matches[i].test(segment)) {
|
|
3044
|
-
throw new TypeError('Expected all "'.concat(token.name, '" to match "').concat(token.pattern, '", but got "').concat(segment, '"'));
|
|
3045
|
-
}
|
|
3046
|
-
path += token.prefix + segment + token.suffix;
|
|
3047
|
-
}
|
|
3048
|
-
continue;
|
|
3049
|
-
}
|
|
3050
|
-
if (typeof value === "string" || typeof value === "number") {
|
|
3051
|
-
var segment = encode(String(value), token);
|
|
3052
|
-
if (validate && !matches[i].test(segment)) {
|
|
3053
|
-
throw new TypeError('Expected "'.concat(token.name, '" to match "').concat(token.pattern, '", but got "').concat(segment, '"'));
|
|
3054
|
-
}
|
|
3055
|
-
path += token.prefix + segment + token.suffix;
|
|
3056
|
-
continue;
|
|
3057
|
-
}
|
|
3058
|
-
if (optional)
|
|
3059
|
-
continue;
|
|
3060
|
-
var typeOfMessage = repeat ? "an array" : "a string";
|
|
3061
|
-
throw new TypeError('Expected "'.concat(token.name, '" to be ').concat(typeOfMessage));
|
|
3062
|
-
}
|
|
3063
|
-
return path;
|
|
3064
|
-
};
|
|
3065
|
-
}
|
|
3066
|
-
exports.tokensToFunction = tokensToFunction;
|
|
3067
|
-
function match(str, options) {
|
|
3068
|
-
var keys = [];
|
|
3069
|
-
var re = pathToRegexp2(str, keys, options);
|
|
3070
|
-
return regexpToFunction(re, keys, options);
|
|
3071
|
-
}
|
|
3072
|
-
exports.match = match;
|
|
3073
|
-
function regexpToFunction(re, keys, options) {
|
|
3074
|
-
if (options === void 0) {
|
|
3075
|
-
options = {};
|
|
3076
|
-
}
|
|
3077
|
-
var _a = options.decode, decode = _a === void 0 ? function(x) {
|
|
3078
|
-
return x;
|
|
3079
|
-
} : _a;
|
|
3080
|
-
return function(pathname) {
|
|
3081
|
-
var m = re.exec(pathname);
|
|
3082
|
-
if (!m)
|
|
3083
|
-
return false;
|
|
3084
|
-
var path = m[0], index = m.index;
|
|
3085
|
-
var params = /* @__PURE__ */ Object.create(null);
|
|
3086
|
-
var _loop_1 = function(i2) {
|
|
3087
|
-
if (m[i2] === void 0)
|
|
3088
|
-
return "continue";
|
|
3089
|
-
var key = keys[i2 - 1];
|
|
3090
|
-
if (key.modifier === "*" || key.modifier === "+") {
|
|
3091
|
-
params[key.name] = m[i2].split(key.prefix + key.suffix).map(function(value) {
|
|
3092
|
-
return decode(value, key);
|
|
3093
|
-
});
|
|
3094
|
-
} else {
|
|
3095
|
-
params[key.name] = decode(m[i2], key);
|
|
3096
|
-
}
|
|
3097
|
-
};
|
|
3098
|
-
for (var i = 1; i < m.length; i++) {
|
|
3099
|
-
_loop_1(i);
|
|
3100
|
-
}
|
|
3101
|
-
return { path, index, params };
|
|
3102
|
-
};
|
|
3103
|
-
}
|
|
3104
|
-
exports.regexpToFunction = regexpToFunction;
|
|
3105
|
-
function escapeString(str) {
|
|
3106
|
-
return str.replace(/([.+*?=^!:${}()[\]|/\\])/g, "\\$1");
|
|
3107
|
-
}
|
|
3108
|
-
function flags(options) {
|
|
3109
|
-
return options && options.sensitive ? "" : "i";
|
|
3110
|
-
}
|
|
3111
|
-
function regexpToRegexp(path, keys) {
|
|
3112
|
-
if (!keys)
|
|
3113
|
-
return path;
|
|
3114
|
-
var groupsRegex = /\((?:\?<(.*?)>)?(?!\?)/g;
|
|
3115
|
-
var index = 0;
|
|
3116
|
-
var execResult = groupsRegex.exec(path.source);
|
|
3117
|
-
while (execResult) {
|
|
3118
|
-
keys.push({
|
|
3119
|
-
// Use parenthesized substring match if available, index otherwise
|
|
3120
|
-
name: execResult[1] || index++,
|
|
3121
|
-
prefix: "",
|
|
3122
|
-
suffix: "",
|
|
3123
|
-
modifier: "",
|
|
3124
|
-
pattern: ""
|
|
3125
|
-
});
|
|
3126
|
-
execResult = groupsRegex.exec(path.source);
|
|
3127
|
-
}
|
|
3128
|
-
return path;
|
|
3129
|
-
}
|
|
3130
|
-
function arrayToRegexp(paths, keys, options) {
|
|
3131
|
-
var parts = paths.map(function(path) {
|
|
3132
|
-
return pathToRegexp2(path, keys, options).source;
|
|
3133
|
-
});
|
|
3134
|
-
return new RegExp("(?:".concat(parts.join("|"), ")"), flags(options));
|
|
3135
|
-
}
|
|
3136
|
-
function stringToRegexp(path, keys, options) {
|
|
3137
|
-
return tokensToRegexp(parse(path, options), keys, options);
|
|
3138
|
-
}
|
|
3139
|
-
function tokensToRegexp(tokens, keys, options) {
|
|
3140
|
-
if (options === void 0) {
|
|
3141
|
-
options = {};
|
|
3142
|
-
}
|
|
3143
|
-
var _a = options.strict, strict = _a === void 0 ? false : _a, _b = options.start, start = _b === void 0 ? true : _b, _c = options.end, end = _c === void 0 ? true : _c, _d = options.encode, encode = _d === void 0 ? function(x) {
|
|
3144
|
-
return x;
|
|
3145
|
-
} : _d, _e = options.delimiter, delimiter = _e === void 0 ? "/#?" : _e, _f = options.endsWith, endsWith = _f === void 0 ? "" : _f;
|
|
3146
|
-
var endsWithRe = "[".concat(escapeString(endsWith), "]|$");
|
|
3147
|
-
var delimiterRe = "[".concat(escapeString(delimiter), "]");
|
|
3148
|
-
var route = start ? "^" : "";
|
|
3149
|
-
for (var _i = 0, tokens_1 = tokens; _i < tokens_1.length; _i++) {
|
|
3150
|
-
var token = tokens_1[_i];
|
|
3151
|
-
if (typeof token === "string") {
|
|
3152
|
-
route += escapeString(encode(token));
|
|
3153
|
-
} else {
|
|
3154
|
-
var prefix = escapeString(encode(token.prefix));
|
|
3155
|
-
var suffix = escapeString(encode(token.suffix));
|
|
3156
|
-
if (token.pattern) {
|
|
3157
|
-
if (keys)
|
|
3158
|
-
keys.push(token);
|
|
3159
|
-
if (prefix || suffix) {
|
|
3160
|
-
if (token.modifier === "+" || token.modifier === "*") {
|
|
3161
|
-
var mod = token.modifier === "*" ? "?" : "";
|
|
3162
|
-
route += "(?:".concat(prefix, "((?:").concat(token.pattern, ")(?:").concat(suffix).concat(prefix, "(?:").concat(token.pattern, "))*)").concat(suffix, ")").concat(mod);
|
|
3163
|
-
} else {
|
|
3164
|
-
route += "(?:".concat(prefix, "(").concat(token.pattern, ")").concat(suffix, ")").concat(token.modifier);
|
|
3165
|
-
}
|
|
3166
|
-
} else {
|
|
3167
|
-
if (token.modifier === "+" || token.modifier === "*") {
|
|
3168
|
-
throw new TypeError('Can not repeat "'.concat(token.name, '" without a prefix and suffix'));
|
|
3169
|
-
}
|
|
3170
|
-
route += "(".concat(token.pattern, ")").concat(token.modifier);
|
|
3171
|
-
}
|
|
3172
|
-
} else {
|
|
3173
|
-
route += "(?:".concat(prefix).concat(suffix, ")").concat(token.modifier);
|
|
3174
|
-
}
|
|
3175
|
-
}
|
|
3176
|
-
}
|
|
3177
|
-
if (end) {
|
|
3178
|
-
if (!strict)
|
|
3179
|
-
route += "".concat(delimiterRe, "?");
|
|
3180
|
-
route += !options.endsWith ? "$" : "(?=".concat(endsWithRe, ")");
|
|
3181
|
-
} else {
|
|
3182
|
-
var endToken = tokens[tokens.length - 1];
|
|
3183
|
-
var isEndDelimited = typeof endToken === "string" ? delimiterRe.indexOf(endToken[endToken.length - 1]) > -1 : endToken === void 0;
|
|
3184
|
-
if (!strict) {
|
|
3185
|
-
route += "(?:".concat(delimiterRe, "(?=").concat(endsWithRe, "))?");
|
|
3186
|
-
}
|
|
3187
|
-
if (!isEndDelimited) {
|
|
3188
|
-
route += "(?=".concat(delimiterRe, "|").concat(endsWithRe, ")");
|
|
3189
|
-
}
|
|
3190
|
-
}
|
|
3191
|
-
return new RegExp(route, flags(options));
|
|
3192
|
-
}
|
|
3193
|
-
exports.tokensToRegexp = tokensToRegexp;
|
|
3194
|
-
function pathToRegexp2(path, keys, options) {
|
|
3195
|
-
if (path instanceof RegExp)
|
|
3196
|
-
return regexpToRegexp(path, keys);
|
|
3197
|
-
if (Array.isArray(path))
|
|
3198
|
-
return arrayToRegexp(path, keys, options);
|
|
3199
|
-
return stringToRegexp(path, keys, options);
|
|
3200
|
-
}
|
|
3201
|
-
exports.pathToRegexp = pathToRegexp2;
|
|
3202
|
-
}
|
|
3203
|
-
});
|
|
3204
|
-
|
|
3205
|
-
// ../../internals/path-to-regexp/dist/index.js
|
|
3206
|
-
var require_dist3 = __commonJS({
|
|
3207
|
-
"../../internals/path-to-regexp/dist/index.js"(exports) {
|
|
3208
|
-
"use strict";
|
|
3209
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3210
|
-
exports.compile = exports.pathToRegexp = void 0;
|
|
3211
|
-
var path_to_regexp_1 = require_dist();
|
|
3212
|
-
Object.defineProperty(exports, "compile", { enumerable: true, get: function() {
|
|
3213
|
-
return path_to_regexp_1.compile;
|
|
3214
|
-
} });
|
|
3215
|
-
var path_to_regexp_updated_1 = require_dist2();
|
|
3216
|
-
function cloneKeys(keys) {
|
|
3217
|
-
if (typeof keys === "undefined") {
|
|
3218
|
-
return void 0;
|
|
3219
|
-
}
|
|
3220
|
-
return keys.slice(0);
|
|
3221
|
-
}
|
|
3222
|
-
function compareKeys(left, right) {
|
|
3223
|
-
const leftSerialized = typeof left === "undefined" ? "undefined" : left.toString();
|
|
3224
|
-
const rightSerialized = typeof right === "undefined" ? "undefined" : right.toString();
|
|
3225
|
-
return leftSerialized === rightSerialized;
|
|
3226
|
-
}
|
|
3227
|
-
function pathToRegexp2(callerId, path, keys, options) {
|
|
3228
|
-
const newKeys = cloneKeys(keys);
|
|
3229
|
-
const currentRegExp = (0, path_to_regexp_1.pathToRegexp)(path, keys, options);
|
|
3230
|
-
try {
|
|
3231
|
-
const currentKeys = keys;
|
|
3232
|
-
const newRegExp = (0, path_to_regexp_updated_1.pathToRegexp)(path, newKeys, options);
|
|
3233
|
-
const isDiffRegExp = currentRegExp.toString() !== newRegExp.toString();
|
|
3234
|
-
if (process.env.FORCE_PATH_TO_REGEXP_LOG || isDiffRegExp) {
|
|
3235
|
-
const message = JSON.stringify({
|
|
3236
|
-
path,
|
|
3237
|
-
currentRegExp: currentRegExp.toString(),
|
|
3238
|
-
newRegExp: newRegExp.toString()
|
|
3239
|
-
});
|
|
3240
|
-
console.error(`[vc] PATH TO REGEXP PATH DIFF @ #${callerId}: ${message}`);
|
|
3241
|
-
}
|
|
3242
|
-
const isDiffKeys = !compareKeys(keys, newKeys);
|
|
3243
|
-
if (process.env.FORCE_PATH_TO_REGEXP_LOG || isDiffKeys) {
|
|
3244
|
-
const message = JSON.stringify({
|
|
3245
|
-
isDiffKeys,
|
|
3246
|
-
currentKeys,
|
|
3247
|
-
newKeys
|
|
3248
|
-
});
|
|
3249
|
-
console.error(`[vc] PATH TO REGEXP KEYS DIFF @ #${callerId}: ${message}`);
|
|
3250
|
-
}
|
|
3251
|
-
} catch (err) {
|
|
3252
|
-
const error = err;
|
|
3253
|
-
const message = JSON.stringify({
|
|
3254
|
-
path,
|
|
3255
|
-
error: error.message
|
|
3256
|
-
});
|
|
3257
|
-
console.error(`[vc] PATH TO REGEXP ERROR @ #${callerId}: ${message}`);
|
|
3258
|
-
}
|
|
3259
|
-
return currentRegExp;
|
|
3260
|
-
}
|
|
3261
|
-
exports.pathToRegexp = pathToRegexp2;
|
|
3262
|
-
}
|
|
3263
|
-
});
|
|
3264
|
-
|
|
3265
2445
|
// src/index.ts
|
|
3266
2446
|
var src_exports = {};
|
|
3267
2447
|
__export(src_exports, {
|
|
@@ -3282,10 +2462,56 @@ var import_build_utils3 = require("@vercel/build-utils");
|
|
|
3282
2462
|
var import_semver = __toESM(require_semver2());
|
|
3283
2463
|
var import_fs = require("fs");
|
|
3284
2464
|
var import_path = require("path");
|
|
3285
|
-
var import_path_to_regexp = __toESM(require_dist3());
|
|
3286
2465
|
var import_build_utils = require("@vercel/build-utils");
|
|
3287
2466
|
var import_build_utils2 = require("@vercel/build-utils");
|
|
3288
2467
|
var import_module = require("module");
|
|
2468
|
+
var import_path_to_regexp = require("path-to-regexp");
|
|
2469
|
+
var import_path_to_regexp_updated = require("path-to-regexp-updated");
|
|
2470
|
+
function cloneKeys(keys) {
|
|
2471
|
+
if (typeof keys === "undefined") {
|
|
2472
|
+
return void 0;
|
|
2473
|
+
}
|
|
2474
|
+
return keys.slice(0);
|
|
2475
|
+
}
|
|
2476
|
+
function compareKeys(left, right) {
|
|
2477
|
+
const leftSerialized = typeof left === "undefined" ? "undefined" : left.toString();
|
|
2478
|
+
const rightSerialized = typeof right === "undefined" ? "undefined" : right.toString();
|
|
2479
|
+
return leftSerialized === rightSerialized;
|
|
2480
|
+
}
|
|
2481
|
+
function pathToRegexp(callerId, path, keys, options) {
|
|
2482
|
+
const newKeys = cloneKeys(keys);
|
|
2483
|
+
const currentRegExp = (0, import_path_to_regexp.pathToRegexp)(path, keys, options);
|
|
2484
|
+
try {
|
|
2485
|
+
const currentKeys = keys;
|
|
2486
|
+
const newRegExp = (0, import_path_to_regexp_updated.pathToRegexp)(path, newKeys, options);
|
|
2487
|
+
const isDiffRegExp = currentRegExp.toString() !== newRegExp.toString();
|
|
2488
|
+
if (process.env.FORCE_PATH_TO_REGEXP_LOG || isDiffRegExp) {
|
|
2489
|
+
const message = JSON.stringify({
|
|
2490
|
+
path,
|
|
2491
|
+
currentRegExp: currentRegExp.toString(),
|
|
2492
|
+
newRegExp: newRegExp.toString()
|
|
2493
|
+
});
|
|
2494
|
+
console.error(`[vc] PATH TO REGEXP PATH DIFF @ #${callerId}: ${message}`);
|
|
2495
|
+
}
|
|
2496
|
+
const isDiffKeys = !compareKeys(keys, newKeys);
|
|
2497
|
+
if (process.env.FORCE_PATH_TO_REGEXP_LOG || isDiffKeys) {
|
|
2498
|
+
const message = JSON.stringify({
|
|
2499
|
+
isDiffKeys,
|
|
2500
|
+
currentKeys,
|
|
2501
|
+
newKeys
|
|
2502
|
+
});
|
|
2503
|
+
console.error(`[vc] PATH TO REGEXP KEYS DIFF @ #${callerId}: ${message}`);
|
|
2504
|
+
}
|
|
2505
|
+
} catch (err) {
|
|
2506
|
+
const error = err;
|
|
2507
|
+
const message = JSON.stringify({
|
|
2508
|
+
path,
|
|
2509
|
+
error: error.message
|
|
2510
|
+
});
|
|
2511
|
+
console.error(`[vc] PATH TO REGEXP ERROR @ #${callerId}: ${message}`);
|
|
2512
|
+
}
|
|
2513
|
+
return currentRegExp;
|
|
2514
|
+
}
|
|
3289
2515
|
var require_ = (0, import_module.createRequire)(__filename);
|
|
3290
2516
|
var SPLAT_PATH = "/:params*";
|
|
3291
2517
|
var entryExts = [".js", ".jsx", ".ts", ".tsx"];
|
|
@@ -3396,7 +2622,7 @@ function getPathFromRoute(route, routes) {
|
|
|
3396
2622
|
}
|
|
3397
2623
|
function getRegExpFromPath(rePath) {
|
|
3398
2624
|
const keys = [];
|
|
3399
|
-
const re =
|
|
2625
|
+
const re = pathToRegexp("923", rePath, keys);
|
|
3400
2626
|
return keys.length > 0 ? re : false;
|
|
3401
2627
|
}
|
|
3402
2628
|
async function chdirAndReadConfig(remixRunDevPath, dir, packageJsonPath) {
|
|
@@ -3591,6 +2817,15 @@ var REMIX_FRAMEWORK_SETTINGS = {
|
|
|
3591
2817
|
buildResultFilePath: ".vercel/remix-build-result.json",
|
|
3592
2818
|
slug: "remix",
|
|
3593
2819
|
sourceSearchValue: "@remix-run/dev/server-build",
|
|
2820
|
+
edge: {
|
|
2821
|
+
serverSourcePromise: edgeServerSrcPromise,
|
|
2822
|
+
traceWarningTag: "@remix-run/server-runtime"
|
|
2823
|
+
},
|
|
2824
|
+
node: {
|
|
2825
|
+
serverSourcePromise: nodeServerSrcPromise,
|
|
2826
|
+
traceWarningTag: "@remix-run/node",
|
|
2827
|
+
options: {}
|
|
2828
|
+
},
|
|
3594
2829
|
createRenderFunction({
|
|
3595
2830
|
nodeVersion,
|
|
3596
2831
|
entrypointDir,
|
|
@@ -3627,6 +2862,16 @@ var REACT_ROUTER_FRAMEWORK_SETTINGS = {
|
|
|
3627
2862
|
buildResultFilePath: ".vercel/react-router-build-result.json",
|
|
3628
2863
|
slug: "react-router",
|
|
3629
2864
|
sourceSearchValue: "ENTRYPOINT_PLACEHOLDER",
|
|
2865
|
+
// React Router uses the same server source for both node and edge
|
|
2866
|
+
edge: {
|
|
2867
|
+
serverSourcePromise: reactRouterServerSrcPromise,
|
|
2868
|
+
traceWarningTag: "react-router"
|
|
2869
|
+
},
|
|
2870
|
+
node: {
|
|
2871
|
+
serverSourcePromise: reactRouterServerSrcPromise,
|
|
2872
|
+
traceWarningTag: "react-router",
|
|
2873
|
+
options: { useWebApi: true }
|
|
2874
|
+
},
|
|
3630
2875
|
createRenderFunction({
|
|
3631
2876
|
nodeVersion,
|
|
3632
2877
|
entrypointDir,
|
|
@@ -3758,6 +3003,28 @@ var build = async ({
|
|
|
3758
3003
|
});
|
|
3759
3004
|
}
|
|
3760
3005
|
}
|
|
3006
|
+
const buildOutputPath = (0, import_path2.join)(entrypointFsDirname, ".vercel/output");
|
|
3007
|
+
let buildOutputVersion;
|
|
3008
|
+
try {
|
|
3009
|
+
const boaConfigPath = (0, import_path2.join)(buildOutputPath, "config.json");
|
|
3010
|
+
const buildResultContents = await import_fs2.promises.readFile(boaConfigPath, "utf8");
|
|
3011
|
+
buildOutputVersion = JSON.parse(buildResultContents).version;
|
|
3012
|
+
} catch (err) {
|
|
3013
|
+
if ((0, import_error_utils.isErrnoException)(err) && err.code === "ENOENT") {
|
|
3014
|
+
} else {
|
|
3015
|
+
(0, import_build_utils3.debug)(
|
|
3016
|
+
`Error reading ".vercel/output/config.json": ${(0, import_error_utils.errorToString)(err)}`
|
|
3017
|
+
);
|
|
3018
|
+
}
|
|
3019
|
+
}
|
|
3020
|
+
if (buildOutputVersion) {
|
|
3021
|
+
if (buildOutputVersion !== 3) {
|
|
3022
|
+
throw new Error(
|
|
3023
|
+
`The "version" property in ".vercel/output/config.json" must be 3 (received ${buildOutputVersion})`
|
|
3024
|
+
);
|
|
3025
|
+
}
|
|
3026
|
+
return { buildOutputVersion: 3, buildOutputPath };
|
|
3027
|
+
}
|
|
3761
3028
|
const buildResultJsonPath = (0, import_path2.join)(
|
|
3762
3029
|
entrypointFsDirname,
|
|
3763
3030
|
frameworkSettings.buildResultFilePath
|
|
@@ -3919,7 +3186,11 @@ async function createRenderReactRouterFunction(nodeVersion, entrypointDir, rootD
|
|
|
3919
3186
|
rootDir,
|
|
3920
3187
|
serverBuildPath,
|
|
3921
3188
|
serverEntryPoint,
|
|
3922
|
-
serverSourcePromise:
|
|
3189
|
+
serverSourcePromise: (
|
|
3190
|
+
// React Router has the same promise for both edge and node
|
|
3191
|
+
// so this chooses edge out of convenience
|
|
3192
|
+
REACT_ROUTER_FRAMEWORK_SETTINGS.edge.serverSourcePromise
|
|
3193
|
+
),
|
|
3923
3194
|
sourceSearchValue: REACT_ROUTER_FRAMEWORK_SETTINGS.sourceSearchValue
|
|
3924
3195
|
});
|
|
3925
3196
|
let conditions;
|
|
@@ -3934,7 +3205,10 @@ async function createRenderReactRouterFunction(nodeVersion, entrypointDir, rootD
|
|
|
3934
3205
|
conditions,
|
|
3935
3206
|
readFile
|
|
3936
3207
|
});
|
|
3937
|
-
logNftWarnings(
|
|
3208
|
+
logNftWarnings(
|
|
3209
|
+
trace.warnings,
|
|
3210
|
+
REACT_ROUTER_FRAMEWORK_SETTINGS.edge.traceWarningTag
|
|
3211
|
+
);
|
|
3938
3212
|
const files = await getFilesFromTrace({ fileList: trace.fileList, rootDir });
|
|
3939
3213
|
let fn;
|
|
3940
3214
|
if (isEdgeFunction) {
|
|
@@ -3954,7 +3228,7 @@ async function createRenderReactRouterFunction(nodeVersion, entrypointDir, rootD
|
|
|
3954
3228
|
files,
|
|
3955
3229
|
handler,
|
|
3956
3230
|
runtime: nodeVersion.runtime,
|
|
3957
|
-
useWebApi:
|
|
3231
|
+
useWebApi: REACT_ROUTER_FRAMEWORK_SETTINGS.node.options.useWebApi,
|
|
3958
3232
|
regions: config.regions,
|
|
3959
3233
|
memory: config.memory,
|
|
3960
3234
|
maxDuration: config.maxDuration,
|
|
@@ -3971,14 +3245,14 @@ async function createRenderNodeFunction(nodeVersion, entrypointDir, rootDir, ser
|
|
|
3971
3245
|
rootDir,
|
|
3972
3246
|
serverBuildPath,
|
|
3973
3247
|
serverEntryPoint,
|
|
3974
|
-
serverSourcePromise:
|
|
3248
|
+
serverSourcePromise: REMIX_FRAMEWORK_SETTINGS.node.serverSourcePromise,
|
|
3975
3249
|
sourceSearchValue: REMIX_FRAMEWORK_SETTINGS.sourceSearchValue
|
|
3976
3250
|
});
|
|
3977
3251
|
const trace = await (0, import_nft.nodeFileTrace)([handlerPath], {
|
|
3978
3252
|
base: rootDir,
|
|
3979
3253
|
processCwd: entrypointDir
|
|
3980
3254
|
});
|
|
3981
|
-
logNftWarnings(trace.warnings,
|
|
3255
|
+
logNftWarnings(trace.warnings, REMIX_FRAMEWORK_SETTINGS.node.traceWarningTag);
|
|
3982
3256
|
const files = await getFilesFromTrace({ fileList: trace.fileList, rootDir });
|
|
3983
3257
|
const fn = new import_build_utils3.NodejsLambda({
|
|
3984
3258
|
...COMMON_NODE_FUNCTION_OPTIONS,
|
|
@@ -3988,6 +3262,7 @@ async function createRenderNodeFunction(nodeVersion, entrypointDir, rootDir, ser
|
|
|
3988
3262
|
regions: config.regions,
|
|
3989
3263
|
memory: config.memory,
|
|
3990
3264
|
maxDuration: config.maxDuration,
|
|
3265
|
+
useWebApi: REMIX_FRAMEWORK_SETTINGS.node.options.useWebApi,
|
|
3991
3266
|
framework: {
|
|
3992
3267
|
slug: REMIX_FRAMEWORK_SETTINGS.slug,
|
|
3993
3268
|
version: frameworkVersion
|
|
@@ -4000,7 +3275,7 @@ async function createRenderEdgeFunction(entrypointDir, rootDir, serverBuildPath,
|
|
|
4000
3275
|
rootDir,
|
|
4001
3276
|
serverBuildPath,
|
|
4002
3277
|
serverEntryPoint,
|
|
4003
|
-
serverSourcePromise:
|
|
3278
|
+
serverSourcePromise: REMIX_FRAMEWORK_SETTINGS.edge.serverSourcePromise,
|
|
4004
3279
|
sourceSearchValue: REMIX_FRAMEWORK_SETTINGS.sourceSearchValue
|
|
4005
3280
|
});
|
|
4006
3281
|
const trace = await (0, import_nft.nodeFileTrace)([handlerPath], {
|
|
@@ -4009,7 +3284,7 @@ async function createRenderEdgeFunction(entrypointDir, rootDir, serverBuildPath,
|
|
|
4009
3284
|
conditions: EDGE_TRACE_CONDITIONS,
|
|
4010
3285
|
readFile: edgeReadFile
|
|
4011
3286
|
});
|
|
4012
|
-
logNftWarnings(trace.warnings,
|
|
3287
|
+
logNftWarnings(trace.warnings, REMIX_FRAMEWORK_SETTINGS.edge.traceWarningTag);
|
|
4013
3288
|
const files = await getFilesFromTrace({ fileList: trace.fileList, rootDir });
|
|
4014
3289
|
const fn = new import_build_utils3.EdgeFunction({
|
|
4015
3290
|
...COMMON_EDGE_FUNCTION_OPTIONS,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vercel/remix-builder",
|
|
3
|
-
"version": "5.2.
|
|
3
|
+
"version": "5.2.4",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"homepage": "https://vercel.com/docs",
|
|
@@ -18,14 +18,15 @@
|
|
|
18
18
|
"@vercel/error-utils": "2.0.3",
|
|
19
19
|
"@vercel/nft": "0.27.10",
|
|
20
20
|
"@vercel/static-config": "3.0.0",
|
|
21
|
+
"path-to-regexp-updated": "npm:path-to-regexp@6.3.0",
|
|
22
|
+
"path-to-regexp": "6.1.0",
|
|
21
23
|
"ts-morph": "12.0.0"
|
|
22
24
|
},
|
|
23
25
|
"devDependencies": {
|
|
24
26
|
"@types/jest": "27.5.1",
|
|
25
27
|
"@types/node": "14.18.33",
|
|
26
28
|
"@types/semver": "7.3.13",
|
|
27
|
-
"@vercel/build-utils": "9.2.
|
|
28
|
-
"@vercel-internals/path-to-regexp": "1.0.0",
|
|
29
|
+
"@vercel/build-utils": "9.2.1",
|
|
29
30
|
"glob": "10.3.16",
|
|
30
31
|
"jest-junit": "16.0.0",
|
|
31
32
|
"semver": "7.5.2",
|