@run0/jiki 0.1.0
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/dist/browser-bundle.d.ts +40 -0
- package/dist/builtins.d.ts +22 -0
- package/dist/code-transform.d.ts +7 -0
- package/dist/config/cdn.d.ts +13 -0
- package/dist/container.d.ts +101 -0
- package/dist/dev-server.d.ts +69 -0
- package/dist/errors.d.ts +19 -0
- package/dist/frameworks/code-transforms.d.ts +32 -0
- package/dist/frameworks/next-api-handler.d.ts +72 -0
- package/dist/frameworks/next-dev-server.d.ts +141 -0
- package/dist/frameworks/next-html-generator.d.ts +36 -0
- package/dist/frameworks/next-route-resolver.d.ts +19 -0
- package/dist/frameworks/next-shims.d.ts +78 -0
- package/dist/frameworks/remix-dev-server.d.ts +47 -0
- package/dist/frameworks/sveltekit-dev-server.d.ts +43 -0
- package/dist/frameworks/vite-dev-server.d.ts +50 -0
- package/dist/fs-errors.d.ts +36 -0
- package/dist/index.cjs +14916 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.ts +61 -0
- package/dist/index.mjs +14898 -0
- package/dist/index.mjs.map +1 -0
- package/dist/kernel.d.ts +48 -0
- package/dist/memfs.d.ts +144 -0
- package/dist/metrics.d.ts +78 -0
- package/dist/module-resolver.d.ts +60 -0
- package/dist/network-interceptor.d.ts +71 -0
- package/dist/npm/cache.d.ts +76 -0
- package/dist/npm/index.d.ts +60 -0
- package/dist/npm/lockfile-reader.d.ts +32 -0
- package/dist/npm/pnpm.d.ts +18 -0
- package/dist/npm/registry.d.ts +45 -0
- package/dist/npm/resolver.d.ts +39 -0
- package/dist/npm/sync-installer.d.ts +18 -0
- package/dist/npm/tarball.d.ts +4 -0
- package/dist/npm/workspaces.d.ts +46 -0
- package/dist/persistence.d.ts +94 -0
- package/dist/plugin.d.ts +156 -0
- package/dist/polyfills/assert.d.ts +30 -0
- package/dist/polyfills/child_process.d.ts +116 -0
- package/dist/polyfills/chokidar.d.ts +18 -0
- package/dist/polyfills/crypto.d.ts +49 -0
- package/dist/polyfills/events.d.ts +28 -0
- package/dist/polyfills/fs.d.ts +82 -0
- package/dist/polyfills/http.d.ts +147 -0
- package/dist/polyfills/module.d.ts +29 -0
- package/dist/polyfills/net.d.ts +53 -0
- package/dist/polyfills/os.d.ts +91 -0
- package/dist/polyfills/path.d.ts +96 -0
- package/dist/polyfills/perf_hooks.d.ts +21 -0
- package/dist/polyfills/process.d.ts +99 -0
- package/dist/polyfills/querystring.d.ts +15 -0
- package/dist/polyfills/readdirp.d.ts +18 -0
- package/dist/polyfills/readline.d.ts +32 -0
- package/dist/polyfills/stream.d.ts +106 -0
- package/dist/polyfills/stubs.d.ts +737 -0
- package/dist/polyfills/tty.d.ts +25 -0
- package/dist/polyfills/url.d.ts +41 -0
- package/dist/polyfills/util.d.ts +61 -0
- package/dist/polyfills/v8.d.ts +43 -0
- package/dist/polyfills/vm.d.ts +76 -0
- package/dist/polyfills/worker-threads.d.ts +77 -0
- package/dist/polyfills/ws.d.ts +32 -0
- package/dist/polyfills/zlib.d.ts +87 -0
- package/dist/runtime-helpers.d.ts +4 -0
- package/dist/runtime-interface.d.ts +39 -0
- package/dist/sandbox.d.ts +69 -0
- package/dist/server-bridge.d.ts +55 -0
- package/dist/shell-commands.d.ts +2 -0
- package/dist/shell.d.ts +101 -0
- package/dist/transpiler.d.ts +47 -0
- package/dist/type-checker.d.ts +57 -0
- package/dist/types/package-json.d.ts +17 -0
- package/dist/utils/binary-encoding.d.ts +4 -0
- package/dist/utils/hash.d.ts +6 -0
- package/dist/utils/safe-path.d.ts +6 -0
- package/dist/worker-runtime.d.ts +34 -0
- package/package.json +59 -0
- package/src/browser-bundle.ts +498 -0
- package/src/builtins.ts +222 -0
- package/src/code-transform.ts +183 -0
- package/src/config/cdn.ts +17 -0
- package/src/container.ts +343 -0
- package/src/dev-server.ts +322 -0
- package/src/errors.ts +604 -0
- package/src/frameworks/code-transforms.ts +667 -0
- package/src/frameworks/next-api-handler.ts +366 -0
- package/src/frameworks/next-dev-server.ts +1252 -0
- package/src/frameworks/next-html-generator.ts +585 -0
- package/src/frameworks/next-route-resolver.ts +521 -0
- package/src/frameworks/next-shims.ts +1084 -0
- package/src/frameworks/remix-dev-server.ts +163 -0
- package/src/frameworks/sveltekit-dev-server.ts +197 -0
- package/src/frameworks/vite-dev-server.ts +370 -0
- package/src/fs-errors.ts +118 -0
- package/src/index.ts +188 -0
- package/src/kernel.ts +381 -0
- package/src/memfs.ts +1006 -0
- package/src/metrics.ts +140 -0
- package/src/module-resolver.ts +511 -0
- package/src/network-interceptor.ts +143 -0
- package/src/npm/cache.ts +172 -0
- package/src/npm/index.ts +377 -0
- package/src/npm/lockfile-reader.ts +105 -0
- package/src/npm/pnpm.ts +108 -0
- package/src/npm/registry.ts +120 -0
- package/src/npm/resolver.ts +339 -0
- package/src/npm/sync-installer.ts +217 -0
- package/src/npm/tarball.ts +136 -0
- package/src/npm/workspaces.ts +255 -0
- package/src/persistence.ts +235 -0
- package/src/plugin.ts +293 -0
- package/src/polyfills/assert.ts +164 -0
- package/src/polyfills/child_process.ts +535 -0
- package/src/polyfills/chokidar.ts +52 -0
- package/src/polyfills/crypto.ts +433 -0
- package/src/polyfills/events.ts +178 -0
- package/src/polyfills/fs.ts +297 -0
- package/src/polyfills/http.ts +478 -0
- package/src/polyfills/module.ts +97 -0
- package/src/polyfills/net.ts +123 -0
- package/src/polyfills/os.ts +108 -0
- package/src/polyfills/path.ts +169 -0
- package/src/polyfills/perf_hooks.ts +30 -0
- package/src/polyfills/process.ts +349 -0
- package/src/polyfills/querystring.ts +66 -0
- package/src/polyfills/readdirp.ts +72 -0
- package/src/polyfills/readline.ts +80 -0
- package/src/polyfills/stream.ts +610 -0
- package/src/polyfills/stubs.ts +600 -0
- package/src/polyfills/tty.ts +43 -0
- package/src/polyfills/url.ts +97 -0
- package/src/polyfills/util.ts +173 -0
- package/src/polyfills/v8.ts +62 -0
- package/src/polyfills/vm.ts +111 -0
- package/src/polyfills/worker-threads.ts +189 -0
- package/src/polyfills/ws.ts +73 -0
- package/src/polyfills/zlib.ts +244 -0
- package/src/runtime-helpers.ts +83 -0
- package/src/runtime-interface.ts +46 -0
- package/src/sandbox.ts +178 -0
- package/src/server-bridge.ts +473 -0
- package/src/service-worker.ts +153 -0
- package/src/shell-commands.ts +708 -0
- package/src/shell.ts +795 -0
- package/src/transpiler.ts +282 -0
- package/src/type-checker.ts +241 -0
- package/src/types/package-json.ts +17 -0
- package/src/utils/binary-encoding.ts +38 -0
- package/src/utils/hash.ts +24 -0
- package/src/utils/safe-path.ts +38 -0
- package/src/worker-runtime.ts +42 -0
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import type { MemFS } from "../memfs";
|
|
2
|
+
import * as pathShim from "./path";
|
|
3
|
+
|
|
4
|
+
let _vfs: MemFS | null = null;
|
|
5
|
+
export function initReaddirp(vfs: MemFS): void {
|
|
6
|
+
_vfs = vfs;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export interface ReaddirpEntry {
|
|
10
|
+
path: string;
|
|
11
|
+
fullPath: string;
|
|
12
|
+
basename: string;
|
|
13
|
+
dirent: { isFile(): boolean; isDirectory(): boolean };
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export default function readdirp(
|
|
17
|
+
root: string,
|
|
18
|
+
options?: {
|
|
19
|
+
fileFilter?: string | string[];
|
|
20
|
+
directoryFilter?: string | string[];
|
|
21
|
+
depth?: number;
|
|
22
|
+
},
|
|
23
|
+
): AsyncIterable<ReaddirpEntry> & {
|
|
24
|
+
[Symbol.asyncIterator](): AsyncIterableIterator<ReaddirpEntry>;
|
|
25
|
+
} {
|
|
26
|
+
const entries: ReaddirpEntry[] = [];
|
|
27
|
+
|
|
28
|
+
if (_vfs) {
|
|
29
|
+
const collect = (dir: string, depth: number) => {
|
|
30
|
+
if (options?.depth !== undefined && depth > options.depth) return;
|
|
31
|
+
try {
|
|
32
|
+
const items = _vfs!.readdirSync(dir);
|
|
33
|
+
for (const name of items) {
|
|
34
|
+
const fullPath = pathShim.join(dir, name);
|
|
35
|
+
try {
|
|
36
|
+
const stat = _vfs!.statSync(fullPath);
|
|
37
|
+
entries.push({
|
|
38
|
+
path: pathShim.relative(root, fullPath),
|
|
39
|
+
fullPath,
|
|
40
|
+
basename: name,
|
|
41
|
+
dirent: {
|
|
42
|
+
isFile: () => stat.isFile(),
|
|
43
|
+
isDirectory: () => stat.isDirectory(),
|
|
44
|
+
},
|
|
45
|
+
});
|
|
46
|
+
if (stat.isDirectory()) collect(fullPath, depth + 1);
|
|
47
|
+
} catch {}
|
|
48
|
+
}
|
|
49
|
+
} catch {}
|
|
50
|
+
};
|
|
51
|
+
collect(root, 0);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
let idx = 0;
|
|
55
|
+
return {
|
|
56
|
+
[Symbol.asyncIterator](): AsyncIterableIterator<ReaddirpEntry> {
|
|
57
|
+
return {
|
|
58
|
+
next(): Promise<IteratorResult<ReaddirpEntry>> {
|
|
59
|
+
if (idx < entries.length)
|
|
60
|
+
return Promise.resolve({ value: entries[idx++], done: false });
|
|
61
|
+
return Promise.resolve({
|
|
62
|
+
value: undefined as unknown as ReaddirpEntry,
|
|
63
|
+
done: true,
|
|
64
|
+
});
|
|
65
|
+
},
|
|
66
|
+
[Symbol.asyncIterator]() {
|
|
67
|
+
return this;
|
|
68
|
+
},
|
|
69
|
+
};
|
|
70
|
+
},
|
|
71
|
+
};
|
|
72
|
+
}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { EventEmitter } from "./events";
|
|
2
|
+
|
|
3
|
+
export class Interface extends EventEmitter {
|
|
4
|
+
private _input: unknown;
|
|
5
|
+
private _output: unknown;
|
|
6
|
+
terminal: boolean;
|
|
7
|
+
|
|
8
|
+
constructor(options?: {
|
|
9
|
+
input?: unknown;
|
|
10
|
+
output?: unknown;
|
|
11
|
+
terminal?: boolean;
|
|
12
|
+
}) {
|
|
13
|
+
super();
|
|
14
|
+
this._input = options?.input;
|
|
15
|
+
this._output = options?.output;
|
|
16
|
+
this.terminal = options?.terminal ?? false;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
question(query: string, cb: (answer: string) => void): void {
|
|
20
|
+
if (this._output && typeof (this._output as any).write === "function") {
|
|
21
|
+
(this._output as any).write(query);
|
|
22
|
+
}
|
|
23
|
+
cb("");
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
close(): void {
|
|
27
|
+
this.emit("close");
|
|
28
|
+
}
|
|
29
|
+
pause(): this {
|
|
30
|
+
return this;
|
|
31
|
+
}
|
|
32
|
+
resume(): this {
|
|
33
|
+
return this;
|
|
34
|
+
}
|
|
35
|
+
prompt(_preserveCursor?: boolean): void {}
|
|
36
|
+
setPrompt(_prompt: string): void {}
|
|
37
|
+
write(_data: string): void {}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export function createInterface(options?: unknown): Interface {
|
|
41
|
+
return new Interface(
|
|
42
|
+
options as { input?: unknown; output?: unknown; terminal?: boolean },
|
|
43
|
+
);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export function clearLine(
|
|
47
|
+
_stream: unknown,
|
|
48
|
+
_dir: number,
|
|
49
|
+
_cb?: () => void,
|
|
50
|
+
): boolean {
|
|
51
|
+
return true;
|
|
52
|
+
}
|
|
53
|
+
export function clearScreenDown(_stream: unknown, _cb?: () => void): boolean {
|
|
54
|
+
return true;
|
|
55
|
+
}
|
|
56
|
+
export function cursorTo(
|
|
57
|
+
_stream: unknown,
|
|
58
|
+
_x: number,
|
|
59
|
+
_y?: number,
|
|
60
|
+
_cb?: () => void,
|
|
61
|
+
): boolean {
|
|
62
|
+
return true;
|
|
63
|
+
}
|
|
64
|
+
export function moveCursor(
|
|
65
|
+
_stream: unknown,
|
|
66
|
+
_dx: number,
|
|
67
|
+
_dy: number,
|
|
68
|
+
_cb?: () => void,
|
|
69
|
+
): boolean {
|
|
70
|
+
return true;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
export default {
|
|
74
|
+
Interface,
|
|
75
|
+
createInterface,
|
|
76
|
+
clearLine,
|
|
77
|
+
clearScreenDown,
|
|
78
|
+
cursorTo,
|
|
79
|
+
moveCursor,
|
|
80
|
+
};
|