@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,18 @@
|
|
|
1
|
+
import { MemFS } from "../memfs";
|
|
2
|
+
import type { AutoInstallProvider } from "../module-resolver";
|
|
3
|
+
import type { LayoutStrategy } from "./index";
|
|
4
|
+
export declare class SyncAutoInstaller implements AutoInstallProvider {
|
|
5
|
+
private vfs;
|
|
6
|
+
private registryUrl;
|
|
7
|
+
private cwd;
|
|
8
|
+
private layout;
|
|
9
|
+
private manifestCache;
|
|
10
|
+
private installed;
|
|
11
|
+
constructor(vfs: MemFS, layout: LayoutStrategy, options?: {
|
|
12
|
+
cwd?: string;
|
|
13
|
+
registry?: string;
|
|
14
|
+
});
|
|
15
|
+
installSync(name: string): void;
|
|
16
|
+
private installPackageSync;
|
|
17
|
+
private fetchManifestSync;
|
|
18
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { MemFS } from "../memfs";
|
|
2
|
+
import type { PackageCache } from "./cache";
|
|
3
|
+
export declare function downloadAndExtract(url: string, vfs: MemFS, destDir: string, stripComponents?: number, cache?: PackageCache): Promise<void>;
|
|
4
|
+
export declare function extractTarball(data: Uint8Array, vfs: MemFS, destDir: string, stripComponents?: number): Promise<void>;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Monorepo workspace support.
|
|
3
|
+
*
|
|
4
|
+
* Parses `workspaces` field from package.json or `pnpm-workspace.yaml`
|
|
5
|
+
* and resolves `workspace:*` version specifiers to local packages.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```ts
|
|
9
|
+
* const workspaces = discoverWorkspaces(vfs, '/');
|
|
10
|
+
* // [{ name: '@myapp/utils', path: '/packages/utils', version: '1.0.0' }]
|
|
11
|
+
* ```
|
|
12
|
+
*/
|
|
13
|
+
import type { MemFS } from "../memfs";
|
|
14
|
+
export interface WorkspacePackage {
|
|
15
|
+
/** Package name from its package.json. */
|
|
16
|
+
name: string;
|
|
17
|
+
/** Absolute path to the workspace package directory. */
|
|
18
|
+
path: string;
|
|
19
|
+
/** Version from its package.json. */
|
|
20
|
+
version: string;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Discover all workspace packages in a monorepo.
|
|
24
|
+
*
|
|
25
|
+
* Checks for:
|
|
26
|
+
* 1. `workspaces` field in root package.json (npm/yarn format)
|
|
27
|
+
* 2. `pnpm-workspace.yaml` (pnpm format)
|
|
28
|
+
*
|
|
29
|
+
* Returns an array of discovered workspace packages with their names,
|
|
30
|
+
* paths, and versions.
|
|
31
|
+
*/
|
|
32
|
+
export declare function discoverWorkspaces(vfs: MemFS, cwd: string): WorkspacePackage[];
|
|
33
|
+
/**
|
|
34
|
+
* Resolve a `workspace:*` version specifier to the local package path.
|
|
35
|
+
* Returns the workspace package if found, or `null` if not a workspace dep.
|
|
36
|
+
*/
|
|
37
|
+
export declare function resolveWorkspaceDep(specifier: string, workspaces: WorkspacePackage[]): WorkspacePackage | null;
|
|
38
|
+
/**
|
|
39
|
+
* Check if a version string is a workspace protocol specifier.
|
|
40
|
+
*/
|
|
41
|
+
export declare function isWorkspaceProtocol(version: string): boolean;
|
|
42
|
+
/**
|
|
43
|
+
* Create symlinks in node_modules for workspace packages, similar to
|
|
44
|
+
* how pnpm/yarn link local packages.
|
|
45
|
+
*/
|
|
46
|
+
export declare function linkWorkspaces(vfs: MemFS, cwd: string, workspaces: WorkspacePackage[]): void;
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Persistence layer for MemFS.
|
|
3
|
+
*
|
|
4
|
+
* Provides a `PersistenceAdapter` interface and an `IndexedDBAdapter`
|
|
5
|
+
* implementation that synchronises the in-memory filesystem to IndexedDB.
|
|
6
|
+
*
|
|
7
|
+
* Writes are fire-and-forget — they never block the synchronous VFS API.
|
|
8
|
+
* Mutations are batched and flushed via microtask debounce (~100 ms) so
|
|
9
|
+
* rapid consecutive writes result in a single IndexedDB transaction.
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```ts
|
|
13
|
+
* const adapter = new IndexedDBAdapter('my-project');
|
|
14
|
+
* const vfs = new MemFS({ persistence: adapter });
|
|
15
|
+
* await vfs.hydrate(); // load persisted state
|
|
16
|
+
* vfs.writeFileSync('/hello.txt', 'world'); // auto-persisted
|
|
17
|
+
* ```
|
|
18
|
+
*/
|
|
19
|
+
import type { FSNode } from "./memfs";
|
|
20
|
+
/** Serialised form of a single filesystem entry stored in the adapter. */
|
|
21
|
+
export interface PersistedEntry {
|
|
22
|
+
path: string;
|
|
23
|
+
type: "file" | "directory" | "symlink";
|
|
24
|
+
/** File content as Uint8Array. Only set for type === "file". */
|
|
25
|
+
content?: Uint8Array;
|
|
26
|
+
/** Symlink target. Only set for type === "symlink". */
|
|
27
|
+
target?: string;
|
|
28
|
+
mtime: number;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Backend-agnostic interface for persisting MemFS state.
|
|
32
|
+
* Implement this to plug in any storage backend (IndexedDB, OPFS,
|
|
33
|
+
* localStorage, etc.).
|
|
34
|
+
*/
|
|
35
|
+
export interface PersistenceAdapter {
|
|
36
|
+
/** Persist a single entry (upsert by path). */
|
|
37
|
+
save(entry: PersistedEntry): void;
|
|
38
|
+
/** Delete a persisted entry by path. */
|
|
39
|
+
delete(path: string): void;
|
|
40
|
+
/** Load all persisted entries. */
|
|
41
|
+
loadAll(): Promise<PersistedEntry[]>;
|
|
42
|
+
/** Delete all persisted entries. */
|
|
43
|
+
clear(): Promise<void>;
|
|
44
|
+
/** Flush any pending writes immediately. Returns when the flush completes. */
|
|
45
|
+
flush(): Promise<void>;
|
|
46
|
+
}
|
|
47
|
+
/** Options for the IndexedDB adapter. */
|
|
48
|
+
export interface IndexedDBAdapterOptions {
|
|
49
|
+
/** IndexedDB database name. Defaults to `"jiki-vfs"`. */
|
|
50
|
+
dbName?: string;
|
|
51
|
+
/** Object store name. Defaults to `"files"`. */
|
|
52
|
+
storeName?: string;
|
|
53
|
+
/** Batch flush interval in milliseconds. Defaults to 100. */
|
|
54
|
+
flushIntervalMs?: number;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Persists MemFS entries to IndexedDB.
|
|
58
|
+
*
|
|
59
|
+
* Mutations are batched into a queue and flushed periodically (default
|
|
60
|
+
* every 100 ms) in a single readwrite transaction for performance.
|
|
61
|
+
*/
|
|
62
|
+
export declare class IndexedDBAdapter implements PersistenceAdapter {
|
|
63
|
+
private dbName;
|
|
64
|
+
private storeName;
|
|
65
|
+
private flushIntervalMs;
|
|
66
|
+
private db;
|
|
67
|
+
private queue;
|
|
68
|
+
private flushTimer;
|
|
69
|
+
private flushPromise;
|
|
70
|
+
constructor(options?: IndexedDBAdapterOptions);
|
|
71
|
+
private openDB;
|
|
72
|
+
save(entry: PersistedEntry): void;
|
|
73
|
+
delete(path: string): void;
|
|
74
|
+
loadAll(): Promise<PersistedEntry[]>;
|
|
75
|
+
clear(): Promise<void>;
|
|
76
|
+
flush(): Promise<void>;
|
|
77
|
+
private scheduleFlush;
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* In-memory adapter that stores entries in a `Map`.
|
|
81
|
+
* Useful for tests and server-side usage where IndexedDB is unavailable.
|
|
82
|
+
*/
|
|
83
|
+
export declare class InMemoryAdapter implements PersistenceAdapter {
|
|
84
|
+
private store;
|
|
85
|
+
save(entry: PersistedEntry): void;
|
|
86
|
+
delete(path: string): void;
|
|
87
|
+
loadAll(): Promise<PersistedEntry[]>;
|
|
88
|
+
clear(): Promise<void>;
|
|
89
|
+
flush(): Promise<void>;
|
|
90
|
+
/** Return the number of stored entries (test helper). */
|
|
91
|
+
get size(): number;
|
|
92
|
+
}
|
|
93
|
+
/** Convert an FSNode at the given path to a PersistedEntry. */
|
|
94
|
+
export declare function nodeToEntry(path: string, node: FSNode): PersistedEntry;
|
package/dist/plugin.d.ts
ADDED
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Plugin system for jiki.
|
|
3
|
+
*
|
|
4
|
+
* Provides lifecycle hooks that let external code intercept and extend
|
|
5
|
+
* jiki's behaviour at key points: module resolution, module loading,
|
|
6
|
+
* code transformation, shell command registration, package installation,
|
|
7
|
+
* and container boot.
|
|
8
|
+
*
|
|
9
|
+
* The API mirrors esbuild's plugin conventions so it feels familiar to
|
|
10
|
+
* most JavaScript developers.
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```ts
|
|
14
|
+
* const myPlugin: JikiPlugin = {
|
|
15
|
+
* name: 'my-plugin',
|
|
16
|
+
* setup(hooks) {
|
|
17
|
+
* hooks.onResolve(/^virtual:/, (args) => ({
|
|
18
|
+
* path: `/virtual/${args.path.slice(8)}`,
|
|
19
|
+
* }));
|
|
20
|
+
* hooks.onLoad(/^\/virtual\//, (args) => ({
|
|
21
|
+
* contents: `module.exports = "hello from ${args.path}";`,
|
|
22
|
+
* }));
|
|
23
|
+
* },
|
|
24
|
+
* };
|
|
25
|
+
*
|
|
26
|
+
* const container = boot({ plugins: [myPlugin] });
|
|
27
|
+
* ```
|
|
28
|
+
*/
|
|
29
|
+
/** Arguments passed to an `onResolve` callback. */
|
|
30
|
+
export interface OnResolveArgs {
|
|
31
|
+
/** The raw module specifier (e.g. `"virtual:config"` or `"./foo"`). */
|
|
32
|
+
path: string;
|
|
33
|
+
/** Directory the import originates from. */
|
|
34
|
+
resolveDir: string;
|
|
35
|
+
}
|
|
36
|
+
/** Return value from an `onResolve` callback. */
|
|
37
|
+
export interface OnResolveResult {
|
|
38
|
+
/** Resolved absolute path. Returning this skips the default resolver. */
|
|
39
|
+
path: string;
|
|
40
|
+
}
|
|
41
|
+
/** Arguments passed to an `onLoad` callback. */
|
|
42
|
+
export interface OnLoadArgs {
|
|
43
|
+
/** The fully-resolved module path. */
|
|
44
|
+
path: string;
|
|
45
|
+
}
|
|
46
|
+
/** Return value from an `onLoad` callback. */
|
|
47
|
+
export interface OnLoadResult {
|
|
48
|
+
/** Source code to use instead of reading from the VFS. */
|
|
49
|
+
contents: string;
|
|
50
|
+
}
|
|
51
|
+
/** Arguments passed to an `onTransform` callback. */
|
|
52
|
+
export interface OnTransformArgs {
|
|
53
|
+
/** The fully-resolved file path. */
|
|
54
|
+
path: string;
|
|
55
|
+
/** Source code *after* previous transforms in the pipeline. */
|
|
56
|
+
contents: string;
|
|
57
|
+
}
|
|
58
|
+
/** Return value from an `onTransform` callback. */
|
|
59
|
+
export interface OnTransformResult {
|
|
60
|
+
/** Transformed source code. */
|
|
61
|
+
contents: string;
|
|
62
|
+
}
|
|
63
|
+
/** Callback types for lifecycle hooks. */
|
|
64
|
+
export type OnResolveCallback = (args: OnResolveArgs) => OnResolveResult | null | undefined | void;
|
|
65
|
+
export type OnLoadCallback = (args: OnLoadArgs) => OnLoadResult | null | undefined | void;
|
|
66
|
+
export type OnTransformCallback = (args: OnTransformArgs) => OnTransformResult | null | undefined | void;
|
|
67
|
+
export type OnInstallCallback = (packages: string[]) => void;
|
|
68
|
+
export type OnBootCallback = () => void;
|
|
69
|
+
import type { CommandHandler } from "./shell";
|
|
70
|
+
/** Hook registration API handed to {@link JikiPlugin.setup}. */
|
|
71
|
+
export interface PluginHooks {
|
|
72
|
+
/**
|
|
73
|
+
* Intercept module resolution. The first callback whose `filter` matches
|
|
74
|
+
* **and** returns a non-null result wins — later callbacks are skipped.
|
|
75
|
+
*/
|
|
76
|
+
onResolve(filter: RegExp, callback: OnResolveCallback): void;
|
|
77
|
+
/**
|
|
78
|
+
* Intercept module loading. The first callback whose `filter` matches
|
|
79
|
+
* **and** returns a non-null result wins — later callbacks are skipped.
|
|
80
|
+
*/
|
|
81
|
+
onLoad(filter: RegExp, callback: OnLoadCallback): void;
|
|
82
|
+
/**
|
|
83
|
+
* Intercept code transformation. Unlike resolve/load, this is a
|
|
84
|
+
* **pipeline**: every matching callback runs in registration order,
|
|
85
|
+
* each receiving the output of the previous one.
|
|
86
|
+
*/
|
|
87
|
+
onTransform(filter: RegExp, callback: OnTransformCallback): void;
|
|
88
|
+
/** Register a custom shell command. */
|
|
89
|
+
onCommand(name: string, handler: CommandHandler): void;
|
|
90
|
+
/** Called after packages are installed. */
|
|
91
|
+
onInstall(callback: OnInstallCallback): void;
|
|
92
|
+
/** Called after the container is fully initialised. */
|
|
93
|
+
onBoot(callback: OnBootCallback): void;
|
|
94
|
+
}
|
|
95
|
+
/** A jiki plugin. */
|
|
96
|
+
export interface JikiPlugin {
|
|
97
|
+
/** Human-readable name (used in error messages and debugging). */
|
|
98
|
+
name: string;
|
|
99
|
+
/** Called once during container construction. Register hooks here. */
|
|
100
|
+
setup(hooks: PluginHooks): void;
|
|
101
|
+
}
|
|
102
|
+
interface CommandEntry {
|
|
103
|
+
name: string;
|
|
104
|
+
handler: CommandHandler;
|
|
105
|
+
plugin: string;
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Central registry that collects hooks from all plugins and exposes
|
|
109
|
+
* methods for the runtime to invoke them.
|
|
110
|
+
*
|
|
111
|
+
* Intentionally not a singleton — each {@link Container} gets its own
|
|
112
|
+
* `PluginRegistry` so plugins cannot leak between containers.
|
|
113
|
+
*/
|
|
114
|
+
export declare class PluginRegistry {
|
|
115
|
+
private resolveHooks;
|
|
116
|
+
private loadHooks;
|
|
117
|
+
private transformHooks;
|
|
118
|
+
private commandHooks;
|
|
119
|
+
private installHooks;
|
|
120
|
+
private bootHooks;
|
|
121
|
+
/** True if at least one plugin has been registered. */
|
|
122
|
+
get hasPlugins(): boolean;
|
|
123
|
+
/** Number of registered resolve hooks. */
|
|
124
|
+
get resolveHookCount(): number;
|
|
125
|
+
/** Number of registered load hooks. */
|
|
126
|
+
get loadHookCount(): number;
|
|
127
|
+
/** Number of registered transform hooks. */
|
|
128
|
+
get transformHookCount(): number;
|
|
129
|
+
/** Number of registered command hooks. */
|
|
130
|
+
get commandHookCount(): number;
|
|
131
|
+
/** Register all hooks from a single plugin. */
|
|
132
|
+
register(plugin: JikiPlugin): void;
|
|
133
|
+
/**
|
|
134
|
+
* Run resolve hooks. First matching callback that returns a result wins.
|
|
135
|
+
* Returns `null` if no plugin handled the specifier.
|
|
136
|
+
*/
|
|
137
|
+
runResolve(path: string, resolveDir: string): OnResolveResult | null;
|
|
138
|
+
/**
|
|
139
|
+
* Run load hooks. First matching callback that returns a result wins.
|
|
140
|
+
* Returns `null` if no plugin provided contents.
|
|
141
|
+
*/
|
|
142
|
+
runLoad(path: string): OnLoadResult | null;
|
|
143
|
+
/**
|
|
144
|
+
* Run transform hooks as a pipeline.
|
|
145
|
+
* Every matching callback runs in order, each receiving the output of the
|
|
146
|
+
* previous one. Returns the final transformed source.
|
|
147
|
+
*/
|
|
148
|
+
runTransform(path: string, contents: string): string;
|
|
149
|
+
/** Return all command hooks so the shell can register them. */
|
|
150
|
+
getCommandHooks(): CommandEntry[];
|
|
151
|
+
/** Notify all install hooks. */
|
|
152
|
+
runInstall(packages: string[]): void;
|
|
153
|
+
/** Notify all boot hooks. */
|
|
154
|
+
runBoot(): void;
|
|
155
|
+
}
|
|
156
|
+
export {};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
declare class AssertionError extends Error {
|
|
2
|
+
actual: unknown;
|
|
3
|
+
expected: unknown;
|
|
4
|
+
operator: string;
|
|
5
|
+
constructor(message: string, actual?: unknown, expected?: unknown, operator?: string);
|
|
6
|
+
}
|
|
7
|
+
declare function assert(value: unknown, message?: string): asserts value;
|
|
8
|
+
declare namespace assert {
|
|
9
|
+
var ok: typeof assert;
|
|
10
|
+
var equal: (actual: unknown, expected: unknown, message?: string) => void;
|
|
11
|
+
var notEqual: (actual: unknown, expected: unknown, message?: string) => void;
|
|
12
|
+
var strictEqual: (actual: unknown, expected: unknown, message?: string) => void;
|
|
13
|
+
var notStrictEqual: (actual: unknown, expected: unknown, message?: string) => void;
|
|
14
|
+
var deepEqual: (actual: unknown, expected: unknown, message?: string) => void;
|
|
15
|
+
var deepStrictEqual: (actual: unknown, expected: unknown, message?: string) => void;
|
|
16
|
+
var notDeepEqual: (actual: unknown, expected: unknown, message?: string) => void;
|
|
17
|
+
var notDeepStrictEqual: (actual: unknown, expected: unknown, message?: string) => void;
|
|
18
|
+
var throws: (fn: () => void, errorOrMessage?: unknown, message?: string) => void;
|
|
19
|
+
var doesNotThrow: (fn: () => void, message?: string) => void;
|
|
20
|
+
var rejects: (fn: (() => Promise<unknown>) | Promise<unknown>, message?: string) => Promise<void>;
|
|
21
|
+
var doesNotReject: (fn: (() => Promise<unknown>) | Promise<unknown>, message?: string) => Promise<void>;
|
|
22
|
+
var ifError: (value: unknown) => void;
|
|
23
|
+
var fail: (message?: string) => never;
|
|
24
|
+
var match: (string: string, regexp: RegExp, message?: string) => void;
|
|
25
|
+
var doesNotMatch: (string: string, regexp: RegExp, message?: string) => void;
|
|
26
|
+
var AssertionError: typeof import("./assert").AssertionError;
|
|
27
|
+
var strict: typeof assert;
|
|
28
|
+
}
|
|
29
|
+
export { AssertionError };
|
|
30
|
+
export default assert;
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import { EventEmitter } from "./events";
|
|
2
|
+
import type { MemFS } from "../memfs";
|
|
3
|
+
interface KernelLike {
|
|
4
|
+
runFile: (path: string) => unknown;
|
|
5
|
+
getProcess: () => ProcessLike;
|
|
6
|
+
}
|
|
7
|
+
interface ProcessLike {
|
|
8
|
+
argv: string[];
|
|
9
|
+
exit: (code?: number) => never;
|
|
10
|
+
connected?: boolean;
|
|
11
|
+
send?: (message: unknown, callback?: (error: Error | null) => void) => boolean;
|
|
12
|
+
stdout: {
|
|
13
|
+
isTTY?: boolean;
|
|
14
|
+
emit: (event: string, ...args: unknown[]) => void;
|
|
15
|
+
};
|
|
16
|
+
stderr: {
|
|
17
|
+
isTTY?: boolean;
|
|
18
|
+
emit: (event: string, ...args: unknown[]) => void;
|
|
19
|
+
};
|
|
20
|
+
stdin: {
|
|
21
|
+
isTTY?: boolean;
|
|
22
|
+
setRawMode?: (mode: boolean) => unknown;
|
|
23
|
+
emit: (event: string, ...args: unknown[]) => void;
|
|
24
|
+
};
|
|
25
|
+
on: (event: string, listener: (...args: unknown[]) => void) => unknown;
|
|
26
|
+
once: (event: string, listener: (...args: unknown[]) => void) => unknown;
|
|
27
|
+
emit: (event: string, ...args: unknown[]) => boolean;
|
|
28
|
+
listeners: (event: string) => ((...args: unknown[]) => void)[];
|
|
29
|
+
}
|
|
30
|
+
export declare function patchDefineProperty(): void;
|
|
31
|
+
export declare function getActiveForkedChildren(): number;
|
|
32
|
+
export declare function setOnForkedChildExit(cb: (() => void) | null): (() => void) | null;
|
|
33
|
+
export declare function setStreamingCallbacks(opts: {
|
|
34
|
+
onStdout?: (data: string) => void;
|
|
35
|
+
onStderr?: (data: string) => void;
|
|
36
|
+
signal?: AbortSignal;
|
|
37
|
+
}): void;
|
|
38
|
+
export declare function clearStreamingCallbacks(): void;
|
|
39
|
+
export declare function getStreamingState(): {
|
|
40
|
+
streamStdout: ((data: string) => void) | null;
|
|
41
|
+
streamStderr: ((data: string) => void) | null;
|
|
42
|
+
abortSignal: AbortSignal | null;
|
|
43
|
+
};
|
|
44
|
+
export declare function sendStdin(data: string): void;
|
|
45
|
+
export declare function setActiveProcessStdin(stdin: {
|
|
46
|
+
emit: (event: string, ...args: unknown[]) => void;
|
|
47
|
+
} | null): void;
|
|
48
|
+
export declare function initChildProcess(vfs: MemFS, runtimeFactory?: (vfs: MemFS, options?: Record<string, unknown>) => KernelLike): void;
|
|
49
|
+
export declare class ChildProcess extends EventEmitter {
|
|
50
|
+
pid: number;
|
|
51
|
+
exitCode: number | null;
|
|
52
|
+
signalCode: string | null;
|
|
53
|
+
killed: boolean;
|
|
54
|
+
connected: boolean;
|
|
55
|
+
spawnargs: string[];
|
|
56
|
+
spawnfile: string;
|
|
57
|
+
stdout: EventEmitter | null;
|
|
58
|
+
stderr: EventEmitter | null;
|
|
59
|
+
stdin: EventEmitter | null;
|
|
60
|
+
constructor();
|
|
61
|
+
kill(signal?: string): boolean;
|
|
62
|
+
send(message: unknown, _cb?: (error: Error | null) => void): boolean;
|
|
63
|
+
disconnect(): void;
|
|
64
|
+
ref(): this;
|
|
65
|
+
unref(): this;
|
|
66
|
+
}
|
|
67
|
+
export interface ExecResult {
|
|
68
|
+
stdout: string;
|
|
69
|
+
stderr: string;
|
|
70
|
+
}
|
|
71
|
+
export declare function exec(command: string, optionsOrCb?: unknown | ((err: Error | null, result?: ExecResult) => void), cb?: (err: Error | null, result?: ExecResult) => void): ChildProcess;
|
|
72
|
+
export declare function execSync(command: string, _options?: unknown): string;
|
|
73
|
+
export interface SpawnOptions {
|
|
74
|
+
cwd?: string;
|
|
75
|
+
env?: Record<string, string>;
|
|
76
|
+
stdio?: "pipe" | "inherit" | "ignore" | Array<"pipe" | "inherit" | "ignore" | "ipc" | null>;
|
|
77
|
+
shell?: boolean | string;
|
|
78
|
+
detached?: boolean;
|
|
79
|
+
uid?: number;
|
|
80
|
+
gid?: number;
|
|
81
|
+
timeout?: number;
|
|
82
|
+
signal?: AbortSignal;
|
|
83
|
+
}
|
|
84
|
+
export declare function spawn(command: string, args?: string[], options?: SpawnOptions | unknown): ChildProcess;
|
|
85
|
+
export declare function execFile(file: string, args?: string[], optionsOrCb?: unknown, cb?: (err: Error | null, stdout?: string, stderr?: string) => void): ChildProcess;
|
|
86
|
+
export declare function execFileSync(file: string, args?: string[], _options?: unknown): string;
|
|
87
|
+
export declare function spawnSync(command: string, args?: string[], _options?: unknown): {
|
|
88
|
+
stdout: string;
|
|
89
|
+
stderr: string;
|
|
90
|
+
status: number;
|
|
91
|
+
};
|
|
92
|
+
/**
|
|
93
|
+
* Fork — runs a Node.js module in a simulated child process using a new Kernel.
|
|
94
|
+
* Creates bidirectional IPC between parent and child, with serialized message delivery.
|
|
95
|
+
*/
|
|
96
|
+
export declare function fork(modulePath: string, argsOrOptions?: string[] | Record<string, unknown>, options?: Record<string, unknown>): ChildProcess;
|
|
97
|
+
declare const _default: {
|
|
98
|
+
ChildProcess: typeof ChildProcess;
|
|
99
|
+
exec: typeof exec;
|
|
100
|
+
execSync: typeof execSync;
|
|
101
|
+
spawn: typeof spawn;
|
|
102
|
+
execFile: typeof execFile;
|
|
103
|
+
execFileSync: typeof execFileSync;
|
|
104
|
+
fork: typeof fork;
|
|
105
|
+
spawnSync: typeof spawnSync;
|
|
106
|
+
initChildProcess: typeof initChildProcess;
|
|
107
|
+
setStreamingCallbacks: typeof setStreamingCallbacks;
|
|
108
|
+
clearStreamingCallbacks: typeof clearStreamingCallbacks;
|
|
109
|
+
sendStdin: typeof sendStdin;
|
|
110
|
+
setActiveProcessStdin: typeof setActiveProcessStdin;
|
|
111
|
+
getStreamingState: typeof getStreamingState;
|
|
112
|
+
getActiveForkedChildren: typeof getActiveForkedChildren;
|
|
113
|
+
setOnForkedChildExit: typeof setOnForkedChildExit;
|
|
114
|
+
patchDefineProperty: typeof patchDefineProperty;
|
|
115
|
+
};
|
|
116
|
+
export default _default;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { EventEmitter } from "./events";
|
|
2
|
+
import type { MemFS } from "../memfs";
|
|
3
|
+
export declare function initChokidar(vfs: MemFS): void;
|
|
4
|
+
export declare class FSWatcher extends EventEmitter {
|
|
5
|
+
closed: boolean;
|
|
6
|
+
private watchers;
|
|
7
|
+
add(paths: string | string[]): this;
|
|
8
|
+
unwatch(_paths: string | string[]): this;
|
|
9
|
+
close(): Promise<void>;
|
|
10
|
+
getWatched(): Record<string, string[]>;
|
|
11
|
+
}
|
|
12
|
+
export declare function watch(paths: string | string[], _options?: unknown): FSWatcher;
|
|
13
|
+
declare const _default: {
|
|
14
|
+
watch: typeof watch;
|
|
15
|
+
FSWatcher: typeof FSWatcher;
|
|
16
|
+
initChokidar: typeof initChokidar;
|
|
17
|
+
};
|
|
18
|
+
export default _default;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { BufferImpl } from "./stream";
|
|
2
|
+
export declare function randomBytes(size: number): BufferImpl;
|
|
3
|
+
export declare function randomUUID(): string;
|
|
4
|
+
export declare function randomInt(min: number, max?: number): number;
|
|
5
|
+
declare class HashImpl {
|
|
6
|
+
private algorithm;
|
|
7
|
+
private data;
|
|
8
|
+
constructor(algorithm: string);
|
|
9
|
+
update(data: string | Uint8Array, encoding?: string): this;
|
|
10
|
+
private _combine;
|
|
11
|
+
digestAsync(encoding?: string): Promise<string | Uint8Array>;
|
|
12
|
+
digest(encoding?: string): string | Uint8Array;
|
|
13
|
+
}
|
|
14
|
+
declare class HmacImpl {
|
|
15
|
+
private algorithm;
|
|
16
|
+
private key;
|
|
17
|
+
private chunks;
|
|
18
|
+
constructor(algorithm: string, key: string | Uint8Array);
|
|
19
|
+
update(data: string | Uint8Array, _encoding?: string): this;
|
|
20
|
+
digest(encoding?: string): string | Uint8Array;
|
|
21
|
+
}
|
|
22
|
+
export declare function createHash(algorithm: string): HashImpl;
|
|
23
|
+
export declare function createHmac(algorithm: string, key: string | Uint8Array): HmacImpl;
|
|
24
|
+
export declare function timingSafeEqual(a: Uint8Array, b: Uint8Array): boolean;
|
|
25
|
+
export declare function getHashes(): string[];
|
|
26
|
+
export declare function getCiphers(): string[];
|
|
27
|
+
export declare function createSign(_algorithm: string): {
|
|
28
|
+
update(data: string | Uint8Array): /*elided*/ any;
|
|
29
|
+
sign(key: unknown, encoding?: string): string | BufferImpl;
|
|
30
|
+
};
|
|
31
|
+
export declare function createVerify(_algorithm: string): {
|
|
32
|
+
update(data: string | Uint8Array): /*elided*/ any;
|
|
33
|
+
verify(key: unknown, signature: unknown, encoding?: string): boolean;
|
|
34
|
+
};
|
|
35
|
+
export declare const webcrypto: Crypto;
|
|
36
|
+
declare const _default: {
|
|
37
|
+
randomBytes: typeof randomBytes;
|
|
38
|
+
randomUUID: typeof randomUUID;
|
|
39
|
+
randomInt: typeof randomInt;
|
|
40
|
+
createHash: typeof createHash;
|
|
41
|
+
createHmac: typeof createHmac;
|
|
42
|
+
timingSafeEqual: typeof timingSafeEqual;
|
|
43
|
+
getHashes: typeof getHashes;
|
|
44
|
+
getCiphers: typeof getCiphers;
|
|
45
|
+
createSign: typeof createSign;
|
|
46
|
+
createVerify: typeof createVerify;
|
|
47
|
+
webcrypto: Crypto;
|
|
48
|
+
};
|
|
49
|
+
export default _default;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
export type EventListener = (...args: any[]) => void;
|
|
2
|
+
export declare class EventEmitter {
|
|
3
|
+
on(event: string, listener: EventListener): this;
|
|
4
|
+
addListener(event: string, listener: EventListener): this;
|
|
5
|
+
once(event: string, listener: EventListener): this;
|
|
6
|
+
off(event: string, listener: EventListener): this;
|
|
7
|
+
removeListener(event: string, listener: EventListener): this;
|
|
8
|
+
removeAllListeners(event?: string): this;
|
|
9
|
+
emit(event: string, ...args: unknown[]): boolean;
|
|
10
|
+
listeners(event: string): EventListener[];
|
|
11
|
+
rawListeners(event: string): EventListener[];
|
|
12
|
+
listenerCount(event: string): number;
|
|
13
|
+
eventNames(): string[];
|
|
14
|
+
setMaxListeners(n: number): this;
|
|
15
|
+
getMaxListeners(): number;
|
|
16
|
+
prependListener(event: string, listener: EventListener): this;
|
|
17
|
+
prependOnceListener(event: string, listener: EventListener): this;
|
|
18
|
+
static listenerCount(emitter: EventEmitter, event: string): number;
|
|
19
|
+
static once(emitter: EventEmitter, event: string): Promise<unknown[]>;
|
|
20
|
+
}
|
|
21
|
+
declare const events: typeof EventEmitter & {
|
|
22
|
+
EventEmitter: typeof EventEmitter;
|
|
23
|
+
once: (emitter: EventEmitter, event: string) => Promise<unknown[]>;
|
|
24
|
+
on: (emitter: EventEmitter, event: string) => AsyncIterable<unknown[]>;
|
|
25
|
+
getEventListeners: (emitter: EventEmitter, event: string) => EventListener[];
|
|
26
|
+
listenerCount: (emitter: EventEmitter, event: string) => number;
|
|
27
|
+
};
|
|
28
|
+
export default events;
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import type { MemFS, Stats } from "../memfs";
|
|
2
|
+
export interface FsShim {
|
|
3
|
+
readFileSync: (path: string, encoding?: string | {
|
|
4
|
+
encoding?: string;
|
|
5
|
+
}) => string | Uint8Array;
|
|
6
|
+
writeFileSync: (path: string, data: string | Uint8Array) => void;
|
|
7
|
+
existsSync: (path: string) => boolean;
|
|
8
|
+
mkdirSync: (path: string, options?: {
|
|
9
|
+
recursive?: boolean;
|
|
10
|
+
}) => void;
|
|
11
|
+
readdirSync: (path: string, options?: {
|
|
12
|
+
withFileTypes?: boolean;
|
|
13
|
+
}) => unknown;
|
|
14
|
+
statSync: (path: string) => Stats;
|
|
15
|
+
lstatSync: (path: string) => Stats;
|
|
16
|
+
unlinkSync: (path: string) => void;
|
|
17
|
+
rmdirSync: (path: string, options?: {
|
|
18
|
+
recursive?: boolean;
|
|
19
|
+
}) => void;
|
|
20
|
+
rmSync: (path: string, options?: {
|
|
21
|
+
recursive?: boolean;
|
|
22
|
+
force?: boolean;
|
|
23
|
+
}) => void;
|
|
24
|
+
renameSync: (old: string, n: string) => void;
|
|
25
|
+
copyFileSync: (src: string, dest: string) => void;
|
|
26
|
+
accessSync: (path: string, mode?: number) => void;
|
|
27
|
+
realpathSync: (path: string) => string;
|
|
28
|
+
symlinkSync: (target: string, linkPath: string) => void;
|
|
29
|
+
readlinkSync: (path: string) => string;
|
|
30
|
+
chmodSync: (path: string, mode: number) => void;
|
|
31
|
+
chownSync: (path: string, uid: number, gid: number) => void;
|
|
32
|
+
lchmodSync: (path: string, mode: number) => void;
|
|
33
|
+
lchownSync: (path: string, uid: number, gid: number) => void;
|
|
34
|
+
openSync: (path: string, flags?: string | number) => number;
|
|
35
|
+
closeSync: (fd: number) => void;
|
|
36
|
+
readSync: (fd: number, buffer: Uint8Array, offset: number, length: number, position: number | null) => number;
|
|
37
|
+
writeSync: (fd: number, buffer: Uint8Array, offset: number, length: number, position: number | null) => number;
|
|
38
|
+
fstatSync: (fd: number) => Stats;
|
|
39
|
+
watch: MemFS["watch"];
|
|
40
|
+
createReadStream: MemFS["createReadStream"];
|
|
41
|
+
createWriteStream: MemFS["createWriteStream"];
|
|
42
|
+
readFile: MemFS["readFile"];
|
|
43
|
+
stat: MemFS["stat"];
|
|
44
|
+
lstat: MemFS["lstat"];
|
|
45
|
+
readdir: MemFS["readdir"];
|
|
46
|
+
realpath: MemFS["realpath"];
|
|
47
|
+
access: MemFS["access"];
|
|
48
|
+
promises: {
|
|
49
|
+
readFile: (path: string, encoding?: string | {
|
|
50
|
+
encoding?: string;
|
|
51
|
+
}) => Promise<string | Uint8Array>;
|
|
52
|
+
writeFile: (path: string, data: string | Uint8Array) => Promise<void>;
|
|
53
|
+
mkdir: (path: string, options?: {
|
|
54
|
+
recursive?: boolean;
|
|
55
|
+
}) => Promise<void>;
|
|
56
|
+
readdir: (path: string, options?: {
|
|
57
|
+
withFileTypes?: boolean;
|
|
58
|
+
}) => Promise<unknown>;
|
|
59
|
+
stat: (path: string) => Promise<Stats>;
|
|
60
|
+
lstat: (path: string) => Promise<Stats>;
|
|
61
|
+
unlink: (path: string) => Promise<void>;
|
|
62
|
+
rmdir: (path: string, options?: {
|
|
63
|
+
recursive?: boolean;
|
|
64
|
+
}) => Promise<void>;
|
|
65
|
+
rm: (path: string, options?: {
|
|
66
|
+
recursive?: boolean;
|
|
67
|
+
force?: boolean;
|
|
68
|
+
}) => Promise<void>;
|
|
69
|
+
rename: (old: string, n: string) => Promise<void>;
|
|
70
|
+
access: (path: string, mode?: number) => Promise<void>;
|
|
71
|
+
realpath: (path: string) => Promise<string>;
|
|
72
|
+
copyFile: (src: string, dest: string) => Promise<void>;
|
|
73
|
+
symlink: (target: string, linkPath: string) => Promise<void>;
|
|
74
|
+
readlink: (path: string) => Promise<string>;
|
|
75
|
+
chmod: (path: string, mode: number) => Promise<void>;
|
|
76
|
+
chown: (path: string, uid: number, gid: number) => Promise<void>;
|
|
77
|
+
lchmod: (path: string, mode: number) => Promise<void>;
|
|
78
|
+
lchown: (path: string, uid: number, gid: number) => Promise<void>;
|
|
79
|
+
};
|
|
80
|
+
constants: Record<string, number>;
|
|
81
|
+
}
|
|
82
|
+
export declare function createFsShim(vfs: MemFS, getCwd: () => string): FsShim;
|