@mintlify/previewing 3.1.56 → 3.1.57
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/LICENSE +93 -0
- package/README.md +17 -17
- package/dist/constants.d.ts +9 -9
- package/dist/constants.js +31 -31
- package/dist/downloadImage.d.ts +4 -4
- package/dist/downloadImage.js +139 -139
- package/dist/index.d.ts +3 -3
- package/dist/index.js +3 -3
- package/dist/local-preview/helper-commands/installDepsCommand.d.ts +2 -2
- package/dist/local-preview/helper-commands/installDepsCommand.js +51 -51
- package/dist/local-preview/index.d.ts +3 -3
- package/dist/local-preview/index.js +212 -212
- package/dist/local-preview/listener/categorize.d.ts +8 -8
- package/dist/local-preview/listener/categorize.js +193 -193
- package/dist/local-preview/listener/generate.d.ts +1 -1
- package/dist/local-preview/listener/generate.js +137 -137
- package/dist/local-preview/listener/index.d.ts +2 -2
- package/dist/local-preview/listener/index.js +317 -317
- package/dist/local-preview/listener/update.d.ts +2 -2
- package/dist/local-preview/listener/update.js +79 -79
- package/dist/local-preview/listener/utils/createPage.d.ts +10 -10
- package/dist/local-preview/listener/utils/createPage.js +210 -210
- package/dist/local-preview/listener/utils/getOpenApiContext.d.ts +21 -21
- package/dist/local-preview/listener/utils/getOpenApiContext.js +55 -55
- package/dist/local-preview/listener/utils/mintConfigFile.d.ts +2 -2
- package/dist/local-preview/listener/utils/mintConfigFile.js +74 -74
- package/dist/local-preview/listener/utils/types.d.ts +2 -2
- package/dist/local-preview/listener/utils/types.js +1 -1
- package/dist/local-preview/listener/utils.d.ts +13 -13
- package/dist/local-preview/listener/utils.js +112 -112
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/util.d.ts +4 -4
- package/dist/util.js +20 -20
- package/package.json +88 -87
|
@@ -1,137 +1,137 @@
|
|
|
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
|
-
};
|
|
48
|
-
// TODO - add types
|
|
49
|
-
import { generateDecoratedMintNavigationFromPages } from '@mintlify/prebuild';
|
|
50
|
-
import { promises as _promises } from 'fs';
|
|
51
|
-
import { outputFile } from 'fs-extra';
|
|
52
|
-
import path from 'path';
|
|
53
|
-
import { CMD_EXEC_PATH } from '../../constants.js';
|
|
54
|
-
import { categorizeFiles } from './categorize.js';
|
|
55
|
-
import createPage from './utils/createPage.js';
|
|
56
|
-
import { getConfigObj } from './utils/mintConfigFile.js';
|
|
57
|
-
var readFile = _promises.readFile;
|
|
58
|
-
var pageMetadataKeys = [
|
|
59
|
-
'title',
|
|
60
|
-
'description',
|
|
61
|
-
'sidebarTitle',
|
|
62
|
-
'href',
|
|
63
|
-
'api',
|
|
64
|
-
'openapi',
|
|
65
|
-
'contentType',
|
|
66
|
-
'auth',
|
|
67
|
-
'version',
|
|
68
|
-
'mode',
|
|
69
|
-
'hideFooterPagination',
|
|
70
|
-
'authors',
|
|
71
|
-
'lastUpdatedDate',
|
|
72
|
-
'createdDate',
|
|
73
|
-
'size',
|
|
74
|
-
];
|
|
75
|
-
var createFilenamePageMetadataMap = function (contentDirectoryPath, contentFilenames, openApiFiles, clientPath, writeFiles) {
|
|
76
|
-
if (writeFiles === void 0) { writeFiles = false; }
|
|
77
|
-
return __awaiter(void 0, void 0, void 0, function () {
|
|
78
|
-
var pagesAcc, contentPromises;
|
|
79
|
-
return __generator(this, function (_a) {
|
|
80
|
-
switch (_a.label) {
|
|
81
|
-
case 0:
|
|
82
|
-
pagesAcc = {};
|
|
83
|
-
contentPromises = [];
|
|
84
|
-
contentFilenames.forEach(function (filename) {
|
|
85
|
-
contentPromises.push((function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
86
|
-
var sourcePath, contentStr, _a, slug, pageMetadata, pageContent, targetPath;
|
|
87
|
-
var _b;
|
|
88
|
-
return __generator(this, function (_c) {
|
|
89
|
-
switch (_c.label) {
|
|
90
|
-
case 0:
|
|
91
|
-
sourcePath = path.join(contentDirectoryPath, filename);
|
|
92
|
-
return [4 /*yield*/, readFile(sourcePath)];
|
|
93
|
-
case 1:
|
|
94
|
-
contentStr = (_c.sent()).toString();
|
|
95
|
-
return [4 /*yield*/, createPage(filename, contentStr, contentDirectoryPath, openApiFiles)];
|
|
96
|
-
case 2:
|
|
97
|
-
_a = _c.sent(), slug = _a.slug, pageMetadata = _a.pageMetadata, pageContent = _a.pageContent;
|
|
98
|
-
if (!(clientPath && writeFiles)) return [3 /*break*/, 4];
|
|
99
|
-
targetPath = path.join(clientPath, 'src', '_props', filename);
|
|
100
|
-
return [4 /*yield*/, outputFile(targetPath, pageContent, {
|
|
101
|
-
flag: 'w',
|
|
102
|
-
})];
|
|
103
|
-
case 3:
|
|
104
|
-
_c.sent();
|
|
105
|
-
_c.label = 4;
|
|
106
|
-
case 4:
|
|
107
|
-
pagesAcc = __assign(__assign({}, pagesAcc), (_b = {}, _b[slug] = pageMetadata, _b));
|
|
108
|
-
return [2 /*return*/];
|
|
109
|
-
}
|
|
110
|
-
});
|
|
111
|
-
}); })());
|
|
112
|
-
});
|
|
113
|
-
return [4 /*yield*/, Promise.all(contentPromises)];
|
|
114
|
-
case 1:
|
|
115
|
-
_a.sent();
|
|
116
|
-
return [2 /*return*/, pagesAcc];
|
|
117
|
-
}
|
|
118
|
-
});
|
|
119
|
-
});
|
|
120
|
-
};
|
|
121
|
-
export var generateNav = function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
122
|
-
var _a, contentFilenames, openApiFiles, _b, filenamePageMetadataMap, configObj;
|
|
123
|
-
return __generator(this, function (_c) {
|
|
124
|
-
switch (_c.label) {
|
|
125
|
-
case 0: return [4 /*yield*/, categorizeFiles(CMD_EXEC_PATH)];
|
|
126
|
-
case 1:
|
|
127
|
-
_a = _c.sent(), contentFilenames = _a.contentFilenames, openApiFiles = _a.openApiFiles;
|
|
128
|
-
return [4 /*yield*/, Promise.all([
|
|
129
|
-
createFilenamePageMetadataMap(CMD_EXEC_PATH, contentFilenames, openApiFiles),
|
|
130
|
-
getConfigObj(CMD_EXEC_PATH),
|
|
131
|
-
])];
|
|
132
|
-
case 2:
|
|
133
|
-
_b = _c.sent(), filenamePageMetadataMap = _b[0], configObj = _b[1];
|
|
134
|
-
return [2 /*return*/, generateDecoratedMintNavigationFromPages(filenamePageMetadataMap, configObj === null || configObj === void 0 ? void 0 : configObj.navigation)];
|
|
135
|
-
}
|
|
136
|
-
});
|
|
137
|
-
}); };
|
|
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
|
+
};
|
|
48
|
+
// TODO - add types
|
|
49
|
+
import { generateDecoratedMintNavigationFromPages } from '@mintlify/prebuild';
|
|
50
|
+
import { promises as _promises } from 'fs';
|
|
51
|
+
import { outputFile } from 'fs-extra';
|
|
52
|
+
import path from 'path';
|
|
53
|
+
import { CMD_EXEC_PATH } from '../../constants.js';
|
|
54
|
+
import { categorizeFiles } from './categorize.js';
|
|
55
|
+
import createPage from './utils/createPage.js';
|
|
56
|
+
import { getConfigObj } from './utils/mintConfigFile.js';
|
|
57
|
+
var readFile = _promises.readFile;
|
|
58
|
+
var pageMetadataKeys = [
|
|
59
|
+
'title',
|
|
60
|
+
'description',
|
|
61
|
+
'sidebarTitle',
|
|
62
|
+
'href',
|
|
63
|
+
'api',
|
|
64
|
+
'openapi',
|
|
65
|
+
'contentType',
|
|
66
|
+
'auth',
|
|
67
|
+
'version',
|
|
68
|
+
'mode',
|
|
69
|
+
'hideFooterPagination',
|
|
70
|
+
'authors',
|
|
71
|
+
'lastUpdatedDate',
|
|
72
|
+
'createdDate',
|
|
73
|
+
'size',
|
|
74
|
+
];
|
|
75
|
+
var createFilenamePageMetadataMap = function (contentDirectoryPath, contentFilenames, openApiFiles, clientPath, writeFiles) {
|
|
76
|
+
if (writeFiles === void 0) { writeFiles = false; }
|
|
77
|
+
return __awaiter(void 0, void 0, void 0, function () {
|
|
78
|
+
var pagesAcc, contentPromises;
|
|
79
|
+
return __generator(this, function (_a) {
|
|
80
|
+
switch (_a.label) {
|
|
81
|
+
case 0:
|
|
82
|
+
pagesAcc = {};
|
|
83
|
+
contentPromises = [];
|
|
84
|
+
contentFilenames.forEach(function (filename) {
|
|
85
|
+
contentPromises.push((function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
86
|
+
var sourcePath, contentStr, _a, slug, pageMetadata, pageContent, targetPath;
|
|
87
|
+
var _b;
|
|
88
|
+
return __generator(this, function (_c) {
|
|
89
|
+
switch (_c.label) {
|
|
90
|
+
case 0:
|
|
91
|
+
sourcePath = path.join(contentDirectoryPath, filename);
|
|
92
|
+
return [4 /*yield*/, readFile(sourcePath)];
|
|
93
|
+
case 1:
|
|
94
|
+
contentStr = (_c.sent()).toString();
|
|
95
|
+
return [4 /*yield*/, createPage(filename, contentStr, contentDirectoryPath, openApiFiles)];
|
|
96
|
+
case 2:
|
|
97
|
+
_a = _c.sent(), slug = _a.slug, pageMetadata = _a.pageMetadata, pageContent = _a.pageContent;
|
|
98
|
+
if (!(clientPath && writeFiles)) return [3 /*break*/, 4];
|
|
99
|
+
targetPath = path.join(clientPath, 'src', '_props', filename);
|
|
100
|
+
return [4 /*yield*/, outputFile(targetPath, pageContent, {
|
|
101
|
+
flag: 'w',
|
|
102
|
+
})];
|
|
103
|
+
case 3:
|
|
104
|
+
_c.sent();
|
|
105
|
+
_c.label = 4;
|
|
106
|
+
case 4:
|
|
107
|
+
pagesAcc = __assign(__assign({}, pagesAcc), (_b = {}, _b[slug] = pageMetadata, _b));
|
|
108
|
+
return [2 /*return*/];
|
|
109
|
+
}
|
|
110
|
+
});
|
|
111
|
+
}); })());
|
|
112
|
+
});
|
|
113
|
+
return [4 /*yield*/, Promise.all(contentPromises)];
|
|
114
|
+
case 1:
|
|
115
|
+
_a.sent();
|
|
116
|
+
return [2 /*return*/, pagesAcc];
|
|
117
|
+
}
|
|
118
|
+
});
|
|
119
|
+
});
|
|
120
|
+
};
|
|
121
|
+
export var generateNav = function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
122
|
+
var _a, contentFilenames, openApiFiles, _b, filenamePageMetadataMap, configObj;
|
|
123
|
+
return __generator(this, function (_c) {
|
|
124
|
+
switch (_c.label) {
|
|
125
|
+
case 0: return [4 /*yield*/, categorizeFiles(CMD_EXEC_PATH)];
|
|
126
|
+
case 1:
|
|
127
|
+
_a = _c.sent(), contentFilenames = _a.contentFilenames, openApiFiles = _a.openApiFiles;
|
|
128
|
+
return [4 /*yield*/, Promise.all([
|
|
129
|
+
createFilenamePageMetadataMap(CMD_EXEC_PATH, contentFilenames, openApiFiles),
|
|
130
|
+
getConfigObj(CMD_EXEC_PATH),
|
|
131
|
+
])];
|
|
132
|
+
case 2:
|
|
133
|
+
_b = _c.sent(), filenamePageMetadataMap = _b[0], configObj = _b[1];
|
|
134
|
+
return [2 /*return*/, generateDecoratedMintNavigationFromPages(filenamePageMetadataMap, configObj === null || configObj === void 0 ? void 0 : configObj.navigation)];
|
|
135
|
+
}
|
|
136
|
+
});
|
|
137
|
+
}); };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
declare const listener: () => void;
|
|
2
|
-
export default listener;
|
|
1
|
+
declare const listener: () => void;
|
|
2
|
+
export default listener;
|