@shipstatic/drop 1.0.3 → 2.0.0-beta.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,74 +1,35 @@
1
- import { P as ProcessedFile } from './useDrop-BAYclQ_x.cjs';
2
- export { C as ClientError, D as DropOptions, a as DropReturn, b as DropState, c as DropStateValue, d as DropStatus, e as DropzonePropsOptions, F as FILE_STATUSES, f as FileStatus, u as useDrop } from './useDrop-BAYclQ_x.cjs';
3
- export { formatFileSize } from '@shipstatic/ship';
1
+ import { PlatformLimits } from '@shipstatic/types';
2
+ import { P as ProcessedFile, D as DropStatus } from './useDrop-Bmjfjp_o.cjs';
3
+ export { a as DropOptions, b as DropPhase, c as DropReturn, d as DropzonePropsOptions, u as useDrop } from './useDrop-Bmjfjp_o.cjs';
4
+ import '@shipstatic/ship';
4
5
 
6
+ interface ProcessFilesOptions {
7
+ /** Platform limits, from `ship.getLimits()` */
8
+ limits: PlatformLimits;
9
+ /** Progress reporter for long steps */
10
+ onStatus?: (status: DropStatus) => void;
11
+ }
5
12
  /**
6
- * Patch a File's `webkitRelativePath` so downstream consumers (the Ship SDK)
7
- * read our resolved deploy path. Browser-set `webkitRelativePath` is read-only,
8
- * so we redefine the property — `configurable: true` allows re-patching later.
9
- */
10
- declare function setRelativePath(file: File, path: string): void;
11
- /**
12
- * Create a ProcessedFile from a File object
13
- * This is the single conversion point from File to ProcessedFile
14
- *
15
- * Note: MD5 calculation is handled by Ship SDK during deployment.
16
- * Drop focuses on file processing, path normalization, and UI state management.
17
- *
18
- * Path resolution priority:
19
- * 1. options.path (if provided)
20
- * 2. file.webkitRelativePath (if non-empty, preserves folder structure)
21
- * 3. file.name (fallback)
22
- */
23
- declare function createProcessedFile(file: File, options?: {
24
- /** Custom path (defaults to webkitRelativePath or file.name) */
25
- path?: string;
26
- }): ProcessedFile;
27
- /**
28
- * Strip common directory prefix from file paths.
13
+ * The verdict. Mirrors the hook's state minus `isDragging`, which is a pointer
14
+ * concern the pipeline knows nothing about.
29
15
  *
30
- * Delegates the path algorithm to Ship SDK's `optimizeDeployPaths` (the single
31
- * source of truth for deploy-path normalization) and mutates each underlying
32
- * File's `webkitRelativePath` so downstream consumers (Ship SDK) read the
33
- * stripped path when given the raw File objects.
34
- */
35
- declare function stripCommonPrefix(files: ProcessedFile[]): ProcessedFile[];
36
- /**
37
- * Recursively traverse FileSystemEntry from drag & drop to collect all files
38
- * Properly sets webkitRelativePath to preserve folder structure
39
- */
40
- declare function traverseFileTree(entry: FileSystemEntry, files: File[], currentPath?: string): Promise<void>;
41
-
42
- interface ZipExtractionResult {
43
- /** Extracted files as regular File objects */
44
- files: File[];
45
- /** Any errors encountered during extraction */
46
- errors: string[];
16
+ * Ready files are `files.filter(f => f.status === FileValidationStatus.READY)` kept as
17
+ * one derivation rather than a second field that could disagree with the first.
18
+ */
19
+ interface DropOutcome {
20
+ phase: 'ready' | 'error';
21
+ files: ProcessedFile[];
22
+ sourceName: string;
23
+ status: DropStatus;
24
+ needsBuild: boolean;
47
25
  }
48
26
  /**
49
- * Extracts all files from a ZIP archive
50
- * Returns regular File objects that can be processed like any other file
51
- */
52
- declare function extractZipToFiles(zipFile: File): Promise<ZipExtractionResult>;
53
- /**
54
- * Sanitize and normalize a file path to prevent directory traversal attacks
55
- * Removes: .., ., leading/trailing slashes, absolute paths, and empty segments
27
+ * Run the pipeline.
56
28
  *
57
- * @example
58
- * normalizePath('../../etc/passwd') 'etc/passwd'
59
- * normalizePath('foo/./bar/../baz.txt') 'foo/baz.txt'
60
- * normalizePath('/absolute/path.txt') → 'absolute/path.txt'
61
- */
62
- declare function normalizePath(path: string): string;
63
- /**
64
- * Check if a file is a ZIP file based on MIME type or extension
65
- */
66
- declare function isZipFile(file: File): boolean;
67
-
68
- /**
69
- * Get MIME type from file path (browser-compatible, no Node.js dependencies)
70
- * Returns empty string if extension not found, allowing fallback to browser detection
29
+ * Never throws: an unbuilt project rejected by `filterJunk`, a missing entry
30
+ * point, a file over the limit, and an unexpected host-object failure all come
31
+ * back as an `error` outcome. Callers need no try/catch.
71
32
  */
72
- declare function getMimeType(path: string): string;
33
+ declare function processFiles(input: File[], { limits, onStatus }: ProcessFilesOptions): Promise<DropOutcome>;
73
34
 
74
- export { ProcessedFile, type ZipExtractionResult, createProcessedFile, extractZipToFiles, getMimeType, isZipFile, normalizePath, setRelativePath, stripCommonPrefix, traverseFileTree };
35
+ export { type DropOutcome, DropStatus, type ProcessFilesOptions, ProcessedFile, processFiles };
package/dist/index.d.ts CHANGED
@@ -1,74 +1,35 @@
1
- import { P as ProcessedFile } from './useDrop-BAYclQ_x.js';
2
- export { C as ClientError, D as DropOptions, a as DropReturn, b as DropState, c as DropStateValue, d as DropStatus, e as DropzonePropsOptions, F as FILE_STATUSES, f as FileStatus, u as useDrop } from './useDrop-BAYclQ_x.js';
3
- export { formatFileSize } from '@shipstatic/ship';
1
+ import { PlatformLimits } from '@shipstatic/types';
2
+ import { P as ProcessedFile, D as DropStatus } from './useDrop-Bmjfjp_o.js';
3
+ export { a as DropOptions, b as DropPhase, c as DropReturn, d as DropzonePropsOptions, u as useDrop } from './useDrop-Bmjfjp_o.js';
4
+ import '@shipstatic/ship';
4
5
 
6
+ interface ProcessFilesOptions {
7
+ /** Platform limits, from `ship.getLimits()` */
8
+ limits: PlatformLimits;
9
+ /** Progress reporter for long steps */
10
+ onStatus?: (status: DropStatus) => void;
11
+ }
5
12
  /**
6
- * Patch a File's `webkitRelativePath` so downstream consumers (the Ship SDK)
7
- * read our resolved deploy path. Browser-set `webkitRelativePath` is read-only,
8
- * so we redefine the property — `configurable: true` allows re-patching later.
9
- */
10
- declare function setRelativePath(file: File, path: string): void;
11
- /**
12
- * Create a ProcessedFile from a File object
13
- * This is the single conversion point from File to ProcessedFile
14
- *
15
- * Note: MD5 calculation is handled by Ship SDK during deployment.
16
- * Drop focuses on file processing, path normalization, and UI state management.
17
- *
18
- * Path resolution priority:
19
- * 1. options.path (if provided)
20
- * 2. file.webkitRelativePath (if non-empty, preserves folder structure)
21
- * 3. file.name (fallback)
22
- */
23
- declare function createProcessedFile(file: File, options?: {
24
- /** Custom path (defaults to webkitRelativePath or file.name) */
25
- path?: string;
26
- }): ProcessedFile;
27
- /**
28
- * Strip common directory prefix from file paths.
13
+ * The verdict. Mirrors the hook's state minus `isDragging`, which is a pointer
14
+ * concern the pipeline knows nothing about.
29
15
  *
30
- * Delegates the path algorithm to Ship SDK's `optimizeDeployPaths` (the single
31
- * source of truth for deploy-path normalization) and mutates each underlying
32
- * File's `webkitRelativePath` so downstream consumers (Ship SDK) read the
33
- * stripped path when given the raw File objects.
34
- */
35
- declare function stripCommonPrefix(files: ProcessedFile[]): ProcessedFile[];
36
- /**
37
- * Recursively traverse FileSystemEntry from drag & drop to collect all files
38
- * Properly sets webkitRelativePath to preserve folder structure
39
- */
40
- declare function traverseFileTree(entry: FileSystemEntry, files: File[], currentPath?: string): Promise<void>;
41
-
42
- interface ZipExtractionResult {
43
- /** Extracted files as regular File objects */
44
- files: File[];
45
- /** Any errors encountered during extraction */
46
- errors: string[];
16
+ * Ready files are `files.filter(f => f.status === FileValidationStatus.READY)` kept as
17
+ * one derivation rather than a second field that could disagree with the first.
18
+ */
19
+ interface DropOutcome {
20
+ phase: 'ready' | 'error';
21
+ files: ProcessedFile[];
22
+ sourceName: string;
23
+ status: DropStatus;
24
+ needsBuild: boolean;
47
25
  }
48
26
  /**
49
- * Extracts all files from a ZIP archive
50
- * Returns regular File objects that can be processed like any other file
51
- */
52
- declare function extractZipToFiles(zipFile: File): Promise<ZipExtractionResult>;
53
- /**
54
- * Sanitize and normalize a file path to prevent directory traversal attacks
55
- * Removes: .., ., leading/trailing slashes, absolute paths, and empty segments
27
+ * Run the pipeline.
56
28
  *
57
- * @example
58
- * normalizePath('../../etc/passwd') 'etc/passwd'
59
- * normalizePath('foo/./bar/../baz.txt') 'foo/baz.txt'
60
- * normalizePath('/absolute/path.txt') → 'absolute/path.txt'
61
- */
62
- declare function normalizePath(path: string): string;
63
- /**
64
- * Check if a file is a ZIP file based on MIME type or extension
65
- */
66
- declare function isZipFile(file: File): boolean;
67
-
68
- /**
69
- * Get MIME type from file path (browser-compatible, no Node.js dependencies)
70
- * Returns empty string if extension not found, allowing fallback to browser detection
29
+ * Never throws: an unbuilt project rejected by `filterJunk`, a missing entry
30
+ * point, a file over the limit, and an unexpected host-object failure all come
31
+ * back as an `error` outcome. Callers need no try/catch.
71
32
  */
72
- declare function getMimeType(path: string): string;
33
+ declare function processFiles(input: File[], { limits, onStatus }: ProcessFilesOptions): Promise<DropOutcome>;
73
34
 
74
- export { ProcessedFile, type ZipExtractionResult, createProcessedFile, extractZipToFiles, getMimeType, isZipFile, normalizePath, setRelativePath, stripCommonPrefix, traverseFileTree };
35
+ export { type DropOutcome, DropStatus, type ProcessFilesOptions, ProcessedFile, processFiles };