@effectstream/utils 0.103.0 → 0.103.2

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.
package/README.md CHANGED
@@ -59,7 +59,7 @@ state machine, and the batcher pulls something from here.
59
59
 
60
60
  Address types and validators:
61
61
 
62
- - `AddressType` - enum of chain identifiers (EVM, CARDANO, SUBSTRATE, ALGORAND, MINA, MIDNIGHT, AVAIL, POLKADOT, NEAR).
62
+ - `AddressType` - enum of chain identifiers (EVM, CARDANO, SUBSTRATE, ALGORAND, MINA, MIDNIGHT, AVAIL, POLKADOT, NEAR, SOLANA), plus `NONE` for unattributed inputs.
63
63
  - `AddressValidator` - `Record<AddressType, TSchema>` of TypeBox validators, one per chain.
64
64
  - `AddressAndType` - tagged-union shape for `{ type, address }` pairs.
65
65
 
@@ -95,9 +95,10 @@ Concurrency (Effection-based):
95
95
 
96
96
  Subpath entries:
97
97
 
98
- - `@effectstream/utils/node-env` - `dotenv`-aware env loader, for Node-only callers.
98
+ - `@effectstream/utils/node-env` - `dotenv`-aware env loader exposing the typed `ENV` object, for Node-only callers. Every registered variable is listed in the [environment variables reference](https://effectstream.github.io/docs/home/components/environment-variables).
99
99
  - `@effectstream/utils/runtime` - Effection runtime helpers.
100
100
  - `@effectstream/utils/runtime-spawn` - child-process spawn helpers built on Effection.
101
+ - `@effectstream/utils/fs` - promise-based filesystem helpers used by the orchestrator and binary wrappers: `makeTempDir`, `mkdirRecursive`, `writeTextFile`, `setFileTimes`, `remove`, and directory listing via `DirEntry`.
101
102
 
102
103
  ## Examples
103
104
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@effectstream/utils",
3
- "version": "0.103.0",
3
+ "version": "0.103.2",
4
4
  "license": "(MIT OR Apache-2.0)",
5
5
  "homepage": "https://effectstream.github.io/docs/",
6
6
  "repository": {
@@ -13,6 +13,7 @@
13
13
  },
14
14
  "exports": {
15
15
  ".": "./src/mod.ts",
16
+ "./types": "./src/types/mod.ts",
16
17
  "./node-env": "./src/config.ts",
17
18
  "./runtime": "./src/runtime.ts",
18
19
  "./runtime-spawn": "./src/runtime-spawn.ts",
package/src/runtime.ts CHANGED
@@ -39,15 +39,35 @@ export function getRuntime(): {runtime: Runtime, environment: RuntimeEnvironment
39
39
 
40
40
  /**
41
41
  * Helpers for common process operations.
42
+ *
43
+ * These are node-only by nature, but this module is reachable from BROWSER
44
+ * bundles: `AddressType` is a value export of this package, so importing it
45
+ * (as @effectstream/wallets' IProvider does) pulls the barrel, and the barrel
46
+ * re-exports config.ts — which calls getEnv() at module top level. An
47
+ * unguarded `process` there is a hard `ReferenceError: process is not defined`
48
+ * at import time, before any app code runs.
49
+ *
50
+ * `getEnv` therefore degrades to `undefined` in a browser (an unset variable
51
+ * is the truthful answer there). The mutating/process-control helpers below
52
+ * still throw, because silently doing nothing would hide a real porting bug.
42
53
  */
43
54
 
44
- /** Get environment variable. */
55
+ const hasProcess = (): boolean =>
56
+ typeof process !== "undefined" && process != null;
57
+
58
+ /** Get environment variable. Returns undefined where there is no process. */
45
59
  export function getEnv(key: string): string | undefined {
46
- return process.env[key];
60
+ if (!hasProcess()) return undefined;
61
+ return process.env?.[key];
47
62
  }
48
63
 
49
64
  /** Set environment variable. */
50
65
  export function setEnv(key: string, value: string): void {
66
+ if (!hasProcess()) {
67
+ throw new Error(
68
+ `setEnv(${key}) is not available in this runtime — there is no process to mutate.`,
69
+ );
70
+ }
51
71
  process.env[key] = value;
52
72
  }
53
73
 
package/src/types/mod.ts CHANGED
@@ -1,3 +1,11 @@
1
+ // Exposed as `@effectstream/utils/types` — the browser-safe subset.
2
+ //
3
+ // The ROOT barrel re-exports config.ts, which runs dotenv (.env loading from
4
+ // disk) at import time. Any browser bundle that imports the root for a mere
5
+ // type or enum (AddressType, Result, WalletAddress…) drags that bootstrap —
6
+ // and once crashed outright on `process`. Browser-reachable code should import
7
+ // this subpath instead; keep this tree free of node-only modules (node:buffer
8
+ // is the one allowed exception — it has a real browser polyfill).
1
9
  export type * from "./misc.ts";
2
10
  export type * from "./json-query.ts";
3
11
  export type * from "./nominal.ts";