@elaraai/east-web-std 1.0.85

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 (102) hide show
  1. package/CLA.md +26 -0
  2. package/CONTRIBUTING.md +28 -0
  3. package/LICENSE.md +31 -0
  4. package/README.md +191 -0
  5. package/THIRD_PARTY_NOTICES.md +123 -0
  6. package/dist/src/compliance.spec.d.ts +6 -0
  7. package/dist/src/compliance.spec.d.ts.map +1 -0
  8. package/dist/src/compliance.spec.js +89 -0
  9. package/dist/src/compliance.spec.js.map +1 -0
  10. package/dist/src/console.d.ts +237 -0
  11. package/dist/src/console.d.ts.map +1 -0
  12. package/dist/src/console.js +260 -0
  13. package/dist/src/console.js.map +1 -0
  14. package/dist/src/crypto.d.ts +224 -0
  15. package/dist/src/crypto.d.ts.map +1 -0
  16. package/dist/src/crypto.js +295 -0
  17. package/dist/src/crypto.js.map +1 -0
  18. package/dist/src/fetch.d.ts +383 -0
  19. package/dist/src/fetch.d.ts.map +1 -0
  20. package/dist/src/fetch.js +412 -0
  21. package/dist/src/fetch.js.map +1 -0
  22. package/dist/src/index.d.ts +106 -0
  23. package/dist/src/index.d.ts.map +1 -0
  24. package/dist/src/index.js +93 -0
  25. package/dist/src/index.js.map +1 -0
  26. package/dist/src/path.d.ts +243 -0
  27. package/dist/src/path.d.ts.map +1 -0
  28. package/dist/src/path.js +562 -0
  29. package/dist/src/path.js.map +1 -0
  30. package/dist/src/random/crypto-rng.d.ts +38 -0
  31. package/dist/src/random/crypto-rng.d.ts.map +1 -0
  32. package/dist/src/random/crypto-rng.js +55 -0
  33. package/dist/src/random/crypto-rng.js.map +1 -0
  34. package/dist/src/random/distributions/bates.d.ts +17 -0
  35. package/dist/src/random/distributions/bates.d.ts.map +1 -0
  36. package/dist/src/random/distributions/bates.js +15 -0
  37. package/dist/src/random/distributions/bates.js.map +1 -0
  38. package/dist/src/random/distributions/bernoulli.d.ts +17 -0
  39. package/dist/src/random/distributions/bernoulli.d.ts.map +1 -0
  40. package/dist/src/random/distributions/bernoulli.js +13 -0
  41. package/dist/src/random/distributions/bernoulli.js.map +1 -0
  42. package/dist/src/random/distributions/binomial.d.ts +17 -0
  43. package/dist/src/random/distributions/binomial.d.ts.map +1 -0
  44. package/dist/src/random/distributions/binomial.js +24 -0
  45. package/dist/src/random/distributions/binomial.js.map +1 -0
  46. package/dist/src/random/distributions/exponential.d.ts +17 -0
  47. package/dist/src/random/distributions/exponential.d.ts.map +1 -0
  48. package/dist/src/random/distributions/exponential.js +13 -0
  49. package/dist/src/random/distributions/exponential.js.map +1 -0
  50. package/dist/src/random/distributions/geometric.d.ts +17 -0
  51. package/dist/src/random/distributions/geometric.d.ts.map +1 -0
  52. package/dist/src/random/distributions/geometric.js +14 -0
  53. package/dist/src/random/distributions/geometric.js.map +1 -0
  54. package/dist/src/random/distributions/irwin-hall.d.ts +17 -0
  55. package/dist/src/random/distributions/irwin-hall.d.ts.map +1 -0
  56. package/dist/src/random/distributions/irwin-hall.js +18 -0
  57. package/dist/src/random/distributions/irwin-hall.js.map +1 -0
  58. package/dist/src/random/distributions/log-normal.d.ts +17 -0
  59. package/dist/src/random/distributions/log-normal.d.ts.map +1 -0
  60. package/dist/src/random/distributions/log-normal.js +12 -0
  61. package/dist/src/random/distributions/log-normal.js.map +1 -0
  62. package/dist/src/random/distributions/normal.d.ts +18 -0
  63. package/dist/src/random/distributions/normal.d.ts.map +1 -0
  64. package/dist/src/random/distributions/normal.js +16 -0
  65. package/dist/src/random/distributions/normal.js.map +1 -0
  66. package/dist/src/random/distributions/pareto.d.ts +17 -0
  67. package/dist/src/random/distributions/pareto.d.ts.map +1 -0
  68. package/dist/src/random/distributions/pareto.js +14 -0
  69. package/dist/src/random/distributions/pareto.js.map +1 -0
  70. package/dist/src/random/distributions/poisson.d.ts +17 -0
  71. package/dist/src/random/distributions/poisson.d.ts.map +1 -0
  72. package/dist/src/random/distributions/poisson.js +81 -0
  73. package/dist/src/random/distributions/poisson.js.map +1 -0
  74. package/dist/src/random/distributions/uniform-int.d.ts +17 -0
  75. package/dist/src/random/distributions/uniform-int.d.ts.map +1 -0
  76. package/dist/src/random/distributions/uniform-int.js +16 -0
  77. package/dist/src/random/distributions/uniform-int.js.map +1 -0
  78. package/dist/src/random/distributions/uniform.d.ts +17 -0
  79. package/dist/src/random/distributions/uniform.d.ts.map +1 -0
  80. package/dist/src/random/distributions/uniform.js +10 -0
  81. package/dist/src/random/distributions/uniform.js.map +1 -0
  82. package/dist/src/random/rng.d.ts +21 -0
  83. package/dist/src/random/rng.d.ts.map +1 -0
  84. package/dist/src/random/rng.js +7 -0
  85. package/dist/src/random/rng.js.map +1 -0
  86. package/dist/src/random/xorshift128.d.ts +42 -0
  87. package/dist/src/random/xorshift128.d.ts.map +1 -0
  88. package/dist/src/random/xorshift128.js +119 -0
  89. package/dist/src/random/xorshift128.js.map +1 -0
  90. package/dist/src/random.d.ts +822 -0
  91. package/dist/src/random.d.ts.map +1 -0
  92. package/dist/src/random.js +992 -0
  93. package/dist/src/random.js.map +1 -0
  94. package/dist/src/test.d.ts +86 -0
  95. package/dist/src/test.d.ts.map +1 -0
  96. package/dist/src/test.js +160 -0
  97. package/dist/src/test.js.map +1 -0
  98. package/dist/src/time.d.ts +201 -0
  99. package/dist/src/time.d.ts.map +1 -0
  100. package/dist/src/time.js +300 -0
  101. package/dist/src/time.js.map +1 -0
  102. package/package.json +64 -0
