@echoxyz/sonar-core 0.1.2 → 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,17 @@
1
1
  # @echoxyz/sonar-core
2
2
 
3
+ ## 0.1.4
4
+
5
+ ### Patch Changes
6
+
7
+ - d04d616: Use bound global fetch
8
+
9
+ ## 0.1.3
10
+
11
+ ### Patch Changes
12
+
13
+ - f04cb72: Add globalThis fetch, export type
14
+
3
15
  ## 0.1.2
4
16
 
5
17
  ### Patch Changes
package/dist/index.cjs CHANGED
@@ -173,15 +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
- if (!fetchImpl) {
181
- throw new Error("A fetch implementation must be provided");
182
- }
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
+ })();
183
189
  this.fetchFn = fetchImpl;
184
- this.onUnauthorized = (_c = args.opts) == null ? void 0 : _c.onUnauthorized;
190
+ this.onUnauthorized = (_b = args.opts) == null ? void 0 : _b.onUnauthorized;
185
191
  }
186
192
  // Expose token management methods from the underlying AuthSession for convenience
187
193
  setToken(token) {
package/dist/index.js CHANGED
@@ -137,15 +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
- if (!fetchImpl) {
145
- throw new Error("A fetch implementation must be provided");
146
- }
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
+ })();
147
153
  this.fetchFn = fetchImpl;
148
- this.onUnauthorized = (_c = args.opts) == null ? void 0 : _c.onUnauthorized;
154
+ this.onUnauthorized = (_b = args.opts) == null ? void 0 : _b.onUnauthorized;
149
155
  }
150
156
  // Expose token management methods from the underlying AuthSession for convenience
151
157
  setToken(token) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@echoxyz/sonar-core",
3
- "version": "0.1.2",
3
+ "version": "0.1.4",
4
4
  "type": "module",
5
5
  "main": "./dist/index.cjs",
6
6
  "module": "./dist/index.js",