@siteping/widget 0.9.13 → 0.9.14

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.
@@ -8,4 +8,4 @@ export type { ScreenshotStorage } from "./screenshot-storage.js";
8
8
  export type { AssertEqual, Brand, DeepReadonly, IfEquals, KeysOfType, NonEmptyArray, Prettify, Replace, RequiredNonNull, } from "./type-utils.js";
9
9
  export { hasOwn, isRecord } from "./type-utils.js";
10
10
  export type { AnchorData, AnnotationCreateInput, AnnotationPayload, AnnotationRecord, AnnotationResponse, BuiltinLocale, ConsoleDiagnosticEntry, ConsoleDiagnosticLevel, DiagnosticsCaptureOptions, DiagnosticsSnapshot, FeedbackCreateInput, FeedbackPage, FeedbackPayload, FeedbackQuery, FeedbackRecord, FeedbackResponse, FeedbackResponseList, FeedbackStatus, FeedbackType, FeedbackUpdateInput, NetworkDiagnosticEntry, PageScope, RectData, SitepingConfig, SitepingDeepLinkOptions, SitepingIdentity, SitepingInstance, SitepingLocale, SitepingPosition, SitepingPublicEventListener, SitepingPublicEvents, SitepingSkipReason, SitepingStore, SitepingTheme, SitepingUnsubscribe, } from "./types.js";
