@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
@@ -0,0 +1,96 @@
1
+ /**
2
+ * Event module type definitions
3
+ * Corresponds to: modules/rong_event
4
+ */
5
+ export interface EventOptions {
6
+ /** Whether the event bubbles */
7
+ bubbles?: boolean;
8
+ /** Whether the event can be cancelled */
9
+ cancelable?: boolean;
10
+ /** Whether the event can cross shadow DOM boundaries */
11
+ composed?: boolean;
12
+ }
13
+ export interface Event {
14
+ /** Event type name */
15
+ readonly type: string;
16
+ /** Whether the event bubbles */
17
+ readonly bubbles: boolean;
18
+ /** Whether the event can be cancelled */
19
+ readonly cancelable: boolean;
20
+ /** Whether the event can cross shadow DOM boundaries */
21
+ readonly composed: boolean;
22
+ }
23
+ export interface EventConstructor {
24
+ new (type: string, options?: EventOptions): Event;
25
+ prototype: Event;
26
+ }
27
+ export interface CustomEventOptions extends EventOptions {
28
+ /** Custom data associated with the event */
29
+ detail?: any;
30
+ }
31
+ export interface CustomEvent extends Event {
32
+ /** Custom data associated with the event */
33
+ readonly detail: any;
34
+ }
35
+ export interface CustomEventConstructor {
36
+ new (type: string, options?: CustomEventOptions): CustomEvent;
37
+ prototype: CustomEvent;
38
+ }
39
+ export type EventListener = (event: Event) => void;
40
+ export interface AddEventListenerOptions {
41
+ /** Remove listener after first invocation */
42
+ once?: boolean;
43
+ /** Use capture phase */
44
+ capture?: boolean;
45
+ /** Listener is passive (won't call preventDefault) */
46
+ passive?: boolean;
47
+ }
48
+ export interface EventTarget {
49
+ /** Add event listener (Web standard) */
50
+ addEventListener(type: string, listener: EventListener, options?: boolean | AddEventListenerOptions): void;
51
+ /** Remove event listener (Web standard) */
52
+ removeEventListener(type: string, listener: EventListener, options?: boolean | AddEventListenerOptions): void;
53
+ /** Dispatch event (Web standard) */
54
+ dispatchEvent(event: Event): boolean;
55
+ }
56
+ export interface EventTargetConstructor {
57
+ new (): EventTarget;
58
+ prototype: EventTarget;
59
+ }
60
+ export type EventName = string | symbol;
61
+ export type EventEmitterListener = (...args: any[]) => void;
62
+ export interface EventEmitter extends EventTarget {
63
+ /** Add event listener (Node.js style) */
64
+ on(eventName: EventName, listener: EventEmitterListener): this;
65
+ /** Add one-time event listener */
66
+ once(eventName: EventName, listener: EventEmitterListener): this;
67
+ /** Remove event listener */
68
+ off(eventName: EventName, listener: EventEmitterListener): this;
69
+ /** Remove event listener (alias for off) */
70
+ removeListener(eventName: EventName, listener: EventEmitterListener): this;
71
+ /** Remove all listeners for an event */
72
+ removeAllListeners(eventName?: EventName): this;
73
+ /** Add listener at the beginning of the listeners array */
74
+ prependListener(eventName: EventName, listener: EventEmitterListener): this;
75
+ /** Add one-time listener at the beginning of the listeners array */
76
+ prependOnceListener(eventName: EventName, listener: EventEmitterListener): this;
77
+ /** Emit an event */
78
+ emit(eventName: EventName, ...args: any[]): boolean;
79
+ /** Get array of registered event names */
80
+ eventNames(): EventName[];
81
+ /** Set maximum number of listeners per event (default: 10) */
82
+ setMaxListeners(n: number): this;
83
+ /** Get maximum number of listeners per event */
84
+ getMaxListeners(): number;
85
+ /** Get number of listeners for an event, optionally filtered by a specific listener */
86
+ listenerCount(eventName: EventName, listener?: EventEmitterListener): number;
87
+ }
88
+ export interface EventEmitterConstructor {
89
+ new (): EventEmitter;
90
+ prototype: EventEmitter;
91
+ }
92
+ declare global {
93
+ const EventEmitter: EventEmitterConstructor;
94
+ }
95
+ export {};
96
+ //# sourceMappingURL=event.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"event.d.ts","sourceRoot":"","sources":["../src/event.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,MAAM,WAAW,YAAY;IAC3B,gCAAgC;IAChC,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,yCAAyC;IACzC,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,wDAAwD;IACxD,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED,MAAM,WAAW,KAAK;IACpB,sBAAsB;IACtB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAEtB,gCAAgC;IAChC,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;IAE1B,yCAAyC;IACzC,QAAQ,CAAC,UAAU,EAAE,OAAO,CAAC;IAE7B,wDAAwD;IACxD,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC;CAC5B;AAED,MAAM,WAAW,gBAAgB;IAC/B,KAAI,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,YAAY,GAAG,KAAK,CAAC;IACjD,SAAS,EAAE,KAAK,CAAC;CAClB;AAED,MAAM,WAAW,kBAAmB,SAAQ,YAAY;IACtD,4CAA4C;IAC5C,MAAM,CAAC,EAAE,GAAG,CAAC;CACd;AAED,MAAM,WAAW,WAAY,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*/
6
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Exception module type definitions
3
+ * Corresponds to: modules/rong_exception
4
+ */
5
+ export type DOMExceptionName = 'IndexSizeError' | 'DOMStringSizeError' | 'HierarchyRequestError' | 'InvalidCharacterError' | 'NoDataAllowedError' | 'NoModificationAllowedError' | 'NotFoundError' | 'NotSupportedError' | 'InUseAttributeError' | 'InvalidStateError' | 'SyntaxError' | 'InvalidModificationError' | 'NamespaceError' | 'InvalidAccessError' | 'ValidationError' | 'TypeMismatchError' | 'SecurityError' | 'NetworkError' | 'AbortError' | 'URLMismatchError' | 'QuotaExceededError' | 'TimeoutError' | 'InvalidNodeTypeError' | 'DataCloneError' | 'Error' | 'INDEX_SIZE_ERR' | 'DOMSTRING_SIZE_ERR' | 'HIERARCHY_REQUEST_ERR' | 'INVALID_CHARACTER_ERR' | 'NO_DATA_ALLOWED_ERR' | 'NO_MODIFICATION_ALLOWED_ERR' | 'NOT_FOUND_ERR' | 'NOT_SUPPORTED_ERR' | 'INUSE_ATTRIBUTE_ERR' | 'INVALID_STATE_ERR' | 'SYNTAX_ERR' | 'INVALID_MODIFICATION_ERR' | 'NAMESPACE_ERR' | 'INVALID_ACCESS_ERR' | 'VALIDATION_ERR' | 'TYPE_MISMATCH_ERR' | 'SECURITY_ERR' | 'NETWORK_ERR' | 'ABORT_ERR' | 'URL_MISMATCH_ERR' | 'QUOTA_EXCEEDED_ERR' | 'TIMEOUT_ERR' | 'INVALID_NODE_TYPE_ERR' | 'DATA_CLONE_ERR' | 'ERROR';
6
+ export interface DOMException extends Error {
7
+ /** Error name */
8
+ readonly name: string;
9
+ /** Error message */
10
+ readonly message: string;
11
+ /** Stack trace (currently returns "NotImplemented") */
12
+ readonly stack: string;
13
+ }
14
+ export interface DOMExceptionConstructor {
15
+ new (message?: string, name?: DOMExceptionName): DOMException;
16
+ prototype: DOMException;
17
+ }
18
+ export {};
19
+ //# sourceMappingURL=exception.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"exception.d.ts","sourceRoot":"","sources":["../src/exception.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,MAAM,MAAM,gBAAgB,GACxB,gBAAgB,GAChB,oBAAoB,GACpB,uBAAuB,GACvB,uBAAuB,GACvB,oBAAoB,GACpB,4BAA4B,GAC5B,eAAe,GACf,mBAAmB,GACnB,qBAAqB,GACrB,mBAAmB,GACnB,aAAa,GACb,0BAA0B,GAC1B,gBAAgB,GAChB,oBAAoB,GACpB,iBAAiB,GACjB,mBAAmB,GACnB,eAAe,GACf,cAAc,GACd,YAAY,GACZ,kBAAkB,GAClB,oBAAoB,GACpB,cAAc,GACd,sBAAsB,GACtB,gBAAgB,GAChB,OAAO,GAEP,gBAAgB,GAChB,oBAAoB,GACpB,uBAAuB,GACvB,uBAAuB,GACvB,qBAAqB,GACrB,6BAA6B,GAC7B,eAAe,GACf,mBAAmB,GACnB,qBAAqB,GACrB,mBAAmB,GACnB,YAAY,GACZ,0BAA0B,GAC1B,eAAe,GACf,oBAAoB,GACpB,gBAAgB,GAChB,mBAAmB,GACnB,cAAc,GACd,aAAa,GACb,WAAW,GACX,kBAAkB,GAClB,oBAAoB,GACpB,aAAa,GACb,uBAAuB,GACvB,gBAAgB,GAChB,OAAO,CAAC;AAEZ,MAAM,WAAW,YAAa,SAAQ,KAAK;IACzC,iBAAiB;IACjB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAEtB,oBAAoB;IACpB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IAEzB,uDAAuD;IACvD,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;CACxB;AAED,MAAM,WAAW,uBAAuB;IACtC,KAAI,OAAO,CAAC,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,gBAAgB,GAAG,YAAY,CAAC;IAC7D,SAAS,EAAE,YAAY,CAAC;CACzB;AAID,OAAO,EAAE,CAAC"}
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ /**
3
+ * Exception module type definitions
4
+ * Corresponds to: modules/rong_exception
5
+ */
6
+ Object.defineProperty(exports, "__esModule", { value: true });
package/dist/fs.d.ts ADDED
@@ -0,0 +1,450 @@
1
+ /**
2
+ * File System module type definitions
3
+ * Corresponds to: modules/rong_fs
4
+ *
5
+ * Provides APIs for file system operations including reading, writing, and directory management.
6
+ * All file system APIs are mounted under the global `Rong` namespace.
7
+ */
8
+ /**
9
+ * Options for reading files.
10
+ */
11
+ export interface ReadFileOptions {
12
+ /**
13
+ * AbortSignal to cancel the read operation.
14
+ * When aborted, the operation will throw an AbortError.
15
+ *
16
+ * @see {@link AbortSignal}
17
+ * @example
18
+ * ```typescript
19
+ * const controller = new AbortController();
20
+ * const promise = Rong.readTextFile('/file.txt', {
21
+ * signal: controller.signal
22
+ * });
23
+ * // Cancel after 1 second
24
+ * setTimeout(() => controller.abort(), 1000);
25
+ * ```
26
+ */
27
+ signal?: AbortSignal;
28
+ }
29
+ /**
30
+ * Options for writing files.
31
+ */
32
+ export interface WriteFileOptions {
33
+ /**
34
+ * Append to file instead of overwriting.
35
+ * Cannot be used together with `createNew`.
36
+ *
37
+ * @default false
38
+ */
39
+ append?: boolean;
40
+ /**
41
+ * Create file only if it doesn't exist.
42
+ * Throws AlreadyExistsError if the file already exists.
43
+ * Cannot be used together with `append`.
44
+ *
45
+ * @default false
46
+ * @throws {AlreadyExistsError} If file already exists
47
+ */
48
+ createNew?: boolean;
49
+ /**
50
+ * File permissions mode (Unix-like systems only).
51
+ * Octal number (e.g., 0o644 for rw-r--r--).
52
+ * Ignored on Windows.
53
+ *
54
+ * @default 0o666 (modified by process umask)
55
+ * @platform unix
56
+ * @example
57
+ * ```typescript
58
+ * await Rong.writeTextFile('/script.sh', '#!/bin/bash\necho hello', {
59
+ * mode: 0o755 // rwxr-xr-x
60
+ * });
61
+ * ```
62
+ */
63
+ mode?: number;
64
+ /**
65
+ * AbortSignal to cancel the write operation.
66
+ *
67
+ * @see {@link AbortSignal}
68
+ */
69
+ signal?: AbortSignal;
70
+ }
71
+ /**
72
+ * Options for opening files.
73
+ */
74
+ export interface FileOpenOptions {
75
+ /**
76
+ * Open file for reading.
77
+ * @default false
78
+ */
79
+ read?: boolean;
80
+ /**
81
+ * Open file for writing.
82
+ * @default false
83
+ */
84
+ write?: boolean;
85
+ /**
86
+ * Open file for appending (writes go to end of file).
87
+ * @default false
88
+ */
89
+ append?: boolean;
90
+ /**
91
+ * Truncate file to 0 bytes when opening (if it exists).
92
+ * Only valid when `write` is true.
93
+ * @default false
94
+ */
95
+ truncate?: boolean;
96
+ /**
97
+ * Create file if it doesn't exist.
98
+ * Only valid when `write` is true.
99
+ * @default false
100
+ */
101
+ create?: boolean;
102
+ /**
103
+ * Create file only if it doesn't exist (exclusive creation).
104
+ * Throws AlreadyExistsError if file exists.
105
+ * Only valid when `write` is true.
106
+ *
107
+ * @default false
108
+ * @throws {AlreadyExistsError} If file already exists
109
+ */
110
+ createNew?: boolean;
111
+ /**
112
+ * File permissions mode (Unix-like systems only).
113
+ * @default 0o666 (modified by process umask)
114
+ * @platform unix
115
+ */
116
+ mode?: number;
117
+ }
118
+ /**
119
+ * Options for creating directories.
120
+ */
121
+ export interface MkdirOptions {
122
+ /**
123
+ * Create parent directories as needed.
124
+ * If false and parent doesn't exist, throws NotFoundError.
125
+ *
126
+ * @default false
127
+ * @throws {NotFoundError} If parent doesn't exist and recursive is false
128
+ * @example
129
+ * ```typescript
130
+ * // Create nested directories
131
+ * await Rong.mkdir('/path/to/nested/dir', { recursive: true });
132
+ * ```
133
+ */
134
+ recursive?: boolean;
135
+ /**
136
+ * Directory permissions mode (Unix-like systems only).
137
+ * @default 0o777 (modified by process umask)
138
+ * @platform unix
139
+ */
140
+ mode?: number;
141
+ }
142
+ /**
143
+ * Options for removing files and directories.
144
+ */
145
+ export interface RemoveOptions {
146
+ /**
147
+ * Remove directories and their contents recursively.
148
+ * If false and path is a non-empty directory, throws an error.
149
+ *
150
+ * @default false
151
+ * @example
152
+ * ```typescript
153
+ * // Remove directory and all its contents
154
+ * await Rong.remove('/path/to/dir', { recursive: true });
155
+ * ```
156
+ */
157
+ recursive?: boolean;
158
+ }
159
+ /**
160
+ * Options for setting file timestamps via {@link FsModule.utime}.
161
+ */
162
+ export interface UTimeOptions {
163
+ /**
164
+ * Access time in milliseconds since Unix epoch.
165
+ * If omitted, defaults to "now" (runtime-dependent).
166
+ */
167
+ accessed?: number;
168
+ /**
169
+ * Modified time in milliseconds since Unix epoch.
170
+ * If omitted, defaults to "now" (runtime-dependent).
171
+ */
172
+ modified?: number;
173
+ }
174
+ /**
175
+ * File or directory metadata information.
176
+ * Returned by `stat()` and `lstat()` functions.
177
+ */
178
+ export interface FileInfo {
179
+ /**
180
+ * Whether this is a regular file.
181
+ * Mutually exclusive with `isDirectory` and `isSymlink`.
182
+ */
183
+ readonly isFile: boolean;
184
+ /**
185
+ * Whether this is a directory.
186
+ * Mutually exclusive with `isFile` and `isSymlink`.
187
+ */
188
+ readonly isDirectory: boolean;
189
+ /**
190
+ * Whether this is a symbolic link.
191
+ * For symbolic links, use `lstat()` instead of `stat()`
192
+ * to get link information rather than target information.
193
+ */
194
+ readonly isSymlink: boolean;
195
+ /**
196
+ * File size in bytes.
197
+ * For directories, this is the size of the directory entry, not its contents.
198
+ */
199
+ readonly size: number;
200
+ /**
201
+ * Last modified time in milliseconds since Unix epoch.
202
+ * May be undefined if not supported by the file system.
203
+ */
204
+ readonly modified?: number;
205
+ /**
206
+ * Last accessed time in milliseconds since Unix epoch.
207
+ * May be undefined if not supported by the file system.
208
+ */
209
+ readonly accessed?: number;
210
+ /**
211
+ * Creation time in milliseconds since Unix epoch.
212
+ * May be undefined if not supported by the file system.
213
+ */
214
+ readonly created?: number;
215
+ /**
216
+ * File permissions mode (Unix-like systems only).
217
+ * Octal representation of file permissions.
218
+ * Undefined on Windows.
219
+ *
220
+ * @platform unix
221
+ */
222
+ readonly mode?: number;
223
+ }
224
+ /**
225
+ * Directory entry information.
226
+ * Returned by `readDir()` function.
227
+ */
228
+ export interface DirEntry {
229
+ /**
230
+ * Entry name (without directory path).
231
+ * @example For `/path/to/file.txt`, name is `file.txt`
232
+ */
233
+ readonly name: string;
234
+ /** Whether this entry is a regular file */
235
+ readonly isFile: boolean;
236
+ /** Whether this entry is a directory */
237
+ readonly isDirectory: boolean;
238
+ /** Whether this entry is a symbolic link */
239
+ readonly isSymlink: boolean;
240
+ }
241
+ /**
242
+ * Seek modes for file positioning.
243
+ * Used with `FsFile.seek()` method.
244
+ */
245
+ export declare enum SeekMode {
246
+ /** Seek from start of file (absolute position) */
247
+ Start = 0,
248
+ /** Seek from current position (relative) */
249
+ Current = 1,
250
+ /** Seek from end of file (usually negative offset) */
251
+ End = 2
252
+ }
253
+ /**
254
+ * File handle for advanced file operations.
255
+ * Obtained from `Rong.open()`.
256
+ *
257
+ * @example
258
+ * ```typescript
259
+ * const file = await Rong.open('/path/to/file.txt', {
260
+ * read: true,
261
+ * write: true
262
+ * });
263
+ *
264
+ * try {
265
+ * const buffer = new ArrayBuffer(1024);
266
+ * const bytesRead = await file.read(buffer);
267
+ * console.log(`Read ${bytesRead} bytes`);
268
+ * } finally {
269
+ * await file.close();
270
+ * }
271
+ * ```
272
+ */
273
+ export interface FsFile {
274
+ /**
275
+ * Get file metadata.
276
+ *
277
+ * @returns Promise with file information
278
+ * @throws {IOError} If stat operation fails
279
+ * @example
280
+ * ```typescript
281
+ * const info = await file.stat();
282
+ * console.log(`File size: ${info.size} bytes`);
283
+ * ```
284
+ */
285
+ stat(): Promise<FileInfo>;
286
+ /**
287
+ * Read from file into buffer.
288
+ * Reads from current file position and advances the position.
289
+ *
290
+ * @param buffer - ArrayBuffer to read into
291
+ * @returns Promise with bytes read, or null on EOF
292
+ * @throws {IOError} If read operation fails
293
+ * @example
294
+ * ```typescript
295
+ * const buffer = new ArrayBuffer(4096);
296
+ * const bytesRead = await file.read(buffer);
297
+ * if (bytesRead === null) {
298
+ * console.log('Reached end of file');
299
+ * } else {
300
+ * console.log(`Read ${bytesRead} bytes`);
301
+ * }
302
+ * ```
303
+ */
304
+ read(buffer: ArrayBuffer): Promise<number | null>;
305
+ /**
306
+ * Write buffer to file.
307
+ * Writes at current file position and advances the position.
308
+ *
309
+ * @param buffer - ArrayBuffer to write
310
+ * @returns Promise with number of bytes written
311
+ * @throws {IOError} If write operation fails
312
+ * @example
313
+ * ```typescript
314
+ * const data = new TextEncoder().encode('Hello World');
315
+ * const bytesWritten = await file.write(data.buffer);
316
+ * console.log(`Wrote ${bytesWritten} bytes`);
317
+ * ```
318
+ */
319
+ write(buffer: ArrayBuffer): Promise<number>;
320
+ /**
321
+ * Sync file contents to disk.
322
+ * Ensures all buffered writes are flushed to storage.
323
+ *
324
+ * @returns Promise that resolves when sync is complete
325
+ * @throws {IOError} If sync operation fails
326
+ */
327
+ sync(): Promise<void>;
328
+ /**
329
+ * Truncate or extend file to specified length.
330
+ *
331
+ * @param len - Target length in bytes (default: 0)
332
+ * @returns Promise that resolves when truncate is complete
333
+ * @throws {IOError} If truncate operation fails
334
+ * @example
335
+ * ```typescript
336
+ * // Truncate to 100 bytes
337
+ * await file.truncate(100);
338
+ *
339
+ * // Truncate to 0 bytes (clear file)
340
+ * await file.truncate();
341
+ * ```
342
+ */
343
+ truncate(len?: number): Promise<void>;
344
+ /**
345
+ * Seek to position in file.
346
+ *
347
+ * @param offset - Byte offset
348
+ * @param whence - Seek mode (Start, Current, or End)
349
+ * @returns Promise with new absolute position
350
+ * @throws {IOError} If seek operation fails
351
+ * @example
352
+ * ```typescript
353
+ * // Seek to byte 100 from start
354
+ * await file.seek(100, Rong.SeekMode.Start);
355
+ *
356
+ * // Seek forward 50 bytes from current position
357
+ * await file.seek(50, Rong.SeekMode.Current);
358
+ *
359
+ * // Seek to 10 bytes before end
360
+ * await file.seek(-10, Rong.SeekMode.End);
361
+ * ```
362
+ */
363
+ seek(offset: number, whence?: SeekMode): Promise<number>;
364
+ /**
365
+ * Close file handle.
366
+ * After closing, no further operations can be performed.
367
+ * It's recommended to use try-finally to ensure files are closed.
368
+ *
369
+ * @returns Promise that resolves when file is closed
370
+ * @example
371
+ * ```typescript
372
+ * const file = await Rong.open('/file.txt', { read: true });
373
+ * try {
374
+ * // Use file...
375
+ * } finally {
376
+ * await file.close();
377
+ * }
378
+ * ```
379
+ */
380
+ close(): Promise<void>;
381
+ /**
382
+ * Get ReadableStream for reading file contents.
383
+ * The stream reads from the current file position.
384
+ * Cannot be used simultaneously with direct read operations.
385
+ *
386
+ * @example
387
+ * ```typescript
388
+ * const file = await Rong.open('/file.txt', { read: true });
389
+ * const readable = file.readable;
390
+ *
391
+ * for await (const chunk of readable) {
392
+ * console.log('Received chunk:', chunk.length, 'bytes');
393
+ * }
394
+ * ```
395
+ */
396
+ readonly readable: ReadableStream<Uint8Array>;
397
+ /**
398
+ * Get WritableStream for writing file contents.
399
+ * The stream writes to the current file position.
400
+ * Cannot be used simultaneously with direct write operations.
401
+ *
402
+ * @example
403
+ * ```typescript
404
+ * const file = await Rong.open('/file.txt', { write: true, create: true });
405
+ * const writable = file.writable;
406
+ * const writer = writable.getWriter();
407
+ *
408
+ * await writer.write(new TextEncoder().encode('Hello'));
409
+ * await writer.close();
410
+ * ```
411
+ */
412
+ readonly writable: WritableStream<Uint8Array>;
413
+ }
414
+ /**
415
+ * File System module interface.
416
+ * All operations are available under the global `Rong` namespace.
417
+ */
418
+ export interface FsModule {
419
+ readTextFile(path: string, options?: ReadFileOptions): Promise<string>;
420
+ readFile(path: string, options?: ReadFileOptions): Promise<ArrayBuffer>;
421
+ writeTextFile(path: string, text: string, options?: WriteFileOptions): Promise<void>;
422
+ writeFile(path: string, data: ArrayBufferView, options?: WriteFileOptions): Promise<void>;
423
+ copyFile(from: string, to: string): Promise<void>;
424
+ truncate(path: string, len?: number): Promise<void>;
425
+ open(path: string, options?: FileOpenOptions): Promise<FsFile>;
426
+ mkdir(path: string, options?: MkdirOptions): Promise<void>;
427
+ readDir(path: string): Promise<AsyncIterableIterator<DirEntry>>;
428
+ stat(path: string): Promise<FileInfo>;
429
+ lstat(path: string): Promise<FileInfo>;
430
+ remove(path: string, options?: RemoveOptions): Promise<void>;
431
+ chdir(path: string): Promise<void>;
432
+ symlink(target: string, path: string): Promise<void>;
433
+ readlink(path: string): Promise<string>;
434
+ /**
435
+ * Change file permissions (Unix only)
436
+ * @platform unix
437
+ */
438
+ chmod(path: string, mode: number): Promise<void>;
439
+ /**
440
+ * Change file ownership (Unix only)
441
+ * @platform unix
442
+ */
443
+ chown(path: string, uid: number, gid: number): Promise<void>;
444
+ utime(path: string, options: UTimeOptions): Promise<void>;
445
+ rename(oldPath: string, newPath: string): Promise<void>;
446
+ realPath(path: string): Promise<string>;
447
+ readonly SeekMode: typeof SeekMode;
448
+ }
449
+ export {};
450
+ //# sourceMappingURL=fs.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fs.d.ts","sourceRoot":"","sources":["../src/fs.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAIH;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B;;;;;;;;;;;;;;OAcG;IACH,MAAM,CAAC,EAAE,WAAW,CAAC;CACtB;AAED;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B;;;;;OAKG;IACH,MAAM,CAAC,EAAE,OAAO,CAAC;IAEjB;;;;;;;OAOG;IACH,SAAS,CAAC,EAAE,OAAO,CAAC;IAEpB;;;;;;;;;;;;;OAaG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;IAEd;;;;OAIG;IACH,MAAM,CAAC,EAAE,WAAW,CAAC;CACtB;AAED;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B;;;OAGG;IACH,IAAI,CAAC,EAAE,OAAO,CAAC;IAEf;;;OAGG;IACH,KAAK,CAAC,EAAE,OAAO,CAAC;IAEhB;;;OAGG;IACH,MAAM,CAAC,EAAE,OAAO,CAAC;IAEjB;;;;OAIG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC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AAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAGnC,OAAO,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACrD,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;IAGxC;;;OAGG;IACH,KAAK,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACjD;;;OAGG;IACH,KAAK,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC7D,KAAK,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAG1D,MAAM,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACxD,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;IAGxC,QAAQ,CAAC,QAAQ,EAAE,OAAO,QAAQ,CAAC;CACpC;AAGD,OAAO,EAAE,CAAC"}
package/dist/fs.js ADDED
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+ /**
3
+ * File System module type definitions
4
+ * Corresponds to: modules/rong_fs
5
+ *
6
+ * Provides APIs for file system operations including reading, writing, and directory management.
7
+ * All file system APIs are mounted under the global `Rong` namespace.
8
+ */
9
+ Object.defineProperty(exports, "__esModule", { value: true });
10
+ exports.SeekMode = void 0;
11
+ /**
12
+ * Seek modes for file positioning.
13
+ * Used with `FsFile.seek()` method.
14
+ */
15
+ var SeekMode;
16
+ (function (SeekMode) {
17
+ /** Seek from start of file (absolute position) */
18
+ SeekMode[SeekMode["Start"] = 0] = "Start";
19
+ /** Seek from current position (relative) */
20
+ SeekMode[SeekMode["Current"] = 1] = "Current";
21
+ /** Seek from end of file (usually negative offset) */
22
+ SeekMode[SeekMode["End"] = 2] = "End";
23
+ })(SeekMode = exports.SeekMode || (exports.SeekMode = {}));