@utoo/web 1.1.0 → 1.2.0-rc.10

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.
Files changed (56) hide show
  1. package/README.md +55 -0
  2. package/esm/a0a815481b4ff49f8961.wasm +0 -0
  3. package/esm/index.d.ts +3 -2
  4. package/esm/index.js +3 -2
  5. package/esm/loaderWorker.js +2 -0
  6. package/esm/loaderWorker.js.LICENSE.txt +23 -0
  7. package/esm/{forkedProject.d.ts → project/ForkedProject.d.ts} +5 -3
  8. package/esm/{forkedProject.js → project/ForkedProject.js} +8 -0
  9. package/esm/{internalProject.d.ts → project/InternalProject.d.ts} +5 -3
  10. package/esm/project/InternalProject.js +132 -0
  11. package/esm/{project.d.ts → project/Project.d.ts} +4 -1
  12. package/esm/{project.js → project/Project.js} +21 -6
  13. package/esm/serviceWorker.js +4 -3
  14. package/esm/{type.d.ts → types.d.ts} +44 -0
  15. package/esm/types.js +56 -0
  16. package/esm/utils/sabcom.d.ts +61 -0
  17. package/esm/utils/sabcom.js +203 -0
  18. package/esm/utoo/index.d.ts +126 -66
  19. package/esm/utoo/index.js +351 -235
  20. package/esm/utoo/index_bg.wasm +0 -0
  21. package/esm/webpackLoaders/cjs.js +299 -0
  22. package/esm/webpackLoaders/loaderWorkerPool.d.ts +2 -0
  23. package/esm/webpackLoaders/loaderWorkerPool.js +90 -0
  24. package/esm/webpackLoaders/polyfills/fsPolyfill.d.ts +78 -0
  25. package/esm/webpackLoaders/polyfills/fsPolyfill.js +279 -0
  26. package/esm/webpackLoaders/polyfills/fsPromisesPolyfill.d.ts +26 -0
  27. package/esm/webpackLoaders/polyfills/fsPromisesPolyfill.js +112 -0
  28. package/esm/webpackLoaders/polyfills/nodePolyFills.d.ts +92 -0
  29. package/esm/webpackLoaders/polyfills/nodePolyFills.js +230 -0
  30. package/esm/webpackLoaders/polyfills/workerThreadsPolyfill.d.ts +7 -0
  31. package/esm/webpackLoaders/polyfills/workerThreadsPolyfill.js +16 -0
  32. package/esm/webpackLoaders/{worker/type.d.ts → types.d.ts} +2 -1
  33. package/esm/webpackLoaders/worker.d.ts +2 -0
  34. package/esm/webpackLoaders/worker.js +46 -0
  35. package/esm/worker.js +2 -2
  36. package/package.json +19 -18
  37. package/esm/internalProject.js +0 -185
  38. package/esm/type.js +0 -12
  39. package/esm/webpackLoaders/loaders/less-loader/index.d.ts +0 -3
  40. package/esm/webpackLoaders/loaders/less-loader/index.js +0 -103
  41. package/esm/webpackLoaders/loaders/less-loader/options.json +0 -67
  42. package/esm/webpackLoaders/loaders/less-loader/utils.d.ts +0 -14
  43. package/esm/webpackLoaders/loaders/less-loader/utils.js +0 -217
  44. package/esm/webpackLoaders/worker/cjs.js +0 -80
  45. package/esm/webpackLoaders/worker/index.d.ts +0 -2
  46. package/esm/webpackLoaders/worker/index.js +0 -31
  47. package/esm/webpackLoaders/worker/nodePolyFills.d.ts +0 -14
  48. package/esm/webpackLoaders/worker/nodePolyFills.js +0 -24
  49. package/esm/webpackLoaders/workerContent.d.ts +0 -2
  50. package/esm/webpackLoaders/workerContent.js +0 -1
  51. /package/esm/{installServiceWorker.d.ts → utils/installServiceWorker.d.ts} +0 -0
  52. /package/esm/{installServiceWorker.js → utils/installServiceWorker.js} +0 -0
  53. /package/esm/{message.d.ts → utils/message.d.ts} +0 -0
  54. /package/esm/{message.js → utils/message.js} +0 -0
  55. /package/esm/webpackLoaders/{worker/cjs.d.ts → cjs.d.ts} +0 -0
  56. /package/esm/webpackLoaders/{worker/type.js → types.js} +0 -0
