@utoo/web 0.0.1-alpha.3 → 0.0.1-alpha.31

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.
@@ -0,0 +1,22 @@
1
+ import { ProjectEndpoint } from "./type";
2
+ export declare class ForkedProject implements ProjectEndpoint {
3
+ private endpoint;
4
+ constructor(port: MessagePort);
5
+ install(packageLock: string): Promise<void>;
6
+ build(): Promise<import("./type").BuildOutput>;
7
+ readFile(path: string, encoding?: "utf8"): Promise<any>;
8
+ writeFile(path: string, content: string | Uint8Array, encoding?: "utf8"): Promise<void>;
9
+ copyFile(src: string, dst: string): Promise<void>;
10
+ readdir(path: string, options?: {
11
+ recursive?: boolean;
12
+ }): Promise<import("./type").Dirent[]>;
13
+ mkdir(path: string, options?: {
14
+ recursive?: boolean;
15
+ }): Promise<void>;
16
+ rm(path: string, options?: {
17
+ recursive?: boolean;
18
+ }): Promise<void>;
19
+ rmdir(path: string, options?: {
20
+ recursive?: boolean;
21
+ }): Promise<void>;
22
+ }
@@ -0,0 +1,34 @@
1
+ import * as comlink from "comlink";
2
+ export class ForkedProject {
3
+ constructor(port) {
4
+ var _a;
5
+ (_a = this.endpoint) !== null && _a !== void 0 ? _a : (this.endpoint = comlink.wrap(port));
6
+ }
7
+ async install(packageLock) {
8
+ return await this.endpoint.install(packageLock);
9
+ }
10
+ async build() {
11
+ return await this.endpoint.build();
12
+ }
13
+ async readFile(path, encoding) {
14
+ return (await this.endpoint.readFile(path, encoding));
15
+ }
16
+ async writeFile(path, content, encoding) {
17
+ return await this.endpoint.writeFile(path, content, encoding);
18
+ }
19
+ async copyFile(src, dst) {
20
+ return await this.endpoint.copyFile(src, dst);
21
+ }
22
+ async readdir(path, options) {
23
+ return await this.endpoint.readdir(path, options);
24
+ }
25
+ async mkdir(path, options) {
26
+ return await this.endpoint.mkdir(path, options);
27
+ }
28
+ async rm(path, options) {
29
+ return await this.endpoint.rm(path, options);
30
+ }
31
+ async rmdir(path, options) {
32
+ return await this.endpoint.rmdir(path, options);
33
+ }
34
+ }
package/esm/index.d.ts CHANGED
@@ -1,17 +1,2 @@
1
- import { ProjectEndpoint, DirEntry } from "./type";
2
- export declare class Project implements ProjectEndpoint {
3
- #private;
4
- private cwd;
5
- private remote;
6
- constructor(cwd: string);
7
- install(packageLock: string): Promise<void>;
8
- build(): Promise<void>;
9
- readFile(path: string): Promise<string>;
10
- writeFile(path: string, content: string): Promise<void>;
11
- copyFile(src: string, dst: string): Promise<void>;
12
- readDir(path: string): Promise<DirEntry[]>;
13
- createDir(path: string): Promise<void>;
14
- createDirAll(path: string): Promise<void>;
15
- static fork(port1: MessagePort, port2: MessagePort): ProjectEndpoint;
16
- }
1
+ export { Project } from "./project";
17
2
  export * from "./type";
