@echoxyz/sonar-core 0.1.3 → 0.1.4

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/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # @echoxyz/sonar-core
2
2
 
3
+ ## 0.1.4
4
+
5
+ ### Patch Changes
6
+
7
+ - d04d616: Use bound global fetch
8
+
3
9
  ## 0.1.3
4
10
 
5
11
  ### Patch Changes
package/dist/index.cjs CHANGED
@@ -173,17 +173,21 @@ var SonarClient = class {
173
173
  fetchFn;
174
174
  onUnauthorized;
175
175
  constructor(args) {
176
- var _a, _b, _c;
176
+ var _a, _b;
177
177
  this.apiURL = args.apiURL;
178
178
  this.auth = ((_a = args.opts) == null ? void 0 : _a.auth) ?? new AuthSession({ storage: createWebStorage() });
179
- const fetchImpl = ((_b = args.opts) == null ? void 0 : _b.fetch) ?? globalThis.fetch ?? (() => {
180
- throw new Error("No fetch available");
181
- });
182
- if (!fetchImpl) {
183
- throw new Error("A fetch implementation must be provided");
184
- }
179
+ const fetchImpl = (() => {
180
+ var _a2;
181
+ if ((_a2 = args.opts) == null ? void 0 : _a2.fetch) {
182
+ return args.opts.fetch;
183
+ }
184
+ if (typeof globalThis.fetch === "function") {
185
+ return globalThis.fetch.bind(globalThis);
186
+ }
187
+ throw new Error("No fetch implementation available");
188
+ })();
185
189
  this.fetchFn = fetchImpl;
186
- this.onUnauthorized = (_c = args.opts) == null ? void 0 : _c.onUnauthorized;
190
+ this.onUnauthorized = (_b = args.opts) == null ? void 0 : _b.onUnauthorized;
187
191
  }
188
192
  // Expose token management methods from the underlying AuthSession for convenience
189
193
  setToken(token) {
package/dist/index.js CHANGED
@@ -137,17 +137,21 @@ var SonarClient = class {
137
137
  fetchFn;
138
138
  onUnauthorized;
139
139
  constructor(args) {
140
- var _a, _b, _c;
140
+ var _a, _b;
141
141
  this.apiURL = args.apiURL;
142
142
  this.auth = ((_a = args.opts) == null ? void 0 : _a.auth) ?? new AuthSession({ storage: createWebStorage() });
143
- const fetchImpl = ((_b = args.opts) == null ? void 0 : _b.fetch) ?? globalThis.fetch ?? (() => {
144
- throw new Error("No fetch available");
145
- });
146
- if (!fetchImpl) {
147
- throw new Error("A fetch implementation must be provided");
148
- }
143
+ const fetchImpl = (() => {
144
+ var _a2;
145
+ if ((_a2 = args.opts) == null ? void 0 : _a2.fetch) {
146
+ return args.opts.fetch;
147
+ }
148
+ if (typeof globalThis.fetch === "function") {
149
+ return globalThis.fetch.bind(globalThis);
150
+ }
151
+ throw new Error("No fetch implementation available");
152
+ })();
149
153
  this.fetchFn = fetchImpl;
150
- this.onUnauthorized = (_c = args.opts) == null ? void 0 : _c.onUnauthorized;
154
+ this.onUnauthorized = (_b = args.opts) == null ? void 0 : _b.onUnauthorized;
151
155
  }
152
156
  // Expose token management methods from the underlying AuthSession for convenience
153
157
  setToken(token) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@echoxyz/sonar-core",
3
- "version": "0.1.3",
3
+ "version": "0.1.4",
4
4
  "type": "module",
5
5
  "main": "./dist/index.cjs",
6
6
  "module": "./dist/index.js",