@rspress/plugin-llms 2.0.0-beta.20 → 2.0.0-beta.21

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.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import type { PageIndexInfo } from '@rspress/shared';
2
- import type { RspressPlugin } from '@rspress/shared';
1
+ import type { PageIndexInfo } from 'rspress/core';
2
+ import type { RspressPlugin } from 'rspress/core';
3
3
 
4
4
  declare interface LlmsFullTxt {
5
5
  /**
package/dist/index.js CHANGED
@@ -1,121 +1,10 @@
1
- /*! For license information please see index.js.LICENSE.txt */
2
1
  import node_path from "node:path";
3
- import { getSidebarDataGroup, normalizeHref, withBase } from "@rspress/shared";
4
- import { logger } from "@rspress/shared/logger";
5
- import { remarkPluginNormalizeLink } from "@rspress/core";
2
+ import { getSidebarDataGroup, logger, matchPath, normalizeHref, remarkFileCodeBlock, remarkPluginNormalizeLink, withBase } from "rspress/core";
6
3
  import remark_mdx from "remark-mdx";
7
4
  import remark_parse from "remark-parse";
8
5
  import remark_stringify from "remark-stringify";
9
6
  import { unified } from "unified";
10
7
  import { SKIP, visit } from "unist-util-visit";
11
- var router_Action;
12
- (function(Action) {
13
- Action["Pop"] = "POP";
14
- Action["Push"] = "PUSH";
15
- Action["Replace"] = "REPLACE";
16
- })(router_Action || (router_Action = {}));
17
- function warning(cond, message) {
18
- if (!cond) {
19
- if ("undefined" != typeof console) console.warn(message);
20
- try {
21
- throw new Error(message);
22
- } catch (e) {}
23
- }
24
- }
25
- var router_ResultType;
26
- (function(ResultType) {
27
- ResultType["data"] = "data";
28
- ResultType["deferred"] = "deferred";
29
- ResultType["redirect"] = "redirect";
30
- ResultType["error"] = "error";
31
- })(router_ResultType || (router_ResultType = {}));
32
- new Set([
33
- "lazy",
34
- "caseSensitive",
35
- "path",
36
- "id",
37
- "index",
38
- "children"
39
- ]);
40
- function matchPath(pattern, pathname) {
41
- if ("string" == typeof pattern) pattern = {
42
- path: pattern,
43
- caseSensitive: false,
44
- end: true
45
- };
46
- let [matcher, compiledParams] = compilePath(pattern.path, pattern.caseSensitive, pattern.end);
47
- let match = pathname.match(matcher);
48
- if (!match) return null;
49
- let matchedPathname = match[0];
50
- let pathnameBase = matchedPathname.replace(/(.)\/+$/, "$1");
51
- let captureGroups = match.slice(1);
52
- let params = compiledParams.reduce((memo, _ref, index)=>{
53
- let { paramName, isOptional } = _ref;
54
- if ("*" === paramName) {
55
- let splatValue = captureGroups[index] || "";
56
- pathnameBase = matchedPathname.slice(0, matchedPathname.length - splatValue.length).replace(/(.)\/+$/, "$1");
57
- }
58
- const value = captureGroups[index];
59
- if (isOptional && !value) memo[paramName] = void 0;
60
- else memo[paramName] = (value || "").replace(/%2F/g, "/");
61
- return memo;
62
- }, {});
63
- return {
64
- params,
65
- pathname: matchedPathname,
66
- pathnameBase,
67
- pattern
68
- };
69
- }
70
- function compilePath(path, caseSensitive, end) {
71
- if (void 0 === caseSensitive) caseSensitive = false;
72
- if (void 0 === end) end = true;
73
- warning("*" === path || !path.endsWith("*") || path.endsWith("/*"), "Route path \"" + path + '" will be treated as if it were "' + path.replace(/\*$/, "/*") + '" because the `*` character must always follow a `/` in the pattern. To get rid of this warning, please change the route path to "' + path.replace(/\*$/, "/*") + "\".");
74
- let params = [];
75
- let regexpSource = "^" + path.replace(/\/*\*?$/, "").replace(/^\/*/, "/").replace(/[\\.*+^${}|()[\]]/g, "\\$&").replace(/\/:([\w-]+)(\?)?/g, (_, paramName, isOptional)=>{
76
- params.push({
77
- paramName,
78
- isOptional: null != isOptional
79
- });
80
- return isOptional ? "/?([^\\/]+)?" : "/([^\\/]+)";
81
- });
82
- if (path.endsWith("*")) {
83
- params.push({
84
- paramName: "*"
85
- });
86
- regexpSource += "*" === path || "/*" === path ? "(.*)$" : "(?:\\/(.+)|\\/*)$";
87
- } else if (end) regexpSource += "\\/*$";
88
- else if ("" !== path && "/" !== path) regexpSource += "(?:(?=\\/|$))";
89
- let matcher = new RegExp(regexpSource, caseSensitive ? void 0 : "i");
90
- return [
91
- matcher,
92
- params
93
- ];
94
- }
95
- const validMutationMethodsArr = [
96
- "post",
97
- "put",
98
- "patch",
99
- "delete"
100
- ];
101
- new Set(validMutationMethodsArr);
102
- const validRequestMethodsArr = [
103
- "get",
104
- ...validMutationMethodsArr
105
- ];
106
- new Set(validRequestMethodsArr);
107
- new Set([
108
- 301,
109
- 302,
110
- 303,
111
- 307,
112
- 308
113
- ]);
114
- new Set([
115
- 307,
116
- 308
117
- ]);
118
- Symbol("deferred");
119
8
  function routePathToMdPath(routePath, base) {
120
9
  let url = routePath;
121
10
  url = normalizeHref(url, false);
@@ -201,7 +90,9 @@ const mdxToMdPlugin = ()=>(tree)=>{
201
90
  });
202
91
  };