@@ -0,0 +1,230 @@
1
+ const buffer = require("buffer");
2
+ self.Buffer = buffer.Buffer;
3
+ const process = require("process");
4
+ const originalCwd = process.cwd;
5
+ process.cwd = () => {
6
+ var _a;
7
+ // @ts-ignore
8
+ return ((_a = self.workerData) === null || _a === void 0 ? void 0 : _a.cwd) || (originalCwd === null || originalCwd === void 0 ? void 0 : originalCwd()) || "/";
9
+ };
10
+ if (!process.versions)
11
+ process.versions = {};
12
+ if (!process.versions.node)
13
+ process.versions.node = "24.0.0";
14
+ self.process = process;
15
+ self.global = self;
16
+ const path = require("path");
17
+ const originalResolve = path.resolve;
18
+ path.resolve = (...args) => {
19
+ var _a;
20
+ // @ts-ignore
21
+ const cwd = ((_a = self.workerData) === null || _a === void 0 ? void 0 : _a.cwd) || "/";
22
+ return originalResolve(cwd, ...args);
23
+ };
24
+ import * as fs from "./fsPolyfill";
25
+ import * as workerThreads from "./workerThreadsPolyfill";
26
+ const workerThreadsWithLiveWorkerData = {
27
+ ...workerThreads,
28
+ get workerData() {
29
+ // @ts-ignore
30
+ return self.workerData;
31
+ },
32
+ get threadId() {
33
+ var _a;
34
+ // @ts-ignore
35
+ return ((_a = self.workerData) === null || _a === void 0 ? void 0 : _a.workerId) || 0;
36
+ },
37
+ };
38
+ // Used to directly inject polyfill instance into systemjs
39
+ export default {
40
+ get assert() {
41
+ return require("assert");
42
+ },
43
+ get "node:assert"() {
44
+ return require("assert");
45
+ },
46
+ buffer,
47
+ "node:buffer": buffer,
48
+ get child_process() {
49
+ return require("child_process");
50
+ },
51
+ get "node:child_process"() {
52
+ return require("child_process");
53
+ },
54
+ get cluster() {
55
+ return require("cluster");
56
+ },
57
+ get "node:cluster"() {
58
+ return require("cluster");
59
+ },
60
+ get console() {
61
+ return require("console");
62
+ },
63
+ get "node:console"() {
64
+ return require("console");
65
+ },
66
+ get constants() {
67
+ return require("constants");
68
+ },
69
+ get "node:constants"() {
70
+ return require("constants");
71
+ },
72
+ get crypto() {
73
+ return require("crypto");
74
+ },
75
+ get "node:crypto"() {
76
+ return require("crypto");
77
+ },
78
+ get dgram() {
79
+ return require("dgram");
80
+ },
81
+ get "node:dgram"() {
82
+ return require("dgram");
83
+ },
84
+ get dns() {
85
+ return require("dns");
86
+ },
87
+ get "node:dns"() {
88
+ return require("dns");
89
+ },
90
+ get domain() {
91
+ return require("domain");
92
+ },
93
+ get "node:domain"() {
94
+ return require("domain");
95
+ },
96
+ get events() {
97
+ return require("events");
98
+ },
99
+ get "node:events"() {
100
+ return require("events");
101
+ },
102
+ get http() {
103
+ return require("http");
104
+ },
105
+ get "node:http"() {
106
+ return require("http");
107
+ },
108
+ get http2() {
109
+ return require("http2");
110
+ },
111
+ get "node:http2"() {
112
+ return require("http2");
113
+ },
114
+ get https() {
115
+ return require("https");
116
+ },
117
+ get "node:https"() {
118
+ return require("https");
119
+ },
120
+ get module() {
121
+ return require("module");
122
+ },
123
+ get "node:module"() {
124
+ return require("module");
125
+ },
126
+ get net() {
127
+ return require("net");
128
+ },
129
+ get "node:net"() {
130
+ return require("net");
131
+ },
132
+ get os() {
133
+ return require("os");
134
+ },
135
+ get "node:os"() {
136
+ return require("os");
137
+ },
138
+ get punycode() {
139
+ return require("punycode");
140
+ },
141
+ get "node:punycode"() {
142
+ return require("punycode");
143
+ },
144
+ get querystring() {
145
+ return require("querystring");
146
+ },
147
+ get "node:querystring"() {
148
+ return require("querystring");
149
+ },
150
+ get readline() {
151
+ return require("readline");
152
+ },
153
+ get "node:readline"() {
154
+ return require("readline");
155
+ },
156
+ get repl() {
157
+ return require("repl");
158
+ },
159
+ get "node:repl"() {
160
+ return require("repl");
161
+ },
162
+ get stream() {
163
+ return require("stream");
164
+ },
165
+ get "node:stream"() {
166
+ return require("stream");
167
+ },
168
+ get string_decoder() {
169
+ return require("string_decoder");
170
+ },
171
+ get "node:string_decoder"() {
172
+ return require("string_decoder");
173
+ },
174
+ get sys() {
175
+ return require("util");
176
+ },
177
+ get "node:sys"() {
178
+ return require("util");
179
+ },
180
+ get timers() {
181
+ return require("timers");
182
+ },
183
+ get "node:timers"() {
184
+ return require("timers");
185
+ },
186
+ get tls() {
187
+ return require("tls");
188
+ },
189
+ get "node:tls"() {
190
+ return require("tls");
191
+ },
192
+ get tty() {
193
+ return require("tty");
194
+ },
195
+ get "node:tty"() {
196
+ return require("tty");
197
+ },
198
+ get vm() {
199
+ return require("vm");
200
+ },
201
+ get "node:vm"() {
202
+ return require("vm");
203
+ },
204
+ get zlib() {
205
+ return require("zlib");
206
+ },
207
+ get "node:zlib"() {
208
+ return require("zlib");
209
+ },
210
+ fs,
211
+ "node:fs": fs,
212
+ path,
213
+ "node:path": path,
214
+ process,
215
+ "node:process": process,
216
+ get url() {
217
+ return require("url");
218
+ },
219
+ get "node:url"() {
220
+ return require("url");
221
+ },
222
+ get util() {
223
+ return require("util");
224
+ },
225
+ get "node:util"() {
226
+ return require("util");
227
+ },
228
+ worker_threads: workerThreadsWithLiveWorkerData,
229
+ "node:worker_threads": workerThreadsWithLiveWorkerData,
230
+ };
@@ -0,0 +1,7 @@
1
+ export declare const workerData: any;
2
+ export declare const isMainThread = false;
3
+ export declare const parentPort: {
4
+ postMessage: (message: any) => void;
5
+ on: (event: string, listener: (...args: any[]) => void) => void;
6
+ off: (event: string, listener: (...args: any[]) => void) => void;
7
+ };
@@ -0,0 +1,16 @@
1
+ // @ts-ignore
2
+ export const workerData = self.workerData;
3
+ export const isMainThread = false;
4
+ export const parentPort = {
5
+ postMessage: (message) => self.postMessage(message),
6
+ on: (event, listener) => {
7
+ if (event === "message") {
8
+ self.onmessage = (e) => listener(e.data);
9
+ }
10
+ },
11
+ off: (event, listener) => {
12
+ if (event === "message") {
13
+ self.onmessage = null;
14
+ }
15
+ },
16
+ };
@@ -1,11 +1,12 @@
1
1
  export interface LoaderRunnerMeta {
2
2
  workerData: {
3
- poolId: string;
4
3
  workerId: number;
5
4
  cwd: string;
5
+ projectRoot: string;
6
6
  };
7
7
  loaderAssets: {
8
8
  importMaps: Record<string, string>;
9
9
  entrypoint: string;
10
10
  };
11
+ sab?: SharedArrayBuffer;
11
12
  }
