@forgeroute/ui 0.4.99 → 0.5.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.
@@ -1,5 +1,5 @@
1
1
  import * as i0 from "@angular/core";
2
- import { ChangeDetectionStrategy, ChangeDetectorRef, Component, DestroyRef, ElementRef, Injectable, InjectionToken, Injector, computed, effect, inject, input, makeEnvironmentProviders, output, provideAppInitializer, signal, untracked, viewChild } from "@angular/core";
2
+ import { ChangeDetectionStrategy, ChangeDetectorRef, Component, DestroyRef, ElementRef, Injectable, InjectionToken, Injector, computed, effect, inject, input, isDevMode, makeEnvironmentProviders, output, provideAppInitializer, signal, untracked, viewChild } from "@angular/core";
3
3
  import { DOCUMENT } from "@angular/common";
4
4
  import { Subject, defer, firstValueFrom, from, of, throwError, timer } from "rxjs";
5
5
  import { ConfirmService, SidePanelComponent, ToastService, UI_NOTES_QUEUE, UiLabelsService, uiText } from "@forgeroute/ui";
@@ -149,6 +149,12 @@ function resolveConfigCached(cfg) {
149
149
  }
150
150
  return resolved;
151
151
  }
152
+ function blockPaymentsOffline(patterns, message) {
153
+ return patterns.map((pattern) => ({
154
+ pattern,
155
+ ...message ? { message } : {}
156
+ }));
157
+ }
152
158
  function isInScope(url, cfg) {
153
159
  return url.includes(cfg.apiPrefix) && !matchesAny(url, cfg.skip);
154
160
  }
@@ -2313,6 +2319,15 @@ function handleRead(req, next, cfg) {
2313
2319
  })));
2314
2320
  return live().pipe(catchError((err) => isNetworkFailure(err) ? serveCopyOr(() => throwError(() => err)) : throwError(() => err)));
2315
2321
  }
2322
+ const warnedPaymentUrls = /* @__PURE__ */ new Set();
2323
+ const PAYMENT_SEGMENT = /(^|\/)(payments?|payment-links?|payment-intents?|pay|charges?|refunds?)(\/|$)/i;
2324
+ function warnIfPaymentQueued(url) {
2325
+ if (!isDevMode()) return;
2326
+ const path = pathOnly(url);
2327
+ if (!PAYMENT_SEGMENT.test(path) || warnedPaymentUrls.has(path)) return;
2328
+ warnedPaymentUrls.add(path);
2329
+ console.warn(`Offline: "${path}" looks like a payment and is being QUEUED for replay while offline. A replay after reconnecting is a second charge: list it in blockOffline with blockPaymentsOffline().`);
2330
+ }
2316
2331
  function handleWrite(req, next, cfg) {
2317
2332
  const connection = inject(ConnectionStateService);
2318
2333
  const userId = cfg.getUserId();
@@ -2334,6 +2349,7 @@ function handleWrite(req, next, cfg) {
2334
2349
  }
2335
2350
  const body = storableBody(req.body);
2336
2351
  if (!body.ok) return throwError(() => new OfflineBlockedError(labels.t("connection.storageUnavailable"), "storage"));
2352
+ warnIfPaymentQueued(req.urlWithParams);
2337
2353
  const store = inject(OfflineStore);
2338
2354
  const support = inject(OfflineSupportService);
2339
2355
  const method = req.method.toUpperCase();
@@ -3524,6 +3540,6 @@ i0.ɵɵngDeclareClassMetadata({
3524
3540
  }]
3525
3541
  }
3526
3542
  });
3527
- export { ConnectionBannerComponent, ConnectionStateService, DEFAULT_DETAIL_TTL_MS, DEFAULT_LIST_TTL_MS, FROM_CACHE_HEADER, IDEMPOTENCY_HEADER, IDEMPOTENCY_IN_PROGRESS_CODE, IDMAP_TTL_MS, KeepMineError, LEASE_TTL_MS, OFFLINE_IDB_FACTORY, OFFLINE_LEASE_STORAGE, OFFLINE_LOCK_MANAGER, OFFLINE_REPLAY_HEADER, OFFLINE_SUPPORT_CONFIG, ONLINE_DEBOUNCE_MS, OfflineBlockedError, OfflineNotesQueue, OfflineReplayer, OfflineStore, OfflineSupportService, PendingChangesDrawerComponent, QueueFullError, REQUEST_LONG, REQUEST_TIMEOUT_MS, RequestTimeoutError, STALE_CLAIM_MS, SYNCED_FLASH_MS, StaleDataChipComponent, StaleDataService, StillWorkingComponent, StorageUnavailableError, backoffMs, classifyReplay, connectionInterceptor, createChannel, defaultCreatedId, deriveEntity, generateUuid, hasStampField, idempotencyInterceptor, invalidationPrefix, isClaimable, isInScope, isMutationMethod, isOfflineBlockedError, isQuotaError, isRequestTimeoutError, lastSegmentIsId, matchesAny, matchesUrl, offlineHttpInterceptors, offlineInterceptor, pathAndQuery, pathOnly, provideOfflineSupport, resolveConfig, resolveConfigCached, stripStampFields };
3543
+ export { ConnectionBannerComponent, ConnectionStateService, DEFAULT_DETAIL_TTL_MS, DEFAULT_LIST_TTL_MS, FROM_CACHE_HEADER, IDEMPOTENCY_HEADER, IDEMPOTENCY_IN_PROGRESS_CODE, IDMAP_TTL_MS, KeepMineError, LEASE_TTL_MS, OFFLINE_IDB_FACTORY, OFFLINE_LEASE_STORAGE, OFFLINE_LOCK_MANAGER, OFFLINE_REPLAY_HEADER, OFFLINE_SUPPORT_CONFIG, ONLINE_DEBOUNCE_MS, OfflineBlockedError, OfflineNotesQueue, OfflineReplayer, OfflineStore, OfflineSupportService, PendingChangesDrawerComponent, QueueFullError, REQUEST_LONG, REQUEST_TIMEOUT_MS, RequestTimeoutError, STALE_CLAIM_MS, SYNCED_FLASH_MS, StaleDataChipComponent, StaleDataService, StillWorkingComponent, StorageUnavailableError, backoffMs, blockPaymentsOffline, classifyReplay, connectionInterceptor, createChannel, defaultCreatedId, deriveEntity, generateUuid, hasStampField, idempotencyInterceptor, invalidationPrefix, isClaimable, isInScope, isMutationMethod, isOfflineBlockedError, isQuotaError, isRequestTimeoutError, lastSegmentIsId, matchesAny, matchesUrl, offlineHttpInterceptors, offlineInterceptor, pathAndQuery, pathOnly, provideOfflineSupport, resolveConfig, resolveConfigCached, stripStampFields };
3528
3544
 
3529
3545
  //# sourceMappingURL=forgeroute-ui-offline.mjs.map