fern-api 0.30.6 → 0.30.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/bundle.cjs +71 -37
  2. package/package.json +1 -1
package/bundle.cjs CHANGED
@@ -1030261,7 +1030261,7 @@ var AccessTokenPosthogManager = class {
1030261
1030261
  properties: {
1030262
1030262
  ...event,
1030263
1030263
  ...event.properties,
1030264
- version: "0.30.6",
1030264
+ version: "0.30.7",
1030265
1030265
  usingAccessToken: true
1030266
1030266
  }
1030267
1030267
  });
@@ -1030323,7 +1030323,7 @@ var UserPosthogManager = class {
1030323
1030323
  distinctId: this.userId ?? await this.getPersistedDistinctId(),
1030324
1030324
  event: "CLI",
1030325
1030325
  properties: {
1030326
- version: "0.30.6",
1030326
+ version: "0.30.7",
1030327
1030327
  ...event,
1030328
1030328
  ...event.properties
1030329
1030329
  }
@@ -1056263,10 +1056263,10 @@ var CliContext = class {
1056263
1056263
  return "fern-api";
1056264
1056264
  }
1056265
1056265
  getPackageVersion() {
1056266
- if ("0.30.6" == null) {
1056266
+ if ("0.30.7" == null) {
1056267
1056267
  this.logger.error("CLI_VERSION is not defined");
1056268
1056268
  }
1056269
- return "0.30.6";
1056269
+ return "0.30.7";
1056270
1056270
  }
1056271
1056271
  getCliName() {
1056272
1056272
  if ("fern" == null) {
@@ -1073012,7 +1073012,10 @@ function isExternalUrl(url) {
1073012
1073012
  function replaceImagePathsAndUrls(markdown, fileIdsMap, markdownFilesToPathName, metadata, context) {
1073013
1073013
  const { content: content5, data: data2 } = (0, import_gray_matter.default)(markdown);
1073014
1073014
  let replacedContent = content5;
1073015
- const tree = fromMarkdown(content5);
1073015
+ const tree = fromMarkdown(content5, {
1073016
+ extensions: [mdx()],
1073017
+ mdastExtensions: [mdxFromMarkdown()]
1073018
+ });
1073016
1073019
  let offset2 = 0;
1073017
1073020
  visit2(tree, (node3) => {
1073018
1073021
  if (node3.position == null) {
@@ -1073021,8 +1073024,7 @@ function replaceImagePathsAndUrls(markdown, fileIdsMap, markdownFilesToPathName,
1073021
1073024
  const { start: start4, length } = getPosition(content5, node3.position);
1073022
1073025
  const original = replacedContent.slice(start4 + offset2, start4 + offset2 + length);
1073023
1073026
  let replaced = original;
1073024
- if (node3.type === "image") {
1073025
- const src = trimAnchor(node3.url);
1073027
+ function replaceSrc(src) {
1073026
1073028
  if (src != null && !isExternalUrl(src)) {
1073027
1073029
  try {
1073028
1073030
  const fileId = fileIdsMap.get(AbsoluteFilePath.of(src));
@@ -1073033,25 +1073035,11 @@ function replaceImagePathsAndUrls(markdown, fileIdsMap, markdownFilesToPathName,
1073033
1073035
  }
1073034
1073036
  }
1073035
1073037
  }
1073036
- if (node3.type === "html" || node3.type === "text") {
1073037
- const srcRegex = /src={?['"]([^'"]+)['"](?! \+)}?/g;
1073038
- let match;
1073039
- while ((match = srcRegex.exec(node3.value)) != null) {
1073040
- const pathToImage = trimAnchor(match[1]);
1073041
- if (pathToImage != null && !isExternalUrl(pathToImage)) {
1073042
- try {
1073043
- const fileId = fileIdsMap.get(AbsoluteFilePath.of(pathToImage));
1073044
- if (fileId != null) {
1073045
- replaced = replaced.replaceAll(pathToImage, `file:${fileId}`);
1073046
- }
1073047
- } catch (e) {
1073048
- }
1073049
- }
1073038
+ function replaceHref(href) {
1073039
+ if (href == null) {
1073040
+ return;
1073050
1073041
  }
1073051
- }
1073052
- if (node3.type === "link") {
1073053
- const href = trimAnchor(node3.url);
1073054
- if (href != null && (href.endsWith(".md") || href.endsWith(".mdx"))) {
1073042
+ if (href.endsWith(".md") || href.endsWith(".mdx")) {
1073055
1073043
  const absoluteFilePath = resolvePath(href, metadata);
1073056
1073044
  if (absoluteFilePath != null) {
1073057
1073045
  const pathName = markdownFilesToPathName.get(absoluteFilePath);
@@ -1073063,24 +1073051,70 @@ function replaceImagePathsAndUrls(markdown, fileIdsMap, markdownFilesToPathName,
1073063
1073051
  }
1073064
1073052
  }
1073065
1073053
  }
1073066
- if (node3.type === "html" || node3.type === "text") {
1073067
- const hrefRegex = /href={?['"]([^'"]+)['"](?! \+)}?/g;
1073054
+ if (node3.type === "image") {
1073055
+ const src = trimAnchor(node3.url);
1073056
+ replaceSrc(src);
1073057
+ }
1073058
+ if (node3.type === "mdxJsxFlowElement" || node3.type === "mdxJsxTextElement") {
1073059
+ if (node3.name && MEDIA_NODE_NAMES.includes(node3.name)) {
1073060
+ const srcAttr = node3.attributes.find((attr) => attr.type === "mdxJsxAttribute" && attr.name === "src");
1073061
+ if (srcAttr == null ? void 0 : srcAttr.value) {
1073062
+ let srcValue = srcAttr.value;
1073063
+ if (typeof srcValue !== "string") {
1073064
+ const match = srcValue.value.match(STR_REGEX);
1073065
+ if (match == null ? void 0 : match[1]) {
1073066
+ srcValue = match[1];
1073067
+ }
1073068
+ }
1073069
+ const pathToImage = trimAnchor(srcValue);
1073070
+ replaceSrc(pathToImage);
1073071
+ }
1073072
+ } else {
1073073
+ node3.attributes.forEach((attr) => {
1073074
+ if (attr.type === "mdxJsxAttribute" && attr.value && typeof attr.value !== "string") {
1073075
+ const match = SRC_REGEX.exec(attr.value.value);
1073076
+ if (match == null ? void 0 : match[1]) {
1073077
+ const pathToImage = trimAnchor(match[1]);
1073078
+ replaceSrc(pathToImage);
1073079
+ }
1073080
+ }
1073081
+ });
1073082
+ }
1073083
+ }
1073084
+ if (node3.type === "html" || node3.type === "text" || node3.type === "mdxTextExpression") {
1073085
+ const srcRegex = /src={?['"]([^'"]+)['"](?! \+)}?/g;
1073068
1073086
  let match;
1073069
- while ((match = hrefRegex.exec(node3.value)) != null) {
1073070
- const href = trimAnchor(match[1]);
1073071
- if (href != null && (href.endsWith(".md") || href.endsWith(".mdx"))) {
1073072
- const absoluteFilePath = resolvePath(href, metadata);
1073073
- if (absoluteFilePath != null) {
1073074
- const pathName = markdownFilesToPathName.get(absoluteFilePath);
1073075
- if (pathName != null) {
1073076
- replaced = replaced.replaceAll(href, pathName);
1073077
- } else {
1073078
- context.logger.error(`${relative(metadata.absolutePathToFernFolder, absoluteFilePath)} has no slug defined but is referenced by ${relative(metadata.absolutePathToFernFolder, metadata.absolutePathToMdx)}`);
1073087
+ while ((match = srcRegex.exec(node3.value)) != null) {
1073088
+ const pathToImage = trimAnchor(match[1]);
1073089
+ replaceSrc(pathToImage);
1073090
+ }
1073091
+ }
1073092
+ if (node3.type === "link") {
1073093
+ replaceHref(trimAnchor(node3.url));
1073094
+ }
1073095
+ if (node3.type === "mdxJsxFlowElement" || node3.type === "mdxJsxTextElement") {
1073096
+ if (node3.name === "a") {
1073097
+ const hrefAttr = node3.attributes.find((attr) => attr.type === "mdxJsxAttribute" && attr.name === "href");
1073098
+ if (hrefAttr == null ? void 0 : hrefAttr.value) {
1073099
+ let href = hrefAttr.value;
1073100
+ if (typeof href !== "string") {
1073101
+ const match = href.value.match(STR_REGEX);
1073102
+ if (match == null ? void 0 : match[1]) {
1073103
+ href = match[1];
1073079
1073104
  }
1073080
1073105
  }
1073106
+ replaceHref(trimAnchor(href));
1073081
1073107
  }
1073082
1073108
  }
1073083
1073109
  }
1073110
+ if (node3.type === "html" || node3.type === "text" || node3.type === "mdxTextExpression") {
1073111
+ const hrefRegex = /href={?['"]([^'"]+)['"](?! \+)}?/g;
1073112
+ let match;
1073113
+ while ((match = hrefRegex.exec(node3.value)) != null) {
1073114
+ const href = trimAnchor(match[1]);
1073115
+ replaceHref(href);
1073116
+ }
1073117
+ }
1073084
1073118
  if (replaced === original) {
1073085
1073119
  return;
1073086
1073120
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fern-api",
3
- "version": "0.30.6",
3
+ "version": "0.30.7",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/fern-api/fern.git",