@@ -0,0 +1,237 @@
1
+ /**
2
+ * Copyright (c) 2025 Elara AI Pty Ltd
3
+ * Dual-licensed under AGPL-3.0 and commercial license. See LICENSE for details.
4
+ */
5
+ import { StringType, NullType } from "@elaraai/east";
6
+ import type { PlatformFunction } from "@elaraai/east/internal";
7
+ /**
8
+ * Where an East program's console output goes: its host's standard output
9
+ * and standard error.
10
+ *
11
+ * A browser has no standard streams, so the host that runs the program gives
12
+ * them: e3-web appends each to the execution's log, and
13
+ * {@link globalConsoleSink} hands each to the page's `console`. Each call
14
+ * carries the text the program wrote, exactly — {@link Console.log} and
15
+ * {@link Console.error} end it with a newline, {@link Console.write} does not
16
+ * — so a sink that appends it to a log holds what east-node-std writes to
17
+ * its process's streams.
18
+ *
19
+ * @remarks
20
+ * A sink that throws fails the East call that wrote, with an `EastError`.
21
+ */
22
+ export interface ConsoleSink {
23
+ /** Takes text the program writes to standard output. */
24
+ stdout(text: string): void;
25
+ /** Takes text the program writes to standard error. */
26
+ stderr(text: string): void;
27
+ }
28
+ /**
29
+ * The global `console` as a {@link ConsoleSink}: standard output to
30
+ * `console.log`, standard error to `console.error`.
31
+ *
32
+ * A console shows each call as one entry, so a write becomes an entry of its
33
+ * own, and the newline that ends a line is dropped rather than shown as an
34
+ * empty line below it.
35
+ *
36
+ * @remarks
37
+ * This is the sink {@link ConsoleImpl} and `WebPlatform` write to. A host
38
+ * that keeps a log gives `createWebPlatform` its own sink instead.
39
+ */
40
+ export declare const globalConsoleSink: ConsoleSink;
41
+ /**
42
+ * Writes a message to stdout with a newline.
43
+ *
44
+ * Outputs a string message to standard output (stdout) followed by a newline character.
45
+ * This is useful for general logging and output in East programs.
46
+ *
47
+ * This is a platform function for the East language, enabling console output
48
+ * in East programs running in a browser, where the host's {@link ConsoleSink}
49
+ * is standard output.
50
+ *
51
+ * @param message - The message to write to stdout
52
+ * @returns Null
53
+ *
54
+ * @throws {EastError} When the host's sink fails to take the output
55
+ *
56
+ * @example
57
+ * ```ts
58
+ * const logMessage = East.function([], NullType, $ => {
59
+ * $(Console.log("Hello, World!"));
60
+ * });
61
+ * ```
62
+ */
63
+ export declare const console_log: import("@elaraai/east").PlatformDefinition<[StringType], NullType>;
64
+ /**
65
+ * Writes a message to stderr with a newline.
66
+ *
67
+ * Outputs a string message to standard error (stderr) followed by a newline character.
68
+ * This is used for error messages and warnings, keeping them separate from normal output.
69
+ *
70
+ * This is a platform function for the East language, enabling error output
71
+ * in East programs running in a browser, where the host's {@link ConsoleSink}
72
+ * is standard error.
73
+ *
74
+ * @param message - The message to write to stderr
75
+ * @returns Null
76
+ *
77
+ * @throws {EastError} When the host's sink fails to take the output
78
+ *
79
+ * @example
80
+ * ```ts
81
+ * const logError = East.function([], NullType, $ => {
82
+ * $(Console.error("Error: Invalid input"));
83
+ * });
84
+ * ```
85
+ */
86
+ export declare const console_error: import("@elaraai/east").PlatformDefinition<[StringType], NullType>;
87
+ /**
88
+ * Writes a message to stdout without a newline.
89
+ *
90
+ * Outputs a string message to standard output (stdout) without appending a newline.
91
+ * This allows building output incrementally or creating progress indicators on a single line.
92
+ *
93
+ * This is a platform function for the East language, enabling raw console output
94
+ * in East programs running in a browser, where the host's {@link ConsoleSink}
95
+ * is standard output.
96
+ *
97
+ * @param message - The message to write to stdout
98
+ * @returns Null
99
+ *
100
+ * @throws {EastError} When the host's sink fails to take the output
101
+ *
102
+ * @example
103
+ * ```ts
104
+ * const showProgress = East.function([], NullType, $ => {
105
+ * $(Console.write("Processing... "));
106
+ * $(Console.log("done!"));
107
+ * });
108
+ * ```
109
+ */
110
+ export declare const console_write: import("@elaraai/east").PlatformDefinition<[StringType], NullType>;
111
+ /**
112
+ * Creates the console platform functions over a host's sink.
113
+ *
114
+ * @param sink - Where the program's standard output and standard error go
115
+ * @returns The console platform functions, writing to `sink`
116
+ *
117
+ * @example
118
+ * ```ts
119
+ * import { East, NullType } from "@elaraai/east";
120
+ * import { Console, createConsoleImpl } from "@elaraai/east-web-std";
121
+ *
122
+ * let stdout = "";
123
+ * const greet = East.function([], NullType, $ => {
124
+ * $(Console.write("Hello, "));
125
+ * $(Console.log("World!"));
126
+ * });
127
+ *
128
+ * const compiled = East.compile(greet, createConsoleImpl({
129
+ * stdout: text => { stdout += text; },
130
+ * stderr: () => {},
131
+ * }));
132
+ * compiled(); // stdout is now "Hello, World!\n"
133
+ * ```
134
+ */
135
+ export declare function createConsoleImpl(sink: ConsoleSink): PlatformFunction[];
136
+ /**
137
+ * Browser implementation of console platform functions, writing to the
138
+ * global `console` ({@link globalConsoleSink}).
139
+ *
140
+ * Pass this array to {@link East.compile} to enable console I/O operations.
141
+ */
142
+ declare const ConsoleImpl: PlatformFunction[];
143
+ /**
144
+ * Grouped console I/O platform functions.
145
+ *
146
+ * Provides standard console operations for East programs.
147
+ *
148
+ * @example
149
+ * ```ts
150
+ * import { East, NullType } from "@elaraai/east";
151
+ * import { Console } from "@elaraai/east-web-std";
152
+ *
153
+ * const greet = East.function([], NullType, $ => {
154
+ * $(Console.log("Hello, World!"));
155
+ * $(Console.error("This is a warning"));
156
+ * $(Console.write("No newline here"));
157
+ * });
158
+ *
159
+ * const compiled = East.compile(greet, Console.Implementation);
160
+ * compiled();
161
+ * ```
162
+ */
163
+ export declare const Console: {
164
+ /**
165
+ * Writes a message to stdout with a newline.
166
+ *
167
+ * Outputs a string message to standard output (stdout) followed by a newline character.
168
+ * This is useful for general logging and output in East programs.
169
+ *
170
+ * @param message - The message to write to stdout
171
+ * @returns Null
172
+ * @throws {EastError} When the host's sink fails to take the output
173
+ *
174
+ * @example
175
+ * ```ts
176
+ * const logMessage = East.function([], NullType, $ => {
177
+ * $(Console.log("Hello, World!"));
178
+ * });
179
+ *
180
+ * const compiled = East.compile(logMessage, Console.Implementation);
181
+ * compiled(); // Outputs: Hello, World!
182
+ * ```
183
+ */
184
+ readonly log: import("@elaraai/east").PlatformDefinition<[StringType], NullType>;
185
+ /**
186
+ * Writes a message to stderr with a newline.
187
+ *
188
+ * Outputs a string message to standard error (stderr) followed by a newline character.
189
+ * This is used for error messages and warnings, keeping them separate from normal output.
190
+ *
191
+ * @param message - The message to write to stderr
192
+ * @returns Null
193
+ * @throws {EastError} When the host's sink fails to take the output
194
+ *
195
+ * @example
196
+ * ```ts
197
+ * const logError = East.function([], NullType, $ => {
198
+ * $(Console.error("Error: Invalid input"));
199
+ * });
200
+ *
201
+ * const compiled = East.compile(logError, Console.Implementation);
202
+ * compiled(); // Outputs to stderr: Error: Invalid input
203
+ * ```
204
+ */
205
+ readonly error: import("@elaraai/east").PlatformDefinition<[StringType], NullType>;
206
+ /**
207
+ * Writes a message to stdout without a newline.
208
+ *
209
+ * Outputs a string message to standard output (stdout) without appending a newline.
210
+ * This allows building output incrementally or creating progress indicators.
211
+ *
212
+ * @param message - The message to write to stdout
213
+ * @returns Null
214
+ * @throws {EastError} When the host's sink fails to take the output
215
+ *
216
+ * @example
217
+ * ```ts
218
+ * const showProgress = East.function([], NullType, $ => {
219
+ * $(Console.write("Processing... "));
220
+ * $(Console.log("done!"));
221
+ * });
222
+ *
223
+ * const compiled = East.compile(showProgress, Console.Implementation);
224
+ * compiled(); // Outputs: Processing... done!
225
+ * ```
226
+ */
227
+ readonly write: import("@elaraai/east").PlatformDefinition<[StringType], NullType>;
228
+ /**
229
+ * Browser implementation of console platform functions, writing to the
230
+ * global `console`.
231
+ *
232
+ * Pass this to {@link East.compile} to enable console I/O operations.
233
+ */
234
+ readonly Implementation: PlatformFunction[];
235
+ };
236
+ export { ConsoleImpl };
237
+ //# sourceMappingURL=console.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"console.d.ts","sourceRoot":"","sources":["../../src/console.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAQ,UAAU,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAC3D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAG/D;;;;;;;;;;;;;;GAcG;AACH,MAAM,WAAW,WAAW;IACxB,wDAAwD;IACxD,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,uDAAuD;IACvD,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;CAC9B;AAOD;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,iBAAiB,EAAE,WAG/B,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,eAAO,MAAM,WAAW,oEAAuD,CAAC;AAEhF;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,eAAO,MAAM,aAAa,oEAAyD,CAAC;AAEpF;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,eAAO,MAAM,aAAa,oEAAyD,CAAC;AAEpF;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,WAAW,GAAG,gBAAgB,EAAE,CAiCvE;AAED;;;;;GAKG;AACH,QAAA,MAAM,WAAW,EAAE,gBAAgB,EAAyC,CAAC;AAE7E;;;;;;;;;;;;;;;;;;;GAmBG;AACH,eAAO,MAAM,OAAO;IAChB;;;;;;;;;;;;;;;;;;;OAmBG;;IAGH;;;;;;;;;;;;;;;;;;;OAmBG;;IAGH;;;;;;;;;;;;;;;;;;;;OAoBG;;IAGH;;;;;OAKG;;CAEG,CAAC;AAGX,OAAO,EAAE,WAAW,EAAE,CAAC"}
@@ -0,0 +1,260 @@
1
+ /**
2
+ * Copyright (c) 2025 Elara AI Pty Ltd
3
+ * Dual-licensed under AGPL-3.0 and commercial license. See LICENSE for details.
4
+ */
5
+ import { East, StringType, NullType } from "@elaraai/east";
6
+ import { EastError } from "@elaraai/east/internal";
7
+ /** The text without its final newline, when it ends with one. */
8
+ function withoutFinalNewline(text) {
9
+ return text.endsWith("\n") ? text.slice(0, -1) : text;
10
+ }
11
+ /**
12
+ * The global `console` as a {@link ConsoleSink}: standard output to
13
+ * `console.log`, standard error to `console.error`.
14
+ *
15
+ * A console shows each call as one entry, so a write becomes an entry of its
16
+ * own, and the newline that ends a line is dropped rather than shown as an
17
+ * empty line below it.
18
+ *
19
+ * @remarks
20
+ * This is the sink {@link ConsoleImpl} and `WebPlatform` write to. A host
21
+ * that keeps a log gives `createWebPlatform` its own sink instead.
22
+ */
23
+ export const globalConsoleSink = {
24
+ stdout: (text) => { console.log(withoutFinalNewline(text)); },
25
+ stderr: (text) => { console.error(withoutFinalNewline(text)); },
26
+ };
27
+ /**
28
+ * Writes a message to stdout with a newline.
29
+ *
30
+ * Outputs a string message to standard output (stdout) followed by a newline character.
31
+ * This is useful for general logging and output in East programs.
32
+ *
33
+ * This is a platform function for the East language, enabling console output
34
+ * in East programs running in a browser, where the host's {@link ConsoleSink}
35
+ * is standard output.
36
+ *
37
+ * @param message - The message to write to stdout
38
+ * @returns Null
39
+ *
40
+ * @throws {EastError} When the host's sink fails to take the output
41
+ *
42
+ * @example
43
+ * ```ts
44
+ * const logMessage = East.function([], NullType, $ => {
45
+ * $(Console.log("Hello, World!"));
46
+ * });
47
+ * ```
48
+ */
49
+ export const console_log = East.platform("console_log", [StringType], NullType);
50
+ /**
51
+ * Writes a message to stderr with a newline.
52
+ *
53
+ * Outputs a string message to standard error (stderr) followed by a newline character.
54
+ * This is used for error messages and warnings, keeping them separate from normal output.
55
+ *
56
+ * This is a platform function for the East language, enabling error output
57
+ * in East programs running in a browser, where the host's {@link ConsoleSink}
58
+ * is standard error.
59
+ *
60
+ * @param message - The message to write to stderr
61
+ * @returns Null
62
+ *
63
+ * @throws {EastError} When the host's sink fails to take the output
64
+ *
65
+ * @example
66
+ * ```ts
67
+ * const logError = East.function([], NullType, $ => {
68
+ * $(Console.error("Error: Invalid input"));
69
+ * });
70
+ * ```
71
+ */
72
+ export const console_error = East.platform("console_error", [StringType], NullType);
73
+ /**
74
+ * Writes a message to stdout without a newline.
75
+ *
76
+ * Outputs a string message to standard output (stdout) without appending a newline.
77
+ * This allows building output incrementally or creating progress indicators on a single line.
78
+ *
79
+ * This is a platform function for the East language, enabling raw console output
80
+ * in East programs running in a browser, where the host's {@link ConsoleSink}
81
+ * is standard output.
82
+ *
83
+ * @param message - The message to write to stdout
84
+ * @returns Null
85
+ *
86
+ * @throws {EastError} When the host's sink fails to take the output
87
+ *
88
+ * @example
89
+ * ```ts
90
+ * const showProgress = East.function([], NullType, $ => {
91
+ * $(Console.write("Processing... "));
92
+ * $(Console.log("done!"));
93
+ * });
94
+ * ```
95
+ */
96
+ export const console_write = East.platform("console_write", [StringType], NullType);
97
+ /**
98
+ * Creates the console platform functions over a host's sink.
99
+ *
100
+ * @param sink - Where the program's standard output and standard error go
101
+ * @returns The console platform functions, writing to `sink`
102
+ *
103
+ * @example
104
+ * ```ts
105
+ * import { East, NullType } from "@elaraai/east";
106
+ * import { Console, createConsoleImpl } from "@elaraai/east-web-std";
107
+ *
108
+ * let stdout = "";
109
+ * const greet = East.function([], NullType, $ => {
110
+ * $(Console.write("Hello, "));
111
+ * $(Console.log("World!"));
112
+ * });
113
+ *
114
+ * const compiled = East.compile(greet, createConsoleImpl({
115
+ * stdout: text => { stdout += text; },
116
+ * stderr: () => {},
117
+ * }));
118
+ * compiled(); // stdout is now "Hello, World!\n"
119
+ * ```
120
+ */
121
+ export function createConsoleImpl(sink) {
122
+ return [
123
+ console_log.implement((msg) => {
124
+ try {
125
+ sink.stdout(`${msg}\n`);
126
+ }
127
+ catch (err) {
128
+ throw new EastError(`Failed to write to stdout: ${err.message}`, {
129
+ location: [{ filename: "console_log", line: 0n, column: 0n }],
130
+ cause: err
131
+ });
132
+ }
133
+ }),
134
+ console_error.implement((msg) => {
135
+ try {
136
+ sink.stderr(`${msg}\n`);
137
+ }
138
+ catch (err) {
139
+ throw new EastError(`Failed to write to stderr: ${err.message}`, {
140
+ location: [{ filename: "console_error", line: 0n, column: 0n }],
141
+ cause: err
142
+ });
143
+ }
144
+ }),
145
+ console_write.implement((msg) => {
146
+ try {
147
+ sink.stdout(msg);
148
+ }
149
+ catch (err) {
150
+ throw new EastError(`Failed to write to stdout: ${err.message}`, {
151
+ location: [{ filename: "console_write", line: 0n, column: 0n }],
152
+ cause: err
153
+ });
154
+ }
155
+ }),
156
+ ];
157
+ }
158
+ /**
159
+ * Browser implementation of console platform functions, writing to the
160
+ * global `console` ({@link globalConsoleSink}).
161
+ *
162
+ * Pass this array to {@link East.compile} to enable console I/O operations.
163
+ */
164
+ const ConsoleImpl = createConsoleImpl(globalConsoleSink);
165
+ /**
166
+ * Grouped console I/O platform functions.
167
+ *
168
+ * Provides standard console operations for East programs.
169
+ *
170
+ * @example
171
+ * ```ts
172
+ * import { East, NullType } from "@elaraai/east";
173
+ * import { Console } from "@elaraai/east-web-std";
174
+ *
175
+ * const greet = East.function([], NullType, $ => {
176
+ * $(Console.log("Hello, World!"));
177
+ * $(Console.error("This is a warning"));
178
+ * $(Console.write("No newline here"));
179
+ * });
180
+ *
181
+ * const compiled = East.compile(greet, Console.Implementation);
182
+ * compiled();
183
+ * ```
184
+ */
185
+ export const Console = {
186
+ /**
187
+ * Writes a message to stdout with a newline.
188
+ *
189
+ * Outputs a string message to standard output (stdout) followed by a newline character.
190
+ * This is useful for general logging and output in East programs.
191
+ *
192
+ * @param message - The message to write to stdout
193
+ * @returns Null
194
+ * @throws {EastError} When the host's sink fails to take the output
195
+ *
196
+ * @example
197
+ * ```ts
198
+ * const logMessage = East.function([], NullType, $ => {
199
+ * $(Console.log("Hello, World!"));
200
+ * });
201
+ *
202
+ * const compiled = East.compile(logMessage, Console.Implementation);
203
+ * compiled(); // Outputs: Hello, World!
204
+ * ```
205
+ */
206
+ log: console_log,
207
+ /**
208
+ * Writes a message to stderr with a newline.
209
+ *
210
+ * Outputs a string message to standard error (stderr) followed by a newline character.
211
+ * This is used for error messages and warnings, keeping them separate from normal output.
212
+ *
213
+ * @param message - The message to write to stderr
214
+ * @returns Null
215
+ * @throws {EastError} When the host's sink fails to take the output
216
+ *
217
+ * @example
218
+ * ```ts
219
+ * const logError = East.function([], NullType, $ => {
220
+ * $(Console.error("Error: Invalid input"));
221
+ * });
222
+ *
223
+ * const compiled = East.compile(logError, Console.Implementation);
224
+ * compiled(); // Outputs to stderr: Error: Invalid input
225
+ * ```
226
+ */
227
+ error: console_error,
228
+ /**
229
+ * Writes a message to stdout without a newline.
230
+ *
231
+ * Outputs a string message to standard output (stdout) without appending a newline.
232
+ * This allows building output incrementally or creating progress indicators.
233
+ *
234
+ * @param message - The message to write to stdout
235
+ * @returns Null
236
+ * @throws {EastError} When the host's sink fails to take the output
237
+ *
238
+ * @example
239
+ * ```ts
240
+ * const showProgress = East.function([], NullType, $ => {
241
+ * $(Console.write("Processing... "));
242
+ * $(Console.log("done!"));
243
+ * });
244
+ *
245
+ * const compiled = East.compile(showProgress, Console.Implementation);
246
+ * compiled(); // Outputs: Processing... done!
247
+ * ```
248
+ */
249
+ write: console_write,
250
+ /**
251
+ * Browser implementation of console platform functions, writing to the
252
+ * global `console`.
253
+ *
254
+ * Pass this to {@link East.compile} to enable console I/O operations.
255
+ */
256
+ Implementation: ConsoleImpl,
257
+ };
258
+ // Exported beside `Console.Implementation`, as east-node-std exports it
259
+ export { ConsoleImpl };
260
+ //# sourceMappingURL=console.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"console.js","sourceRoot":"","sources":["../../src/console.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAE3D,OAAO,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AAwBnD,iEAAiE;AACjE,SAAS,mBAAmB,CAAC,IAAY;IACrC,OAAO,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;AAC1D,CAAC;AAED;;;;;;;;;;;GAWG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAgB;IAC1C,MAAM,EAAE,CAAC,IAAY,EAAE,EAAE,GAAG,OAAO,CAAC,GAAG,CAAC,mBAAmB,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;IACrE,MAAM,EAAE,CAAC,IAAY,EAAE,EAAE,GAAG,OAAO,CAAC,KAAK,CAAC,mBAAmB,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;CAC1E,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG,IAAI,CAAC,QAAQ,CAAC,aAAa,EAAE,CAAC,UAA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