package/esm/index.js CHANGED
@@ -1,105 +1,2 @@
1
- var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
2
- if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
3
- if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
4
- return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
5
- };
6
- var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
7
- if (kind === "m") throw new TypeError("Private method is not writable");
8
- if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
9
- if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
10
- return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
11
- };
12
- var _Project_tunnel;
13
- import * as comlink from "comlink";
14
- import { Fork, HandShake } from "./message";
15
- let ProjectWorker;
16
- const ConnectedPorts = new Set();
17
- export class Project {
18
- constructor(cwd) {
19
- var _a, _b;
20
- _Project_tunnel.set(this, void 0);
21
- this.cwd = cwd;
22
- const { port1, port2 } = new MessageChannel();
23
- (_a = this.remote) !== null && _a !== void 0 ? _a : (this.remote = comlink.wrap(port1));
24
- if (!ProjectWorker) {
25
- ProjectWorker = new Worker(new URL("./worker", import.meta.url));
26
- self.addEventListener("message", (e) => {
27
- const port = e.ports[0];
28
- if (e.data === Fork && !ConnectedPorts.has(port)) {
29
- ProjectWorker.postMessage(HandShake, [port]);
30
- }
31
- });
32
- }
33
- ProjectWorker.postMessage(HandShake, [port2]);
34
- __classPrivateFieldSet(this, _Project_tunnel, (_b = __classPrivateFieldGet(this, _Project_tunnel, "f")) !== null && _b !== void 0 ? _b : this.remote.mount(this.cwd), "f");
35
- }
36
- async install(packageLock) {
37
- await __classPrivateFieldGet(this, _Project_tunnel, "f");
38
- return await this.remote.install(packageLock);
39
- }
40
- async build() {
41
- await __classPrivateFieldGet(this, _Project_tunnel, "f");
42
- return await this.remote.build();
43
- }
44
- async readFile(path) {
45
- await __classPrivateFieldGet(this, _Project_tunnel, "f");
46
- return await this.remote.readFile(path);
47
- }
48
- async writeFile(path, content) {
49
- await __classPrivateFieldGet(this, _Project_tunnel, "f");
50
- return await this.remote.writeFile(path, content);
51
- }
52
- async copyFile(src, dst) {
53
- await __classPrivateFieldGet(this, _Project_tunnel, "f");
54
- return await this.remote.copyFile(src, dst);
55
- }
56
- async readDir(path) {
57
- await __classPrivateFieldGet(this, _Project_tunnel, "f");
58
- return await this.remote.readDir(path);
59
- }
60
- async createDir(path) {
61
- await __classPrivateFieldGet(this, _Project_tunnel, "f");
62
- return await this.remote.createDir(path);
63
- }
64
- async createDirAll(path) {
65
- await __classPrivateFieldGet(this, _Project_tunnel, "f");
66
- return await this.remote.createDirAll(path);
67
- }
68
- // This should be called from different worker
69
- static fork(port1, port2) {
70
- self.postMessage(Fork, [port2]);
71
- return new ForkedProject(port1);
72
- }
73
- }
74
- _Project_tunnel = new WeakMap();
75
- class ForkedProject {
76
- constructor(port) {
77
- var _a;
78
- (_a = this.endpoint) !== null && _a !== void 0 ? _a : (this.endpoint = comlink.wrap(port));
79
- }
80
- async install(packageLock) {
81
- return await this.endpoint.install(packageLock);
82
- }
83
- async build() {
84
- return await this.endpoint.build();
85
- }
86
- async readFile(path) {
87
- return await this.endpoint.readFile(path);
88
- }
89
- async writeFile(path, content) {
90
- return await this.endpoint.writeFile(path, content);
91
- }
92
- async copyFile(src, dst) {
93
- return await this.endpoint.copyFile(src, dst);
94
- }
95
- async readDir(path) {
96
- return await this.endpoint.readDir(path);
97
- }
98
- async createDir(path) {
99
- return await this.endpoint.createDir(path);
100
- }
101
- async createDirAll(path) {
102
- return await this.endpoint.createDirAll(path);
103
- }
104
- }
1
+ export { Project } from "./project";
105
2
  export * from "./type";
@@ -0,0 +1 @@
1
+ export declare function installServiceWorker(url: string, scope: string): Promise<void>;
@@ -0,0 +1,36 @@
1
+ import { ServiceWorkerHandShake } from "./message";
2
+ export async function installServiceWorker(url, scope) {
3
+ const registration = await navigator.serviceWorker.register(url, {
4
+ scope: "/",
5
+ });
6
+ return new Promise((resolve) => {
7
+ function sendMessage(sw) {
8
+ sw.postMessage({
9
+ [ServiceWorkerHandShake]: true,
10
+ scope,
11
+ });
12
+ resolve();
13
+ }
14
+ function listenForActivation(sw) {
15
+ sw.addEventListener("statechange", () => {
16
+ if (sw.state === "activated") {
17
+ sendMessage(sw);
18
+ }
19
+ });
20
+ }
21
+ function checkSWState(registration) {
22
+ if (registration.active) {
23
+ sendMessage(registration.active);
24
+ }
25
+ else if (registration.installing) {
26
+ listenForActivation(registration.installing);
27
+ }
28
+ registration.addEventListener("updatefound", () => {
29
+ if (registration.installing) {
30
+ listenForActivation(registration.installing);
31
+ }
32
+ });
33
+ }
34
+ checkSWState(registration);
35
+ });
36
+ }
package/esm/message.d.ts CHANGED
@@ -1,2 +1,3 @@
1
1
  export declare const HandShake = "__handshake__";
