@useupup/core 3.3.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.
Files changed (118) hide show
  1. package/LICENSE +21 -0
  2. package/NOTICE +8 -0
  3. package/README.md +75 -0
  4. package/dist/browser-SXR426OQ.cjs +10 -0
  5. package/dist/browser-WD6T5ABJ.js +1 -0
  6. package/dist/chunk-2H5ICKFT.cjs +122 -0
  7. package/dist/chunk-6HF3I2JS.cjs +39 -0
  8. package/dist/chunk-6S5DQDQH.js +212 -0
  9. package/dist/chunk-BMQC27OE.cjs +92 -0
  10. package/dist/chunk-BSGQGINR.cjs +219 -0
  11. package/dist/chunk-CPKZ2CXD.cjs +179 -0
  12. package/dist/chunk-DTKDIMKT.cjs +573 -0
  13. package/dist/chunk-DYE5XJ6Z.cjs +2134 -0
  14. package/dist/chunk-E3ZCNOXG.cjs +74 -0
  15. package/dist/chunk-FEQY2WYY.cjs +2377 -0
  16. package/dist/chunk-FMURBCZ7.js +120 -0
  17. package/dist/chunk-FYQQRULL.js +37 -0
  18. package/dist/chunk-GE4LIVXP.js +133 -0
  19. package/dist/chunk-HFR5HZJZ.js +56 -0
  20. package/dist/chunk-I7ULPCA2.js +72 -0
  21. package/dist/chunk-MHYXDLZR.js +569 -0
  22. package/dist/chunk-N2SLHVAW.cjs +61 -0
  23. package/dist/chunk-OOPDEOTM.js +169 -0
  24. package/dist/chunk-PMBR3OUW.js +2359 -0
  25. package/dist/chunk-QK7HZIVY.cjs +144 -0
  26. package/dist/chunk-T2AQHY7V.cjs +59 -0
  27. package/dist/chunk-TRCP5FUR.js +90 -0
  28. package/dist/chunk-U7KL5M2H.cjs +374 -0
  29. package/dist/chunk-UXNPM54W.js +2108 -0
  30. package/dist/chunk-VV6QCQLL.js +365 -0
  31. package/dist/chunk-ZMS2HXLB.js +56 -0
  32. package/dist/context-shapes-123dd3b6.d.cts +207 -0
  33. package/dist/context-shapes-27b24c8f.d.ts +207 -0
  34. package/dist/contracts-pipeline-cf177270.d.cts +78 -0
  35. package/dist/contracts-pipeline-cf177270.d.ts +78 -0
  36. package/dist/contracts-strategies-378a16b7.d.cts +168 -0
  37. package/dist/contracts-strategies-378a16b7.d.ts +168 -0
  38. package/dist/contracts.cjs +181 -0
  39. package/dist/contracts.d.cts +11 -0
  40. package/dist/contracts.d.ts +11 -0
  41. package/dist/contracts.js +4 -0
  42. package/dist/core-141335ac.d.ts +651 -0
  43. package/dist/core-bea2ceca.d.cts +651 -0
  44. package/dist/create-worker-provider-AA5SRII6.js +58 -0
  45. package/dist/create-worker-provider-KJNUSSTW.cjs +60 -0
  46. package/dist/eligibility-ONLNJ6FB.cjs +10 -0
  47. package/dist/eligibility-ULFC3E4G.js +8 -0
  48. package/dist/error-code-map-9c44a425.d.ts +62 -0
  49. package/dist/error-code-map-dd5becfa.d.cts +62 -0
  50. package/dist/i18n/index.cjs +90 -0
  51. package/dist/i18n/index.d.cts +3 -0
  52. package/dist/i18n/index.d.ts +3 -0
  53. package/dist/i18n/index.js +1 -0
  54. package/dist/index.cjs +1770 -0
  55. package/dist/index.d.cts +280 -0
  56. package/dist/index.d.ts +280 -0
  57. package/dist/index.js +1589 -0
  58. package/dist/internal.cjs +2407 -0
  59. package/dist/internal.d.cts +595 -0
  60. package/dist/internal.d.ts +595 -0
  61. package/dist/internal.js +2275 -0
  62. package/dist/pipeline/index.cjs +10 -0
  63. package/dist/pipeline/index.d.cts +11 -0
  64. package/dist/pipeline/index.d.ts +11 -0
  65. package/dist/pipeline/index.js +1 -0
  66. package/dist/pipeline-worker.cjs +199 -0
  67. package/dist/pipeline-worker.d.cts +2 -0
  68. package/dist/pipeline-worker.d.ts +2 -0
  69. package/dist/pipeline-worker.js +197 -0
  70. package/dist/resolve-locale-81feef21.d.ts +20 -0
  71. package/dist/resolve-locale-9cb63600.d.cts +20 -0
  72. package/dist/resolve-theme-01758105.d.ts +53 -0
  73. package/dist/resolve-theme-66cf8d98.d.cts +53 -0
  74. package/dist/server-mode-drive-controller-b5f8ee12.d.cts +180 -0
  75. package/dist/server-mode-drive-controller-b5f8ee12.d.ts +180 -0
  76. package/dist/steps/compress.cjs +66 -0
  77. package/dist/steps/compress.d.cts +10 -0
  78. package/dist/steps/compress.d.ts +10 -0
  79. package/dist/steps/compress.js +64 -0
  80. package/dist/steps/exif.cjs +44 -0
  81. package/dist/steps/exif.d.cts +5 -0
  82. package/dist/steps/exif.d.ts +5 -0
  83. package/dist/steps/exif.js +42 -0
  84. package/dist/steps/hash.cjs +44 -0
  85. package/dist/steps/hash.d.cts +5 -0
  86. package/dist/steps/hash.d.ts +5 -0
  87. package/dist/steps/hash.js +42 -0
  88. package/dist/steps/heic.cjs +59 -0
  89. package/dist/steps/heic.d.cts +5 -0
  90. package/dist/steps/heic.d.ts +5 -0
  91. package/dist/steps/heic.js +57 -0
  92. package/dist/steps/thumbnail.cjs +54 -0
  93. package/dist/steps/thumbnail.d.cts +10 -0
  94. package/dist/steps/thumbnail.d.ts +10 -0
  95. package/dist/steps/thumbnail.js +52 -0
  96. package/dist/strategies/index.cjs +82 -0
  97. package/dist/strategies/index.d.cts +187 -0
  98. package/dist/strategies/index.d.ts +187 -0
  99. package/dist/strategies/index.js +60 -0
  100. package/dist/strategies/tus-upload.cjs +14 -0
  101. package/dist/strategies/tus-upload.d.cts +15 -0
  102. package/dist/strategies/tus-upload.d.ts +15 -0
  103. package/dist/strategies/tus-upload.js +5 -0
  104. package/dist/theme/index.cjs +38 -0
  105. package/dist/theme/index.d.cts +3 -0
  106. package/dist/theme/index.d.ts +3 -0
  107. package/dist/theme/index.js +1 -0
  108. package/dist/theme-store-2e56a674.d.cts +39 -0
  109. package/dist/theme-store-f13e0315.d.ts +39 -0
  110. package/dist/token-endpoint-5fdb4a35.d.ts +20 -0
  111. package/dist/token-endpoint-a7d15ab6.d.cts +20 -0
  112. package/dist/ui-translations-c5d00392.d.cts +455 -0
  113. package/dist/ui-translations-c5d00392.d.ts +455 -0
  114. package/dist/uploader-props-72242002.d.ts +340 -0
  115. package/dist/uploader-props-7f956e60.d.cts +340 -0
  116. package/dist/vars-d3421f6c.d.cts +240 -0
  117. package/dist/vars-d3421f6c.d.ts +240 -0
  118. package/package.json +182 -0
