@stellar/typescript-wallet-sdk 4.0.0-beta.1786156822907 → 4.0.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stellar/typescript-wallet-sdk",
3
- "version": "4.0.0-beta.1786156822907",
3
+ "version": "4.0.0",
4
4
  "engines": {
5
5
  "node": ">=22"
6
6
  },
@@ -76,4 +76,4 @@
76
76
  "example:sep24": "ts-node examples/sep24/sep24.ts",
77
77
  "example:sep12": "ts-node examples/sep12/sep12.ts"
78
78
  }
79
- }
79
+ }
@@ -0,0 +1,45 @@
1
+ /**
2
+ * Lazy `eventsource` facade.
3
+ *
4
+ * eventsource v4 subclasses the DOM globals `Event`/`EventTarget` at module
5
+ * scope, which React Native's Hermes does not provide. Horizon's CallBuilder
6
+ * requires this module eagerly but only reads it inside `stream()`, so deferring
7
+ * evaluation to first property access keeps imports working everywhere while
8
+ * leaving streaming intact wherever those globals exist.
9
+ *
10
+ * Aliased in webpack.config.js: `eventsource$` resolves here, `eventsource-real$`
11
+ * to the real package.
12
+ */
13
+ let realModule;
14
+
15
+ const load = () => {
16
+ if (!realModule) {
17
+ try {
18
+ // eslint-disable-next-line global-require
19
+ realModule = require("eventsource-real");
20
+ } catch (cause) {
21
+ // CallBuilder.stream() catches this and retries on a timer, so make the
22
+ // error it reports to onerror self-explanatory.
23
+ throw new Error(
24
+ "Horizon streaming needs the DOM Event/EventTarget globals and a " +
25
+ "streaming fetch body, which React Native does not provide. Alias " +
26
+ '"eventsource" to a native SSE client (e.g. react-native-sse) to use ' +
27
+ `CallBuilder.stream(). Original error: ${cause.message}`,
28
+ );
29
+ }
30
+ }
31
+
32
+ return realModule;
33
+ };
34
+
35
+ Object.defineProperty(exports, "EventSource", {
36
+ enumerable: true,
37
+ configurable: true,
38
+ get: () => load().EventSource,
39
+ });
40
+
41
+ Object.defineProperty(exports, "ErrorEvent", {
42
+ enumerable: true,
43
+ configurable: true,
44
+ get: () => load().ErrorEvent,
45
+ });
package/webpack.config.js CHANGED
@@ -19,6 +19,17 @@ module.exports = (env = { NODE: false }) => {
19
19
  },
20
20
  resolve: {
21
21
  extensions: [".js", ".json", ".ts"],
22
+ alias: {
23
+ // eventsource v4, reached via stellar-sdk's Horizon CallBuilder,
24
+ // subclasses the DOM globals Event and EventTarget at module scope, so
25
+ // importing this package threw "Property 'Event' doesn't exist" on React
26
+ // Native. Unlike the km and soroban packages, this one exposes
27
+ // Horizon.Server publicly, so stubbing eventsource out would break
28
+ // .stream() on web and Node. Defer its evaluation to first use instead.
29
+ eventsource$: path.resolve(__dirname, "src/shims/eventsource.js"),
30
+ // The facade's load target; "eventsource" would resolve back to itself.
31
+ "eventsource-real$": require.resolve("eventsource"),
32
+ },
22
33
  fallback: isBrowser
23
34
  ? {
24
35
  crypto: require.resolve("crypto-browserify"),