dumi 2.4.40 → 2.4.42
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/features/compile/index.js +7 -1
- package/dist/features/compile/utoopackLoaders.d.ts +2 -1
- package/dist/features/compile/utoopackLoaders.js +5 -1
- package/dist/features/exportStatic.js +34 -1
- package/dist/loaders/markdown/index.d.ts +2 -0
- package/dist/loaders/markdown/index.js +35 -7
- package/package.json +7 -7
|
@@ -118,6 +118,11 @@ var compile_default = (api) => {
|
|
|
118
118
|
fn() {
|
|
119
119
|
var _a, _b;
|
|
120
120
|
if (api.config.utoopack) {
|
|
121
|
+
const demoAssetsFile = import_path.default.join(
|
|
122
|
+
api.paths.absTmpPath,
|
|
123
|
+
import_utoopackLoaders.UTOOPACK_DEMO_ASSETS_FILENAME
|
|
124
|
+
);
|
|
125
|
+
import_fs.default.rmSync(demoAssetsFile, { force: true });
|
|
121
126
|
api.writeTmpFile({
|
|
122
127
|
noPluginDir: true,
|
|
123
128
|
path: import_utoopackLoaders.LOADER_CTX_FILENAME,
|
|
@@ -127,7 +132,8 @@ var compile_default = (api) => {
|
|
|
127
132
|
api.appData.routes ?? {},
|
|
128
133
|
api.config.extraRemarkPlugins,
|
|
129
134
|
api.config.extraRehypePlugins,
|
|
130
|
-
((_b = api.service.configManager) == null ? void 0 : _b.files) ?? []
|
|
135
|
+
((_b = api.service.configManager) == null ? void 0 : _b.files) ?? [],
|
|
136
|
+
demoAssetsFile
|
|
131
137
|
)
|
|
132
138
|
});
|
|
133
139
|
}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import type { IApi, IDumiTechStack } from '../../types';
|
|
2
2
|
export declare const UTOOPACK_LOADER_CTX_KEY = "__dumiLoaderContextPath";
|
|
3
3
|
export declare const LOADER_CTX_FILENAME = "dumi-loader-ctx.cjs";
|
|
4
|
+
export declare const UTOOPACK_DEMO_ASSETS_FILENAME = "dumi-utoopack-demo-assets.jsonl";
|
|
4
5
|
export declare function buildLoaderContextContent(techStacks: IDumiTechStack[], builtins?: Record<string, {
|
|
5
6
|
specifier: string;
|
|
6
7
|
source: string;
|
|
7
|
-
}>, routes?: Record<string, unknown>, extraRemarkPlugins?: IApi['config']['extraRemarkPlugins'], extraRehypePlugins?: IApi['config']['extraRehypePlugins'], sourceFiles?: string[]): string;
|
|
8
|
+
}>, routes?: Record<string, unknown>, extraRemarkPlugins?: IApi['config']['extraRemarkPlugins'], extraRehypePlugins?: IApi['config']['extraRehypePlugins'], sourceFiles?: string[], demoAssetsFile?: string): string;
|
|
8
9
|
export declare const getUtoopackRules: (api: IApi, config?: IApi['config']) => Record<string, unknown>;
|
|
@@ -30,6 +30,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
30
30
|
var utoopackLoaders_exports = {};
|
|
31
31
|
__export(utoopackLoaders_exports, {
|
|
32
32
|
LOADER_CTX_FILENAME: () => LOADER_CTX_FILENAME,
|
|
33
|
+
UTOOPACK_DEMO_ASSETS_FILENAME: () => UTOOPACK_DEMO_ASSETS_FILENAME,
|
|
33
34
|
UTOOPACK_LOADER_CTX_KEY: () => UTOOPACK_LOADER_CTX_KEY,
|
|
34
35
|
buildLoaderContextContent: () => buildLoaderContextContent,
|
|
35
36
|
getUtoopackRules: () => getUtoopackRules
|
|
@@ -44,6 +45,7 @@ var utilsRegisterPath = require.resolve("@umijs/utils");
|
|
|
44
45
|
var esbuildImplementorPath = require.resolve("@umijs/bundler-utils/compiled/esbuild");
|
|
45
46
|
var UTOOPACK_LOADER_CTX_KEY = "__dumiLoaderContextPath";
|
|
46
47
|
var LOADER_CTX_FILENAME = "dumi-loader-ctx.cjs";
|
|
48
|
+
var UTOOPACK_DEMO_ASSETS_FILENAME = "dumi-utoopack-demo-assets.jsonl";
|
|
47
49
|
function toSerializable(value) {
|
|
48
50
|
return JSON.parse(JSON.stringify(value));
|
|
49
51
|
}
|
|
@@ -169,7 +171,7 @@ function toPluginRefs(plugins = [], sourceFiles = []) {
|
|
|
169
171
|
return toPluginTargetRef(plugin, sourceFiles);
|
|
170
172
|
}).join(", ")}]`;
|
|
171
173
|
}
|
|
172
|
-
function buildLoaderContextContent(techStacks, builtins = {}, routes = {}, extraRemarkPlugins = [], extraRehypePlugins = [], sourceFiles = []) {
|
|
174
|
+
function buildLoaderContextContent(techStacks, builtins = {}, routes = {}, extraRemarkPlugins = [], extraRehypePlugins = [], sourceFiles = [], demoAssetsFile) {
|
|
173
175
|
const refs = toTechStackRefs(techStacks);
|
|
174
176
|
return `'use strict';
|
|
175
177
|
try {
|
|
@@ -184,6 +186,7 @@ try {
|
|
|
184
186
|
exports.techStacks = [${refs.join(", ")}];
|
|
185
187
|
exports.builtins = ${JSON.stringify(builtins)};
|
|
186
188
|
exports.routes = ${JSON.stringify(routes)};
|
|
189
|
+
exports.demoAssetsFile = ${JSON.stringify(demoAssetsFile)};
|
|
187
190
|
exports.extraRemarkPlugins = ${toPluginRefs(
|
|
188
191
|
extraRemarkPlugins,
|
|
189
192
|
sourceFiles
|
|
@@ -363,6 +366,7 @@ var getUtoopackRules = (api, config = api.config) => {
|
|
|
363
366
|
// Annotate the CommonJS export names for ESM import in node:
|
|
364
367
|
0 && (module.exports = {
|
|
365
368
|
LOADER_CTX_FILENAME,
|
|
369
|
+
UTOOPACK_DEMO_ASSETS_FILENAME,
|
|
366
370
|
UTOOPACK_LOADER_CTX_KEY,
|
|
367
371
|
buildLoaderContextContent,
|
|
368
372
|
getUtoopackRules
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
1
2
|
var __defProp = Object.defineProperty;
|
|
2
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
4
6
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
7
|
var __export = (target, all) => {
|
|
6
8
|
for (var name in all)
|
|
@@ -14,6 +16,14 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
14
16
|
}
|
|
15
17
|
return to;
|
|
16
18
|
};
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
24
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
25
|
+
mod
|
|
26
|
+
));
|
|
17
27
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
28
|
|
|
19
29
|
// src/features/exportStatic.ts
|
|
@@ -23,12 +33,27 @@ __export(exportStatic_exports, {
|
|
|
23
33
|
});
|
|
24
34
|
module.exports = __toCommonJS(exportStatic_exports);
|
|
25
35
|
var import_constants = require("../constants");
|
|
36
|
+
var import_fs = __toESM(require("fs"));
|
|
37
|
+
var import_path = __toESM(require("path"));
|
|
38
|
+
var import_plugin_utils = require("umi/plugin-utils");
|
|
26
39
|
var import_assets = require("./assets");
|
|
40
|
+
var import_utoopackLoaders = require("./compile/utoopackLoaders");
|
|
27
41
|
var NO_PRERENDER_ROUTES = [
|
|
28
42
|
// disable prerender for demo render page, because umi-hd doesn't support ssr
|
|
29
43
|
// ref: https://github.com/umijs/dumi/pull/1451
|
|
30
44
|
"demo-render"
|
|
31
45
|
];
|
|
46
|
+
function readExampleAssetsFile(filePath) {
|
|
47
|
+
if (!import_fs.default.existsSync(filePath))
|
|
48
|
+
return [];
|
|
49
|
+
return import_fs.default.readFileSync(filePath, "utf-8").split("\n").filter(Boolean).reduce((acc, line) => {
|
|
50
|
+
try {
|
|
51
|
+
acc.push(JSON.parse(line));
|
|
52
|
+
} catch {
|
|
53
|
+
}
|
|
54
|
+
return acc;
|
|
55
|
+
}, []);
|
|
56
|
+
}
|
|
32
57
|
var exportStatic_default = (api) => {
|
|
33
58
|
api.describe({
|
|
34
59
|
key: "dumi:exportStatic",
|
|
@@ -50,7 +75,15 @@ var exportStatic_default = (api) => {
|
|
|
50
75
|
before: "exportStatic",
|
|
51
76
|
fn(memo) {
|
|
52
77
|
const routePrefix = `${import_constants.SP_ROUTE_PREFIX}demos`;
|
|
53
|
-
const examples =
|
|
78
|
+
const examples = import_plugin_utils.lodash.uniqBy(
|
|
79
|
+
[
|
|
80
|
+
...(0, import_assets.getExampleAssets)(),
|
|
81
|
+
...readExampleAssetsFile(
|
|
82
|
+
import_path.default.join(api.paths.absTmpPath, import_utoopackLoaders.UTOOPACK_DEMO_ASSETS_FILENAME)
|
|
83
|
+
)
|
|
84
|
+
],
|
|
85
|
+
"id"
|
|
86
|
+
);
|
|
54
87
|
api.appData.exportHtmlData.push(
|
|
55
88
|
...examples.map(({ id }) => ({
|
|
56
89
|
route: { path: `/${routePrefix}/${id}` },
|
|
@@ -5,6 +5,7 @@ interface IMdLoaderDefaultModeOptions extends Omit<IMdTransformerOptions, 'fileA
|
|
|
5
5
|
builtins: IThemeLoadResult['builtins'];
|
|
6
6
|
onResolveDemos?: (demos: NonNullable<IMdTransformerResult['meta']['demos']>) => void;
|
|
7
7
|
onResolveAtomMeta?: (atomId: string, meta: IMdTransformerResult['meta']['frontmatter']) => void;
|
|
8
|
+
demoAssetsFile?: string;
|
|
8
9
|
disableLiveDemo: boolean;
|
|
9
10
|
}
|
|
10
11
|
interface IMdLoaderDemosModeOptions extends Omit<IMdLoaderDefaultModeOptions, 'builtins' | 'mode'> {
|
|
@@ -27,5 +28,6 @@ type MdLoaderCache = {
|
|
|
27
28
|
getSync: (key: string, defaultValue: any) => any;
|
|
28
29
|
};
|
|
29
30
|
export declare function getMdLoaderCacheSync<T>(cache: MdLoaderCache, key: string, defaultValue: T): T;
|
|
31
|
+
export declare function getDemoSourceFiles(demos?: IMdTransformerResult['meta']['demos']): string[];
|
|
30
32
|
export default function mdLoader(this: any, content: string): void;
|
|
31
33
|
export {};
|
|
@@ -30,6 +30,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
30
30
|
var markdown_exports = {};
|
|
31
31
|
__export(markdown_exports, {
|
|
32
32
|
default: () => mdLoader,
|
|
33
|
+
getDemoSourceFiles: () => getDemoSourceFiles,
|
|
33
34
|
getMdLoaderCacheSync: () => getMdLoaderCacheSync
|
|
34
35
|
});
|
|
35
36
|
module.exports = __toCommonJS(markdown_exports);
|
|
@@ -55,15 +56,24 @@ function getMdLoaderCacheSync(cache, key, defaultValue) {
|
|
|
55
56
|
throw err;
|
|
56
57
|
}
|
|
57
58
|
}
|
|
59
|
+
function getDemoSidecarFiles(file) {
|
|
60
|
+
const { dir, name } = import_path.default.parse(file);
|
|
61
|
+
const mdFile = import_path.default.join(dir, `${name}.md`);
|
|
62
|
+
return import_fs.default.existsSync(mdFile) ? [mdFile] : [];
|
|
63
|
+
}
|
|
58
64
|
function getDemoSourceFiles(demos = []) {
|
|
59
|
-
|
|
65
|
+
const files = /* @__PURE__ */ new Set();
|
|
66
|
+
demos.forEach((demo) => {
|
|
60
67
|
if ("resolveMap" in demo) {
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
68
|
+
Object.values(demo.resolveMap).filter((p) => import_path.default.isAbsolute(p)).forEach((file) => {
|
|
69
|
+
files.add(file);
|
|
70
|
+
getDemoSidecarFiles(file).forEach(
|
|
71
|
+
(sidecarFile) => files.add(sidecarFile)
|
|
72
|
+
);
|
|
73
|
+
});
|
|
64
74
|
}
|
|
65
|
-
|
|
66
|
-
|
|
75
|
+
});
|
|
76
|
+
return Array.from(files);
|
|
67
77
|
}
|
|
68
78
|
function isRelativePath(path2) {
|
|
69
79
|
return /^\.{1,2}(?!\w)/.test(path2);
|
|
@@ -86,6 +96,18 @@ function emitDefault(opts, ret) {
|
|
|
86
96
|
if (demos && opts.onResolveDemos) {
|
|
87
97
|
opts.onResolveDemos(demos);
|
|
88
98
|
}
|
|
99
|
+
if (demos && opts.demoAssetsFile) {
|
|
100
|
+
const assets = demos.reduce((acc, demo) => {
|
|
101
|
+
if ("asset" in demo)
|
|
102
|
+
acc.push(JSON.stringify(demo.asset));
|
|
103
|
+
return acc;
|
|
104
|
+
}, []);
|
|
105
|
+
if (assets.length) {
|
|
106
|
+
import_fs.default.mkdirSync(import_path.default.dirname(opts.demoAssetsFile), { recursive: true });
|
|
107
|
+
import_fs.default.appendFileSync(opts.demoAssetsFile, `${assets.join("\n")}
|
|
108
|
+
`);
|
|
109
|
+
}
|
|
110
|
+
}
|
|
89
111
|
if (frontmatter.atomId && opts.onResolveAtomMeta) {
|
|
90
112
|
opts.onResolveAtomMeta(frontmatter.atomId, frontmatter);
|
|
91
113
|
}
|
|
@@ -371,9 +393,14 @@ function mdLoader(content) {
|
|
|
371
393
|
if (ctx.extraRehypePlugins && !((_c = opts.extraRehypePlugins) == null ? void 0 : _c.length)) {
|
|
372
394
|
opts.extraRehypePlugins = ctx.extraRehypePlugins;
|
|
373
395
|
}
|
|
396
|
+
if (ctx.demoAssetsFile && !opts.demoAssetsFile) {
|
|
397
|
+
opts.demoAssetsFile = ctx.demoAssetsFile;
|
|
398
|
+
}
|
|
374
399
|
}
|
|
375
400
|
const cb = this.async();
|
|
376
|
-
if (process.env.NODE_ENV === "production" && ["onResolveDemos", "onResolveAtomMeta"].some(
|
|
401
|
+
if (process.env.NODE_ENV === "production" && ["onResolveDemos", "onResolveAtomMeta", "demoAssetsFile"].some(
|
|
402
|
+
(k) => k in opts
|
|
403
|
+
)) {
|
|
377
404
|
this.cacheable(false);
|
|
378
405
|
}
|
|
379
406
|
const cache = (0, import_utils.getCache)("md-loader");
|
|
@@ -417,5 +444,6 @@ function mdLoader(content) {
|
|
|
417
444
|
}
|
|
418
445
|
// Annotate the CommonJS export names for ESM import in node:
|
|
419
446
|
0 && (module.exports = {
|
|
447
|
+
getDemoSourceFiles,
|
|
420
448
|
getMdLoaderCacheSync
|
|
421
449
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dumi",
|
|
3
|
-
"version": "2.4.
|
|
3
|
+
"version": "2.4.42",
|
|
4
4
|
"description": "📖 Documentation Generator of React Component",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"generator",
|
|
@@ -69,9 +69,9 @@
|
|
|
69
69
|
"@swc/core": "1.9.2",
|
|
70
70
|
"@types/hast": "^2.3.5",
|
|
71
71
|
"@types/mdast": "^3.0.12",
|
|
72
|
-
"@umijs/bundler-utils": "^4.6.
|
|
73
|
-
"@umijs/core": "^4.6.
|
|
74
|
-
"@umijs/utils": "^4.6.
|
|
72
|
+
"@umijs/bundler-utils": "^4.6.74",
|
|
73
|
+
"@umijs/core": "^4.6.74",
|
|
74
|
+
"@umijs/utils": "^4.6.74",
|
|
75
75
|
"animated-scroll-to": "^2.3.0",
|
|
76
76
|
"classnames": "2.3.2",
|
|
77
77
|
"codesandbox-import-utils": "^2.2.3",
|
|
@@ -123,7 +123,7 @@
|
|
|
123
123
|
"sass": "^1.64.1",
|
|
124
124
|
"sitemap": "^7.1.1",
|
|
125
125
|
"sucrase": "^3.34.0",
|
|
126
|
-
"umi": "^4.6.
|
|
126
|
+
"umi": "^4.6.74",
|
|
127
127
|
"unified": "^10.1.2",
|
|
128
128
|
"unist-util-visit": "^4.1.2",
|
|
129
129
|
"unist-util-visit-parents": "^5.1.3",
|
|
@@ -147,8 +147,8 @@
|
|
|
147
147
|
"@types/react-copy-to-clipboard": "^5.0.4",
|
|
148
148
|
"@types/react-dom": "^18.2.7",
|
|
149
149
|
"@typescript/native-preview": "7.0.0-dev.20260623.1",
|
|
150
|
-
"@umijs/lint": "^4.6.
|
|
151
|
-
"@umijs/plugins": "4.6.
|
|
150
|
+
"@umijs/lint": "^4.6.74",
|
|
151
|
+
"@umijs/plugins": "4.6.74",
|
|
152
152
|
"eslint": "^8.46.0",
|
|
153
153
|
"esno": "^4.7.0",
|
|
154
154
|
"fast-glob": "^3.3.1",
|