@ibanzajoe/uploader 1.2.1 → 1.4.0

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.cts CHANGED
@@ -1,5 +1,5 @@
1
- import { P as PickerResponse, F as FileResult, d as UploaderClientOptions } from './client-CUmYuQ7Z.cjs';
2
- export { D as DeliveryProtection, a as PolicySpec, U as UploadAllOptions, b as UploadOptions, c as UploaderClient } from './client-CUmYuQ7Z.cjs';
1
+ import { D as DeliveryProtection, P as PickerResponse, F as FileResult, d as UploaderClientOptions } from './client-DW6DcS6o.cjs';
2
+ export { a as PolicySpec, U as UploadAllOptions, b as UploadOptions, c as UploaderClient, e as UsageWarning } from './client-DW6DcS6o.cjs';
3
3
  export { C as CropParams, O as OutputParams, Q as QualityParams, R as ResizeParams, a as RotateParams, T as TransformChain, b as TransformOp, c as TransformOpName, d as TransformUrlOptions, e as crop, f as flip, g as flop, o as output, q as quality, r as resize, h as rotate, t as transformUrl, w as withSignedPolicy } from './transform-BTZ0kodO.cjs';
4
4
  import * as React from 'react';
5
5
  import React__default, { CSSProperties } from 'react';
@@ -161,6 +161,17 @@ type SharedPickerProps = {
161
161
  policy: string;
162
162
  signature: string;
163
163
  };
164
+ /**
165
+ * Client-level default delivery protection applied to every file this picker
166
+ * uploads (`public` | `hotlink` | `signed`). Omitted → the account default
167
+ * configured in the website. Must be permitted by the account's plan.
168
+ */
169
+ deliveryProtection?: DeliveryProtection;
170
+ /**
171
+ * Client-level default per-file allowed origins (a domain lock for `signed`,
172
+ * or the allowlist for `hotlink`). Omitted → the account allowlist.
173
+ */
174
+ allowedOrigins?: string[];
164
175
  /** File constraint and source options. */
165
176
  pickerOptions?: PickerOptions;
166
177
  /** Called when all uploads complete. */
@@ -233,7 +244,7 @@ type PickerOverlayProps = SharedPickerProps & {
233
244
  /** Inline styles applied to the modal panel. */
234
245
  style?: React__default.CSSProperties;
235
246
  };
236
- declare function PickerOverlay({ open, onClose, apikey, apiUrl, security, pickerOptions, onUploadDone, onFileUploadFinished, onFileUploadFailed, onCancel, theme, className, style, }: PickerOverlayProps): React__default.JSX.Element | null;
247
+ declare function PickerOverlay({ open, onClose, apikey, apiUrl, security, deliveryProtection, allowedOrigins, pickerOptions, onUploadDone, onFileUploadFinished, onFileUploadFailed, onCancel, theme, className, style, }: PickerOverlayProps): React__default.JSX.Element | null;
237
248
 
238
249
  /**
239
250
  * DropPane — inline drag-and-drop upload zone.
@@ -276,7 +287,7 @@ type DropPaneProps = SharedPickerProps & {
276
287
  /** Inline styles applied to the root element. */
277
288
  style?: React__default.CSSProperties;
278
289
  };
279
- declare function DropPane({ apikey, apiUrl, security, pickerOptions, onUploadDone, onFileUploadFinished, onFileUploadFailed, onCancel, hint, theme, className, style, }: DropPaneProps): React__default.JSX.Element;
290
+ declare function DropPane({ apikey, apiUrl, security, deliveryProtection, allowedOrigins, pickerOptions, onUploadDone, onFileUploadFinished, onFileUploadFailed, onCancel, hint, theme, className, style, }: DropPaneProps): React__default.JSX.Element;
280
291
 
