@utoo/web 1.2.0-rc.2 → 1.2.0-rc.4
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 → 3ec3463a197b5c4bac1e.wasm} +0 -0
- package/esm/loaderWorker.js +1 -1
- package/esm/loaderWorker.js.LICENSE.txt +0 -21
- package/esm/loaderWorkerPool.d.ts +1 -1
- package/esm/loaderWorkerPool.js +15 -62
- package/esm/sabcom.d.ts +13 -0
- package/esm/sabcom.js +65 -0
- package/esm/serviceWorker.js +1 -1
- package/esm/utoo/index.d.ts +20 -1
- package/esm/utoo/index.js +90 -61
- package/esm/utoo/index_bg.wasm +0 -0
- package/esm/webpackLoaders/worker/cjs.js +45 -28
- package/esm/webpackLoaders/worker/polyfills/fsPolyfill.d.ts +132 -12
- package/esm/webpackLoaders/worker/polyfills/fsPolyfill.js +66 -13
- package/esm/webpackLoaders/worker/polyfills/nodePolyFills.d.ts +0 -2
- package/esm/webpackLoaders/worker/polyfills/nodePolyFills.js +4 -3
- package/package.json +1 -1
- package/esm/webpackLoaders/loaders/less-loader/index.d.ts +0 -3
- package/esm/webpackLoaders/loaders/less-loader/index.js +0 -103
- package/esm/webpackLoaders/loaders/less-loader/options.json +0 -67
- package/esm/webpackLoaders/loaders/less-loader/utils.d.ts +0 -14
- package/esm/webpackLoaders/loaders/less-loader/utils.js +0 -217
- package/esm/webpackLoaders/worker/polyfills/fastGlobPolyfill.d.ts +0 -2
- package/esm/webpackLoaders/worker/polyfills/fastGlobPolyfill.js +0 -48
|
@@ -51,13 +51,16 @@ const executeModule = (moduleCode, moduleId, id, importMaps, entrypoint) => {
|
|
|
51
51
|
if (moduleId === entrypoint) {
|
|
52
52
|
moduleCode = "self.Buffer = require('buffer').Buffer;" + moduleCode;
|
|
53
53
|
}
|
|
54
|
+
if (!moduleId.endsWith(".json")) {
|
|
55
|
+
moduleCode = `// [Debug] Resolved: ${moduleId}\n` + moduleCode;
|
|
56
|
+
}
|
|
54
57
|
try {
|
|
55
58
|
if (moduleId.endsWith(".json")) {
|
|
56
59
|
finalExports = JSON.parse(moduleCode);
|
|
57
60
|
module.exports = finalExports;
|
|
58
61
|
}
|
|
59
62
|
else {
|
|
60
|
-
new Function("require", "exports", "module", "__filename", "__dirname", moduleCode)(moduleRequire, module.exports, module, moduleId, context);
|
|
63
|
+
new Function("require", "exports", "module", "__filename", "__dirname", "process", moduleCode)(moduleRequire, module.exports, module, moduleId, context, nodePolyFills.process);
|
|
61
64
|
finalExports = module.exports;
|
|
62
65
|
}
|
|
63
66
|
}
|
|
@@ -86,7 +89,7 @@ const executeModule = (moduleCode, moduleId, id, importMaps, entrypoint) => {
|
|
|
86
89
|
return finalExports;
|
|
87
90
|
};
|
|
88
91
|
const loadModule = (id, context, importMaps, entrypoint) => {
|
|
89
|
-
var _a, _b, _c
|
|
92
|
+
var _a, _b, _c;
|
|
90
93
|
const cacheKey = `${context}:${id}`;
|
|
91
94
|
if (resolutionCache[cacheKey]) {
|
|
92
95
|
const cachedId = resolutionCache[cacheKey];
|
|
@@ -133,13 +136,6 @@ const loadModule = (id, context, importMaps, entrypoint) => {
|
|
|
133
136
|
let searchPaths = searchPathsCache[context];
|
|
134
137
|
if (!searchPaths) {
|
|
135
138
|
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
139
|
let currentDir = context;
|
|
144
140
|
while (true) {
|
|
145
141
|
if (path.basename(currentDir) !== "node_modules") {
|
|
@@ -179,25 +175,35 @@ const loadModule = (id, context, importMaps, entrypoint) => {
|
|
|
179
175
|
];
|
|
180
176
|
for (const candidate of candidates) {
|
|
181
177
|
if (existsSync(candidate) && !statSync(candidate).isDirectory()) {
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
178
|
+
try {
|
|
179
|
+
resolvedId = candidate;
|
|
180
|
+
moduleCode = fs.readFileSync(candidate, "utf8");
|
|
181
|
+
moduleId = candidate;
|
|
182
|
+
break;
|
|
183
|
+
}
|
|
184
|
+
catch (e) {
|
|
185
|
+
// ignore
|
|
186
|
+
}
|
|
186
187
|
}
|
|
187
188
|
}
|
|
188
189
|
}
|
|
189
190
|
}
|
|
190
|
-
catch (
|
|
191
|
+
catch (_d) { }
|
|
191
192
|
}
|
|
192
193
|
if (!moduleCode) {
|
|
193
194
|
const extensions = ["", ".js", ".json", "/index.js"];
|
|
194
195
|
for (const ext of extensions) {
|
|
195
196
|
const p = nodeModulesPath + ext;
|
|
196
197
|
if (existsSync(p) && !statSync(p).isDirectory()) {
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
198
|
+
try {
|
|
199
|
+
resolvedId = p;
|
|
200
|
+
moduleCode = fs.readFileSync(p, "utf8");
|
|
201
|
+
moduleId = p;
|
|
202
|
+
break;
|
|
203
|
+
}
|
|
204
|
+
catch (e) {
|
|
205
|
+
// ignore
|
|
206
|
+
}
|
|
201
207
|
}
|
|
202
208
|
}
|
|
203
209
|
}
|
|
@@ -208,7 +214,7 @@ const loadModule = (id, context, importMaps, entrypoint) => {
|
|
|
208
214
|
// Fallback: Try resolving absolute path (handling CWD stripping)
|
|
209
215
|
if (!moduleCode && id.startsWith("/")) {
|
|
210
216
|
// @ts-ignore
|
|
211
|
-
const cwd = ((
|
|
217
|
+
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) || "/";
|
|
212
218
|
let relativeId = id;
|
|
213
219
|
if (id.startsWith(cwd)) {
|
|
214
220
|
relativeId = id.slice(cwd.length);
|
|
@@ -219,10 +225,15 @@ const loadModule = (id, context, importMaps, entrypoint) => {
|
|
|
219
225
|
for (const ext of extensions) {
|
|
220
226
|
const p = relativeId + ext;
|
|
221
227
|
if (existsSync(p) && !statSync(p).isDirectory()) {
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
228
|
+
try {
|
|
229
|
+
resolvedId = p; // Use relative path for FS ops
|
|
230
|
+
moduleCode = fs.readFileSync(p, "utf8");
|
|
231
|
+
moduleId = id; // Keep original absolute path as module ID
|
|
232
|
+
break;
|
|
233
|
+
}
|
|
234
|
+
catch (e) {
|
|
235
|
+
// ignore
|
|
236
|
+
}
|
|
226
237
|
}
|
|
227
238
|
}
|
|
228
239
|
}
|
|
@@ -232,10 +243,16 @@ const loadModule = (id, context, importMaps, entrypoint) => {
|
|
|
232
243
|
for (const ext of extensions) {
|
|
233
244
|
const p = resolvedId + ext;
|
|
234
245
|
if (existsSync(p) && !statSync(p).isDirectory()) {
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
246
|
+
try {
|
|
247
|
+
resolvedId = p;
|
|
248
|
+
moduleCode = fs.readFileSync(p, "utf8");
|
|
249
|
+
moduleId = p;
|
|
250
|
+
break;
|
|
251
|
+
}
|
|
252
|
+
catch (e) {
|
|
253
|
+
console.error(`[Debug] Failed to read file ${p}:`, e);
|
|
254
|
+
// ignore
|
|
255
|
+
}
|
|
239
256
|
}
|
|
240
257
|
}
|
|
241
258
|
}
|
|
@@ -244,7 +261,7 @@ const loadModule = (id, context, importMaps, entrypoint) => {
|
|
|
244
261
|
resolutionCache[cacheKey] = moduleId;
|
|
245
262
|
return executeModule(moduleCode, moduleId, id, importMaps, entrypoint);
|
|
246
263
|
}
|
|
247
|
-
console.error(`Worker: Dependency ${id} (resolved: ${resolvedId}) not found
|
|
264
|
+
console.error(`Worker: Dependency ${id} (resolved: ${resolvedId}) not found. Context: ${context}`);
|
|
248
265
|
return {};
|
|
249
266
|
};
|
|
250
267
|
export async function cjs(entrypoint, importMaps) {
|
|
@@ -14,18 +14,58 @@ export declare function rmdir(path: string, options: any, cb: Function): void;
|
|
|
14
14
|
export declare function copyFileSync(src: string, dst: string): void;
|
|
15
15
|
export declare function copyFile(src: string, dst: string, cb: Function): void;
|
|
16
16
|
export declare function statSync(p: string): {
|
|
17
|
+
dev: number;
|
|
18
|
+
ino: number;
|
|
19
|
+
mode: number;
|
|
20
|
+
nlink: number;
|
|
21
|
+
uid: number;
|
|
22
|
+
gid: number;
|
|
23
|
+
rdev: number;
|
|
24
|
+
size: number;
|
|
25
|
+
blksize: number;
|
|
26
|
+
blocks: number;
|
|
27
|
+
atimeMs: number;
|
|
28
|
+
mtimeMs: number;
|
|
29
|
+
ctimeMs: number;
|
|
30
|
+
birthtimeMs: number;
|
|
31
|
+
atime: Date;
|
|
32
|
+
mtime: Date;
|
|
33
|
+
ctime: Date;
|
|
34
|
+
birthtime: Date;
|
|
17
35
|
isDirectory: () => any;
|
|
18
36
|
isFile: () => any;
|
|
19
37
|
isSymbolicLink: () => any;
|
|
20
|
-
|
|
21
|
-
|
|
38
|
+
isBlockDevice: () => boolean;
|
|
39
|
+
isCharacterDevice: () => boolean;
|
|
40
|
+
isFIFO: () => boolean;
|
|
41
|
+
isSocket: () => boolean;
|
|
22
42
|
};
|
|
23
43
|
export declare function lstatSync(p: string): {
|
|
44
|
+
dev: number;
|
|
45
|
+
ino: number;
|
|
46
|
+
mode: number;
|
|
47
|
+
nlink: number;
|
|
48
|
+
uid: number;
|
|
49
|
+
gid: number;
|
|
50
|
+
rdev: number;
|
|
51
|
+
size: number;
|
|
52
|
+
blksize: number;
|
|
53
|
+
blocks: number;
|
|
54
|
+
atimeMs: number;
|
|
55
|
+
mtimeMs: number;
|
|
56
|
+
ctimeMs: number;
|
|
57
|
+
birthtimeMs: number;
|
|
58
|
+
atime: Date;
|
|
59
|
+
mtime: Date;
|
|
60
|
+
ctime: Date;
|
|
61
|
+
birthtime: Date;
|
|
24
62
|
isDirectory: () => any;
|
|
25
63
|
isFile: () => any;
|
|
26
64
|
isSymbolicLink: () => any;
|
|
27
|
-
|
|
28
|
-
|
|
65
|
+
isBlockDevice: () => boolean;
|
|
66
|
+
isCharacterDevice: () => boolean;
|
|
67
|
+
isFIFO: () => boolean;
|
|
68
|
+
isSocket: () => boolean;
|
|
29
69
|
};
|
|
30
70
|
export declare function stat(path: string, cb: Function): void;
|
|
31
71
|
export declare function lstat(path: string, cb: Function): void;
|
|
@@ -43,18 +83,58 @@ export declare const promises: {
|
|
|
43
83
|
rmdir: (path: string, options?: any) => Promise<void>;
|
|
44
84
|
copyFile: (src: string, dst: string) => Promise<void>;
|
|
45
85
|
stat: (p: string) => Promise<{
|
|
86
|
+
dev: number;
|
|
87
|
+
ino: number;
|
|
88
|
+
mode: number;
|
|
89
|
+
nlink: number;
|
|
90
|
+
uid: number;
|
|
91
|
+
gid: number;
|
|
92
|
+
rdev: number;
|
|
93
|
+
size: number;
|
|
94
|
+
blksize: number;
|
|
95
|
+
blocks: number;
|
|
96
|
+
atimeMs: number;
|
|
97
|
+
mtimeMs: number;
|
|
98
|
+
ctimeMs: number;
|
|
99
|
+
birthtimeMs: number;
|
|
100
|
+
atime: Date;
|
|
101
|
+
mtime: Date;
|
|
102
|
+
ctime: Date;
|
|
103
|
+
birthtime: Date;
|
|
46
104
|
isDirectory: () => any;
|
|
47
105
|
isFile: () => any;
|
|
48
106
|
isSymbolicLink: () => any;
|
|
49
|
-
|
|
50
|
-
|
|
107
|
+
isBlockDevice: () => boolean;
|
|
108
|
+
isCharacterDevice: () => boolean;
|
|
109
|
+
isFIFO: () => boolean;
|
|
110
|
+
isSocket: () => boolean;
|
|
51
111
|
}>;
|
|
52
112
|
lstat: (p: string) => Promise<{
|
|
113
|
+
dev: number;
|
|
114
|
+
ino: number;
|
|
115
|
+
mode: number;
|
|
116
|
+
nlink: number;
|
|
117
|
+
uid: number;
|
|
118
|
+
gid: number;
|
|
119
|
+
rdev: number;
|
|
120
|
+
size: number;
|
|
121
|
+
blksize: number;
|
|
122
|
+
blocks: number;
|
|
123
|
+
atimeMs: number;
|
|
124
|
+
mtimeMs: number;
|
|
125
|
+
ctimeMs: number;
|
|
126
|
+
birthtimeMs: number;
|
|
127
|
+
atime: Date;
|
|
128
|
+
mtime: Date;
|
|
129
|
+
ctime: Date;
|
|
130
|
+
birthtime: Date;
|
|
53
131
|
isDirectory: () => any;
|
|
54
132
|
isFile: () => any;
|
|
55
133
|
isSymbolicLink: () => any;
|
|
56
|
-
|
|
57
|
-
|
|
134
|
+
isBlockDevice: () => boolean;
|
|
135
|
+
isCharacterDevice: () => boolean;
|
|
136
|
+
isFIFO: () => boolean;
|
|
137
|
+
isSocket: () => boolean;
|
|
58
138
|
}>;
|
|
59
139
|
realpath: (p: string) => Promise<string>;
|
|
60
140
|
access: (path: string, mode?: number) => Promise<void>;
|
|
@@ -98,18 +178,58 @@ declare const _default: {
|
|
|
98
178
|
rmdir: (path: string, options?: any) => Promise<void>;
|
|
99
179
|
copyFile: (src: string, dst: string) => Promise<void>;
|
|
100
180
|
stat: (p: string) => Promise<{
|
|
181
|
+
dev: number;
|
|
182
|
+
ino: number;
|
|
183
|
+
mode: number;
|
|
184
|
+
nlink: number;
|
|
185
|
+
uid: number;
|
|
186
|
+
gid: number;
|
|
187
|
+
rdev: number;
|
|
188
|
+
size: number;
|
|
189
|
+
blksize: number;
|
|
190
|
+
blocks: number;
|
|
191
|
+
atimeMs: number;
|
|
192
|
+
mtimeMs: number;
|
|
193
|
+
ctimeMs: number;
|
|
194
|
+
birthtimeMs: number;
|
|
195
|
+
atime: Date;
|
|
196
|
+
mtime: Date;
|
|
197
|
+
ctime: Date;
|
|
198
|
+
birthtime: Date;
|
|
101
199
|
isDirectory: () => any;
|
|
102
200
|
isFile: () => any;
|
|
103
201
|
isSymbolicLink: () => any;
|
|
104
|
-
|
|
105
|
-
|
|
202
|
+
isBlockDevice: () => boolean;
|
|
203
|
+
isCharacterDevice: () => boolean;
|
|
204
|
+
isFIFO: () => boolean;
|
|
205
|
+
isSocket: () => boolean;
|
|
106
206
|
}>;
|
|
107
207
|
lstat: (p: string) => Promise<{
|
|
208
|
+
dev: number;
|
|
209
|
+
ino: number;
|
|
210
|
+
mode: number;
|
|
211
|
+
nlink: number;
|
|
212
|
+
uid: number;
|
|
213
|
+
gid: number;
|
|
214
|
+
rdev: number;
|
|
215
|
+
size: number;
|
|
216
|
+
blksize: number;
|
|
217
|
+
blocks: number;
|
|
218
|
+
atimeMs: number;
|
|
219
|
+
mtimeMs: number;
|
|
220
|
+
ctimeMs: number;
|
|
221
|
+
birthtimeMs: number;
|
|
222
|
+
atime: Date;
|
|
223
|
+
mtime: Date;
|
|
224
|
+
ctime: Date;
|
|
225
|
+
birthtime: Date;
|
|
108
226
|
isDirectory: () => any;
|
|
109
227
|
isFile: () => any;
|
|
110
228
|
isSymbolicLink: () => any;
|
|
111
|
-
|
|
112
|
-
|
|
229
|
+
isBlockDevice: () => boolean;
|
|
230
|
+
isCharacterDevice: () => boolean;
|
|
231
|
+
isFIFO: () => boolean;
|
|
232
|
+
isSocket: () => boolean;
|
|
113
233
|
}>;
|
|
114
234
|
realpath: (p: string) => Promise<string>;
|
|
115
235
|
access: (path: string, mode?: number) => Promise<void>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Buffer } from "buffer";
|
|
2
2
|
import path from "path";
|
|
3
|
-
import
|
|
3
|
+
import * as sabcom from "../../../sabcom";
|
|
4
4
|
function resolvePath(p) {
|
|
5
5
|
var _a, _b, _c;
|
|
6
6
|
// @ts-ignore
|
|
@@ -48,7 +48,7 @@ export function readFile(path, options, cb) {
|
|
|
48
48
|
}
|
|
49
49
|
export function readFileSync(path, options) {
|
|
50
50
|
const client = getSabClient();
|
|
51
|
-
const result = client.call(SAB_OP_READ_FILE, resolvePath(path));
|
|
51
|
+
const result = client.call(sabcom.SAB_OP_READ_FILE, resolvePath(path));
|
|
52
52
|
if (options === "utf8" ||
|
|
53
53
|
options === "utf-8" ||
|
|
54
54
|
(options && (options.encoding === "utf8" || options.encoding === "utf-8"))) {
|
|
@@ -58,7 +58,7 @@ export function readFileSync(path, options) {
|
|
|
58
58
|
}
|
|
59
59
|
export function readdirSync(path, options) {
|
|
60
60
|
const client = getSabClient();
|
|
61
|
-
const result = client.call(SAB_OP_READ_DIR, resolvePath(path));
|
|
61
|
+
const result = client.call(sabcom.SAB_OP_READ_DIR, resolvePath(path));
|
|
62
62
|
const json = new TextDecoder().decode(result);
|
|
63
63
|
const entries = JSON.parse(json);
|
|
64
64
|
if (options === null || options === void 0 ? void 0 : options.withFileTypes) {
|
|
@@ -89,7 +89,7 @@ export function writeFileSync(path, data, options) {
|
|
|
89
89
|
// TODO: handle binary data properly
|
|
90
90
|
const content = typeof data === "string" ? data : new TextDecoder().decode(data);
|
|
91
91
|
const payload = JSON.stringify({ path: resolvePath(path), data: content });
|
|
92
|
-
client.call(SAB_OP_WRITE_FILE, payload);
|
|
92
|
+
client.call(sabcom.SAB_OP_WRITE_FILE, payload);
|
|
93
93
|
}
|
|
94
94
|
export function writeFile(path, data, options, cb) {
|
|
95
95
|
if (typeof options === "function") {
|
|
@@ -108,7 +108,7 @@ export function mkdirSync(path, options) {
|
|
|
108
108
|
const client = getSabClient();
|
|
109
109
|
const recursive = (options === null || options === void 0 ? void 0 : options.recursive) || false;
|
|
110
110
|
const payload = JSON.stringify({ path: resolvePath(path), recursive });
|
|
111
|
-
client.call(SAB_OP_MKDIR, payload);
|
|
111
|
+
client.call(sabcom.SAB_OP_MKDIR, payload);
|
|
112
112
|
}
|
|
113
113
|
export function mkdir(path, options, cb) {
|
|
114
114
|
if (typeof options === "function") {
|
|
@@ -127,7 +127,7 @@ export function rmSync(path, options) {
|
|
|
127
127
|
const client = getSabClient();
|
|
128
128
|
const recursive = (options === null || options === void 0 ? void 0 : options.recursive) || false;
|
|
129
129
|
const payload = JSON.stringify({ path: resolvePath(path), recursive });
|
|
130
|
-
client.call(SAB_OP_RM, payload);
|
|
130
|
+
client.call(sabcom.SAB_OP_RM, payload);
|
|
131
131
|
}
|
|
132
132
|
export function rm(path, options, cb) {
|
|
133
133
|
if (typeof options === "function") {
|
|
@@ -146,7 +146,7 @@ export function rmdirSync(path, options) {
|
|
|
146
146
|
const client = getSabClient();
|
|
147
147
|
const recursive = (options === null || options === void 0 ? void 0 : options.recursive) || false;
|
|
148
148
|
const payload = JSON.stringify({ path: resolvePath(path), recursive });
|
|
149
|
-
client.call(SAB_OP_RMDIR, payload);
|
|
149
|
+
client.call(sabcom.SAB_OP_RMDIR, payload);
|
|
150
150
|
}
|
|
151
151
|
export function rmdir(path, options, cb) {
|
|
152
152
|
if (typeof options === "function") {
|
|
@@ -167,7 +167,7 @@ export function copyFileSync(src, dst) {
|
|
|
167
167
|
src: resolvePath(src),
|
|
168
168
|
dst: resolvePath(dst),
|
|
169
169
|
});
|
|
170
|
-
client.call(SAB_OP_COPY_FILE, payload);
|
|
170
|
+
client.call(sabcom.SAB_OP_COPY_FILE, payload);
|
|
171
171
|
}
|
|
172
172
|
export function copyFile(src, dst, cb) {
|
|
173
173
|
try {
|
|
@@ -183,26 +183,79 @@ export function statSync(p) {
|
|
|
183
183
|
const name = path.basename(p);
|
|
184
184
|
// Root check
|
|
185
185
|
if (p === "/" || p === ".") {
|
|
186
|
+
const now = new Date();
|
|
187
|
+
const nowMs = now.getTime();
|
|
186
188
|
return {
|
|
189
|
+
dev: 0,
|
|
190
|
+
ino: 0,
|
|
191
|
+
mode: 16877,
|
|
192
|
+
nlink: 1,
|
|
193
|
+
uid: 0,
|
|
194
|
+
gid: 0,
|
|
195
|
+
rdev: 0,
|
|
196
|
+
size: 0,
|
|
197
|
+
blksize: 4096,
|
|
198
|
+
blocks: 0,
|
|
199
|
+
atimeMs: nowMs,
|
|
200
|
+
mtimeMs: nowMs,
|
|
201
|
+
ctimeMs: nowMs,
|
|
202
|
+
birthtimeMs: nowMs,
|
|
203
|
+
atime: now,
|
|
204
|
+
mtime: now,
|
|
205
|
+
ctime: now,
|
|
206
|
+
birthtime: now,
|
|
187
207
|
isDirectory: () => true,
|
|
188
208
|
isFile: () => false,
|
|
189
209
|
isSymbolicLink: () => false,
|
|
190
|
-
|
|
191
|
-
|
|
210
|
+
isBlockDevice: () => false,
|
|
211
|
+
isCharacterDevice: () => false,
|
|
212
|
+
isFIFO: () => false,
|
|
213
|
+
isSocket: () => false,
|
|
192
214
|
};
|
|
193
215
|
}
|
|
194
216
|
try {
|
|
195
217
|
const entries = readdirSync(parent, { withFileTypes: true });
|
|
196
218
|
const entry = entries.find((e) => e.name === name);
|
|
197
219
|
if (!entry) {
|
|
198
|
-
|
|
220
|
+
const error = new Error(`ENOENT: no such file or directory, stat '${p}'`);
|
|
221
|
+
// @ts-ignore
|
|
222
|
+
error.code = "ENOENT";
|
|
223
|
+
// @ts-ignore
|
|
224
|
+
error.errno = -2;
|
|
225
|
+
// @ts-ignore
|
|
226
|
+
error.syscall = "stat";
|
|
227
|
+
// @ts-ignore
|
|
228
|
+
error.path = p;
|
|
229
|
+
throw error;
|
|
199
230
|
}
|
|
231
|
+
const now = new Date();
|
|
232
|
+
const nowMs = now.getTime();
|
|
200
233
|
return {
|
|
234
|
+
dev: 0,
|
|
235
|
+
ino: 0,
|
|
236
|
+
mode: entry.isDirectory() ? 16877 : 33188,
|
|
237
|
+
nlink: 1,
|
|
238
|
+
uid: 0,
|
|
239
|
+
gid: 0,
|
|
240
|
+
rdev: 0,
|
|
241
|
+
size: 0,
|
|
242
|
+
blksize: 4096,
|
|
243
|
+
blocks: 0,
|
|
244
|
+
atimeMs: nowMs,
|
|
245
|
+
mtimeMs: nowMs,
|
|
246
|
+
ctimeMs: nowMs,
|
|
247
|
+
birthtimeMs: nowMs,
|
|
248
|
+
atime: now,
|
|
249
|
+
mtime: now,
|
|
250
|
+
ctime: now,
|
|
251
|
+
birthtime: now,
|
|
201
252
|
isDirectory: () => entry.isDirectory(),
|
|
202
253
|
isFile: () => entry.isFile(),
|
|
203
254
|
isSymbolicLink: () => entry.isSymbolicLink(),
|
|
204
|
-
|
|
205
|
-
|
|
255
|
+
isBlockDevice: () => false,
|
|
256
|
+
isCharacterDevice: () => false,
|
|
257
|
+
isFIFO: () => false,
|
|
258
|
+
isSocket: () => false,
|
|
206
259
|
};
|
|
207
260
|
}
|
|
208
261
|
catch (e) {
|
|
@@ -22,7 +22,6 @@ declare const _default: {
|
|
|
22
22
|
readonly "node:domain": any;
|
|
23
23
|
readonly events: any;
|
|
24
24
|
readonly "node:events": any;
|
|
25
|
-
"fast-glob": any;
|
|
26
25
|
readonly http: any;
|
|
27
26
|
readonly "node:http": any;
|
|
28
27
|
readonly http2: any;
|
|
@@ -61,7 +60,6 @@ declare const _default: {
|
|
|
61
60
|
readonly "node:zlib": any;
|
|
62
61
|
fs: typeof fs;
|
|
63
62
|
"node:fs": typeof fs;
|
|
64
|
-
"graceful-fs": typeof fs;
|
|
65
63
|
path: any;
|
|
66
64
|
"node:path": any;
|
|
67
65
|
process: any;
|
|
@@ -7,6 +7,10 @@ process.cwd = () => {
|
|
|
7
7
|
// @ts-ignore
|
|
8
8
|
return ((_a = self.workerData) === null || _a === void 0 ? void 0 : _a.cwd) || (originalCwd === null || originalCwd === void 0 ? void 0 : originalCwd()) || "/";
|
|
9
9
|
};
|
|
10
|
+
if (!process.versions)
|
|
11
|
+
process.versions = {};
|
|
12
|
+
if (!process.versions.node)
|
|
13
|
+
process.versions.node = "24.0.0";
|
|
10
14
|
self.process = process;
|
|
11
15
|
self.global = self;
|
|
12
16
|
const path = require("path");
|
|
@@ -17,7 +21,6 @@ path.resolve = (...args) => {
|
|
|
17
21
|
const cwd = ((_a = self.workerData) === null || _a === void 0 ? void 0 : _a.cwd) || "/";
|
|
18
22
|
return originalResolve(cwd, ...args);
|
|
19
23
|
};
|
|
20
|
-
import fastGlob from "./fastGlobPolyfill";
|
|
21
24
|
import * as fs from "./fsPolyfill";
|
|
22
25
|
import * as workerThreads from "./workerThreadsPolyfill";
|
|
23
26
|
const workerThreadsWithLiveWorkerData = {
|
|
@@ -96,7 +99,6 @@ export default {
|
|
|
96
99
|
get "node:events"() {
|
|
97
100
|
return require("events");
|
|
98
101
|
},
|
|
99
|
-
"fast-glob": fastGlob,
|
|
100
102
|
get http() {
|
|
101
103
|
return require("http");
|
|
102
104
|
},
|
|
@@ -207,7 +209,6 @@ export default {
|
|
|
207
209
|
},
|
|
208
210
|
fs,
|
|
209
211
|
"node:fs": fs,
|
|
210
|
-
"graceful-fs": fs,
|
|
211
212
|
path,
|
|
212
213
|
"node:path": path,
|
|
213
214
|
process,
|
package/package.json
CHANGED
|
@@ -1,103 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", {
|
|
3
|
-
value: true
|
|
4
|
-
});
|
|
5
|
-
exports.default = void 0;
|
|
6
|
-
var _path = _interopRequireDefault(require("path"));
|
|
7
|
-
var _options = _interopRequireDefault(require("./options.json"));
|
|
8
|
-
var _utils = require("./utils");
|
|
9
|
-
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
10
|
-
async function lessLoader(source) {
|
|
11
|
-
const options = this.getOptions(_options.default);
|
|
12
|
-
const callback = this.async();
|
|
13
|
-
let implementation;
|
|
14
|
-
try {
|
|
15
|
-
implementation = (0, _utils.getLessImplementation)(this, options.implementation);
|
|
16
|
-
}
|
|
17
|
-
catch (error) {
|
|
18
|
-
callback(error);
|
|
19
|
-
return;
|
|
20
|
-
}
|
|
21
|
-
if (!implementation) {
|
|
22
|
-
callback(new Error(`The Less implementation "${options.implementation}" not found`));
|
|
23
|
-
return;
|
|
24
|
-
}
|
|
25
|
-
const lessOptions = (0, _utils.getLessOptions)(this, options, implementation);
|
|
26
|
-
const useSourceMap = typeof options.sourceMap === "boolean" ? options.sourceMap : this.sourceMap;
|
|
27
|
-
if (useSourceMap) {
|
|
28
|
-
lessOptions.sourceMap = {
|
|
29
|
-
outputSourceFiles: true
|
|
30
|
-
};
|
|
31
|
-
}
|
|
32
|
-
let data = source;
|
|
33
|
-
if (typeof options.additionalData !== "undefined") {
|
|
34
|
-
data = typeof options.additionalData === "function" ? `${await options.additionalData(data, this)}` : `${options.additionalData}\n${data}`;
|
|
35
|
-
}
|
|
36
|
-
const logger = this.getLogger("less-loader");
|
|
37
|
-
const loaderContext = this;
|
|
38
|
-
const loggerListener = {
|
|
39
|
-
error(message) {
|
|
40
|
-
// TODO enable by default in the next major release
|
|
41
|
-
if (options.lessLogAsWarnOrErr) {
|
|
42
|
-
loaderContext.emitError(new Error(message));
|
|
43
|
-
}
|
|
44
|
-
else {
|
|
45
|
-
logger.error(message);
|
|
46
|
-
}
|
|
47
|
-
},
|
|
48
|
-
warn(message) {
|
|
49
|
-
// TODO enable by default in the next major release
|
|
50
|
-
if (options.lessLogAsWarnOrErr) {
|
|
51
|
-
loaderContext.emitWarning(new Error(message));
|
|
52
|
-
}
|
|
53
|
-
else {
|
|
54
|
-
logger.warn(message);
|
|
55
|
-
}
|
|
56
|
-
},
|
|
57
|
-
info(message) {
|
|
58
|
-
logger.log(message);
|
|
59
|
-
},
|
|
60
|
-
debug(message) {
|
|
61
|
-
logger.debug(message);
|
|
62
|
-
}
|
|
63
|
-
};
|
|
64
|
-
implementation.logger.addListener(loggerListener);
|
|
65
|
-
let result;
|
|
66
|
-
try {
|
|
67
|
-
result = await implementation.render(data, lessOptions);
|
|
68
|
-
}
|
|
69
|
-
catch (error) {
|
|
70
|
-
if (error.filename) {
|
|
71
|
-
// `less` returns forward slashes on windows when `webpack` resolver return an absolute windows path in `WebpackFileManager`
|
|
72
|
-
// Ref: https://github.com/webpack-contrib/less-loader/issues/357
|
|
73
|
-
this.addDependency(_path.default.normalize(error.filename));
|
|
74
|
-
}
|
|
75
|
-
callback((0, _utils.errorFactory)(error));
|
|
76
|
-
return;
|
|
77
|
-
}
|
|
78
|
-
finally {
|
|
79
|
-
// Fix memory leaks in `less`
|
|
80
|
-
implementation.logger.removeListener(loggerListener);
|
|
81
|
-
delete lessOptions.pluginManager.webpackLoaderContext;
|
|
82
|
-
delete lessOptions.pluginManager;
|
|
83
|
-
}
|
|
84
|
-
const { css, imports } = result;
|
|
85
|
-
imports.forEach(item => {
|
|
86
|
-
if ((0, _utils.isUnsupportedUrl)(item)) {
|
|
87
|
-
return;
|
|
88
|
-
}
|
|
89
|
-
// `less` return forward slashes on windows when `webpack` resolver return an absolute windows path in `WebpackFileManager`
|
|
90
|
-
// Ref: https://github.com/webpack-contrib/less-loader/issues/357
|
|
91
|
-
const normalizedItem = _path.default.normalize(item);
|
|
92
|
-
// Custom `importer` can return only `contents` so item will be relative
|
|
93
|
-
if (_path.default.isAbsolute(normalizedItem)) {
|
|
94
|
-
this.addDependency(normalizedItem);
|
|
95
|
-
}
|
|
96
|
-
});
|
|
97
|
-
let map = typeof result.map === "string" ? JSON.parse(result.map) : result.map;
|
|
98
|
-
if (map && useSourceMap) {
|
|
99
|
-
map = (0, _utils.normalizeSourceMap)(map, this.rootContext);
|
|
100
|
-
}
|
|
101
|
-
callback(null, css, map);
|
|
102
|
-
}
|
|
103
|
-
var _default = exports.default = lessLoader;
|