dumi 2.3.4 → 2.4.0-alpha.1
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/compiled/loader-runner/index.d.ts +67 -0
- package/compiled/loader-runner/index.js +567 -0
- package/dist/client/theme-api/useSiteSearch/index.js +1 -1
- package/dist/features/compile/index.d.ts +2 -1
- package/dist/features/compile/index.js +24 -2
- package/dist/features/compile/makoHooks.d.ts +8 -0
- package/dist/features/compile/makoHooks.js +155 -0
- package/dist/features/html2sketch.js +2 -2
- package/dist/features/theme/index.js +13 -17
- package/dist/loaders/demo/index.js +4 -1
- package/dist/loaders/markdown/index.js +25 -7
- package/dist/loaders/null/index.d.ts +2 -0
- package/dist/loaders/null/index.js +35 -0
- package/dist/utils.d.ts +8 -1
- package/dist/utils.js +14 -0
- package/package.json +6 -6
- package/theme-default/slots/Content/index.d.ts +1 -1
- package/theme-default/slots/Content/index.js +1 -1
- package/theme-default/styles/heti.less +953 -0
- package/theme-default/slots/Content/heti.scss +0 -4
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
|
|
3
|
+
export declare interface ExtendedLoaderContext {
|
|
4
|
+
context: string | null;
|
|
5
|
+
loaderIndex: number;
|
|
6
|
+
loaders: Loader[];
|
|
7
|
+
resourcePath: string | undefined;
|
|
8
|
+
resourceQuery: string | undefined;
|
|
9
|
+
async: (() => (() => void) | undefined) | null;
|
|
10
|
+
callback: (() => void) | null;
|
|
11
|
+
cacheable: (flag: boolean) => void;
|
|
12
|
+
dependency: (file: string) => void;
|
|
13
|
+
addDependency: (file: string) => void;
|
|
14
|
+
addContextDependency: (context: string) => void;
|
|
15
|
+
getDependencies: () => string[];
|
|
16
|
+
getContextDependencies: () => string[];
|
|
17
|
+
clearDependencies: () => void;
|
|
18
|
+
resource: string;
|
|
19
|
+
request: string;
|
|
20
|
+
remainingRequest: string;
|
|
21
|
+
currentRequest: string;
|
|
22
|
+
previousRequest: string;
|
|
23
|
+
query: {
|
|
24
|
+
[key: string]: any;
|
|
25
|
+
} | string;
|
|
26
|
+
data: any;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export declare function getContext(resource: string): string;
|
|
30
|
+
|
|
31
|
+
export declare interface Loader {
|
|
32
|
+
path: string;
|
|
33
|
+
query: string;
|
|
34
|
+
request: string;
|
|
35
|
+
options: any;
|
|
36
|
+
normal: null | ((request: string) => string);
|
|
37
|
+
pitch: null | ((request: string) => string);
|
|
38
|
+
raw: string;
|
|
39
|
+
data: any;
|
|
40
|
+
pitchExecuted: boolean;
|
|
41
|
+
normalExecuted: boolean;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export declare interface RunLoaderOption {
|
|
45
|
+
resource: string;
|
|
46
|
+
loaders: any[];
|
|
47
|
+
context: any;
|
|
48
|
+
readResource: (
|
|
49
|
+
filename: string,
|
|
50
|
+
callback: (err: NodeJS.ErrnoException | null, data: Buffer | null) => void,
|
|
51
|
+
) => void;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export declare interface RunLoaderResult {
|
|
55
|
+
result?: Array<Buffer | null> | undefined;
|
|
56
|
+
resourceBuffer?: Buffer | null | undefined;
|
|
57
|
+
cacheable: boolean;
|
|
58
|
+
fileDependencies: string[];
|
|
59
|
+
contextDependencies: string[];
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export declare function runLoaders(
|
|
63
|
+
options: RunLoaderOption,
|
|
64
|
+
callback: (err: NodeJS.ErrnoException | null, result: RunLoaderResult) => any,
|
|
65
|
+
): void;
|
|
66
|
+
|
|
67
|
+
export { }
|
|
@@ -0,0 +1,567 @@
|
|
|
1
|
+
/******/ (function() { // webpackBootstrap
|
|
2
|
+
/******/ var __webpack_modules__ = ({
|
|
3
|
+
|
|
4
|
+
/***/ 441:
|
|
5
|
+
/***/ (function(module) {
|
|
6
|
+
|
|
7
|
+
"use strict";
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
class LoadingLoaderError extends Error {
|
|
11
|
+
constructor(message) {
|
|
12
|
+
super(message);
|
|
13
|
+
this.name = "LoaderRunnerError";
|
|
14
|
+
Error.captureStackTrace(this, this.constructor);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
module.exports = LoadingLoaderError;
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
/***/ }),
|
|
22
|
+
|
|
23
|
+
/***/ 713:
|
|
24
|
+
/***/ (function(module, __unused_webpack_exports, __nccwpck_require__) {
|
|
25
|
+
|
|
26
|
+
var LoaderLoadingError = __nccwpck_require__(441);
|
|
27
|
+
var url;
|
|
28
|
+
|
|
29
|
+
module.exports = function loadLoader(loader, callback) {
|
|
30
|
+
if(loader.type === "module") {
|
|
31
|
+
try {
|
|
32
|
+
if(url === undefined) url = __nccwpck_require__(310);
|
|
33
|
+
var loaderUrl = url.pathToFileURL(loader.path);
|
|
34
|
+
var modulePromise = eval("import(" + JSON.stringify(loaderUrl.toString()) + ")");
|
|
35
|
+
modulePromise.then(function(module) {
|
|
36
|
+
handleResult(loader, module, callback);
|
|
37
|
+
}, callback);
|
|
38
|
+
return;
|
|
39
|
+
} catch(e) {
|
|
40
|
+
callback(e);
|
|
41
|
+
}
|
|
42
|
+
} else {
|
|
43
|
+
try {
|
|
44
|
+
var module = require(loader.path);
|
|
45
|
+
} catch(e) {
|
|
46
|
+
// it is possible for node to choke on a require if the FD descriptor
|
|
47
|
+
// limit has been reached. give it a chance to recover.
|
|
48
|
+
if(e instanceof Error && e.code === "EMFILE") {
|
|
49
|
+
var retry = loadLoader.bind(null, loader, callback);
|
|
50
|
+
if(typeof setImmediate === "function") {
|
|
51
|
+
// node >= 0.9.0
|
|
52
|
+
return setImmediate(retry);
|
|
53
|
+
} else {
|
|
54
|
+
// node < 0.9.0
|
|
55
|
+
return process.nextTick(retry);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
return callback(e);
|
|
59
|
+
}
|
|
60
|
+
return handleResult(loader, module, callback);
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
function handleResult(loader, module, callback) {
|
|
65
|
+
if(typeof module !== "function" && typeof module !== "object") {
|
|
66
|
+
return callback(new LoaderLoadingError(
|
|
67
|
+
"Module '" + loader.path + "' is not a loader (export function or es6 module)"
|
|
68
|
+
));
|
|
69
|
+
}
|
|
70
|
+
loader.normal = typeof module === "function" ? module : module.default;
|
|
71
|
+
loader.pitch = module.pitch;
|
|
72
|
+
loader.raw = module.raw;
|
|
73
|
+
if(typeof loader.normal !== "function" && typeof loader.pitch !== "function") {
|
|
74
|
+
return callback(new LoaderLoadingError(
|
|
75
|
+
"Module '" + loader.path + "' is not a loader (must have normal or pitch function)"
|
|
76
|
+
));
|
|
77
|
+
}
|
|
78
|
+
callback();
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
/***/ }),
|
|
83
|
+
|
|
84
|
+
/***/ 147:
|
|
85
|
+
/***/ (function(module) {
|
|
86
|
+
|
|
87
|
+
"use strict";
|
|
88
|
+
module.exports = require("fs");
|
|
89
|
+
|
|
90
|
+
/***/ }),
|
|
91
|
+
|
|
92
|
+
/***/ 310:
|
|
93
|
+
/***/ (function(module) {
|
|
94
|
+
|
|
95
|
+
"use strict";
|
|
96
|
+
module.exports = require("url");
|
|
97
|
+
|
|
98
|
+
/***/ })
|
|
99
|
+
|
|
100
|
+
/******/ });
|
|
101
|
+
/************************************************************************/
|
|
102
|
+
/******/ // The module cache
|
|
103
|
+
/******/ var __webpack_module_cache__ = {};
|
|
104
|
+
/******/
|
|
105
|
+
/******/ // The require function
|
|
106
|
+
/******/ function __nccwpck_require__(moduleId) {
|
|
107
|
+
/******/ // Check if module is in cache
|
|
108
|
+
/******/ var cachedModule = __webpack_module_cache__[moduleId];
|
|
109
|
+
/******/ if (cachedModule !== undefined) {
|
|
110
|
+
/******/ return cachedModule.exports;
|
|
111
|
+
/******/ }
|
|
112
|
+
/******/ // Create a new module (and put it into the cache)
|
|
113
|
+
/******/ var module = __webpack_module_cache__[moduleId] = {
|
|
114
|
+
/******/ // no module.id needed
|
|
115
|
+
/******/ // no module.loaded needed
|
|
116
|
+
/******/ exports: {}
|
|
117
|
+
/******/ };
|
|
118
|
+
/******/
|
|
119
|
+
/******/ // Execute the module function
|
|
120
|
+
/******/ var threw = true;
|
|
121
|
+
/******/ try {
|
|
122
|
+
/******/ __webpack_modules__[moduleId](module, module.exports, __nccwpck_require__);
|
|
123
|
+
/******/ threw = false;
|
|
124
|
+
/******/ } finally {
|
|
125
|
+
/******/ if(threw) delete __webpack_module_cache__[moduleId];
|
|
126
|
+
/******/ }
|
|
127
|
+
/******/
|
|
128
|
+
/******/ // Return the exports of the module
|
|
129
|
+
/******/ return module.exports;
|
|
130
|
+
/******/ }
|
|
131
|
+
/******/
|
|
132
|
+
/************************************************************************/
|
|
133
|
+
/******/ /* webpack/runtime/compat */
|
|
134
|
+
/******/
|
|
135
|
+
/******/ if (typeof __nccwpck_require__ !== 'undefined') __nccwpck_require__.ab = __dirname + "/";
|
|
136
|
+
/******/
|
|
137
|
+
/************************************************************************/
|
|
138
|
+
var __webpack_exports__ = {};
|
|
139
|
+
// This entry need to be wrapped in an IIFE because it need to be isolated against other modules in the chunk.
|
|
140
|
+
!function() {
|
|
141
|
+
var exports = __webpack_exports__;
|
|
142
|
+
/*
|
|
143
|
+
MIT License http://www.opensource.org/licenses/mit-license.php
|
|
144
|
+
Author Tobias Koppers @sokra
|
|
145
|
+
*/
|
|
146
|
+
var fs = __nccwpck_require__(147);
|
|
147
|
+
var readFile = fs.readFile.bind(fs);
|
|
148
|
+
var loadLoader = __nccwpck_require__(713);
|
|
149
|
+
|
|
150
|
+
function utf8BufferToString(buf) {
|
|
151
|
+
var str = buf.toString("utf-8");
|
|
152
|
+
if(str.charCodeAt(0) === 0xFEFF) {
|
|
153
|
+
return str.substr(1);
|
|
154
|
+
} else {
|
|
155
|
+
return str;
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
const PATH_QUERY_FRAGMENT_REGEXP = /^((?:\0.|[^?#\0])*)(\?(?:\0.|[^#\0])*)?(#.*)?$/;
|
|
160
|
+
|
|
161
|
+
/**
|
|
162
|
+
* @param {string} str the path with query and fragment
|
|
163
|
+
* @returns {{ path: string, query: string, fragment: string }} parsed parts
|
|
164
|
+
*/
|
|
165
|
+
function parsePathQueryFragment(str) {
|
|
166
|
+
var match = PATH_QUERY_FRAGMENT_REGEXP.exec(str);
|
|
167
|
+
return {
|
|
168
|
+
path: match[1].replace(/\0(.)/g, "$1"),
|
|
169
|
+
query: match[2] ? match[2].replace(/\0(.)/g, "$1") : "",
|
|
170
|
+
fragment: match[3] || ""
|
|
171
|
+
};
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
function dirname(path) {
|
|
175
|
+
if(path === "/") return "/";
|
|
176
|
+
var i = path.lastIndexOf("/");
|
|
177
|
+
var j = path.lastIndexOf("\\");
|
|
178
|
+
var i2 = path.indexOf("/");
|
|
179
|
+
var j2 = path.indexOf("\\");
|
|
180
|
+
var idx = i > j ? i : j;
|
|
181
|
+
var idx2 = i > j ? i2 : j2;
|
|
182
|
+
if(idx < 0) return path;
|
|
183
|
+
if(idx === idx2) return path.substr(0, idx + 1);
|
|
184
|
+
return path.substr(0, idx);
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
function createLoaderObject(loader) {
|
|
188
|
+
var obj = {
|
|
189
|
+
path: null,
|
|
190
|
+
query: null,
|
|
191
|
+
fragment: null,
|
|
192
|
+
options: null,
|
|
193
|
+
ident: null,
|
|
194
|
+
normal: null,
|
|
195
|
+
pitch: null,
|
|
196
|
+
raw: null,
|
|
197
|
+
data: null,
|
|
198
|
+
pitchExecuted: false,
|
|
199
|
+
normalExecuted: false
|
|
200
|
+
};
|
|
201
|
+
Object.defineProperty(obj, "request", {
|
|
202
|
+
enumerable: true,
|
|
203
|
+
get: function() {
|
|
204
|
+
return obj.path.replace(/#/g, "\0#") + obj.query.replace(/#/g, "\0#") + obj.fragment;
|
|
205
|
+
},
|
|
206
|
+
set: function(value) {
|
|
207
|
+
if(typeof value === "string") {
|
|
208
|
+
var splittedRequest = parsePathQueryFragment(value);
|
|
209
|
+
obj.path = splittedRequest.path;
|
|
210
|
+
obj.query = splittedRequest.query;
|
|
211
|
+
obj.fragment = splittedRequest.fragment;
|
|
212
|
+
obj.options = undefined;
|
|
213
|
+
obj.ident = undefined;
|
|
214
|
+
} else {
|
|
215
|
+
if(!value.loader)
|
|
216
|
+
throw new Error("request should be a string or object with loader and options (" + JSON.stringify(value) + ")");
|
|
217
|
+
obj.path = value.loader;
|
|
218
|
+
obj.fragment = value.fragment || "";
|
|
219
|
+
obj.type = value.type;
|
|
220
|
+
obj.options = value.options;
|
|
221
|
+
obj.ident = value.ident;
|
|
222
|
+
if(obj.options === null)
|
|
223
|
+
obj.query = "";
|
|
224
|
+
else if(obj.options === undefined)
|
|
225
|
+
obj.query = "";
|
|
226
|
+
else if(typeof obj.options === "string")
|
|
227
|
+
obj.query = "?" + obj.options;
|
|
228
|
+
else if(obj.ident)
|
|
229
|
+
obj.query = "??" + obj.ident;
|
|
230
|
+
else if(typeof obj.options === "object" && obj.options.ident)
|
|
231
|
+
obj.query = "??" + obj.options.ident;
|
|
232
|
+
else
|
|
233
|
+
obj.query = "?" + JSON.stringify(obj.options);
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
});
|
|
237
|
+
obj.request = loader;
|
|
238
|
+
if(Object.preventExtensions) {
|
|
239
|
+
Object.preventExtensions(obj);
|
|
240
|
+
}
|
|
241
|
+
return obj;
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
function runSyncOrAsync(fn, context, args, callback) {
|
|
245
|
+
var isSync = true;
|
|
246
|
+
var isDone = false;
|
|
247
|
+
var isError = false; // internal error
|
|
248
|
+
var reportedError = false;
|
|
249
|
+
context.async = function async() {
|
|
250
|
+
if(isDone) {
|
|
251
|
+
if(reportedError) return; // ignore
|
|
252
|
+
throw new Error("async(): The callback was already called.");
|
|
253
|
+
}
|
|
254
|
+
isSync = false;
|
|
255
|
+
return innerCallback;
|
|
256
|
+
};
|
|
257
|
+
var innerCallback = context.callback = function() {
|
|
258
|
+
if(isDone) {
|
|
259
|
+
if(reportedError) return; // ignore
|
|
260
|
+
throw new Error("callback(): The callback was already called.");
|
|
261
|
+
}
|
|
262
|
+
isDone = true;
|
|
263
|
+
isSync = false;
|
|
264
|
+
try {
|
|
265
|
+
callback.apply(null, arguments);
|
|
266
|
+
} catch(e) {
|
|
267
|
+
isError = true;
|
|
268
|
+
throw e;
|
|
269
|
+
}
|
|
270
|
+
};
|
|
271
|
+
try {
|
|
272
|
+
var result = (function LOADER_EXECUTION() {
|
|
273
|
+
return fn.apply(context, args);
|
|
274
|
+
}());
|
|
275
|
+
if(isSync) {
|
|
276
|
+
isDone = true;
|
|
277
|
+
if(result === undefined)
|
|
278
|
+
return callback();
|
|
279
|
+
if(result && typeof result === "object" && typeof result.then === "function") {
|
|
280
|
+
return result.then(function(r) {
|
|
281
|
+
callback(null, r);
|
|
282
|
+
}, callback);
|
|
283
|
+
}
|
|
284
|
+
return callback(null, result);
|
|
285
|
+
}
|
|
286
|
+
} catch(e) {
|
|
287
|
+
if(isError) throw e;
|
|
288
|
+
if(isDone) {
|
|
289
|
+
// loader is already "done", so we cannot use the callback function
|
|
290
|
+
// for better debugging we print the error on the console
|
|
291
|
+
if(typeof e === "object" && e.stack) console.error(e.stack);
|
|
292
|
+
else console.error(e);
|
|
293
|
+
return;
|
|
294
|
+
}
|
|
295
|
+
isDone = true;
|
|
296
|
+
reportedError = true;
|
|
297
|
+
callback(e);
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
function convertArgs(args, raw) {
|
|
303
|
+
if(!raw && Buffer.isBuffer(args[0]))
|
|
304
|
+
args[0] = utf8BufferToString(args[0]);
|
|
305
|
+
else if(raw && typeof args[0] === "string")
|
|
306
|
+
args[0] = Buffer.from(args[0], "utf-8");
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
function iteratePitchingLoaders(options, loaderContext, callback) {
|
|
310
|
+
// abort after last loader
|
|
311
|
+
if(loaderContext.loaderIndex >= loaderContext.loaders.length)
|
|
312
|
+
return processResource(options, loaderContext, callback);
|
|
313
|
+
|
|
314
|
+
var currentLoaderObject = loaderContext.loaders[loaderContext.loaderIndex];
|
|
315
|
+
|
|
316
|
+
// iterate
|
|
317
|
+
if(currentLoaderObject.pitchExecuted) {
|
|
318
|
+
loaderContext.loaderIndex++;
|
|
319
|
+
return iteratePitchingLoaders(options, loaderContext, callback);
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
// load loader module
|
|
323
|
+
loadLoader(currentLoaderObject, function(err) {
|
|
324
|
+
if(err) {
|
|
325
|
+
loaderContext.cacheable(false);
|
|
326
|
+
return callback(err);
|
|
327
|
+
}
|
|
328
|
+
var fn = currentLoaderObject.pitch;
|
|
329
|
+
currentLoaderObject.pitchExecuted = true;
|
|
330
|
+
if(!fn) return iteratePitchingLoaders(options, loaderContext, callback);
|
|
331
|
+
|
|
332
|
+
runSyncOrAsync(
|
|
333
|
+
fn,
|
|
334
|
+
loaderContext, [loaderContext.remainingRequest, loaderContext.previousRequest, currentLoaderObject.data = {}],
|
|
335
|
+
function(err) {
|
|
336
|
+
if(err) return callback(err);
|
|
337
|
+
var args = Array.prototype.slice.call(arguments, 1);
|
|
338
|
+
// Determine whether to continue the pitching process based on
|
|
339
|
+
// argument values (as opposed to argument presence) in order
|
|
340
|
+
// to support synchronous and asynchronous usages.
|
|
341
|
+
var hasArg = args.some(function(value) {
|
|
342
|
+
return value !== undefined;
|
|
343
|
+
});
|
|
344
|
+
if(hasArg) {
|
|
345
|
+
loaderContext.loaderIndex--;
|
|
346
|
+
iterateNormalLoaders(options, loaderContext, args, callback);
|
|
347
|
+
} else {
|
|
348
|
+
iteratePitchingLoaders(options, loaderContext, callback);
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
);
|
|
352
|
+
});
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
function processResource(options, loaderContext, callback) {
|
|
356
|
+
// set loader index to last loader
|
|
357
|
+
loaderContext.loaderIndex = loaderContext.loaders.length - 1;
|
|
358
|
+
|
|
359
|
+
var resourcePath = loaderContext.resourcePath;
|
|
360
|
+
if(resourcePath) {
|
|
361
|
+
options.processResource(loaderContext, resourcePath, function(err) {
|
|
362
|
+
if(err) return callback(err);
|
|
363
|
+
var args = Array.prototype.slice.call(arguments, 1);
|
|
364
|
+
options.resourceBuffer = args[0];
|
|
365
|
+
iterateNormalLoaders(options, loaderContext, args, callback);
|
|
366
|
+
});
|
|
367
|
+
} else {
|
|
368
|
+
iterateNormalLoaders(options, loaderContext, [null], callback);
|
|
369
|
+
}
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
function iterateNormalLoaders(options, loaderContext, args, callback) {
|
|
373
|
+
if(loaderContext.loaderIndex < 0)
|
|
374
|
+
return callback(null, args);
|
|
375
|
+
|
|
376
|
+
var currentLoaderObject = loaderContext.loaders[loaderContext.loaderIndex];
|
|
377
|
+
|
|
378
|
+
// iterate
|
|
379
|
+
if(currentLoaderObject.normalExecuted) {
|
|
380
|
+
loaderContext.loaderIndex--;
|
|
381
|
+
return iterateNormalLoaders(options, loaderContext, args, callback);
|
|
382
|
+
}
|
|
383
|
+
|
|
384
|
+
var fn = currentLoaderObject.normal;
|
|
385
|
+
currentLoaderObject.normalExecuted = true;
|
|
386
|
+
if(!fn) {
|
|
387
|
+
return iterateNormalLoaders(options, loaderContext, args, callback);
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
convertArgs(args, currentLoaderObject.raw);
|
|
391
|
+
|
|
392
|
+
runSyncOrAsync(fn, loaderContext, args, function(err) {
|
|
393
|
+
if(err) return callback(err);
|
|
394
|
+
|
|
395
|
+
var args = Array.prototype.slice.call(arguments, 1);
|
|
396
|
+
iterateNormalLoaders(options, loaderContext, args, callback);
|
|
397
|
+
});
|
|
398
|
+
}
|
|
399
|
+
|
|
400
|
+
exports.getContext = function getContext(resource) {
|
|
401
|
+
var path = parsePathQueryFragment(resource).path;
|
|
402
|
+
return dirname(path);
|
|
403
|
+
};
|
|
404
|
+
|
|
405
|
+
exports.runLoaders = function runLoaders(options, callback) {
|
|
406
|
+
// read options
|
|
407
|
+
var resource = options.resource || "";
|
|
408
|
+
var loaders = options.loaders || [];
|
|
409
|
+
var loaderContext = options.context || {};
|
|
410
|
+
var processResource = options.processResource || ((readResource, context, resource, callback) => {
|
|
411
|
+
context.addDependency(resource);
|
|
412
|
+
readResource(resource, callback);
|
|
413
|
+
}).bind(null, options.readResource || readFile);
|
|
414
|
+
|
|
415
|
+
//
|
|
416
|
+
var splittedResource = resource && parsePathQueryFragment(resource);
|
|
417
|
+
var resourcePath = splittedResource ? splittedResource.path : undefined;
|
|
418
|
+
var resourceQuery = splittedResource ? splittedResource.query : undefined;
|
|
419
|
+
var resourceFragment = splittedResource ? splittedResource.fragment : undefined;
|
|
420
|
+
var contextDirectory = resourcePath ? dirname(resourcePath) : null;
|
|
421
|
+
|
|
422
|
+
// execution state
|
|
423
|
+
var requestCacheable = true;
|
|
424
|
+
var fileDependencies = [];
|
|
425
|
+
var contextDependencies = [];
|
|
426
|
+
var missingDependencies = [];
|
|
427
|
+
|
|
428
|
+
// prepare loader objects
|
|
429
|
+
loaders = loaders.map(createLoaderObject);
|
|
430
|
+
|
|
431
|
+
loaderContext.context = contextDirectory;
|
|
432
|
+
loaderContext.loaderIndex = 0;
|
|
433
|
+
loaderContext.loaders = loaders;
|
|
434
|
+
loaderContext.resourcePath = resourcePath;
|
|
435
|
+
loaderContext.resourceQuery = resourceQuery;
|
|
436
|
+
loaderContext.resourceFragment = resourceFragment;
|
|
437
|
+
loaderContext.async = null;
|
|
438
|
+
loaderContext.callback = null;
|
|
439
|
+
loaderContext.getOptions = function getOptions() {
|
|
440
|
+
var entry = loaderContext.loaders[loaderContext.loaderIndex];
|
|
441
|
+
return entry.options && typeof entry.options === "object" ? entry.options : {};
|
|
442
|
+
};
|
|
443
|
+
|
|
444
|
+
loaderContext.cacheable = function cacheable(flag) {
|
|
445
|
+
if(flag === false) {
|
|
446
|
+
requestCacheable = false;
|
|
447
|
+
}
|
|
448
|
+
};
|
|
449
|
+
loaderContext.dependency = loaderContext.addDependency = function addDependency(file) {
|
|
450
|
+
fileDependencies.push(file);
|
|
451
|
+
};
|
|
452
|
+
loaderContext.addContextDependency = function addContextDependency(context) {
|
|
453
|
+
contextDependencies.push(context);
|
|
454
|
+
};
|
|
455
|
+
loaderContext.addMissingDependency = function addMissingDependency(context) {
|
|
456
|
+
missingDependencies.push(context);
|
|
457
|
+
};
|
|
458
|
+
loaderContext.getDependencies = function getDependencies() {
|
|
459
|
+
return fileDependencies.slice();
|
|
460
|
+
};
|
|
461
|
+
loaderContext.getContextDependencies = function getContextDependencies() {
|
|
462
|
+
return contextDependencies.slice();
|
|
463
|
+
};
|
|
464
|
+
loaderContext.getMissingDependencies = function getMissingDependencies() {
|
|
465
|
+
return missingDependencies.slice();
|
|
466
|
+
};
|
|
467
|
+
loaderContext.clearDependencies = function clearDependencies() {
|
|
468
|
+
fileDependencies.length = 0;
|
|
469
|
+
contextDependencies.length = 0;
|
|
470
|
+
missingDependencies.length = 0;
|
|
471
|
+
requestCacheable = true;
|
|
472
|
+
};
|
|
473
|
+
Object.defineProperty(loaderContext, "resource", {
|
|
474
|
+
enumerable: true,
|
|
475
|
+
get: function() {
|
|
476
|
+
if(loaderContext.resourcePath === undefined)
|
|
477
|
+
return undefined;
|
|
478
|
+
return loaderContext.resourcePath.replace(/#/g, "\0#") + loaderContext.resourceQuery.replace(/#/g, "\0#") + loaderContext.resourceFragment;
|
|
479
|
+
},
|
|
480
|
+
set: function(value) {
|
|
481
|
+
var splittedResource = value && parsePathQueryFragment(value);
|
|
482
|
+
loaderContext.resourcePath = splittedResource ? splittedResource.path : undefined;
|
|
483
|
+
loaderContext.resourceQuery = splittedResource ? splittedResource.query : undefined;
|
|
484
|
+
loaderContext.resourceFragment = splittedResource ? splittedResource.fragment : undefined;
|
|
485
|
+
}
|
|
486
|
+
});
|
|
487
|
+
Object.defineProperty(loaderContext, "request", {
|
|
488
|
+
enumerable: true,
|
|
489
|
+
get: function() {
|
|
490
|
+
return loaderContext.loaders.map(function(o) {
|
|
491
|
+
return o.request;
|
|
492
|
+
}).concat(loaderContext.resource || "").join("!");
|
|
493
|
+
}
|
|
494
|
+
});
|
|
495
|
+
Object.defineProperty(loaderContext, "remainingRequest", {
|
|
496
|
+
enumerable: true,
|
|
497
|
+
get: function() {
|
|
498
|
+
if(loaderContext.loaderIndex >= loaderContext.loaders.length - 1 && !loaderContext.resource)
|
|
499
|
+
return "";
|
|
500
|
+
return loaderContext.loaders.slice(loaderContext.loaderIndex + 1).map(function(o) {
|
|
501
|
+
return o.request;
|
|
502
|
+
}).concat(loaderContext.resource || "").join("!");
|
|
503
|
+
}
|
|
504
|
+
});
|
|
505
|
+
Object.defineProperty(loaderContext, "currentRequest", {
|
|
506
|
+
enumerable: true,
|
|
507
|
+
get: function() {
|
|
508
|
+
return loaderContext.loaders.slice(loaderContext.loaderIndex).map(function(o) {
|
|
509
|
+
return o.request;
|
|
510
|
+
}).concat(loaderContext.resource || "").join("!");
|
|
511
|
+
}
|
|
512
|
+
});
|
|
513
|
+
Object.defineProperty(loaderContext, "previousRequest", {
|
|
514
|
+
enumerable: true,
|
|
515
|
+
get: function() {
|
|
516
|
+
return loaderContext.loaders.slice(0, loaderContext.loaderIndex).map(function(o) {
|
|
517
|
+
return o.request;
|
|
518
|
+
}).join("!");
|
|
519
|
+
}
|
|
520
|
+
});
|
|
521
|
+
Object.defineProperty(loaderContext, "query", {
|
|
522
|
+
enumerable: true,
|
|
523
|
+
get: function() {
|
|
524
|
+
var entry = loaderContext.loaders[loaderContext.loaderIndex];
|
|
525
|
+
return entry.options && typeof entry.options === "object" ? entry.options : entry.query;
|
|
526
|
+
}
|
|
527
|
+
});
|
|
528
|
+
Object.defineProperty(loaderContext, "data", {
|
|
529
|
+
enumerable: true,
|
|
530
|
+
get: function() {
|
|
531
|
+
return loaderContext.loaders[loaderContext.loaderIndex].data;
|
|
532
|
+
}
|
|
533
|
+
});
|
|
534
|
+
|
|
535
|
+
// finish loader context
|
|
536
|
+
if(Object.preventExtensions) {
|
|
537
|
+
Object.preventExtensions(loaderContext);
|
|
538
|
+
}
|
|
539
|
+
|
|
540
|
+
var processOptions = {
|
|
541
|
+
resourceBuffer: null,
|
|
542
|
+
processResource: processResource
|
|
543
|
+
};
|
|
544
|
+
iteratePitchingLoaders(processOptions, loaderContext, function(err, result) {
|
|
545
|
+
if(err) {
|
|
546
|
+
return callback(err, {
|
|
547
|
+
cacheable: requestCacheable,
|
|
548
|
+
fileDependencies: fileDependencies,
|
|
549
|
+
contextDependencies: contextDependencies,
|
|
550
|
+
missingDependencies: missingDependencies
|
|
551
|
+
});
|
|
552
|
+
}
|
|
553
|
+
callback(null, {
|
|
554
|
+
result: result,
|
|
555
|
+
resourceBuffer: processOptions.resourceBuffer,
|
|
556
|
+
cacheable: requestCacheable,
|
|
557
|
+
fileDependencies: fileDependencies,
|
|
558
|
+
contextDependencies: contextDependencies,
|
|
559
|
+
missingDependencies: missingDependencies
|
|
560
|
+
});
|
|
561
|
+
});
|
|
562
|
+
};
|
|
563
|
+
|
|
564
|
+
}();
|
|
565
|
+
module.exports = __webpack_exports__;
|
|
566
|
+
/******/ })()
|
|
567
|
+
;
|
|
@@ -7,7 +7,7 @@ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
|
7
7
|
import { useNavData } from 'dumi';
|
|
8
8
|
import { useCallback, useEffect, useRef, useState } from 'react';
|
|
9
9
|
// @ts-ignore
|
|
10
|
-
import workerCode from
|
|
10
|
+
import workerCode from "../../../../compiled/_internal/searchWorker.min?dumi-raw";
|
|
11
11
|
import useSearchData from "./useSearchData";
|
|
12
12
|
var worker;
|
|
13
13
|
|