dumi 2.3.7 → 2.3.8
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.
|
@@ -41,14 +41,19 @@ function getCachedRouteMeta(route) {
|
|
|
41
41
|
var proxyGetter = function proxyGetter(target, prop) {
|
|
42
42
|
if (ASYNC_META_PROPS.includes(prop)) {
|
|
43
43
|
if (!asyncCache.get(cacheKey)) {
|
|
44
|
+
var routeMetaPromise = getRouteMetaById(route.id);
|
|
44
45
|
// load async meta then replace cache
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
46
|
+
if (routeMetaPromise) {
|
|
47
|
+
asyncCache.set(cacheKey, routeMetaPromise.then(function (full) {
|
|
48
|
+
return cache.set(cacheKey, merge(full)).get(cacheKey);
|
|
49
|
+
}));
|
|
50
|
+
}
|
|
48
51
|
}
|
|
49
|
-
|
|
50
52
|
// throw promise to trigger suspense
|
|
51
|
-
|
|
53
|
+
var currentCache = asyncCache.get(cacheKey);
|
|
54
|
+
if (currentCache) {
|
|
55
|
+
throw currentCache;
|
|
56
|
+
}
|
|
52
57
|
}
|
|
53
58
|
return target[prop];
|
|
54
59
|
};
|
|
@@ -138,17 +138,16 @@ export function getRouteMetaById<T extends { syncOnly?: boolean }>(
|
|
|
138
138
|
id: string,
|
|
139
139
|
opts?: T,
|
|
140
140
|
): T extends { syncOnly: true }
|
|
141
|
-
? IRouteMeta
|
|
142
|
-
: Promise<IRouteMeta> {
|
|
143
|
-
|
|
144
|
-
frontmatter: {},
|
|
145
|
-
toc: [],
|
|
146
|
-
texts: [],
|
|
147
|
-
};
|
|
141
|
+
? IRouteMeta | undefined
|
|
142
|
+
: Promise<IRouteMeta> | undefined {
|
|
143
|
+
|
|
148
144
|
if (filesMeta[id]) {
|
|
149
145
|
const { frontmatter, toc, textGetter, tabs } = filesMeta[id];
|
|
150
|
-
routeMeta
|
|
151
|
-
|
|
146
|
+
const routeMeta: IRouteMeta = {
|
|
147
|
+
frontmatter,
|
|
148
|
+
toc,
|
|
149
|
+
texts: [],
|
|
150
|
+
};
|
|
152
151
|
|
|
153
152
|
if (opts?.syncOnly) {
|
|
154
153
|
if (tabs) {
|
|
@@ -176,10 +175,6 @@ export function getRouteMetaById<T extends { syncOnly?: boolean }>(
|
|
|
176
175
|
});
|
|
177
176
|
}
|
|
178
177
|
}
|
|
179
|
-
if (opts?.syncOnly) {
|
|
180
|
-
return routeMeta;
|
|
181
|
-
}
|
|
182
|
-
return Promise.resolve(routeMeta);
|
|
183
178
|
}
|
|
184
179
|
|
|
185
180
|
/**
|