@mintlify/previewing 3.1.0 → 3.1.2

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 (45) hide show
  1. package/README.md +8 -69
  2. package/dist/constants.d.ts +1 -1
  3. package/dist/constants.js +27 -28
  4. package/dist/downloadImage.js +112 -55
  5. package/dist/index.d.ts +2 -2
  6. package/dist/index.js +2 -3
  7. package/dist/local-preview/helper-commands/installDepsCommand.js +49 -10
  8. package/dist/local-preview/index.d.ts +1 -1
  9. package/dist/local-preview/index.js +221 -131
  10. package/dist/local-preview/listener/categorize.d.ts +1 -1
  11. package/dist/local-preview/listener/categorize.js +134 -79
  12. package/dist/local-preview/listener/generate.d.ts +1 -1
  13. package/dist/local-preview/listener/generate.js +138 -60
  14. package/dist/local-preview/listener/index.js +289 -172
  15. package/dist/local-preview/listener/update.js +75 -20
  16. package/dist/local-preview/listener/utils/createPage.d.ts +1 -1
  17. package/dist/local-preview/listener/utils/createPage.js +176 -123
  18. package/dist/local-preview/listener/utils/getOpenApiContext.d.ts +3 -3
  19. package/dist/local-preview/listener/utils/getOpenApiContext.js +22 -24
  20. package/dist/local-preview/listener/utils/mintConfigFile.js +71 -19
  21. package/dist/local-preview/listener/utils/toTitleCase.js +3 -4
  22. package/dist/local-preview/listener/utils/types.d.ts +2 -2
  23. package/dist/local-preview/listener/utils/types.js +0 -1
  24. package/dist/local-preview/listener/utils.d.ts +1 -2
  25. package/dist/local-preview/listener/utils.js +93 -49
  26. package/dist/tsconfig.tsbuildinfo +1 -0
  27. package/dist/util.d.ts +5 -5
  28. package/dist/util.js +30 -37
  29. package/package.json +6 -1
  30. package/dist/constants.js.map +0 -1
  31. package/dist/downloadImage.js.map +0 -1
  32. package/dist/index.js.map +0 -1
  33. package/dist/local-preview/helper-commands/installDepsCommand.js.map +0 -1
  34. package/dist/local-preview/index.js.map +0 -1
  35. package/dist/local-preview/listener/categorize.js.map +0 -1
  36. package/dist/local-preview/listener/generate.js.map +0 -1
  37. package/dist/local-preview/listener/index.js.map +0 -1
  38. package/dist/local-preview/listener/update.js.map +0 -1
  39. package/dist/local-preview/listener/utils/createPage.js.map +0 -1
  40. package/dist/local-preview/listener/utils/getOpenApiContext.js.map +0 -1
  41. package/dist/local-preview/listener/utils/mintConfigFile.js.map +0 -1
  42. package/dist/local-preview/listener/utils/toTitleCase.js.map +0 -1
  43. package/dist/local-preview/listener/utils/types.js.map +0 -1
  44. package/dist/local-preview/listener/utils.js.map +0 -1
  45. package/dist/util.js.map +0 -1
@@ -1,74 +1,152 @@
1
+ var __assign = (this && this.__assign) || function () {
2
+ __assign = Object.assign || function(t) {
3
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
4
+ s = arguments[i];
5
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
6
+ t[p] = s[p];
7
+ }
8
+ return t;
9
+ };
10
+ return __assign.apply(this, arguments);
11
+ };
12
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
13
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
14
+ return new (P || (P = Promise))(function (resolve, reject) {
15
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
16
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
17
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
18
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
19
+ });
20
+ };
21
+ var __generator = (this && this.__generator) || function (thisArg, body) {
22
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
23
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
24
+ function verb(n) { return function (v) { return step([n, v]); }; }
25
+ function step(op) {
26
+ if (f) throw new TypeError("Generator is already executing.");
27
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
28
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
29
+ if (y = 0, t) op = [op[0] & 2, t.value];
30
+ switch (op[0]) {
31
+ case 0: case 1: t = op; break;
32
+ case 4: _.label++; return { value: op[1], done: false };
33
+ case 5: _.label++; y = op[1]; op = [0]; continue;
34
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
35
+ default:
36
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
37
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
38
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
39
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
40
+ if (t[2]) _.ops.pop();
41
+ _.trys.pop(); continue;
42
+ }
43
+ op = body.call(thisArg, _);
44
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
45
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
46
+ }
47
+ };
1
48
  // TODO - add types
