@mintlify/previewing 4.0.1462 → 4.0.1464
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/__tests__/listener-graphql-packages.test.js +68 -0
- package/dist/__tests__/listener-package-manifest.test.d.ts +1 -0
- package/dist/__tests__/listener-package-manifest.test.js +103 -0
- package/dist/__tests__/packages-builder.test.d.ts +1 -0
- package/dist/__tests__/packages-builder.test.js +88 -0
- package/dist/__tests__/packages-collect.test.d.ts +1 -0
- package/dist/__tests__/packages-collect.test.js +387 -0
- package/dist/__tests__/packages-dev-snippets.test.d.ts +1 -0
- package/dist/__tests__/packages-dev-snippets.test.js +478 -0
- package/dist/__tests__/packages-dev.test.d.ts +1 -0
- package/dist/__tests__/packages-dev.test.js +1304 -0
- package/dist/__tests__/packages-flag.test.d.ts +1 -0
- package/dist/__tests__/packages-flag.test.js +146 -0
- package/dist/__tests__/packages-imports.test.d.ts +1 -0
- package/dist/__tests__/packages-imports.test.js +68 -0
- package/dist/__tests__/packages-island-errors.test.d.ts +1 -0
- package/dist/__tests__/packages-island-errors.test.js +128 -0
- package/dist/__tests__/packages-serve.test.d.ts +1 -0
- package/dist/__tests__/packages-serve.test.js +73 -0
- package/dist/__tests__/packages-setup.test.js +65 -7
- package/dist/local-preview/index.js +6 -0
- package/dist/local-preview/listener/index.d.ts +1 -0
- package/dist/local-preview/listener/index.js +10 -1
- package/dist/local-preview/listener/regenerateAllSnippets.js +2 -0
- package/dist/local-preview/listener/resolve-imports-from-import-closure.js +3 -0
- package/dist/local-preview/listener/resolveAllImports.js +2 -0
- package/dist/local-preview/packages/dev.d.ts +88 -0
- package/dist/local-preview/packages/dev.js +478 -0
- package/dist/local-preview/packages/index.d.ts +8 -0
- package/dist/local-preview/packages/index.js +89 -0
- package/dist/local-preview/packages/serve.d.ts +8 -0
- package/dist/local-preview/packages/serve.js +41 -0
- package/dist/local-preview/packages/state.d.ts +6 -0
- package/dist/local-preview/packages/state.js +6 -0
- package/dist/local-preview/run.js +8 -0
- package/dist/logging-state.d.ts +1 -0
- package/dist/logging-state.js +5 -0
- package/dist/packages/builder.d.ts +2 -0
- package/dist/packages/builder.js +1 -0
- package/dist/packages/index.d.ts +0 -1
- package/dist/packages/index.js +0 -1
- package/dist/packages/setup.d.ts +2 -0
- package/dist/packages/setup.js +5 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +4 -4
- package/dist/__tests__/packages-check.test.js +0 -254
- package/dist/packages/check.d.ts +0 -25
- package/dist/packages/check.js +0 -132
- /package/dist/__tests__/{packages-check.test.d.ts → listener-graphql-packages.test.d.ts} +0 -0
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import fse from 'fs-extra';
|
|
2
|
+
import path from 'path';
|
|
3
|
+
export const PACKAGE_ROUTE_PREFIX = '/_mintlify/pkg';
|
|
4
|
+
const BUILD_ID = /^[A-Za-z0-9_-]{1,64}$/;
|
|
5
|
+
const ISLAND_ENTRY = /^client\/islands\/([A-Za-z0-9_-]{1,64})\.js$/;
|
|
6
|
+
export const EMPTY_ISLAND_MODULE = 'export function hydrate() {\n return { unmount() {} };\n}\n';
|
|
7
|
+
const resolveInside = (root, relative) => {
|
|
8
|
+
const resolved = path.resolve(root, relative);
|
|
9
|
+
return resolved.startsWith(root + path.sep) ? resolved : undefined;
|
|
10
|
+
};
|
|
11
|
+
export const createPackageRoute = (getState) => async (req, res, next) => {
|
|
12
|
+
const state = getState();
|
|
13
|
+
if (!state.enabled || (req.method !== 'GET' && req.method !== 'HEAD')) {
|
|
14
|
+
next();
|
|
15
|
+
return;
|
|
16
|
+
}
|
|
17
|
+
const [buildId, ...rest] = req.path.replace(/^\/+/, '').split('/');
|
|
18
|
+
const relative = rest.join('/');
|
|
19
|
+
const clientDir = buildId && BUILD_ID.test(buildId) ? path.join(state.buildsDir, buildId, 'client') : '';
|
|
20
|
+
const inClient = relative.startsWith('client/') ? relative.slice('client/'.length) : '';
|
|
21
|
+
const file = clientDir && inClient ? resolveInside(clientDir, inClient) : undefined;
|
|
22
|
+
res.setHeader('X-Content-Type-Options', 'nosniff');
|
|
23
|
+
if (file &&
|
|
24
|
+
(await fse.stat(file).then((stat) => stat.isFile(), () => false))) {
|
|
25
|
+
res.sendFile(path.relative(clientDir, file), {
|
|
26
|
+
root: clientDir,
|
|
27
|
+
dotfiles: 'deny',
|
|
28
|
+
headers: { 'Cache-Control': 'no-cache' },
|
|
29
|
+
});
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
if (ISLAND_ENTRY.test(relative)) {
|
|
33
|
+
res
|
|
34
|
+
.status(200)
|
|
35
|
+
.type('text/javascript')
|
|
36
|
+
.setHeader('Cache-Control', 'no-store')
|
|
37
|
+
.send(EMPTY_ISLAND_MODULE);
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
res.status(404).type('text/plain').send('Not found');
|
|
41
|
+
};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { PackageImportOptions } from '@mintlify/common';
|
|
2
|
+
export declare const getPackageImportOptions: () => PackageImportOptions | undefined;
|
|
3
|
+
export declare const setPackageImportOptions: (options: PackageImportOptions | undefined) => void;
|
|
4
|
+
export declare const packageImportArgs: () => {
|
|
5
|
+
packages?: PackageImportOptions;
|
|
6
|
+
};
|
|
@@ -6,12 +6,14 @@ import { Server as SocketServer } from 'socket.io';
|
|
|
6
6
|
import { CMD_EXEC_PATH, NEXT_PUBLIC_PATH } from '../constants.js';
|
|
7
7
|
import { addLog, removeSpinnerLogs } from '../logging-state.js';
|
|
8
8
|
import { LaunchLog, SearchDisabledLog, UpdateLog } from '../logs.js';
|
|
9
|
+
import { isNativePackagesEnabled } from '../packages/flag.js';
|
|
9
10
|
import { maybeFixMissingWindowsEnvVar } from '../util.js';
|
|
10
11
|
import { addDevTimingLog, startDevTiming, timeDev } from './dev-timing.js';
|
|
11
12
|
import listener, { initializeDocsConfigHashCache, initializeFrontmatterHashCache, initializeImportCache, } from './listener/index.js';
|
|
12
13
|
import { refreshTrackedReferencedFiles } from './listener/referencedFiles.js';
|
|
13
14
|
import { getLocalNetworkIp } from './network.js';
|
|
14
15
|
import { ensurePageCompiled, getFailedCompileEvents, markOnDemandPagesReady, setCompileListener, } from './on-demand-page.js';
|
|
16
|
+
import { packageRoute, setPackagesRebuiltListener } from './packages/index.js';
|
|
15
17
|
import { setupNext } from './setupNext.js';
|
|
16
18
|
const PROXY_RESPONSE_HEADER_DENYLIST = new Set([
|
|
17
19
|
'connection',
|
|
@@ -53,6 +55,7 @@ export const run = async (argv) => {
|
|
|
53
55
|
process.env.LOCAL_OG_PREVIEW = 'true';
|
|
54
56
|
const requestHandler = await timeDev('setup Next handler', () => setupNext());
|
|
55
57
|
const localIp = getLocalNetworkIp();
|
|
58
|
+
const nativePackages = isNativePackagesEnabled();
|
|
56
59
|
const apiUrl = argv.apiUrl ?? process.env.MINTLIFY_API_URL ?? 'http://localhost:5000';
|
|
57
60
|
const accessToken = argv.accessToken;
|
|
58
61
|
const subdomain = argv.subdomain;
|
|
@@ -60,6 +63,8 @@ export const run = async (argv) => {
|
|
|
60
63
|
process.env.MINTLIFY_API_URL = apiUrl;
|
|
61
64
|
if (subdomain)
|
|
62
65
|
process.env.MINTLIFY_CLI_SUBDOMAIN = subdomain;
|
|
66
|
+
if (nativePackages)
|
|
67
|
+
app.use(packageRoute.prefix, packageRoute.handler);
|
|
63
68
|
// next-server is bugged, public files added after starting aren't served
|
|
64
69
|
app.use('/', express.static(NEXT_PUBLIC_PATH));
|
|
65
70
|
app.use((req, _res, next) => {
|
|
@@ -133,6 +138,8 @@ export const run = async (argv) => {
|
|
|
133
138
|
const onChange = () => {
|
|
134
139
|
io.emit('reload');
|
|
135
140
|
};
|
|
141
|
+
if (nativePackages)
|
|
142
|
+
setPackagesRebuiltListener(onChange);
|
|
136
143
|
setCompileListener((event) => {
|
|
137
144
|
io.emit('compiling', event);
|
|
138
145
|
});
|
|
@@ -184,6 +191,7 @@ export const run = async (argv) => {
|
|
|
184
191
|
disablePrefetch: argv.disablePrefetch,
|
|
185
192
|
allowSourceRefs: true,
|
|
186
193
|
lazyPages: true,
|
|
194
|
+
nativePackages,
|
|
187
195
|
}, watcherGate);
|
|
188
196
|
await timeDev('initialize import cache', () => initializeImportCache(CMD_EXEC_PATH, argv.fileImportsMap));
|
|
189
197
|
markOnDemandPagesReady();
|
package/dist/logging-state.d.ts
CHANGED
|
@@ -6,6 +6,7 @@ export declare const addChangeLog: (log: React.ReactNode) => void;
|
|
|
6
6
|
export declare const addErrorLog: (log: React.ReactNode) => void;
|
|
7
7
|
export declare const addRawErrorLog: (message: string) => void;
|
|
8
8
|
export declare const clearErrorLogs: () => void;
|
|
9
|
+
export declare const removeErrorLogs: (targets: readonly React.ReactNode[]) => void;
|
|
9
10
|
export declare const clearLogs: () => void;
|
|
10
11
|
export declare const removeLastLog: () => void;
|
|
11
12
|
export declare const removeLog: (target: React.ReactNode) => void;
|
package/dist/logging-state.js
CHANGED
|
@@ -47,6 +47,11 @@ export const clearErrorLogs = () => {
|
|
|
47
47
|
currentErrorLogs = [];
|
|
48
48
|
setErrorLogsCallback?.(currentErrorLogs);
|
|
49
49
|
};
|
|
50
|
+
export const removeErrorLogs = (targets) => {
|
|
51
|
+
ensureLoggingInstance();
|
|
52
|
+
currentErrorLogs = currentErrorLogs.filter((log) => !targets.includes(log));
|
|
53
|
+
setErrorLogsCallback?.(currentErrorLogs);
|
|
54
|
+
};
|
|
50
55
|
export const clearLogs = () => {
|
|
51
56
|
ensureLoggingInstance();
|
|
52
57
|
currentLogs = [];
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
+
import type { BuildDiagnostic } from '@mintlify/package-builder';
|
|
1
2
|
type PackageBuilder = typeof import('@mintlify/package-builder');
|
|
2
3
|
export declare const PACKAGE_BUILDER_MISSING = "The optional @mintlify/package-builder dependency is not installed, so npm packages are unavailable. npm skips it under --omit=optional or when esbuild fails to install; reinstall mint with --include=optional --foreground-scripts to see why.";
|
|
3
4
|
export declare const loadPackageBuilder: (load?: () => Promise<PackageBuilder>) => Promise<PackageBuilder>;
|
|
5
|
+
export declare const formatDiagnostic: ({ pkg, message }: BuildDiagnostic) => string;
|
|
4
6
|
export {};
|
package/dist/packages/builder.js
CHANGED
package/dist/packages/index.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
export { checkPackages, describeBuild, type PackagesCheckLine, type PackagesCheckOptions, type PackagesCheckResult, } from './check.js';
|
|
2
1
|
export { collectPackageIslands, PackageIslandCollector, resolvePageContent, type CollectedIslands, type CollectPackageIslandsInput, type PackageIslandProblem, type PageIslands, } from './collect.js';
|
|
3
2
|
export { isNativePackagesEnabled } from './flag.js';
|
|
4
3
|
export { normalizeProviderPath, readPackagesSetup, type PackagesSetup } from './setup.js';
|
package/dist/packages/index.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
export { checkPackages, describeBuild, } from './check.js';
|
|
2
1
|
export { collectPackageIslands, PackageIslandCollector, resolvePageContent, } from './collect.js';
|
|
3
2
|
export { isNativePackagesEnabled } from './flag.js';
|
|
4
3
|
export { normalizeProviderPath, readPackagesSetup } from './setup.js';
|
package/dist/packages/setup.d.ts
CHANGED
|
@@ -11,6 +11,8 @@ export declare class DocsJsonError extends Error {
|
|
|
11
11
|
constructor(problems: string[]);
|
|
12
12
|
}
|
|
13
13
|
export declare class InvalidPackagesError extends DocsJsonError {
|
|
14
|
+
readonly variables: Record<string, string> | undefined;
|
|
15
|
+
constructor(problems: string[], variables: Record<string, string> | undefined);
|
|
14
16
|
}
|
|
15
17
|
export declare const normalizeProviderPath: (provider: string) => string;
|
|
16
18
|
export declare const readPackagesSetup: (docsRoot: string) => Promise<PackagesSetup | undefined>;
|
package/dist/packages/setup.js
CHANGED
|
@@ -12,6 +12,10 @@ export class DocsJsonError extends Error {
|
|
|
12
12
|
}
|
|
13
13
|
}
|
|
14
14
|
export class InvalidPackagesError extends DocsJsonError {
|
|
15
|
+
constructor(problems, variables) {
|
|
16
|
+
super(problems);
|
|
17
|
+
this.variables = variables;
|
|
18
|
+
}
|
|
15
19
|
}
|
|
16
20
|
const messageOf = (error) => (error instanceof Error ? error.message : String(error));
|
|
17
21
|
const readText = async (path) => {
|
|
@@ -51,7 +55,7 @@ export const readPackagesSetup = async (docsRoot) => {
|
|
|
51
55
|
return undefined;
|
|
52
56
|
const parsed = packagesSchema.safeParse(docsConfig.packages);
|
|
53
57
|
if (!parsed.success) {
|
|
54
|
-
throw new InvalidPackagesError(parsed.error.issues.map((issue) => `docs.json ${['packages', ...issue.path].join('.')}: ${issue.message}`));
|
|
58
|
+
throw new InvalidPackagesError(parsed.error.issues.map((issue) => `docs.json ${['packages', ...issue.path].join('.')}: ${issue.message}`), readVariables(docsConfig.variables));
|
|
55
59
|
}
|
|
56
60
|
const packages = parsed.data;
|
|
57
61
|
if (packages.provider !== undefined)
|