@utoo/web 1.1.0 → 1.2.0-rc.2
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/esm/f4423b245e72d3fa009d.wasm +0 -0
- package/esm/internalProject.d.ts +1 -0
- package/esm/internalProject.js +10 -85
- package/esm/loaderWorker.js +2 -0
- package/esm/loaderWorker.js.LICENSE.txt +44 -0
- package/esm/loaderWorkerPool.d.ts +3 -0
- package/esm/loaderWorkerPool.js +125 -0
- package/esm/project.d.ts +1 -0
- package/esm/project.js +2 -0
- package/esm/sabcom.d.ts +31 -0
- package/esm/sabcom.js +71 -0
- package/esm/type.d.ts +1 -0
- package/esm/utoo/index.d.ts +72 -47
- package/esm/utoo/index.js +257 -165
- package/esm/utoo/index_bg.wasm +0 -0
- package/esm/webpackLoaders/worker/cjs.js +253 -58
- package/esm/webpackLoaders/worker/index.d.ts +2 -2
- package/esm/webpackLoaders/worker/index.js +36 -26
- package/esm/webpackLoaders/worker/polyfills/fastGlobPolyfill.d.ts +2 -0
- package/esm/webpackLoaders/worker/polyfills/fastGlobPolyfill.js +48 -0
- package/esm/webpackLoaders/worker/polyfills/fsPolyfill.d.ts +124 -0
- package/esm/webpackLoaders/worker/polyfills/fsPolyfill.js +316 -0
- package/esm/webpackLoaders/worker/polyfills/fsPromisesPolyfill.d.ts +9 -0
- package/esm/webpackLoaders/worker/polyfills/fsPromisesPolyfill.js +9 -0
- package/esm/webpackLoaders/worker/polyfills/nodePolyFills.d.ts +94 -0
- package/esm/webpackLoaders/worker/polyfills/nodePolyFills.js +229 -0
- package/esm/webpackLoaders/worker/polyfills/workerThreadsPolyfill.d.ts +7 -0
- package/esm/webpackLoaders/worker/polyfills/workerThreadsPolyfill.js +16 -0
- package/esm/webpackLoaders/worker/type.d.ts +1 -1
- package/package.json +11 -11
- package/esm/webpackLoaders/worker/nodePolyFills.d.ts +0 -14
- package/esm/webpackLoaders/worker/nodePolyFills.js +0 -24
- package/esm/webpackLoaders/workerContent.d.ts +0 -2
- package/esm/webpackLoaders/workerContent.js +0 -1
|
@@ -1,9 +1,255 @@
|
|
|
1
1
|
import "systemjs/dist/system.js";
|
|
2
|
-
import nodePolyFills from "./nodePolyFills";
|
|
2
|
+
import nodePolyFills from "./polyfills/nodePolyFills";
|
|
3
|
+
const fs = nodePolyFills.fs;
|
|
4
|
+
const path = nodePolyFills.path;
|
|
5
|
+
const installedModules = {};
|
|
6
|
+
const statCache = {};
|
|
7
|
+
const pkgJsonCache = {};
|
|
8
|
+
const resolutionCache = {};
|
|
9
|
+
const searchPathsCache = {};
|
|
10
|
+
const statSync = (p) => {
|
|
11
|
+
if (p.includes("node_modules") &&
|
|
12
|
+
Object.prototype.hasOwnProperty.call(statCache, p)) {
|
|
13
|
+
if (statCache[p] === false)
|
|
14
|
+
throw new Error("ENOENT");
|
|
15
|
+
return statCache[p];
|
|
16
|
+
}
|
|
17
|
+
try {
|
|
18
|
+
const res = fs.statSync(p);
|
|
19
|
+
if (p.includes("node_modules"))
|
|
20
|
+
statCache[p] = res;
|
|
21
|
+
return res;
|
|
22
|
+
}
|
|
23
|
+
catch (e) {
|
|
24
|
+
if (p.includes("node_modules"))
|
|
25
|
+
statCache[p] = false;
|
|
26
|
+
throw e;
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
const existsSync = (p) => {
|
|
30
|
+
try {
|
|
31
|
+
statSync(p);
|
|
32
|
+
return true;
|
|
33
|
+
}
|
|
34
|
+
catch (_a) {
|
|
35
|
+
return false;
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
const executeModule = (moduleCode, moduleId, id, importMaps, entrypoint) => {
|
|
39
|
+
if (installedModules[moduleId]) {
|
|
40
|
+
return installedModules[moduleId].exports;
|
|
41
|
+
}
|
|
42
|
+
const context = path.dirname(moduleId);
|
|
43
|
+
let finalExports = {};
|
|
44
|
+
const moduleRequire = (childId) => loadModule(childId, context, importMaps, entrypoint);
|
|
45
|
+
moduleRequire.resolve = (request) => request;
|
|
46
|
+
const module = { exports: finalExports, require: moduleRequire };
|
|
47
|
+
if (moduleId.includes("node_modules")) {
|
|
48
|
+
installedModules[moduleId] = module;
|
|
49
|
+
}
|
|
50
|
+
// Hack for entrypoint
|
|
51
|
+
if (moduleId === entrypoint) {
|
|
52
|
+
moduleCode = "self.Buffer = require('buffer').Buffer;" + moduleCode;
|
|
53
|
+
}
|
|
54
|
+
try {
|
|
55
|
+
if (moduleId.endsWith(".json")) {
|
|
56
|
+
finalExports = JSON.parse(moduleCode);
|
|
57
|
+
module.exports = finalExports;
|
|
58
|
+
}
|
|
59
|
+
else {
|
|
60
|
+
new Function("require", "exports", "module", "__filename", "__dirname", moduleCode)(moduleRequire, module.exports, module, moduleId, context);
|
|
61
|
+
finalExports = module.exports;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
catch (e) {
|
|
65
|
+
console.error(`Worker: Error executing module ${moduleId}:`, e);
|
|
66
|
+
throw new Error(`Failed to load dependency ${moduleId}: ${e.message}`);
|
|
67
|
+
}
|
|
68
|
+
const originalWarn = console.warn;
|
|
69
|
+
console.warn = (...args) => {
|
|
70
|
+
var _a;
|
|
71
|
+
const msg = ((_a = args[0]) === null || _a === void 0 ? void 0 : _a.toString()) || "";
|
|
72
|
+
if (msg.includes("(SystemJS Error#W3")) {
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
75
|
+
originalWarn.apply(console, args);
|
|
76
|
+
};
|
|
77
|
+
try {
|
|
78
|
+
System.set(moduleId, { default: finalExports });
|
|
79
|
+
}
|
|
80
|
+
catch (e) {
|
|
81
|
+
// ignore
|
|
82
|
+
}
|
|
83
|
+
finally {
|
|
84
|
+
console.warn = originalWarn;
|
|
85
|
+
}
|
|
86
|
+
return finalExports;
|
|
87
|
+
};
|
|
88
|
+
const loadModule = (id, context, importMaps, entrypoint) => {
|
|
89
|
+
var _a, _b, _c, _d, _e, _f;
|
|
90
|
+
const cacheKey = `${context}:${id}`;
|
|
91
|
+
if (resolutionCache[cacheKey]) {
|
|
92
|
+
const cachedId = resolutionCache[cacheKey];
|
|
93
|
+
if (installedModules[cachedId]) {
|
|
94
|
+
return installedModules[cachedId].exports;
|
|
95
|
+
}
|
|
96
|
+
// Fast path: if we know the resolved path, try to load it directly
|
|
97
|
+
try {
|
|
98
|
+
const moduleCode = fs.readFileSync(cachedId, "utf8");
|
|
99
|
+
return executeModule(moduleCode, cachedId, id, importMaps, entrypoint);
|
|
100
|
+
}
|
|
101
|
+
catch (e) {
|
|
102
|
+
// If read fails, fall back to full resolution
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
// 1. Resolve
|
|
106
|
+
let resolvedId = id;
|
|
107
|
+
if (id.startsWith(".")) {
|
|
108
|
+
resolvedId = path.resolve(context, id);
|
|
109
|
+
}
|
|
110
|
+
// 2. Check Cache (SystemJS)
|
|
111
|
+
let dependency = System.get(resolvedId);
|
|
112
|
+
if (dependency)
|
|
113
|
+
return dependency.default;
|
|
114
|
+
if (id !== resolvedId) {
|
|
115
|
+
dependency = System.get(id);
|
|
116
|
+
if (dependency)
|
|
117
|
+
return dependency.default;
|
|
118
|
+
}
|
|
119
|
+
// 3. Check Node Polyfills
|
|
120
|
+
if (id in nodePolyFills) {
|
|
121
|
+
// @ts-ignore
|
|
122
|
+
return nodePolyFills[id];
|
|
123
|
+
}
|
|
124
|
+
if (resolvedId in nodePolyFills) {
|
|
125
|
+
// @ts-ignore
|
|
126
|
+
return nodePolyFills[resolvedId];
|
|
127
|
+
}
|
|
128
|
+
// 4. Check importMaps & FS
|
|
129
|
+
let moduleCode = importMaps[resolvedId] || importMaps[id];
|
|
130
|
+
let moduleId = importMaps[resolvedId] ? resolvedId : id;
|
|
131
|
+
// Fallback: Try resolving from node_modules
|
|
132
|
+
if (!moduleCode && !id.startsWith(".") && !id.startsWith("/")) {
|
|
133
|
+
let searchPaths = searchPathsCache[context];
|
|
134
|
+
if (!searchPaths) {
|
|
135
|
+
searchPaths = [];
|
|
136
|
+
// @ts-ignore
|
|
137
|
+
const cwd = ((_b = (_a = self.process) === null || _a === void 0 ? void 0 : _a.cwd) === null || _b === void 0 ? void 0 : _b.call(_a)) || ((_c = self.workerData) === null || _c === void 0 ? void 0 : _c.cwd) || "/";
|
|
138
|
+
const isInsideNodeModules = context.includes("/node_modules/") ||
|
|
139
|
+
context.includes("\\node_modules\\");
|
|
140
|
+
if (isInsideNodeModules) {
|
|
141
|
+
searchPaths.push(path.join(cwd, "node_modules"));
|
|
142
|
+
}
|
|
143
|
+
let currentDir = context;
|
|
144
|
+
while (true) {
|
|
145
|
+
if (path.basename(currentDir) !== "node_modules") {
|
|
146
|
+
const nodeModulesPath = path.join(currentDir, "node_modules");
|
|
147
|
+
if (!searchPaths.includes(nodeModulesPath)) {
|
|
148
|
+
searchPaths.push(nodeModulesPath);
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
const parent = path.dirname(currentDir);
|
|
152
|
+
if (parent === currentDir)
|
|
153
|
+
break;
|
|
154
|
+
currentDir = parent;
|
|
155
|
+
}
|
|
156
|
+
searchPathsCache[context] = searchPaths;
|
|
157
|
+
}
|
|
158
|
+
for (const nodeModulesDir of searchPaths) {
|
|
159
|
+
const nodeModulesPath = path.join(nodeModulesDir, id);
|
|
160
|
+
// Check package.json first
|
|
161
|
+
const pkgJsonPath = path.join(nodeModulesPath, "package.json");
|
|
162
|
+
if (existsSync(pkgJsonPath)) {
|
|
163
|
+
try {
|
|
164
|
+
let pkg;
|
|
165
|
+
if (pkgJsonCache[pkgJsonPath]) {
|
|
166
|
+
pkg = pkgJsonCache[pkgJsonPath];
|
|
167
|
+
}
|
|
168
|
+
else {
|
|
169
|
+
pkg = JSON.parse(fs.readFileSync(pkgJsonPath, "utf8"));
|
|
170
|
+
pkgJsonCache[pkgJsonPath] = pkg;
|
|
171
|
+
}
|
|
172
|
+
const mainField = pkg.main;
|
|
173
|
+
if (mainField) {
|
|
174
|
+
const candidates = [
|
|
175
|
+
path.resolve(nodeModulesPath, mainField),
|
|
176
|
+
path.resolve(nodeModulesPath, mainField) + ".js",
|
|
177
|
+
path.resolve(nodeModulesPath, mainField) + ".json",
|
|
178
|
+
path.resolve(nodeModulesPath, mainField, "index.js"),
|
|
179
|
+
];
|
|
180
|
+
for (const candidate of candidates) {
|
|
181
|
+
if (existsSync(candidate) && !statSync(candidate).isDirectory()) {
|
|
182
|
+
resolvedId = candidate;
|
|
183
|
+
moduleCode = fs.readFileSync(candidate, "utf8");
|
|
184
|
+
moduleId = candidate;
|
|
185
|
+
break;
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
catch (_g) { }
|
|
191
|
+
}
|
|
192
|
+
if (!moduleCode) {
|
|
193
|
+
const extensions = ["", ".js", ".json", "/index.js"];
|
|
194
|
+
for (const ext of extensions) {
|
|
195
|
+
const p = nodeModulesPath + ext;
|
|
196
|
+
if (existsSync(p) && !statSync(p).isDirectory()) {
|
|
197
|
+
resolvedId = p;
|
|
198
|
+
moduleCode = fs.readFileSync(p, "utf8");
|
|
199
|
+
moduleId = p;
|
|
200
|
+
break;
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
if (moduleCode)
|
|
205
|
+
break;
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
// Fallback: Try resolving absolute path (handling CWD stripping)
|
|
209
|
+
if (!moduleCode && id.startsWith("/")) {
|
|
210
|
+
// @ts-ignore
|
|
211
|
+
const cwd = ((_e = (_d = self.process) === null || _d === void 0 ? void 0 : _d.cwd) === null || _e === void 0 ? void 0 : _e.call(_d)) || ((_f = self.workerData) === null || _f === void 0 ? void 0 : _f.cwd) || "/";
|
|
212
|
+
let relativeId = id;
|
|
213
|
+
if (id.startsWith(cwd)) {
|
|
214
|
+
relativeId = id.slice(cwd.length);
|
|
215
|
+
if (relativeId.startsWith("/"))
|
|
216
|
+
relativeId = relativeId.slice(1);
|
|
217
|
+
}
|
|
218
|
+
const extensions = ["", ".js", ".json", "/index.js"];
|
|
219
|
+
for (const ext of extensions) {
|
|
220
|
+
const p = relativeId + ext;
|
|
221
|
+
if (existsSync(p) && !statSync(p).isDirectory()) {
|
|
222
|
+
resolvedId = p; // Use relative path for FS ops
|
|
223
|
+
moduleCode = fs.readFileSync(p, "utf8");
|
|
224
|
+
moduleId = id; // Keep original absolute path as module ID
|
|
225
|
+
break;
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
if (!moduleCode) {
|
|
230
|
+
// Try extensions
|
|
231
|
+
const extensions = ["", ".js", ".json", "/index.js"];
|
|
232
|
+
for (const ext of extensions) {
|
|
233
|
+
const p = resolvedId + ext;
|
|
234
|
+
if (existsSync(p) && !statSync(p).isDirectory()) {
|
|
235
|
+
resolvedId = p;
|
|
236
|
+
moduleCode = fs.readFileSync(p, "utf8");
|
|
237
|
+
moduleId = p;
|
|
238
|
+
break;
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
if (moduleCode) {
|
|
243
|
+
const cacheKey = `${context}:${id}`;
|
|
244
|
+
resolutionCache[cacheKey] = moduleId;
|
|
245
|
+
return executeModule(moduleCode, moduleId, id, importMaps, entrypoint);
|
|
246
|
+
}
|
|
247
|
+
console.error(`Worker: Dependency ${id} (resolved: ${resolvedId}) not found.`);
|
|
248
|
+
return {};
|
|
249
|
+
};
|
|
3
250
|
export async function cjs(entrypoint, importMaps) {
|
|
4
|
-
debugger;
|
|
5
251
|
await Promise.all(Object.entries(importMaps).map(async ([k, v]) => {
|
|
6
|
-
if (v.startsWith("
|
|
252
|
+
if (v.startsWith("https://")) {
|
|
7
253
|
try {
|
|
8
254
|
const response = await fetch(v);
|
|
9
255
|
if (response.ok) {
|
|
@@ -20,61 +266,10 @@ export async function cjs(entrypoint, importMaps) {
|
|
|
20
266
|
}
|
|
21
267
|
}
|
|
22
268
|
}));
|
|
23
|
-
Object.assign(importMaps, nodePolyFills);
|
|
24
|
-
const require = (id) => {
|
|
25
|
-
let dependency = System.get(id);
|
|
26
|
-
if (dependency) {
|
|
27
|
-
return dependency.default;
|
|
28
|
-
}
|
|
29
|
-
if (id in nodePolyFills) {
|
|
30
|
-
// @ts-ignore
|
|
31
|
-
return nodePolyFills[id];
|
|
32
|
-
}
|
|
33
|
-
const moduleCode = importMaps[id];
|
|
34
|
-
if (!moduleCode) {
|
|
35
|
-
console.error(`Worker: Dependency ${id} not found in import maps.`);
|
|
36
|
-
return {};
|
|
37
|
-
}
|
|
38
|
-
let finalExports = {};
|
|
39
|
-
const module = { exports: finalExports };
|
|
40
|
-
const exports = module.exports;
|
|
41
|
-
try {
|
|
42
|
-
new Function("require", "exports", "module", moduleCode)(require, exports, module);
|
|
43
|
-
finalExports = module.exports;
|
|
44
|
-
}
|
|
45
|
-
catch (e) {
|
|
46
|
-
console.error(`Worker: Error executing dependency module ${id}:`, e);
|
|
47
|
-
throw new Error(`Failed to load CJS dependency ${id}: ${e.message}`);
|
|
48
|
-
}
|
|
49
|
-
System.set(id, { default: finalExports });
|
|
50
|
-
return finalExports;
|
|
51
|
-
};
|
|
52
|
-
require.resolve = (request) => request;
|
|
53
269
|
// @ts-ignore
|
|
54
270
|
// a hack for loader-runner resolving
|
|
55
|
-
self.__systemjs_require__ =
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
if (path === entrypoint) {
|
|
60
|
-
entryPointCode = moduleCode;
|
|
61
|
-
// FIXME
|
|
62
|
-
entryPointCode = "self.Buffer = require('buffer').Buffer;" + moduleCode;
|
|
63
|
-
break;
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
if (entryPointCode) {
|
|
67
|
-
let finalExports = {};
|
|
68
|
-
const module = { exports: finalExports };
|
|
69
|
-
const exports = module.exports;
|
|
70
|
-
try {
|
|
71
|
-
new Function("require", "exports", "module", entryPointCode)(require, exports, module);
|
|
72
|
-
}
|
|
73
|
-
catch (e) {
|
|
74
|
-
console.error(`Worker: Error executing entry point ${entrypoint}:`, e);
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
else {
|
|
78
|
-
console.warn("Warning: Entry point not found in import maps. No final execution step taken.");
|
|
79
|
-
}
|
|
271
|
+
self.__systemjs_require__ = (id) => loadModule(id, path.dirname(entrypoint), importMaps, entrypoint);
|
|
272
|
+
// @ts-ignore
|
|
273
|
+
self.__systemjs_require__.resolve = (request) => request;
|
|
274
|
+
loadModule(entrypoint, path.dirname(entrypoint), importMaps, entrypoint);
|
|
80
275
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
declare
|
|
2
|
-
export default
|
|
1
|
+
export declare function startLoaderWorker(): void;
|
|
2
|
+
export default startLoaderWorker;
|
|
@@ -1,31 +1,41 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { SabComClient } from "../../sabcom";
|
|
2
|
+
import initWasm, { recvTaskMessageInWorker, sendTaskMessage, workerCreated, } from "../../utoo";
|
|
2
3
|
import { cjs } from "./cjs";
|
|
3
4
|
const binding = {
|
|
4
|
-
|
|
5
|
-
recvMessageInWorker,
|
|
6
|
-
notifyWorkerAck,
|
|
5
|
+
recvTaskMessageInWorker,
|
|
7
6
|
sendTaskMessage,
|
|
7
|
+
workerCreated,
|
|
8
8
|
};
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
9
|
+
export function startLoaderWorker() {
|
|
10
|
+
self.onmessage = async (event) => {
|
|
11
|
+
let [module, memory, meta] = event.data;
|
|
12
|
+
await initWasm(module, memory).catch((err) => {
|
|
13
|
+
console.log(err);
|
|
14
|
+
throw err;
|
|
15
|
+
});
|
|
16
|
+
const sabClient = meta.sab
|
|
17
|
+
? new SabComClient(meta.sab, () => {
|
|
18
|
+
self.postMessage("sab_request");
|
|
19
|
+
})
|
|
20
|
+
: undefined;
|
|
21
|
+
self.workerData = {
|
|
22
|
+
workerId: meta.workerData.workerId,
|
|
23
|
+
cwd: meta.workerData.cwd,
|
|
24
|
+
binding,
|
|
25
|
+
sabClient,
|
|
26
|
+
};
|
|
27
|
+
self.process = {
|
|
28
|
+
env: {},
|
|
29
|
+
cwd: () => self.workerData.cwd,
|
|
30
|
+
};
|
|
31
|
+
console.log("Worker CWD:", self.process.cwd());
|
|
32
|
+
cjs(meta.loaderAssets.entrypoint, meta.loaderAssets.importMaps);
|
|
28
33
|
};
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
34
|
+
}
|
|
35
|
+
// @ts-ignore
|
|
36
|
+
if (typeof __webpack_require__ !== "undefined") {
|
|
37
|
+
// @ts-ignore
|
|
38
|
+
self.startLoaderWorker = startLoaderWorker;
|
|
39
|
+
}
|
|
40
|
+
startLoaderWorker();
|
|
41
|
+
export default startLoaderWorker;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import micromatch from "micromatch";
|
|
2
|
+
import * as path from "path";
|
|
3
|
+
import * as fs from "./fsPolyfill";
|
|
4
|
+
const walkSync = (currentDir, rootDir, entries) => {
|
|
5
|
+
let list;
|
|
6
|
+
try {
|
|
7
|
+
list = fs.readdirSync(currentDir, { withFileTypes: true });
|
|
8
|
+
}
|
|
9
|
+
catch (e) {
|
|
10
|
+
return;
|
|
11
|
+
}
|
|
12
|
+
for (const entry of list) {
|
|
13
|
+
const fullPath = path.join(currentDir, entry.name);
|
|
14
|
+
const relativePath = path.relative(rootDir, fullPath);
|
|
15
|
+
if (entry.isDirectory()) {
|
|
16
|
+
walkSync(fullPath, rootDir, entries);
|
|
17
|
+
}
|
|
18
|
+
else if (entry.isFile()) {
|
|
19
|
+
entries.push(relativePath);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
const fastGlob = (patterns, options = {}) => {
|
|
24
|
+
return Promise.resolve(fastGlob.sync(patterns, options));
|
|
25
|
+
};
|
|
26
|
+
fastGlob.sync = (patterns, options = {}) => {
|
|
27
|
+
const cwd = options.cwd || "/";
|
|
28
|
+
const ignore = options.ignore || [];
|
|
29
|
+
const allFiles = [];
|
|
30
|
+
walkSync(cwd, cwd, allFiles);
|
|
31
|
+
const matched = micromatch(allFiles, patterns, {
|
|
32
|
+
ignore: ignore,
|
|
33
|
+
dot: options.dot,
|
|
34
|
+
cwd: cwd,
|
|
35
|
+
});
|
|
36
|
+
if (options.absolute) {
|
|
37
|
+
return matched.map((p) => path.join(cwd, p));
|
|
38
|
+
}
|
|
39
|
+
return matched;
|
|
40
|
+
};
|
|
41
|
+
fastGlob.stream = (patterns, options = {}) => {
|
|
42
|
+
throw new Error("fastGlob.stream is not implemented in polyfill");
|
|
43
|
+
};
|
|
44
|
+
fastGlob.async = fastGlob;
|
|
45
|
+
fastGlob.generateTasks = () => [];
|
|
46
|
+
fastGlob.isDynamicPattern = (p) => micromatch.scan(p).isGlob;
|
|
47
|
+
fastGlob.escapePath = (p) => p.replace(/([*?|(){}[\]])/g, "\\$1");
|
|
48
|
+
export default fastGlob;
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
import { Buffer } from "buffer";
|
|
2
|
+
export declare function readFile(path: string, options: any, cb: Function): void;
|
|
3
|
+
export declare function readFileSync(path: string, options: any): string | Buffer<any>;
|
|
4
|
+
export declare function readdirSync(path: string, options?: any): any;
|
|
5
|
+
export declare function readdir(path: string, options: any, cb: Function): void;
|
|
6
|
+
export declare function writeFileSync(path: string, data: string | Uint8Array, options?: any): void;
|
|
7
|
+
export declare function writeFile(path: string, data: string | Uint8Array, options: any, cb: Function): void;
|
|
8
|
+
export declare function mkdirSync(path: string, options?: any): void;
|
|
9
|
+
export declare function mkdir(path: string, options: any, cb: Function): void;
|
|
10
|
+
export declare function rmSync(path: string, options?: any): void;
|
|
11
|
+
export declare function rm(path: string, options: any, cb: Function): void;
|
|
12
|
+
export declare function rmdirSync(path: string, options?: any): void;
|
|
13
|
+
export declare function rmdir(path: string, options: any, cb: Function): void;
|
|
14
|
+
export declare function copyFileSync(src: string, dst: string): void;
|
|
15
|
+
export declare function copyFile(src: string, dst: string, cb: Function): void;
|
|
16
|
+
export declare function statSync(p: string): {
|
|
17
|
+
isDirectory: () => any;
|
|
18
|
+
isFile: () => any;
|
|
19
|
+
isSymbolicLink: () => any;
|
|
20
|
+
size: number;
|
|
21
|
+
mtime: Date;
|
|
22
|
+
};
|
|
23
|
+
export declare function lstatSync(p: string): {
|
|
24
|
+
isDirectory: () => any;
|
|
25
|
+
isFile: () => any;
|
|
26
|
+
isSymbolicLink: () => any;
|
|
27
|
+
size: number;
|
|
28
|
+
mtime: Date;
|
|
29
|
+
};
|
|
30
|
+
export declare function stat(path: string, cb: Function): void;
|
|
31
|
+
export declare function lstat(path: string, cb: Function): void;
|
|
32
|
+
export declare function realpathSync(p: string): string;
|
|
33
|
+
export declare function realpath(p: string, cb: Function): void;
|
|
34
|
+
export declare function accessSync(path: string, mode?: number): void;
|
|
35
|
+
export declare function access(path: string, mode: number | Function, cb?: Function): void;
|
|
36
|
+
export declare function existsSync(path: string): boolean;
|
|
37
|
+
export declare const promises: {
|
|
38
|
+
readFile: (path: string, options?: any) => Promise<string | Buffer<any>>;
|
|
39
|
+
writeFile: (path: string, data: string | Uint8Array, options?: any) => Promise<void>;
|
|
40
|
+
readdir: (path: string, options?: any) => Promise<any>;
|
|
41
|
+
mkdir: (path: string, options?: any) => Promise<void>;
|
|
42
|
+
rm: (path: string, options?: any) => Promise<void>;
|
|
43
|
+
rmdir: (path: string, options?: any) => Promise<void>;
|
|
44
|
+
copyFile: (src: string, dst: string) => Promise<void>;
|
|
45
|
+
stat: (p: string) => Promise<{
|
|
46
|
+
isDirectory: () => any;
|
|
47
|
+
isFile: () => any;
|
|
48
|
+
isSymbolicLink: () => any;
|
|
49
|
+
size: number;
|
|
50
|
+
mtime: Date;
|
|
51
|
+
}>;
|
|
52
|
+
lstat: (p: string) => Promise<{
|
|
53
|
+
isDirectory: () => any;
|
|
54
|
+
isFile: () => any;
|
|
55
|
+
isSymbolicLink: () => any;
|
|
56
|
+
size: number;
|
|
57
|
+
mtime: Date;
|
|
58
|
+
}>;
|
|
59
|
+
realpath: (p: string) => Promise<string>;
|
|
60
|
+
access: (path: string, mode?: number) => Promise<void>;
|
|
61
|
+
};
|
|
62
|
+
export declare const constants: {
|
|
63
|
+
F_OK: number;
|
|
64
|
+
R_OK: number;
|
|
65
|
+
W_OK: number;
|
|
66
|
+
X_OK: number;
|
|
67
|
+
};
|
|
68
|
+
declare const _default: {
|
|
69
|
+
readFile: typeof readFile;
|
|
70
|
+
readFileSync: typeof readFileSync;
|
|
71
|
+
readdir: typeof readdir;
|
|
72
|
+
readdirSync: typeof readdirSync;
|
|
73
|
+
writeFile: typeof writeFile;
|
|
74
|
+
writeFileSync: typeof writeFileSync;
|
|
75
|
+
mkdir: typeof mkdir;
|
|
76
|
+
mkdirSync: typeof mkdirSync;
|
|
77
|
+
rm: typeof rm;
|
|
78
|
+
rmSync: typeof rmSync;
|
|
79
|
+
rmdir: typeof rmdir;
|
|
80
|
+
rmdirSync: typeof rmdirSync;
|
|
81
|
+
copyFile: typeof copyFile;
|
|
82
|
+
copyFileSync: typeof copyFileSync;
|
|
83
|
+
stat: typeof stat;
|
|
84
|
+
statSync: typeof statSync;
|
|
85
|
+
lstat: typeof lstat;
|
|
86
|
+
lstatSync: typeof lstatSync;
|
|
87
|
+
realpath: typeof realpath;
|
|
88
|
+
realpathSync: typeof realpathSync;
|
|
89
|
+
access: typeof access;
|
|
90
|
+
accessSync: typeof accessSync;
|
|
91
|
+
existsSync: typeof existsSync;
|
|
92
|
+
promises: {
|
|
93
|
+
readFile: (path: string, options?: any) => Promise<string | Buffer<any>>;
|
|
94
|
+
writeFile: (path: string, data: string | Uint8Array, options?: any) => Promise<void>;
|
|
95
|
+
readdir: (path: string, options?: any) => Promise<any>;
|
|
96
|
+
mkdir: (path: string, options?: any) => Promise<void>;
|
|
97
|
+
rm: (path: string, options?: any) => Promise<void>;
|
|
98
|
+
rmdir: (path: string, options?: any) => Promise<void>;
|
|
99
|
+
copyFile: (src: string, dst: string) => Promise<void>;
|
|
100
|
+
stat: (p: string) => Promise<{
|
|
101
|
+
isDirectory: () => any;
|
|
102
|
+
isFile: () => any;
|
|
103
|
+
isSymbolicLink: () => any;
|
|
104
|
+
size: number;
|
|
105
|
+
mtime: Date;
|
|
106
|
+
}>;
|
|
107
|
+
lstat: (p: string) => Promise<{
|
|
108
|
+
isDirectory: () => any;
|
|
109
|
+
isFile: () => any;
|
|
110
|
+
isSymbolicLink: () => any;
|
|
111
|
+
size: number;
|
|
112
|
+
mtime: Date;
|
|
113
|
+
}>;
|
|
114
|
+
realpath: (p: string) => Promise<string>;
|
|
115
|
+
access: (path: string, mode?: number) => Promise<void>;
|
|
116
|
+
};
|
|
117
|
+
constants: {
|
|
118
|
+
F_OK: number;
|
|
119
|
+
R_OK: number;
|
|
120
|
+
W_OK: number;
|
|
121
|
+
X_OK: number;
|
|
122
|
+
};
|
|
123
|
+
};
|
|
124
|
+
export default _default;
|