@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.
Files changed (152) hide show
  1. package/dist/browser-bundle.d.ts +40 -0
  2. package/dist/builtins.d.ts +22 -0
  3. package/dist/code-transform.d.ts +7 -0
  4. package/dist/config/cdn.d.ts +13 -0
  5. package/dist/container.d.ts +101 -0
  6. package/dist/dev-server.d.ts +69 -0
  7. package/dist/errors.d.ts +19 -0
  8. package/dist/frameworks/code-transforms.d.ts +32 -0
  9. package/dist/frameworks/next-api-handler.d.ts +72 -0
  10. package/dist/frameworks/next-dev-server.d.ts +141 -0
  11. package/dist/frameworks/next-html-generator.d.ts +36 -0
  12. package/dist/frameworks/next-route-resolver.d.ts +19 -0
  13. package/dist/frameworks/next-shims.d.ts +78 -0
  14. package/dist/frameworks/remix-dev-server.d.ts +47 -0
  15. package/dist/frameworks/sveltekit-dev-server.d.ts +43 -0
  16. package/dist/frameworks/vite-dev-server.d.ts +50 -0
  17. package/dist/fs-errors.d.ts +36 -0
  18. package/dist/index.cjs +14916 -0
  19. package/dist/index.cjs.map +1 -0
  20. package/dist/index.d.ts +61 -0
  21. package/dist/index.mjs +14898 -0
  22. package/dist/index.mjs.map +1 -0
  23. package/dist/kernel.d.ts +48 -0
  24. package/dist/memfs.d.ts +144 -0
  25. package/dist/metrics.d.ts +78 -0
  26. package/dist/module-resolver.d.ts +60 -0
  27. package/dist/network-interceptor.d.ts +71 -0
  28. package/dist/npm/cache.d.ts +76 -0
  29. package/dist/npm/index.d.ts +60 -0
  30. package/dist/npm/lockfile-reader.d.ts +32 -0
  31. package/dist/npm/pnpm.d.ts +18 -0
  32. package/dist/npm/registry.d.ts +45 -0
  33. package/dist/npm/resolver.d.ts +39 -0
  34. package/dist/npm/sync-installer.d.ts +18 -0
  35. package/dist/npm/tarball.d.ts +4 -0
  36. package/dist/npm/workspaces.d.ts +46 -0
  37. package/dist/persistence.d.ts +94 -0
  38. package/dist/plugin.d.ts +156 -0
  39. package/dist/polyfills/assert.d.ts +30 -0
  40. package/dist/polyfills/child_process.d.ts +116 -0
  41. package/dist/polyfills/chokidar.d.ts +18 -0
  42. package/dist/polyfills/crypto.d.ts +49 -0
  43. package/dist/polyfills/events.d.ts +28 -0
  44. package/dist/polyfills/fs.d.ts +82 -0
  45. package/dist/polyfills/http.d.ts +147 -0
  46. package/dist/polyfills/module.d.ts +29 -0
  47. package/dist/polyfills/net.d.ts +53 -0
  48. package/dist/polyfills/os.d.ts +91 -0
  49. package/dist/polyfills/path.d.ts +96 -0
  50. package/dist/polyfills/perf_hooks.d.ts +21 -0
  51. package/dist/polyfills/process.d.ts +99 -0
  52. package/dist/polyfills/querystring.d.ts +15 -0
  53. package/dist/polyfills/readdirp.d.ts +18 -0
  54. package/dist/polyfills/readline.d.ts +32 -0
  55. package/dist/polyfills/stream.d.ts +106 -0
  56. package/dist/polyfills/stubs.d.ts +737 -0
  57. package/dist/polyfills/tty.d.ts +25 -0
  58. package/dist/polyfills/url.d.ts +41 -0
  59. package/dist/polyfills/util.d.ts +61 -0
  60. package/dist/polyfills/v8.d.ts +43 -0
  61. package/dist/polyfills/vm.d.ts +76 -0
  62. package/dist/polyfills/worker-threads.d.ts +77 -0
  63. package/dist/polyfills/ws.d.ts +32 -0
  64. package/dist/polyfills/zlib.d.ts +87 -0
  65. package/dist/runtime-helpers.d.ts +4 -0
  66. package/dist/runtime-interface.d.ts +39 -0
  67. package/dist/sandbox.d.ts +69 -0
  68. package/dist/server-bridge.d.ts +55 -0
  69. package/dist/shell-commands.d.ts +2 -0
  70. package/dist/shell.d.ts +101 -0
  71. package/dist/transpiler.d.ts +47 -0
  72. package/dist/type-checker.d.ts +57 -0
  73. package/dist/types/package-json.d.ts +17 -0
  74. package/dist/utils/binary-encoding.d.ts +4 -0
  75. package/dist/utils/hash.d.ts +6 -0
  76. package/dist/utils/safe-path.d.ts +6 -0
  77. package/dist/worker-runtime.d.ts +34 -0
  78. package/package.json +59 -0
  79. package/src/browser-bundle.ts +498 -0
  80. package/src/builtins.ts +222 -0
  81. package/src/code-transform.ts +183 -0
  82. package/src/config/cdn.ts +17 -0
  83. package/src/container.ts +343 -0
  84. package/src/dev-server.ts +322 -0
  85. package/src/errors.ts +604 -0
  86. package/src/frameworks/code-transforms.ts +667 -0
  87. package/src/frameworks/next-api-handler.ts +366 -0
  88. package/src/frameworks/next-dev-server.ts +1252 -0
  89. package/src/frameworks/next-html-generator.ts +585 -0
  90. package/src/frameworks/next-route-resolver.ts +521 -0
  91. package/src/frameworks/next-shims.ts +1084 -0
  92. package/src/frameworks/remix-dev-server.ts +163 -0
  93. package/src/frameworks/sveltekit-dev-server.ts +197 -0
  94. package/src/frameworks/vite-dev-server.ts +370 -0
  95. package/src/fs-errors.ts +118 -0
  96. package/src/index.ts +188 -0
  97. package/src/kernel.ts +381 -0
  98. package/src/memfs.ts +1006 -0
  99. package/src/metrics.ts +140 -0
  100. package/src/module-resolver.ts +511 -0
  101. package/src/network-interceptor.ts +143 -0
  102. package/src/npm/cache.ts +172 -0
  103. package/src/npm/index.ts +377 -0
  104. package/src/npm/lockfile-reader.ts +105 -0
  105. package/src/npm/pnpm.ts +108 -0
  106. package/src/npm/registry.ts +120 -0
  107. package/src/npm/resolver.ts +339 -0
  108. package/src/npm/sync-installer.ts +217 -0
  109. package/src/npm/tarball.ts +136 -0
  110. package/src/npm/workspaces.ts +255 -0
  111. package/src/persistence.ts +235 -0
  112. package/src/plugin.ts +293 -0
  113. package/src/polyfills/assert.ts +164 -0
  114. package/src/polyfills/child_process.ts +535 -0
  115. package/src/polyfills/chokidar.ts +52 -0
  116. package/src/polyfills/crypto.ts +433 -0
  117. package/src/polyfills/events.ts +178 -0
  118. package/src/polyfills/fs.ts +297 -0
  119. package/src/polyfills/http.ts +478 -0
  120. package/src/polyfills/module.ts +97 -0
  121. package/src/polyfills/net.ts +123 -0
  122. package/src/polyfills/os.ts +108 -0
  123. package/src/polyfills/path.ts +169 -0
  124. package/src/polyfills/perf_hooks.ts +30 -0
  125. package/src/polyfills/process.ts +349 -0
  126. package/src/polyfills/querystring.ts +66 -0
  127. package/src/polyfills/readdirp.ts +72 -0
  128. package/src/polyfills/readline.ts +80 -0
  129. package/src/polyfills/stream.ts +610 -0
  130. package/src/polyfills/stubs.ts +600 -0
  131. package/src/polyfills/tty.ts +43 -0
  132. package/src/polyfills/url.ts +97 -0
  133. package/src/polyfills/util.ts +173 -0
  134. package/src/polyfills/v8.ts +62 -0
  135. package/src/polyfills/vm.ts +111 -0
  136. package/src/polyfills/worker-threads.ts +189 -0
  137. package/src/polyfills/ws.ts +73 -0
  138. package/src/polyfills/zlib.ts +244 -0
  139. package/src/runtime-helpers.ts +83 -0
  140. package/src/runtime-interface.ts +46 -0
  141. package/src/sandbox.ts +178 -0
  142. package/src/server-bridge.ts +473 -0
  143. package/src/service-worker.ts +153 -0
  144. package/src/shell-commands.ts +708 -0
  145. package/src/shell.ts +795 -0
  146. package/src/transpiler.ts +282 -0
  147. package/src/type-checker.ts +241 -0
  148. package/src/types/package-json.ts +17 -0
  149. package/src/utils/binary-encoding.ts +38 -0
  150. package/src/utils/hash.ts +24 -0
  151. package/src/utils/safe-path.ts +38 -0
  152. 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
+ };