11
- export { BUILTIN_LOCALES, FEEDBACK_STATUSES, FEEDBACK_TYPES, flattenAnnotation, isStoreDuplicate, isStoreNotFound, StoreDuplicateError, StoreNotFoundError, } from "./types.js";
11
+ export { BUILTIN_LOCALES, FEEDBACK_STATUSES, FEEDBACK_TYPES, flattenAnnotation, isStoreDuplicate, isStoreNotFound, isStorePersistence, StoreDuplicateError, StoreNotFoundError, StorePersistenceError, } from "./types.js";
package/dist/types.d.ts CHANGED
@@ -57,8 +57,21 @@ export interface SitepingConfig {
57
57
  showAnnotationsToggle?: boolean | undefined;
58
58
  /** Accent color for the widget UI — defaults to '#0066ff' */
59
59
  accentColor?: string;
60
- /** Show the widget even in production — defaults to false */
60
+ /**
61
+ * Render the widget even when it would normally be skipped — this bypasses
62
+ * BOTH the production-environment guard AND the mobile-viewport guard.
63
+ * Defaults to false. Use it for dedicated review tools, staging environments,
64
+ * or responsive testing where you always want the widget present.
65
+ */
61
66
  forceShow?: boolean;
67
+ /**
68
+ * Minimum viewport width (px) at or above which the widget renders. Below it,
69
+ * the widget is skipped and `onSkip("mobile")` fires. Defaults to `768`.
70
+ *
71
+ * Set lower (e.g. `0`) to allow narrow/mobile viewports, or use `forceShow`
72
+ * to bypass the viewport check entirely.
73
+ */
74
+ minViewportWidth?: number | undefined;
62
75
  /** Enable debug logging of lifecycle events — defaults to false */
63
76
  debug?: boolean;
64
77
  /** Color theme — defaults to 'light' */
@@ -418,6 +431,16 @@ export declare class StoreDuplicateError extends Error {
418
431
  readonly code: "STORE_DUPLICATE";
419
432
  constructor(message?: string);
420
433
  }
434
+ /**
435
+ * Thrown when a store accepts a mutation but cannot persist it — e.g.
436
+ * `localStorage` is full (QuotaExceededError). Adapters MUST throw this rather
437
+ * than swallow the failure, so callers learn the write was lost instead of
438
+ * seeing a phantom success.
439
+ */
440
+ export declare class StorePersistenceError extends Error {
441
+ readonly code: "STORE_PERSISTENCE";
442
+ constructor(message?: string, options?: ErrorOptions);
443
+ }
421
444
  /** Shape of any ORM error that carries a Prisma-style `code` field. */
422
445
  type CodedError<C extends string = string> = {
423
446
  code: C;
@@ -426,6 +449,13 @@ type CodedError<C extends string = string> = {
426
449
  export declare function isStoreNotFound(error: unknown): error is StoreNotFoundError | CodedError<"P2025">;
427
450
  /** Type guard — works for `StoreDuplicateError` and ORM-specific equivalents (e.g. Prisma P2002). */
428
451
  export declare function isStoreDuplicate(error: unknown): error is StoreDuplicateError | CodedError<"P2002">;
452
+ /**
453
+ * Type guard for `StorePersistenceError`. Matches on the stable `code` field
454
+ * in addition to `instanceof`: every consumer package bundles its own copy of
455
+ * core (tsup `noExternal`), so an instance thrown by one package fails an
456
+ * `instanceof` check against another package's class identity.
457
+ */
458
+ export declare function isStorePersistence(error: unknown): error is StorePersistenceError | CodedError<"STORE_PERSISTENCE">;
429
459
  /** Flatten a widget `AnnotationPayload` (nested anchor + rect) into a flat `AnnotationCreateInput`. */
430
460
  export declare function flattenAnnotation(ann: AnnotationPayload): Prettify<AnnotationCreateInput>;
431
461
  /** Paginated result returned by `SitepingStore.getFeedbacks`. */
@@ -447,20 +477,23 @@ export interface FeedbackPage {
447
477
  * - **`createFeedback`**: either return the existing record on duplicate
448
478
  * `clientId` (idempotent) or throw `StoreDuplicateError`. The handler
449
479
  * handles both patterns.
480
+ * - **All mutations**: when a write is accepted but cannot be persisted
481
+ * (e.g. storage quota), throw `StorePersistenceError` instead of reporting
482
+ * a phantom success. Detect it with `isStorePersistence`.
450
483
  * - Other methods should not throw on empty results — return empty arrays or `null`.
451
484
  */
452
485
  export interface SitepingStore {
453
- /** Create a feedback with its annotations. Idempotent on `clientId` — return existing record on duplicate, or throw `StoreDuplicateError`. */
486
+ /** Create a feedback with its annotations. Idempotent on `clientId` — return existing record on duplicate, or throw `StoreDuplicateError`. Throws `StorePersistenceError` when the write cannot be persisted. */
454
487
  createFeedback(data: FeedbackCreateInput): Promise<FeedbackRecord>;
455
488
  /** Paginated query with optional filters. Returns empty array (not error) when no results. */
456
489
  getFeedbacks(query: FeedbackQuery): Promise<FeedbackPage>;
457
490
  /** Lookup by client-generated UUID. Returns `null` (not error) when not found. */
458
491
  findByClientId(clientId: string): Promise<FeedbackRecord | null>;
459
- /** Update status/resolvedAt. Throws `StoreNotFoundError` if `id` does not exist. */
492
+ /** Update status/resolvedAt. Throws `StoreNotFoundError` if `id` does not exist, `StorePersistenceError` when the write cannot be persisted. */
460
493
  updateFeedback(id: string, data: FeedbackUpdateInput): Promise<FeedbackRecord>;
461
- /** Delete a single record. Throws `StoreNotFoundError` if `id` does not exist. */
494
+ /** Delete a single record. Throws `StoreNotFoundError` if `id` does not exist, `StorePersistenceError` when the write cannot be persisted. */
462
495
  deleteFeedback(id: string): Promise<void>;
463
- /** Bulk delete all feedbacks for a project. No-op (not error) if none exist. */
496
+ /** Bulk delete all feedbacks for a project. No-op (not error) if none exist. Throws `StorePersistenceError` when the write cannot be persisted. */
464
497
  deleteAllFeedbacks(projectName: string): Promise<void>;
465
498
  }
466
499
  /** Payload sent from the widget to the server when submitting feedback. */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@siteping/widget",
3
- "version": "0.9.13",
3
+ "version": "0.9.14",
4
4
  "description": "Feedback widget for client review during development — annotations, bugs, questions directly on the site",
5
5
  "type": "module",
6
6
  "sideEffects": false,