@zimic/interceptor 0.16.1 → 0.17.0-canary.1

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/dist/http.d.ts CHANGED
@@ -255,8 +255,12 @@ declare namespace UnhandledRequestStrategy {
255
255
  }
256
256
  type UnhandledRequestStrategy = UnhandledRequestStrategy.Local | UnhandledRequestStrategy.Remote;
257
257
  interface SharedHttpInterceptorOptions {
258
- /** The type of the HTTP interceptor. */
259
- type: HttpInterceptorType;
258
+ /**
259
+ * The type of the HTTP interceptor.
260
+ *
261
+ * @default 'local'
262
+ */
263
+ type?: HttpInterceptorType;
260
264
  /**
261
265
  * Represents the URL that should be matched by the interceptor. Any request starting with this base URL will be
262
266
  * intercepted if a matching
@@ -283,7 +287,7 @@ interface SharedHttpInterceptorOptions {
283
287
  * @see {@link https://github.com/zimicjs/zimic/wiki/api‐zimic‐interceptor‐http#creating-a-local-http-interceptor Creating a local HTTP interceptor}
284
288
  */
285
289
  interface LocalHttpInterceptorOptions extends SharedHttpInterceptorOptions {
286
- type: 'local';
290
+ type?: 'local';
287
291
  /**
288
292
  * The strategy to use for unhandled requests. If a request starts with the base URL of the interceptor, but no
289
293
  * matching handler exists, this strategy will be used. If a function is provided, it will be called with the
@@ -1294,7 +1298,6 @@ declare class TimesCheckError extends TypeError {
1294
1298
  * };
1295
1299
  * };
1296
1300
  * }>({
1297
- * type: 'local',
1298
1301
  * baseURL: 'http://localhost:3000',
1299
1302
  * });
1300
1303
  *
package/dist/http.js CHANGED
@@ -193,9 +193,7 @@ var isNonEmpty_default = isNonEmpty;
193
193
  function createCachedDynamicImport(importModuleDynamically) {
194
194
  let cachedImportResult;
195
195
  return /* @__PURE__ */ __name2(/* @__PURE__ */ __name(async function importModuleDynamicallyWithCache() {
196
- if (cachedImportResult === void 0) {
197
- cachedImportResult = await importModuleDynamically();
198
- }
196
+ cachedImportResult ??= await importModuleDynamically();
199
197
  return cachedImportResult;
200
198
  }, "importModuleDynamicallyWithCache"), "importModuleDynamicallyWithCache");
201
199
  }
@@ -1276,9 +1274,7 @@ var LocalHttpInterceptorWorker = class extends HttpInterceptorWorker_default {
1276
1274
  return this.internalWorker;
1277
1275
  }
1278
1276
  get internalWorkerOrCreate() {
1279
- if (!this.internalWorker) {
1280
- this.internalWorker = this.createInternalWorker();
1281
- }
1277
+ this.internalWorker ??= this.createInternalWorker();
1282
1278
  return this.internalWorker;
1283
1279
  }
1284
1280
  createInternalWorker() {
@@ -2603,7 +2599,7 @@ var RemoteHttpInterceptor_default = RemoteHttpInterceptor;
2603
2599
 
2604
2600
  // src/http/interceptor/factory.ts
2605
2601
  function isLocalHttpInterceptorOptions(options) {
2606
- return options.type === "local";
2602
+ return options.type === void 0 || options.type === "local";
2607
2603
  }
2608
2604
  __name(isLocalHttpInterceptorOptions, "isLocalHttpInterceptorOptions");
2609
2605
  function isRemoteHttpInterceptorOptions(options) {