@lingxia/rong 0.0.1

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 (82) hide show
  1. package/README.md +59 -0
  2. package/dist/abort.d.ts +36 -0
  3. package/dist/abort.d.ts.map +1 -0
  4. package/dist/abort.js +6 -0
  5. package/dist/assert.d.ts +44 -0
  6. package/dist/assert.d.ts.map +1 -0
  7. package/dist/assert.js +6 -0
  8. package/dist/buffer.d.ts +45 -0
  9. package/dist/buffer.d.ts.map +1 -0
  10. package/dist/buffer.js +6 -0
  11. package/dist/child_process.d.ts +99 -0
  12. package/dist/child_process.d.ts.map +1 -0
  13. package/dist/child_process.js +6 -0
  14. package/dist/console.d.ts +40 -0
  15. package/dist/console.d.ts.map +1 -0
  16. package/dist/console.js +9 -0
  17. package/dist/encoding.d.ts +10 -0
  18. package/dist/encoding.d.ts.map +1 -0
  19. package/dist/encoding.js +10 -0
  20. package/dist/error.d.ts +104 -0
  21. package/dist/error.d.ts.map +1 -0
  22. package/dist/error.js +90 -0
  23. package/dist/event.d.ts +96 -0
  24. package/dist/event.d.ts.map +1 -0
  25. package/dist/event.js +6 -0
  26. package/dist/exception.d.ts +19 -0
  27. package/dist/exception.d.ts.map +1 -0
  28. package/dist/exception.js +6 -0
  29. package/dist/fs.d.ts +450 -0
  30. package/dist/fs.d.ts.map +1 -0
  31. package/dist/fs.js +23 -0
  32. package/dist/global.d.ts +76 -0
  33. package/dist/global.d.ts.map +1 -0
  34. package/dist/global.js +8 -0
  35. package/dist/http.d.ts +117 -0
  36. package/dist/http.d.ts.map +1 -0
  37. package/dist/http.js +9 -0
  38. package/dist/index.d.ts +56 -0
  39. package/dist/index.d.ts.map +1 -0
  40. package/dist/index.js +77 -0
  41. package/dist/navigator.d.ts +16 -0
  42. package/dist/navigator.d.ts.map +1 -0
  43. package/dist/navigator.js +6 -0
  44. package/dist/path.d.ts +70 -0
  45. package/dist/path.d.ts.map +1 -0
  46. package/dist/path.js +6 -0
  47. package/dist/process.d.ts +53 -0
  48. package/dist/process.d.ts.map +1 -0
  49. package/dist/process.js +6 -0
  50. package/dist/storage.d.ts +53 -0
  51. package/dist/storage.d.ts.map +1 -0
  52. package/dist/storage.js +8 -0
  53. package/dist/stream.d.ts +90 -0
  54. package/dist/stream.d.ts.map +1 -0
  55. package/dist/stream.js +90 -0
  56. package/dist/timer.d.ts +52 -0
  57. package/dist/timer.d.ts.map +1 -0
  58. package/dist/timer.js +6 -0
  59. package/dist/url.d.ts +75 -0
  60. package/dist/url.d.ts.map +1 -0
  61. package/dist/url.js +6 -0
  62. package/package.json +27 -0
  63. package/src/abort.ts +50 -0
  64. package/src/assert.ts +51 -0
  65. package/src/buffer.ts +60 -0
  66. package/src/child_process.ts +116 -0
  67. package/src/console.ts +53 -0
  68. package/src/encoding.ts +10 -0
  69. package/src/error.ts +149 -0
  70. package/src/event.ts +128 -0
  71. package/src/exception.ts +77 -0
  72. package/src/fs.ts +514 -0
  73. package/src/global.ts +98 -0
  74. package/src/http.ts +151 -0
  75. package/src/index.ts +67 -0
  76. package/src/navigator.ts +20 -0
  77. package/src/path.ts +83 -0
  78. package/src/process.ts +74 -0
  79. package/src/storage.ts +64 -0
  80. package/src/stream.ts +98 -0
  81. package/src/timer.ts +61 -0
  82. package/src/url.ts +106 -0