2
+ export declare const ServiceWorkerHandShake = "__service_worker_handshake__";
2
3
  export declare const Fork = "__fork__";
package/esm/message.js CHANGED
@@ -1,2 +1,3 @@
1
1
  export const HandShake = "__handshake__";
2
+ export const ServiceWorkerHandShake = "__service_worker_handshake__";
2
3
  export const Fork = "__fork__";
@@ -0,0 +1,28 @@
1
+ import { BuildOutput, Dirent, ProjectEndpoint, ProjectOptions } from "./type";
2
+ export declare class Project implements ProjectEndpoint {
3
+ #private;
4
+ private serviceWorkerOptions?;
5
+ private remote;
6
+ constructor(options: ProjectOptions);
7
+ private connectWorker;
8
+ installServiceWorker(): Promise<void>;
9
+ mount(): Promise<void>;
10
+ install(packageLock: string): Promise<void>;
11
+ build(): Promise<BuildOutput>;
12
+ readFile(path: string, encoding?: "utf8"): Promise<any>;
13
+ writeFile(path: string, content: string | Uint8Array, encoding?: "utf8"): Promise<void>;
14
+ copyFile(src: string, dst: string): Promise<void>;
15
+ readdir(path: string, options?: {
16
+ recursive?: boolean;
17
+ }): Promise<Dirent[]>;
18
+ mkdir(path: string, options?: {
19
+ recursive?: boolean;
20
+ }): Promise<void>;
21
+ rm(path: string, options?: {
22
+ recursive?: boolean;
23
+ }): Promise<void>;
24
+ rmdir(path: string, options?: {
25
+ recursive?: boolean;
26
+ }): Promise<void>;
27
+ static fork(channel: MessageChannel, eventSource?: Client | DedicatedWorkerGlobalScope): ProjectEndpoint;
28
+ }
package/esm/project.js ADDED
@@ -0,0 +1,111 @@
1
+ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
2
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
3
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
4
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
5
+ };
6
+ var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
7
+ if (kind === "m") throw new TypeError("Private method is not writable");
8
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
9
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
10
+ return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
11
+ };
12
+ var _Project_mount;
13
+ import { handleIssues } from "@utoo/pack-shared";
14
+ import * as comlink from "comlink";
15
+ import { ForkedProject } from "./forkedProject";
16
+ import { installServiceWorker } from "./installServiceWorker";
17
+ import { Fork, HandShake } from "./message";
18
+ import { Dirent, } from "./type";
19
+ let ProjectWorker;
20
+ const ConnectedPorts = new Set();
21
+ export class Project {
22
+ constructor(options) {
23
+ var _a, _b;
24
+ _Project_mount.set(this, void 0);
25
+ const { cwd, workerUrl, wasmUrl, threadWorkerUrl, serviceWorker } = options;
26
+ this.serviceWorkerOptions = serviceWorker;
27
+ const { port1, port2 } = new MessageChannel();
28
+ (_a = this.remote) !== null && _a !== void 0 ? _a : (this.remote = comlink.wrap(port1));
29
+ if (!ProjectWorker) {
30
+ ProjectWorker = workerUrl
31
+ ? new Worker(workerUrl)
32
+ : new Worker(new URL("./worker", import.meta.url));
33
+ window.addEventListener("message", (e) => {
34
+ this.connectWorker(e);
35
+ });
36
+ if (this.serviceWorkerOptions) {
37
+ navigator.serviceWorker.addEventListener("message", (e) => {
38
+ this.connectWorker(e);
39
+ });
40
+ }
41
+ }
42
+ ProjectWorker.postMessage(HandShake, [port2]);
43
+ __classPrivateFieldSet(this, _Project_mount, (_b = __classPrivateFieldGet(this, _Project_mount, "f")) !== null && _b !== void 0 ? _b : this.remote.mount({
44
+ cwd,
45
+ wasmUrl,
46
+ threadWorkerUrl,
47
+ }), "f");
48
+ }
49
+ connectWorker(e) {
50
+ const port = e.ports[0];
51
+ if (e.data === Fork && !ConnectedPorts.has(port)) {
52
+ ProjectWorker.postMessage(HandShake, [port]);
53
+ }
54
+ }
55
+ async installServiceWorker() {
56
+ if (this.serviceWorkerOptions) {
57
+ const { url, scope } = this.serviceWorkerOptions;
58
+ // Should add "Service-Worker-Allowed": "/" in page root response headers,
59
+ return await installServiceWorker(url, scope);
60
+ }
61
+ }
62
+ async mount() {
63
+ return await __classPrivateFieldGet(this, _Project_mount, "f");
64
+ }
65
+ async install(packageLock) {
66
+ await __classPrivateFieldGet(this, _Project_mount, "f");
67
+ return await this.remote.install(packageLock);
68
+ }
69
+ async build() {
70
+ await __classPrivateFieldGet(this, _Project_mount, "f");
71
+ const res = await this.remote.build();
72
+ handleIssues(res.issues, false, false);
73
+ return res;
74
+ }
75
+ async readFile(path, encoding) {
76
+ await __classPrivateFieldGet(this, _Project_mount, "f");
77
+ return (await this.remote.readFile(path, encoding));
78
+ }
79
+ async writeFile(path, content, encoding) {
80
+ await __classPrivateFieldGet(this, _Project_mount, "f");
81
+ return await this.remote.writeFile(path, content, encoding);
82
+ }
83
+ async copyFile(src, dst) {
84
+ await __classPrivateFieldGet(this, _Project_mount, "f");
85
+ return await this.remote.copyFile(src, dst);
86
+ }
87
+ async readdir(path, options) {
88
+ await __classPrivateFieldGet(this, _Project_mount, "f");
89
+ const dirEntry = (await this.remote.readdir(path, options));
90
+ return dirEntry.map((e) => new Dirent(e));
91
+ }
92
+ async mkdir(path, options) {
93
+ await __classPrivateFieldGet(this, _Project_mount, "f");
94
+ return await this.remote.mkdir(path, options);
95
+ }
96
+ async rm(path, options) {
97
+ await __classPrivateFieldGet(this, _Project_mount, "f");
98
+ return await this.remote.rm(path, options);
99
+ }
100
+ async rmdir(path, options) {
101
+ await __classPrivateFieldGet(this, _Project_mount, "f");
102
+ return await this.remote.rmdir(path, options);
103
+ }
104
+ static fork(channel, eventSource) {
105
+ (eventSource || self).postMessage(Fork, {
106
+ transfer: [channel.port2],
107
+ });
108
+ return new ForkedProject(channel.port1);
109
+ }
110
+ }
111
+ _Project_mount = new WeakMap();
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,56 @@
1
+ import { Project } from ".";
2
+ import { ServiceWorkerHandShake } from "./message";
3
+ let _resolve;
4
+ let _promise = new Promise((resolve) => {
5
+ _resolve = resolve;
6
+ });
7
+ let _projectEndpoint;
8
+ let _serviceWorkerScope;
9
+ self.addEventListener("message", (event) => {
10
+ if (event.data && event.data[ServiceWorkerHandShake] === true) {
11
+ _serviceWorkerScope = event.data.scope;
12
+ _projectEndpoint = Project.fork(new MessageChannel(), event.source);
13
+ _resolve();
14
+ }
15
+ });
16
+ self.addEventListener("fetch", async (event) => {
17
+ await _promise;
18
+ const { url, referrer } = event.request;
19
+ if (new URL(url).pathname.startsWith(_serviceWorkerScope) ||
20
+ (referrer && new URL(referrer).pathname.startsWith(_serviceWorkerScope))) {
21
+ const projectPath = "." + new URL(url).pathname.replace(_serviceWorkerScope, "");
22
+ event.respondWith(readFileFromProject(projectPath));
23
+ }
24
+ else {
25
+ event.respondWith(fetch(event.request));
26
+ }
27
+ });
28
+ async function readFileFromProject(projectPath) {
29
+ try {
30
+ const content = await _projectEndpoint.readFile(projectPath);
31
+ let mimeType = "application/octet-stream";
32
+ if (projectPath.endsWith(".js")) {
33
+ mimeType = "application/javascript";
34
+ }
35
+ else if (projectPath.endsWith(".css")) {
36
+ mimeType = "text/css";
37
+ }
38
+ else if (projectPath.endsWith(".html")) {
39
+ mimeType = "text/html";
40
+ }
41
+ else if (projectPath.endsWith(".json")) {
42
+ mimeType = "application/json";
43
+ }
44
+ return new Response(content, {
45
+ headers: {
46
+ "Content-Type": mimeType,
47
+ ...(mimeType === "text/html"
48
+ ? { "Cross-Origin-Embedder-Policy": "require-corp" }
49
+ : {}),
50
+ },
51
+ });
52
+ }
53
+ catch (e) {
54
+ return new Response("Not Found", { status: 404 });
55
+ }
56
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,4 @@
1
+ import initWasm from "./utoo";
2
+ // this is for wasm_thread to spawn new worker thread.
3
+ // see: https://github.com/utooland/wasm_thread/blob/94438ff771ee0a6a55d79e49a655707970acb615/src/wasm32/js/web_worker.js#L10
4
+ self.wasm_bindgen = initWasm;
package/esm/type.d.ts CHANGED
@@ -1,15 +1,47 @@
1
- import type { DirEntryType } from "./utoo";
2
- export interface DirEntry {
1
+ import { Issue } from "@utoo/pack-shared";
2
+ import { DirEntryType } from "./utoo";
3
+ export interface RawDirent {
3
4
  name: string;
4
5
  type: DirEntryType;
5
6
  }
7
+ export declare class Dirent {
8
+ private rawDirent;
9
+ name: string;
10
+ constructor(rawDirent: RawDirent);
11
+ isDirectory(): boolean;
12
+ isFile(): boolean;
13
+ }
14
+ export interface BuildOutput {
15
+ issues: Issue[];
16
+ }
6
17
  export interface ProjectEndpoint {
7
18
  install: (packageLock: string) => Promise<void>;
8
- build: () => Promise<void>;
9
- readFile(path: string): Promise<string>;
10
- writeFile(path: string, content: string): Promise<void>;
11
- readDir(path: string): Promise<DirEntry[]>;
12
- createDir(path: string): Promise<void>;
13
- createDirAll(path: string): Promise<void>;
19
+ build: () => Promise<BuildOutput>;
20
+ readFile(path: string): Promise<Uint8Array>;
21
+ readFile(path: string, encoding?: "utf8"): Promise<string>;
22
+ writeFile(path: string, content: string | Uint8Array, encoding?: "utf8"): Promise<void>;
23
+ readdir(path: string, options?: {
24
+ recursive?: boolean;
25
+ }): Promise<Dirent[]>;
26
+ mkdir(path: string, options?: {
27
+ recursive?: boolean;
28
+ }): Promise<void>;
29
+ rm(path: string, options?: {
30
+ recursive?: boolean;
31
+ }): Promise<void>;
32
+ rmdir(path: string, options?: {
33
+ recursive?: boolean;
34
+ }): Promise<void>;
14
35
  copyFile(src: string, dst: string): Promise<void>;
15
36
  }
37
+ export interface ProjectOptions {
38
+ cwd: string;
39
+ workerUrl?: string;
40
+ threadWorkerUrl: string;
41
+ wasmUrl?: string;
42
+ serviceWorker?: ServiceWorkerOptions;
43
+ }
44
+ export interface ServiceWorkerOptions {
45
+ url: string;
46
+ scope: string;
47
+ }
package/esm/type.js CHANGED
@@ -1 +1,12 @@
1
- export {};
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,18 +1,15 @@
1
+ export function init_pack(): void;
1
2
  /**
2
- * @param {PartialProjectOptions} partial_options
3
- * @returns {Promise<void>}
3
+ * Entry point for web workers
4
+ * @param {number} ptr
4
5
  */
5
- export function build(partial_options: PartialProjectOptions): Promise<void>;
6
- export function init_pack(): void;
6
+ export function wasm_thread_entry_point(ptr: number): void;
7
7
  export class CreateSyncAccessHandleOptions {
8
8
  static __wrap(ptr: any): any;
9
9
  __destroy_into_raw(): number | undefined;
10
10
  __wbg_ptr: number | undefined;
11
11
  free(): void;
12
12
  }
13
- /**
14
- * Directory entry with name and type information
15
- */
16
13
  export class DirEntry {
17
14
  static __wrap(ptr: any): any;
18
15
  toJSON(): {
@@ -40,74 +37,89 @@ export class DirEntry {
40
37
  */
41
38
  get type(): DirEntryType;
42
39
  }
43
- export class PartialProjectOptions {
40
+ export class Metadata {
41
+ static __wrap(ptr: any): any;
42
+ toJSON(): {};
43
+ toString(): string;
44
44
  __destroy_into_raw(): number | undefined;
45
45
  __wbg_ptr: number | undefined;
46
46
  free(): void;
47
- /**
48
- * @param {string} arg0
49
- */
50
- set project_path(arg0: string);
51
- /**
52
- * @returns {string}
53
- */
54
- get project_path(): string;
55
- /**
56
- * @param {string | null} [arg0]
57
- */
58
- set config(arg0: string | null);
59
- /**
60
- * @returns {string | undefined}
61
- */
62
- get config(): string | undefined;
63
47
  }
64
48
  export class Project {
65
49
  /**
66
50
  * @param {string} cwd
51
+ * @param {string} thread_url
67
52
  */
68
- constructor(cwd: string);
53
+ constructor(cwd: string, thread_url: string);
69
54
  __destroy_into_raw(): number;
70
55
  __wbg_ptr: number;
71
56
  free(): void;
72
57
  /**
73
- * @returns {string}
58
+ * @param {string} path
59
+ * @returns {Promise<void>}
74
60
  */
75
- get cwd(): string;
61
+ createDir(path: string): Promise<void>;
76
62
  /**
77
- * @param {string} package_lock
63
+ * @param {string} path
64
+ * @param {boolean} recursive
78
65
  * @returns {Promise<void>}
79
66
  */
80
- install(package_lock: string): Promise<void>;
67
+ removeDir(path: string, recursive: boolean): Promise<void>;
81
68
  /**
69
+ * @param {string} path
82
70
  * @returns {Promise<void>}
83
71
  */
84
- build(): Promise<void>;
72
+ removeFile(path: string): Promise<void>;
85
73
  /**
86
74
  * @param {string} path
87
- * @returns {Promise<string>}
75
+ * @param {string} content
76
+ * @returns {Promise<void>}
88
77
  */
89
- readFile(path: string): Promise<string>;
78
+ writeString(path: string, content: string): Promise<void>;
90
79
  /**
91
80
  * @param {string} path
92
- * @param {string} content
93
81
  * @returns {Promise<void>}
94
82
  */
95
- writeFile(path: string, content: string): Promise<void>;
83
+ createDirAll(path: string): Promise<void>;
96
84
  /**
97
85
  * @param {string} path
98
- * @returns {Promise<DirEntry[]>}
86
+ * @returns {Promise<string>}
99
87
  */
100
- readDir(path: string): Promise<DirEntry[]>;
88
+ readToString(path: string): Promise<string>;
89
+ /**
90
+ * @returns {string}
91
+ */
92
+ get cwd(): string;
101
93
  /**
102
94
  * @param {string} path
103
- * @returns {Promise<void>}
95
+ * @returns {Promise<Uint8Array>}
104
96
  */
105
- createDir(path: string): Promise<void>;
97
+ read(path: string): Promise<Uint8Array>;
98
+ /**
99
+ * @returns {Promise<any>}
100
+ */
101
+ build(): Promise<any>;
106
102
  /**
107
103
  * @param {string} path
104
+ * @param {Uint8Array} content
108
105
  * @returns {Promise<void>}
109
106
  */
110
- createDirAll(path: string): Promise<void>;
107
+ write(path: string, content: Uint8Array): Promise<void>;
108
+ /**
109
+ * @param {string} package_lock
110
+ * @returns {Promise<void>}
111
+ */
112
+ install(package_lock: string): Promise<void>;
113
+ /**
114
+ * @param {string} path
115
+ * @returns {Promise<Metadata>}
116
+ */
117
+ metadata(path: string): Promise<Metadata>;
118
+ /**
119
+ * @param {string} path
120
+ * @returns {Promise<DirEntry[]>}
121
+ */
122
+ readDir(path: string): Promise<DirEntry[]>;
111
123
  /**
112
124
  * @param {string} src
113
125
  * @param {string} dst
@@ -116,5 +128,5 @@ export class Project {
116
128
  copyFile(src: string, dst: string): Promise<void>;
117
129
  }
118
130
  export default __wbg_init;
119
- export function initSync(module: any): any;
120
- declare function __wbg_init(module_or_path: any): Promise<any>;
131
+ export function initSync(module: any, memory: any): any;
132
+ declare function __wbg_init(module_or_path: any, memory: any): Promise<any>;