@ckeditor/ckeditor5-dev-manual-server 56.2.1 → 56.3.0
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/index.js +30 -10
- package/dist/manual-test-plugin/shell-html.d.ts +2 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -205,8 +205,8 @@ function loadRenderedInstructions(entry, workspaceRoot) {
|
|
|
205
205
|
* @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
|
|
206
206
|
* For licensing, see LICENSE.md.
|
|
207
207
|
*/
|
|
208
|
-
function createManualShellHtml({ entry, html, shellScriptPublicPath, shellTemplateFilePath, workspaceRoot }) {
|
|
209
|
-
const shellDocument = parse(readFileSync(shellTemplateFilePath, "utf8"));
|
|
208
|
+
function createManualShellHtml({ catalogPublicPath = "/", entry, html, shellScriptPublicPath, shellTemplateFilePath, workspaceRoot }) {
|
|
209
|
+
const shellDocument = parse(readFileSync(shellTemplateFilePath, "utf8").replace("href=\"/\" title=\"Back to test index\"", `href="${catalogPublicPath}" title="Back to test index"`));
|
|
210
210
|
const shellHead = getRequiredElementByTagName$1(shellDocument, "head");
|
|
211
211
|
const shellBody = getRequiredElementByTagName$1(shellDocument, "body");
|
|
212
212
|
const shellTitle = getRequiredElementByTagName$1(shellHead, "title");
|
|
@@ -314,6 +314,7 @@ const MANUAL_SHELL_TEMPLATE_FILE_PATH = resolve(MANUAL_THEME_ROOT, "shell.html")
|
|
|
314
314
|
const MANUAL_SHELL_SCRIPT_FILE_PATH = resolve(MANUAL_THEME_ROOT, "shell.ts");
|
|
315
315
|
function manualTestsPlugin(manualTestPatterns) {
|
|
316
316
|
let workspaceRoot = process.cwd();
|
|
317
|
+
let base = "/";
|
|
317
318
|
const manualPagePatterns = manualTestPatterns.map(toManualPagePattern);
|
|
318
319
|
const manualPagesCache = cacheValue(() => collectManualPages(manualPagePatterns, workspaceRoot));
|
|
319
320
|
const manualStaticAssetsCache = cacheValue(() => collectManualStaticAssets(manualTestPatterns, workspaceRoot));
|
|
@@ -327,13 +328,15 @@ function manualTestsPlugin(manualTestPatterns) {
|
|
|
327
328
|
return getManualPages().get(toPublicSpecifier(relative(workspaceRoot, filePath)));
|
|
328
329
|
};
|
|
329
330
|
const getManualCatalogPublicPath = () => toPublicFilePath(MANUAL_CATALOG_FILE_PATH, workspaceRoot);
|
|
331
|
+
const getManualCatalogBuildInputFilePath = () => resolve(workspaceRoot, "index.html");
|
|
330
332
|
const getManualCatalogScriptPublicPath = () => toPublicFilePath(MANUAL_CATALOG_SCRIPT_FILE_PATH, workspaceRoot);
|
|
331
333
|
const getManualShellScriptPublicPath = () => toPublicFilePath(MANUAL_SHELL_SCRIPT_FILE_PATH, workspaceRoot);
|
|
332
|
-
const
|
|
334
|
+
const getManualCatalogClientPath = (entry) => toBaseCatalogPath(base, entry.htmlFilePath);
|
|
335
|
+
const getManualBuildInputs = () => [getManualCatalogBuildInputFilePath(), ...[...getManualPages().values()].map((entry) => resolve(workspaceRoot, entry.htmlFilePath.slice(1)))];
|
|
333
336
|
const resolvedVirtualModuleId = `\0${MANUAL_ENTRIES_VIRTUAL_ID}`;
|
|
334
337
|
const getClientEntries = () => [...getManualPages().values()].map((entry) => ({
|
|
335
338
|
displayName: entry.displayName,
|
|
336
|
-
href: entry.htmlFilePath,
|
|
339
|
+
href: toBasePublicPath(entry.htmlFilePath, base),
|
|
337
340
|
packageName: entry.packageName,
|
|
338
341
|
slug: entry.slug
|
|
339
342
|
}));
|
|
@@ -345,23 +348,23 @@ function manualTestsPlugin(manualTestPatterns) {
|
|
|
345
348
|
},
|
|
346
349
|
configResolved(config) {
|
|
347
350
|
workspaceRoot = config.root;
|
|
351
|
+
base = config.base || "/";
|
|
348
352
|
invalidateManualFileCaches();
|
|
349
353
|
config.build.rolldownOptions.input = getManualBuildInputs();
|
|
350
354
|
},
|
|
351
355
|
configureServer(server) {
|
|
352
356
|
const { memoryFiles } = server.environments.client;
|
|
353
357
|
useManualTestMiddlewares(server, getManualCatalogPublicPath, getManualStaticAssets);
|
|
354
|
-
useBundledDevManualHtmlSource(memoryFiles, getManualPages, getManualShellScriptPublicPath, () => workspaceRoot);
|
|
355
|
-
},
|
|
356
|
-
configurePreviewServer(server) {
|
|
357
|
-
useManualCatalogMiddleware(server, getManualCatalogPublicPath);
|
|
358
|
+
useBundledDevManualHtmlSource(memoryFiles, getManualPages, getManualShellScriptPublicPath, getManualCatalogClientPath, () => workspaceRoot);
|
|
358
359
|
},
|
|
359
360
|
resolveId(source) {
|
|
360
361
|
if (source == MANUAL_ENTRIES_VIRTUAL_ID) return resolvedVirtualModuleId;
|
|
362
|
+
if (isManualCatalogBuildInputSpecifier(source, getManualCatalogBuildInputFilePath(), workspaceRoot)) return getManualCatalogBuildInputFilePath();
|
|
361
363
|
return null;
|
|
362
364
|
},
|
|
363
365
|
load(id) {
|
|
364
366
|
if (id == resolvedVirtualModuleId) return `export const manualTestEntries = ${getManualEntriesJson()};`;
|
|
367
|
+
if (toPosixPath(id) == toPosixPath(getManualCatalogBuildInputFilePath())) return readFileSync(MANUAL_CATALOG_FILE_PATH, "utf8");
|
|
365
368
|
return null;
|
|
366
369
|
},
|
|
367
370
|
generateBundle() {
|
|
@@ -374,10 +377,11 @@ function manualTestsPlugin(manualTestPatterns) {
|
|
|
374
377
|
transformIndexHtml: {
|
|
375
378
|
order: "pre",
|
|
376
379
|
handler(html, context) {
|
|
377
|
-
if (
|
|
380
|
+
if (isManualCatalogHtmlFile(context.filename, getManualCatalogBuildInputFilePath())) return html.replace("./catalog.ts", getManualCatalogScriptPublicPath());
|
|
378
381
|
const entry = getManualPageEntryForFile(context.filename);
|
|
379
382
|
if (!entry) return;
|
|
380
383
|
return createManualShellHtml({
|
|
384
|
+
catalogPublicPath: getManualCatalogClientPath(entry),
|
|
381
385
|
entry,
|
|
382
386
|
html,
|
|
383
387
|
shellScriptPublicPath: getManualShellScriptPublicPath(),
|
|
@@ -398,7 +402,7 @@ function useManualCatalogMiddleware(server, getManualCatalogPublicPath) {
|
|
|
398
402
|
next();
|
|
399
403
|
});
|
|
400
404
|
}
|
|
401
|
-
function useBundledDevManualHtmlSource(memoryFiles, getManualPages, getManualShellScriptPublicPath, getWorkspaceRoot) {
|
|
405
|
+
function useBundledDevManualHtmlSource(memoryFiles, getManualPages, getManualShellScriptPublicPath, getManualCatalogClientPath, getWorkspaceRoot) {
|
|
402
406
|
if (!memoryFiles) return;
|
|
403
407
|
const getBundledFile = memoryFiles.get.bind(memoryFiles);
|
|
404
408
|
memoryFiles.get = (filePath) => {
|
|
@@ -409,6 +413,7 @@ function useBundledDevManualHtmlSource(memoryFiles, getManualPages, getManualShe
|
|
|
409
413
|
const shellScriptPublicPath = getManualShellScriptPublicPath();
|
|
410
414
|
const bundledHtml = getFileSource(file);
|
|
411
415
|
return { source: mergeBundledAssetTags(createManualShellHtml({
|
|
416
|
+
catalogPublicPath: getManualCatalogClientPath(entry),
|
|
412
417
|
entry,
|
|
413
418
|
html: readFileSync(resolve(workspaceRoot, stripLeadingSlash(entry.htmlFilePath)), "utf8"),
|
|
414
419
|
shellScriptPublicPath,
|
|
@@ -424,6 +429,21 @@ function toManualPagePattern(pattern) {
|
|
|
424
429
|
if (/\.(?:html|js|md|ts|\{[^}]*\})$/.test(pattern)) return pattern;
|
|
425
430
|
return `${pattern}.{html,js,md,ts}`;
|
|
426
431
|
}
|
|
432
|
+
function isManualCatalogHtmlFile(filePath, catalogBuildInputFilePath) {
|
|
433
|
+
const normalizedFilePath = toPosixPath(filePath);
|
|
434
|
+
return normalizedFilePath == toPosixPath(MANUAL_CATALOG_FILE_PATH) || normalizedFilePath == toPosixPath(catalogBuildInputFilePath);
|
|
435
|
+
}
|
|
436
|
+
function isManualCatalogBuildInputSpecifier(source, catalogBuildInputFilePath, workspaceRoot) {
|
|
437
|
+
return toPosixPath(resolve(workspaceRoot, source)) == toPosixPath(catalogBuildInputFilePath);
|
|
438
|
+
}
|
|
439
|
+
function toBasePublicPath(publicPath, base) {
|
|
440
|
+
if (base == "" || base == "./") return `.${publicPath}`;
|
|
441
|
+
return `${base.replace(/\/$/, "")}${publicPath}`;
|
|
442
|
+
}
|
|
443
|
+
function toBaseCatalogPath(base, entryHtmlFilePath) {
|
|
444
|
+
if (base == "" || base == "./") return posix.relative(posix.dirname(stripLeadingSlash(entryHtmlFilePath)), "index.html");
|
|
445
|
+
return base;
|
|
446
|
+
}
|
|
427
447
|
function mergeBundledAssetTags(sourceHtml, bundledHtml, entry, shellScriptPublicPath) {
|
|
428
448
|
const sourceDocument = parse(sourceHtml);
|
|
429
449
|
const bundledDocument = parse(bundledHtml);
|
|
@@ -4,10 +4,11 @@
|
|
|
4
4
|
*/
|
|
5
5
|
import type { ManualPageEntry } from "./types.js";
|
|
6
6
|
export interface CreateManualShellHtmlOptions {
|
|
7
|
+
catalogPublicPath?: string;
|
|
7
8
|
entry: ManualPageEntry;
|
|
8
9
|
html: string;
|
|
9
10
|
shellScriptPublicPath: string;
|
|
10
11
|
shellTemplateFilePath: string;
|
|
11
12
|
workspaceRoot: string;
|
|
12
13
|
}
|
|
13
|
-
export declare function createManualShellHtml({ entry, html, shellScriptPublicPath, shellTemplateFilePath, workspaceRoot }: CreateManualShellHtmlOptions): string;
|
|
14
|
+
export declare function createManualShellHtml({ catalogPublicPath, entry, html, shellScriptPublicPath, shellTemplateFilePath, workspaceRoot }: CreateManualShellHtmlOptions): string;
|
package/package.json
CHANGED