281
292
  /**
282
293
  * CameraCapture — in-picker webcam capture.
@@ -390,4 +401,4 @@ type EditImageOptions = {
390
401
  };
391
402
  declare function editImage(file: File, opts?: EditImageOptions): Promise<File>;
392
403
 
393
- export { CameraCapture, type CameraCaptureProps, type CropArea, DropPane, type DropPaneProps, type EditImageOptions, FileResult, type Flip, ImageEditor, type ImageEditorProps, type PickerFile, type PickerFileState, type PickerOptions, PickerOverlay, type PickerOverlayProps, PickerResponse, type SharedPickerProps, UploaderClientOptions, type UploaderTheme, type UsePickerOptions, type UsePickerResult, editImage, isCameraSupported, shouldOfferCamera, themeToVars, usePicker };
404
+ export { CameraCapture, type CameraCaptureProps, type CropArea, DeliveryProtection, DropPane, type DropPaneProps, type EditImageOptions, FileResult, type Flip, ImageEditor, type ImageEditorProps, type PickerFile, type PickerFileState, type PickerOptions, PickerOverlay, type PickerOverlayProps, PickerResponse, type SharedPickerProps, UploaderClientOptions, type UploaderTheme, type UsePickerOptions, type UsePickerResult, editImage, isCameraSupported, shouldOfferCamera, themeToVars, usePicker };
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { P as PickerResponse, F as FileResult, d as UploaderClientOptions } from './client-CUmYuQ7Z.js';
2
- export { D as DeliveryProtection, a as PolicySpec, U as UploadAllOptions, b as UploadOptions, c as UploaderClient } from './client-CUmYuQ7Z.js';
1
+ import { D as DeliveryProtection, P as PickerResponse, F as FileResult, d as UploaderClientOptions } from './client-DW6DcS6o.js';
2
+ export { a as PolicySpec, U as UploadAllOptions, b as UploadOptions, c as UploaderClient, e as UsageWarning } from './client-DW6DcS6o.js';
3
3
  export { C as CropParams, O as OutputParams, Q as QualityParams, R as ResizeParams, a as RotateParams, T as TransformChain, b as TransformOp, c as TransformOpName, d as TransformUrlOptions, e as crop, f as flip, g as flop, o as output, q as quality, r as resize, h as rotate, t as transformUrl, w as withSignedPolicy } from './transform-BTZ0kodO.js';
4
4
  import * as React from 'react';
5
5
  import React__default, { CSSProperties } from 'react';
@@ -161,6 +161,17 @@ type SharedPickerProps = {
161
161
  policy: string;
162
162
  signature: string;
163
163
  };
164
+ /**
165
+ * Client-level default delivery protection applied to every file this picker
166
+ * uploads (`public` | `hotlink` | `signed`). Omitted → the account default
167
+ * configured in the website. Must be permitted by the account's plan.
168
+ */
169
+ deliveryProtection?: DeliveryProtection;
170
+ /**
171
+ * Client-level default per-file allowed origins (a domain lock for `signed`,
172
+ * or the allowlist for `hotlink`). Omitted → the account allowlist.
173
+ */
174
+ allowedOrigins?: string[];
164
175
  /** File constraint and source options. */
165
176
  pickerOptions?: PickerOptions;
166
177
  /** Called when all uploads complete. */
@@ -233,7 +244,7 @@ type PickerOverlayProps = SharedPickerProps & {
233
244
  /** Inline styles applied to the modal panel. */
234
245
  style?: React__default.CSSProperties;
235
246
  };
236
- declare function PickerOverlay({ open, onClose, apikey, apiUrl, security, pickerOptions, onUploadDone, onFileUploadFinished, onFileUploadFailed, onCancel, theme, className, style, }: PickerOverlayProps): React__default.JSX.Element | null;
247
+ declare function PickerOverlay({ open, onClose, apikey, apiUrl, security, deliveryProtection, allowedOrigins, pickerOptions, onUploadDone, onFileUploadFinished, onFileUploadFailed, onCancel, theme, className, style, }: PickerOverlayProps): React__default.JSX.Element | null;
237
248
 
238
249
  /**
239
250
  * DropPane — inline drag-and-drop upload zone.
@@ -276,7 +287,7 @@ type DropPaneProps = SharedPickerProps & {
276
287
  /** Inline styles applied to the root element. */
277
288
  style?: React__default.CSSProperties;
278
289
  };
279
- declare function DropPane({ apikey, apiUrl, security, pickerOptions, onUploadDone, onFileUploadFinished, onFileUploadFailed, onCancel, hint, theme, className, style, }: DropPaneProps): React__default.JSX.Element;
290
+ declare function DropPane({ apikey, apiUrl, security, deliveryProtection, allowedOrigins, pickerOptions, onUploadDone, onFileUploadFinished, onFileUploadFailed, onCancel, hint, theme, className, style, }: DropPaneProps): React__default.JSX.Element;
280
291
 
