webstudio 0.303.0 → 0.305.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/lib/cli.js CHANGED
@@ -52586,6 +52586,446 @@ const assetQueryResourceConfigurationPatchInput = strictObject({
52586
52586
  output: assetQueryResourceConfigurationInput.shape.output.removeDefault().optional(),
52587
52587
  content: assetQueryResourceConfigurationInput.shape.content.removeDefault().optional()
52588
52588
  });
52589
+ /**
52590
+ * @remix-run/router v1.23.0
52591
+ *
52592
+ * Copyright (c) Remix Software Inc.
52593
+ *
52594
+ * This source code is licensed under the MIT license found in the
52595
+ * LICENSE.md file in the root directory of this source tree.
52596
+ *
52597
+ * @license MIT
52598
+ */
52599
+ function _extends$3() {
52600
+ _extends$3 = Object.assign ? Object.assign.bind() : function(target) {
52601
+ for (var i = 1; i < arguments.length; i++) {
52602
+ var source = arguments[i];
52603
+ for (var key2 in source) {
52604
+ if (Object.prototype.hasOwnProperty.call(source, key2)) {
52605
+ target[key2] = source[key2];
52606
+ }
52607
+ }
52608
+ }
52609
+ return target;
52610
+ };
52611
+ return _extends$3.apply(this, arguments);
52612
+ }
52613
+ var Action;
52614
+ (function(Action2) {
52615
+ Action2["Pop"] = "POP";
52616
+ Action2["Push"] = "PUSH";
52617
+ Action2["Replace"] = "REPLACE";
52618
+ })(Action || (Action = {}));
52619
+ function invariant$2(value2, message) {
52620
+ if (value2 === false || value2 === null || typeof value2 === "undefined") {
52621
+ throw new Error(message);
52622
+ }
52623
+ }
52624
+ function warning$2(cond, message) {
52625
+ if (!cond) {
52626
+ if (typeof console !== "undefined") console.warn(message);
52627
+ try {
52628
+ throw new Error(message);
52629
+ } catch (e2) {
52630
+ }
52631
+ }
52632
+ }
52633
+ function createPath$1(_ref) {
52634
+ let {
52635
+ pathname = "/",
52636
+ search: search2 = "",
52637
+ hash: hash2 = ""
52638
+ } = _ref;
52639
+ if (search2 && search2 !== "?") pathname += search2.charAt(0) === "?" ? search2 : "?" + search2;
52640
+ if (hash2 && hash2 !== "#") pathname += hash2.charAt(0) === "#" ? hash2 : "#" + hash2;
52641
+ return pathname;
52642
+ }
52643
+ function parsePath$1(path2) {
52644
+ let parsedPath = {};
52645
+ if (path2) {
52646
+ let hashIndex = path2.indexOf("#");
52647
+ if (hashIndex >= 0) {
52648
+ parsedPath.hash = path2.substr(hashIndex);
52649
+ path2 = path2.substr(0, hashIndex);
52650
+ }
52651
+ let searchIndex = path2.indexOf("?");
52652
+ if (searchIndex >= 0) {
52653
+ parsedPath.search = path2.substr(searchIndex);
52654
+ path2 = path2.substr(0, searchIndex);
52655
+ }
52656
+ if (path2) {
52657
+ parsedPath.pathname = path2;
52658
+ }
52659
+ }
52660
+ return parsedPath;
52661
+ }
52662
+ var ResultType;
52663
+ (function(ResultType2) {
52664
+ ResultType2["data"] = "data";
52665
+ ResultType2["deferred"] = "deferred";
52666
+ ResultType2["redirect"] = "redirect";
52667
+ ResultType2["error"] = "error";
52668
+ })(ResultType || (ResultType = {}));
52669
+ function matchRoutes$1(routes, locationArg, basename2) {
52670
+ if (basename2 === void 0) {
52671
+ basename2 = "/";
52672
+ }
52673
+ return matchRoutesImpl$1(routes, locationArg, basename2);
52674
+ }
52675
+ function matchRoutesImpl$1(routes, locationArg, basename2, allowPartial) {
52676
+ let location = typeof locationArg === "string" ? parsePath$1(locationArg) : locationArg;
52677
+ let pathname = stripBasename$1(location.pathname || "/", basename2);
52678
+ if (pathname == null) {
52679
+ return null;
52680
+ }
52681
+ let branches = flattenRoutes$1(routes);
52682
+ rankRouteBranches$1(branches);
52683
+ let matches2 = null;
52684
+ for (let i = 0; matches2 == null && i < branches.length; ++i) {
52685
+ let decoded = decodePath$1(pathname);
52686
+ matches2 = matchRouteBranch$1(branches[i], decoded);
52687
+ }
52688
+ return matches2;
52689
+ }
52690
+ function convertRouteMatchToUiMatch$1(match, loaderData) {
52691
+ let {
52692
+ route,
52693
+ pathname,
52694
+ params
52695
+ } = match;
52696
+ return {
52697
+ id: route.id,
52698
+ pathname,
52699
+ params,
52700
+ data: loaderData[route.id],
52701
+ handle: route.handle
52702
+ };
52703
+ }
52704
+ function flattenRoutes$1(routes, branches, parentsMeta, parentPath) {
52705
+ if (branches === void 0) {
52706
+ branches = [];
52707
+ }
52708
+ if (parentsMeta === void 0) {
52709
+ parentsMeta = [];
52710
+ }
52711
+ if (parentPath === void 0) {
52712
+ parentPath = "";
52713
+ }
52714
+ let flattenRoute = (route, index2, relativePath) => {
52715
+ let meta2 = {
52716
+ relativePath: relativePath === void 0 ? route.path || "" : relativePath,
52717
+ caseSensitive: route.caseSensitive === true,
52718
+ childrenIndex: index2,
52719
+ route
52720
+ };
52721
+ if (meta2.relativePath.startsWith("/")) {
52722
+ invariant$2(meta2.relativePath.startsWith(parentPath), 'Absolute route path "' + meta2.relativePath + '" nested under path ' + ('"' + parentPath + '" is not valid. An absolute child route path ') + "must start with the combined path of all its parent routes.");
52723
+ meta2.relativePath = meta2.relativePath.slice(parentPath.length);
52724
+ }
52725
+ let path2 = joinPaths$1([parentPath, meta2.relativePath]);
52726
+ let routesMeta = parentsMeta.concat(meta2);
52727
+ if (route.children && route.children.length > 0) {
52728
+ invariant$2(
52729
+ // Our types know better, but runtime JS may not!
52730
+ // @ts-expect-error
52731
+ route.index !== true,
52732
+ "Index routes must not have child routes. Please remove " + ('all child routes from route path "' + path2 + '".')
52733
+ );
52734
+ flattenRoutes$1(route.children, branches, routesMeta, path2);
52735
+ }
52736
+ if (route.path == null && !route.index) {
52737
+ return;
52738
+ }
52739
+ branches.push({
52740
+ path: path2,
52741
+ score: computeScore$1(path2, route.index),
52742
+ routesMeta
52743
+ });
52744
+ };
52745
+ routes.forEach((route, index2) => {
52746
+ var _route$path;
52747
+ if (route.path === "" || !((_route$path = route.path) != null && _route$path.includes("?"))) {
52748
+ flattenRoute(route, index2);
52749
+ } else {
52750
+ for (let exploded of explodeOptionalSegments$1(route.path)) {
52751
+ flattenRoute(route, index2, exploded);
52752
+ }
52753
+ }
52754
+ });
52755
+ return branches;
52756
+ }
52757
+ function explodeOptionalSegments$1(path2) {
52758
+ let segments = path2.split("/");
52759
+ if (segments.length === 0) return [];
52760
+ let [first, ...rest] = segments;
52761
+ let isOptional = first.endsWith("?");
52762
+ let required2 = first.replace(/\?$/, "");
52763
+ if (rest.length === 0) {
52764
+ return isOptional ? [required2, ""] : [required2];
52765
+ }
52766
+ let restExploded = explodeOptionalSegments$1(rest.join("/"));
52767
+ let result2 = [];
52768
+ result2.push(...restExploded.map((subpath) => subpath === "" ? required2 : [required2, subpath].join("/")));
52769
+ if (isOptional) {
52770
+ result2.push(...restExploded);
52771
+ }
52772
+ return result2.map((exploded) => path2.startsWith("/") && exploded === "" ? "/" : exploded);
52773
+ }
52774
+ function rankRouteBranches$1(branches) {
52775
+ branches.sort((a2, b2) => a2.score !== b2.score ? b2.score - a2.score : compareIndexes$1(a2.routesMeta.map((meta2) => meta2.childrenIndex), b2.routesMeta.map((meta2) => meta2.childrenIndex)));
52776
+ }
52777
+ const paramRe$1 = /^:[\w-]+$/;
52778
+ const dynamicSegmentValue$1 = 3;
52779
+ const indexRouteValue$1 = 2;
52780
+ const emptySegmentValue$1 = 1;
52781
+ const staticSegmentValue$1 = 10;
52782
+ const splatPenalty$1 = -2;
52783
+ const isSplat$1 = (s2) => s2 === "*";
52784
+ function computeScore$1(path2, index2) {
52785
+ let segments = path2.split("/");
52786
+ let initialScore = segments.length;
52787
+ if (segments.some(isSplat$1)) {
52788
+ initialScore += splatPenalty$1;
52789
+ }
52790
+ if (index2) {
52791
+ initialScore += indexRouteValue$1;
52792
+ }
52793
+ return segments.filter((s2) => !isSplat$1(s2)).reduce((score, segment) => score + (paramRe$1.test(segment) ? dynamicSegmentValue$1 : segment === "" ? emptySegmentValue$1 : staticSegmentValue$1), initialScore);
52794
+ }
52795
+ function compareIndexes$1(a2, b2) {
52796
+ let siblings2 = a2.length === b2.length && a2.slice(0, -1).every((n2, i) => n2 === b2[i]);
52797
+ return siblings2 ? (
52798
+ // If two routes are siblings, we should try to match the earlier sibling
52799
+ // first. This allows people to have fine-grained control over the matching
52800
+ // behavior by simply putting routes with identical paths in the order they
52801
+ // want them tried.
52802
+ a2[a2.length - 1] - b2[b2.length - 1]
52803
+ ) : (
52804
+ // Otherwise, it doesn't really make sense to rank non-siblings by index,
52805
+ // so they sort equally.
52806
+ 0
52807
+ );
52808
+ }
52809
+ function matchRouteBranch$1(branch, pathname, allowPartial) {
52810
+ let {
52811
+ routesMeta
52812
+ } = branch;
52813
+ let matchedParams = {};
52814
+ let matchedPathname = "/";
52815
+ let matches2 = [];
52816
+ for (let i = 0; i < routesMeta.length; ++i) {
52817
+ let meta2 = routesMeta[i];
52818
+ let end = i === routesMeta.length - 1;
52819
+ let remainingPathname = matchedPathname === "/" ? pathname : pathname.slice(matchedPathname.length) || "/";
52820
+ let match = matchPath$1({
52821
+ path: meta2.relativePath,
52822
+ caseSensitive: meta2.caseSensitive,
52823
+ end
52824
+ }, remainingPathname);
52825
+ let route = meta2.route;
52826
+ if (!match) {
52827
+ return null;
52828
+ }
52829
+ Object.assign(matchedParams, match.params);
52830
+ matches2.push({
52831
+ // TODO: Can this as be avoided?
52832
+ params: matchedParams,
52833
+ pathname: joinPaths$1([matchedPathname, match.pathname]),
52834
+ pathnameBase: normalizePathname$1(joinPaths$1([matchedPathname, match.pathnameBase])),
52835
+ route
52836
+ });
52837
+ if (match.pathnameBase !== "/") {
52838
+ matchedPathname = joinPaths$1([matchedPathname, match.pathnameBase]);
52839
+ }
52840
+ }
52841
+ return matches2;
52842
+ }
52843
+ function matchPath$1(pattern, pathname) {
52844
+ if (typeof pattern === "string") {
52845
+ pattern = {
52846
+ path: pattern,
52847
+ caseSensitive: false,
52848
+ end: true
52849
+ };
52850
+ }
52851
+ let [matcher, compiledParams] = compilePath$1(pattern.path, pattern.caseSensitive, pattern.end);
52852
+ let match = pathname.match(matcher);
52853
+ if (!match) return null;
52854
+ let matchedPathname = match[0];
52855
+ let pathnameBase = matchedPathname.replace(/(.)\/+$/, "$1");
52856
+ let captureGroups = match.slice(1);
52857
+ let params = compiledParams.reduce((memo, _ref, index2) => {
52858
+ let {
52859
+ paramName,
52860
+ isOptional
52861
+ } = _ref;
52862
+ if (paramName === "*") {
52863
+ let splatValue = captureGroups[index2] || "";
52864
+ pathnameBase = matchedPathname.slice(0, matchedPathname.length - splatValue.length).replace(/(.)\/+$/, "$1");
52865
+ }
52866
+ const value2 = captureGroups[index2];
52867
+ if (isOptional && !value2) {
52868
+ memo[paramName] = void 0;
52869
+ } else {
52870
+ memo[paramName] = (value2 || "").replace(/%2F/g, "/");
52871
+ }
52872
+ return memo;
52873
+ }, {});
52874
+ return {
52875
+ params,
52876
+ pathname: matchedPathname,
52877
+ pathnameBase,
52878
+ pattern
52879
+ };
52880
+ }
52881
+ function compilePath$1(path2, caseSensitive, end) {
52882
+ if (caseSensitive === void 0) {
52883
+ caseSensitive = false;
52884
+ }
52885
+ if (end === void 0) {
52886
+ end = true;
52887
+ }
52888
+ warning$2(path2 === "*" || !path2.endsWith("*") || path2.endsWith("/*"), 'Route path "' + path2 + '" will be treated as if it were ' + ('"' + path2.replace(/\*$/, "/*") + '" because the `*` character must ') + "always follow a `/` in the pattern. To get rid of this warning, " + ('please change the route path to "' + path2.replace(/\*$/, "/*") + '".'));
52889
+ let params = [];
52890
+ let regexpSource = "^" + path2.replace(/\/*\*?$/, "").replace(/^\/*/, "/").replace(/[\\.*+^${}|()[\]]/g, "\\$&").replace(/\/:([\w-]+)(\?)?/g, (_2, paramName, isOptional) => {
52891
+ params.push({
52892
+ paramName,
52893
+ isOptional: isOptional != null
52894
+ });
52895
+ return isOptional ? "/?([^\\/]+)?" : "/([^\\/]+)";
52896
+ });
52897
+ if (path2.endsWith("*")) {
52898
+ params.push({
52899
+ paramName: "*"
52900
+ });
52901
+ regexpSource += path2 === "*" || path2 === "/*" ? "(.*)$" : "(?:\\/(.+)|\\/*)$";
52902
+ } else if (end) {
52903
+ regexpSource += "\\/*$";
52904
+ } else if (path2 !== "" && path2 !== "/") {
52905
+ regexpSource += "(?:(?=\\/|$))";
52906
+ } else ;
52907
+ let matcher = new RegExp(regexpSource, caseSensitive ? void 0 : "i");
52908
+ return [matcher, params];
52909
+ }
52910
+ function decodePath$1(value2) {
52911
+ try {
52912
+ return value2.split("/").map((v2) => decodeURIComponent(v2).replace(/\//g, "%2F")).join("/");
52913
+ } catch (error) {
52914
+ warning$2(false, 'The URL path "' + value2 + '" could not be decoded because it is is a malformed URL segment. This is probably due to a bad percent ' + ("encoding (" + error + ")."));
52915
+ return value2;
52916
+ }
52917
+ }
52918
+ function stripBasename$1(pathname, basename2) {
52919
+ if (basename2 === "/") return pathname;
52920
+ if (!pathname.toLowerCase().startsWith(basename2.toLowerCase())) {
52921
+ return null;
52922
+ }
52923
+ let startIndex = basename2.endsWith("/") ? basename2.length - 1 : basename2.length;
52924
+ let nextChar = pathname.charAt(startIndex);
52925
+ if (nextChar && nextChar !== "/") {
52926
+ return null;
52927
+ }
52928
+ return pathname.slice(startIndex) || "/";
52929
+ }
52930
+ function resolvePath$1(to2, fromPathname) {
52931
+ if (fromPathname === void 0) {
52932
+ fromPathname = "/";
52933
+ }
52934
+ let {
52935
+ pathname: toPathname,
52936
+ search: search2 = "",
52937
+ hash: hash2 = ""
52938
+ } = typeof to2 === "string" ? parsePath$1(to2) : to2;
52939
+ let pathname = toPathname ? toPathname.startsWith("/") ? toPathname : resolvePathname$1(toPathname, fromPathname) : fromPathname;
52940
+ return {
52941
+ pathname,
52942
+ search: normalizeSearch$1(search2),
52943
+ hash: normalizeHash$1(hash2)
52944
+ };
52945
+ }
52946
+ function resolvePathname$1(relativePath, fromPathname) {
52947
+ let segments = fromPathname.replace(/\/+$/, "").split("/");
52948
+ let relativeSegments = relativePath.split("/");
52949
+ relativeSegments.forEach((segment) => {
52950
+ if (segment === "..") {
52951
+ if (segments.length > 1) segments.pop();
52952
+ } else if (segment !== ".") {
52953
+ segments.push(segment);
52954
+ }
52955
+ });
52956
+ return segments.length > 1 ? segments.join("/") : "/";
52957
+ }
52958
+ function getInvalidPathError$1(char, field, dest, path2) {
52959
+ return "Cannot include a '" + char + "' character in a manually specified " + ("`to." + field + "` field [" + JSON.stringify(path2) + "]. Please separate it out to the ") + ("`to." + dest + "` field. Alternatively you may provide the full path as ") + 'a string in <Link to="..."> and the router will parse it for you.';
52960
+ }
52961
+ function getPathContributingMatches$1(matches2) {
52962
+ return matches2.filter((match, index2) => index2 === 0 || match.route.path && match.route.path.length > 0);
52963
+ }
52964
+ function getResolveToMatches$1(matches2, v7_relativeSplatPath) {
52965
+ let pathMatches = getPathContributingMatches$1(matches2);
52966
+ if (v7_relativeSplatPath) {
52967
+ return pathMatches.map((match, idx) => idx === pathMatches.length - 1 ? match.pathname : match.pathnameBase);
52968
+ }
52969
+ return pathMatches.map((match) => match.pathnameBase);
52970
+ }
52971
+ function resolveTo$1(toArg, routePathnames, locationPathname, isPathRelative) {
52972
+ if (isPathRelative === void 0) {
52973
+ isPathRelative = false;
52974
+ }
52975
+ let to2;
52976
+ if (typeof toArg === "string") {
52977
+ to2 = parsePath$1(toArg);
52978
+ } else {
52979
+ to2 = _extends$3({}, toArg);
52980
+ invariant$2(!to2.pathname || !to2.pathname.includes("?"), getInvalidPathError$1("?", "pathname", "search", to2));
52981
+ invariant$2(!to2.pathname || !to2.pathname.includes("#"), getInvalidPathError$1("#", "pathname", "hash", to2));
52982
+ invariant$2(!to2.search || !to2.search.includes("#"), getInvalidPathError$1("#", "search", "hash", to2));
52983
+ }
52984
+ let isEmptyPath2 = toArg === "" || to2.pathname === "";
52985
+ let toPathname = isEmptyPath2 ? "/" : to2.pathname;
52986
+ let from;
52987
+ if (toPathname == null) {
52988
+ from = locationPathname;
52989
+ } else {
52990
+ let routePathnameIndex = routePathnames.length - 1;
52991
+ if (!isPathRelative && toPathname.startsWith("..")) {
52992
+ let toSegments = toPathname.split("/");
52993
+ while (toSegments[0] === "..") {
52994
+ toSegments.shift();
52995
+ routePathnameIndex -= 1;
52996
+ }
52997
+ to2.pathname = toSegments.join("/");
52998
+ }
52999
+ from = routePathnameIndex >= 0 ? routePathnames[routePathnameIndex] : "/";
53000
+ }
53001
+ let path2 = resolvePath$1(to2, from);
53002
+ let hasExplicitTrailingSlash = toPathname && toPathname !== "/" && toPathname.endsWith("/");
53003
+ let hasCurrentTrailingSlash = (isEmptyPath2 || toPathname === ".") && locationPathname.endsWith("/");
53004
+ if (!path2.pathname.endsWith("/") && (hasExplicitTrailingSlash || hasCurrentTrailingSlash)) {
53005
+ path2.pathname += "/";
53006
+ }
53007
+ return path2;
53008
+ }
53009
+ const joinPaths$1 = (paths) => paths.join("/").replace(/\/\/+/g, "/");
53010
+ const normalizePathname$1 = (pathname) => pathname.replace(/\/+$/, "").replace(/^\/*/, "/");
53011
+ const normalizeSearch$1 = (search2) => !search2 || search2 === "?" ? "" : search2.startsWith("?") ? search2 : "?" + search2;
53012
+ const normalizeHash$1 = (hash2) => !hash2 || hash2 === "#" ? "" : hash2.startsWith("#") ? hash2 : "#" + hash2;
53013
+ class AbortedDeferredError extends Error {
53014
+ }
53015
+ const validMutationMethodsArr$1 = ["post", "put", "patch", "delete"];
53016
+ new Set(validMutationMethodsArr$1);
53017
+ const validRequestMethodsArr$1 = ["get", ...validMutationMethodsArr$1];
53018
+ new Set(validRequestMethodsArr$1);
53019
+ const IDLE_FETCHER$1 = {
53020
+ state: "idle",
53021
+ data: void 0,
53022
+ formMethod: void 0,
53023
+ formAction: void 0,
53024
+ formEncType: void 0,
53025
+ formData: void 0,
53026
+ json: void 0,
53027
+ text: void 0
53028
+ };
52589
53029
  const basicLoginErrors = (login) => {
52590
53030
  const issues = [];
52591
53031
  if (login.length === 0) {
@@ -52677,6 +53117,22 @@ const isRecord$1 = (value2) => {
52677
53117
  return typeof value2 === "object" && value2 !== null && Array.isArray(value2) === false;
52678
53118
  };
52679
53119
  const parameterSegment = /^:\w+[?*]?$/;
53120
+ const decodeStaticSegment = (segment) => {
53121
+ if (segment.includes("%") === false) {
53122
+ return { path: segment };
53123
+ }
53124
+ try {
53125
+ const decoded = decodeURIComponent(segment);
53126
+ return {
53127
+ // Remix decodes request paths; keep encoded slashes within one segment.
53128
+ path: decoded.replaceAll("/", "%2F"),
53129
+ // These were valid literal segments before route matching used Remix.
53130
+ literal: decoded.startsWith(":") || /[?*%]/.test(decoded)
53131
+ };
53132
+ } catch {
53133
+ return { path: segment, literal: true };
53134
+ }
53135
+ };
52680
53136
  const validatePathnamePattern$1 = (route) => {
52681
53137
  if (route.startsWith("/") === false) {
52682
53138
  return 'Route must start with "/"';
@@ -52684,7 +53140,7 @@ const validatePathnamePattern$1 = (route) => {
52684
53140
  if (route === "/") {
52685
53141
  return;
52686
53142
  }
52687
- if (route !== "/" && route.endsWith("/")) {
53143
+ if (route.endsWith("/")) {
52688
53144
  return 'Route must not end with "/"';
52689
53145
  }
52690
53146
  if (route.includes("//")) {
@@ -52705,6 +53161,9 @@ const validatePathnamePattern$1 = (route) => {
52705
53161
  if (segment.startsWith(":") && parameterSegment.test(segment) === false) {
52706
53162
  return `Invalid route parameter "${segment}"`;
52707
53163
  }
53164
+ if (segment.includes("?") && parameterSegment.test(segment) === false) {
53165
+ return 'Optional marker "?" is only allowed on a named parameter';
53166
+ }
52708
53167
  if (segment.includes("*")) {
52709
53168
  return "Wildcard can only be used as * or :name*";
52710
53169
  }
@@ -52863,38 +53322,75 @@ const createWsAuthResources = ({
52863
53322
  ].join("\n")
52864
53323
  };
52865
53324
  };
52866
- const normalizePathname$2 = (pathname) => {
52867
- if (pathname === "" || pathname === "/") {
52868
- return "/";
52869
- }
52870
- return pathname.endsWith("/") ? pathname.slice(0, -1) : pathname;
52871
- };
52872
- const matchesPathnamePattern = (route, pathname) => {
52873
- const routeSegments = normalizePathname$2(route).slice(1).split("/");
52874
- const pathnameSegments = normalizePathname$2(pathname).slice(1).split("/");
52875
- const matchSegments = (routeIndex, pathnameIndex) => {
52876
- const routeSegment = routeSegments[routeIndex];
52877
- const pathnameSegment = pathnameSegments[pathnameIndex];
52878
- if (routeSegment === void 0) {
52879
- return pathnameSegment === void 0;
52880
- }
52881
- if (routeSegment === "*" || /^:\w+\*$/.test(routeSegment)) {
52882
- return routeIndex === routeSegments.length - 1;
53325
+ const toRouterPattern = (pattern, literals, decodedPathname) => {
53326
+ const segments = [];
53327
+ for (const segment of (pattern || "/").replace(/:\w+\*$/, "*").split("/")) {
53328
+ if (segment === "*" || segment.startsWith(":")) {
53329
+ segments.push(segment);
53330
+ continue;
52883
53331
  }
52884
- if (/^:\w+\?$/.test(routeSegment)) {
52885
- return matchSegments(routeIndex + 1, pathnameIndex) || pathnameSegment !== void 0 && matchSegments(routeIndex + 1, pathnameIndex + 1);
53332
+ const decoded = decodeStaticSegment(segment);
53333
+ if (decoded.literal) {
53334
+ let marker = literals.get(segment);
53335
+ if (marker === void 0) {
53336
+ let index2 = literals.size;
53337
+ marker = `\0${index2}\0`;
53338
+ while (decodedPathname.includes(marker) || Array.from(literals.values()).includes(marker)) {
53339
+ index2 += 1;
53340
+ marker = `\0${index2}\0`;
53341
+ }
53342
+ literals.set(segment, marker);
53343
+ }
53344
+ segments.push(marker);
53345
+ continue;
52886
53346
  }
52887
- if (pathnameSegment === void 0) {
52888
- return false;
53347
+ segments.push(decoded.path);
53348
+ }
53349
+ return segments.join("/");
53350
+ };
53351
+ const matchPathnameRoutes = (routes, pathname) => {
53352
+ const literals = /* @__PURE__ */ new Map();
53353
+ const decodedPathname = pathname.split("/").map((segment) => {
53354
+ try {
53355
+ return decodeURIComponent(segment);
53356
+ } catch {
53357
+ return segment;
52889
53358
  }
52890
- if (/^:\w+$/.test(routeSegment)) {
52891
- return matchSegments(routeIndex + 1, pathnameIndex + 1);
53359
+ }).join("/");
53360
+ const routerRoutes = routes.map((route) => ({
53361
+ path: toRouterPattern(route.pattern, literals, decodedPathname),
53362
+ caseSensitive: false,
53363
+ source: route
53364
+ }));
53365
+ const decodedLiterals = Array.from(literals, ([literal2, marker]) => {
53366
+ try {
53367
+ return [marker, decodeURIComponent(literal2)];
53368
+ } catch {
53369
+ return [marker, literal2];
52892
53370
  }
52893
- return routeSegment === pathnameSegment && matchSegments(routeIndex + 1, pathnameIndex + 1);
53371
+ });
53372
+ const routerPathname = pathname.split("/").map((segment) => literals.get(segment) ?? segment).join("/");
53373
+ const match = matchRoutes$1(routerRoutes, routerPathname)?.at(-1);
53374
+ if (match === void 0) {
53375
+ return;
53376
+ }
53377
+ return {
53378
+ value: match.route.source.value,
53379
+ params: Object.fromEntries(
53380
+ Object.entries(match.params).map(([name2, value2]) => [
53381
+ name2,
53382
+ value2 === void 0 ? value2 : decodedLiterals.reduce(
53383
+ (result2, [marker, literal2]) => result2.replaceAll(marker, literal2),
53384
+ value2
53385
+ )
53386
+ ])
53387
+ )
52894
53388
  };
52895
- return matchSegments(0, 0);
52896
53389
  };
52897
- const findWsAuthRoute = (authRoutes, pathname) => authRoutes.find(({ route }) => matchesPathnamePattern(route, pathname));
53390
+ const matchPathnamePattern = (pattern, pathname) => matchPathnameRoutes([{ pattern, value: true }], pathname)?.params;
53391
+ const findWsAuthRoute = (authRoutes, pathname) => authRoutes.find(
53392
+ ({ route }) => matchPathnamePattern(route, pathname) !== void 0
53393
+ );
52898
53394
  const platformHeaderNames = /* @__PURE__ */ new Set([
52899
53395
  "x-powered-by",
52900
53396
  "x-content-type-options",
@@ -59876,12 +60372,29 @@ const diagnosticContext = {
59876
60372
  renderScope: string$5().min(1).optional(),
59877
60373
  sourceRange: contentBlockSourceRange.optional()
59878
60374
  };
60375
+ const invalidMdxDiagnosticReason = _enum([
60376
+ // The MDX source was identified, but reading it from asset storage failed.
60377
+ "source-read-failed",
60378
+ // The MDX document exists, but its revision, content reference, or source text is unavailable.
60379
+ "missing-source",
60380
+ // No MDX document in the publication artifact matches the requested asset ID.
60381
+ "missing-asset",
60382
+ // A document referenced from MDX frontmatter could not be loaded or resolved.
60383
+ "linked-document-unavailable",
60384
+ // The rendered MDX violates HTML nesting rules, such as a link inside a link.
60385
+ "html-content-model",
60386
+ // Dynamic MDX contains Resources that cannot be selected safely for a Collection item or action.
60387
+ "dynamic-resource",
60388
+ // A dynamic source has no known candidates or exceeds the supported candidate limit.
60389
+ "dynamic-source-unbounded"
60390
+ ]);
59879
60391
  const contentBlockDiagnostic = discriminatedUnion("code", [
59880
60392
  strictObject({
59881
60393
  ...diagnosticContext,
59882
60394
  code: literal$2("invalid-mdx"),
59883
60395
  severity: literal$2("error"),
59884
- message: string$5().min(1)
60396
+ message: string$5().min(1),
60397
+ reason: invalidMdxDiagnosticReason.optional()
59885
60398
  }),
59886
60399
  strictObject({
59887
60400
  ...diagnosticContext,
@@ -63515,6 +64028,18 @@ const runtimeOperationContractData = [
63515
64028
  message: {
63516
64029
  type: "string",
63517
64030
  minLength: 1
64031
+ },
64032
+ reason: {
64033
+ type: "string",
64034
+ enum: [
64035
+ "source-read-failed",
64036
+ "missing-source",
64037
+ "missing-asset",
64038
+ "linked-document-unavailable",
64039
+ "html-content-model",
64040
+ "dynamic-resource",
64041
+ "dynamic-source-unbounded"
64042
+ ]
63518
64043
  }
63519
64044
  },
63520
64045
  required: ["blockInstanceId", "code", "severity", "message"],
@@ -64093,6 +64618,18 @@ const runtimeOperationContractData = [
64093
64618
  message: {
64094
64619
  type: "string",
64095
64620
  minLength: 1
64621
+ },
64622
+ reason: {
64623
+ type: "string",
64624
+ enum: [
64625
+ "source-read-failed",
64626
+ "missing-source",
64627
+ "missing-asset",
64628
+ "linked-document-unavailable",
64629
+ "html-content-model",
64630
+ "dynamic-resource",
64631
+ "dynamic-source-unbounded"
64632
+ ]
64096
64633
  }
64097
64634
  },
64098
64635
  required: ["blockInstanceId", "code", "severity", "message"],
@@ -64690,6 +65227,18 @@ const runtimeOperationContractData = [
64690
65227
  message: {
64691
65228
  type: "string",
64692
65229
  minLength: 1
65230
+ },
65231
+ reason: {
65232
+ type: "string",
65233
+ enum: [
65234
+ "source-read-failed",
65235
+ "missing-source",
65236
+ "missing-asset",
65237
+ "linked-document-unavailable",
65238
+ "html-content-model",
65239
+ "dynamic-resource",
65240
+ "dynamic-source-unbounded"
65241
+ ]
64693
65242
  }
64694
65243
  },
64695
65244
  required: ["blockInstanceId", "code", "severity", "message"],
@@ -65253,6 +65802,18 @@ const runtimeOperationContractData = [
65253
65802
  message: {
65254
65803
  type: "string",
65255
65804
  minLength: 1
65805
+ },
65806
+ reason: {
65807
+ type: "string",
65808
+ enum: [
65809
+ "source-read-failed",
65810
+ "missing-source",
65811
+ "missing-asset",
65812
+ "linked-document-unavailable",
65813
+ "html-content-model",
65814
+ "dynamic-resource",
65815
+ "dynamic-source-unbounded"
65816
+ ]
65256
65817
  }
65257
65818
  },
65258
65819
  required: ["blockInstanceId", "code", "severity", "message"],
@@ -65822,6 +66383,18 @@ const runtimeOperationContractData = [
65822
66383
  message: {
65823
66384
  type: "string",
65824
66385
  minLength: 1
66386
+ },
66387
+ reason: {
66388
+ type: "string",
66389
+ enum: [
66390
+ "source-read-failed",
66391
+ "missing-source",
66392
+ "missing-asset",
66393
+ "linked-document-unavailable",
66394
+ "html-content-model",
66395
+ "dynamic-resource",
66396
+ "dynamic-source-unbounded"
66397
+ ]
65825
66398
  }
65826
66399
  },
65827
66400
  required: ["blockInstanceId", "code", "severity", "message"],
@@ -66373,6 +66946,18 @@ const runtimeOperationContractData = [
66373
66946
  message: {
66374
66947
  type: "string",
66375
66948
  minLength: 1
66949
+ },
66950
+ reason: {
66951
+ type: "string",
66952
+ enum: [
66953
+ "source-read-failed",
66954
+ "missing-source",
66955
+ "missing-asset",
66956
+ "linked-document-unavailable",
66957
+ "html-content-model",
66958
+ "dynamic-resource",
66959
+ "dynamic-source-unbounded"
66960
+ ]
66376
66961
  }
66377
66962
  },
66378
66963
  required: ["blockInstanceId", "code", "severity", "message"],
@@ -66917,6 +67502,18 @@ const runtimeOperationContractData = [
66917
67502
  message: {
66918
67503
  type: "string",
66919
67504
  minLength: 1
67505
+ },
67506
+ reason: {
67507
+ type: "string",
67508
+ enum: [
67509
+ "source-read-failed",
67510
+ "missing-source",
67511
+ "missing-asset",
67512
+ "linked-document-unavailable",
67513
+ "html-content-model",
67514
+ "dynamic-resource",
67515
+ "dynamic-source-unbounded"
67516
+ ]
66920
67517
  }
66921
67518
  },
66922
67519
  required: ["blockInstanceId", "code", "severity", "message"],
@@ -114137,6 +114734,18 @@ const runtimeOperationContractData = [
114137
114734
  message: {
114138
114735
  type: "string",
114139
114736
  minLength: 1
114737
+ },
114738
+ reason: {
114739
+ type: "string",
114740
+ enum: [
114741
+ "source-read-failed",
114742
+ "missing-source",
114743
+ "missing-asset",
114744
+ "linked-document-unavailable",
114745
+ "html-content-model",
114746
+ "dynamic-resource",
114747
+ "dynamic-source-unbounded"
114748
+ ]
114140
114749
  }
114141
114750
  },
114142
114751
  required: ["blockInstanceId", "code", "severity", "message"],
@@ -188102,29 +188711,41 @@ const findVariablesByInstanceId = ({
188102
188711
  }
188103
188712
  return { maskedIdByName, availableDataSourceIds };
188104
188713
  };
188714
+ const createFindAvailableVariables = ({
188715
+ instances,
188716
+ dataSources
188717
+ }) => {
188718
+ const parentInstanceById = getParentInstanceById(instances);
188719
+ const dataSourcesByScopeInstanceId = getDataSourcesByScopeInstanceId(dataSources);
188720
+ return (startingInstanceId) => {
188721
+ const { maskedIdByName } = findVariablesByInstanceId({
188722
+ startingInstanceId,
188723
+ parentInstanceById,
188724
+ instances,
188725
+ dataSources,
188726
+ dataSourcesByScopeInstanceId
188727
+ });
188728
+ const availableVariables = [];
188729
+ for (const dataSourceId2 of maskedIdByName.values()) {
188730
+ const dataSource2 = dataSources.get(dataSourceId2);
188731
+ if (dataSource2) {
188732
+ availableVariables.push(dataSource2);
188733
+ }
188734
+ if (dataSourceId2 === SYSTEM_VARIABLE_ID) {
188735
+ availableVariables.push(systemParameter);
188736
+ }
188737
+ }
188738
+ return availableVariables;
188739
+ };
188740
+ };
188105
188741
  const findAvailableVariables = ({
188106
188742
  startingInstanceId,
188107
188743
  instances,
188108
188744
  dataSources
188109
188745
  }) => {
188110
- const { maskedIdByName } = findVariablesByInstanceId({
188111
- startingInstanceId,
188112
- parentInstanceById: getParentInstanceById(instances),
188113
- instances,
188114
- dataSources,
188115
- dataSourcesByScopeInstanceId: getDataSourcesByScopeInstanceId(dataSources)
188116
- });
188117
- const availableVariables = [];
188118
- for (const dataSourceId2 of maskedIdByName.values()) {
188119
- const dataSource2 = dataSources.get(dataSourceId2);
188120
- if (dataSource2) {
188121
- availableVariables.push(dataSource2);
188122
- }
188123
- if (dataSourceId2 === SYSTEM_VARIABLE_ID) {
188124
- availableVariables.push(systemParameter);
188125
- }
188126
- }
188127
- return availableVariables;
188746
+ return createFindAvailableVariables({ instances, dataSources })(
188747
+ startingInstanceId
188748
+ );
188128
188749
  };
188129
188750
  const bindExpressionToInstanceScope = ({
188130
188751
  expression: expression2,
@@ -200509,35 +201130,13 @@ const getSerializedPagePath = (pages2, page2) => joinPath$1(
200509
201130
  page2.path
200510
201131
  );
200511
201132
  const normalizeSerializedPagePath = (path2) => path2 === "/" ? "" : path2;
200512
- const escapeRegExp = (value2) => value2.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
200513
- const isSerializedPagePathMatch = (pattern, path2) => {
200514
- if (pattern === path2) {
200515
- return true;
200516
- }
200517
- const segments = pattern.split("/");
200518
- const pathSegments = path2.split("/");
200519
- const regexParts = segments.map((segment, index2) => {
200520
- if (segment === "*") {
200521
- return index2 === segments.length - 1 ? ".*" : "[^/]+";
200522
- }
200523
- const param = segment.match(/^:(\w+)([?*]?)$/);
200524
- if (param === null) {
200525
- return escapeRegExp(segment);
200526
- }
200527
- const modifier = param[2];
200528
- if (modifier === "?") {
200529
- return "[^/]*";
200530
- }
200531
- if (modifier === "*") {
200532
- return index2 === segments.length - 1 ? ".*" : "[^/]+";
200533
- }
200534
- return "[^/]+";
200535
- });
200536
- if (segments.length !== pathSegments.length && pattern.endsWith("*") === false) {
200537
- return false;
200538
- }
200539
- return new RegExp(`^${regexParts.join("/")}$`).test(path2);
200540
- };
201133
+ const findMatchingSerializedPageByPath = (pages2, path2) => matchPathnameRoutes(
201134
+ pages2.pages.map((page2) => ({
201135
+ pattern: getSerializedPagePath(pages2, page2),
201136
+ value: page2
201137
+ })),
201138
+ normalizeSerializedPagePath(path2)
201139
+ )?.value;
200541
201140
  const serializePageSummary = (pages2, page2) => ({
200542
201141
  id: page2.id,
200543
201142
  name: page2.name,
@@ -200574,9 +201173,7 @@ const findSerializedPageByInput = (pages2, input2) => {
200574
201173
  const exactPage = pages2.pages.find(
200575
201174
  (page2) => getSerializedPagePath(pages2, page2) === pagePath2
200576
201175
  );
200577
- return exactPage ?? pages2.pages.find(
200578
- (page2) => isSerializedPagePathMatch(getSerializedPagePath(pages2, page2), pagePath2)
200579
- );
201176
+ return exactPage ?? findMatchingSerializedPageByPath(pages2, pagePath2);
200580
201177
  }
200581
201178
  };
200582
201179
  const findExactSerializedPageByPath = (pages2, path2) => {
@@ -200585,12 +201182,6 @@ const findExactSerializedPageByPath = (pages2, path2) => {
200585
201182
  (page2) => getSerializedPagePath(pages2, page2) === pagePath2
200586
201183
  );
200587
201184
  };
200588
- const findMatchingSerializedPageByPath = (pages2, path2) => {
200589
- const pagePath2 = normalizeSerializedPagePath(path2);
200590
- return pages2.pages.find(
200591
- (page2) => isSerializedPagePathMatch(getSerializedPagePath(pages2, page2), pagePath2)
200592
- );
200593
- };
200594
201185
  const isSerializedFallbackPage = (pages2, page2) => {
200595
201186
  const path2 = getSerializedPagePath(pages2, page2);
200596
201187
  return page2.meta.status === "404" || path2 === "/*" || path2 === "*";
@@ -205275,31 +205866,7 @@ const generateRemixRoute = (pathname) => {
205275
205866
  const tail = pathname.endsWith("*") ? "" : "._index";
205276
205867
  return `${base2}${tail}`;
205277
205868
  };
205278
- const generateRemixParams = (pathname) => {
205279
- const name2 = pathname.match(/:(?<name>\w+)\*$/)?.groups?.name;
205280
- let generated2 = "";
205281
- generated2 += `type Params = Record<string, string | undefined>;
205282
- `;
205283
- generated2 += `export const getRemixParams = ({ ...params }: Params): Params => {
205284
- `;
205285
- if (name2) {
205286
- generated2 += ` params["${name2}"] = params["*"]
205287
- `;
205288
- generated2 += ` delete params["*"]
205289
- `;
205290
- }
205291
- if (pathname.endsWith("/*")) {
205292
- generated2 += ` params[0] = params["*"]
205293
- `;
205294
- generated2 += ` delete params["*"]
205295
- `;
205296
- }
205297
- generated2 += ` return params
205298
- `;
205299
- generated2 += `}
205300
- `;
205301
- return generated2;
205302
- };
205869
+ const generateRemixParams = (pathname) => `export const getRemixParams = (params: Record<string, string | undefined>) => toWebstudioParams(${JSON.stringify(pathname)}, params);`;
205303
205870
  const normalizeProps = ({
205304
205871
  props: props2,
205305
205872
  assetBaseUrl,
@@ -257430,10 +257997,10 @@ function requireParse() {
257430
257997
  Container.registerParse(parse6);
257431
257998
  return parse_1;
257432
257999
  }
257433
- var warning$2;
258000
+ var warning$1;
257434
258001
  var hasRequiredWarning;
257435
258002
  function requireWarning() {
257436
- if (hasRequiredWarning) return warning$2;
258003
+ if (hasRequiredWarning) return warning$1;
257437
258004
  hasRequiredWarning = 1;
257438
258005
  class Warning {
257439
258006
  constructor(text2, opts = {}) {
@@ -257462,9 +258029,9 @@ function requireWarning() {
257462
258029
  return this.text;
257463
258030
  }
257464
258031
  }
257465
- warning$2 = Warning;
258032
+ warning$1 = Warning;
257466
258033
  Warning.default = Warning;
257467
- return warning$2;
258034
+ return warning$1;
257468
258035
  }
257469
258036
  var result;
257470
258037
  var hasRequiredResult;
@@ -286877,7 +287444,8 @@ const materializeMdxTemplates = async ({
286877
287444
  data: data2,
286878
287445
  metas,
286879
287446
  projectId,
286880
- assetReferences = []
287447
+ assetReferences = [],
287448
+ findAvailableVariables: sharedFindAvailableVariables
286881
287449
  }) => {
286882
287450
  const materializedTemplates = [];
286883
287451
  const diagnostics = [...resolution2.diagnostics];
@@ -286888,6 +287456,11 @@ const materializeMdxTemplates = async ({
286888
287456
  reference
286889
287457
  ])
286890
287458
  );
287459
+ let findAvailableVariables2 = sharedFindAvailableVariables;
287460
+ const getFindAvailableVariables = () => findAvailableVariables2 ??= createFindAvailableVariables({
287461
+ instances: data2.instances,
287462
+ dataSources: data2.dataSources
287463
+ });
286891
287464
  for (const reference of resolution2.references) {
286892
287465
  if (reference.type === "unresolved-template") {
286893
287466
  materializedTemplates.push({
@@ -286934,11 +287507,9 @@ const materializeMdxTemplates = async ({
286934
287507
  const { newInstanceIds } = insertWebstudioFragmentCopy({
286935
287508
  data: materializedData,
286936
287509
  fragment: sourceFragment2,
286937
- availableVariables: findAvailableVariables({
286938
- startingInstanceId: reference.templateInstanceId,
286939
- instances: data2.instances,
286940
- dataSources: data2.dataSources
286941
- }),
287510
+ availableVariables: getFindAvailableVariables()(
287511
+ reference.templateInstanceId
287512
+ ),
286942
287513
  projectId,
286943
287514
  createId: createId2
286944
287515
  });
@@ -327680,7 +328251,7 @@ const createContractVersion = (schema2, additionalSchemas = []) => {
327680
328251
  })
327681
328252
  )}`;
327682
328253
  };
327683
- const maxProjectBundleSize = 20 * 1024 * 1024;
328254
+ const maxProjectBundleSize = 32 * 1024 * 1024;
327684
328255
  const stagedUploadPath = "/rest/staged-upload";
327685
328256
  const stagedUploadProjectIdHeader = "x-webstudio-project-id";
327686
328257
  const projectSessionRestorePointPath = "build.restorePoint";
@@ -332695,7 +333266,7 @@ class HandledCliError extends Error {
332695
333266
  }
332696
333267
  const isHandledCliError = (error) => error instanceof HandledCliError;
332697
333268
  const name = "webstudio";
332698
- const version$1 = "0.303.0";
333269
+ const version$1 = "0.305.0";
332699
333270
  const description = "Webstudio CLI";
332700
333271
  const author = "Webstudio <github@webstudio.is>";
332701
333272
  const homepage = "https://webstudio.is";
@@ -333061,6 +333632,8 @@ const materializeManagedAgents = async ({
333061
333632
  await dependencies2.writeFileAtomic(path2, next);
333062
333633
  return { path: path2, status: current4 === void 0 ? "created" : "updated" };
333063
333634
  };
333635
+ const maxConcurrentMdxDependencyBlocks = 4;
333636
+ const maxConcurrentMdxDependenciesPerBlock = 8;
333064
333637
  const publishedMdxTotalBytes = 32 * 1024 * 1024;
333065
333638
  const getPublishedMdxAssetIds = (assets) => new Set(assets.filter(isMdxFileAsset).map(({ id: id2 }) => id2));
333066
333639
  const getPublishedMdxContentDatabaseMaxBytes = ({
@@ -333167,7 +333740,9 @@ const createPublishedBuildContentCompilationPlan = (build2, dynamicAssetIdsByBlo
333167
333740
  const resolvePublishedMdxDependencyClosureWithParser = async ({
333168
333741
  build: build2,
333169
333742
  artifact,
333743
+ loadDocumentSource,
333170
333744
  onTemplateOmission,
333745
+ onDependencyReadFailure,
333171
333746
  onMdxBlockInstanceId,
333172
333747
  allMdxAssetIds,
333173
333748
  parseDocument: parseDocument2
@@ -333207,62 +333782,102 @@ const resolvePublishedMdxDependencyClosureWithParser = async ({
333207
333782
  }
333208
333783
  };
333209
333784
  while (pending.length > 0) {
333210
- const blockId = pending.shift();
333211
- if (processed.has(blockId)) {
333212
- continue;
333213
- }
333214
- processed.add(blockId);
333215
- const source = sourcesByBlockId.get(blockId);
333216
- if (source === void 0) {
333217
- continue;
333218
- }
333219
- onMdxBlockInstanceId?.(blockId);
333220
- const staticValue = getStaticContentBlockSourceAssetId(source);
333221
- const assetIds = typeof staticValue === "string" ? [staticValue] : resolvePublishedMdxAssetCandidates({
333222
- build: build2,
333223
- artifact,
333224
- blockInstanceIds: /* @__PURE__ */ new Set([blockId]),
333225
- allMdxAssetIds
333226
- }).get(blockId) ?? [];
333227
- for (const assetId2 of assetIds) {
333228
- const documentEntry = documentsById.get(assetId2);
333229
- const sourceText = documentEntry?.contentRef === void 0 ? void 0 : artifact.contents?.[documentEntry.contentRef];
333230
- if (documentEntry?.revision === void 0 || documentEntry.contentRef === void 0 || sourceText === void 0) {
333231
- continue;
333232
- }
333233
- const parsed = await parseDocument2({
333234
- assetId: assetId2,
333235
- revision: documentEntry.revision,
333236
- contentRef: documentEntry.contentRef,
333237
- source: sourceText
333238
- });
333239
- if (parsed.status === "unrecoverable") {
333240
- continue;
333785
+ const blockIds = pending.splice(0);
333786
+ const parsedDocumentsByBlock = await mapBounded(
333787
+ blockIds,
333788
+ maxConcurrentMdxDependencyBlocks,
333789
+ async (blockId) => {
333790
+ if (processed.has(blockId)) {
333791
+ return { blockId, parsedDocuments: [] };
333792
+ }
333793
+ processed.add(blockId);
333794
+ const source = sourcesByBlockId.get(blockId);
333795
+ if (source === void 0) {
333796
+ return { blockId, parsedDocuments: [] };
333797
+ }
333798
+ onMdxBlockInstanceId?.(blockId);
333799
+ const staticValue = getStaticContentBlockSourceAssetId(source);
333800
+ const assetIds = typeof staticValue === "string" ? [staticValue] : resolvePublishedMdxAssetCandidates({
333801
+ build: build2,
333802
+ artifact,
333803
+ blockInstanceIds: /* @__PURE__ */ new Set([blockId]),
333804
+ allMdxAssetIds
333805
+ }).get(blockId) ?? [];
333806
+ const parsedDocuments = await mapBounded(
333807
+ assetIds,
333808
+ maxConcurrentMdxDependenciesPerBlock,
333809
+ async (assetId2) => {
333810
+ const documentEntry = documentsById.get(assetId2);
333811
+ if (documentEntry?.extension?.toLowerCase() !== "mdx" && documentEntry?.mimeType !== "text/mdx") {
333812
+ return;
333813
+ }
333814
+ let sourceText = documentEntry.contentRef === void 0 ? void 0 : artifact.contents?.[documentEntry.contentRef];
333815
+ if (sourceText === void 0 && documentEntry.revision !== void 0 && documentEntry.contentRef !== void 0 && loadDocumentSource !== void 0) {
333816
+ try {
333817
+ sourceText = await loadDocumentSource({
333818
+ id: assetId2,
333819
+ revision: documentEntry.revision,
333820
+ contentRef: documentEntry.contentRef
333821
+ });
333822
+ } catch (error) {
333823
+ onDependencyReadFailure?.({
333824
+ blockInstanceId: blockId,
333825
+ assetId: assetId2,
333826
+ contentRef: documentEntry.contentRef,
333827
+ message: `Could not inspect this MDX source: ${error instanceof Error ? error.message : String(error)}`
333828
+ });
333829
+ return;
333830
+ }
333831
+ }
333832
+ if (documentEntry.revision === void 0 || documentEntry.contentRef === void 0 || sourceText === void 0) {
333833
+ return;
333834
+ }
333835
+ const parsed = await parseDocument2({
333836
+ assetId: assetId2,
333837
+ revision: documentEntry.revision,
333838
+ contentRef: documentEntry.contentRef,
333839
+ source: sourceText
333840
+ });
333841
+ return parsed.status === "unrecoverable" ? void 0 : { assetId: assetId2, documentEntry, document: parsed.document };
333842
+ }
333843
+ );
333844
+ return {
333845
+ blockId,
333846
+ parsedDocuments: parsedDocuments.filter(
333847
+ (document2) => document2 !== void 0
333848
+ )
333849
+ };
333241
333850
  }
333242
- const document2 = parsed.document;
333243
- const resolution2 = resolveMdxTemplates({
333244
- document: document2,
333245
- identity: {
333246
- blockInstanceId: blockId,
333247
- assetId: assetId2,
333248
- revision: documentEntry.revision,
333249
- contentRef: documentEntry.contentRef,
333250
- renderScope: "publication-dependency-discovery"
333251
- },
333252
- instances,
333253
- props: propsById,
333254
- metas: componentMetas
333255
- });
333256
- assertMdxTemplateStructure(resolution2);
333257
- for (const reference of resolution2.references) {
333258
- if (reference.type === "resolved-template") {
333259
- visitTemplateSubtree(reference.templateInstanceId);
333260
- } else {
333261
- onTemplateOmission?.({
333851
+ );
333852
+ for (const { blockId, parsedDocuments } of parsedDocumentsByBlock) {
333853
+ for (const { assetId: assetId2, documentEntry, document: document2 } of parsedDocuments) {
333854
+ if (documentEntry.revision === void 0 || documentEntry.contentRef === void 0) {
333855
+ continue;
333856
+ }
333857
+ const resolution2 = resolveMdxTemplates({
333858
+ document: document2,
333859
+ identity: {
333262
333860
  blockInstanceId: blockId,
333263
333861
  assetId: assetId2,
333264
- templateName: reference.templateName
333265
- });
333862
+ revision: documentEntry.revision,
333863
+ contentRef: documentEntry.contentRef,
333864
+ renderScope: "publication-dependency-discovery"
333865
+ },
333866
+ instances,
333867
+ props: propsById,
333868
+ metas: componentMetas
333869
+ });
333870
+ assertMdxTemplateStructure(resolution2);
333871
+ for (const reference of resolution2.references) {
333872
+ if (reference.type === "resolved-template") {
333873
+ visitTemplateSubtree(reference.templateInstanceId);
333874
+ } else {
333875
+ onTemplateOmission?.({
333876
+ blockInstanceId: blockId,
333877
+ assetId: assetId2,
333878
+ templateName: reference.templateName
333879
+ });
333880
+ }
333266
333881
  }
333267
333882
  }
333268
333883
  }
@@ -333297,8 +333912,11 @@ const createPublishedMdxDependencyClosureResolver = (dependencies2 = { parseMdxD
333297
333912
  };
333298
333913
  const candidateDocumentKey = Symbol("candidate-document");
333299
333914
  const isCandidateDocument = (value2) => typeof value2 === "object" && value2 !== null && candidateDocumentKey in value2;
333300
- const getValueAtPath = (value2, path2) => {
333915
+ const getValueAtPath = (value2, path2, knownNonMdxAssetIds) => {
333301
333916
  if (isCandidateDocument(value2)) {
333917
+ if (knownNonMdxAssetIds?.has(value2[candidateDocumentKey]._id) && (path2.length === 0 || path2.length === 1 && (path2[0] === "id" || path2[0] === "_id"))) {
333918
+ return;
333919
+ }
333302
333920
  if (path2[0] === "properties" && value2.graph !== void 0 && isDocumentGraphFieldAffected({
333303
333921
  graph: value2.graph,
333304
333922
  sourceId: value2[candidateDocumentKey]._id,
@@ -333324,6 +333942,7 @@ const resolvePublishedMdxAssetCandidates = ({
333324
333942
  artifact,
333325
333943
  allowUnresolved = false,
333326
333944
  blockInstanceIds = getPublishedInstanceIds(build2),
333945
+ allAssetIds,
333327
333946
  allMdxAssetIds
333328
333947
  }) => {
333329
333948
  const instances = new Map(
@@ -333351,6 +333970,9 @@ const resolvePublishedMdxAssetCandidates = ({
333351
333970
  );
333352
333971
  const documentGraph = artifact?.documentGraph === void 0 ? void 0 : createDocumentGraph(artifact.documentGraph);
333353
333972
  const documents = artifact?.documents ?? [];
333973
+ const knownNonMdxAssetIds = allAssetIds === void 0 || allMdxAssetIds === void 0 ? void 0 : new Set(
333974
+ [...allAssetIds].filter((assetId2) => !allMdxAssetIds.has(assetId2))
333975
+ );
333354
333976
  const evaluateDataSource = (dataSourceId2, path2, visiting = /* @__PURE__ */ new Set(), mutableVariables = /* @__PURE__ */ new Set()) => {
333355
333977
  if (visiting.has(dataSourceId2)) {
333356
333978
  throw new Error("Dynamic MDX source data dependency is cyclic");
@@ -333413,7 +334035,8 @@ const resolvePublishedMdxAssetCandidates = ({
333413
334035
  graph: documentGraph
333414
334036
  } : getValueAtPath(
333415
334037
  { [candidateDocumentKey]: document2, graph: documentGraph },
333416
- fieldPath
334038
+ fieldPath,
334039
+ knownNonMdxAssetIds
333417
334040
  )
333418
334041
  );
333419
334042
  }
@@ -333454,7 +334077,7 @@ const resolvePublishedMdxAssetCandidates = ({
333454
334077
  }
333455
334078
  return [iterable];
333456
334079
  });
333457
- return items.map((item) => getValueAtPath(item, path2));
334080
+ return items.map((item) => getValueAtPath(item, path2, knownNonMdxAssetIds));
333458
334081
  };
333459
334082
  const candidatesByBlock = /* @__PURE__ */ new Map();
333460
334083
  for (const blockInstanceId of blockInstanceIds) {
@@ -340074,6 +340697,7 @@ const createMdxContentModelDiagnostics = ({
340074
340697
  {
340075
340698
  code: "invalid-mdx",
340076
340699
  severity: "error",
340700
+ reason: "html-content-model",
340077
340701
  blockInstanceId: root2.identity.blockInstanceId,
340078
340702
  assetId: root2.identity.assetId,
340079
340703
  contentRef: root2.identity.contentRef,
@@ -340644,6 +341268,7 @@ const getUnsafeDynamicPublishedMdxDiagnostic = ({
340644
341268
  return {
340645
341269
  code: "invalid-mdx",
340646
341270
  severity: "error",
341271
+ reason: "dynamic-resource",
340647
341272
  blockInstanceId: root2.identity.blockInstanceId,
340648
341273
  assetId: root2.identity.assetId,
340649
341274
  renderScope: `route:${route}:block:${root2.identity.blockInstanceId}`,
@@ -340659,6 +341284,7 @@ const getUnsafeDynamicPublishedMdxDiagnostic = ({
340659
341284
  return {
340660
341285
  code: "invalid-mdx",
340661
341286
  severity: "error",
341287
+ reason: "dynamic-resource",
340662
341288
  blockInstanceId: root2.identity.blockInstanceId,
340663
341289
  assetId: root2.identity.assetId,
340664
341290
  renderScope: `route:${route}:block:${root2.identity.blockInstanceId}`,
@@ -340779,9 +341405,11 @@ const materializePublishedMdx = async ({
340779
341405
  });
340780
341406
  const roots = [];
340781
341407
  const warnings = [];
341408
+ let findAvailableVariables2;
340782
341409
  const warnUnavailableSource = ({
340783
341410
  blockInstanceId,
340784
341411
  assetId: assetId2,
341412
+ reason,
340785
341413
  message
340786
341414
  }) => {
340787
341415
  warnings.push({
@@ -340789,6 +341417,7 @@ const materializePublishedMdx = async ({
340789
341417
  diagnostic: {
340790
341418
  code: "invalid-mdx",
340791
341419
  severity: "error",
341420
+ ...reason === void 0 ? {} : { reason },
340792
341421
  blockInstanceId,
340793
341422
  ...assetId2 === void 0 ? {} : { assetId: assetId2 },
340794
341423
  renderScope: `route:${route}:block:${blockInstanceId}`,
@@ -340810,6 +341439,7 @@ const materializePublishedMdx = async ({
340810
341439
  if (resolvedAssetIds.length > contentEngineLimits.candidateDocuments) {
340811
341440
  warnUnavailableSource({
340812
341441
  blockInstanceId: block.id,
341442
+ reason: "dynamic-source-unbounded",
340813
341443
  message: `Published Content Block "${block.id}" exceeds the safe MDX candidate limit`
340814
341444
  });
340815
341445
  continue;
@@ -340817,6 +341447,7 @@ const materializePublishedMdx = async ({
340817
341447
  if (resolvedAssetIds.length === 0) {
340818
341448
  warnUnavailableSource({
340819
341449
  blockInstanceId: block.id,
341450
+ reason: "dynamic-source-unbounded",
340820
341451
  message: `Published Content Block "${block.id}" has no bounded dynamic MDX dependency set`
340821
341452
  });
340822
341453
  continue;
@@ -340832,6 +341463,7 @@ const materializePublishedMdx = async ({
340832
341463
  warnUnavailableSource({
340833
341464
  blockInstanceId: block.id,
340834
341465
  assetId: assetId2,
341466
+ reason: "missing-asset",
340835
341467
  message: `Published Content Block "${block.id}" requires unavailable MDX Asset "${assetId2}"`
340836
341468
  });
340837
341469
  }
@@ -340840,15 +341472,34 @@ const materializePublishedMdx = async ({
340840
341472
  warnUnavailableSource({
340841
341473
  blockInstanceId: block.id,
340842
341474
  assetId: candidate._id,
341475
+ reason: "missing-source",
340843
341476
  message: `Published MDX Asset "${candidate._id}" has no revision identity`
340844
341477
  });
340845
341478
  continue;
340846
341479
  }
340847
- const sourceText = artifact.contents?.[candidate.contentRef];
341480
+ let sourceText = artifact.contents?.[candidate.contentRef];
341481
+ if (sourceText === void 0 && loadDocumentSource !== void 0) {
341482
+ try {
341483
+ sourceText = await loadDocumentSource({
341484
+ id: candidate._id,
341485
+ revision: candidate.revision,
341486
+ contentRef: candidate.contentRef
341487
+ });
341488
+ } catch (error) {
341489
+ warnUnavailableSource({
341490
+ blockInstanceId: block.id,
341491
+ assetId: candidate._id,
341492
+ reason: "source-read-failed",
341493
+ message: `Published MDX Asset "${candidate._id}" could not be loaded: ${error instanceof Error ? error.message : String(error)}`
341494
+ });
341495
+ continue;
341496
+ }
341497
+ }
340848
341498
  if (sourceText === void 0) {
340849
341499
  warnUnavailableSource({
340850
341500
  blockInstanceId: block.id,
340851
341501
  assetId: candidate._id,
341502
+ reason: "missing-source",
340852
341503
  message: `Published MDX Asset "${candidate._id}" content is unavailable`
340853
341504
  });
340854
341505
  continue;
@@ -340894,13 +341545,22 @@ const materializePublishedMdx = async ({
340894
341545
  metas
340895
341546
  });
340896
341547
  assertMdxTemplateStructure(resolution2);
341548
+ if (findAvailableVariables2 === void 0 && resolution2.references.some(
341549
+ (reference) => reference.type === "resolved-template"
341550
+ )) {
341551
+ findAvailableVariables2 = createFindAvailableVariables({
341552
+ instances: data2.instances,
341553
+ dataSources: data2.dataSources
341554
+ });
341555
+ }
340897
341556
  const templates2 = await materializeMdxTemplates({
340898
341557
  identity,
340899
341558
  resolution: resolution2,
340900
341559
  data: data2,
340901
341560
  metas,
340902
341561
  projectId,
340903
- assetReferences
341562
+ assetReferences,
341563
+ findAvailableVariables: findAvailableVariables2
340904
341564
  });
340905
341565
  const referencedTemplateNames = Array.from(
340906
341566
  new Set(
@@ -340921,6 +341581,7 @@ const materializePublishedMdx = async ({
340921
341581
  warnUnavailableSource({
340922
341582
  blockInstanceId: block.id,
340923
341583
  assetId: candidate._id,
341584
+ reason: "linked-document-unavailable",
340924
341585
  message: `${linkedDocument} ${failure}${reference} while resolving frontmatter for published MDX Asset "${candidate._id}".`
340925
341586
  });
340926
341587
  } else {
@@ -341326,446 +341987,6 @@ const createFrameworkComponentRegistry = ({
341326
341987
  }
341327
341988
  return { components: components2, metas, buildHooks: buildHooks$1 };
341328
341989
  };
341329
- /**
341330
- * @remix-run/router v1.23.0
341331
- *
341332
- * Copyright (c) Remix Software Inc.
341333
- *
341334
- * This source code is licensed under the MIT license found in the
341335
- * LICENSE.md file in the root directory of this source tree.
341336
- *
341337
- * @license MIT
341338
- */
341339
- function _extends$3() {
341340
- _extends$3 = Object.assign ? Object.assign.bind() : function(target) {
341341
- for (var i = 1; i < arguments.length; i++) {
341342
- var source = arguments[i];
341343
- for (var key2 in source) {
341344
- if (Object.prototype.hasOwnProperty.call(source, key2)) {
341345
- target[key2] = source[key2];
341346
- }
341347
- }
341348
- }
341349
- return target;
341350
- };
341351
- return _extends$3.apply(this, arguments);
341352
- }
341353
- var Action;
341354
- (function(Action2) {
341355
- Action2["Pop"] = "POP";
341356
- Action2["Push"] = "PUSH";
341357
- Action2["Replace"] = "REPLACE";
341358
- })(Action || (Action = {}));
341359
- function invariant$2(value2, message) {
341360
- if (value2 === false || value2 === null || typeof value2 === "undefined") {
341361
- throw new Error(message);
341362
- }
341363
- }
341364
- function warning$1(cond, message) {
341365
- if (!cond) {
341366
- if (typeof console !== "undefined") console.warn(message);
341367
- try {
341368
- throw new Error(message);
341369
- } catch (e2) {
341370
- }
341371
- }
341372
- }
341373
- function createPath$1(_ref) {
341374
- let {
341375
- pathname = "/",
341376
- search: search2 = "",
341377
- hash: hash2 = ""
341378
- } = _ref;
341379
- if (search2 && search2 !== "?") pathname += search2.charAt(0) === "?" ? search2 : "?" + search2;
341380
- if (hash2 && hash2 !== "#") pathname += hash2.charAt(0) === "#" ? hash2 : "#" + hash2;
341381
- return pathname;
341382
- }
341383
- function parsePath$1(path2) {
341384
- let parsedPath = {};
341385
- if (path2) {
341386
- let hashIndex = path2.indexOf("#");
341387
- if (hashIndex >= 0) {
341388
- parsedPath.hash = path2.substr(hashIndex);
341389
- path2 = path2.substr(0, hashIndex);
341390
- }
341391
- let searchIndex = path2.indexOf("?");
341392
- if (searchIndex >= 0) {
341393
- parsedPath.search = path2.substr(searchIndex);
341394
- path2 = path2.substr(0, searchIndex);
341395
- }
341396
- if (path2) {
341397
- parsedPath.pathname = path2;
341398
- }
341399
- }
341400
- return parsedPath;
341401
- }
341402
- var ResultType;
341403
- (function(ResultType2) {
341404
- ResultType2["data"] = "data";
341405
- ResultType2["deferred"] = "deferred";
341406
- ResultType2["redirect"] = "redirect";
341407
- ResultType2["error"] = "error";
341408
- })(ResultType || (ResultType = {}));
341409
- function matchRoutes$1(routes, locationArg, basename2) {
341410
- if (basename2 === void 0) {
341411
- basename2 = "/";
341412
- }
341413
- return matchRoutesImpl$1(routes, locationArg, basename2);
341414
- }
341415
- function matchRoutesImpl$1(routes, locationArg, basename2, allowPartial) {
341416
- let location = typeof locationArg === "string" ? parsePath$1(locationArg) : locationArg;
341417
- let pathname = stripBasename$1(location.pathname || "/", basename2);
341418
- if (pathname == null) {
341419
- return null;
341420
- }
341421
- let branches = flattenRoutes$1(routes);
341422
- rankRouteBranches$1(branches);
341423
- let matches2 = null;
341424
- for (let i = 0; matches2 == null && i < branches.length; ++i) {
341425
- let decoded = decodePath$1(pathname);
341426
- matches2 = matchRouteBranch$1(branches[i], decoded);
341427
- }
341428
- return matches2;
341429
- }
341430
- function convertRouteMatchToUiMatch$1(match, loaderData) {
341431
- let {
341432
- route,
341433
- pathname,
341434
- params
341435
- } = match;
341436
- return {
341437
- id: route.id,
341438
- pathname,
341439
- params,
341440
- data: loaderData[route.id],
341441
- handle: route.handle
341442
- };
341443
- }
341444
- function flattenRoutes$1(routes, branches, parentsMeta, parentPath) {
341445
- if (branches === void 0) {
341446
- branches = [];
341447
- }
341448
- if (parentsMeta === void 0) {
341449
- parentsMeta = [];
341450
- }
341451
- if (parentPath === void 0) {
341452
- parentPath = "";
341453
- }
341454
- let flattenRoute = (route, index2, relativePath) => {
341455
- let meta2 = {
341456
- relativePath: relativePath === void 0 ? route.path || "" : relativePath,
341457
- caseSensitive: route.caseSensitive === true,
341458
- childrenIndex: index2,
341459
- route
341460
- };
341461
- if (meta2.relativePath.startsWith("/")) {
341462
- invariant$2(meta2.relativePath.startsWith(parentPath), 'Absolute route path "' + meta2.relativePath + '" nested under path ' + ('"' + parentPath + '" is not valid. An absolute child route path ') + "must start with the combined path of all its parent routes.");
341463
- meta2.relativePath = meta2.relativePath.slice(parentPath.length);
341464
- }
341465
- let path2 = joinPaths$1([parentPath, meta2.relativePath]);
341466
- let routesMeta = parentsMeta.concat(meta2);
341467
- if (route.children && route.children.length > 0) {
341468
- invariant$2(
341469
- // Our types know better, but runtime JS may not!
341470
- // @ts-expect-error
341471
- route.index !== true,
341472
- "Index routes must not have child routes. Please remove " + ('all child routes from route path "' + path2 + '".')
341473
- );
341474
- flattenRoutes$1(route.children, branches, routesMeta, path2);
341475
- }
341476
- if (route.path == null && !route.index) {
341477
- return;
341478
- }
341479
- branches.push({
341480
- path: path2,
341481
- score: computeScore$1(path2, route.index),
341482
- routesMeta
341483
- });
341484
- };
341485
- routes.forEach((route, index2) => {
341486
- var _route$path;
341487
- if (route.path === "" || !((_route$path = route.path) != null && _route$path.includes("?"))) {
341488
- flattenRoute(route, index2);
341489
- } else {
341490
- for (let exploded of explodeOptionalSegments$1(route.path)) {
341491
- flattenRoute(route, index2, exploded);
341492
- }
341493
- }
341494
- });
341495
- return branches;
341496
- }
341497
- function explodeOptionalSegments$1(path2) {
341498
- let segments = path2.split("/");
341499
- if (segments.length === 0) return [];
341500
- let [first, ...rest] = segments;
341501
- let isOptional = first.endsWith("?");
341502
- let required2 = first.replace(/\?$/, "");
341503
- if (rest.length === 0) {
341504
- return isOptional ? [required2, ""] : [required2];
341505
- }
341506
- let restExploded = explodeOptionalSegments$1(rest.join("/"));
341507
- let result2 = [];
341508
- result2.push(...restExploded.map((subpath) => subpath === "" ? required2 : [required2, subpath].join("/")));
341509
- if (isOptional) {
341510
- result2.push(...restExploded);
341511
- }
341512
- return result2.map((exploded) => path2.startsWith("/") && exploded === "" ? "/" : exploded);
341513
- }
341514
- function rankRouteBranches$1(branches) {
341515
- branches.sort((a2, b2) => a2.score !== b2.score ? b2.score - a2.score : compareIndexes$1(a2.routesMeta.map((meta2) => meta2.childrenIndex), b2.routesMeta.map((meta2) => meta2.childrenIndex)));
341516
- }
341517
- const paramRe$1 = /^:[\w-]+$/;
341518
- const dynamicSegmentValue$1 = 3;
341519
- const indexRouteValue$1 = 2;
341520
- const emptySegmentValue$1 = 1;
341521
- const staticSegmentValue$1 = 10;
341522
- const splatPenalty$1 = -2;
341523
- const isSplat$1 = (s2) => s2 === "*";
341524
- function computeScore$1(path2, index2) {
341525
- let segments = path2.split("/");
341526
- let initialScore = segments.length;
341527
- if (segments.some(isSplat$1)) {
341528
- initialScore += splatPenalty$1;
341529
- }
341530
- if (index2) {
341531
- initialScore += indexRouteValue$1;
341532
- }
341533
- return segments.filter((s2) => !isSplat$1(s2)).reduce((score, segment) => score + (paramRe$1.test(segment) ? dynamicSegmentValue$1 : segment === "" ? emptySegmentValue$1 : staticSegmentValue$1), initialScore);
341534
- }
341535
- function compareIndexes$1(a2, b2) {
341536
- let siblings2 = a2.length === b2.length && a2.slice(0, -1).every((n2, i) => n2 === b2[i]);
341537
- return siblings2 ? (
341538
- // If two routes are siblings, we should try to match the earlier sibling
341539
- // first. This allows people to have fine-grained control over the matching
341540
- // behavior by simply putting routes with identical paths in the order they
341541
- // want them tried.
341542
- a2[a2.length - 1] - b2[b2.length - 1]
341543
- ) : (
341544
- // Otherwise, it doesn't really make sense to rank non-siblings by index,
341545
- // so they sort equally.
341546
- 0
341547
- );
341548
- }
341549
- function matchRouteBranch$1(branch, pathname, allowPartial) {
341550
- let {
341551
- routesMeta
341552
- } = branch;
341553
- let matchedParams = {};
341554
- let matchedPathname = "/";
341555
- let matches2 = [];
341556
- for (let i = 0; i < routesMeta.length; ++i) {
341557
- let meta2 = routesMeta[i];
341558
- let end = i === routesMeta.length - 1;
341559
- let remainingPathname = matchedPathname === "/" ? pathname : pathname.slice(matchedPathname.length) || "/";
341560
- let match = matchPath$1({
341561
- path: meta2.relativePath,
341562
- caseSensitive: meta2.caseSensitive,
341563
- end
341564
- }, remainingPathname);
341565
- let route = meta2.route;
341566
- if (!match) {
341567
- return null;
341568
- }
341569
- Object.assign(matchedParams, match.params);
341570
- matches2.push({
341571
- // TODO: Can this as be avoided?
341572
- params: matchedParams,
341573
- pathname: joinPaths$1([matchedPathname, match.pathname]),
341574
- pathnameBase: normalizePathname$1(joinPaths$1([matchedPathname, match.pathnameBase])),
341575
- route
341576
- });
341577
- if (match.pathnameBase !== "/") {
341578
- matchedPathname = joinPaths$1([matchedPathname, match.pathnameBase]);
341579
- }
341580
- }
341581
- return matches2;
341582
- }
341583
- function matchPath$1(pattern, pathname) {
341584
- if (typeof pattern === "string") {
341585
- pattern = {
341586
- path: pattern,
341587
- caseSensitive: false,
341588
- end: true
341589
- };
341590
- }
341591
- let [matcher, compiledParams] = compilePath$1(pattern.path, pattern.caseSensitive, pattern.end);
341592
- let match = pathname.match(matcher);
341593
- if (!match) return null;
341594
- let matchedPathname = match[0];
341595
- let pathnameBase = matchedPathname.replace(/(.)\/+$/, "$1");
341596
- let captureGroups = match.slice(1);
341597
- let params = compiledParams.reduce((memo, _ref, index2) => {
341598
- let {
341599
- paramName,
341600
- isOptional
341601
- } = _ref;
341602
- if (paramName === "*") {
341603
- let splatValue = captureGroups[index2] || "";
341604
- pathnameBase = matchedPathname.slice(0, matchedPathname.length - splatValue.length).replace(/(.)\/+$/, "$1");
341605
- }
341606
- const value2 = captureGroups[index2];
341607
- if (isOptional && !value2) {
341608
- memo[paramName] = void 0;
341609
- } else {
341610
- memo[paramName] = (value2 || "").replace(/%2F/g, "/");
341611
- }
341612
- return memo;
341613
- }, {});
341614
- return {
341615
- params,
341616
- pathname: matchedPathname,
341617
- pathnameBase,
341618
- pattern
341619
- };
341620
- }
341621
- function compilePath$1(path2, caseSensitive, end) {
341622
- if (caseSensitive === void 0) {
341623
- caseSensitive = false;
341624
- }
341625
- if (end === void 0) {
341626
- end = true;
341627
- }
341628
- warning$1(path2 === "*" || !path2.endsWith("*") || path2.endsWith("/*"), 'Route path "' + path2 + '" will be treated as if it were ' + ('"' + path2.replace(/\*$/, "/*") + '" because the `*` character must ') + "always follow a `/` in the pattern. To get rid of this warning, " + ('please change the route path to "' + path2.replace(/\*$/, "/*") + '".'));
341629
- let params = [];
341630
- let regexpSource = "^" + path2.replace(/\/*\*?$/, "").replace(/^\/*/, "/").replace(/[\\.*+^${}|()[\]]/g, "\\$&").replace(/\/:([\w-]+)(\?)?/g, (_2, paramName, isOptional) => {
341631
- params.push({
341632
- paramName,
341633
- isOptional: isOptional != null
341634
- });
341635
- return isOptional ? "/?([^\\/]+)?" : "/([^\\/]+)";
341636
- });
341637
- if (path2.endsWith("*")) {
341638
- params.push({
341639
- paramName: "*"
341640
- });
341641
- regexpSource += path2 === "*" || path2 === "/*" ? "(.*)$" : "(?:\\/(.+)|\\/*)$";
341642
- } else if (end) {
341643
- regexpSource += "\\/*$";
341644
- } else if (path2 !== "" && path2 !== "/") {
341645
- regexpSource += "(?:(?=\\/|$))";
341646
- } else ;
341647
- let matcher = new RegExp(regexpSource, caseSensitive ? void 0 : "i");
341648
- return [matcher, params];
341649
- }
341650
- function decodePath$1(value2) {
341651
- try {
341652
- return value2.split("/").map((v2) => decodeURIComponent(v2).replace(/\//g, "%2F")).join("/");
341653
- } catch (error) {
341654
- warning$1(false, 'The URL path "' + value2 + '" could not be decoded because it is is a malformed URL segment. This is probably due to a bad percent ' + ("encoding (" + error + ")."));
341655
- return value2;
341656
- }
341657
- }
341658
- function stripBasename$1(pathname, basename2) {
341659
- if (basename2 === "/") return pathname;
341660
- if (!pathname.toLowerCase().startsWith(basename2.toLowerCase())) {
341661
- return null;
341662
- }
341663
- let startIndex = basename2.endsWith("/") ? basename2.length - 1 : basename2.length;
341664
- let nextChar = pathname.charAt(startIndex);
341665
- if (nextChar && nextChar !== "/") {
341666
- return null;
341667
- }
341668
- return pathname.slice(startIndex) || "/";
341669
- }
341670
- function resolvePath$1(to2, fromPathname) {
341671
- if (fromPathname === void 0) {
341672
- fromPathname = "/";
341673
- }
341674
- let {
341675
- pathname: toPathname,
341676
- search: search2 = "",
341677
- hash: hash2 = ""
341678
- } = typeof to2 === "string" ? parsePath$1(to2) : to2;
341679
- let pathname = toPathname ? toPathname.startsWith("/") ? toPathname : resolvePathname$1(toPathname, fromPathname) : fromPathname;
341680
- return {
341681
- pathname,
341682
- search: normalizeSearch$1(search2),
341683
- hash: normalizeHash$1(hash2)
341684
- };
341685
- }
341686
- function resolvePathname$1(relativePath, fromPathname) {
341687
- let segments = fromPathname.replace(/\/+$/, "").split("/");
341688
- let relativeSegments = relativePath.split("/");
341689
- relativeSegments.forEach((segment) => {
341690
- if (segment === "..") {
341691
- if (segments.length > 1) segments.pop();
341692
- } else if (segment !== ".") {
341693
- segments.push(segment);
341694
- }
341695
- });
341696
- return segments.length > 1 ? segments.join("/") : "/";
341697
- }
341698
- function getInvalidPathError$1(char, field, dest, path2) {
341699
- return "Cannot include a '" + char + "' character in a manually specified " + ("`to." + field + "` field [" + JSON.stringify(path2) + "]. Please separate it out to the ") + ("`to." + dest + "` field. Alternatively you may provide the full path as ") + 'a string in <Link to="..."> and the router will parse it for you.';
341700
- }
341701
- function getPathContributingMatches$1(matches2) {
341702
- return matches2.filter((match, index2) => index2 === 0 || match.route.path && match.route.path.length > 0);
341703
- }
341704
- function getResolveToMatches$1(matches2, v7_relativeSplatPath) {
341705
- let pathMatches = getPathContributingMatches$1(matches2);
341706
- if (v7_relativeSplatPath) {
341707
- return pathMatches.map((match, idx) => idx === pathMatches.length - 1 ? match.pathname : match.pathnameBase);
341708
- }
341709
- return pathMatches.map((match) => match.pathnameBase);
341710
- }
341711
- function resolveTo$1(toArg, routePathnames, locationPathname, isPathRelative) {
341712
- if (isPathRelative === void 0) {
341713
- isPathRelative = false;
341714
- }
341715
- let to2;
341716
- if (typeof toArg === "string") {
341717
- to2 = parsePath$1(toArg);
341718
- } else {
341719
- to2 = _extends$3({}, toArg);
341720
- invariant$2(!to2.pathname || !to2.pathname.includes("?"), getInvalidPathError$1("?", "pathname", "search", to2));
341721
- invariant$2(!to2.pathname || !to2.pathname.includes("#"), getInvalidPathError$1("#", "pathname", "hash", to2));
341722
- invariant$2(!to2.search || !to2.search.includes("#"), getInvalidPathError$1("#", "search", "hash", to2));
341723
- }
341724
- let isEmptyPath2 = toArg === "" || to2.pathname === "";
341725
- let toPathname = isEmptyPath2 ? "/" : to2.pathname;
341726
- let from;
341727
- if (toPathname == null) {
341728
- from = locationPathname;
341729
- } else {
341730
- let routePathnameIndex = routePathnames.length - 1;
341731
- if (!isPathRelative && toPathname.startsWith("..")) {
341732
- let toSegments = toPathname.split("/");
341733
- while (toSegments[0] === "..") {
341734
- toSegments.shift();
341735
- routePathnameIndex -= 1;
341736
- }
341737
- to2.pathname = toSegments.join("/");
341738
- }
341739
- from = routePathnameIndex >= 0 ? routePathnames[routePathnameIndex] : "/";
341740
- }
341741
- let path2 = resolvePath$1(to2, from);
341742
- let hasExplicitTrailingSlash = toPathname && toPathname !== "/" && toPathname.endsWith("/");
341743
- let hasCurrentTrailingSlash = (isEmptyPath2 || toPathname === ".") && locationPathname.endsWith("/");
341744
- if (!path2.pathname.endsWith("/") && (hasExplicitTrailingSlash || hasCurrentTrailingSlash)) {
341745
- path2.pathname += "/";
341746
- }
341747
- return path2;
341748
- }
341749
- const joinPaths$1 = (paths) => paths.join("/").replace(/\/\/+/g, "/");
341750
- const normalizePathname$1 = (pathname) => pathname.replace(/\/+$/, "").replace(/^\/*/, "/");
341751
- const normalizeSearch$1 = (search2) => !search2 || search2 === "?" ? "" : search2.startsWith("?") ? search2 : "?" + search2;
341752
- const normalizeHash$1 = (hash2) => !hash2 || hash2 === "#" ? "" : hash2.startsWith("#") ? hash2 : "#" + hash2;
341753
- class AbortedDeferredError extends Error {
341754
- }
341755
- const validMutationMethodsArr$1 = ["post", "put", "patch", "delete"];
341756
- new Set(validMutationMethodsArr$1);
341757
- const validRequestMethodsArr$1 = ["get", ...validMutationMethodsArr$1];
341758
- new Set(validRequestMethodsArr$1);
341759
- const IDLE_FETCHER$1 = {
341760
- state: "idle",
341761
- data: void 0,
341762
- formMethod: void 0,
341763
- formAction: void 0,
341764
- formEncType: void 0,
341765
- formData: void 0,
341766
- json: void 0,
341767
- text: void 0
341768
- };
341769
341990
  /**
341770
341991
  * React Router v6.30.0
341771
341992
  *
@@ -341906,7 +342127,7 @@ function useNavigateUnstable$1() {
341906
342127
  if (options === void 0) {
341907
342128
  options = {};
341908
342129
  }
341909
- process.env.NODE_ENV !== "production" ? warning$1(activeRef.current, navigateEffectWarning$1) : void 0;
342130
+ process.env.NODE_ENV !== "production" ? warning$2(activeRef.current, navigateEffectWarning$1) : void 0;
341910
342131
  if (!activeRef.current) return;
341911
342132
  if (typeof to2 === "number") {
341912
342133
  navigator2.go(to2);
@@ -342014,7 +342235,7 @@ function useNavigateStable$1() {
342014
342235
  if (options === void 0) {
342015
342236
  options = {};
342016
342237
  }
342017
- process.env.NODE_ENV !== "production" ? warning$1(activeRef.current, navigateEffectWarning$1) : void 0;
342238
+ process.env.NODE_ENV !== "production" ? warning$2(activeRef.current, navigateEffectWarning$1) : void 0;
342018
342239
  if (!activeRef.current) return;
342019
342240
  if (typeof to2 === "number") {
342020
342241
  router.navigate(to2);
@@ -342208,7 +342429,7 @@ function isFormDataSubmitterSupported$1() {
342208
342429
  const supportedFormEncTypes$1 = /* @__PURE__ */ new Set(["application/x-www-form-urlencoded", "multipart/form-data", "text/plain"]);
342209
342430
  function getFormEncType$1(encType) {
342210
342431
  if (encType != null && !supportedFormEncTypes$1.has(encType)) {
342211
- process.env.NODE_ENV !== "production" ? warning$1(false, '"' + encType + '" is not a valid `encType` for `<Form>`/`<fetcher.Form>` ' + ('and will default to "' + defaultEncType$1 + '"')) : void 0;
342432
+ process.env.NODE_ENV !== "production" ? warning$2(false, '"' + encType + '" is not a valid `encType` for `<Form>`/`<fetcher.Form>` ' + ('and will default to "' + defaultEncType$1 + '"')) : void 0;
342212
342433
  return null;
342213
342434
  }
342214
342435
  return encType;
@@ -342320,7 +342541,7 @@ const Link$4 = /* @__PURE__ */ reactExports.forwardRef(function LinkWithRef(_ref
342320
342541
  isExternal = true;
342321
342542
  }
342322
342543
  } catch (e2) {
342323
- process.env.NODE_ENV !== "production" ? warning$1(false, '<Link to="' + to2 + '"> contains an invalid URL which will probably break when clicked - please update to a valid URL path.') : void 0;
342544
+ process.env.NODE_ENV !== "production" ? warning$2(false, '<Link to="' + to2 + '"> contains an invalid URL which will probably break when clicked - please update to a valid URL path.') : void 0;
342324
342545
  }
342325
342546
  }
342326
342547
  }
@@ -342702,7 +342923,7 @@ function useScrollRestoration$1(_temp4) {
342702
342923
  try {
342703
342924
  sessionStorage.setItem(storageKey || SCROLL_RESTORATION_STORAGE_KEY$1, JSON.stringify(savedScrollPositions$1));
342704
342925
  } catch (error) {
342705
- process.env.NODE_ENV !== "production" ? warning$1(false, "Failed to save scroll positions in sessionStorage, <ScrollRestoration /> will not work properly (" + error + ").") : void 0;
342926
+ process.env.NODE_ENV !== "production" ? warning$2(false, "Failed to save scroll positions in sessionStorage, <ScrollRestoration /> will not work properly (" + error + ").") : void 0;
342706
342927
  }
342707
342928
  window.history.scrollRestoration = "auto";
342708
342929
  }, [storageKey, getKey2, navigation.state, location, matches2]));
@@ -347026,6 +347247,7 @@ Please check webstudio --help for more details`
347026
347247
  const siteData = parsedSiteData.data;
347027
347248
  const pages2 = migratePages(siteData.build.pages);
347028
347249
  const publicationBuild = { ...siteData.build, pages: pages2 };
347250
+ const allAssetIds = new Set(siteData.assets.map(({ id: id2 }) => id2));
347029
347251
  const allMdxAssetIds = getPublishedMdxAssetIds(siteData.assets);
347030
347252
  if (siteData.assetIndex === void 0 && (createPublishedBuildContentCompilationPlan(publicationBuild) !== void 0 || hasDynamicPublishedMdxSources(publicationBuild))) {
347031
347253
  throw new Error(
@@ -347087,6 +347309,7 @@ Please check webstudio --help for more details`
347087
347309
  build: publicationBuild,
347088
347310
  artifact: verifiedAssetIndex,
347089
347311
  allowUnresolved: true,
347312
+ allAssetIds,
347090
347313
  allMdxAssetIds
347091
347314
  });
347092
347315
  for (const blockInstanceId of getDynamicPublishedMdxSourceBlockIds(
@@ -347322,6 +347545,7 @@ Please check webstudio --help for more details`
347322
347545
  build: pageBuild,
347323
347546
  artifact: verifiedAssetIndex,
347324
347547
  blockInstanceIds: pendingBlockIds,
347548
+ allAssetIds,
347325
347549
  allMdxAssetIds
347326
347550
  }) : void 0;
347327
347551
  const materialized = await materializePublishedMdx({
@@ -347736,6 +347960,7 @@ Please check webstudio --help for more details`
347736
347960
 
347737
347961
 
347738
347962
  import type { PageMeta } from "@webstudio-is/sdk";
347963
+ import { toWebstudioParams } from "@webstudio-is/react-sdk";
347739
347964
  ${generateResources({
347740
347965
  scope: scope2,
347741
347966
  // XML generation removes the body wrapper from the instance map.