@@ -0,0 +1,2 @@
1
+ export declare function startLoaderWorker(): void;
2
+ export default startLoaderWorker;
@@ -0,0 +1,46 @@
1
+ import { SabComClient } from "../utils/sabcom";
2
+ import initWasm, { Project, recvTaskMessageInWorker, sendTaskMessage, workerCreated, } from "../utoo";
3
+ import { cjs } from "./cjs";
4
+ const binding = {
5
+ recvTaskMessageInWorker,
6
+ sendTaskMessage,
7
+ workerCreated,
8
+ };
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
+ // Initialize the thread-local state (tokio runtime).
22
+ // We don't need to pass threadWorkerUrl here because it's already stored in a global static in Rust.
23
+ Project.init("");
24
+ Project.setCwd(meta.workerData.cwd);
25
+ self.workerData = {
26
+ workerId: meta.workerData.workerId,
27
+ cwd: meta.workerData.cwd,
28
+ projectRoot: meta.workerData.projectRoot,
29
+ binding,
30
+ sabClient,
31
+ fs: Project,
32
+ };
33
+ self.process = {
34
+ env: {},
35
+ cwd: () => self.workerData.cwd,
36
+ };
37
+ cjs(meta.loaderAssets.entrypoint, meta.loaderAssets.importMaps);
38
+ };
39
+ }
40
+ // @ts-ignore
41
+ if (typeof __webpack_require__ !== "undefined") {
42
+ // @ts-ignore
43
+ self.startLoaderWorker = startLoaderWorker;
44
+ }
45
+ startLoaderWorker();
46
+ export default startLoaderWorker;
package/esm/worker.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import * as comlink from "comlink";
2
- import { internalEndpoint } from "./internalProject";
3
- import { HandShake } from "./message";
2
+ import { internalEndpoint } from "./project/InternalProject";
3
+ import { HandShake } from "./utils/message";
4
4
  const ConnectedPorts = new Set();
