fumadocs-openapi 10.2.1 → 10.2.3

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 (278) hide show
  1. package/dist/generate-file.d.ts +53 -49
  2. package/dist/generate-file.d.ts.map +1 -1
  3. package/dist/generate-file.js +88 -102
  4. package/dist/generate-file.js.map +1 -0
  5. package/dist/index.d.ts +6 -6
  6. package/dist/index.js +3 -1
  7. package/dist/playground/client.d.ts +88 -72
  8. package/dist/playground/client.d.ts.map +1 -1
  9. package/dist/playground/client.js +446 -296
  10. package/dist/playground/client.js.map +1 -0
  11. package/dist/playground/components/inputs.js +395 -172
  12. package/dist/playground/components/inputs.js.map +1 -0
  13. package/dist/playground/components/oauth-dialog.js +270 -174
  14. package/dist/playground/components/oauth-dialog.js.map +1 -0
  15. package/dist/playground/components/server-select.js +115 -55
  16. package/dist/playground/components/server-select.js.map +1 -0
  17. package/dist/playground/fetcher.d.ts +10 -18
  18. package/dist/playground/fetcher.d.ts.map +1 -1
  19. package/dist/playground/fetcher.js +67 -75
  20. package/dist/playground/fetcher.js.map +1 -0
  21. package/dist/playground/get-default-values.js +23 -26
  22. package/dist/playground/get-default-values.js.map +1 -0
  23. package/dist/playground/index.d.ts +23 -13
  24. package/dist/playground/index.d.ts.map +1 -1
  25. package/dist/playground/index.js +87 -91
  26. package/dist/playground/index.js.map +1 -0
  27. package/dist/playground/lazy.js +9 -2
  28. package/dist/playground/lazy.js.map +1 -0
  29. package/dist/playground/schema.d.ts +18 -55
  30. package/dist/playground/schema.d.ts.map +1 -1
  31. package/dist/playground/schema.js +117 -106
  32. package/dist/playground/schema.js.map +1 -0
  33. package/dist/playground/status-info.js +49 -37
  34. package/dist/playground/status-info.js.map +1 -0
  35. package/dist/requests/generators/csharp.js +40 -50
  36. package/dist/requests/generators/csharp.js.map +1 -0
  37. package/dist/requests/generators/curl.js +28 -27
  38. package/dist/requests/generators/curl.js.map +1 -0
  39. package/dist/requests/generators/go.js +39 -35
  40. package/dist/requests/generators/go.js.map +1 -0
  41. package/dist/requests/generators/index.js +49 -43
  42. package/dist/requests/generators/index.js.map +1 -0
  43. package/dist/requests/generators/java.js +56 -67
  44. package/dist/requests/generators/java.js.map +1 -0
  45. package/dist/requests/generators/javascript.js +38 -45
  46. package/dist/requests/generators/javascript.js.map +1 -0
  47. package/dist/requests/generators/python.js +33 -37
  48. package/dist/requests/generators/python.js.map +1 -0
  49. package/dist/requests/media/adapter.d.ts +38 -84
  50. package/dist/requests/media/adapter.d.ts.map +1 -1
  51. package/dist/requests/media/adapter.js +122 -169
  52. package/dist/requests/media/adapter.js.map +1 -0
  53. package/dist/requests/media/encode.d.ts +12 -7
  54. package/dist/requests/media/encode.d.ts.map +1 -1
  55. package/dist/requests/media/encode.js +129 -109
  56. package/dist/requests/media/encode.js.map +1 -0
  57. package/dist/requests/media/resolve-adapter.js +28 -28
  58. package/dist/requests/media/resolve-adapter.js.map +1 -0
  59. package/dist/requests/string-utils.js +28 -35
  60. package/dist/requests/string-utils.js.map +1 -0
  61. package/dist/requests/to-python-object.js +16 -28
  62. package/dist/requests/to-python-object.js.map +1 -0
  63. package/dist/requests/types.d.ts +25 -21
  64. package/dist/requests/types.d.ts.map +1 -1
  65. package/dist/scalar/client.js +57 -20
  66. package/dist/scalar/client.js.map +1 -0
  67. package/dist/scalar/index.d.ts +8 -2
  68. package/dist/scalar/index.d.ts.map +1 -1
  69. package/dist/scalar/index.js +29 -19
  70. package/dist/scalar/index.js.map +1 -0
  71. package/dist/server/create.d.ts +29 -25
  72. package/dist/server/create.d.ts.map +1 -1
  73. package/dist/server/create.js +42 -39
  74. package/dist/server/create.js.map +1 -0
  75. package/dist/server/index.d.ts +3 -3
  76. package/dist/server/index.js +4 -2
  77. package/dist/server/proxy.d.ts +28 -28
  78. package/dist/server/proxy.d.ts.map +1 -1
  79. package/dist/server/proxy.js +58 -75
  80. package/dist/server/proxy.js.map +1 -0
  81. package/dist/server/source-api.d.ts +32 -25
  82. package/dist/server/source-api.d.ts.map +1 -1
  83. package/dist/server/source-api.js +82 -69
  84. package/dist/server/source-api.js.map +1 -0
  85. package/dist/types.d.ts +41 -36
  86. package/dist/types.d.ts.map +1 -1
  87. package/dist/ui/api-page.d.ts +140 -136
  88. package/dist/ui/api-page.d.ts.map +1 -1
  89. package/dist/ui/api-page.js +134 -118
  90. package/dist/ui/api-page.js.map +1 -0
  91. package/dist/ui/client/index.d.ts +30 -26
  92. package/dist/ui/client/index.d.ts.map +1 -1
  93. package/dist/ui/client/index.js +8 -2
  94. package/dist/ui/client/index.js.map +1 -0
  95. package/dist/ui/client/storage-key.js +16 -10
  96. package/dist/ui/client/storage-key.js.map +1 -0
  97. package/dist/ui/components/accordion.js +40 -14
  98. package/dist/ui/components/accordion.js.map +1 -0
  99. package/dist/ui/components/dialog.js +51 -15
  100. package/dist/ui/components/dialog.js.map +1 -0
  101. package/dist/ui/components/input.js +18 -8
  102. package/dist/ui/components/input.js.map +1 -0
  103. package/dist/ui/components/method-label.js +38 -33
  104. package/dist/ui/components/method-label.js.map +1 -0
  105. package/dist/ui/components/select.js +66 -15
  106. package/dist/ui/components/select.js.map +1 -0
  107. package/dist/ui/contexts/api.js +96 -85
  108. package/dist/ui/contexts/api.js.map +1 -0
  109. package/dist/ui/contexts/api.lazy.js +9 -2
  110. package/dist/ui/contexts/api.lazy.js.map +1 -0
  111. package/dist/ui/index.d.ts +2 -2
  112. package/dist/ui/index.js +3 -1
  113. package/dist/ui/operation/client.js +65 -27
  114. package/dist/ui/operation/client.js.map +1 -0
  115. package/dist/ui/operation/index.js +403 -186
  116. package/dist/ui/operation/index.js.map +1 -0
  117. package/dist/ui/operation/request-tabs.d.ts +15 -16
  118. package/dist/ui/operation/request-tabs.d.ts.map +1 -1
  119. package/dist/ui/operation/request-tabs.js +151 -131
  120. package/dist/ui/operation/request-tabs.js.map +1 -0
  121. package/dist/ui/operation/response-tabs.d.ts +27 -28
  122. package/dist/ui/operation/response-tabs.d.ts.map +1 -1
  123. package/dist/ui/operation/response-tabs.js +73 -56
  124. package/dist/ui/operation/response-tabs.js.map +1 -0
  125. package/dist/ui/operation/usage-tabs/client.js +117 -88
  126. package/dist/ui/operation/usage-tabs/client.js.map +1 -0
  127. package/dist/ui/operation/usage-tabs/index.d.ts +22 -21
  128. package/dist/ui/operation/usage-tabs/index.d.ts.map +1 -1
  129. package/dist/ui/operation/usage-tabs/index.js +63 -48
  130. package/dist/ui/operation/usage-tabs/index.js.map +1 -0
  131. package/dist/ui/operation/usage-tabs/lazy.js +11 -4
  132. package/dist/ui/operation/usage-tabs/lazy.js.map +1 -0
  133. package/dist/ui/schema/client.d.ts +11 -7
  134. package/dist/ui/schema/client.d.ts.map +1 -1
  135. package/dist/ui/schema/client.js +213 -127
  136. package/dist/ui/schema/client.js.map +1 -0
  137. package/dist/ui/schema/index.d.ts +51 -50
  138. package/dist/ui/schema/index.d.ts.map +1 -1
  139. package/dist/ui/schema/index.js +225 -248
  140. package/dist/ui/schema/index.js.map +1 -0
  141. package/dist/ui/schema/lazy.js +9 -2
  142. package/dist/ui/schema/lazy.js.map +1 -0
  143. package/dist/utils/cn.js +3 -1
  144. package/dist/utils/deep-equal.js +18 -26
  145. package/dist/utils/deep-equal.js.map +1 -0
  146. package/dist/utils/get-typescript-schema.js +21 -19
  147. package/dist/utils/get-typescript-schema.js.map +1 -0
  148. package/dist/utils/id-to-title.js +13 -16
  149. package/dist/utils/id-to-title.js.map +1 -0
  150. package/dist/utils/lazy.js +13 -11
  151. package/dist/utils/lazy.js.map +1 -0
  152. package/dist/utils/merge-schema.js +130 -174
  153. package/dist/utils/merge-schema.js.map +1 -0
  154. package/dist/utils/pages/builder.d.ts +80 -76
  155. package/dist/utils/pages/builder.d.ts.map +1 -1
  156. package/dist/utils/pages/builder.js +101 -118
  157. package/dist/utils/pages/builder.js.map +1 -0
  158. package/dist/utils/pages/preset-auto.d.ts +58 -55
  159. package/dist/utils/pages/preset-auto.d.ts.map +1 -1
  160. package/dist/utils/pages/preset-auto.js +124 -137
  161. package/dist/utils/pages/preset-auto.js.map +1 -0
  162. package/dist/utils/pages/to-body.js +21 -18
  163. package/dist/utils/pages/to-body.js.map +1 -0
  164. package/dist/utils/pages/to-static-data.js +48 -40
  165. package/dist/utils/pages/to-static-data.js.map +1 -0
  166. package/dist/utils/pages/to-text.d.ts +43 -41
  167. package/dist/utils/pages/to-text.d.ts.map +1 -1
  168. package/dist/utils/pages/to-text.js +93 -126
  169. package/dist/utils/pages/to-text.js.map +1 -0
  170. package/dist/utils/process-document.d.ts +18 -19
  171. package/dist/utils/process-document.d.ts.map +1 -1
  172. package/dist/utils/process-document.js +43 -54
  173. package/dist/utils/process-document.js.map +1 -0
  174. package/dist/utils/remove-undefined.js +18 -18
  175. package/dist/utils/remove-undefined.js.map +1 -0
  176. package/dist/utils/schema-to-string.js +46 -64
  177. package/dist/utils/schema-to-string.js.map +1 -0
  178. package/dist/utils/schema.d.ts +11 -27
  179. package/dist/utils/schema.d.ts.map +1 -1
  180. package/dist/utils/schema.js +43 -44
  181. package/dist/utils/schema.js.map +1 -0
  182. package/dist/utils/url.js +35 -56
  183. package/dist/utils/url.js.map +1 -0
  184. package/dist/utils/use-query.js +39 -33
  185. package/dist/utils/use-query.js.map +1 -0
  186. package/package.json +35 -34
  187. package/dist/index.d.ts.map +0 -1
  188. package/dist/playground/components/inputs.d.ts +0 -25
  189. package/dist/playground/components/inputs.d.ts.map +0 -1
  190. package/dist/playground/components/oauth-dialog.d.ts +0 -13
  191. package/dist/playground/components/oauth-dialog.d.ts.map +0 -1
  192. package/dist/playground/components/server-select.d.ts +0 -3
  193. package/dist/playground/components/server-select.d.ts.map +0 -1
  194. package/dist/playground/get-default-values.d.ts +0 -3
  195. package/dist/playground/get-default-values.d.ts.map +0 -1
  196. package/dist/playground/lazy.d.ts +0 -2
  197. package/dist/playground/lazy.d.ts.map +0 -1
  198. package/dist/playground/status-info.d.ts +0 -8
  199. package/dist/playground/status-info.d.ts.map +0 -1
  200. package/dist/requests/generators/csharp.d.ts +0 -3
  201. package/dist/requests/generators/csharp.d.ts.map +0 -1
  202. package/dist/requests/generators/curl.d.ts +0 -3
  203. package/dist/requests/generators/curl.d.ts.map +0 -1
  204. package/dist/requests/generators/go.d.ts +0 -3
  205. package/dist/requests/generators/go.d.ts.map +0 -1
  206. package/dist/requests/generators/index.d.ts +0 -3
  207. package/dist/requests/generators/index.d.ts.map +0 -1
  208. package/dist/requests/generators/java.d.ts +0 -3
  209. package/dist/requests/generators/java.d.ts.map +0 -1
  210. package/dist/requests/generators/javascript.d.ts +0 -3
  211. package/dist/requests/generators/javascript.d.ts.map +0 -1
  212. package/dist/requests/generators/python.d.ts +0 -3
  213. package/dist/requests/generators/python.d.ts.map +0 -1
  214. package/dist/requests/media/resolve-adapter.d.ts +0 -19
  215. package/dist/requests/media/resolve-adapter.d.ts.map +0 -1
  216. package/dist/requests/string-utils.d.ts +0 -7
  217. package/dist/requests/string-utils.d.ts.map +0 -1
  218. package/dist/requests/to-python-object.d.ts +0 -2
  219. package/dist/requests/to-python-object.d.ts.map +0 -1
  220. package/dist/requests/types.js +0 -1
  221. package/dist/scalar/client.d.ts +0 -7
  222. package/dist/scalar/client.d.ts.map +0 -1
  223. package/dist/server/index.d.ts.map +0 -1
  224. package/dist/types.js +0 -1
  225. package/dist/ui/client/storage-key.d.ts +0 -9
  226. package/dist/ui/client/storage-key.d.ts.map +0 -1
  227. package/dist/ui/components/accordion.d.ts +0 -8
  228. package/dist/ui/components/accordion.d.ts.map +0 -1
  229. package/dist/ui/components/dialog.d.ts +0 -20
  230. package/dist/ui/components/dialog.d.ts.map +0 -1
  231. package/dist/ui/components/input.d.ts +0 -6
  232. package/dist/ui/components/input.d.ts.map +0 -1
  233. package/dist/ui/components/method-label.d.ts +0 -10
  234. package/dist/ui/components/method-label.d.ts.map +0 -1
  235. package/dist/ui/components/select.d.ts +0 -14
  236. package/dist/ui/components/select.d.ts.map +0 -1
  237. package/dist/ui/contexts/api.d.ts +0 -33
  238. package/dist/ui/contexts/api.d.ts.map +0 -1
  239. package/dist/ui/contexts/api.lazy.d.ts +0 -2
  240. package/dist/ui/contexts/api.lazy.d.ts.map +0 -1
  241. package/dist/ui/icons.d.ts +0 -49
  242. package/dist/ui/icons.d.ts.map +0 -1
  243. package/dist/ui/icons.js +0 -281
  244. package/dist/ui/index.d.ts.map +0 -1
  245. package/dist/ui/operation/client.d.ts +0 -19
  246. package/dist/ui/operation/client.d.ts.map +0 -1
  247. package/dist/ui/operation/index.d.ts +0 -12
  248. package/dist/ui/operation/index.d.ts.map +0 -1
  249. package/dist/ui/operation/usage-tabs/client.d.ts +0 -23
  250. package/dist/ui/operation/usage-tabs/client.d.ts.map +0 -1
  251. package/dist/ui/operation/usage-tabs/lazy.d.ts +0 -4
  252. package/dist/ui/operation/usage-tabs/lazy.d.ts.map +0 -1
  253. package/dist/ui/schema/lazy.d.ts +0 -2
  254. package/dist/ui/schema/lazy.d.ts.map +0 -1
  255. package/dist/utils/cn.d.ts +0 -2
  256. package/dist/utils/cn.d.ts.map +0 -1
  257. package/dist/utils/deep-equal.d.ts +0 -2
  258. package/dist/utils/deep-equal.d.ts.map +0 -1
  259. package/dist/utils/get-typescript-schema.d.ts +0 -4
  260. package/dist/utils/get-typescript-schema.d.ts.map +0 -1
  261. package/dist/utils/id-to-title.d.ts +0 -2
  262. package/dist/utils/id-to-title.d.ts.map +0 -1
  263. package/dist/utils/lazy.d.ts +0 -5
  264. package/dist/utils/lazy.d.ts.map +0 -1
  265. package/dist/utils/merge-schema.d.ts +0 -7
  266. package/dist/utils/merge-schema.d.ts.map +0 -1
  267. package/dist/utils/pages/to-body.d.ts +0 -4
  268. package/dist/utils/pages/to-body.d.ts.map +0 -1
  269. package/dist/utils/pages/to-static-data.d.ts +0 -10
  270. package/dist/utils/pages/to-static-data.d.ts.map +0 -1
  271. package/dist/utils/remove-undefined.d.ts +0 -2
  272. package/dist/utils/remove-undefined.d.ts.map +0 -1
  273. package/dist/utils/schema-to-string.d.ts +0 -8
  274. package/dist/utils/schema-to-string.d.ts.map +0 -1
  275. package/dist/utils/url.d.ts +0 -11
  276. package/dist/utils/url.d.ts.map +0 -1
  277. package/dist/utils/use-query.d.ts +0 -8
  278. package/dist/utils/use-query.d.ts.map +0 -1
