@lingxia/rong 0.2.0 → 0.3.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 (66) hide show
  1. package/README.md +9 -7
  2. package/dist/command.d.ts +93 -0
  3. package/dist/command.d.ts.map +1 -0
  4. package/dist/command.js +6 -0
  5. package/dist/compression.d.ts +12 -0
  6. package/dist/compression.d.ts.map +1 -0
  7. package/dist/compression.js +6 -0
  8. package/dist/console.d.ts +20 -7
  9. package/dist/console.d.ts.map +1 -1
  10. package/dist/error.d.ts +40 -13
  11. package/dist/error.d.ts.map +1 -1
  12. package/dist/error.js +63 -28
  13. package/dist/fs.d.ts +111 -310
  14. package/dist/fs.d.ts.map +1 -1
  15. package/dist/fs.js +7 -4
  16. package/dist/global.d.ts +44 -37
  17. package/dist/global.d.ts.map +1 -1
  18. package/dist/http.d.ts +4 -0
  19. package/dist/http.d.ts.map +1 -1
  20. package/dist/index.d.ts +15 -12
  21. package/dist/index.d.ts.map +1 -1
  22. package/dist/index.js +15 -12
  23. package/dist/redis.d.ts +109 -0
  24. package/dist/redis.d.ts.map +1 -0
  25. package/dist/redis.js +13 -0
  26. package/dist/s3.d.ts +174 -0
  27. package/dist/s3.d.ts.map +1 -0
  28. package/dist/s3.js +10 -0
  29. package/dist/sqlite.d.ts +98 -0
  30. package/dist/sqlite.d.ts.map +1 -0
  31. package/dist/sqlite.js +8 -0
  32. package/dist/sse.d.ts +26 -0
  33. package/dist/sse.d.ts.map +1 -0
  34. package/dist/sse.js +2 -0
  35. package/dist/storage.d.ts +5 -16
  36. package/dist/storage.d.ts.map +1 -1
  37. package/dist/storage.js +4 -1
  38. package/dist/stream.d.ts +5 -8
  39. package/dist/stream.d.ts.map +1 -1
  40. package/dist/stream.js +5 -8
  41. package/dist/timer.d.ts +1 -18
  42. package/dist/timer.d.ts.map +1 -1
  43. package/dist/worker.d.ts +31 -0
  44. package/dist/worker.d.ts.map +1 -0
  45. package/dist/worker.js +14 -0
  46. package/package.json +12 -4
  47. package/src/abort.ts +0 -50
  48. package/src/assert.ts +0 -51
  49. package/src/buffer.ts +0 -60
  50. package/src/child_process.ts +0 -116
  51. package/src/console.ts +0 -53
  52. package/src/encoding.ts +0 -10
  53. package/src/error.ts +0 -149
  54. package/src/event.ts +0 -128
  55. package/src/exception.ts +0 -77
  56. package/src/fs.ts +0 -514
  57. package/src/global.ts +0 -98
  58. package/src/http.ts +0 -157
  59. package/src/index.ts +0 -67
  60. package/src/navigator.ts +0 -20
  61. package/src/path.ts +0 -83
  62. package/src/process.ts +0 -74
  63. package/src/storage.ts +0 -64
  64. package/src/stream.ts +0 -98
  65. package/src/timer.ts +0 -61
  66. package/src/url.ts +0 -106
