@mintlify/common 1.0.1308 → 1.0.1310
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/mdx/builtInComponents.d.ts +2 -0
- package/dist/mdx/builtInComponents.js +3 -0
- package/dist/mdx/builtInComponents.test.d.ts +1 -0
- package/dist/mdx/builtInComponents.test.js +20 -0
- package/dist/mdx/index.d.ts +2 -0
- package/dist/mdx/index.js +2 -0
- package/dist/mdx/snippets/resolveAllImports.d.ts +1 -0
- package/dist/mdx/snippets/resolveAllImports.js +9 -7
- package/dist/mdx/snippets/resolveImport/index.d.ts +1 -0
- package/dist/mdx/snippets/resolveImport/index.js +1 -0
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +2 -2
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { BUILD_RENAMED_COMPONENTS, isBuiltInComponent } from './builtInComponents.js';
|
|
2
|
+
import { remarkFrames } from './plugins/remark/remarkFrames.js';
|
|
3
|
+
import { coreRemark } from './remark.js';
|
|
4
|
+
import { allowedComponents } from './utils.js';
|
|
5
|
+
describe('isBuiltInComponent', () => {
|
|
6
|
+
it('accepts every component remarkMdxRemoveUnknownJsx keeps', () => {
|
|
7
|
+
expect(allowedComponents.filter((name) => !isBuiltInComponent(name))).toEqual([]);
|
|
8
|
+
expect(isBuiltInComponent('Color.Row')).toBe(true);
|
|
9
|
+
expect(isBuiltInComponent('Color.Nope')).toBe(false);
|
|
10
|
+
expect(isBuiltInComponent('Missing')).toBe(false);
|
|
11
|
+
});
|
|
12
|
+
it('accepts tags the build rewrites before removing unknown JSX', () => {
|
|
13
|
+
const tree = coreRemark().parse('<Example>\n x\n</Example>\n');
|
|
14
|
+
remarkFrames()(tree);
|
|
15
|
+
const [node] = tree.children;
|
|
16
|
+
expect(BUILD_RENAMED_COMPONENTS).toEqual(['Example', 'Snippet']);
|
|
17
|
+
expect((node === null || node === void 0 ? void 0 : node.name) && allowedComponents.includes(node.name)).toBe(true);
|
|
18
|
+
expect(BUILD_RENAMED_COMPONENTS.every(isBuiltInComponent)).toBe(true);
|
|
19
|
+
});
|
|
20
|
+
});
|
package/dist/mdx/index.d.ts
CHANGED
|
@@ -15,4 +15,6 @@ export * from './getCodeStyling.js';
|
|
|
15
15
|
export * from './getCodeRanges.js';
|
|
16
16
|
export * from './replaceVariables.js';
|
|
17
17
|
export * from './componentIds.js';
|
|
18
|
+
export * from './builtInComponents.js';
|
|
19
|
+
export { collectPatternNames, visitReferences } from './estreeReferences.js';
|
|
18
20
|
export * from './islands/index.js';
|
package/dist/mdx/index.js
CHANGED
|
@@ -15,4 +15,6 @@ export * from './getCodeStyling.js';
|
|
|
15
15
|
export * from './getCodeRanges.js';
|
|
16
16
|
export * from './replaceVariables.js';
|
|
17
17
|
export * from './componentIds.js';
|
|
18
|
+
export * from './builtInComponents.js';
|
|
19
|
+
export { collectPatternNames, visitReferences } from './estreeReferences.js';
|
|
18
20
|
export * from './islands/index.js';
|
|
@@ -5,6 +5,7 @@ import { type PackageImportOptions } from '../islands/packageImports.js';
|
|
|
5
5
|
export type ResolveImportsWarning = {
|
|
6
6
|
type: 'invalid-import-path' | 'missing-file' | 'import-resolution-error' | 'default-import-no-default-export' | 'export-collision' | 'undeclared-package' | 'package-import-conflict';
|
|
7
7
|
message: string;
|
|
8
|
+
file?: string;
|
|
8
9
|
};
|
|
9
10
|
export declare const resolveAllImports: (params: {
|
|
10
11
|
snippets: (FileType & {
|
|
@@ -10,6 +10,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
10
10
|
import { jsx, toJs } from 'estree-util-to-js';
|
|
11
11
|
import { remove } from 'unist-util-remove';
|
|
12
12
|
import { visit } from 'unist-util-visit';
|
|
13
|
+
import { normalizeRelativePath } from '../../fs/normalizeRelativePath.js';
|
|
13
14
|
import { MdxImportSpecifier } from '../../types/mdx/snippets/import.js';
|
|
14
15
|
import { createImportNode, isDeclaredPackageImport, isNonHostBareImport, mergeImports, } from '../islands/packageImports.js';
|
|
15
16
|
import { estreeIsProgram, isImportDeclaration, isMdxJsEsm } from '../utils.js';
|
|
@@ -109,6 +110,7 @@ export const resolveAllImports = (params) => __awaiter(void 0, void 0, void 0, f
|
|
|
109
110
|
var _a;
|
|
110
111
|
var _b, _c, _d, _e;
|
|
111
112
|
const { snippets, fileWithImports, onWarning, packages } = params;
|
|
113
|
+
const file = normalizeRelativePath(fileWithImports.filename);
|
|
112
114
|
let ast = fileWithImports.tree;
|
|
113
115
|
const kept = packages && /\.mdx?$/.test(fileWithImports.filename)
|
|
114
116
|
? takePackageReExports(ast, packages.packageNames)
|
|
@@ -125,7 +127,7 @@ export const resolveAllImports = (params) => __awaiter(void 0, void 0, void 0, f
|
|
|
125
127
|
}
|
|
126
128
|
const message = `Package ${(_c = getSpecifierPackageName(source)) !== null && _c !== void 0 ? _c : source} imported in ${fileWithImports.filename} is not declared in package.json dependencies.`;
|
|
127
129
|
if (onWarning) {
|
|
128
|
-
onWarning({ type: 'undeclared-package', message });
|
|
130
|
+
onWarning({ type: 'undeclared-package', message, file });
|
|
129
131
|
}
|
|
130
132
|
else {
|
|
131
133
|
console.log(message);
|
|
@@ -139,7 +141,7 @@ export const resolveAllImports = (params) => __awaiter(void 0, void 0, void 0, f
|
|
|
139
141
|
if (resolvedPath == null) {
|
|
140
142
|
const message = `Invalid import path ${source} in ${fileWithImports.filename}. Only local imports are supported.`;
|
|
141
143
|
if (onWarning) {
|
|
142
|
-
onWarning({ type: 'invalid-import-path', message });
|
|
144
|
+
onWarning({ type: 'invalid-import-path', message, file });
|
|
143
145
|
}
|
|
144
146
|
else {
|
|
145
147
|
console.log(message);
|
|
@@ -150,7 +152,7 @@ export const resolveAllImports = (params) => __awaiter(void 0, void 0, void 0, f
|
|
|
150
152
|
if (foundSnippet == undefined) {
|
|
151
153
|
const message = `Could not find file ${resolvedPath} - imported from ${fileWithImports.filename}`;
|
|
152
154
|
if (onWarning) {
|
|
153
|
-
onWarning({ type: 'missing-file', message });
|
|
155
|
+
onWarning({ type: 'missing-file', message, file });
|
|
154
156
|
}
|
|
155
157
|
else {
|
|
156
158
|
console.log(message);
|
|
@@ -178,7 +180,7 @@ export const resolveAllImports = (params) => __awaiter(void 0, void 0, void 0, f
|
|
|
178
180
|
importedSnippet.tree.children.every((node) => node.type === 'yaml' || node.type === 'mdxjsEsm')) {
|
|
179
181
|
const message = `Default import "${specifier.name}" in ${fileWithImports.filename} will not render — ${resolvedPath} has no default export. Use a named import instead: import { ExportName } from '${source}'`;
|
|
180
182
|
if (onWarning) {
|
|
181
|
-
onWarning({ type: 'default-import-no-default-export', message });
|
|
183
|
+
onWarning({ type: 'default-import-no-default-export', message, file });
|
|
182
184
|
}
|
|
183
185
|
else {
|
|
184
186
|
console.log(message);
|
|
@@ -187,7 +189,7 @@ export const resolveAllImports = (params) => __awaiter(void 0, void 0, void 0, f
|
|
|
187
189
|
try {
|
|
188
190
|
const contentWithResolvedImport = yield resolveImport(specifier, ast, importedSnippet.tree, exportMap, (warning) => {
|
|
189
191
|
// the collision itself doesn't know which page it happened in, so add it here
|
|
190
|
-
const located = Object.assign(Object.assign({}, warning), { message: `${warning.message} (in ${fileWithImports.filename}, importing ${resolvedPath})
|
|
192
|
+
const located = Object.assign(Object.assign({}, warning), { message: `${warning.message} (in ${fileWithImports.filename}, importing ${resolvedPath})`, file });
|
|
191
193
|
if (onWarning) {
|
|
192
194
|
onWarning(located);
|
|
193
195
|
}
|
|
@@ -203,7 +205,7 @@ export const resolveAllImports = (params) => __awaiter(void 0, void 0, void 0, f
|
|
|
203
205
|
catch (err) {
|
|
204
206
|
const message = `Error resolving import "${specifier.name}" in ${fileWithImports.filename}: ${err instanceof Error ? err.message : String(err)}`;
|
|
205
207
|
if (onWarning) {
|
|
206
|
-
onWarning({ type: 'import-resolution-error', message });
|
|
208
|
+
onWarning({ type: 'import-resolution-error', message, file });
|
|
207
209
|
}
|
|
208
210
|
else {
|
|
209
211
|
console.log(message);
|
|
@@ -221,7 +223,7 @@ export const resolveAllImports = (params) => __awaiter(void 0, void 0, void 0, f
|
|
|
221
223
|
for (const { local, first, second } of conflicts) {
|
|
222
224
|
const message = `${local} is imported twice in ${fileWithImports.filename}, as ${first} and as ${second}. Snippets inlined into a page share its imports, so import one of them under another name.`;
|
|
223
225
|
if (onWarning) {
|
|
224
|
-
onWarning({ type: 'package-import-conflict', message });
|
|
226
|
+
onWarning({ type: 'package-import-conflict', message, file });
|
|
225
227
|
}
|
|
226
228
|
else {
|
|
227
229
|
console.log(message);
|
|
@@ -4,6 +4,7 @@ import { collectContextFromTree } from '../../plugins/remark/staticEvaluator.js'
|
|
|
4
4
|
import { type OnExportCollision } from './exportCollision.js';
|
|
5
5
|
export { type ExportCollisionWarning, type OnExportCollision } from './exportCollision.js';
|
|
6
6
|
export { findExport } from './findExport.js';
|
|
7
|
+
export { collectExportedNames } from './snippetDeclarations.js';
|
|
7
8
|
export { injectToTopOfFileOfTree } from './injectToTopOfFile.js';
|
|
8
9
|
/** What one page's imports have resolved so far. Pass the same state for every import of a page. */
|
|
9
10
|
export interface ImportResolutionState {
|
|
@@ -17,6 +17,7 @@ import { injectToTopOfFileOfTree } from './injectToTopOfFile.js';
|
|
|
17
17
|
import { resolveComponentWithContent } from './resolveComponentWithContent.js';
|
|
18
18
|
import { collectExportedNames, collectTopLevelBindingNames, declarationSource, exportedBindingName, injectBelowEagerDependencies, isolateExportedDeclarator, patternSiblingNames, prepareSnippetSiblings, } from './snippetDeclarations.js';
|
|
19
19
|
export { findExport } from './findExport.js';
|
|
20
|
+
export { collectExportedNames } from './snippetDeclarations.js';
|
|
20
21
|
export { injectToTopOfFileOfTree } from './injectToTopOfFile.js';
|
|
21
22
|
const VALID_SPECIFIERS = [
|
|
22
23
|
MdxImportSpecifier.ImportSpecifier,
|