@@ -0,0 +1,180 @@
1
+ type DriveFile = {
2
+ id: string;
3
+ name: string;
4
+ path: string;
5
+ size: number;
6
+ mimeType: string;
7
+ isFolder: boolean;
8
+ thumbnail?: string | undefined;
9
+ modifiedAt?: string | undefined;
10
+ };
11
+ type DriveFolder = DriveFile & {
12
+ children: DriveFile[];
13
+ };
14
+ type DriveUser = {
15
+ name: string;
16
+ email?: string;
17
+ picture?: string;
18
+ };
19
+ type DriveState = 'idle' | 'authenticating' | 'authenticated' | 'browsing' | 'session-expired';
20
+ /** The one drive browse-failure surface (F-124). `action` names the operation that failed. */
21
+ type DriveBrowserError = {
22
+ message: string;
23
+ action?: string | undefined;
24
+ };
25
+ /**
26
+ * A page returned by DrivePlugin.loadMoreFiles (F-125). `cursor` is an OPAQUE
27
+ * string — each plugin encodes its own native continuation token (Dropbox's
28
+ * raw cursor, Box's "folderId:offset", Google's JSON pageToken, OneDrive's
29
+ * absolute @odata.nextLink) inside it. The controller stores and hands it
30
+ * back verbatim; it never branches on provider.
31
+ */
32
+ type DriveListPage = {
33
+ files: DriveFile[];
34
+ hasMore: boolean;
35
+ cursor?: string | undefined;
36
+ };
37
+ type DriveEventMap = {
38
+ authenticated: {
39
+ token: string;
40
+ };
41
+ 'signed-out': Record<string, never>;
42
+ 'session-expired': Record<string, never>;
43
+ 'files-loaded': {
44
+ files: DriveFile[];
45
+ path: string;
46
+ hasMore?: boolean;
47
+ cursor?: string;
48
+ };
49
+ error: {
50
+ error: Error;
51
+ action: string;
52
+ };
53
+ 'state-change': {
54
+ state: DriveState;
55
+ };
56
+ };
57
+
58
+ /**
59
+ * Per-provider configuration for the framework-agnostic DriveBrowserController.
60
+ * The four cloud-drive providers share ~90% of their browse logic; everything
61
+ * that genuinely differs is captured declaratively here.
62
+ */
63
+ type DriveAuthKind = 'gis' | 'popup';
64
+ type DriveFolderKey = 'id' | 'path';
65
+ type DriveSelectFolderStrategy = 'cached-children' | 'load-all';
66
+ interface DriveProviderDescriptor {
67
+ /** Key passed to core.getPlugin(...). Matches the plugin's `id`/`name`. */
68
+ pluginId: string;
69
+ /**
70
+ * Prefix used to build event names for bindDriveEvents(core, eventPrefix, …).
71
+ */
72
+ eventPrefix: string;
73
+ /** Display name for the root folder. */
74
+ rootFolderName: string;
75
+ /** Id used to detect/label the root folder in files-loaded payloads. */
76
+ rootFolderId: string;
77
+ /** Whether a folder is addressed by `id` (most) or `path` (Dropbox). */
78
+ folderKey: DriveFolderKey;
79
+ /** Argument passed to plugin.loadFiles() to list the root folder. */
80
+ loadFilesRootArg: string | undefined;
81
+ /** Which field in the files-loaded payload carries the folder identity. */
82
+ folderIdField: 'folderId' | 'path';
83
+ /** Auth strategy: GIS popup (Google) or plugin-driven popup (the rest). */
84
+ auth: DriveAuthKind;
85
+ /** How onSelectCurrentFolder gathers files. */
86
+ selectFolder: DriveSelectFolderStrategy;
87
+ /** Root argument for plugin.loadAllFilesInFolder() (popup providers only). */
88
+ loadAllRootArg?: string;
89
+ }
90
+ declare const GOOGLE_DRIVE_DESCRIPTOR: DriveProviderDescriptor;
91
+ declare const ONE_DRIVE_DESCRIPTOR: DriveProviderDescriptor;
92
+ declare const DROPBOX_DESCRIPTOR: DriveProviderDescriptor;
93
+ declare const BOX_DESCRIPTOR: DriveProviderDescriptor;
94
+
95
+ /** The uniform observer surface every hoisted core controller exposes. */
96
+ interface ObservableController<TSnapshot = unknown> {
97
+ /** Subscribe to change notifications; returns an unsubscribe. */
98
+ subscribe(listener: () => void): () => void;
99
+ /** Current immutable snapshot — referentially stable until a change occurs. */
100
+ getSnapshot(): TSnapshot;
101
+ /** Tear down internal subscriptions/listeners. Idempotent. */
102
+ destroy(): void;
103
+ }
104
+
105
+ type ServerModeProvider = 'google-drive' | 'one-drive' | 'dropbox' | 'box';
106
+ interface ServerDriveFile {
107
+ id: string;
108
+ name: string;
109
+ size?: number;
110
+ mimeType?: string;
111
+ thumbnailUrl?: string;
112
+ isFolder: boolean;
113
+ modifiedAt?: string;
114
+ }
115
+ type ServerDriveListState = {
116
+ status: 'idle';
117
+ } | {
118
+ status: 'loading';
119
+ } | {
120
+ status: 'ready';
121
+ files: ServerDriveFile[];
122
+ } | {
123
+ status: 'reauth';
124
+ } | {
125
+ status: 'error';
126
+ message: string;
127
+ code?: string;
128
+ };
129
+ type ServerDriveTransferResult = {
130
+ status: 'ok';
131
+ result: unknown;
132
+ } | {
133
+ status: 'reauth';
134
+ } | {
135
+ status: 'error';
136
+ message: string;
137
+ code?: string;
138
+ };
139
+ interface ServerDriveSnapshot {
140
+ state: ServerDriveListState;
141
+ folderId: string | undefined;
142
+ search: string;
143
+ }
144
+ interface ServerModeDriveDeps {
145
+ provider: ServerModeProvider;
146
+ /** Getter so the controller never reads a runtime global at construction. */
147
+ serverUrl: () => string | undefined;
148
+ }
149
+ declare class ServerModeDriveController implements ObservableController<ServerDriveSnapshot> {
150
+ private deps;
151
+ private snapshot;
152
+ private listeners;
153
+ private abort;
154
+ private authListener;
155
+ constructor(deps: ServerModeDriveDeps);
156
+ subscribe: (listener: () => void) => (() => void);
157
+ getSnapshot: () => ServerDriveSnapshot;
158
+ private setState;
159
+ /** Initial list. Call on mount. */
160
+ init(): void;
161
+ list(opts?: {
162
+ folderId?: string;
163
+ search?: string;
164
+ }): Promise<void>;
165
+ refresh(opts?: {
166
+ folderId?: string;
167
+ search?: string;
168
+ }): Promise<void>;
169
+ transfer(file: ServerDriveFile): Promise<ServerDriveTransferResult>;
170
+ startAuth(): void;
171
+ setFolderId(id: string | undefined): void;
172
+ setSearch(s: string): void;
173
+ /** Force the reauth view (used by batch consumers on a transfer 401). */
174
+ requestReauth(): void;
175
+ /** Force the error view (used by batch consumers on a transfer failure). */
176
+ setError(message: string): void;
177
+ destroy(): void;
178
+ }
179
+
180
+ export { BOX_DESCRIPTOR as B, type DriveUser as D, GOOGLE_DRIVE_DESCRIPTOR as G, ONE_DRIVE_DESCRIPTOR as O, type ServerModeProvider as S, type DriveFile as a, type DriveListPage as b, type DriveState as c, type DriveFolder as d, type DriveEventMap as e, type DriveBrowserError as f, DROPBOX_DESCRIPTOR as g, type ObservableController as h, type ServerDriveFile as i, type ServerDriveListState as j, type DriveProviderDescriptor as k, ServerModeDriveController as l, type ServerDriveTransferResult as m, type ServerDriveSnapshot as n, type ServerModeDriveDeps as o, type DriveAuthKind as p, type DriveFolderKey as q, type DriveSelectFolderStrategy as r };
@@ -0,0 +1,180 @@
1
+ type DriveFile = {
2
+ id: string;
3
+ name: string;
4
+ path: string;
5
+ size: number;
6
+ mimeType: string;
7
+ isFolder: boolean;
8
+ thumbnail?: string | undefined;
9
+ modifiedAt?: string | undefined;
10
+ };
11
+ type DriveFolder = DriveFile & {
12
+ children: DriveFile[];
13
+ };
14
+ type DriveUser = {
15
+ name: string;
16
+ email?: string;
17
+ picture?: string;
18
+ };
19
+ type DriveState = 'idle' | 'authenticating' | 'authenticated' | 'browsing' | 'session-expired';
20
+ /** The one drive browse-failure surface (F-124). `action` names the operation that failed. */
21
+ type DriveBrowserError = {
22
+ message: string;
23
+ action?: string | undefined;
24
+ };
25
+ /**
26
+ * A page returned by DrivePlugin.loadMoreFiles (F-125). `cursor` is an OPAQUE
27
+ * string — each plugin encodes its own native continuation token (Dropbox's
28
+ * raw cursor, Box's "folderId:offset", Google's JSON pageToken, OneDrive's
29
+ * absolute @odata.nextLink) inside it. The controller stores and hands it
30
+ * back verbatim; it never branches on provider.
31
+ */
32
+ type DriveListPage = {
33
+ files: DriveFile[];
34
+ hasMore: boolean;
35
+ cursor?: string | undefined;
36
+ };
37
+ type DriveEventMap = {
38
+ authenticated: {
39
+ token: string;
40
+ };
41
+ 'signed-out': Record<string, never>;
42
+ 'session-expired': Record<string, never>;
43
+ 'files-loaded': {
44
+ files: DriveFile[];
45
+ path: string;
46
+ hasMore?: boolean;
47
+ cursor?: string;
48
+ };
49
+ error: {
50
+ error: Error;
51
+ action: string;
52
+ };
53
+ 'state-change': {
54
+ state: DriveState;
55
+ };
56
+ };
57
+
58
+ /**
59
+ * Per-provider configuration for the framework-agnostic DriveBrowserController.
60
+ * The four cloud-drive providers share ~90% of their browse logic; everything
61
+ * that genuinely differs is captured declaratively here.
62
+ */
63
+ type DriveAuthKind = 'gis' | 'popup';
64
+ type DriveFolderKey = 'id' | 'path';
65
+ type DriveSelectFolderStrategy = 'cached-children' | 'load-all';
66
+ interface DriveProviderDescriptor {
67
+ /** Key passed to core.getPlugin(...). Matches the plugin's `id`/`name`. */
68
+ pluginId: string;
69
+ /**
70
+ * Prefix used to build event names for bindDriveEvents(core, eventPrefix, …).
71
+ */
72
+ eventPrefix: string;
73
+ /** Display name for the root folder. */
74
+ rootFolderName: string;
75
+ /** Id used to detect/label the root folder in files-loaded payloads. */
76
+ rootFolderId: string;
77
+ /** Whether a folder is addressed by `id` (most) or `path` (Dropbox). */
78
+ folderKey: DriveFolderKey;
79
+ /** Argument passed to plugin.loadFiles() to list the root folder. */
80
+ loadFilesRootArg: string | undefined;
81
+ /** Which field in the files-loaded payload carries the folder identity. */
82
+ folderIdField: 'folderId' | 'path';
83
+ /** Auth strategy: GIS popup (Google) or plugin-driven popup (the rest). */
84
+ auth: DriveAuthKind;
85
+ /** How onSelectCurrentFolder gathers files. */
86
+ selectFolder: DriveSelectFolderStrategy;
87
+ /** Root argument for plugin.loadAllFilesInFolder() (popup providers only). */
88
+ loadAllRootArg?: string;
89
+ }
90
+ declare const GOOGLE_DRIVE_DESCRIPTOR: DriveProviderDescriptor;
91
+ declare const ONE_DRIVE_DESCRIPTOR: DriveProviderDescriptor;
92
+ declare const DROPBOX_DESCRIPTOR: DriveProviderDescriptor;
93
+ declare const BOX_DESCRIPTOR: DriveProviderDescriptor;
94
+
95
+ /** The uniform observer surface every hoisted core controller exposes. */
96
+ interface ObservableController<TSnapshot = unknown> {
97
+ /** Subscribe to change notifications; returns an unsubscribe. */
98
+ subscribe(listener: () => void): () => void;
99
+ /** Current immutable snapshot — referentially stable until a change occurs. */
100
+ getSnapshot(): TSnapshot;
101
+ /** Tear down internal subscriptions/listeners. Idempotent. */
102
+ destroy(): void;
103
+ }
104
+
105
+ type ServerModeProvider = 'google-drive' | 'one-drive' | 'dropbox' | 'box';
106
+ interface ServerDriveFile {
107
+ id: string;
108
+ name: string;
109
+ size?: number;
110
+ mimeType?: string;
111
+ thumbnailUrl?: string;
112
+ isFolder: boolean;
113
+ modifiedAt?: string;
114
+ }
115
+ type ServerDriveListState = {
116
+ status: 'idle';
117
+ } | {
118
+ status: 'loading';
119
+ } | {
120
+ status: 'ready';
121
+ files: ServerDriveFile[];
122
+ } | {
123
+ status: 'reauth';
124
+ } | {
125
+ status: 'error';
126
+ message: string;
127
+ code?: string;
128
+ };
129
+ type ServerDriveTransferResult = {
130
+ status: 'ok';
131
+ result: unknown;
132
+ } | {
133
+ status: 'reauth';
134
+ } | {
135
+ status: 'error';
136
+ message: string;
137
+ code?: string;
138
+ };
139
+ interface ServerDriveSnapshot {
140
+ state: ServerDriveListState;
141
+ folderId: string | undefined;
142
+ search: string;
143
+ }
144
+ interface ServerModeDriveDeps {
145
+ provider: ServerModeProvider;
146
+ /** Getter so the controller never reads a runtime global at construction. */
147
+ serverUrl: () => string | undefined;
148
+ }
149
+ declare class ServerModeDriveController implements ObservableController<ServerDriveSnapshot> {
150
+ private deps;
151
+ private snapshot;
152
+ private listeners;
153
+ private abort;
154
+ private authListener;
155
+ constructor(deps: ServerModeDriveDeps);
156
+ subscribe: (listener: () => void) => (() => void);
157
+ getSnapshot: () => ServerDriveSnapshot;
158
+ private setState;
159
+ /** Initial list. Call on mount. */
160
+ init(): void;
161
+ list(opts?: {
162
+ folderId?: string;
163
+ search?: string;
164
+ }): Promise<void>;
165
+ refresh(opts?: {
166
+ folderId?: string;
167
+ search?: string;
168
+ }): Promise<void>;
169
+ transfer(file: ServerDriveFile): Promise<ServerDriveTransferResult>;
170
+ startAuth(): void;
171
+ setFolderId(id: string | undefined): void;
172
+ setSearch(s: string): void;
173
+ /** Force the reauth view (used by batch consumers on a transfer 401). */
174
+ requestReauth(): void;
175
+ /** Force the error view (used by batch consumers on a transfer failure). */
176
+ setError(message: string): void;
177
+ destroy(): void;
178
+ }
179
+
180
+ export { BOX_DESCRIPTOR as B, type DriveUser as D, GOOGLE_DRIVE_DESCRIPTOR as G, ONE_DRIVE_DESCRIPTOR as O, type ServerModeProvider as S, type DriveFile as a, type DriveListPage as b, type DriveState as c, type DriveFolder as d, type DriveEventMap as e, type DriveBrowserError as f, DROPBOX_DESCRIPTOR as g, type ObservableController as h, type ServerDriveFile as i, type ServerDriveListState as j, type DriveProviderDescriptor as k, ServerModeDriveController as l, type ServerDriveTransferResult as m, type ServerDriveSnapshot as n, type ServerModeDriveDeps as o, type DriveAuthKind as p, type DriveFolderKey as q, type DriveSelectFolderStrategy as r };
@@ -0,0 +1,66 @@
1
+ 'use strict';
2
+
3
+ var chunk2H5ICKFT_cjs = require('../chunk-2H5ICKFT.cjs');
4
+ var chunkBSGQGINR_cjs = require('../chunk-BSGQGINR.cjs');
5
+ require('../chunk-QK7HZIVY.cjs');
6
+
7
+ // src/steps/compress.ts
8
+ function compressStep(_options) {
9
+ return {
10
+ name: "compress",
11
+ shouldProcess: (file) => file.type.startsWith("image/"),
12
+ async process(file, context) {
13
+ if (await chunk2H5ICKFT_cjs.isAnimatedImage(file)) return file;
14
+ if (context.worker) {
15
+ try {
16
+ const result = await context.worker.execute({
17
+ type: "compress",
18
+ data: await file.arrayBuffer(),
19
+ params: {
20
+ mime: file.type,
21
+ name: file.name,
22
+ maxWidthOrHeight: _options?.maxWidthOrHeight,
23
+ maxSizeMB: _options?.maxSizeMB,
24
+ quality: _options?.quality
25
+ }
26
+ });
27
+ if (result.kind === "image")
28
+ return chunkBSGQGINR_cjs.uploadFileFromImageResult(file, result);
29
+ } catch {
30
+ }
31
+ }
32
+ const maxBytes = typeof _options?.maxSizeMB === "number" ? _options.maxSizeMB * 1024 * 1024 : void 0;
33
+ let quality = _options?.quality ?? 0.82;
34
+ let processed = await chunkBSGQGINR_cjs.encodeImageFile(file, {
35
+ maxWidthOrHeight: _options?.maxWidthOrHeight ?? 1920,
36
+ quality,
37
+ metadata: {
38
+ originalSize: file.size,
39
+ compressed: true
40
+ }
41
+ });
42
+ while (processed && maxBytes && processed.size > maxBytes && quality > 0.35) {
43
+ quality = Math.max(0.35, quality - 0.12);
44
+ processed = await chunkBSGQGINR_cjs.encodeImageFile(file, {
45
+ maxWidthOrHeight: _options?.maxWidthOrHeight ?? 1920,
46
+ quality,
47
+ metadata: {
48
+ originalSize: file.size,
49
+ compressed: true
50
+ }
51
+ });
52
+ }
53
+ if (!processed) return file;
54
+ if (processed.size >= file.size && !maxBytes && !_options?.maxWidthOrHeight) {
55
+ return file;
56
+ }
57
+ processed.metadata = {
58
+ ...processed.metadata,
59
+ processedSize: processed.size
60
+ };
61
+ return processed;
62
+ }
63
+ };
64
+ }
65
+
66
+ exports.compressStep = compressStep;
@@ -0,0 +1,10 @@
1
+ import { P as PipelineStep } from '../contracts-pipeline-cf177270.cjs';
2
+
3
+ interface ImageCompressionOptions {
4
+ maxWidthOrHeight?: number;
5
+ maxSizeMB?: number;
6
+ quality?: number;
7
+ }
8
+ declare function compressStep(_options?: ImageCompressionOptions): PipelineStep;
9
+
10
+ export { type ImageCompressionOptions, compressStep };
@@ -0,0 +1,10 @@
1
+ import { P as PipelineStep } from '../contracts-pipeline-cf177270.js';
2
+
3
+ interface ImageCompressionOptions {
4
+ maxWidthOrHeight?: number;
5
+ maxSizeMB?: number;
6
+ quality?: number;
7
+ }
8
+ declare function compressStep(_options?: ImageCompressionOptions): PipelineStep;
9
+
10
+ export { type ImageCompressionOptions, compressStep };
@@ -0,0 +1,64 @@
1
+ import { isAnimatedImage } from '../chunk-FMURBCZ7.js';
2
+ import { uploadFileFromImageResult, encodeImageFile } from '../chunk-6S5DQDQH.js';
3
+ import '../chunk-GE4LIVXP.js';
4
+
5
+ // src/steps/compress.ts
6
+ function compressStep(_options) {
7
+ return {
8
+ name: "compress",
9
+ shouldProcess: (file) => file.type.startsWith("image/"),
10
+ async process(file, context) {
11
+ if (await isAnimatedImage(file)) return file;
12
+ if (context.worker) {
13
+ try {
14
+ const result = await context.worker.execute({
15
+ type: "compress",
16
+ data: await file.arrayBuffer(),
17
+ params: {
18
+ mime: file.type,
19
+ name: file.name,
20
+ maxWidthOrHeight: _options?.maxWidthOrHeight,
21
+ maxSizeMB: _options?.maxSizeMB,
22
+ quality: _options?.quality
23
+ }
24
+ });
25
+ if (result.kind === "image")
26
+ return uploadFileFromImageResult(file, result);
27
+ } catch {
28
+ }
29
+ }
30
+ const maxBytes = typeof _options?.maxSizeMB === "number" ? _options.maxSizeMB * 1024 * 1024 : void 0;
31
+ let quality = _options?.quality ?? 0.82;
32
+ let processed = await encodeImageFile(file, {
33
+ maxWidthOrHeight: _options?.maxWidthOrHeight ?? 1920,
34
+ quality,
35
+ metadata: {
36
+ originalSize: file.size,
37
+ compressed: true
38
+ }
39
+ });
40
+ while (processed && maxBytes && processed.size > maxBytes && quality > 0.35) {
41
+ quality = Math.max(0.35, quality - 0.12);
42
+ processed = await encodeImageFile(file, {
43
+ maxWidthOrHeight: _options?.maxWidthOrHeight ?? 1920,
44
+ quality,
45
+ metadata: {
46
+ originalSize: file.size,
47
+ compressed: true
48
+ }
49
+ });
50
+ }
51
+ if (!processed) return file;
52
+ if (processed.size >= file.size && !maxBytes && !_options?.maxWidthOrHeight) {
53
+ return file;
54
+ }
55
+ processed.metadata = {
56
+ ...processed.metadata,
57
+ processedSize: processed.size
58
+ };
59
+ return processed;
60
+ }
61
+ };
62
+ }
63
+
64
+ export { compressStep };
@@ -0,0 +1,44 @@
1
+ 'use strict';
2
+
3
+ var chunk2H5ICKFT_cjs = require('../chunk-2H5ICKFT.cjs');
4
+ var chunkBSGQGINR_cjs = require('../chunk-BSGQGINR.cjs');
5
+ require('../chunk-QK7HZIVY.cjs');
6
+
7
+ // src/steps/exif.ts
8
+ function exifStep() {
9
+ return {
10
+ name: "exif",
11
+ shouldProcess: (file) => file.type.startsWith("image/"),
12
+ async process(file, context) {
13
+ if (await chunk2H5ICKFT_cjs.isAnimatedImage(file)) return file;
14
+ if (context.worker) {
15
+ try {
16
+ const result = await context.worker.execute({
17
+ type: "exif",
18
+ data: await file.arrayBuffer(),
19
+ params: { mime: file.type, name: file.name }
20
+ });
21
+ if (result.kind === "image")
22
+ return chunkBSGQGINR_cjs.uploadFileFromImageResult(file, result);
23
+ } catch {
24
+ }
25
+ }
26
+ const processed = await chunkBSGQGINR_cjs.encodeImageFile(file, {
27
+ type: file.type || "image/jpeg",
28
+ quality: 0.92,
29
+ metadata: {
30
+ originalSize: file.size,
31
+ exifStripped: true
32
+ }
33
+ });
34
+ if (!processed) return file;
35
+ processed.metadata = {
36
+ ...processed.metadata,
37
+ processedSize: processed.size
38
+ };
39
+ return processed;
40
+ }
41
+ };
42
+ }
43
+
44
+ exports.exifStep = exifStep;
@@ -0,0 +1,5 @@
1
+ import { P as PipelineStep } from '../contracts-pipeline-cf177270.cjs';
2
+
3
+ declare function exifStep(): PipelineStep;
4
+
5
+ export { exifStep };
@@ -0,0 +1,5 @@
1
+ import { P as PipelineStep } from '../contracts-pipeline-cf177270.js';
2
+
3
+ declare function exifStep(): PipelineStep;
4
+
5
+ export { exifStep };
@@ -0,0 +1,42 @@
1
+ import { isAnimatedImage } from '../chunk-FMURBCZ7.js';
2
+ import { uploadFileFromImageResult, encodeImageFile } from '../chunk-6S5DQDQH.js';
3
+ import '../chunk-GE4LIVXP.js';
4
+
5
+ // src/steps/exif.ts
6
+ function exifStep() {
7
+ return {
8
+ name: "exif",
9
+ shouldProcess: (file) => file.type.startsWith("image/"),
10
+ async process(file, context) {
11
+ if (await isAnimatedImage(file)) return file;
12
+ if (context.worker) {
13
+ try {
14
+ const result = await context.worker.execute({
15
+ type: "exif",
16
+ data: await file.arrayBuffer(),
17
+ params: { mime: file.type, name: file.name }
18
+ });
19
+ if (result.kind === "image")
20
+ return uploadFileFromImageResult(file, result);
21
+ } catch {
22
+ }
23
+ }
24
+ const processed = await encodeImageFile(file, {
25
+ type: file.type || "image/jpeg",
26
+ quality: 0.92,
27
+ metadata: {
28
+ originalSize: file.size,
29
+ exifStripped: true
30
+ }
31
+ });
32
+ if (!processed) return file;
33
+ processed.metadata = {
34
+ ...processed.metadata,
35
+ processedSize: processed.size
36
+ };
37
+ return processed;
38
+ }
39
+ };
40
+ }
41
+
42
+ export { exifStep };
@@ -0,0 +1,44 @@
1
+ 'use strict';
2
+
3
+ // src/steps/hash.ts
4
+ async function computeSHA256(buffer) {
5
+ const hashBuffer = await crypto.subtle.digest("SHA-256", buffer);
6
+ const hashArray = Array.from(new Uint8Array(hashBuffer));
7
+ return hashArray.map((b) => b.toString(16).padStart(2, "0")).join("");
8
+ }
9
+ function hashStep() {
10
+ return {
11
+ name: "hash",
12
+ async process(file, context) {
13
+ if (context.worker) {
14
+ try {
15
+ const result = await context.worker.execute({
16
+ type: "hash",
17
+ data: await file.arrayBuffer()
18
+ });
19
+ if (result.kind === "hash") {
20
+ file.metadata = {
21
+ ...file.metadata,
22
+ checksum: result.checksum,
23
+ originalContentHash: result.checksum
24
+ };
25
+ return Object.assign(file, {
26
+ checksumSHA256: result.checksum
27
+ });
28
+ }
29
+ } catch {
30
+ }
31
+ }
32
+ const buffer = await file.arrayBuffer();
33
+ const hash = await computeSHA256(buffer);
34
+ file.metadata = {
35
+ ...file.metadata,
36
+ checksum: hash,
37
+ originalContentHash: hash
38
+ };
39
+ return Object.assign(file, { checksumSHA256: hash });
40
+ }
41
+ };
42
+ }
43
+
44
+ exports.hashStep = hashStep;
@@ -0,0 +1,5 @@
1
+ import { P as PipelineStep } from '../contracts-pipeline-cf177270.cjs';
2
+
3
+ declare function hashStep(): PipelineStep;
4
+
5
+ export { hashStep };
@@ -0,0 +1,5 @@
1
+ import { P as PipelineStep } from '../contracts-pipeline-cf177270.js';
2
+
3
+ declare function hashStep(): PipelineStep;
4
+
5
+ export { hashStep };