@@ -0,0 +1,98 @@
1
+ /**
2
+ * SQLite module type definitions.
3
+ * Corresponds to: modules/rong_sqlite
4
+ *
5
+ * Sync API — all operations are synchronous (no Promises).
6
+ */
7
+ /**
8
+ * Result of a write operation (INSERT, UPDATE, DELETE).
9
+ */
10
+ export interface RunResult {
11
+ /** Number of rows changed. */
12
+ changes: number;
13
+ /** Row ID of the last inserted row. Large values are returned as `bigint`. */
14
+ lastInsertRowid: number | bigint;
15
+ }
16
+ /**
17
+ * Prepared SQL statement for repeated execution.
18
+ * Created via `db.prepare(sql)`.
19
+ *
20
+ * @example
21
+ * ```typescript
22
+ * const stmt = db.prepare("SELECT * FROM users WHERE age > ?");
23
+ * const rows = stmt.all([18]);
24
+ * const first = stmt.get([18]);
25
+ * stmt.finalize();
26
+ * ```
27
+ */
28
+ export interface Statement {
29
+ /** The SQL text of this statement. */
30
+ readonly sql: string;
31
+ /** Execute and return `{ changes, lastInsertRowid }`. */
32
+ run(params?: SQLiteParams): RunResult;
33
+ /** Execute and return all matching rows as array of objects. */
34
+ all(params?: SQLiteParams): Record<string, any>[];
35
+ /** Execute and return the first matching row, or `null`. */
36
+ get(params?: SQLiteParams): Record<string, any> | null;
37
+ /** Execute and return all rows as arrays of column values. */
38
+ values(params?: SQLiteParams): any[][];
39
+ /** Mark the statement as finalized. Further calls will throw. */
40
+ finalize(): void;
41
+ }
42
+ /** Supported parameter types for SQLite queries. */
43
+ export type SQLiteParam = null | boolean | number | bigint | string | ArrayBuffer | Uint8Array;
44
+ export type SQLiteParams = SQLiteParam[];
45
+ /**
46
+ * SQLite database connection.
47
+ *
48
+ * @example
49
+ * ```typescript
50
+ * const db = new Rong.SQLite("mydb.sqlite");
51
+ *
52
+ * db.exec("CREATE TABLE users (id INTEGER PRIMARY KEY, name TEXT, age INTEGER)");
53
+ * db.run("INSERT INTO users (name, age) VALUES (?, ?)", ["Alice", 30]);
54
+ *
55
+ * const rows = db.query("SELECT * FROM users WHERE age > ?", [18]);
56
+ * console.log(rows);
57
+ *
58
+ * db.close();
59
+ * ```
60
+ */
61
+ export declare class SQLite {
62
+ /**
63
+ * Open a SQLite database.
64
+ * @param filename - Path to the database file, or `":memory:"` for in-memory. Defaults to `":memory:"`.
65
+ */
66
+ constructor(filename?: string);
67
+ /** The filename used to open the database. */
68
+ readonly filename: string;
69
+ /** Whether the database is currently inside a transaction. */
70
+ readonly inTransaction: boolean;
71
+ /**
72
+ * Execute one or more SQL statements (no parameters, no return value).
73
+ * Use for DDL / schema setup.
74
+ */
75
+ exec(sql: string): void;
76
+ /**
77
+ * Execute a single statement with optional parameters.
78
+ * Returns `{ changes, lastInsertRowid }`.
79
+ */
80
+ run(sql: string, params?: SQLiteParams): RunResult;
81
+ /**
82
+ * Execute a query and return all matching rows as an array of objects.
83
+ */
84
+ query(sql: string, params?: SQLiteParams): Record<string, any>[];
85
+ /**
86
+ * Create a prepared statement for repeated execution.
87
+ */
88
+ prepare(sql: string): Statement;
89
+ /**
90
+ * Run a function inside a transaction.
91
+ * Commits on success, rolls back if the callback throws.
92
+ */
93
+ transaction(callback: () => void): void;
94
+ /** Close the database connection. */
95
+ close(): void;
96
+ }
97
+ export {};
98
+ //# sourceMappingURL=sqlite.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file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AG,IAAI;IAEvB;;;OAGG;IACH,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,YAAY,GAAG,SAAS;IAElD;;OAEG;IACH,KAAK,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,YAAY,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE;IAEhE;;OAEG;IACH,OAAO,CAAC,GAAG,EAAE,MAAM,GAAG,SAAS;IAE/B;;;OAGG;IACH,WAAW,CAAC,QAAQ,EAAE,MAAM,IAAI,GAAG,IAAI;IAEvC,qCAAqC;IACrC,KAAK,IAAI,IAAI;CACd;AAED,OAAO,EAAE,CAAC"}
package/dist/sqlite.js ADDED
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ /**
3
+ * SQLite module type definitions.
4
+ * Corresponds to: modules/rong_sqlite
5
+ *
6
+ * Sync API — all operations are synchronous (no Promises).
7
+ */
8
+ Object.defineProperty(exports, "__esModule", { value: true });
package/dist/sse.d.ts ADDED
@@ -0,0 +1,26 @@
1
+ export interface SSEOptions {
2
+ headers?: Record<string, string>;
3
+ requestTimeoutMs?: number;
4
+ signal?: AbortSignal;
5
+ reconnect?: {
6
+ enabled?: boolean;
7
+ maxRetries?: number;
8
+ baseDelayMs?: number;
9
+ maxDelayMs?: number;
10
+ };
11
+ }
12
+ export interface SSEEvent {
13
+ readonly type: string;
14
+ readonly data: string;
15
+ readonly id: string;
16
+ readonly origin: string;
17
+ }
18
+ export interface SSE extends AsyncIterable<SSEEvent> {
19
+ readonly url: string;
20
+ close(): void;
21
+ [Symbol.asyncIterator](): AsyncIterator<SSEEvent>;
22
+ }
23
+ export interface SSEConstructor {
24
+ new (url: string, options?: SSEOptions): SSE;
25
+ }
26
+ //# sourceMappingURL=sse.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sse.d.ts","sourceRoot":"","sources":["../src/sse.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,UAAU;IACzB,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACjC,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,MAAM,CAAC,EAAE,WAAW,CAAC;IACrB,SAAS,CAAC,EAAE;QACV,OAAO,CAAC,EAAE,OAAO,CAAC;QAClB,UAAU,CAAC,EAAE,MAAM,CAAC;QACpB,WAAW,CAAC,EAAE,MAAM,CAAC;QACrB,UAAU,CAAC,EAAE,MAAM,CAAC;KACrB,CAAC;CACH;AAED,MAAM,WAAW,QAAQ;IACvB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;CACzB;AAED,MAAM,WAAW,GAAI,SAAQ,aAAa,CAAC,QAAQ,CAAC;IAClD,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,KAAK,IAAI,IAAI,CAAC;IACd,CAAC,MAAM,CAAC,aAAa,CAAC,IAAI,aAAa,CAAC,QAAQ,CAAC,CAAC;CACnD;AAED,MAAM,WAAW,cAAc;IAC7B,KAAK,GAAG,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,UAAU,GAAG,GAAG,CAAC;CAC9C"}
package/dist/sse.js ADDED
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
package/dist/storage.d.ts CHANGED
@@ -2,7 +2,10 @@
2
2
  * Storage module type definitions
