@signalwire/js 4.0.0-dev-20260303132237 → 4.0.0-dev-20260303135011

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/browser.mjs CHANGED
@@ -6934,7 +6934,7 @@ var require_switchMap = /* @__PURE__ */ __commonJSMin(((exports) => {
6934
6934
  var innerFrom_1$6 = require_innerFrom();
6935
6935
  var lift_1$13 = require_lift();
6936
6936
  var OperatorSubscriber_1$11 = require_OperatorSubscriber();
6937
- function switchMap$2(project, resultSelector) {
6937
+ function switchMap$3(project, resultSelector) {
6938
6938
  return lift_1$13.operate(function(source, subscriber) {
6939
6939
  var innerSubscriber = null;
6940
6940
  var index = 0;
@@ -6958,7 +6958,7 @@ var require_switchMap = /* @__PURE__ */ __commonJSMin(((exports) => {
6958
6958
  }));
6959
6959
  });
6960
6960
  }
6961
- exports.switchMap = switchMap$2;
6961
+ exports.switchMap = switchMap$3;
6962
6962
  }));
6963
6963
 
6964
6964
  //#endregion
@@ -14866,7 +14866,10 @@ var Fetcher = class {
14866
14866
  this.nextUrl = `${this.endpoint}?${params}`;
14867
14867
  }
14868
14868
  async next() {
14869
- if (!this.nextUrl) return [];
14869
+ if (!this.nextUrl) {
14870
+ this.hasMore = false;
14871
+ return [];
14872
+ }
14870
14873
  const response = await this.http.request({
14871
14874
  ...GET_PARAMS,
14872
14875
  url: this.nextUrl
@@ -14874,6 +14877,7 @@ var Fetcher = class {
14874
14877
  if (response.ok && !!response.body) {
14875
14878
  const result = JSON.parse(response.body);
14876
14879
  this.nextUrl = result.links.next;
14880
+ this.hasMore = !!this.nextUrl;
14877
14881
  return result.data.filter(this.filter).map(this.mapper);
14878
14882
  }
14879
14883
  logger$8.error("Failed to fetch entity");
@@ -14895,6 +14899,7 @@ var EntityCollection = class extends Destroyable {
14895
14899
  this.onError = onError;
14896
14900
  this.loading$ = this.createBehaviorSubject(false);
14897
14901
  this.values$ = this.createReplaySubject(1);
14902
+ this._hasMore$ = this.createBehaviorSubject(true);
14898
14903
  this.collectionData = /* @__PURE__ */ new Map();
14899
14904
  this.observablesRegistry = /* @__PURE__ */ new Map();
14900
14905
  this.upsertData = (data) => {
@@ -14910,7 +14915,7 @@ var EntityCollection = class extends Destroyable {
14910
14915
  this._destroy$ = new import_cjs$8.Subject();
14911
14916
  this.updateSubscription = this.update$.subscribe(this.upsertData);
14912
14917
  this.loading$.next(false);
14913
- this.hasMore$ = (0, import_cjs$8.defer)(() => (0, import_cjs$8.from)(this.init())).pipe((0, import_cjs$8.shareReplay)(1), (0, import_cjs$8.takeUntil)(this._destroy$));
14918
+ this.hasMore$ = (0, import_cjs$8.defer)(() => (0, import_cjs$8.from)(this.init())).pipe((0, import_cjs$8.switchMap)(() => this._hasMore$), (0, import_cjs$8.distinctUntilChanged)(), (0, import_cjs$8.shareReplay)(1), (0, import_cjs$8.takeUntil)(this._destroy$));
14914
14919
  }
14915
14920
  get loading() {
14916
14921
  return this.loading$.value;
@@ -14925,17 +14930,21 @@ var EntityCollection = class extends Destroyable {
14925
14930
  return Array.from(this.collectionData.values());
14926
14931
  }
14927
14932
  async init() {
14928
- if (this.fetchController.hasMore === false) return Promise.resolve(false);
14933
+ if (this.fetchController.hasMore === false) {
14934
+ this._hasMore$.next(false);
14935
+ return;
14936
+ }
14929
14937
  await this.fetchMore();
14930
- return this.fetchController.hasMore ?? true;
14931
14938
  }
14932
14939
  async fetchMore() {
14933
14940
  try {
14934
14941
  this.loading$.next(true);
14935
14942
  (await this.fetchController.next()).forEach(this.upsertData);
14943
+ this._hasMore$.next(this.fetchController.hasMore ?? false);
14936
14944
  this.loading$.next(false);
14937
14945
  } catch (error) {
14938
14946
  logger$8.error(`Failed to fetch initial collection data`, error);
14947
+ this._hasMore$.next(this.fetchController.hasMore ?? false);
14939
14948
  this.loading$.next(false);
14940
14949
  this.onError?.(new CollectionFetchError("fetchMore", error));
14941
14950
  }