203
92
  function mdxToMd(content, filepath, routeService, base) {
204
- return unified().use(remark_parse).use(remark_mdx).use(mdxToMdPlugin).use(remarkPluginNormalizeLink, {
93
+ return unified().use(remark_parse).use(remark_mdx).use(remarkFileCodeBlock, {
94
+ filepath
95
+ }).use(mdxToMdPlugin).use(remarkPluginNormalizeLink, {
205
96
  cleanUrls: '.md',
206
97
  routeService,
207
98
  __base: base
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rspress/plugin-llms",
3
- "version": "2.0.0-beta.20",
3
+ "version": "2.0.0-beta.21",
4
4
  "description": "A plugin for rspress to generate llms.txt, llms-full.txt, md files to let llm understand your website.",
5
5
  "bugs": "https://github.com/web-infra-dev/rspress/issues",
6
6
  "repository": {
@@ -23,22 +23,20 @@
23
23
  "remark-stringify": "^11.0.0",
24
24
  "unified": "^11.0.5",
25
25
  "unist-util-visit": "^5.0.0",
26
- "unist-util-visit-children": "^3.0.0",
27
- "@rspress/shared": "2.0.0-beta.20"
26
+ "unist-util-visit-children": "^3.0.0"
28
27
  },
29
28
  "devDependencies": {
30
29
  "@microsoft/api-extractor": "^7.52.8",
31
- "@rsbuild/core": "~1.4.3",
32
- "@rslib/core": "0.10.4",
30
+ "@rsbuild/core": "~1.4.6",
31
+ "@rslib/core": "0.10.5",
33
32
  "@types/hast": "^3.0.4",
34
33
  "@types/node": "^22.8.1",
35
34
  "typescript": "^5.8.2",
36
35
  "vfile": "^6.0.3",
37
- "@rspress/config": "1.0.0",
38
- "@rspress/runtime": "2.0.0-beta.20"
36
+ "@rspress/config": "1.0.0"
39
37
  },
40
38
  "peerDependencies": {
41
- "@rspress/core": "^2.0.0-beta.20"
39
+ "rspress": "^2.0.0-beta.21"
42
40
  },
43
41
  "engines": {
44
42
  "node": ">=18.0.0"
@@ -1,10 +0,0 @@
1
- /**
2
- * @remix-run/router v1.22.0
3
- *
4
- * Copyright (c) Remix Software Inc.
5
- *
6
- * This source code is licensed under the MIT license found in the
7
- * LICENSE.md file in the root directory of this source tree.
8
- *
9
- * @license MIT
10
- */