2
- import { promises as _promises } from "fs";
3
- import { outputFile } from "fs-extra";
4
- import path from "path";
5
- import createPage from "./utils/createPage.js";
6
- import { categorizeFiles } from "./categorize.js";
7
- import { CMD_EXEC_PATH } from "../../constants.js";
8
- import { getConfigObj } from "./utils/mintConfigFile.js";
9
- const { readFile } = _promises;
10
- const pageMetadataKeys = [
11
- "title",
12
- "description",
13
- "sidebarTitle",
14
- "href",
15
- "api",
16
- "openapi",
17
- "contentType",
18
- "auth",
19
- "version",
20
- "mode",
21
- "hideFooterPagination",
22
- "authors",
23
- "lastUpdatedDate",
24
- "createdDate",
25
- "size",
49
+ import { promises as _promises } from 'fs';
50
+ import { outputFile } from 'fs-extra';
51
+ import path from 'path';
52
+ import { CMD_EXEC_PATH } from '../../constants.js';
53
+ import { categorizeFiles } from './categorize.js';
54
+ import createPage from './utils/createPage.js';
55
+ import { getConfigObj } from './utils/mintConfigFile.js';
56
+ var readFile = _promises.readFile;
57
+ var pageMetadataKeys = [
58
+ 'title',
59
+ 'description',
60
+ 'sidebarTitle',
61
+ 'href',
62
+ 'api',
63
+ 'openapi',
64
+ 'contentType',
65
+ 'auth',
66
+ 'version',
67
+ 'mode',
68
+ 'hideFooterPagination',
69
+ 'authors',
70
+ 'lastUpdatedDate',
71
+ 'createdDate',
72
+ 'size',
26
73
  ];
27
- const generateDecoratedMintNavigationFromPages = (filenamePageMetadataMap, mintConfigNav) => {
28
- const filenames = Object.keys(filenamePageMetadataMap);
29
- const createNav = (nav) => {
74
+ var generateDecoratedMintNavigationFromPages = function (filenamePageMetadataMap, mintConfigNav) {
75
+ var filenames = Object.keys(filenamePageMetadataMap);
76
+ var createNav = function (nav) {
30
77
  return {
31
78
  group: nav.group,
32
- version: nav?.version,
33
- pages: nav.pages.map((page) => {
34
- if (typeof page === "string" && filenames.includes(page)) {
79
+ version: nav === null || nav === void 0 ? void 0 : nav.version,
80
+ pages: nav.pages.map(function (page) {
81
+ if (typeof page === 'string' && filenames.includes(page)) {
35
82
  return filenamePageMetadataMap[page];
36
83
  }
37
84
  return createNav(page);
38
85
  }),
39
86
  };
40
87
  };
41
- return mintConfigNav.map((nav) => createNav(nav));
88
+ return mintConfigNav.map(function (nav) { return createNav(nav); });
42
89
  };
43
- const createFilenamePageMetadataMap = async (contentDirectoryPath, contentFilenames, openApiFiles, clientPath, writeFiles = false) => {
44
- let pagesAcc = {};
45
- const contentPromises = [];
46
- contentFilenames.forEach((filename) => {
47
- contentPromises.push((async () => {
48
- const sourcePath = path.join(contentDirectoryPath, filename);
49
- const contentStr = (await readFile(sourcePath)).toString();
50
- const { slug, pageMetadata, pageContent } = await createPage(filename, contentStr, contentDirectoryPath, openApiFiles);
51
- if (clientPath && writeFiles) {
52
- const targetPath = path.join(clientPath, "src", "_props", filename);
53
- await outputFile(targetPath, pageContent, {
54
- flag: "w",
55
- });
90
+ var createFilenamePageMetadataMap = function (contentDirectoryPath, contentFilenames, openApiFiles, clientPath, writeFiles) {
91
+ if (writeFiles === void 0) { writeFiles = false; }
92
+ return __awaiter(void 0, void 0, void 0, function () {
93
+ var pagesAcc, contentPromises;
94
+ return __generator(this, function (_a) {
95
+ switch (_a.label) {
96
+ case 0:
97
+ pagesAcc = {};
98
+ contentPromises = [];
99
+ contentFilenames.forEach(function (filename) {
100
+ contentPromises.push((function () { return __awaiter(void 0, void 0, void 0, function () {
101
+ var sourcePath, contentStr, _a, slug, pageMetadata, pageContent, targetPath;
102
+ var _b;
103
+ return __generator(this, function (_c) {
104
+ switch (_c.label) {
105
+ case 0:
106
+ sourcePath = path.join(contentDirectoryPath, filename);
107
+ return [4 /*yield*/, readFile(sourcePath)];
108
+ case 1:
109
+ contentStr = (_c.sent()).toString();
110
+ return [4 /*yield*/, createPage(filename, contentStr, contentDirectoryPath, openApiFiles)];
111
+ case 2:
112
+ _a = _c.sent(), slug = _a.slug, pageMetadata = _a.pageMetadata, pageContent = _a.pageContent;
113
+ if (!(clientPath && writeFiles)) return [3 /*break*/, 4];
114
+ targetPath = path.join(clientPath, 'src', '_props', filename);
115
+ return [4 /*yield*/, outputFile(targetPath, pageContent, {
116
+ flag: 'w',
117
+ })];
118
+ case 3:
119
+ _c.sent();
120
+ _c.label = 4;
121
+ case 4:
122
+ pagesAcc = __assign(__assign({}, pagesAcc), (_b = {}, _b[slug] = pageMetadata, _b));
123
+ return [2 /*return*/];
124
+ }
125
+ });
126
+ }); })());
127
+ });
128
+ return [4 /*yield*/, Promise.all(contentPromises)];
129
+ case 1:
130
+ _a.sent();
131
+ return [2 /*return*/, pagesAcc];
56
132
  }
57
- pagesAcc = {
58
- ...pagesAcc,
59
- [slug]: pageMetadata,
60
- };
61
- })());
133
+ });
62
134
  });
63
- await Promise.all(contentPromises);
64
- return pagesAcc;
65
135
  };
66
- export const generateNav = async () => {
67
- const { contentFilenames, openApiFiles } = await categorizeFiles(CMD_EXEC_PATH);
68
- const [filenamePageMetadataMap, configObj] = await Promise.all([
69
- createFilenamePageMetadataMap(CMD_EXEC_PATH, contentFilenames, openApiFiles),
70
- getConfigObj(CMD_EXEC_PATH),
71
- ]);
72
- return generateDecoratedMintNavigationFromPages(filenamePageMetadataMap, configObj?.navigation);
73
- };
74
- //# sourceMappingURL=generate.js.map
136
+ export var generateNav = function () { return __awaiter(void 0, void 0, void 0, function () {
137
+ var _a, contentFilenames, openApiFiles, _b, filenamePageMetadataMap, configObj;
138
+ return __generator(this, function (_c) {
139
+ switch (_c.label) {
140
+ case 0: return [4 /*yield*/, categorizeFiles(CMD_EXEC_PATH)];
141
+ case 1:
142
+ _a = _c.sent(), contentFilenames = _a.contentFilenames, openApiFiles = _a.openApiFiles;
143
+ return [4 /*yield*/, Promise.all([
144
+ createFilenamePageMetadataMap(CMD_EXEC_PATH, contentFilenames, openApiFiles),
145
+ getConfigObj(CMD_EXEC_PATH),
146
+ ])];
147
+ case 2:
148
+ _b = _c.sent(), filenamePageMetadataMap = _b[0], configObj = _b[1];
149
+ return [2 /*return*/, generateDecoratedMintNavigationFromPages(filenamePageMetadataMap, configObj === null || configObj === void 0 ? void 0 : configObj.navigation)];
150
+ }
151
+ });
152
+ }); };