@scalemule/nextjs 0.1.4 → 0.1.5

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/index.d.mts CHANGED
@@ -1,4 +1,5 @@
1
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
2
+ import * as React from 'react';
2
3
  import { ReactNode, ReactElement } from 'react';
3
4
  import { MoneyClient } from '@scalemule/money';
4
5
  export { MoneyClient, MoneyClientConfig, createMoneyClient } from '@scalemule/money';
@@ -332,6 +333,85 @@ interface UseFileStatusReturn {
332
333
  */
333
334
  declare function useFileStatus(options: UseFileStatusOptions): UseFileStatusReturn;
334
335
 
336
+ interface ScaleMuleMediaProps {
337
+ /** Storage `file_id` of the media to render. Required. */
338
+ fileId: string;
339
+ /** MIME type — drives which element to render. Required. */
340
+ mimeType: string;
341
+ /**
342
+ * Optional sender-side optimistic preview. While the upload is in
343
+ * progress (or the recipient hasn't yet observed the message), the
344
+ * component renders this Blob URL. Once `useFileStatus` resolves a
345
+ * scan-clean state and a server-side URL, the component swaps to it.
346
+ */
347
+ blobPreview?: string;
348
+ /** Display width hint (CSS pixels). Used for image breakpoint selection. */
349
+ width?: number;
350
+ /** Display height hint (CSS pixels). */
351
+ height?: number;
352
+ /** Pass-through className for the rendered element. */
353
+ className?: string;
354
+ /** Pass-through style. */
355
+ style?: React.CSSProperties;
356
+ /** Alt text for `<img>`; aria-label for `<audio>` / `<video>`. */
357
+ alt?: string;
358
+ /**
359
+ * Polling interval while waiting for the media pipeline to complete.
360
+ * Defaults to 2000ms; set to `null` to disable polling. Polling stops
361
+ * automatically once scan is clean.
362
+ */
363
+ pollIntervalMs?: number | null;
364
+ /**
365
+ * Render a custom placeholder while waiting for scan / upload. Defaults
366
+ * to a tiny "Loading…" div. Receives the current FileStatus (or null).
367
+ */
368
+ renderPlaceholder?: () => React.ReactNode;
369
+ /**
370
+ * Render the "blocked" UI when scan flips to `threat`. Defaults to a
371
+ * "This file was blocked" message. Customize for branding.
372
+ */
373
+ renderBlocked?: () => React.ReactNode;
374
+ /**
375
+ * Custom render override. If provided, the component still calls
376
+ * `useFileStatus` but yields rendering to this function. Useful for
377
+ * highly custom presentation (e.g. lightbox triggers, hover overlays).
378
+ */
379
+ renderOverride?: (args: {
380
+ src: string | null;
381
+ state: 'preview' | 'pending' | 'ready' | 'blocked' | 'error';
382
+ }) => React.ReactNode;
383
+ }
384
+ /**
385
+ * Progressive-enhancement media renderer.
386
+ *
387
+ * Renders the right element for the given MIME type and progressively
388
+ * upgrades the source URL as the media pipeline advances:
389
+ *
390
+ * blob preview (if set) → original view URL → optimized variant (image)
391
+ * → HLS playlist (video)
392
+ *
393
+ * Today this is pull-only — `useFileStatus` polls until scan is clean
394
+ * (and the caller can stop polling by passing `pollIntervalMs={null}`).
395
+ * The push variant rides on the chat translation bridge (Phase 3 / P5')
396
+ * and lights up automatically once that ships.
397
+ *
398
+ * For non-Safari browsers, HLS playback requires `hls.js` to be
399
+ * available. The component dynamic-imports it on first need; if the
400
+ * import fails (not installed), it falls back to the original-bytes URL.
401
+ *
402
+ * @example
403
+ * ```tsx
404
+ * <ScaleMuleMedia
405
+ * fileId={attachment.file_id}
406
+ * mimeType={attachment.mime_type}
407
+ * width={520}
408
+ * blobPreview={pendingPreviewUrl}
409
+ * alt={attachment.filename}
410
+ * />
411
+ * ```
412
+ */
413
+ declare function ScaleMuleMedia(props: ScaleMuleMediaProps): React.ReactElement | null;
414
+
335
415
  declare const useMoney: typeof useMoneyClient;
336
416
 
337
417
  /**
@@ -815,4 +895,4 @@ declare function createSafeLogger(prefix: string): {
815
895
  error: (message: string, data?: unknown) => void;
816
896
  };
817
897
 
818
- export { ApiError, type FeatureFlagEvaluation, type FeatureFlagEvaluation as FeatureFlagResult, type FeedbackItem, type FeedbackItemInput, type FeedbackPriority, type FeedbackStatus, type FeedbackType, FeedbackWidget, type FeedbackWidgetConfig, type FeedbackWidgetProps, ListFilesParams, LoginResponse, type MediaUploadResult, type PasswordValidationResult, type PhoneCountry, type PhoneValidationResult, type RealtimeEvent, type RealtimeMessage, type RealtimeStatus, ScaleMuleClient, ScaleMuleConfig, ScaleMuleProvider, type ScaleMuleProviderProps, UseAnalyticsOptions, UseAnalyticsReturn, UseAuthReturn, UseBillingReturn, UseContentReturn, type UseFeatureFlagsOptions, type UseFeatureFlagsReturn, type UseFeedbackOptions, type UseFeedbackResult, type UseFileStatusOptions, type UseFileStatusReturn, type UseFeatureFlagsOptions as UseFlagsOptions, type UseFeatureFlagsReturn as UseFlagsReturn, type UseMediaReturn, type UseMediaUploadOptions, type UsePushNotificationsOptions, type UsePushNotificationsReturn, type UseRealtimeOptions, type UseRealtimeReturn, type UseShareOptions, type UseShareReturn, UseUserReturn, User, type UsernameValidationResult, composePhone, createSafeLogger, normalizePhone, phoneCountries, sanitizeForLog, useAnalytics, useAuth, useBilling, useContent, useFeatureFlags, useFeedback, useFileStatus, useMedia, useMoney, useMoneyClient, usePushNotifications, useRealtime, useScaleMule, useScaleMuleClient, useShare, useUser, validateForm, validators };
898
+ export { ApiError, type FeatureFlagEvaluation, type FeatureFlagEvaluation as FeatureFlagResult, type FeedbackItem, type FeedbackItemInput, type FeedbackPriority, type FeedbackStatus, type FeedbackType, FeedbackWidget, type FeedbackWidgetConfig, type FeedbackWidgetProps, ListFilesParams, LoginResponse, type MediaUploadResult, type PasswordValidationResult, type PhoneCountry, type PhoneValidationResult, type RealtimeEvent, type RealtimeMessage, type RealtimeStatus, ScaleMuleClient, ScaleMuleConfig, ScaleMuleMedia, type ScaleMuleMediaProps, ScaleMuleProvider, type ScaleMuleProviderProps, UseAnalyticsOptions, UseAnalyticsReturn, UseAuthReturn, UseBillingReturn, UseContentReturn, type UseFeatureFlagsOptions, type UseFeatureFlagsReturn, type UseFeedbackOptions, type UseFeedbackResult, type UseFileStatusOptions, type UseFileStatusReturn, type UseFeatureFlagsOptions as UseFlagsOptions, type UseFeatureFlagsReturn as UseFlagsReturn, type UseMediaReturn, type UseMediaUploadOptions, type UsePushNotificationsOptions, type UsePushNotificationsReturn, type UseRealtimeOptions, type UseRealtimeReturn, type UseShareOptions, type UseShareReturn, UseUserReturn, User, type UsernameValidationResult, composePhone, createSafeLogger, normalizePhone, phoneCountries, sanitizeForLog, useAnalytics, useAuth, useBilling, useContent, useFeatureFlags, useFeedback, useFileStatus, useMedia, useMoney, useMoneyClient, usePushNotifications, useRealtime, useScaleMule, useScaleMuleClient, useShare, useUser, validateForm, validators };
package/dist/index.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
2
+ import * as React from 'react';
2
3
  import { ReactNode, ReactElement } from 'react';
3
4
  import { MoneyClient } from '@scalemule/money';
4
5
  export { MoneyClient, MoneyClientConfig, createMoneyClient } from '@scalemule/money';
@@ -332,6 +333,85 @@ interface UseFileStatusReturn {
332
333
  */
333
334
  declare function useFileStatus(options: UseFileStatusOptions): UseFileStatusReturn;
334
335
 
336
+ interface ScaleMuleMediaProps {
337
+ /** Storage `file_id` of the media to render. Required. */
338
+ fileId: string;
339
+ /** MIME type — drives which element to render. Required. */
340
+ mimeType: string;
341
+ /**
342
+ * Optional sender-side optimistic preview. While the upload is in
343
+ * progress (or the recipient hasn't yet observed the message), the
344
+ * component renders this Blob URL. Once `useFileStatus` resolves a
345
+ * scan-clean state and a server-side URL, the component swaps to it.
346
+ */
347
+ blobPreview?: string;
348
+ /** Display width hint (CSS pixels). Used for image breakpoint selection. */
349
+ width?: number;
350
+ /** Display height hint (CSS pixels). */
351
+ height?: number;
352
+ /** Pass-through className for the rendered element. */
353
+ className?: string;
354
+ /** Pass-through style. */
355
+ style?: React.CSSProperties;
356
+ /** Alt text for `<img>`; aria-label for `<audio>` / `<video>`. */
357
+ alt?: string;
358
+ /**
359
+ * Polling interval while waiting for the media pipeline to complete.
360
+ * Defaults to 2000ms; set to `null` to disable polling. Polling stops
361
+ * automatically once scan is clean.
362
+ */
363
+ pollIntervalMs?: number | null;
364
+ /**
365
+ * Render a custom placeholder while waiting for scan / upload. Defaults
366
+ * to a tiny "Loading…" div. Receives the current FileStatus (or null).
367
+ */
368
+ renderPlaceholder?: () => React.ReactNode;
369
+ /**
370
+ * Render the "blocked" UI when scan flips to `threat`. Defaults to a
371
+ * "This file was blocked" message. Customize for branding.
372
+ */
373
+ renderBlocked?: () => React.ReactNode;
374
+ /**
375
+ * Custom render override. If provided, the component still calls
376
+ * `useFileStatus` but yields rendering to this function. Useful for
377
+ * highly custom presentation (e.g. lightbox triggers, hover overlays).
378
+ */
379
+ renderOverride?: (args: {
380
+ src: string | null;
381
+ state: 'preview' | 'pending' | 'ready' | 'blocked' | 'error';
382
+ }) => React.ReactNode;
383
+ }
384
+ /**
385
+ * Progressive-enhancement media renderer.
386
+ *
387
+ * Renders the right element for the given MIME type and progressively
388
+ * upgrades the source URL as the media pipeline advances:
389
+ *
390
+ * blob preview (if set) → original view URL → optimized variant (image)
391
+ * → HLS playlist (video)
392
+ *
393
+ * Today this is pull-only — `useFileStatus` polls until scan is clean
394
+ * (and the caller can stop polling by passing `pollIntervalMs={null}`).
395
+ * The push variant rides on the chat translation bridge (Phase 3 / P5')
396
+ * and lights up automatically once that ships.
397
+ *
398
+ * For non-Safari browsers, HLS playback requires `hls.js` to be
399
+ * available. The component dynamic-imports it on first need; if the
400
+ * import fails (not installed), it falls back to the original-bytes URL.
401
+ *
402
+ * @example
403
+ * ```tsx
404
+ * <ScaleMuleMedia
405
+ * fileId={attachment.file_id}
406
+ * mimeType={attachment.mime_type}
407
+ * width={520}
408
+ * blobPreview={pendingPreviewUrl}
409
+ * alt={attachment.filename}
410
+ * />
411
+ * ```
412
+ */
413
+ declare function ScaleMuleMedia(props: ScaleMuleMediaProps): React.ReactElement | null;
414
+
335
415
  declare const useMoney: typeof useMoneyClient;
336
416
 
337
417
  /**
@@ -815,4 +895,4 @@ declare function createSafeLogger(prefix: string): {
815
895
  error: (message: string, data?: unknown) => void;
816
896
  };
817
897
 
818
- export { ApiError, type FeatureFlagEvaluation, type FeatureFlagEvaluation as FeatureFlagResult, type FeedbackItem, type FeedbackItemInput, type FeedbackPriority, type FeedbackStatus, type FeedbackType, FeedbackWidget, type FeedbackWidgetConfig, type FeedbackWidgetProps, ListFilesParams, LoginResponse, type MediaUploadResult, type PasswordValidationResult, type PhoneCountry, type PhoneValidationResult, type RealtimeEvent, type RealtimeMessage, type RealtimeStatus, ScaleMuleClient, ScaleMuleConfig, ScaleMuleProvider, type ScaleMuleProviderProps, UseAnalyticsOptions, UseAnalyticsReturn, UseAuthReturn, UseBillingReturn, UseContentReturn, type UseFeatureFlagsOptions, type UseFeatureFlagsReturn, type UseFeedbackOptions, type UseFeedbackResult, type UseFileStatusOptions, type UseFileStatusReturn, type UseFeatureFlagsOptions as UseFlagsOptions, type UseFeatureFlagsReturn as UseFlagsReturn, type UseMediaReturn, type UseMediaUploadOptions, type UsePushNotificationsOptions, type UsePushNotificationsReturn, type UseRealtimeOptions, type UseRealtimeReturn, type UseShareOptions, type UseShareReturn, UseUserReturn, User, type UsernameValidationResult, composePhone, createSafeLogger, normalizePhone, phoneCountries, sanitizeForLog, useAnalytics, useAuth, useBilling, useContent, useFeatureFlags, useFeedback, useFileStatus, useMedia, useMoney, useMoneyClient, usePushNotifications, useRealtime, useScaleMule, useScaleMuleClient, useShare, useUser, validateForm, validators };
898
+ export { ApiError, type FeatureFlagEvaluation, type FeatureFlagEvaluation as FeatureFlagResult, type FeedbackItem, type FeedbackItemInput, type FeedbackPriority, type FeedbackStatus, type FeedbackType, FeedbackWidget, type FeedbackWidgetConfig, type FeedbackWidgetProps, ListFilesParams, LoginResponse, type MediaUploadResult, type PasswordValidationResult, type PhoneCountry, type PhoneValidationResult, type RealtimeEvent, type RealtimeMessage, type RealtimeStatus, ScaleMuleClient, ScaleMuleConfig, ScaleMuleMedia, type ScaleMuleMediaProps, ScaleMuleProvider, type ScaleMuleProviderProps, UseAnalyticsOptions, UseAnalyticsReturn, UseAuthReturn, UseBillingReturn, UseContentReturn, type UseFeatureFlagsOptions, type UseFeatureFlagsReturn, type UseFeedbackOptions, type UseFeedbackResult, type UseFileStatusOptions, type UseFileStatusReturn, type UseFeatureFlagsOptions as UseFlagsOptions, type UseFeatureFlagsReturn as UseFlagsReturn, type UseMediaReturn, type UseMediaUploadOptions, type UsePushNotificationsOptions, type UsePushNotificationsReturn, type UseRealtimeOptions, type UseRealtimeReturn, type UseShareOptions, type UseShareReturn, UseUserReturn, User, type UsernameValidationResult, composePhone, createSafeLogger, normalizePhone, phoneCountries, sanitizeForLog, useAnalytics, useAuth, useBilling, useContent, useFeatureFlags, useFeedback, useFileStatus, useMedia, useMoney, useMoneyClient, usePushNotifications, useRealtime, useScaleMule, useScaleMuleClient, useShare, useUser, validateForm, validators };