@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/README.md +166 -124
- package/dist/index.cjs +534 -9828
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +27 -66
- package/dist/index.d.ts +27 -66
- package/dist/index.js +534 -9817
- package/dist/index.js.map +1 -1
- package/dist/testing.cjs +65 -96
- package/dist/testing.cjs.map +1 -1
- package/dist/testing.d.cts +47 -67
- package/dist/testing.d.ts +47 -67
- package/dist/testing.js +65 -92
- package/dist/testing.js.map +1 -1
- package/dist/useDrop-Bmjfjp_o.d.cts +140 -0
- package/dist/useDrop-Bmjfjp_o.d.ts +140 -0
- package/package.json +45 -26
- package/dist/useDrop-BAYclQ_x.d.cts +0 -147
- package/dist/useDrop-BAYclQ_x.d.ts +0 -147
package/dist/index.d.cts
CHANGED
|
@@ -1,74 +1,35 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
export {
|
|
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
|
-
*
|
|
7
|
-
*
|
|
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
|
-
*
|
|
31
|
-
*
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
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
|
-
*
|
|
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
|
-
*
|
|
58
|
-
*
|
|
59
|
-
*
|
|
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
|
|
33
|
+
declare function processFiles(input: File[], { limits, onStatus }: ProcessFilesOptions): Promise<DropOutcome>;
|
|
73
34
|
|
|
74
|
-
export {
|
|
35
|
+
export { type DropOutcome, DropStatus, type ProcessFilesOptions, ProcessedFile, processFiles };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,74 +1,35 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
export {
|
|
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
|
-
*
|
|
7
|
-
*
|
|
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
|
-
*
|
|
31
|
-
*
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
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
|
-
*
|
|
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
|
-
*
|
|
58
|
-
*
|
|
59
|
-
*
|
|
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
|
|
33
|
+
declare function processFiles(input: File[], { limits, onStatus }: ProcessFilesOptions): Promise<DropOutcome>;
|
|
73
34
|
|
|
74
|
-
export {
|
|
35
|
+
export { type DropOutcome, DropStatus, type ProcessFilesOptions, ProcessedFile, processFiles };
|