@@ -1,138 +1,125 @@
1
- import * as path from 'node:path';
2
- import { isUrl } from '../../utils/url.js';
3
- export function createAutoPreset(options) {
4
- if (options.per === 'custom')
5
- return options;
6
- const { slugify = (s) => {
7
- return s.replace(/\s+/g, '-').toLowerCase();
8
- }, } = options;
9
- let nameFn;
10
- if (typeof options.name === 'function') {
11
- nameFn = options.name;
12
- }
13
- else {
14
- const { algorithm = 'v2' } = options.name ?? {};
15
- nameFn = function (result, document) {
16
- if (result.type === 'tag') {
17
- return slugify(result.tag);
18
- }
19
- if (result.type === 'group') {
20
- const schemaId = result.schemaId;
21
- return isUrl(schemaId)
22
- ? 'index'
23
- : path.basename(schemaId, path.extname(schemaId));
24
- }
25
- if (result.type === 'operation') {
26
- const operation = document.paths[result.item.path][result.item.method];
27
- if (algorithm === 'v2' && operation.operationId) {
28
- return operation.operationId;
29
- }
30
- return path.join(this.routePathToFilePath(result.item.path), result.item.method.toLowerCase());
31
- }
32
- const hook = document.webhooks[result.item.name][result.item.method];
33
- if (algorithm === 'v2' && hook.operationId) {
34
- return hook.operationId;
35
- }
36
- return slugify(result.item.name);
37
- };
38
- }
39
- function groupOutput(builder, entry) {
40
- const { dereferenced } = builder.document;
41
- const { groupBy = 'none' } = options;
42
- if (groupBy === 'route') {
43
- return [
44
- path.join(builder.routePathToFilePath(entry.type === 'operation' ? entry.item.path : entry.item.name), `${entry.item.method.toLowerCase()}.mdx`),
45
- ];
46
- }
47
- const file = nameFn.call(builder, entry, dereferenced);
48
- if (groupBy === 'tag') {
49
- let tags = entry.type === 'operation'
50
- ? dereferenced.paths[entry.item.path][entry.item.method].tags
51
- : dereferenced.webhooks[entry.item.name][entry.item.method].tags;
52
- if (!tags || tags.length === 0) {
53
- console.warn('When `groupBy` is set to `tag`, make sure a `tags` is defined for every operation schema.');
54
- tags = ['unknown'];
55
- }
56
- return tags.map((tag) => path.join(slugify(tag), `${file}.mdx`));
57
- }
58
- if (typeof groupBy === 'function') {
59
- return [path.join(slugify(groupBy(entry)), `${file}.mdx`)];
60
- }
61
- return [`${file}.mdx`];
62
- }
63
- return {
64
- toPages(builder) {
65
- const { dereferenced } = builder.document;
66
- const items = builder.extract();
67
- if (options.per === 'file') {
68
- const entry = {
69
- type: 'group',
70
- schemaId: builder.id,
71
- path: '',
72
- info: {
73
- title: dereferenced.info.title,
74
- description: dereferenced.info.description,
75
- },
76
- ...items,
77
- };
78
- entry.path = nameFn.call(builder, entry, dereferenced) + '.mdx';
79
- builder.create(entry);
80
- return;
81
- }
82
- if (options.per === 'tag') {
83
- const tags = dereferenced.tags ?? [];
84
- for (const tag of tags) {
85
- const { displayName } = builder.fromTag(tag);
86
- const entry = {
87
- type: 'tag',
88
- path: '',
89
- schemaId: builder.id,
90
- info: {
91
- title: displayName,
92
- description: tag.description,
93
- },
94
- webhooks: items.webhooks.filter((webhook) => webhook.tags?.includes(tag.name)),
95
- operations: items.operations.filter((op) => op.tags?.includes(tag.name)),
96
- tag: tag.name,
97
- rawTag: tag,
98
- };
99
- entry.path = nameFn.call(builder, entry, dereferenced) + '.mdx';
100
- builder.create(entry);
101
- }
102
- return;
103
- }
104
- for (const op of items.operations) {
105
- const { pathItem, operation, displayName } = builder.fromExtractedOperation(op);
106
- const entry = {
107
- type: 'operation',
108
- schemaId: builder.id,
109
- item: op,
110
- path: '',
111
- info: {
112
- title: displayName,
113
- description: operation.description ?? pathItem.description,
114
- },
115
- };
116
- for (const outputPath of groupOutput(builder, entry)) {
117
- builder.create({ ...entry, path: outputPath });
118
- }
119
- }
120
- for (const webhook of items.webhooks) {
121
- const { pathItem, operation, displayName } = builder.fromExtractedWebhook(webhook);
122
- const entry = {
123
- type: 'webhook',
124
- schemaId: builder.id,
125
- info: {
126
- title: displayName,
127
- description: operation.description ?? pathItem.description,
128
- },
129
- item: webhook,
130
- path: '',
131
- };
132
- for (const outputPath of groupOutput(builder, entry)) {
133
- builder.create({ ...entry, path: outputPath });
134
- }
135
- }
136
- },
137
- };
1
+ import { isUrl } from "../url.js";
2
+ import * as path from "node:path";
3
+
4
+ //#region src/utils/pages/preset-auto.ts
5
+ function createAutoPreset(options) {
6
+ if (options.per === "custom") return options;
7
+ const { slugify = (s) => {
8
+ return s.replace(/\s+/g, "-").toLowerCase();
9
+ } } = options;
10
+ let nameFn;
11
+ if (typeof options.name === "function") nameFn = options.name;
12
+ else {
13
+ const { algorithm = "v2" } = options.name ?? {};
14
+ nameFn = function(result, document) {
15
+ if (result.type === "tag") return slugify(result.tag);
16
+ if (result.type === "group") {
17
+ const schemaId = result.schemaId;
18
+ return isUrl(schemaId) ? "index" : path.basename(schemaId, path.extname(schemaId));
19
+ }
20
+ if (result.type === "operation") {
21
+ const operation = document.paths[result.item.path][result.item.method];
22
+ if (algorithm === "v2" && operation.operationId) return operation.operationId;
23
+ return path.join(this.routePathToFilePath(result.item.path), result.item.method.toLowerCase());
24
+ }
25
+ const hook = document.webhooks[result.item.name][result.item.method];
26
+ if (algorithm === "v2" && hook.operationId) return hook.operationId;
27
+ return slugify(result.item.name);
28
+ };
29
+ }
30
+ function groupOutput(builder, entry) {
31
+ const { dereferenced } = builder.document;
32
+ const { groupBy = "none" } = options;
33
+ if (groupBy === "route") return [path.join(builder.routePathToFilePath(entry.type === "operation" ? entry.item.path : entry.item.name), `${entry.item.method.toLowerCase()}.mdx`)];
34
+ const file = nameFn.call(builder, entry, dereferenced);
35
+ if (groupBy === "tag") {
36
+ let tags = entry.type === "operation" ? dereferenced.paths[entry.item.path][entry.item.method].tags : dereferenced.webhooks[entry.item.name][entry.item.method].tags;
37
+ if (!tags || tags.length === 0) {
38
+ console.warn("When `groupBy` is set to `tag`, make sure a `tags` is defined for every operation schema.");
39
+ tags = ["unknown"];
40
+ }
41
+ return tags.map((tag) => path.join(slugify(tag), `${file}.mdx`));
42
+ }
43
+ if (typeof groupBy === "function") return [path.join(slugify(groupBy(entry)), `${file}.mdx`)];
44
+ return [`${file}.mdx`];
45
+ }
46
+ return { toPages(builder) {
47
+ const { dereferenced } = builder.document;
48
+ const items = builder.extract();
49
+ if (options.per === "file") {
50
+ const entry = {
51
+ type: "group",
52
+ schemaId: builder.id,
53
+ path: "",
54
+ info: {
55
+ title: dereferenced.info.title,
56
+ description: dereferenced.info.description
57
+ },
58
+ ...items
59
+ };
60
+ entry.path = nameFn.call(builder, entry, dereferenced) + ".mdx";
61
+ builder.create(entry);
62
+ return;
63
+ }
64
+ if (options.per === "tag") {
65
+ const tags = dereferenced.tags ?? [];
66
+ for (const tag of tags) {
67
+ const { displayName } = builder.fromTag(tag);
68
+ const entry = {
69
+ type: "tag",
70
+ path: "",
71
+ schemaId: builder.id,
72
+ info: {
73
+ title: displayName,
74
+ description: tag.description
75
+ },
76
+ webhooks: items.webhooks.filter((webhook) => webhook.tags?.includes(tag.name)),
77
+ operations: items.operations.filter((op) => op.tags?.includes(tag.name)),
78
+ tag: tag.name,
79
+ rawTag: tag
80
+ };
81
+ entry.path = nameFn.call(builder, entry, dereferenced) + ".mdx";
82
+ builder.create(entry);
83
+ }
84
+ return;
85
+ }
86
+ for (const op of items.operations) {
87
+ const { pathItem, operation, displayName } = builder.fromExtractedOperation(op);
88
+ const entry = {
89
+ type: "operation",
90
+ schemaId: builder.id,
91
+ item: op,
92
+ path: "",
93
+ info: {
94
+ title: displayName,
95
+ description: operation.description ?? pathItem.description
96
+ }
97
+ };
98
+ for (const outputPath of groupOutput(builder, entry)) builder.create({
99
+ ...entry,
100
+ path: outputPath
101
+ });
102
+ }
103
+ for (const webhook of items.webhooks) {
104
+ const { pathItem, operation, displayName } = builder.fromExtractedWebhook(webhook);
105
+ const entry = {
106
+ type: "webhook",
107
+ schemaId: builder.id,
108
+ info: {
109
+ title: displayName,
110
+ description: operation.description ?? pathItem.description
111
+ },
112
+ item: webhook,
113
+ path: ""
114
+ };
115
+ for (const outputPath of groupOutput(builder, entry)) builder.create({
116
+ ...entry,
117
+ path: outputPath
118
+ });
119
+ }
120
+ } };
138
121
  }
122
+
123
+ //#endregion
124
+ export { createAutoPreset };
125
+ //# sourceMappingURL=preset-auto.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"preset-auto.js","names":["nameFn: NameFn<OutputEntry>","entry: OutputGroup","entry: TagOutput","entry: OperationOutput","entry: WebhookOutput"],"sources":["../../../src/utils/pages/preset-auto.ts"],"sourcesContent":["import * as path from 'node:path';\nimport type { ProcessedDocument } from '@/utils/process-document';\nimport type {\n OperationOutput,\n OutputEntry,\n OutputGroup,\n PagesBuilder,\n PagesBuilderConfig,\n TagOutput,\n WebhookOutput,\n} from '@/utils/pages/builder';\nimport { isUrl } from '@/utils/url';\n\ninterface OperationConfig extends BaseConfig {\n /**\n * Generate a page for each API endpoint/operation (default).\n */\n per?: 'operation';\n\n /**\n * Group output using folders (Only works on `operation` mode)\n * - tag: `{tag}/{file}`\n * - route: `{endpoint}/{method}` (it will ignore the `name` option)\n * - none: `{file}` (default)\n * - a function that aligns group name (folder path) to each entry\n *\n * @defaultValue 'none'\n */\n groupBy?: 'tag' | 'route' | 'none' | ((entry: OperationOutput | WebhookOutput) => string);\n\n /**\n * Specify name for output file\n */\n name?: NameFn<OperationOutput | WebhookOutput> | NameFnOptions;\n}\n\ninterface TagConfig extends BaseConfig {\n /**\n * Generate a page for each tag.\n */\n per: 'tag';\n\n /**\n * Specify name for output file\n */\n name?: NameFn<TagOutput> | NameFnOptions;\n}\n\ninterface SchemaConfig extends BaseConfig {\n /**\n * Generate a page for each schema file.\n */\n per: 'file';\n\n /**\n * Specify name for output file\n */\n name?: NameFn<OutputGroup> | NameFnOptions;\n}\n\nexport type SchemaToPagesOptions =\n | SchemaConfig\n | TagConfig\n | OperationConfig\n | ({\n per: 'custom';\n } & PagesBuilderConfig);\n\ntype NameFn<Entry> = (\n this: PagesBuilder,\n output: Entry,\n document: ProcessedDocument['dereferenced'],\n) => string;\n\ninterface NameFnOptions {\n /**\n * The version of algorithm used to generate file paths.\n *\n * v1: Fumadocs OpenAPI v8\n * v2: Fumadocs OpenAPI v9\n *\n * @defaultValue v2\n */\n algorithm?: 'v2' | 'v1';\n}\n\ninterface BaseConfig {\n /**\n * Custom function to convert names into file names.\n *\n * By default, it only escapes whitespaces and upper case (English) characters\n */\n slugify?: (name: string) => string;\n}\n\nexport function createAutoPreset(options: SchemaToPagesOptions): PagesBuilderConfig {\n if (options.per === 'custom') return options;\n const {\n slugify = (s) => {\n return s.replace(/\\s+/g, '-').toLowerCase();\n },\n } = options;\n let nameFn: NameFn<OutputEntry>;\n\n if (typeof options.name === 'function') {\n nameFn = options.name as NameFn<OutputEntry>;\n } else {\n const { algorithm = 'v2' } = options.name ?? {};\n\n nameFn = function (result, document) {\n if (result.type === 'tag') {\n return slugify(result.tag);\n }\n\n if (result.type === 'group') {\n const schemaId = result.schemaId;\n\n return isUrl(schemaId) ? 'index' : path.basename(schemaId, path.extname(schemaId));\n }\n\n if (result.type === 'operation') {\n const operation = document.paths![result.item.path]![result.item.method]!;\n\n if (algorithm === 'v2' && operation.operationId) {\n return operation.operationId;\n }\n\n return path.join(\n this.routePathToFilePath(result.item.path),\n result.item.method.toLowerCase(),\n );\n }\n\n const hook = document.webhooks![result.item.name][result.item.method]!;\n\n if (algorithm === 'v2' && hook.operationId) {\n return hook.operationId;\n }\n\n return slugify(result.item.name);\n };\n }\n\n function groupOutput(builder: PagesBuilder, entry: OperationOutput | WebhookOutput): string[] {\n const { dereferenced } = builder.document;\n const { groupBy = 'none' } = options as OperationConfig;\n\n if (groupBy === 'route') {\n return [\n path.join(\n builder.routePathToFilePath(\n entry.type === 'operation' ? entry.item.path : entry.item.name,\n ),\n `${entry.item.method.toLowerCase()}.mdx`,\n ),\n ];\n }\n\n const file = nameFn.call(builder, entry, dereferenced);\n if (groupBy === 'tag') {\n let tags =\n entry.type === 'operation'\n ? dereferenced.paths![entry.item.path]![entry.item.method]!.tags\n : dereferenced.webhooks![entry.item.name][entry.item.method]!.tags;\n\n if (!tags || tags.length === 0) {\n console.warn(\n 'When `groupBy` is set to `tag`, make sure a `tags` is defined for every operation schema.',\n );\n\n tags = ['unknown'];\n }\n\n return tags.map((tag) => path.join(slugify(tag), `${file}.mdx`));\n }\n\n if (typeof groupBy === 'function') {\n return [path.join(slugify(groupBy(entry)), `${file}.mdx`)];\n }\n\n return [`${file}.mdx`];\n }\n\n return {\n toPages(builder) {\n const { dereferenced } = builder.document;\n const items = builder.extract();\n\n if (options.per === 'file') {\n const entry: OutputGroup = {\n type: 'group',\n schemaId: builder.id,\n path: '',\n info: {\n title: dereferenced.info.title,\n description: dereferenced.info.description,\n },\n ...items,\n };\n entry.path = nameFn.call(builder, entry, dereferenced) + '.mdx';\n builder.create(entry);\n return;\n }\n\n if (options.per === 'tag') {\n const tags = dereferenced.tags ?? [];\n for (const tag of tags) {\n const { displayName } = builder.fromTag(tag);\n const entry: TagOutput = {\n type: 'tag',\n path: '',\n schemaId: builder.id,\n info: {\n title: displayName,\n description: tag.description,\n },\n webhooks: items.webhooks.filter((webhook) => webhook.tags?.includes(tag.name)),\n operations: items.operations.filter((op) => op.tags?.includes(tag.name)),\n tag: tag.name,\n rawTag: tag,\n };\n\n entry.path = nameFn.call(builder, entry, dereferenced) + '.mdx';\n builder.create(entry);\n }\n\n return;\n }\n\n for (const op of items.operations) {\n const { pathItem, operation, displayName } = builder.fromExtractedOperation(op)!;\n\n const entry: OperationOutput = {\n type: 'operation',\n schemaId: builder.id,\n item: op,\n path: '',\n info: {\n title: displayName,\n description: operation.description ?? pathItem.description,\n },\n };\n\n for (const outputPath of groupOutput(builder, entry)) {\n builder.create({ ...entry, path: outputPath });\n }\n }\n\n for (const webhook of items.webhooks) {\n const { pathItem, operation, displayName } = builder.fromExtractedWebhook(webhook)!;\n\n const entry: WebhookOutput = {\n type: 'webhook',\n schemaId: builder.id,\n info: {\n title: displayName,\n description: operation.description ?? pathItem.description,\n },\n item: webhook,\n path: '',\n };\n\n for (const outputPath of groupOutput(builder, entry)) {\n builder.create({ ...entry, path: outputPath });\n }\n }\n },\n };\n}\n"],"mappings":"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"}
@@ -1,19 +1,22 @@
1
- export function toBody(entry) {
2
- if (entry.type === 'operation')
3
- return {
4
- document: entry.schemaId,
5
- operations: [entry.item],
6
- };
7
- if (entry.type === 'webhook')
8
- return {
9
- document: entry.schemaId,
10
- webhooks: [entry.item],
11
- };
12
- return {
13
- showTitle: true,
14
- showDescription: true,
15
- document: entry.schemaId,
16
- operations: entry.operations,
17
- webhooks: entry.webhooks,
18
- };
1
+ //#region src/utils/pages/to-body.tsx
2
+ function toBody(entry) {
3
+ if (entry.type === "operation") return {
4
+ document: entry.schemaId,
5
+ operations: [entry.item]
6
+ };
7
+ if (entry.type === "webhook") return {
8
+ document: entry.schemaId,
9
+ webhooks: [entry.item]
10
+ };
11
+ return {
12
+ showTitle: true,
13
+ showDescription: true,
14
+ document: entry.schemaId,
15
+ operations: entry.operations,
16
+ webhooks: entry.webhooks
17
+ };
19
18
  }
19
+
20
+ //#endregion
21
+ export { toBody };
22
+ //# sourceMappingURL=to-body.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"to-body.js","names":[],"sources":["../../../src/utils/pages/to-body.tsx"],"sourcesContent":["import type { ApiPageProps } from '@/ui/api-page';\nimport type { OutputEntry } from '@/utils/pages/builder';\n\nexport function toBody(entry: OutputEntry): ApiPageProps {\n if (entry.type === 'operation')\n return {\n document: entry.schemaId,\n operations: [entry.item],\n };\n if (entry.type === 'webhook')\n return {\n document: entry.schemaId,\n webhooks: [entry.item],\n };\n\n return {\n showTitle: true,\n showDescription: true,\n document: entry.schemaId,\n operations: entry.operations,\n webhooks: entry.webhooks,\n };\n}\n"],"mappings":";AAGA,SAAgB,OAAO,OAAkC;AACvD,KAAI,MAAM,SAAS,YACjB,QAAO;EACL,UAAU,MAAM;EAChB,YAAY,CAAC,MAAM,KAAK;EACzB;AACH,KAAI,MAAM,SAAS,UACjB,QAAO;EACL,UAAU,MAAM;EAChB,UAAU,CAAC,MAAM,KAAK;EACvB;AAEH,QAAO;EACL,WAAW;EACX,iBAAiB;EACjB,UAAU,MAAM;EAChB,YAAY,MAAM;EAClB,UAAU,MAAM;EACjB"}
@@ -1,41 +1,49 @@
1
- import Slugger from 'github-slugger';
2
- import { idToTitle } from '../../utils/id-to-title.js';
3
- export function toStaticData(page, dereferenced) {
4
- const slugger = new Slugger();
5
- const toc = [];
6
- const structuredData = { headings: [], contents: [] };
7
- function pathItem(item, defaultTitle) {
8
- if (page.showTitle && item.operationId) {
9
- const title = item.summary ||
10
- (item.operationId ? idToTitle(item.operationId) : defaultTitle);
11
- const id = slugger.slug(title);
12
- toc.push({
13
- depth: 2,
14
- title,
15
- url: `#${id}`,
16
- });
17
- structuredData.headings.push({
18
- content: title,
19
- id,
20
- });
21
- }
22
- if (item.description)
23
- structuredData.contents.push({
24
- content: item.description,
25
- heading: structuredData.headings.at(-1)?.id,
26
- });
27
- }
28
- for (const item of page.operations ?? []) {
29
- const operation = dereferenced.paths?.[item.path]?.[item.method];
30
- if (!operation)
31
- continue;
32
- pathItem(operation, item.path);
33
- }
34
- for (const item of page.webhooks ?? []) {
35
- const webhook = dereferenced.webhooks?.[item.name]?.[item.method];
36
- if (!webhook)
37
- continue;
38
- pathItem(webhook, item.name);
39
- }
40
- return { toc, structuredData };
1
+ import { idToTitle } from "../id-to-title.js";
2
+ import Slugger from "github-slugger";
3
+
4
+ //#region src/utils/pages/to-static-data.ts
5
+ function toStaticData(page, dereferenced) {
6
+ const slugger = new Slugger();
7
+ const toc = [];
8
+ const structuredData = {
9
+ headings: [],
10
+ contents: []
11
+ };
12
+ function pathItem(item, defaultTitle) {
13
+ if (page.showTitle && item.operationId) {
14
+ const title = item.summary || (item.operationId ? idToTitle(item.operationId) : defaultTitle);
15
+ const id = slugger.slug(title);
16
+ toc.push({
17
+ depth: 2,
18
+ title,
19
+ url: `#${id}`
20
+ });
21
+ structuredData.headings.push({
22
+ content: title,
23
+ id
24
+ });
25
+ }
26
+ if (item.description) structuredData.contents.push({
27
+ content: item.description,
28
+ heading: structuredData.headings.at(-1)?.id
29
+ });
30
+ }
31
+ for (const item of page.operations ?? []) {
32
+ const operation = dereferenced.paths?.[item.path]?.[item.method];
33
+ if (!operation) continue;
34
+ pathItem(operation, item.path);
35
+ }
36
+ for (const item of page.webhooks ?? []) {
37
+ const webhook = dereferenced.webhooks?.[item.name]?.[item.method];
38
+ if (!webhook) continue;
39
+ pathItem(webhook, item.name);
40
+ }
41
+ return {
42
+ toc,
43
+ structuredData
44
+ };
41
45
  }
46
+
47
+ //#endregion
48
+ export { toStaticData };
49
+ //# sourceMappingURL=to-static-data.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"to-static-data.js","names":["toc: TOCItemType[]","structuredData: StructuredData"],"sources":["../../../src/utils/pages/to-static-data.ts"],"sourcesContent":["import type { NoReference } from '@/utils/schema';\nimport type { Document, OperationObject } from '@/types';\nimport Slugger from 'github-slugger';\nimport { idToTitle } from '@/utils/id-to-title';\nimport type { TOCItemType } from 'fumadocs-core/toc';\nimport type { StructuredData } from 'fumadocs-core/mdx-plugins';\nimport type { ApiPageProps } from '@/ui';\n\nexport function toStaticData(\n page: ApiPageProps,\n dereferenced: NoReference<Document>,\n): {\n toc: TOCItemType[];\n structuredData: StructuredData;\n} {\n const slugger = new Slugger();\n const toc: TOCItemType[] = [];\n const structuredData: StructuredData = { headings: [], contents: [] };\n\n function pathItem(item: NoReference<OperationObject>, defaultTitle: string) {\n if (page.showTitle && item.operationId) {\n const title = item.summary || (item.operationId ? idToTitle(item.operationId) : defaultTitle);\n const id = slugger.slug(title);\n\n toc.push({\n depth: 2,\n title,\n url: `#${id}`,\n });\n structuredData.headings.push({\n content: title,\n id,\n });\n }\n\n if (item.description)\n structuredData.contents.push({\n content: item.description,\n heading: structuredData.headings.at(-1)?.id,\n });\n }\n\n for (const item of page.operations ?? []) {\n const operation = dereferenced.paths?.[item.path]?.[item.method];\n if (!operation) continue;\n\n pathItem(operation, item.path);\n }\n\n for (const item of page.webhooks ?? []) {\n const webhook = dereferenced.webhooks?.[item.name]?.[item.method];\n if (!webhook) continue;\n\n pathItem(webhook, item.name);\n }\n\n return { toc, structuredData };\n}\n"],"mappings":";;;;AAQA,SAAgB,aACd,MACA,cAIA;CACA,MAAM,UAAU,IAAI,SAAS;CAC7B,MAAMA,MAAqB,EAAE;CAC7B,MAAMC,iBAAiC;EAAE,UAAU,EAAE;EAAE,UAAU,EAAE;EAAE;CAErE,SAAS,SAAS,MAAoC,cAAsB;AAC1E,MAAI,KAAK,aAAa,KAAK,aAAa;GACtC,MAAM,QAAQ,KAAK,YAAY,KAAK,cAAc,UAAU,KAAK,YAAY,GAAG;GAChF,MAAM,KAAK,QAAQ,KAAK,MAAM;AAE9B,OAAI,KAAK;IACP,OAAO;IACP;IACA,KAAK,IAAI;IACV,CAAC;AACF,kBAAe,SAAS,KAAK;IAC3B,SAAS;IACT;IACD,CAAC;;AAGJ,MAAI,KAAK,YACP,gBAAe,SAAS,KAAK;GAC3B,SAAS,KAAK;GACd,SAAS,eAAe,SAAS,GAAG,GAAG,EAAE;GAC1C,CAAC;;AAGN,MAAK,MAAM,QAAQ,KAAK,cAAc,EAAE,EAAE;EACxC,MAAM,YAAY,aAAa,QAAQ,KAAK,QAAQ,KAAK;AACzD,MAAI,CAAC,UAAW;AAEhB,WAAS,WAAW,KAAK,KAAK;;AAGhC,MAAK,MAAM,QAAQ,KAAK,YAAY,EAAE,EAAE;EACtC,MAAM,UAAU,aAAa,WAAW,KAAK,QAAQ,KAAK;AAC1D,MAAI,CAAC,QAAS;AAEd,WAAS,SAAS,KAAK,KAAK;;AAG9B,QAAO;EAAE;EAAK;EAAgB"}
@@ -1,46 +1,48 @@
1
- import type { ProcessedDocument } from '../../utils/process-document.js';
2
- import type { TagObject } from '../../types.js';
3
- import type { OutputEntry } from '../../utils/pages/builder.js';
4
- export interface PagesToTextOptions {
5
- /**
6
- * Additional imports of your MDX components.
7
- */
8
- imports?: {
9
- names: string[];
10
- from: string;
11
- }[];
12
- /**
13
- * Customise frontmatter.
14
- *
15
- * A `full: true` property will be added by default.
16
- */
17
- frontmatter?: (title: string, description: string | undefined, context: DocumentContext) => Record<string, unknown>;
18
- /**
19
- * Add description to document body.
20
- *
21
- * We recommend but don't enable it by default because some OpenAPI schemas have invalid description that breaks MDX syntax.
22
- *
23
- * @defaultValue false
24
- */
25
- includeDescription?: boolean;
26
- /**
27
- * Add a comment to the top of generated files indicating they are auto-generated.
28
- * - `true`: Adds a standardized comment
29
- * - `false`: No comment is added
30
- * - `string`: Adds the provided custom comment
31
- *
32
- * @defaultValue true
33
- */
34
- addGeneratedComment?: boolean | string;
1
+ import "./builder.js";
2
+ import { TagObject } from "../../types.js";
3
+ import "../process-document.js";
4
+
5
+ //#region src/utils/pages/to-text.d.ts
6
+ interface PagesToTextOptions {
7
+ /**
8
+ * Additional imports of your MDX components.
9
+ */
10
+ imports?: {
11
+ names: string[];
12
+ from: string;
13
+ }[];
14
+ /**
15
+ * Customise frontmatter.
16
+ *
17
+ * A `full: true` property will be added by default.
18
+ */
19
+ frontmatter?: (title: string, description: string | undefined, context: DocumentContext) => Record<string, unknown>;
20
+ /**
21
+ * Add description to document body.
22
+ *
23
+ * We recommend but don't enable it by default because some OpenAPI schemas have invalid description that breaks MDX syntax.
24
+ *
25
+ * @defaultValue false
26
+ */
27
+ includeDescription?: boolean;
28
+ /**
29
+ * Add a comment to the top of generated files indicating they are auto-generated.
30
+ * - `true`: Adds a standardized comment
31
+ * - `false`: No comment is added
32
+ * - `string`: Adds the provided custom comment
33
+ *
34
+ * @defaultValue true
35
+ */
36
+ addGeneratedComment?: boolean | string;
35
37
  }
36
- export declare function toText(entry: OutputEntry, processed: ProcessedDocument, options?: PagesToTextOptions): string;
37
- export declare function generateDocument(frontmatter: unknown, content: string, options: PagesToTextOptions): string;
38
- export type DocumentContext = {
39
- type: 'tag';
40
- tag: TagObject | undefined;
38
+ type DocumentContext = {
39
+ type: 'tag';
40
+ tag: TagObject | undefined;
41
41
  } | {
42
- type: 'operation';
42
+ type: 'operation';
43
43
  } | {
44
- type: 'file';
44
+ type: 'file';
45
45
  };
46
+ //#endregion
47
+ export { PagesToTextOptions };
46
48
  //# sourceMappingURL=to-text.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"to-text.d.ts","sourceRoot":"","sources":["../../../src/utils/pages/to-text.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAClE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAGzC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAIzD,MAAM,WAAW,kBAAkB;IACjC;;OAEG;IACH,OAAO,CAAC,EAAE;QACR,KAAK,EAAE,MAAM,EAAE,CAAC;QAChB,IAAI,EAAE,MAAM,CAAC;KACd,EAAE,CAAC;IAEJ;;;;OAIG;IACH,WAAW,CAAC,EAAE,CACZ,KAAK,EAAE,MAAM,EACb,WAAW,EAAE,MAAM,GAAG,SAAS,EAC/B,OAAO,EAAE,eAAe,KACrB,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAE7B;;;;;;OAMG;IACH,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAE7B;;;;;;;OAOG;IACH,mBAAmB,CAAC,EAAE,OAAO,GAAG,MAAM,CAAC;CACxC;AAED,wBAAgB,MAAM,CACpB,KAAK,EAAE,WAAW,EAClB,SAAS,EAAE,iBAAiB,EAC5B,OAAO,GAAE,kBAAuB,UAqEjC;AAED,wBAAgB,gBAAgB,CAC9B,WAAW,EAAE,OAAO,EACpB,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,kBAAkB,GAC1B,MAAM,CA+BR;AAED,MAAM,MAAM,eAAe,GACvB;IACE,IAAI,EAAE,KAAK,CAAC;IACZ,GAAG,EAAE,SAAS,GAAG,SAAS,CAAC;CAC5B,GACD;IACE,IAAI,EAAE,WAAW,CAAC;CACnB,GACD;IACE,IAAI,EAAE,MAAM,CAAC;CACd,CAAC"}
1
+ {"version":3,"file":"to-text.d.ts","names":[],"sources":["../../../src/utils/pages/to-text.ts"],"sourcesContent":[],"mappings":";;;;;UASiB,kBAAA;;AAAjB;AAoJA;;;;;;;;;;0EAnIa,oBACN;;;;;;;;;;;;;;;;;;;KAkIK,eAAA;;OAGD"}