@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
package/CLA.md ADDED
@@ -0,0 +1,26 @@
1
+ # Contributor License Agreement
2
+
3
+ This Contributor License Agreement ("Agreement") is entered into between Elara AI Pty Ltd ("Company") and you (the "Contributor").
4
+
5
+ ## Grant of Copyright License
6
+
7
+ You hereby grant to the Company and to recipients of software distributed by the Company a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare derivative works of, publicly display, publicly perform, sublicense, distribute, and use Your Contributions and such derivative works.
8
+
9
+ ## Grant of Patent License
10
+
11
+ You hereby grant to the Company and to recipients of software distributed by the Company a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer Your Contributions.
12
+
13
+ ## Relicensing Rights
14
+
15
+ You grant the Company the right to license Your Contributions under any license terms, including but not limited to commercial licenses, in addition to the open source license under which the project is distributed.
16
+
17
+ ## Your Representations
18
+
19
+ You represent that:
20
+ - You are legally entitled to grant the above licenses
21
+ - Each of Your Contributions is Your original creation
22
+ - Your Contribution submissions include complete details of any third-party license or other restriction of which you are aware
23
+
24
+ ## Agreement
25
+
26
+ By signing this Agreement through CLA Assistant or by submitting a Contribution, you accept and agree to the terms of this Agreement.
@@ -0,0 +1,28 @@
1
+ # Contributing to east-web-std
2
+
3
+ Thank you for your interest in contributing! We welcome contributions from the community.
4
+
5
+ ## Contributor License Agreement (CLA)
6
+
7
+ Before we can accept your contribution, you must sign our Contributor License Agreement (CLA). This agreement gives Elara AI Pty Ltd the right to use and relicense your contributions, including under commercial licenses, while you retain ownership of your contribution.
8
+
9
+ **Why do we require a CLA?**
10
+ This project is dual-licensed under AGPL-3.0 and commercial licenses. The CLA allows us to offer commercial licenses to users who wish to use this software in proprietary applications.
11
+
12
+ ### Signing the CLA
13
+
14
+ When you submit your first pull request, the CLA Assistant bot will automatically comment on your PR with a link to sign the CLA electronically. It only takes a minute, and you'll only need to sign it once.
15
+
16
+ ## Contributing Process
17
+
18
+ 1. Fork the [east-workspace monorepo](https://github.com/elaraai/east-workspace)
19
+ 2. Create a feature branch (`git checkout -b feature/amazing-feature`)
20
+ 3. Make your changes
21
+ 4. Commit your changes (`git commit -m 'Add amazing feature'`)
22
+ 5. Push to the branch (`git push origin feature/amazing-feature`)
23
+ 6. Open a Pull Request
24
+ 7. Sign the CLA when the bot prompts you
25
+
26
+ ## Questions?
27
+
28
+ Contact us at support@elara.ai
package/LICENSE.md ADDED
@@ -0,0 +1,31 @@
1
+ Copyright (c) 2025 Elara AI Pty Ltd
2
+
3
+ # Dual License — AGPL-3.0 / Commercial
4
+
5
+ This software is available under two licenses. You may choose which license applies to your use:
6
+
7
+ ## Option 1: AGPL-3.0 (Open Source)
8
+
9
+ You may use, modify, and distribute this software under the terms of the GNU Affero General Public License v3.0.
10
+
11
+ This requires that if you use this software in a network service, you must make your complete source code available under AGPL-3.0.
12
+
13
+ Full text: https://www.gnu.org/licenses/agpl-3.0.html
14
+
15
+ ## Option 2: Commercial License
16
+
17
+ If you wish to use this software without the source code disclosure requirements of AGPL-3.0, you must obtain a commercial license from Elara AI Pty Ltd.
18
+
19
+ Contact: support@elara.ai
20
+
21
+ ## Contributions
22
+
23
+ Contributions are welcome. By submitting a pull request, you agree to license your contribution under both AGPL-3.0 and our commercial license terms.
24
+
25
+ ## Governing Law
26
+
27
+ This license is governed by the laws of New South Wales, Australia.
28
+
29
+ ---
30
+
31
+ *Elara AI Pty Ltd*
package/README.md ADDED
@@ -0,0 +1,191 @@
1
+ # East Web
2
+
3
+ > Standard platform functions for East programs in a browser
4
+
5
+ [![License](https://img.shields.io/badge/license-AGPL--3.0-blue.svg)](LICENSE.md)
6
+
7
+ **East Web** provides the standard platform functions of the [East language](https://github.com/elaraai/east-workspace/tree/main/libs/east) for East programs running in a browser: console output, the clock, random numbers, cryptography, HTTP requests and path manipulation. Each one has the name and East types of its [East Node](https://github.com/elaraai/east-workspace/tree/main/libs/east-node) twin, so a program written for Node — or run on East's C and Python runtimes — runs in a browser unchanged. It uses web-standard globals only and loads no Node module.
8
+
9
+ ## Features
10
+
11
+ - **Console I/O** - stdout/stderr output, to a sink the host gives
12
+ - **Time Operations** - Timestamps, sleep and timezone offsets
13
+ - **Random** - Random number generation with statistical distributions; a seed gives East Node's stream, bit for bit
14
+ - **Cryptography** - Random bytes, SHA-256, UUID generation
15
+ - **HTTP Client** - The browser's Fetch API
16
+ - **Path Utilities** - POSIX path manipulation
17
+ - **Test Functions** - The functions East test suites call, run through a host
18
+ - **Type-Safe** - Full TypeScript support with EastError handling
19
+
20
+ ## Installation
21
+
22
+ ```bash
23
+ npm install @elaraai/east-web-std @elaraai/east
24
+ ```
25
+
26
+ ## Quick Start
27
+
28
+ ```typescript
29
+ import { East, NullType } from "@elaraai/east";
30
+ import { Console, Crypto, createWebPlatform } from "@elaraai/east-web-std";
31
+
32
+ // Define an East function using platform functions
33
+ const greet = East.asyncFunction([], NullType, $ => {
34
+ const id = $.let(Crypto.uuid());
35
+ $(Console.log(id));
36
+ });
37
+
38
+ // Compile it on a browser platform whose console output the page keeps
39
+ let output = "";
40
+ const platform = createWebPlatform({
41
+ console: {
42
+ stdout: text => { output += text; },
43
+ stderr: text => { output += text; },
44
+ },
45
+ });
46
+ await greet.toIR().compile(platform)();
47
+ ```
48
+
49
+ ## Platform Functions
50
+
51
+ | Module | Functions | Description |
52
+ |--------|-----------|-------------|
53
+ | **Console** | `log`, `error`, `write` | Console output, to the host's sink |
54
+ | **Time** | `now`, `sleep`, `getTimezoneOffset` | Time, delay and timezone operations |
55
+ | **Random** | `uniform`, `normal`, `range`, `exponential`, `bernoulli`, `seed`, etc. | Random number generation with statistical distributions |
56
+ | **Crypto** | `randomBytes`, `hashSha256`, `hashSha256Bytes`, `uuid` | Cryptographic operations |
57
+ | **Fetch** | `get`, `getBytes`, `post`, `request` | HTTP client using the browser's Fetch API |
58
+ | **Path** | `join`, `resolve`, `dirname`, `basename`, `extname` | POSIX path manipulation |
59
+
60
+ **Complete platform:**
61
+ ```typescript
62
+ import { WebPlatform } from "@elaraai/east-web-std";
63
+ const compiled = myFunction.toIR().compile(WebPlatform);
64
+ ```
65
+
66
+ **A platform of the program's own** — its console sink, its test host, and a
67
+ Random generator no other program shares:
68
+ ```typescript
69
+ import { createWebPlatform } from "@elaraai/east-web-std";
70
+ const compiled = myFunction.toIR().compile(createWebPlatform({ console: sink }));
71
+ ```
72
+
73
+ A host that stops a program without ending its thread gives a `signal`: once
74
+ it aborts, a `Time.sleep` under way fails at once, its timer cleared, so
75
+ nothing the program left keeps the thread's event loop alive.
76
+
77
+ **Individual modules:**
78
+ ```typescript
79
+ import { Path, Crypto } from "@elaraai/east-web-std";
80
+ const compiled = East.compile(myFunction, [...Path.Implementation, ...Crypto.Implementation]);
81
+ ```
82
+
83
+ ## In a browser
84
+
85
+ - **Console** has no standard streams to write to: the host gives a
86
+ `ConsoleSink` with `stdout` and `stderr`, and receives exactly the text the
87
+ program wrote. `WebPlatform` writes to the page's `console`.
88
+ - **Path.resolve** resolves a relative path against `/`: a browser has no
89
+ working directory.
90
+ - **Fetch** is subject to the browser's rules: a cross-origin request needs the
91
+ server's CORS consent, and some request and response headers are hidden.
92
+ - **Crypto.uuid** needs a secure context (a page served over HTTPS, or from
93
+ localhost).
94
+ - **Random** starts unseeded with a cryptographic generator; each
95
+ `createWebPlatform()` has its own.
96
+
97
+ ## What is not provided
98
+
99
+ FileSystem, Env and the large-JSON reader have no meaning in a browser and are
100
+ not provided. A program that calls one of them fails to compile, naming the
101
+ platform function it called — as East fails any program that calls a platform
102
+ function it was not given.
103
+
104
+ ## Development
105
+
106
+ ```bash
107
+ make build # Compile TypeScript
108
+ make test # Run the specs, then East Node's compliance suite over this package
109
+ make lint # Check code quality
110
+ ```
111
+
112
+ ## Claude Code plugin
113
+
114
+ The East ecosystem also ships a [Claude Code](https://claude.com/claude-code) plugin — East language skills, example search, and preemptive diagnostics for East code — installed separately from the `elaraai` marketplace:
115
+
116
+ ```text
117
+ # Inside Claude Code
118
+ /plugin marketplace add elaraai/east-workspace
119
+ /plugin install east@elaraai
120
+ ```
121
+
122
+ ```bash
123
+ # From a terminal
124
+ claude plugin marketplace add elaraai/east-workspace
125
+ claude plugin install east@elaraai
126
+ ```
127
+
128
+ ## License
129
+
130
+ Dual-licensed:
131
+ - **Open Source**: [AGPL-3.0](LICENSE.md) - Free for open source use
132
+ - **Commercial**: Available for proprietary use - contact support@elara.ai
133
+
134
+ Includes code from third-party open source projects under the MIT License — see [THIRD_PARTY_NOTICES.md](THIRD_PARTY_NOTICES.md).
135
+
136
+ ### Ecosystem
137
+
138
+ - **[East](https://github.com/elaraai/east-workspace/tree/main/libs/east)**: Statically typed, expression-based language with serializable IR. Run portable logic across TypeScript, Python, C, and other runtimes.
139
+ - [@elaraai/east](https://www.npmjs.com/package/@elaraai/east): Core language SDK with type system, expressions, and reference JS compiler
140
+
141
+ - **[East Node](https://github.com/elaraai/east-workspace/tree/main/libs/east-node)**: Node.js platform functions for I/O, databases, and system operations.
142
+ - [@elaraai/east-node-std](https://www.npmjs.com/package/@elaraai/east-node-std): Console, FileSystem, Fetch, Crypto, Time, Path, Random
143
+ - [@elaraai/east-node-io](https://www.npmjs.com/package/@elaraai/east-node-io): SQLite, PostgreSQL, MySQL, MongoDB, Redis, S3, FTP, SFTP, XLSX, XML, compression
144
+ - [@elaraai/east-node-cli](https://www.npmjs.com/package/@elaraai/east-node-cli): CLI for running East IR programs in Node.js
145
+
146
+ - **[East Web](https://github.com/elaraai/east-workspace/tree/main/libs/east-web)**: Platform functions for East programs in a browser.
147
+ - [@elaraai/east-web-std](https://www.npmjs.com/package/@elaraai/east-web-std): Console, Fetch, Crypto, Time, Path, Random
148
+
149
+ - **[East C](https://github.com/elaraai/east-workspace/tree/main/libs/east-c)**: C11 native runtime for executing East IR. Distributed via npm (launcher + per-platform optional dependencies) and as tarballs on each GitHub Release.
150
+ - [@elaraai/east-c-cli](https://www.npmjs.com/package/@elaraai/east-c-cli): npm launcher — installs the matching native binary as an optional dependency
151
+ - `east-c`: Core runtime — type system, IR interpreter, builtins, serialization (Beast2, JSON, CSV, East text)
152
+ - `east-c-std`: Console, FileSystem, Fetch, Crypto, Time, Path, Random
153
+ - `east-c-cli`: CLI for running East IR programs natively
154
+
155
+ - **[East Python](https://github.com/elaraai/east-workspace/tree/main/libs/east-py)**: Python runtime, standard platform, I/O, and data-science platform functions. Published to PyPI.
156
+ - [east-py](https://pypi.org/project/east-py/): Core Python runtime — type system, IR compiler, 212+ builtins, Cython-accelerated hot paths
157
+ - [east-py-std](https://pypi.org/project/east-py-std/): Console, FileSystem, Fetch, Crypto, Time, Path, Random
158
+ - [east-py-io](https://pypi.org/project/east-py-io/): SQLite, PostgreSQL, MySQL, MongoDB, Redis, S3, FTP, SFTP, XLSX, XML, compression
159
+ - [east-py-cli](https://pypi.org/project/east-py-cli/): CLI for running East IR programs in Python
160
+ - [east-py-datascience](https://pypi.org/project/east-py-datascience/) (PyPI) + [@elaraai/east-py-datascience](https://www.npmjs.com/package/@elaraai/east-py-datascience) (npm): Optimization (MADS, Optuna, ALNS, GoogleOR), ML (XGBoost, LightGBM, NGBoost, PyTorch, Lightning, GP), Bayesian inference (PyMC), explainability (SHAP), conformal prediction (MAPIE)
161
+
162
+ - **[East UI](https://github.com/elaraai/east-workspace/tree/main/libs/east-ui)**: Typed UI component definitions and React renderer, plus VS Code preview.
163
+ - [@elaraai/east-ui](https://www.npmjs.com/package/@elaraai/east-ui): 50+ typed UI components for layouts, forms, charts, tables, dialogs
164
+ - [@elaraai/east-ui-components](https://www.npmjs.com/package/@elaraai/east-ui-components): React renderer with Chakra UI v3 styling
165
+ - [@elaraai/e3-ui](https://www.npmjs.com/package/@elaraai/e3-ui): e3 + UI bridge — Data bindings, `e3.ui()` task, manifest
166
+ - [@elaraai/e3-ui-components](https://www.npmjs.com/package/@elaraai/e3-ui-components): React Query hooks and preview components for the e3 API
167
+ - [east-ui-preview](https://marketplace.visualstudio.com/items?itemName=ElaraAI.east-ui-preview): VS Code extension for live East UI component preview
168
+
169
+ - **[e3 — East Execution Engine](https://github.com/elaraai/east-workspace/tree/main/libs/e3)**: Durable execution engine for running East pipelines at scale. Git-like content-addressable storage, automatic memoization, reactive dataflow, real-time monitoring.
170
+ - [@elaraai/e3](https://www.npmjs.com/package/@elaraai/e3): SDK for authoring e3 packages with typed tasks and pipelines
171
+ - [@elaraai/e3-core](https://www.npmjs.com/package/@elaraai/e3-core): Object store, dataflow orchestrator, execution state
172
+ - [@elaraai/e3-types](https://www.npmjs.com/package/@elaraai/e3-types): Shared type definitions for e3 packages
173
+ - [@elaraai/e3-cli](https://www.npmjs.com/package/@elaraai/e3-cli): `e3 repo`, `e3 package`, `e3 workspace`, `e3 dataflow run`, `e3 watch`, `e3 task logs` commands
174
+ - [@elaraai/e3-api-client](https://www.npmjs.com/package/@elaraai/e3-api-client): HTTP client for remote e3 repositories
175
+ - [@elaraai/e3-api-server](https://www.npmjs.com/package/@elaraai/e3-api-server): REST API server for e3 repositories
176
+ - [@elaraai/e3-api-tests](https://www.npmjs.com/package/@elaraai/e3-api-tests): Shared API compliance test suites
177
+
178
+ ## Links
179
+
180
+ - **Website**: [https://elaraai.com/](https://elaraai.com/)
181
+ - **East Repository**: [https://github.com/elaraai/east-workspace/tree/main/libs/east](https://github.com/elaraai/east-workspace/tree/main/libs/east)
182
+ - **Issues**: [https://github.com/elaraai/east-workspace/issues](https://github.com/elaraai/east-workspace/issues)
183
+ - **Email**: support@elara.ai
184
+
185
+ ## About Elara
186
+
187
+ East is developed by [Elara AI Pty Ltd](https://elaraai.com/), an AI-powered platform that creates economic digital twins of businesses that optimize performance. Elara combines business objectives, decisions and data to help organizations make data-driven decisions across operations, purchasing, sales and customer engagement, and project and investment planning. East powers the computational layer of Elara solutions, enabling the expression of complex business logic and data in a simple, type-safe and portable language.
188
+
189
+ ---
190
+
191
+ *Developed by [Elara AI Pty Ltd](https://elaraai.com/).*
@@ -0,0 +1,123 @@
1
+ # Third-Party Notices
2
+
3
+ This project includes code from third-party open source projects. The following is a list of these projects and their licenses.
4
+
5
+ ---
6
+
7
+ ## random
8
+
9
+ **Source:** https://github.com/transitive-bullshit/random
10
+ **License:** MIT License
11
+ **Copyright:** Copyright (c) 2018 Travis Fischer
12
+ **Used in:** `/src/random/` directory
13
+
14
+ The `random` package provides seedable random number generation supporting many different probability distributions. East Node vendored portions of this library (`@elaraai/east-node-std`, `src/random/`), and this package ports East Node's copy verbatim so that a seed gives the same stream on both.
15
+
16
+ ### MIT License
17
+
18
+ ```
19
+ MIT License
20
+
21
+ Copyright (c) 2018 Travis Fischer
22
+
23
+ Permission is hereby granted, free of charge, to any person obtaining a copy
24
+ of this software and associated documentation files (the "Software"), to deal
25
+ in the Software without restriction, including without limitation the rights
26
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
27
+ copies of the Software, and to permit persons to whom the Software is
28
+ furnished to do so, subject to the following conditions:
29
+
30
+ The above copyright notice and this permission notice shall be included in all
31
+ copies or substantial portions of the Software.
32
+
33
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
34
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
35
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
36
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
37
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
38
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
39
+ SOFTWARE.
40
+ ```
41
+
42
+ ### Files Included
43
+
44
+ The following files are derived from the `random` package:
45
+ - `src/random/rng.ts` - Base RNG abstract class
46
+ - `src/random/crypto-rng.ts` - Cryptographically secure RNG implementation (modified)
47
+ - `src/random/distributions/uniform.ts` - Uniform distribution
48
+ - `src/random/distributions/uniform-int.ts` - Uniform integer distribution (modified)
49
+ - `src/random/distributions/normal.ts` - Normal/Gaussian distribution
50
+ - `src/random/distributions/exponential.ts` - Exponential distribution (modified)
51
+ - `src/random/distributions/bernoulli.ts` - Bernoulli distribution (modified)
52
+ - `src/random/distributions/binomial.ts` - Binomial distribution (modified)
53
+ - `src/random/distributions/geometric.ts` - Geometric distribution (modified)
54
+ - `src/random/distributions/poisson.ts` - Poisson distribution (modified)
55
+ - `src/random/distributions/pareto.ts` - Pareto distribution (modified)
56
+ - `src/random/distributions/log-normal.ts` - Log-normal distribution
57
+ - `src/random/distributions/irwin-hall.ts` - Irwin-Hall distribution (modified)
58
+ - `src/random/distributions/bates.ts` - Bates distribution (modified)
59
+
60
+ ### Modifications
61
+
62
+ The vendored code has been modified from the original:
63
+ 1. Converted to TypeScript with explicit type annotations
64
+ 2. Removed dependency on seedable RNG (using crypto RNG instead)
65
+ 3. Removed validation utility dependency (inlined validation)
66
+ 4. Changed integer functions to accept `bigint` instead of `number`
67
+ 5. Added Elara AI copyright headers
68
+ 6. Updated imports to match our project structure
69
+ 7. The cryptographic RNG draws from the web-standard `crypto.getRandomValues` rather than Node.js's `crypto.randomBytes`
70
+
71
+ All modifications are released under the same terms as the rest of this project (AGPL-3.0 or commercial license).
72
+
73
+ ---
74
+
75
+ ## Node.js
76
+
77
+ **Source:** https://github.com/nodejs/node (`lib/path.js`)
78
+ **License:** MIT License
79
+ **Copyright:** Copyright Node.js contributors; Copyright Joyent, Inc. and other Node contributors
80
+ **Used in:** `/src/path.ts`
81
+
82
+ East Node's path platform functions call Node.js's POSIX path functions (`node:path/posix`), which a browser does not have. `src/path.ts` ports their algorithms — `normalizeString`, `normalize`, `join`, `resolve`, `dirname`, `basename` and `extname` — so that a path gives the same answer on both.
83
+
84
+ ### MIT License
85
+
86
+ ```
87
+ Copyright Node.js contributors. All rights reserved.
88
+ Copyright Joyent, Inc. and other Node contributors. All rights reserved.
89
+
90
+ Permission is hereby granted, free of charge, to any person obtaining a copy
91
+ of this software and associated documentation files (the "Software"), to
92
+ deal in the Software without restriction, including without limitation the
93
+ rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
94
+ sell copies of the Software, and to permit persons to whom the Software is
95
+ furnished to do so, subject to the following conditions:
96
+
97
+ The above copyright notice and this permission notice shall be included in
98
+ all copies or substantial portions of the Software.
99
+
100
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
101
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
102
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
103
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
104
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
105
+ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
106
+ IN THE SOFTWARE.
107
+ ```
108
+
109
+ ### Modifications
110
+
111
+ 1. Converted to TypeScript, with the POSIX separator fixed rather than passed in
112
+ 2. `resolve` resolves against `/`, where Node.js reads the process's working directory — a browser has none
113
+ 3. `basename` takes no suffix to strip, as the East platform function takes none
114
+
115
+ All modifications are released under the same terms as the rest of this project (AGPL-3.0 or commercial license).
116
+
117
+ ---
118
+
119
+ ## Compliance Statement
120
+
121
+ The inclusion of MIT-licensed code in this AGPL-3.0 licensed project is permitted as the MIT License is compatible with AGPL-3.0. The MIT License allows use, modification, and distribution, including in projects under different licenses, provided the MIT license and copyright notice are preserved.
122
+
123
+ All vendored code files include headers indicating their origin and original license. The full MIT license texts above satisfy the attribution requirements.
@@ -0,0 +1,6 @@
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
+ export {};
6
+ //# sourceMappingURL=compliance.spec.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"compliance.spec.d.ts","sourceRoot":"","sources":["../../src/compliance.spec.ts"],"names":[],"mappings":"AAAA;;;GAGG"}
@@ -0,0 +1,89 @@
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
+ /**
6
+ * east-node-std's compliance suite, over east-web-std.
7
+ *
8
+ * `make -C libs/east-node test-export-std` writes east-node-std's East test
9
+ * suites as IR, one JSON file per suite, to `EAST_NODE_STD_IR` (this
10
+ * checkout's `tmp/east-node-std`): the corpus east-c-std and east-py-std run. This runs the suites of the modules
11
+ * east-web-std provides, each over its own `createWebPlatform()`, with every
12
+ * East test a `node:test` test. It runs in Node, whose web-standard globals
13
+ * are the ones east-web-std uses; the same suites' Chromium leg comes with
14
+ * e3-web's browser pass.
15
+ */
16
+ import { describe, test } from "node:test";
17
+ import assert from "node:assert/strict";
18
+ import { existsSync, readdirSync, readFileSync } from "node:fs";
19
+ import { join } from "node:path";
20
+ import { ArrayType, AsyncEastIR, IntegerType, IRType, SourceMap, StringType, StructType, decodeJSONFor } from "@elaraai/east";
21
+ import { createWebPlatform } from "./index.js";
22
+ /** Where the export is: `EAST_NODE_STD_IR`, which the root `paths.mk` sets to
23
+ * this checkout's `tmp/east-node-std` when this runs through make. */
24
+ const IR_DIR = process.env.EAST_NODE_STD_IR;
25
+ /** The modules east-web-std provides: each one's suite runs here. */
26
+ const PROVIDED = ["Console", "Crypto", "Fetch", "Path", "Random", "Time"];
27
+ /** The modules a browser has no meaning for, which east-web-std leaves out. */
28
+ const NOT_PROVIDED = ["Env", "FileSystem", "Json"];
29
+ /** The file east-node-std's `describeEast` writes a module's suite to. */
30
+ const suiteFile = (module) => `${module}_platform_functions.json`;
31
+ // The wrapper east-node-std's `describeEast` exports a suite in: the suite's
32
+ // IR, and the stacks its location ids name
33
+ const LocationType = StructType({ column: IntegerType, filename: StringType, line: IntegerType });
34
+ const SourceMapType = StructType({ stacks: ArrayType(ArrayType(LocationType)) });
35
+ const ExportWrapperType = StructType({ ir: IRType, source_map: SourceMapType });
36
+ const decodeSuite = decodeJSONFor(ExportWrapperType);
37
+ /** Runs East's suites and tests as `node:test`'s, as east-node-std's TestImpl does. */
38
+ const nodeTestHost = {
39
+ describe: (name, body) => describe(name, body),
40
+ test: (name, body) => test(name, body),
41
+ };
42
+ /** A suite's program in the export at `dir`, with the source map its
43
+ * location ids resolve against. */
44
+ function loadSuite(dir, file) {
45
+ const { ir, source_map } = decodeSuite(readFileSync(join(dir, file)));
46
+ if (ir.type !== "AsyncFunction") {
47
+ throw new Error(`${file} holds a ${ir.type}, not the async function a suite is`);
48
+ }
49
+ const program = new AsyncEastIR(ir);
50
+ // Interning the stacks in their order gives each the id it was exported
51
+ // under: the export is a source map's entries, which are distinct and
52
+ // start with the empty stack at id 0
53
+ const map = new SourceMap();
54
+ for (const stack of source_map.stacks.slice(1)) {
55
+ map.intern_stack(stack);
56
+ }
57
+ if (map.size !== BigInt(source_map.stacks.length)) {
58
+ throw new Error(`${file}: its source map did not rebuild id for id`);
59
+ }
60
+ program.source_map = map;
61
+ return program;
62
+ }
63
+ if (IR_DIR === undefined) {
64
+ test("east-node-std's compliance suite is exported", () => {
65
+ assert.fail("EAST_NODE_STD_IR is unset: run it through make (`make -C libs/east-web test-compliance`)");
66
+ });
67
+ }
68
+ else if (!existsSync(IR_DIR)) {
69
+ test("east-node-std's compliance suite is exported", () => {
70
+ assert.fail(`nothing at ${IR_DIR}: export it with \`make -C libs/east-node test-export-std\``);
71
+ });
72
+ }
73
+ else {
74
+ test("every suite in the export is one east-web-std runs or leaves out", () => {
75
+ const exported = readdirSync(IR_DIR).filter(file => file.endsWith(".json")).sort();
76
+ assert.deepEqual(exported, [...PROVIDED, ...NOT_PROVIDED].map(suiteFile).sort());
77
+ });
78
+ for (const module of PROVIDED) {
79
+ const file = suiteFile(module);
80
+ if (!existsSync(join(IR_DIR, file))) {
81
+ test(`${module}'s suite is exported`, () => {
82
+ assert.fail(`${file} is not in ${IR_DIR}`);
83
+ });
84
+ continue;
85
+ }
86
+ await loadSuite(IR_DIR, file).compile(createWebPlatform({ test: nodeTestHost }))();
87
+ }
88
+ }
89
+ //# sourceMappingURL=compliance.spec.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"compliance.spec.js","sourceRoot":"","sources":["../../src/compliance.spec.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAC3C,OAAO,M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