dumi 2.4.48-alpha.0 → 2.4.48
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/assetParsers/block.js +14 -23
- package/dist/client/pages/Demo/index.js +3 -50
- package/dist/client/theme-api/DumiDemo/index.d.ts +0 -2
- package/dist/client/theme-api/DumiDemo/index.js +10 -68
- package/dist/client/theme-api/types.d.ts +0 -1
- package/dist/features/compile/index.js +4 -24
- package/dist/features/compile/utoopackLoaders.d.ts +0 -3
- package/dist/features/compile/utoopackLoaders.js +7 -25
- package/dist/loaders/markdown/index.d.ts +0 -34
- package/dist/loaders/markdown/index.js +52 -323
- package/dist/loaders/markdown/transformer/index.d.ts +0 -4
- package/dist/loaders/markdown/transformer/rehypeDemo.js +82 -129
- package/dist/techStacks/react.js +1 -2
- package/dist/types.d.ts +0 -6
- package/dist/utils.d.ts +1 -2
- package/dist/utils.js +2 -8
- package/package.json +7 -9
- package/theme-default/slots/SourceCodeEditor/index.js +0 -3
- package/dist/client/theme-api/DumiDemo/hmr.d.ts +0 -5
- package/dist/client/theme-api/DumiDemo/hmr.js +0 -67
- package/dist/loaders/markdown/sharedCache.d.ts +0 -11
- package/dist/loaders/markdown/sharedCache.js +0 -131
|
@@ -29,16 +29,9 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
29
29
|
// src/loaders/markdown/index.ts
|
|
30
30
|
var markdown_exports = {};
|
|
31
31
|
__export(markdown_exports, {
|
|
32
|
-
addDemoFileDependency: () => addDemoFileDependency,
|
|
33
|
-
createDependencyReader: () => createDependencyReader,
|
|
34
|
-
createStableTransform: () => createStableTransform,
|
|
35
32
|
default: () => mdLoader,
|
|
36
|
-
emitDemo: () => emitDemo,
|
|
37
33
|
getDemoSourceFiles: () => getDemoSourceFiles,
|
|
38
|
-
|
|
39
|
-
getMdLoaderCacheResult: () => getMdLoaderCacheResult,
|
|
40
|
-
getMdLoaderCacheSync: () => getMdLoaderCacheSync,
|
|
41
|
-
getMdTransformCacheKeys: () => getMdTransformCacheKeys
|
|
34
|
+
getMdLoaderCacheSync: () => getMdLoaderCacheSync
|
|
42
35
|
});
|
|
43
36
|
module.exports = __toCommonJS(markdown_exports);
|
|
44
37
|
var import_utoopackLoaders = require("../../features/compile/utoopackLoaders");
|
|
@@ -47,61 +40,8 @@ var import_utils = require("../../utils");
|
|
|
47
40
|
var import_fs = __toESM(require("fs"));
|
|
48
41
|
var import_path = __toESM(require("path"));
|
|
49
42
|
var import_plugin_utils = require("umi/plugin-utils");
|
|
50
|
-
var import_sharedCache = require("./sharedCache");
|
|
51
43
|
var import_transformer = __toESM(require("./transformer"));
|
|
52
44
|
var import_rehypeText = require("./transformer/rehypeText");
|
|
53
|
-
var MD_LOADER_RUNTIME_OPTION_KEYS = [
|
|
54
|
-
"mode",
|
|
55
|
-
"builtins",
|
|
56
|
-
"onResolveDemos",
|
|
57
|
-
"onResolveAtomMeta",
|
|
58
|
-
"demoAssetsFile",
|
|
59
|
-
"cacheDirectory",
|
|
60
|
-
"cacheEpoch"
|
|
61
|
-
];
|
|
62
|
-
function getMdTransformCacheKeys({
|
|
63
|
-
resourcePath,
|
|
64
|
-
content,
|
|
65
|
-
useUtoopackDemoHMR,
|
|
66
|
-
opts
|
|
67
|
-
}) {
|
|
68
|
-
const depsHintKey = [
|
|
69
|
-
resourcePath,
|
|
70
|
-
useUtoopackDemoHMR,
|
|
71
|
-
JSON.stringify(import_plugin_utils.lodash.omit(opts, MD_LOADER_RUNTIME_OPTION_KEYS))
|
|
72
|
-
].join(":");
|
|
73
|
-
return {
|
|
74
|
-
depsHintKey,
|
|
75
|
-
baseCacheKey: [depsHintKey, (0, import_utils.getContentHash)(content)].join(":")
|
|
76
|
-
};
|
|
77
|
-
}
|
|
78
|
-
function getStatRevision(stat) {
|
|
79
|
-
return [stat.dev, stat.ino, stat.mode, stat.size, stat.mtimeNs, stat.ctimeNs].map(String).join(":");
|
|
80
|
-
}
|
|
81
|
-
async function getFileRevision(file) {
|
|
82
|
-
return getStatRevision(await import_fs.default.promises.stat(file, { bigint: true }));
|
|
83
|
-
}
|
|
84
|
-
function isMissingFsError(err) {
|
|
85
|
-
return (err == null ? void 0 : err.code) === "ENOENT" || (err == null ? void 0 : err.code) === "ENOTDIR";
|
|
86
|
-
}
|
|
87
|
-
async function getMissingParentRevision(file) {
|
|
88
|
-
let current = file;
|
|
89
|
-
while (true) {
|
|
90
|
-
try {
|
|
91
|
-
const revision = getStatRevision(
|
|
92
|
-
await import_fs.default.promises.stat(current, { bigint: true })
|
|
93
|
-
);
|
|
94
|
-
return `${import_path.default.normalize(current)}:${current === file ? "<appeared>:" : ""}${revision}`;
|
|
95
|
-
} catch (err) {
|
|
96
|
-
if (!isMissingFsError(err))
|
|
97
|
-
throw err;
|
|
98
|
-
const parent = import_path.default.dirname(current);
|
|
99
|
-
if (parent === current)
|
|
100
|
-
return `${current}:<missing>`;
|
|
101
|
-
current = parent;
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
45
|
function isMalformedCacheError(err) {
|
|
106
46
|
return err instanceof SyntaxError || err instanceof Error && /Unexpected end of JSON input|Unterminated string in JSON/.test(
|
|
107
47
|
err.message
|
|
@@ -116,40 +56,25 @@ function getMdLoaderCacheSync(cache, key, defaultValue) {
|
|
|
116
56
|
throw err;
|
|
117
57
|
}
|
|
118
58
|
}
|
|
119
|
-
function
|
|
59
|
+
function getDemoSidecarFiles(file) {
|
|
120
60
|
const { dir, name } = import_path.default.parse(file);
|
|
121
|
-
|
|
61
|
+
const mdFile = import_path.default.join(dir, `${name}.md`);
|
|
62
|
+
return import_fs.default.existsSync(mdFile) ? [mdFile] : [];
|
|
122
63
|
}
|
|
123
|
-
function
|
|
64
|
+
function getDemoSourceFiles(demos = []) {
|
|
124
65
|
const files = /* @__PURE__ */ new Set();
|
|
125
66
|
demos.forEach((demo) => {
|
|
126
67
|
if ("resolveMap" in demo) {
|
|
127
68
|
Object.values(demo.resolveMap).filter((p) => import_path.default.isAbsolute(p)).forEach((file) => {
|
|
128
69
|
files.add(file);
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
}
|
|
70
|
+
getDemoSidecarFiles(file).forEach(
|
|
71
|
+
(sidecarFile) => files.add(sidecarFile)
|
|
72
|
+
);
|
|
133
73
|
});
|
|
134
74
|
}
|
|
135
75
|
});
|
|
136
76
|
return Array.from(files);
|
|
137
77
|
}
|
|
138
|
-
function getDemoSourceFiles(demos = []) {
|
|
139
|
-
return collectDemoSourceFiles(demos);
|
|
140
|
-
}
|
|
141
|
-
function getDemoCacheFiles(demos = []) {
|
|
142
|
-
return collectDemoSourceFiles(demos, true);
|
|
143
|
-
}
|
|
144
|
-
function addDemoFileDependency(loaderContext, opts, file) {
|
|
145
|
-
if (import_fs.default.existsSync(file) || import_utoopackLoaders.UTOOPACK_LOADER_CTX_KEY in opts) {
|
|
146
|
-
loaderContext.addDependency(file);
|
|
147
|
-
} else if (loaderContext.addMissingDependency) {
|
|
148
|
-
loaderContext.addMissingDependency(file);
|
|
149
|
-
} else {
|
|
150
|
-
loaderContext.addDependency(file);
|
|
151
|
-
}
|
|
152
|
-
}
|
|
153
78
|
function isRelativePath(path2) {
|
|
154
79
|
return /^\.{1,2}(?!\w)/.test(path2);
|
|
155
80
|
}
|
|
@@ -218,21 +143,6 @@ export default DumiMarkdownContent;`;
|
|
|
218
143
|
}
|
|
219
144
|
function emitDemo(opts, ret) {
|
|
220
145
|
const { demos } = ret.meta;
|
|
221
|
-
const demoHMRVersions = Object.fromEntries(
|
|
222
|
-
(demos ?? []).flatMap((demo) => {
|
|
223
|
-
const hmrVersion = demo.__dumiUtoopackHMRVersion;
|
|
224
|
-
return typeof hmrVersion === "string" ? [[demo.id, hmrVersion]] : [];
|
|
225
|
-
})
|
|
226
|
-
);
|
|
227
|
-
const enableDemoHMR = opts.useUtoopackDemoHMR === true && Object.keys(demoHMRVersions).length > 0;
|
|
228
|
-
const demoHMRModuleId = JSON.stringify(
|
|
229
|
-
(0, import_plugin_utils.winPath)(`${this.resourcePath}?type=demo`)
|
|
230
|
-
);
|
|
231
|
-
const enableUtoopackSelfAccept = enableDemoHMR && import_utoopackLoaders.UTOOPACK_LOADER_CTX_KEY in opts;
|
|
232
|
-
const renderedDemos = demos == null ? void 0 : demos.map((demo) => ({
|
|
233
|
-
...demo,
|
|
234
|
-
renderedPreviewerProps: "previewerProps" in demo && demo.previewerProps ? JSON.stringify(demo.previewerProps) : void 0
|
|
235
|
-
}));
|
|
236
146
|
const shareDepsMap = {};
|
|
237
147
|
const demoDepsMap = {};
|
|
238
148
|
const relativeDepsMap = {};
|
|
@@ -275,9 +185,6 @@ function emitDemo(opts, ret) {
|
|
|
275
185
|
return import_plugin_utils.Mustache.render(
|
|
276
186
|
`import React from 'react';
|
|
277
187
|
import '${(0, import_plugin_utils.winPath)(this.resourcePath)}?watch=parent';
|
|
278
|
-
{{#enableDemoHMR}}
|
|
279
|
-
import { registerDemoHMRModule } from 'dumi/dist/client/theme-api/DumiDemo/hmr';
|
|
280
|
-
{{/enableDemoHMR}}
|
|
281
188
|
{{#dedupedDemosDeps}}
|
|
282
189
|
import * as {{{specifier}}} from '{{{key}}}';
|
|
283
190
|
{{/dedupedDemosDeps}}
|
|
@@ -292,29 +199,13 @@ export const demos = {
|
|
|
292
199
|
routeId: '{{{routeId}}}',
|
|
293
200
|
{{/routeId}}
|
|
294
201
|
context: {{{renderContext}}},
|
|
295
|
-
{{#previewerProps}}
|
|
296
|
-
previewerProps: {{{renderedPreviewerProps}}},
|
|
297
|
-
{{/previewerProps}}
|
|
298
202
|
renderOpts: {{{renderRenderOpts}}},
|
|
299
203
|
},
|
|
300
204
|
{{/demos}}
|
|
301
|
-
}
|
|
302
|
-
if (
|
|
303
|
-
typeof __turbopack_context__ !== 'undefined' &&
|
|
304
|
-
typeof __turbopack_context__.m?.hot?.accept === 'function'
|
|
305
|
-
) {
|
|
306
|
-
__turbopack_context__.m.hot.accept();
|
|
307
|
-
}
|
|
308
|
-
{{/enableUtoopackSelfAccept}}{{#enableDemoHMR}}
|
|
309
|
-
registerDemoHMRModule({{{demoHMRModuleId}}}, {{{demoHMRVersions}}});
|
|
310
|
-
{{/enableDemoHMR}}`,
|
|
205
|
+
};`,
|
|
311
206
|
{
|
|
312
|
-
demos
|
|
207
|
+
demos,
|
|
313
208
|
dedupedDemosDeps,
|
|
314
|
-
demoHMRModuleId,
|
|
315
|
-
demoHMRVersions: JSON.stringify(demoHMRVersions),
|
|
316
|
-
enableDemoHMR,
|
|
317
|
-
enableUtoopackSelfAccept,
|
|
318
209
|
routeId,
|
|
319
210
|
renderAsset: function renderAsset() {
|
|
320
211
|
if (!("asset" in this))
|
|
@@ -454,9 +345,7 @@ function emit(opts, ret) {
|
|
|
454
345
|
const { demos, embeds } = ret.meta;
|
|
455
346
|
embeds.forEach((file) => this.addDependency(file));
|
|
456
347
|
if (opts.mode !== "demo-index") {
|
|
457
|
-
|
|
458
|
-
(file) => addDemoFileDependency(this, opts, file)
|
|
459
|
-
);
|
|
348
|
+
getDemoSourceFiles(demos).forEach((file) => this.addDependency(file));
|
|
460
349
|
}
|
|
461
350
|
if (this.resourceQuery.includes("watch=parent"))
|
|
462
351
|
return null;
|
|
@@ -473,108 +362,20 @@ function emit(opts, ret) {
|
|
|
473
362
|
return emitDefault.call(this, opts, ret);
|
|
474
363
|
}
|
|
475
364
|
}
|
|
476
|
-
function
|
|
477
|
-
return Array.from(new Set(deps)).sort();
|
|
478
|
-
}
|
|
479
|
-
var readDependencyFromFs = (file) => import_fs.default.promises.readFile(file, "utf-8");
|
|
480
|
-
async function getDepsCacheKey(deps = [], readDependency = readDependencyFromFs) {
|
|
365
|
+
function getDepsCacheKey(deps = []) {
|
|
481
366
|
return JSON.stringify(
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
try {
|
|
485
|
-
const content = await readDependency(file);
|
|
486
|
-
return `${file}:${(0, import_utils.getContentHash)(content)}:${await getFileRevision(
|
|
487
|
-
file
|
|
488
|
-
)}`;
|
|
489
|
-
} catch (err) {
|
|
490
|
-
if (isMissingFsError(err)) {
|
|
491
|
-
return `${file}:<missing>:${await getMissingParentRevision(file)}`;
|
|
492
|
-
}
|
|
493
|
-
throw err;
|
|
494
|
-
}
|
|
495
|
-
})
|
|
367
|
+
deps.map(
|
|
368
|
+
(file) => `${file}:${(0, import_utils.getContentHash)(import_fs.default.readFileSync(file, "utf-8"))}`
|
|
496
369
|
)
|
|
497
370
|
);
|
|
498
371
|
}
|
|
499
|
-
function getMdLoaderCacheRecord(cache, key) {
|
|
500
|
-
const record = getMdLoaderCacheSync(
|
|
501
|
-
cache,
|
|
502
|
-
key,
|
|
503
|
-
void 0
|
|
504
|
-
);
|
|
505
|
-
return (record == null ? void 0 : record.version) === 2 ? record : void 0;
|
|
506
|
-
}
|
|
507
|
-
async function getValidMdLoaderCacheRecord(cache, key, readDependency = readDependencyFromFs) {
|
|
508
|
-
const record = getMdLoaderCacheRecord(cache, key);
|
|
509
|
-
if (!record)
|
|
510
|
-
return void 0;
|
|
511
|
-
if (record.depsKey === await getDepsCacheKey(record.deps, readDependency)) {
|
|
512
|
-
return record;
|
|
513
|
-
}
|
|
514
|
-
return void 0;
|
|
515
|
-
}
|
|
516
|
-
async function getMdLoaderCacheResult(cache, key, readDependency = readDependencyFromFs) {
|
|
517
|
-
var _a;
|
|
518
|
-
return (_a = await getValidMdLoaderCacheRecord(cache, key, readDependency)) == null ? void 0 : _a.result;
|
|
519
|
-
}
|
|
520
|
-
async function createStableTransform({
|
|
521
|
-
initialDeps,
|
|
522
|
-
createValue,
|
|
523
|
-
getDeps,
|
|
524
|
-
readDependency = readDependencyFromFs,
|
|
525
|
-
onDepsDiscovered,
|
|
526
|
-
maxAttempts = 3
|
|
527
|
-
}) {
|
|
528
|
-
let expectedDeps = initialDeps && normalizeDeps(initialDeps);
|
|
529
|
-
for (let attempt = 0; attempt < maxAttempts; attempt += 1) {
|
|
530
|
-
const beforeKey = expectedDeps ? await getDepsCacheKey(expectedDeps, readDependency) : void 0;
|
|
531
|
-
const result = await createValue();
|
|
532
|
-
const deps = normalizeDeps(getDeps(result));
|
|
533
|
-
const depsKey = await getDepsCacheKey(deps, readDependency);
|
|
534
|
-
onDepsDiscovered == null ? void 0 : onDepsDiscovered(deps);
|
|
535
|
-
if (expectedDeps && JSON.stringify(expectedDeps) === JSON.stringify(deps) && beforeKey === depsKey) {
|
|
536
|
-
return { version: 2, deps, depsKey, result };
|
|
537
|
-
}
|
|
538
|
-
expectedDeps = deps;
|
|
539
|
-
}
|
|
540
|
-
throw Object.assign(
|
|
541
|
-
new Error("Markdown dependencies changed repeatedly while transforming"),
|
|
542
|
-
{ code: "EDEPSUNSTABLE" }
|
|
543
|
-
);
|
|
544
|
-
}
|
|
545
|
-
function createDependencyReader(loaderContext, useUtoopack, mode) {
|
|
546
|
-
var _a;
|
|
547
|
-
if (useUtoopack && mode !== "demo-index" && ((_a = loaderContext.fs) == null ? void 0 : _a.readFile)) {
|
|
548
|
-
return (file) => new Promise((resolve, reject) => {
|
|
549
|
-
loaderContext.fs.readFile(
|
|
550
|
-
file,
|
|
551
|
-
(err, data) => {
|
|
552
|
-
if (err)
|
|
553
|
-
reject(err);
|
|
554
|
-
else
|
|
555
|
-
resolve(
|
|
556
|
-
Buffer.isBuffer(data) ? data.toString("utf-8") : String(data)
|
|
557
|
-
);
|
|
558
|
-
}
|
|
559
|
-
);
|
|
560
|
-
});
|
|
561
|
-
}
|
|
562
|
-
return readDependencyFromFs;
|
|
563
|
-
}
|
|
564
|
-
function getMdTransformDepsHint(cache, key) {
|
|
565
|
-
const hint = getMdLoaderCacheSync(
|
|
566
|
-
cache,
|
|
567
|
-
key,
|
|
568
|
-
void 0
|
|
569
|
-
);
|
|
570
|
-
return (hint == null ? void 0 : hint.version) === 1 ? normalizeDeps(hint.deps) : void 0;
|
|
571
|
-
}
|
|
572
372
|
var deferrer = {};
|
|
373
|
+
var depsMapping = {};
|
|
573
374
|
function mdLoader(content) {
|
|
574
375
|
var _a, _b, _c;
|
|
575
376
|
let opts = this.getOptions();
|
|
576
377
|
const loaderContextPath = opts[import_utoopackLoaders.UTOOPACK_LOADER_CTX_KEY];
|
|
577
|
-
const useUtoopackDemoHMR =
|
|
378
|
+
const useUtoopackDemoHMR = process.env.NODE_ENV !== "production" && Boolean(loaderContextPath);
|
|
578
379
|
if (loaderContextPath) {
|
|
579
380
|
const ctx = require(loaderContextPath);
|
|
580
381
|
if (!((_a = opts.techStacks) == null ? void 0 : _a.length)) {
|
|
@@ -602,119 +403,47 @@ function mdLoader(content) {
|
|
|
602
403
|
)) {
|
|
603
404
|
this.cacheable(false);
|
|
604
405
|
}
|
|
605
|
-
const
|
|
606
|
-
const
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
const readDependency = createDependencyReader(
|
|
610
|
-
this,
|
|
611
|
-
useUtoopackDemoHMR,
|
|
612
|
-
opts.mode
|
|
613
|
-
);
|
|
614
|
-
const { baseCacheKey, depsHintKey } = getMdTransformCacheKeys({
|
|
615
|
-
resourcePath: this.resourcePath,
|
|
616
|
-
content,
|
|
406
|
+
const cache = (0, import_utils.getCache)("md-loader");
|
|
407
|
+
const baseCacheKey = [
|
|
408
|
+
this.resourcePath,
|
|
409
|
+
(0, import_utils.getContentHash)(content),
|
|
617
410
|
useUtoopackDemoHMR,
|
|
618
|
-
opts
|
|
411
|
+
JSON.stringify(import_plugin_utils.lodash.omit(opts, ["mode", "builtins", "onResolveDemos"]))
|
|
412
|
+
].join(":");
|
|
413
|
+
const cacheKey = [
|
|
414
|
+
baseCacheKey,
|
|
415
|
+
getDepsCacheKey(depsMapping[this.resourcePath])
|
|
416
|
+
].join(":");
|
|
417
|
+
const cacheRet = getMdLoaderCacheSync(cache, cacheKey, "");
|
|
418
|
+
if (cacheRet) {
|
|
419
|
+
cb(null, emit.call(this, opts, cacheRet));
|
|
420
|
+
return;
|
|
421
|
+
} else if (cacheKey in deferrer) {
|
|
422
|
+
deferrer[cacheKey].then((res) => {
|
|
423
|
+
cb(null, emit.call(this, opts, res));
|
|
424
|
+
}).catch(cb);
|
|
425
|
+
return;
|
|
426
|
+
}
|
|
427
|
+
deferrer[cacheKey] = (0, import_transformer.default)(content, {
|
|
428
|
+
...import_plugin_utils.lodash.omit(opts, ["mode", "builtins", "onResolveDemos"]),
|
|
429
|
+
fileAbsPath: (0, import_plugin_utils.winPath)(this.resourcePath),
|
|
430
|
+
useUtoopackDemoHMR
|
|
619
431
|
});
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
"mode",
|
|
624
|
-
"builtins",
|
|
625
|
-
"onResolveDemos",
|
|
626
|
-
"cacheDirectory",
|
|
627
|
-
"cacheEpoch"
|
|
628
|
-
]),
|
|
629
|
-
fileAbsPath: (0, import_plugin_utils.winPath)(this.resourcePath),
|
|
630
|
-
useUtoopackDemoHMR
|
|
631
|
-
});
|
|
632
|
-
};
|
|
633
|
-
const getTransformDeps = (ret) => normalizeDeps(ret.meta.embeds.concat(getDemoCacheFiles(ret.meta.demos)));
|
|
634
|
-
const saveDepsHint = (deps) => {
|
|
635
|
-
depsHintCache.setSync(depsHintKey, {
|
|
636
|
-
version: 1,
|
|
637
|
-
deps: normalizeDeps(deps)
|
|
638
|
-
});
|
|
639
|
-
};
|
|
640
|
-
const cacheWithPath = cache;
|
|
641
|
-
const getTransform = async () => {
|
|
642
|
-
var _a2;
|
|
643
|
-
const cached = await getValidMdLoaderCacheRecord(
|
|
644
|
-
cache,
|
|
645
|
-
baseCacheKey,
|
|
646
|
-
readDependency
|
|
647
|
-
);
|
|
648
|
-
if (cached)
|
|
649
|
-
return cached;
|
|
650
|
-
const initialDeps = getMdTransformDepsHint(depsHintCache, depsHintKey) ?? ((_a2 = getMdLoaderCacheRecord(cache, baseCacheKey)) == null ? void 0 : _a2.deps);
|
|
651
|
-
const depsFingerprint = initialDeps ? await getDepsCacheKey(initialDeps, readDependency) : "<discover>";
|
|
652
|
-
const deferrerKey = [cacheNamespace, baseCacheKey, depsFingerprint].join(
|
|
653
|
-
":"
|
|
432
|
+
deferrer[cacheKey].then((ret) => {
|
|
433
|
+
depsMapping[this.resourcePath] = ret.meta.embeds.concat(
|
|
434
|
+
getDemoSourceFiles(ret.meta.demos)
|
|
654
435
|
);
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
readDependency,
|
|
664
|
-
onDepsDiscovered: saveDepsHint
|
|
665
|
-
});
|
|
666
|
-
}
|
|
667
|
-
const result = await createTransform();
|
|
668
|
-
const deps = getTransformDeps(result);
|
|
669
|
-
const record = {
|
|
670
|
-
version: 2,
|
|
671
|
-
deps,
|
|
672
|
-
depsKey: await getDepsCacheKey(deps),
|
|
673
|
-
result
|
|
674
|
-
};
|
|
675
|
-
saveDepsHint(deps);
|
|
676
|
-
return record;
|
|
677
|
-
};
|
|
678
|
-
const saveRecord = (record) => {
|
|
679
|
-
cache.setSync(baseCacheKey, record);
|
|
680
|
-
saveDepsHint(record.deps);
|
|
681
|
-
};
|
|
682
|
-
const pending = useUtoopackDemoHMR && cacheWithPath.path ? (0, import_sharedCache.getOrCreateWithFileLock)({
|
|
683
|
-
lockPath: `${cacheWithPath.path(`transform:${baseCacheKey}`)}.lock`,
|
|
684
|
-
getValue: () => getValidMdLoaderCacheRecord(cache, baseCacheKey, readDependency),
|
|
685
|
-
createValue: createRecord,
|
|
686
|
-
setValue: saveRecord
|
|
687
|
-
}) : (async () => {
|
|
688
|
-
const current = await getValidMdLoaderCacheRecord(
|
|
689
|
-
cache,
|
|
690
|
-
baseCacheKey,
|
|
691
|
-
readDependency
|
|
692
|
-
);
|
|
693
|
-
if (current)
|
|
694
|
-
return current;
|
|
695
|
-
const created = await createRecord();
|
|
696
|
-
saveRecord(created);
|
|
697
|
-
return created;
|
|
698
|
-
})();
|
|
699
|
-
deferrer[deferrerKey] = pending;
|
|
700
|
-
try {
|
|
701
|
-
return await pending;
|
|
702
|
-
} finally {
|
|
703
|
-
if (deferrer[deferrerKey] === pending)
|
|
704
|
-
delete deferrer[deferrerKey];
|
|
705
|
-
}
|
|
706
|
-
};
|
|
707
|
-
getTransform().then((record) => cb(null, emit.call(this, opts, record.result))).catch(cb);
|
|
436
|
+
const finalCacheKey = [
|
|
437
|
+
baseCacheKey,
|
|
438
|
+
getDepsCacheKey(depsMapping[this.resourcePath])
|
|
439
|
+
].join(":");
|
|
440
|
+
cache.setSync(finalCacheKey, ret);
|
|
441
|
+
cb(null, emit.call(this, opts, ret));
|
|
442
|
+
delete deferrer[cacheKey];
|
|
443
|
+
}).catch(cb);
|
|
708
444
|
}
|
|
709
445
|
// Annotate the CommonJS export names for ESM import in node:
|
|
710
446
|
0 && (module.exports = {
|
|
711
|
-
addDemoFileDependency,
|
|
712
|
-
createDependencyReader,
|
|
713
|
-
createStableTransform,
|
|
714
|
-
emitDemo,
|
|
715
447
|
getDemoSourceFiles,
|
|
716
|
-
|
|
717
|
-
getMdLoaderCacheResult,
|
|
718
|
-
getMdLoaderCacheSync,
|
|
719
|
-
getMdTransformCacheKeys
|
|
448
|
+
getMdLoaderCacheSync
|
|
720
449
|
});
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import type { IParsedBlockAsset } from '../../../assetParsers/block';
|
|
2
|
-
import type { IDumiDemoProps } from '@/client/theme-api/DumiDemo';
|
|
3
2
|
import type { ILocalesConfig, IRouteMeta } from '@/client/theme-api/types';
|
|
4
3
|
import type { IApi, IDumiConfig, IDumiTechStack } from '../../../types';
|
|
5
4
|
import { type ResolveOptions } from 'enhanced-resolve';
|
|
@@ -24,9 +23,6 @@ declare module 'vfile' {
|
|
|
24
23
|
component: string;
|
|
25
24
|
asset: IParsedBlockAsset['asset'];
|
|
26
25
|
resolveMap: IParsedBlockAsset['resolveMap'];
|
|
27
|
-
previewerProps?: IDumiDemoProps['previewerProps'];
|
|
28
|
-
/** Internal semantic version used by the utoopack demo HMR runtime. */
|
|
29
|
-
__dumiUtoopackHMRVersion?: string;
|
|
30
26
|
renderOpts: {
|
|
31
27
|
type?: string;
|
|
32
28
|
rendererPath?: string;
|