281
292
  /**
282
293
  * CameraCapture — in-picker webcam capture.
@@ -390,4 +401,4 @@ type EditImageOptions = {
390
401
  };
391
402
  declare function editImage(file: File, opts?: EditImageOptions): Promise<File>;
392
403
 
393
- export { CameraCapture, type CameraCaptureProps, type CropArea, DropPane, type DropPaneProps, type EditImageOptions, FileResult, type Flip, ImageEditor, type ImageEditorProps, type PickerFile, type PickerFileState, type PickerOptions, PickerOverlay, type PickerOverlayProps, PickerResponse, type SharedPickerProps, UploaderClientOptions, type UploaderTheme, type UsePickerOptions, type UsePickerResult, editImage, isCameraSupported, shouldOfferCamera, themeToVars, usePicker };
404
+ export { CameraCapture, type CameraCaptureProps, type CropArea, DeliveryProtection, DropPane, type DropPaneProps, type EditImageOptions, FileResult, type Flip, ImageEditor, type ImageEditorProps, type PickerFile, type PickerFileState, type PickerOptions, PickerOverlay, type PickerOverlayProps, PickerResponse, type SharedPickerProps, UploaderClientOptions, type UploaderTheme, type UsePickerOptions, type UsePickerResult, editImage, isCameraSupported, shouldOfferCamera, themeToVars, usePicker };
package/dist/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  UploaderClient
3
- } from "./chunk-6AJTZNOI.js";
3
+ } from "./chunk-7LTEX76J.js";
4
4
  import {
5
5
  crop,
6
6
  flip,
@@ -31,11 +31,22 @@ function nextId() {
31
31
  function usePicker(opts) {
32
32
  const [files, setFiles] = useState([]);
33
33
  const clientRef = useRef(null);
34
- if (!clientRef.current || clientRef.current.apikey !== opts.apikey || clientRef.current.apiUrl !== (opts.apiUrl ?? "https://api.uploaderhq.io")) {
34
+ const clientSigRef = useRef("");
35
+ const clientSig = JSON.stringify({
36
+ apikey: opts.apikey,
37
+ apiUrl: opts.apiUrl ?? null,
38
+ security: opts.security ?? null,
39
+ deliveryProtection: opts.deliveryProtection ?? null,
40
+ allowedOrigins: opts.allowedOrigins ?? null
41
+ });
42
+ if (!clientRef.current || clientSigRef.current !== clientSig) {
43
+ clientSigRef.current = clientSig;
35
44
  clientRef.current = new UploaderClient({
36
45
  apikey: opts.apikey,
37
46
  apiUrl: opts.apiUrl,
38
- security: opts.security
47
+ security: opts.security,
48
+ deliveryProtection: opts.deliveryProtection,
49
+ allowedOrigins: opts.allowedOrigins
39
50
  });
40
51
  }
41
52
  const addFiles = useCallback(
@@ -1138,6 +1149,8 @@ function PickerOverlay({
1138
1149
  apikey,
1139
1150
  apiUrl,
1140
1151
  security,
1152
+ deliveryProtection,
1153
+ allowedOrigins,
1141
1154
  pickerOptions,
1142
1155
  onUploadDone,
1143
1156
  onFileUploadFinished,
@@ -1156,6 +1169,8 @@ function PickerOverlay({
1156
1169
  apikey,
1157
1170
  apiUrl,
1158
1171
  security,
1172
+ deliveryProtection,
1173
+ allowedOrigins,
1159
1174
  pickerOptions,
1160
1175
  onUploadDone,
1161
1176
  onFileUploadFinished,
@@ -1438,6 +1453,8 @@ function DropPane({
1438
1453
  apikey,
1439
1454
  apiUrl,
1440
1455
  security,
1456
+ deliveryProtection,
1457
+ allowedOrigins,
1441
1458
  pickerOptions,
1442
1459
  onUploadDone,
1443
1460
  onFileUploadFinished,
@@ -1455,6 +1472,8 @@ function DropPane({
1455
1472
  apikey,
1456
1473
  apiUrl,
1457
1474
  security,
1475
+ deliveryProtection,
1476
+ allowedOrigins,
1458
1477
  pickerOptions,
1459
1478
  onUploadDone,
1460
1479
  onFileUploadFinished,