5
5
  self.addEventListener("message", (e) => {
6
6
  const port = e.ports[0];
package/package.json CHANGED
@@ -1,42 +1,43 @@
1
1
  {
2
2
  "name": "@utoo/web",
3
- "version": "1.1.0",
3
+ "version": "1.2.0-rc.10",
4
4
  "module": "esm/index.js",
5
5
  "types": "esm/index.d.ts",
6
6
  "files": [
7
- "esm/*"
7
+ "esm"
8
8
  ],
9
9
  "scripts": {
10
- "install-toolchain": "cargo install wasm-bindgen-cli@0.2.104 && brew install binaryen",
10
+ "install-toolchain": "cargo install wasm-bindgen-cli@0.2.104 && brew install binaryen llvm",
11
11
  "build-wasm": "cargo build -p utoo-wasm --target wasm32-unknown-unknown -Z build-std=panic_abort,std",
12
12
  "build-wasm:pm": "cargo build -p utoo-wasm --target wasm32-unknown-unknown --no-default-features -Z build-std=panic_abort,std",
13
13
  "bindgen-dev": "wasm-bindgen ../../target/wasm32-unknown-unknown/wasm-dev/utoo_wasm.wasm --out-dir src/utoo --out-name index --target web --debug --keep-debug --no-demangle",
14
14
  "bindgen-build": "wasm-bindgen ../../target/wasm32-unknown-unknown/release/utoo_wasm.wasm --out-dir src/utoo --out-name index --target web",
15
15
  "bindgen-build:local": "wasm-bindgen ../../target/wasm32-unknown-unknown/release-local/utoo_wasm.wasm --out-dir src/utoo --out-name index --target web",
16
- "pretsc": "npm run build --workspace @utoo/pack-shared",
17
- "tsc": "rm -rf esm && tsc -p ./tsconfig.json",
18
- "dev": "npm run build-wasm -- --profile wasm-dev && npm run bindgen-dev && npm run tsc && cp src/utoo/index_bg.wasm esm/utoo",
19
- "dev:pm": "npm run build-wasm:pm -- --profile wasm-dev && npm run bindgen-dev && npm run tsc && cp src/utoo/index_bg.wasm esm/utoo",
16
+ "tsc": "rm -rf esm && tsc -p ./tsconfig.build.json",
17
+ "copy-wasm": "cp src/utoo/index_bg.wasm esm/utoo",
18
+ "build:shared": "npx turbo run build --filter=@utoo/pack-shared",
19
+ "dev": "npm run build-wasm -- --profile wasm-dev && npm run bindgen-dev && npx turbo run tsc --filter=@utoo/web && npm run build-loaderWorker && npm run copy-wasm",
20
+ "dev:pm": "npm run build-wasm:pm -- --profile wasm-dev && npm run bindgen-dev && npm run tsc && npm run copy-wasm",
20
21
  "wasm-opt": "wasm-opt src/utoo/index_bg.wasm -o esm/utoo/index_bg.wasm --enable-threads --enable-bulk-memory --enable-nontrapping-float-to-int -Oz",
21
- "build": "npm run build-wasm -- --release && npm run bindgen-build && npm run build-loaderWorker && npm run tsc && npm run wasm-opt",
22
- "build:local": "npm run build-wasm -- --profile release-local && npm run bindgen-build:local && npm run build-loaderWorker && npm run tsc && cp src/utoo/index_bg.wasm esm/utoo",
23
- "build-loaderWorker": "node cli/umd.js -e ./src/webpackLoaders/worker/index.ts -o ./src/webpackLoaders/workerContent.js -t webworker --se true",
24
- "prepublishOnly": "npm run build"
22
+ "build": "npm run build-wasm -- --release && npm run bindgen-build && npm run tsc && npm run build-loaderWorker && npm run wasm-opt",
23
+ "build:local": "CC=$(brew --prefix llvm)/bin/clang CXX=$(brew --prefix llvm)/bin/clang++ npm run build-wasm -- --profile release-local && npm run bindgen-build:local && npm run build:shared && npm run tsc && npm run build-loaderWorker && npm run copy-wasm",
24
+ "build-loaderWorker": "node cli/umd.js -e ./src/webpackLoaders/worker.ts -o ./esm/loaderWorker.js -t webworker",
25
+ "clean": "rm -rf esm src/utoo",
26
+ "prepublishOnly": "turbo run build --filter=@utoo/web"
25
27
  },
26
28
  "dependencies": {
29
+ "@utoo/pack-shared": "^0.0.8",
27
30
  "comlink": "^4.4.2",
28
- "systemjs": "^6.15.1",
29
- "loader-runner": "^4.3.0",
30
- "less": "^4.0.0",
31
- "@utoo/pack-shared": "^0.0.7"
31
+ "systemjs": "^6.15.1"
32
32
  },
33
33
  "devDependencies": {
34
- "typescript": "^5.8.3",
35
34
  "@types/systemjs": "^6.15.1",
36
- "webpack": "^5.0.0",
37
- "webpack-merge": "^6.0.1",
35
+ "binaryen": "^125.0.0",
38
36
  "node-stdlib-browser": "^1.3.1",
39
37
  "ts-loader": "^9.5.2",
38
+ "typescript": "^5.8.3",
39
+ "webpack": "^5.0.0",
40
+ "webpack-merge": "^6.0.1",
40
41
  "yargs": "^18.0.0"
41
42
  },
42
43
  "engines": {
@@ -1,185 +0,0 @@
1
- import initWasm, { init_log_filter, Project as ProjectInternal, recvPoolRequest, recvWorkerTermination, } from "./utoo";
2
- // @ts-ignore
3
- import webpackLoadersCode from "./webpackLoaders/workerContent";
4
- let nextWorkerId = 0;
5
- const loaderWorkers = {};
6
- async function getTurbopackLoaderAssets() {
7
- const turbopackLoaderAssets = {};
8
- const dirEntries = await internalEndpoint.projectInternal.readDir(".turbopack");
9
- await Promise.all(dirEntries.map(async (entry) => {
10
- // only collect .js files
11
- if (entry.type === "file" && entry.name.endsWith(".js")) {
12
- turbopackLoaderAssets[`./${entry.name}`] =
13
- await internalEndpoint.projectInternal.readToString(`.turbopack/${entry.name}`);
14
- }
15
- }));
16
- return turbopackLoaderAssets;
17
- }
18
- const createOrScalePool = async (binding, loadersImportMap) => {
19
- while (true) {
20
- try {
21
- let poolOptions = await recvPoolRequest();
22
- const { filename: entrypoint, maxConcurrency } = poolOptions;
23
- const concurrency = Math.max(maxConcurrency, navigator.hardwareConcurrency);
24
- const workers = loaderWorkers[entrypoint] || (loaderWorkers[entrypoint] = []);
25
- if (workers.length < concurrency) {
26
- for (let i = workers.length; i < concurrency; i++) {
27
- nextWorkerId += 1;
28
- const turbopackLoaderAssets = await getTurbopackLoaderAssets();
29
- const blob = new Blob([webpackLoadersCode], {
30
- type: "text/javascript",
31
- });
32
- const workerUrl = URL.createObjectURL(blob);
33
- const worker = new Worker(workerUrl);
34
- worker.postMessage([
35
- // @ts-ignore
36
- initWasm.__wbindgen_wasm_module,
37
- binding.memory,
38
- {
39
- workerData: {
40
- poolId: entrypoint,
41
- workerId: nextWorkerId,
42
- },
43
- loaderAssets: {
44
- importMaps: { ...turbopackLoaderAssets, ...loadersImportMap },
45
- entrypoint: entrypoint.replace(".turbopack/", ""),
46
- },
47
- },
48
- ]);
49
- // @ts-ignore
50
- worker.workerId = nextWorkerId;
51
- // @ts-ignore
52
- workers.push(worker);
53
- }
54
- }
55
- else if (workers.length > concurrency) {
56
- const workersToStop = workers.splice(0, workers.length - concurrency);
57
- workersToStop.forEach((worker) => worker.terminate());
58
- }
59
- }
60
- catch (_e) {
61
- // rust channel closed. do nothing
62
- return;
63
- }
64
- }
65
- };
66
- const waitingForWorkerTermination = async () => {
67
- while (true) {
68
- try {
69
- const { filename, workerId } = await recvWorkerTermination();
70
- const workers = loaderWorkers[filename];
71
- const workerIdx = workers.findIndex((worker) => worker.workerId === workerId);
72
- if (workerIdx > -1) {
73
- const worker = workers.splice(workerIdx, 1);
74
- worker[0].terminate();
75
- }
76
- }
77
- catch (_e) {
78
- // rust channel closed. do nothing
79
- return;
80
- }
81
- }
82
- };
83
- class InternalEndpoint {
84
- // This should be called only once
85
- async mount(opt) {
86
- var _a;
87
- this.options = opt;
88
- const { cwd, wasmUrl, threadWorkerUrl, logFilter } = opt;
89
- (_a = this.wasmInit) !== null && _a !== void 0 ? _a : (this.wasmInit = initWasm(wasmUrl));
90
- await this.wasmInit;
91
- // Initialize log filter after wasm init
92
- const filter = logFilter || "pack_core=info,pack_api=info,utoo_wasm=info";
93
- init_log_filter(filter);
94
- this.projectInternal = new ProjectInternal(cwd, threadWorkerUrl);
95
- return;
96
- }
97
- async install(packageLock, maxConcurrentDownloads) {
98
- await this.wasmInit;
99
- await this.projectInternal.install(packageLock, maxConcurrentDownloads);
100
- return;
101
- }
102
- async build() {
103
- var _a;
104
- const binding = await this.wasmInit;
105
- createOrScalePool(binding, (_a = this.options) === null || _a === void 0 ? void 0 : _a.loadersImportMap);
106
- waitingForWorkerTermination();
107
- return await this.projectInternal.build();
108
- }
109
- async readFile(path, encoding) {
110
- await this.wasmInit;
111
- let ret;
112
- if (encoding === "utf8") {
113
- ret = await this.projectInternal.readToString(path);
114
- }
115
- else {
116
- ret = await this.projectInternal.read(path);
117
- }
118
- return ret;
119
- }
120
- async writeFile(path, content, _encoding) {
121
- await this.wasmInit;
122
- if (typeof content === "string") {
123
- return await this.projectInternal.writeString(path, content);
124
- }
125
- else {
126
- return await this.projectInternal.write(path, content);
127
- }
128
- }
129
- async copyFile(src, dst) {
130
- await this.wasmInit;
131
- return await this.projectInternal.copyFile(src, dst);
132
- }
133
- async readdir(path, options) {
134
- await this.wasmInit;
135
- const dirEntries = (options === null || options === void 0 ? void 0 : options.recursive)
136
- ? await this.projectInternal.readDir(path)
137
- : // TODO: support recursive readDirAll
138
- await this.projectInternal.readDir(path);
139
- const rawDirents = dirEntries.map((e) => {
140
- const dir = e.toJSON();
141
- return {
142
- name: dir.name,
143
- type: dir.type,
144
- };
145
- });
146
- // WARN: This is a hack, functions can not be structurally cloned
147
- return rawDirents;
148
- }
149
- async mkdir(path, options) {
150
- await this.wasmInit;
151
- if (options === null || options === void 0 ? void 0 : options.recursive) {
152
- return await this.projectInternal.createDirAll(path);
153
- }
154
- else {
155
- return await this.projectInternal.createDir(path);
156
- }
157
- }
158
- async rm(path, options) {
159
- await this.wasmInit;
160
- let metadata = (await this.projectInternal.metadata(path)).toJSON();
161
- switch (metadata.type) {
162
- case "file":
163
- return await this.projectInternal.removeFile(path);
164
- case "directory":
165
- return await this.projectInternal.removeDir(path, !!(options === null || options === void 0 ? void 0 : options.recursive));
166
- default:
167
- // nothing to remove now
168
- break;
169
- }
170
- }
171
- async rmdir(path, options) {
172
- await this.wasmInit;
173
- return await this.projectInternal.removeDir(path, !!(options === null || options === void 0 ? void 0 : options.recursive));
174
- }
175
- async gzip(files) {
176
- await this.wasmInit;
177
- return await this.projectInternal.gzip(files);
178
- }
179
- async sigMd5(content) {
180
- await this.wasmInit;
181
- return await this.projectInternal.sigMd5(content);
182
- }
183
- }
184
- const internalEndpoint = new InternalEndpoint();
185
- export { internalEndpoint };
package/esm/type.js DELETED
@@ -1,12 +0,0 @@
1
- export class Dirent {
2
- constructor(rawDirent) {
3
- this.rawDirent = rawDirent;
4
- this.name = this.rawDirent.name;
5
- }
6
- isDirectory() {
7
- return this.rawDirent.type === "directory";
8
- }
9
- isFile() {
10
- return this.rawDirent.type === "file";
11
- }
12
- }
@@ -1,3 +0,0 @@
1
- export const __esModule: boolean;
2
- export default lessLoader;
3
- declare function lessLoader(source: any): Promise<void>;