package/README.md ADDED
@@ -0,0 +1,59 @@
1
+ # @lingxia/rong
2
+
3
+ TypeScript type definitions for the Rong JavaScript runtime (globals injected by Rust).
4
+
5
+ ## Scope
6
+
7
+ - Provides `.d.ts`/TS sources for the runtime surface so editors/TS can typecheck Rong scripts.
8
+ - Not a runtime polyfill: it does not provide implementations, only types.
9
+
10
+ ## Runtime Export Map (high level)
11
+
12
+ Rong injects a small set of globals:
13
+
14
+ - `Rong` namespace: file system + storage
15
+ - Globals: `process`, `child_process`, `path`, `fetch`, `timers`, `assert`, `atob`, `btoa`
16
+
17
+ Rong also implements/extends a subset of Web APIs; the type package relies on TypeScript’s DOM libs for base types like `URL`, `ReadableStream`, `AbortController`, etc.
18
+
19
+ ## Installation
20
+
21
+ ```bash
22
+ npm install @lingxia/rong
23
+ ```
24
+
25
+ ## Usage (typechecking only)
26
+
27
+ Add to your `tsconfig.json`:
28
+
29
+ ```json
30
+ {
31
+ "compilerOptions": {
32
+ "types": ["@lingxia/rong"]
33
+ }
34
+ }
35
+ ```
36
+
37
+ Notes:
38
+
39
+ - This enables global typings; you should not `import` runtime modules like `'child_process'` or `'http'` (those are Rong globals, not Node modules).
40
+ - Ensure your `tsconfig.json` `lib` includes `"DOM"` if you want DOM globals (e.g. `URL`, `ReadableStream`) to be typed.
41
+
42
+ ## Accuracy notes (common gotchas)
43
+
44
+ - Storage is not `localStorage`-compatible. Use `await Rong.storage.open(path)` or `new Rong.Storage(path)`, then `set/get/delete/clear/list/info`.
45
+ - Directory listing is `Rong.readDir(...)` (async iterator), not `Rong.readdir(...)`.
46
+ - HTTP is the global `fetch(...)` API. There is no `http` namespace and no `download` JS API.
47
+
48
+ ## Development
49
+
50
+ ```bash
51
+ # Install dependencies
52
+ npm install
53
+
54
+ # Build
55
+ npm run build
56
+
57
+ # Watch mode
58
+ npm run watch
59
+ ```
@@ -0,0 +1,36 @@
1
+ /**
2
+ * Abort module type definitions
3
+ * Corresponds to: modules/rong_abort
4
+ */
5
+ import { EventTarget } from './event';
6
+ export interface AbortSignal extends EventTarget {
7
+ /** Whether the signal has been aborted */
8
+ readonly aborted: boolean;
9
+ /** Reason for abort (if any) */
10
+ readonly reason: any;
11
+ /** Abort event handler */
12
+ onabort: ((event: Event) => void) | null;
13
+ /** If the signal has been aborted, throw the abort reason */
14
+ throwIfAborted(): void;
15
+ }
16
+ export interface AbortSignalConstructor {
17
+ prototype: AbortSignal;
18
+ /** Returns an AbortSignal that is aborted when any of the given signals are aborted */
19
+ any(signals: AbortSignal[]): AbortSignal;
20
+ /** Returns an AbortSignal that is already aborted */
21
+ abort(reason?: any): AbortSignal;
22
+ /** Returns an AbortSignal that will abort after the specified milliseconds */
23
+ timeout(milliseconds: number): AbortSignal;
24
+ }
25
+ export interface AbortController {
26
+ /** The AbortSignal associated with this controller */
27
+ readonly signal: AbortSignal;
28
+ /** Abort the associated signal */
29
+ abort(reason?: any): void;
30
+ }
31
+ export interface AbortControllerConstructor {
32
+ new (): AbortController;
33
+ prototype: AbortController;
34
+ }
35
+ export {};
36
+ //# sourceMappingURL=abort.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"abort.d.ts","sourceRoot":"","sources":["../src/abort.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAEtC,MAAM,WAAW,WAAY,SAAQ,WAAW;IAC9C,0CAA0C;IAC1C,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;IAE1B,gCAAgC;IAChC,QAAQ,CAAC,MAAM,EAAE,GAAG,CAAC;IAErB,0BAA0B;IAC1B,OAAO,EAAE,CAAC,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC,GAAG,IAAI,CAAC;IAEzC,6DAA6D;IAC7D,cAAc,IAAI,IAAI,CAAC;CACxB;AAED,MAAM,WAAW,sBAAsB;IACrC,SAAS,EAAE,WAAW,CAAC;IAEvB,uFAAuF;IACvF,GAAG,CAAC,OAAO,EAAE,WAAW,EAAE,GAAG,WAAW,CAAC;IAEzC,qDAAqD;IACrD,KAAK,CAAC,MAAM,CAAC,EAAE,GAAG,GAAG,WAAW,CAAC;IAEjC,8EAA8E;IAC9E,OAAO,CAAC,YAAY,EAAE,MAAM,GAAG,WAAW,CAAC;CAC5C;AAED,MAAM,WAAW,eAAe;IAC9B,sDAAsD;IACtD,QAAQ,CAAC,MAAM,EAAE,WAAW,CAAC;IAE7B,kCAAkC;IAClC,KAAK,CAAC,MAAM,CAAC,EAAE,GAAG,GAAG,IAAI,CAAC;CAC3B;AAED,MAAM,WAAW,0BAA0B;IACzC,QAAO,eAAe,CAAC;IACvB,SAAS,EAAE,eAAe,CAAC;CAC5B;AAID,OAAO,EAAE,CAAC"}
package/dist/abort.js ADDED
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ /**
3
+ * Abort module type definitions
4
+ * Corresponds to: modules/rong_abort
5
+ */
6
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,44 @@
1
+ /**
2
+ * Assert module type definitions
3
+ * Corresponds to: modules/rong_assert
4
+ */
5
+ export type AssertionErrorMessage = string | Error;
6
+ export interface AssertFunction {
7
+ /**
8
+ * Assert that a value is truthy
9
+ * @param value - Value to check
10
+ * @param message - Optional error message
11
+ * @throws Error if value is falsy
12
+ */
13
+ (value: any, message?: AssertionErrorMessage): asserts value;
14
+ /**
15
+ * Assert that a value is truthy (alias)
16
+ * @param value - Value to check
17
+ * @param message - Optional error message
18
+ * @throws Error if value is falsy
19
+ */
20
+ ok(value: any, message?: AssertionErrorMessage): asserts value;
21
+ /**
22
+ * Assert that two values are equal
23
+ * @param left - Left value
24
+ * @param right - Right value
25
+ * @param message - Optional error message
26
+ * @throws Error if values are not equal
27
+ */
28
+ equal(left: any, right: any, message?: AssertionErrorMessage): void;
29
+ /**
30
+ * Force assertion failure
31
+ * @param message - Error message
32
+ * @throws Error always
33
+ */
34
+ fail(message?: AssertionErrorMessage): never;
35
+ /**
36
+ * Assert that a function does not throw
37
+ * @param fn - Function to execute
38
+ * @param message - Optional error message
39
+ * @throws Error if function throws
40
+ */
41
+ doesNotThrow(fn: () => void, message?: AssertionErrorMessage): void;
42
+ }
43
+ export {};
44
+ //# sourceMappingURL=assert.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"assert.d.ts","sourceRoot":"","sources":["../src/assert.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,MAAM,MAAM,qBAAqB,GAAG,MAAM,GAAG,KAAK,CAAC;AAEnD,MAAM,WAAW,cAAc;IAC7B;;;;;OAKG;IACH,CAAC,KAAK,EAAE,GAAG,EAAE,OAAO,CAAC,EAAE,qBAAqB,GAAG,OAAO,CAAC,KAAK,CAAC;IAE7D;;;;;OAKG;IACH,EAAE,CAAC,KAAK,EAAE,GAAG,EAAE,OAAO,CAAC,EAAE,qBAAqB,GAAG,OAAO,CAAC,KAAK,CAAC;IAE/D;;;;;;OAMG;IACH,KAAK,CAAC,IAAI,EAAE,GAAG,EAAE,KAAK,EAAE,GAAG,EAAE,OAAO,CAAC,EAAE,qBAAqB,GAAG,IAAI,CAAC;IAEpE;;;;OAIG;IACH,IAAI,CAAC,OAAO,CAAC,EAAE,qBAAqB,GAAG,KAAK,CAAC;IAE7C;;;;;OAKG;IACH,YAAY,CAAC,EAAE,EAAE,MAAM,IAAI,EAAE,OAAO,CAAC,EAAE,qBAAqB,GAAG,IAAI,CAAC;CACrE;AAGD,OAAO,EAAE,CAAC"}
package/dist/assert.js ADDED
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ /**
3
+ * Assert module type definitions
4
+ * Corresponds to: modules/rong_assert
5
+ */
6
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,45 @@
1
+ /**
2
+ * Buffer module type definitions (Blob and File)
3
+ * Corresponds to: modules/rong_buffer
4
+ */
5
+ export type BlobPart = Blob | ArrayBuffer | ArrayBufferView | string;
6
+ export interface BlobOptions {
7
+ /** MIME type of the blob */
8
+ type?: string;
9
+ /** Line ending normalization: "transparent" (default) or "native" */
10
+ endings?: 'transparent' | 'native';
11
+ }
12
+ export interface Blob {
13
+ /** Blob size in bytes */
14
+ readonly size: number;
15
+ /** MIME type of the blob */
16
+ readonly type: string;
17
+ /** Create a slice of the blob */
18
+ slice(start?: number, end?: number, contentType?: string): Blob;
19
+ /** Get blob contents as ArrayBuffer */
20
+ arrayBuffer(): Promise<ArrayBuffer>;
21
+ /** Get blob contents as text */
22
+ text(): Promise<string>;
23
+ /** Get blob contents as Uint8Array */
24
+ bytes(): Promise<Uint8Array>;
25
+ }
26
+ export interface BlobConstructor {
27
+ new (blobParts?: BlobPart[], options?: BlobOptions): Blob;
28
+ prototype: Blob;
29
+ }
30
+ export interface FileOptions extends BlobOptions {
31
+ /** Last modified timestamp (milliseconds since epoch) */
32
+ lastModified?: number;
33
+ }
34
+ export interface File extends Blob {
35
+ /** File name */
36
+ readonly name: string;
37
+ /** Last modified timestamp (milliseconds since epoch) */
38
+ readonly lastModified: number;
39
+ }
40
+ export interface FileConstructor {
41
+ new (fileBits: BlobPart[], fileName: string, options?: FileOptions): File;
42
+ prototype: File;
43
+ }
44
+ export {};
45
+ //# sourceMappingURL=buffer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"buffer.d.ts","sourceRoot":"","sources":["../src/buffer.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,MAAM,MAAM,QAAQ,GAAG,IAAI,GAAG,WAAW,GAAG,eAAe,GAAG,MAAM,CAAC;AAErE,MAAM,WAAW,WAAW;IAC1B,4BAA4B;IAC5B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,qEAAqE;IACrE,OAAO,CAAC,EAAE,aAAa,GAAG,QAAQ,CAAC;CACpC;AAED,MAAM,WAAW,IAAI;IACnB,yBAAyB;IACzB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAEtB,4BAA4B;IAC5B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAEtB,iCAAiC;IACjC,KAAK,CAAC,KAAK,CAAC,EAAE,MAAM,EAAE,GAAG,CAAC,EAAE,MAAM,EAAE,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAEhE,uCAAuC;IACvC,WAAW,IAAI,OAAO,CAAC,WAAW,CAAC,CAAC;IAEpC,gCAAgC;IAChC,IAAI,IAAI,OAAO,CAAC,MAAM,CAAC,CAAC;IAExB,sCAAsC;IACtC,KAAK,IAAI,OAAO,CAAC,UAAU,CAAC,CAAC;CAC9B;AAED,MAAM,WAAW,eAAe;IAC9B,KAAI,SAAS,CAAC,EAAE,QAAQ,EAAE,EAAE,OAAO,CAAC,EAAE,WAAW,GAAG,IAAI,CAAC;IACzD,SAAS,EAAE,IAAI,CAAC;CACjB;AAED,MAAM,WAAW,WAAY,SAAQ,WAAW;IAC9C,yDAAyD;IACzD,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED,MAAM,WAAW,IAAK,SAAQ,IAAI;IAChC,gBAAgB;IAChB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAEtB,yDAAyD;IACzD,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;CAC/B;AAED,MAAM,WAAW,eAAe;IAC9B,KAAI,QAAQ,EAAE,QAAQ,EAAE,EAAE,QAAQ,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,WAAW,GAAG,IAAI,CAAC;IACzE,SAAS,EAAE,IAAI,CAAC;CACjB;AAID,OAAO,EAAE,CAAC"}
package/dist/buffer.js ADDED
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ /**
3
+ * Buffer module type definitions (Blob and File)
4
+ * Corresponds to: modules/rong_buffer
5
+ */
6
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,99 @@
1
+ /**
2
+ * Child Process module type definitions
3
+ * Corresponds to: modules/rong_child_process
4
+ */
5
+ import type { EventEmitter } from './event';
6
+ export interface SpawnOptions {
7
+ /** Current working directory */
8
+ cwd?: string;
9
+ /** Environment variables */
10
+ env?: Record<string, string>;
11
+ /** Use shell to execute command */
12
+ shell?: boolean;
13
+ /** Timeout in milliseconds */
14
+ timeout?: number;
15
+ }
16
+ export interface ExecOptions {
17
+ /** Current working directory */
18
+ cwd?: string;
19
+ /** Environment variables */
20
+ env?: Record<string, string>;
21
+ /** Timeout in milliseconds */
22
+ timeout?: number;
23
+ }
24
+ export interface ExecResult {
25
+ /** Exit code (null if not yet exited) */
26
+ code: number | null;
27
+ /** Standard output */
28
+ stdout: string;
29
+ /** Standard error */
30
+ stderr: string;
31
+ }
32
+ export interface ChildProcess extends EventEmitter {
33
+ /** Process ID (null if process failed to spawn) */
34
+ readonly pid: number | null;
35
+ /** Exit code (available after process exits) */
36
+ readonly exitCode: number | null;
37
+ /** Standard input stream (if configured as 'piped') */
38
+ readonly stdin: WritableStream<Uint8Array> | null;
39
+ /** Standard output stream (if configured as 'piped') */
40
+ readonly stdout: ReadableStream<Uint8Array> | null;
41
+ /** Standard error stream (if configured as 'piped') */
42
+ readonly stderr: ReadableStream<Uint8Array> | null;
43
+ /**
44
+ * Wait for process to exit
45
+ * @returns Exit code (null if terminated by signal)
46
+ */
47
+ wait(): Promise<number | null>;
48
+ /**
49
+ * Kill the process with a signal
50
+ * @param signal - Signal name (e.g., 'SIGTERM', 'SIGKILL') or number
51
+ * @returns true if signal was sent successfully
52
+ */
53
+ kill(signal?: string): boolean;
54
+ on(event: 'exit', listener: (code: number | null) => void): this;
55
+ once(event: 'exit', listener: (code: number | null) => void): this;
56
+ off(event: 'exit', listener: (code: number | null) => void): this;
57
+ }
58
+ export interface ChildProcessModule {
59
+ /**
60
+ * Spawn a child process
61
+ * @param command - Command to execute
62
+ * @param args - Command arguments (optional)
63
+ * @param options - Spawn options
64
+ *
65
+ * @example
66
+ * ```typescript
67
+ * const child = child_process.spawn('ls', ['-la'], { cwd: '/tmp' });
68
+ * const code = await child.wait();
69
+ * ```
70
+ */
71
+ spawn(command: string, args?: string[], options?: SpawnOptions): ChildProcess;
72
+ /**
73
+ * Execute a shell command and capture output
74
+ * @param command - Shell command to execute
75
+ * @param options - Execution options
76
+ *
77
+ * @example
78
+ * ```typescript
79
+ * const result = await child_process.exec('echo "Hello"', { timeout: 5000 });
80
+ * console.log(result.stdout);
81
+ * ```
82
+ */
83
+ exec(command: string, options?: ExecOptions): Promise<ExecResult>;
84
+ /**
85
+ * Execute a file directly without shell
86
+ * @param file - File path to execute
87
+ * @param args - Command arguments
88
+ * @param options - Execution options
89
+ *
90
+ * @example
91
+ * ```typescript
92
+ * const result = await child_process.execFile('/usr/bin/node', ['--version']);
93
+ * console.log(result.stdout);
94
+ * ```
95
+ */
96
+ execFile(file: string, args?: string[], options?: ExecOptions): Promise<ExecResult>;
97
+ }
98
+ export {};
99
+ //# sourceMappingURL=child_process.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"child_process.d.ts","sourceRoot":"","sources":["../src/child_process.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAE5C,MAAM,WAAW,YAAY;IAC3B,gCAAgC;IAChC,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,4BAA4B;IAC5B,GAAG,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC7B,mCAAmC;IACnC,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,8BAA8B;IAC9B,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,WAAW;IAC1B,gCAAgC;IAChC,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,4BAA4B;IAC5B,GAAG,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC7B,8BAA8B;IAC9B,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,UAAU;IACzB,yCAAyC;IACzC,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IACpB,sBAAsB;IACtB,MAAM,EAAE,MAAM,CAAC;IACf,qBAAqB;IACrB,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,YAAa,SAAQ,YAAY;IAChD,mDAAmD;IACnD,QAAQ,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAAC;IAE5B,gDAAgD;IAChD,QAAQ,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IAEjC,uDAAuD;IACvD,QAAQ,CAAC,KAAK,EAAE,cAAc,CAAC,UAAU,CAAC,GAAG,IAAI,CAAC;IAElD,wDAAwD;IACxD,QAAQ,CAAC,MAAM,EAAE,cAAc,CAAC,UAAU,CAAC,GAAG,IAAI,CAAC;IAEnD,uDAAuD;IACvD,QAAQ,CAAC,MAAM,EAAE,cAAc,CAAC,UAAU,CAAC,GAAG,IAAI,CAAC;IAEnD;;;OAGG;IACH,IAAI,IAAI,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC;IAE/B;;;;OAIG;IACH,IAAI,CAAC,MAAM,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;IAG/B,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,KAAK,IAAI,GAAG,IAAI,CAAC;IACjE,IAAI,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,KAAK,IAAI,GAAG,IAAI,CAAC;IACnE,GAAG,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,KAAK,IAAI,GAAG,IAAI,CAAC;CACnE;AAED,MAAM,WAAW,kBAAkB;IACjC;;;;;;;;;;;OAWG;IACH,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,EAAE,EAAE,OAAO,CAAC,EAAE,YAAY,GAAG,YAAY,CAAC;IAE9E;;;;;;;;;;OAUG;IACH,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;IAElE;;;;;;;;;;;OAWG;IACH,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,EAAE,EAAE,OAAO,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;CACrF;AAGD,OAAO,EAAE,CAAC"}
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ /**
3
+ * Child Process module type definitions
4
+ * Corresponds to: modules/rong_child_process
5
+ */
6
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,40 @@
1
+ /**
2
+ * Console module type definitions
3
+ * Corresponds to: modules/rong_console
4
+ *
5
+ * Note: console is a global object provided by the runtime.
6
+ * This module extends the standard Web Console API.
7
+ */
8
+ export interface Console {
9
+ /** Log messages to stdout */
10
+ log(...args: any[]): void;
11
+ /** Log error messages to stderr */
12
+ error(...args: any[]): void;
13
+ /** Log warning messages to stderr */
14
+ warn(...args: any[]): void;
15
+ /** Log informational messages to stdout */
16
+ info(...args: any[]): void;
17
+ /** Log debug messages to stdout */
18
+ debug(...args: any[]): void;
19
+ /** Clear the console */
20
+ clear(): void;
21
+ }
22
+ export interface ConsoleConstructor {
23
+ new (): Console;
24
+ prototype: Console;
25
+ }
26
+ /**
27
+ * Rong console supports format strings in console.log():
28
+ * - %s - String substitution
29
+ * - %d, %i - Integer substitution
30
+ * - %f - Float substitution
31
+ * - %o - Object inspection
32
+ *
33
+ * Example:
34
+ * console.log("Name: %s, Age: %d", "Alice", 30);
35
+ */
36
+ declare global {
37
+ const Console: ConsoleConstructor;
38
+ }
39
+ export {};
40
+ //# sourceMappingURL=console.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"console.d.ts","sourceRoot":"","sources":["../src/console.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,MAAM,WAAW,OAAO;IACtB,6BAA6B;IAC7B,GAAG,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC;IAE1B,mCAAmC;IACnC,KAAK,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC;IAE5B,qCAAqC;IACrC,IAAI,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC;IAE3B,2CAA2C;IAC3C,IAAI,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC;IAE3B,mCAAmC;IACnC,KAAK,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC;IAE5B,wBAAwB;IACxB,KAAK,IAAI,IAAI,CAAC;CACf;AAED,MAAM,WAAW,kBAAkB;IACjC,QAAO,OAAO,CAAC;IACf,SAAS,EAAE,OAAO,CAAC;CACpB;AAMD;;;;;;;;;GASG;AAEH,OAAO,CAAC,MAAM,CAAC;IACb,MAAM,OAAO,EAAE,kBAAkB,CAAC;CACnC;AAED,OAAO,EAAE,CAAC"}
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ /**
3
+ * Console module type definitions
4
+ * Corresponds to: modules/rong_console
5
+ *
6
+ * Note: console is a global object provided by the runtime.
7
+ * This module extends the standard Web Console API.
8
+ */
9
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Encoding module type definitions
3
+ * Corresponds to: modules/rong_encoding
4
+ *
5
+ * Note: TextEncoder and TextDecoder are provided by the global environment
6
+ * and match the Web API specification. No custom type definitions needed.
7
+ * These types are available globally when "DOM" is included in tsconfig.json lib.
8
+ */
9
+ export {};
10
+ //# sourceMappingURL=encoding.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"encoding.d.ts","sourceRoot":"","sources":["../src/encoding.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,CAAC"}
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ /**
3
+ * Encoding module type definitions
4
+ * Corresponds to: modules/rong_encoding
5
+ *
6
+ * Note: TextEncoder and TextDecoder are provided by the global environment
7
+ * and match the Web API specification. No custom type definitions needed.
8
+ * These types are available globally when "DOM" is included in tsconfig.json lib.
9
+ */
10
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,104 @@
1
+ /**
2
+ * Error type definitions for Rong runtime
3
+ *
4
+ * Rong can throw:
5
+ * - standard JS `Error` objects (including `TypeError`, `RangeError`, etc.)
6
+ * - `DOMException` instances for Abort-related errors (e.g. `AbortError`)
7
+ *
8
+ * This module provides type guards and utilities for error handling.
9
+ */
10
+ /**
11
+ * Common error names used throughout the Rong runtime (as `error.name`).
12
+ */
13
+ export type RongErrorName = 'Error' | 'TypeError' | 'RangeError' | 'ReferenceError' | 'AbortError' | 'NetworkError';
14
+ /**
15
+ * Base error interface for Rong runtime errors.
16
+ */
17
+ export interface RongError extends Error {
18
+ /** Error name identifying the error type */
19
+ readonly name: RongErrorName;
20
+ /** Human-readable error message */
21
+ readonly message: string;
22
+ /** Stable Rong error code (e.g. "E_IO", "E_TIMEOUT", ...) when available */
23
+ readonly code?: string;
24
+ /** Optional structured error data when provided by the runtime */
25
+ readonly data?: unknown;
26
+ /** Stack trace (if available) */
27
+ readonly stack?: string;
28
+ }
29
+ /**
30
+ * Error thrown when an operation is aborted via AbortSignal.
31
+ *
32
+ * @example
33
+ * ```typescript
34
+ * const controller = new AbortController();
35
+ * setTimeout(() => controller.abort(), 1000);
36
+ *
37
+ * try {
38
+ * await Rong.readTextFile('/large-file.txt', {
39
+ * signal: controller.signal
40
+ * });
41
+ * } catch (error) {
42
+ * if (isAbortError(error)) {
43
+ * console.log('Operation cancelled');
44
+ * }
45
+ * }
46
+ * ```
47
+ */
48
+ export interface AbortError extends RongError {
49
+ readonly name: 'AbortError';
50
+ }
51
+ export interface NetworkError extends RongError {
52
+ readonly name: 'NetworkError';
53
+ }
54
+ /**
55
+ * Type guard to check if an error is a Rong runtime error.
56
+ *
57
+ * @param error - The error to check
58
+ * @returns true if the error is a RongError
59
+ *
60
+ * @example
61
+ * ```typescript
62
+ * try {
63
+ * await Rong.readTextFile('/file.txt');
64
+ * } catch (error) {
65
+ * if (isRongError(error)) {
66
+ * console.error(`Rong error [${error.name}]: ${error.message}`);
67
+ * }
68
+ * }
69
+ * ```
70
+ */
71
+ export declare function isRongError(error: unknown): error is RongError;
72
+ /**
73
+ * Type guard to check if an error is an AbortError.
74
+ */
75
+ export declare function isAbortError(error: unknown): error is AbortError;
76
+ /**
77
+ * Type guard to check if an error is a NetworkError.
78
+ */
79
+ export declare function isNetworkError(error: unknown): error is NetworkError;
80
+ /**
81
+ * Get a human-readable error message from any error.
82
+ *
83
+ * @param error - The error to format
84
+ * @returns Formatted error message
85
+ *
86
+ * @example
87
+ * ```typescript
88
+ * try {
89
+ * await someOperation();
90
+ * } catch (error) {
91
+ * console.error(formatError(error));
92
+ * }
93
+ * ```
94
+ */
95
+ export declare function formatError(error: unknown): string;
96
+ /**
97
+ * Assert that a value is a RongError, throwing if not.
98
+ *
99
+ * @param error - The value to check
100
+ * @throws {TypeError} If the value is not a RongError
101
+ */
102
+ export declare function assertRongError(error: unknown): asserts error is RongError;
103
+ export {};
104
+ //# sourceMappingURL=error.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"error.d.ts","sourceRoot":"","sources":["../src/error.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH;;GAEG;AACH,MAAM,MAAM,aAAa,GACrB,OAAO,GACP,WAAW,GACX,YAAY,GACZ,gBAAgB,GAChB,YAAY,GACZ,cAAc,CAAC;AAEnB;;GAEG;AACH,MAAM,WAAW,SAAU,SAAQ,KAAK;IACtC,4CAA4C;IAC5C,QAAQ,CAAC,IAAI,EAAE,aAAa,CAAC;IAE7B,mCAAmC;IACnC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IAEzB,4EAA4E;IAC5E,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IAEvB,kEAAkE;IAClE,QAAQ,CAAC,IAAI,CAAC,EAAE,OAAO,CAAC;IAExB,iCAAiC;IACjC,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;CACzB;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,WAAW,UAAW,SAAQ,SAAS;IAC3C,QAAQ,CAAC,IAAI,EAAE,YAAY,CAAC;CAC7B;AAED,MAAM,WAAW,YAAa,SAAQ,SAAS;IAC7C,QAAQ,CAAC,IAAI,EAAE,cAAc,CAAC;CAC/B;AAID;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,SAAS,CAG9D;AAED;;GAEG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,UAAU,CAGhE;AAED;;GAEG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,YAAY,CAGpE;AAID;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CASlD;AAED;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAAC,KAAK,IAAI,SAAS,CAI1E;AAED,OAAO,EAAE,CAAC"}
package/dist/error.js ADDED
@@ -0,0 +1,90 @@
1
+ "use strict";
2
+ /**
3
+ * Error type definitions for Rong runtime
4
+ *
5
+ * Rong can throw:
6
+ * - standard JS `Error` objects (including `TypeError`, `RangeError`, etc.)
7
+ * - `DOMException` instances for Abort-related errors (e.g. `AbortError`)
8
+ *
9
+ * This module provides type guards and utilities for error handling.
10
+ */
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.assertRongError = exports.formatError = exports.isNetworkError = exports.isAbortError = exports.isRongError = void 0;
13
+ // ==================== Type Guards ====================
14
+ /**
15
+ * Type guard to check if an error is a Rong runtime error.
16
+ *
17
+ * @param error - The error to check
18
+ * @returns true if the error is a RongError
19
+ *
20
+ * @example
21
+ * ```typescript
22
+ * try {
23
+ * await Rong.readTextFile('/file.txt');
24
+ * } catch (error) {
25
+ * if (isRongError(error)) {
26
+ * console.error(`Rong error [${error.name}]: ${error.message}`);
27
+ * }
28
+ * }
29
+ * ```
30
+ */
31
+ function isRongError(error) {
32
+ return (error instanceof Error || error instanceof DOMException) &&
33
+ typeof error.name === 'string';
34
+ }
35
+ exports.isRongError = isRongError;
36
+ /**
37
+ * Type guard to check if an error is an AbortError.
38
+ */
39
+ function isAbortError(error) {
40
+ return (error instanceof Error || error instanceof DOMException) &&
41
+ error.name === 'AbortError';
42
+ }
43
+ exports.isAbortError = isAbortError;
44
+ /**
45
+ * Type guard to check if an error is a NetworkError.
46
+ */
47
+ function isNetworkError(error) {
48
+ return (error instanceof Error || error instanceof DOMException) &&
49
+ error.name === 'NetworkError';
50
+ }
51
+ exports.isNetworkError = isNetworkError;
52
+ // ==================== Utility Functions ====================
53
+ /**
54
+ * Get a human-readable error message from any error.
55
+ *
56
+ * @param error - The error to format
57
+ * @returns Formatted error message
58
+ *
59
+ * @example
60
+ * ```typescript
61
+ * try {
62
+ * await someOperation();
63
+ * } catch (error) {
64
+ * console.error(formatError(error));
65
+ * }
66
+ * ```
67
+ */
68
+ function formatError(error) {
69
+ if (isRongError(error)) {
70
+ const code = error.code ? ` ${error.code}` : '';
71
+ return `[${error.name}${code}] ${error.message}`;
72
+ }
73
+ if (error instanceof Error) {
74
+ return error.message;
75
+ }
76
+ return String(error);
77
+ }
78
+ exports.formatError = formatError;
79
+ /**
80
+ * Assert that a value is a RongError, throwing if not.
81
+ *
82
+ * @param error - The value to check
83
+ * @throws {TypeError} If the value is not a RongError
84
+ */
85
+ function assertRongError(error) {
86
+ if (!isRongError(error)) {
87
+ throw new TypeError('Expected RongError');
88
+ }
89
+ }
90
+ exports.assertRongError = assertRongError;