3
3
  * Corresponds to: modules/rong_storage
4
4
  *
5
- * IMPORTANT: Storage is accessed via `Rong.storage.open(path)` or `new Rong.Storage(path)`
5
+ * IMPORTANT: The standard Rong runtime exposes a global `Storage` constructor.
6
+ * It does not provide `Rong.Storage` or `Rong.storage.open(...)` by default.
7
+ * This package does not redeclare the global `Storage` name because it would
8
+ * conflict with the DOM `Storage` type from `lib.dom.d.ts`.
6
9
  */
7
10
  export interface StorageInfo {
8
11
  /** Current storage size in bytes */
@@ -21,7 +24,7 @@ export interface Storage {
21
24
  delete(key: string): Promise<void>;
22
25
  /** Clear all items */
23
26
  clear(): Promise<void>;
24
- /** Get all keys (returns async iterator) */
27
+ /** Get all keys (returns a synchronous iterator wrapped in a Promise) */
25
28
  list(prefix?: string): Promise<IterableIterator<string>>;
26
29
  /** Get storage info */
27
30
  info(): Promise<StorageInfo>;
@@ -35,19 +38,5 @@ export interface StorageOptionsInput {
35
38
  maxValueSize?: number;
36
39
  maxDataSize?: number;
37
40
  }
38
- export interface StorageModule {
39
- /**
40
- * Open a storage database at the given path
41
- * @param path - Path to the database file
42
- * @returns Storage instance
43
- *
44
- * @example
45
- * ```typescript
46
- * const storage = Rong.storage.open('/path/to/db.sqlite');
47
- * await storage.set('key', 'value');
48
- * ```
49
- */
50
- open(path: string, options?: StorageOptionsInput): Promise<Storage>;
51
- }
52
41
  export {};
53
42
  //# sourceMappingURL=storage.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"storage.d.ts","sourceRoot":"","sources":["../src/storage.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,MAAM,WAAW,WAAW;IAC1B,oCAAoC;IACpC,WAAW,EAAE,MAAM,CAAC;IACpB,0BAA0B;IAC1B,SAAS,EAAE,MAAM,CAAC;IAClB,qBAAqB;IACrB,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,OAAO;IACtB,2BAA2B;IAC3B,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAE5C,uBAAuB;IACvB,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC;IAE/B,mBAAmB;IACnB,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAEnC,sBAAsB;IACtB,KAAK,IAA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C;IAEnC,sBAAsB;IACtB,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IAEvB,yEAAyE;IACzE,IAAI,CAAC,MAAM,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,gBAAgB,CAAC,MAAM,CAAC,CAAC,CAAC;IAEzD,uBAAuB;IACvB,IAAI,IAAI,OAAO,CAAC,WAAW,CAAC,CAAC;CAC9B;AAED,MAAM,WAAW,kBAAkB;IACjC,gEAAgE;IAChE,KAAI,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,mBAAmB,GAAG,OAAO,CAAC;CAC3D;AAED,MAAM,WAAW,mBAAmB;IAClC,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,OAAO,EAAE,CAAC"}
package/dist/storage.js CHANGED
@@ -3,6 +3,9 @@
3
3
  * Storage module type definitions
4
4
  * Corresponds to: modules/rong_storage
5
5
  *
6
- * IMPORTANT: Storage is accessed via `Rong.storage.open(path)` or `new Rong.Storage(path)`
6
+ * IMPORTANT: The standard Rong runtime exposes a global `Storage` constructor.
7
+ * It does not provide `Rong.Storage` or `Rong.storage.open(...)` by default.
8
+ * This package does not redeclare the global `Storage` name because it would
9
+ * conflict with the DOM `Storage` type from `lib.dom.d.ts`.
7
10
  */
8
11
  Object.defineProperty(exports, "__esModule", { value: true });
package/dist/stream.d.ts CHANGED
@@ -13,7 +13,7 @@
13
13
  * Usage:
14
14
  * ```typescript
15
15
  * // From file
16
- * const file = await Rong.open('/path/to/file.txt', { read: true });
16
+ * const file = await Rong.file('/path/to/file.txt').open({ read: true });
17
17
  * const readable = file.readable;
18
18
  *
19
19
  * // Read from stream
@@ -31,7 +31,7 @@
31
31
  * Usage:
32
32
  * ```typescript
33
33
  * // To file
34
- * const file = await Rong.open('/path/to/output.txt', { write: true, create: true });
34
+ * const file = await Rong.file('/path/to/output.txt').open({ write: true, create: true });
35
35
  * const writable = file.writable;
36
36
  *
37
37
  * // Write to stream
@@ -60,18 +60,15 @@
60
60
  *
61
61
  * ### Pipe streams
62
62
  * ```typescript
63
- * // Pipe stdin to stdout
64
- * await process.stdin.pipeTo(process.stdout);
65
- *
66
63
  * // Pipe file to file
67
- * const source = await Rong.open('/source.txt', { read: true });
68
- * const dest = await Rong.open('/dest.txt', { write: true, create: true });
64
+ * const source = await Rong.file('/source.txt').open({ read: true });
65
+ * const dest = await Rong.file('/dest.txt').open({ write: true, create: true });
69
66
  * await source.readable.pipeTo(dest.writable);
70
67
  * ```
71
68
  *
72
69
  * ### Process data in chunks
73
70
  * ```typescript
74
- * const file = await Rong.open('/large-file.txt', { read: true });
71
+ * const file = await Rong.file('/large-file.txt').open({ read: true });
75
72
  * const reader = file.readable.getReader();
76
73
  *
77
74
  * let totalBytes = 0;
@@ -1 +1 @@
1
- {"version":3,"file":"stream.d.ts","sourceRoot":"","sources":["../src/stream.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuFG;AAUH,OAAO,EAAE,CAAC"}
1
+ {"version":3,"file":"stream.d.ts","sourceRoot":"","sources":["../src/stream.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoFG;AAUH,OAAO,EAAE,CAAC"}
package/dist/stream.js CHANGED
@@ -14,7 +14,7 @@
14
14
  * Usage:
15
15
  * ```typescript
16
16
  * // From file
17
- * const file = await Rong.open('/path/to/file.txt', { read: true });
17
+ * const file = await Rong.file('/path/to/file.txt').open({ read: true });
18
18
  * const readable = file.readable;
19
19
  *
20
20
  * // Read from stream
@@ -32,7 +32,7 @@
32
32
  * Usage:
33
33
  * ```typescript
34
34
  * // To file
35
- * const file = await Rong.open('/path/to/output.txt', { write: true, create: true });
35
+ * const file = await Rong.file('/path/to/output.txt').open({ write: true, create: true });
36
36
  * const writable = file.writable;
37
37
  *
38
38
  * // Write to stream
@@ -61,18 +61,15 @@
61
61
  *
62
62
  * ### Pipe streams
63
63
  * ```typescript
64
- * // Pipe stdin to stdout
65
- * await process.stdin.pipeTo(process.stdout);
66
- *
67
64
  * // Pipe file to file
68
- * const source = await Rong.open('/source.txt', { read: true });
69
- * const dest = await Rong.open('/dest.txt', { write: true, create: true });
65
+ * const source = await Rong.file('/source.txt').open({ read: true });
66
+ * const dest = await Rong.file('/dest.txt').open({ write: true, create: true });
70
67
  * await source.readable.pipeTo(dest.writable);
71
68
  * ```
72
69
  *
73
70
  * ### Process data in chunks
74
71
  * ```typescript
75
- * const file = await Rong.open('/large-file.txt', { read: true });
72
+ * const file = await Rong.file('/large-file.txt').open({ read: true });
76
73
  * const reader = file.readable.getReader();
77
74
  *
78
75
  * let totalBytes = 0;
package/dist/timer.d.ts CHANGED
@@ -4,20 +4,7 @@
4
4
  */
5
5
  export type TimerCallback = () => void;
6
6
  export type TimerId = number;
7
- export interface TimersNamespace {
8
- /**
9
- * Promise-based timeout that resolves with a timestamp (ms since epoch).
10
- */
11
- setTimeout(delay?: number): Promise<number>;
12
- /**
13
- * Promise-based immediate that resolves with a timestamp (ms since epoch).
14
- */
15
- setImmediate(): Promise<number>;
16
- /**
17
- * Async iterator that yields timestamps (ms since epoch) on each interval tick.
18
- */
19
- setInterval(delay?: number): AsyncIterableIterator<number>;
20
- }
7
+ export type RongSleepValue = number | Date;
21
8
  declare global {
22
9
  /**
23
10
  * Set a timer that executes a callback once after a delay
@@ -43,10 +30,6 @@ declare global {
43
30
  * @param id - Timer ID returned by setInterval
44
31
  */
45
32
  function clearInterval(id: TimerId): void;
46
- /**
47
- * Promise-based timer namespace
48
- */
49
- const timers: TimersNamespace;
50
33
  }
51
34
  export {};
52
35
  //# sourceMappingURL=timer.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"timer.d.ts","sourceRoot":"","sources":["../src/timer.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,MAAM,MAAM,aAAa,GAAG,MAAM,IAAI,CAAC;AACvC,MAAM,MAAM,OAAO,GAAG,MAAM,CAAC;AAE7B,MAAM,WAAW,eAAe;IAC9B;;OAEG;IACH,UAAU,CAAC,KAAK,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;IAE5C;;OAEG;IACH,YAAY,IAAI,OAAO,CAAC,MAAM,CAAC,CAAC;IAEhC;;OAEG;IACH,WAAW,CAAC,KAAK,CAAC,EAAE,MAAM,GAAG,qBAAqB,CAAC,MAAM,CAAC,CAAC;CAC5D;AAED,OAAO,CAAC,MAAM,CAAC;IACb;;;;;OAKG;IACH,SAAS,UAAU,CAAC,QAAQ,EAAE,aAAa,EAAE,KAAK,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;IAEtE;;;OAGG;IACH,SAAS,YAAY,CAAC,EAAE,EAAE,OAAO,GAAG,IAAI,CAAC;IAEzC;;;;;OAKG;IACH,SAAS,WAAW,CAAC,QAAQ,EAAE,aAAa,EAAE,KAAK,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;IAEvE;;;OAGG;IACH,SAAS,aAAa,CAAC,EAAE,EAAE,OAAO,GAAG,IAAI,CAAC;IAE1C;;OAEG;IACH,MAAM,MAAM,EAAE,eAAe,CAAC;CAC/B;AAED,OAAO,EAAE,CAAC"}
1
+ {"version":3,"file":"timer.d.ts","sourceRoot":"","sources":["../src/timer.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,MAAM,MAAM,aAAa,GAAG,MAAM,IAAI,CAAC;AACvC,MAAM,MAAM,OAAO,GAAG,MAAM,CAAC;AAC7B,MAAM,MAAM,cAAc,GAAG,MAAM,GAAG,IAAI,CAAC;AAE3C,OAAO,CAAC,MAAM,CAAC;IACb;;;;;OAKG;IACH,SAAS,UAAU,CAAC,QAAQ,EAAE,aAAa,EAAE,KAAK,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;IAEtE;;;OAGG;IACH,SAAS,YAAY,CAAC,EAAE,EAAE,OAAO,GAAG,IAAI,CAAC;IAEzC;;;;;OAKG;IACH,SAAS,WAAW,CAAC,QAAQ,EAAE,aAAa,EAAE,KAAK,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;IAEvE;;;OAGG;IACH,SAAS,aAAa,CAAC,EAAE,EAAE,OAAO,GAAG,IAAI,CAAC;CAC3C;AAED,OAAO,EAAE,CAAC"}
@@ -0,0 +1,31 @@
1
+ /**
2
+ * Worker module type definitions
3
+ * Corresponds to: modules/rong_worker
4
+ *
5
+ * Rong exposes the standard global `Worker` name, but this package does not
6
+ * redeclare the global constructor because projects are expected to include the
7
+ * DOM lib for shared Web API types. Doing so would conflict with `lib.dom.d.ts`.
8
+ *
9
+ * Export the Rong-specific subset here for documentation and for precise local
10
+ * annotations when you want the runtime surface rather than the full browser
11
+ * Worker API.
12
+ */
13
+ export interface RongWorkerMessageEvent<T = any> {
14
+ readonly data: T;
15
+ }
16
+ export interface RongWorkerErrorEvent {
17
+ readonly type: 'error';
18
+ readonly message: string;
19
+ }
20
+ export interface RongWorker {
21
+ onmessage: ((event: RongWorkerMessageEvent) => void) | undefined;
22
+ onerror: ((event: RongWorkerErrorEvent) => void) | undefined;
23
+ postMessage(data: unknown): void;
24
+ terminate(): void;
25
+ }
26
+ export interface RongWorkerConstructor {
27
+ new (path: string): RongWorker;
28
+ prototype: RongWorker;
29
+ }
30
+ export {};
31
+ //# sourceMappingURL=worker.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"worker.d.ts","sourceRoot":"","sources":["../src/worker.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,MAAM,WAAW,sBAAsB,CAAC,CAAC,GAAG,GAAG;IAC7C,QAAQ,CAAC,IAAI,EAAE,CAAC,CAAC;CAClB;AAED,MAAM,WAAW,oBAAoB;IACnC,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC;IACvB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;CAC1B;AAED,MAAM,WAAW,UAAU;IACzB,SAAS,EAAE,CAAC,CAAC,KAAK,EAAE,sBAAsB,KAAK,IAAI,CAAC,GAAG,SAAS,CAAC;IACjE,OAAO,EAAE,CAAC,CAAC,KAAK,EAAE,oBAAoB,KAAK,IAAI,CAAC,GAAG,SAAS,CAAC;IAC7D,WAAW,CAAC,IAAI,EAAE,OAAO,GAAG,IAAI,CAAC;IACjC,SAAS,IAAI,IAAI,CAAC;CACnB;AAED,MAAM,WAAW,qBAAqB;IACpC,KAAK,IAAI,EAAE,MAAM,GAAG,UAAU,CAAC;IAC/B,SAAS,EAAE,UAAU,CAAC;CACvB;AAED,OAAO,EAAE,CAAC"}
package/dist/worker.js ADDED
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ /**
3
+ * Worker module type definitions
4
+ * Corresponds to: modules/rong_worker
5
+ *
6
+ * Rong exposes the standard global `Worker` name, but this package does not
7
+ * redeclare the global constructor because projects are expected to include the
8
+ * DOM lib for shared Web API types. Doing so would conflict with `lib.dom.d.ts`.
9
+ *
10
+ * Export the Rong-specific subset here for documentation and for precise local
11
+ * annotations when you want the runtime surface rather than the full browser
12
+ * Worker API.
13
+ */
14
+ Object.defineProperty(exports, "__esModule", { value: true });
package/package.json CHANGED
@@ -1,12 +1,20 @@
1
1
  {
2
2
  "name": "@lingxia/rong",
3
- "version": "0.2.0",
3
+ "version": "0.3.0",
4
4
  "description": "TypeScript type definitions for Rong JavaScript runtime",
5
- "main": "dist/index.js",
6
- "types": "dist/index.d.ts",
5
+ "main": "./dist/index.js",
6
+ "types": "./dist/index.d.ts",
7
+ "exports": {
8
+ ".": {
9
+ "types": "./dist/index.d.ts",
10
+ "default": "./dist/index.js"
11
+ },
12
+ "./package.json": "./package.json"
13
+ },
7
14
  "scripts": {
8
15
  "build": "tsc",
9
16
  "watch": "tsc --watch",
17
+ "prepare": "npm run build",
10
18
  "prepublishOnly": "npm run build"
11
19
  },
12
20
  "keywords": [
@@ -22,6 +30,6 @@
22
30
  },
23
31
  "files": [
24
32
  "dist",
25
- "src"
33
+ "README.md"
26
34
  ]
27
35
  }
package/src/abort.ts DELETED
@@ -1,50 +0,0 @@
1
- /**
2
- * Abort module type definitions
3
- * Corresponds to: modules/rong_abort
4
- */
5
-
6
- import { EventTarget } from './event';
7
-
8
- export interface AbortSignal extends EventTarget {
9
- /** Whether the signal has been aborted */
10
- readonly aborted: boolean;
11
-
12
- /** Reason for abort (if any) */
13
- readonly reason: any;
14
-
15
- /** Abort event handler */
16
- onabort: ((event: Event) => void) | null;
17
-
18
- /** If the signal has been aborted, throw the abort reason */
19
- throwIfAborted(): void;
20
- }
21
-
22
- export interface AbortSignalConstructor {
23
- prototype: AbortSignal;
24
-
25
- /** Returns an AbortSignal that is aborted when any of the given signals are aborted */
26
- any(signals: AbortSignal[]): AbortSignal;
27
-
28
- /** Returns an AbortSignal that is already aborted */
29
- abort(reason?: any): AbortSignal;
30
-
31
- /** Returns an AbortSignal that will abort after the specified milliseconds */
32
- timeout(milliseconds: number): AbortSignal;
33
- }
34
-
35
- export interface AbortController {
36
- /** The AbortSignal associated with this controller */
37
- readonly signal: AbortSignal;
38
-
39
- /** Abort the associated signal */
40
- abort(reason?: any): void;
41
- }
42
-
43
- export interface AbortControllerConstructor {
44
- new(): AbortController;
45
- prototype: AbortController;
46
- }
47
-
48
- // Note: AbortSignal and AbortController are provided by the global environment
49
- // These type definitions are for reference and extend the standard Web API
50
- export {};
package/src/assert.ts DELETED
@@ -1,51 +0,0 @@
1
- /**
2
- * Assert module type definitions
3
- * Corresponds to: modules/rong_assert
4
- */
5
-
6
- export type AssertionErrorMessage = string | Error;
7
-
8
- export interface AssertFunction {
9
- /**
10
- * Assert that a value is truthy
11
- * @param value - Value to check
12
- * @param message - Optional error message
13
- * @throws Error if value is falsy
14
- */
15
- (value: any, message?: AssertionErrorMessage): asserts value;
16
-
17
- /**
18
- * Assert that a value is truthy (alias)
19
- * @param value - Value to check
20
- * @param message - Optional error message
21
- * @throws Error if value is falsy
22
- */
23
- ok(value: any, message?: AssertionErrorMessage): asserts value;
24
-
25
- /**
26
- * Assert that two values are equal
27
- * @param left - Left value
28
- * @param right - Right value
29
- * @param message - Optional error message
30
- * @throws Error if values are not equal
31
- */
32
- equal(left: any, right: any, message?: AssertionErrorMessage): void;
33
-
34
- /**
35
- * Force assertion failure
36
- * @param message - Error message
37
- * @throws Error always
38
- */
39
- fail(message?: AssertionErrorMessage): never;
40
-
41
- /**
42
- * Assert that a function does not throw
43
- * @param fn - Function to execute
44
- * @param message - Optional error message
45
- * @throws Error if function throws
46
- */
47
- doesNotThrow(fn: () => void, message?: AssertionErrorMessage): void;
48
- }
49
-
50
- // Note: assert is declared as a global in global.d.ts
51
- export {};
package/src/buffer.ts DELETED
@@ -1,60 +0,0 @@
1
- /**
2
- * Buffer module type definitions (Blob and File)
3
- * Corresponds to: modules/rong_buffer
4
- */
5
-
6
- export type BlobPart = Blob | ArrayBuffer | ArrayBufferView | string;
7
-
8
- export interface BlobOptions {
9
- /** MIME type of the blob */
10
- type?: string;
11
- /** Line ending normalization: "transparent" (default) or "native" */
12
- endings?: 'transparent' | 'native';
13
- }
14
-
15
- export interface Blob {
16
- /** Blob size in bytes */
17
- readonly size: number;
18
-
19
- /** MIME type of the blob */
20
- readonly type: string;
21
-
22
- /** Create a slice of the blob */
23
- slice(start?: number, end?: number, contentType?: string): Blob;
24
-
25
- /** Get blob contents as ArrayBuffer */
26
- arrayBuffer(): Promise<ArrayBuffer>;
27
-
28
- /** Get blob contents as text */
29
- text(): Promise<string>;
30
-
31
- /** Get blob contents as Uint8Array */
32
- bytes(): Promise<Uint8Array>;
33
- }
34
-
35
- export interface BlobConstructor {
36
- new(blobParts?: BlobPart[], options?: BlobOptions): Blob;
37
- prototype: Blob;
38
- }
39
-
40
- export interface FileOptions extends BlobOptions {
41
- /** Last modified timestamp (milliseconds since epoch) */
42
- lastModified?: number;
43
- }
44
-
45
- export interface File extends Blob {
46
- /** File name */
47
- readonly name: string;
48
-
49
- /** Last modified timestamp (milliseconds since epoch) */
50
- readonly lastModified: number;
51
- }
52
-
53
- export interface FileConstructor {
54
- new(fileBits: BlobPart[], fileName: string, options?: FileOptions): File;
55
- prototype: File;
56
- }
57
-
58
- // Note: Blob and File are provided by the global environment
59
- // These type definitions are for reference and extend the standard Web API
60
- export {};