@emailmaker/filemanager 0.10.88 → 0.10.89

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.
@@ -1,2 +1,2 @@
1
- export{D as FileContent,J as FileManagerApiError,C as FileManagerApp,x as FileManagerAppWithContext,E as FileModals,G as FolderSidebar,P as PixieOnlyApp,B as default,v as init,A as initFileManager,y as initPixieEditor,H as installResizeObserverErrorHandler,K as mapHttpStatusToErrorCode,I as uninstallResizeObserverErrorHandler,w as unmount,z as unmountPixieEditor}from"./file-manager-index-DL8wzCQG.js";import"react/jsx-runtime";import"react";import"react-dom/client";import"antd";import"antd/es/alert/ErrorBoundary";import"@ant-design/icons";import"react-dom";
1
+ export{D as FileContent,J as FileManagerApiError,C as FileManagerApp,x as FileManagerAppWithContext,E as FileModals,G as FolderSidebar,P as PixieOnlyApp,B as default,L as fetchRemoteImageBlobByUrl,v as init,A as initFileManager,y as initPixieEditor,H as installResizeObserverErrorHandler,K as mapHttpStatusToErrorCode,I as uninstallResizeObserverErrorHandler,w as unmount,z as unmountPixieEditor}from"./file-manager-index-D14X20BS.js";import"react/jsx-runtime";import"react";import"react-dom/client";import"antd";import"antd/es/alert/ErrorBoundary";import"@ant-design/icons";import"react-dom";
2
2
  //# sourceMappingURL=file-manager.esm.js.map
package/file-manager.js CHANGED
@@ -27116,6 +27116,110 @@ if (true) {
27116
27116
  "use strict";
27117
27117
  module.exports = __WEBPACK_EXTERNAL_MODULE__5442__;
27118
27118
 
27119
+ /***/ }),
27120
+
27121
+ /***/ 5597:
27122
+ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
27123
+
27124
+ "use strict";
27125
+
27126
+ // EXPORTS
27127
+ __webpack_require__.d(__webpack_exports__, {
27128
+ n: () => (/* binding */ fetchRemoteImageBlobByUrl)
27129
+ });
27130
+
27131
+ // EXTERNAL MODULE: ./src/shared/fileManagerApiError.ts
27132
+ var fileManagerApiError = __webpack_require__(7036);
27133
+ ;// ./src/utils/directResourceFetchError.ts
27134
+ /**
27135
+ * Detects a final direct-fetch failure from the host resource proxy engine.
27136
+ * Uses error.name for cross-package compatibility (no instanceof across bundles).
27137
+ */
27138
+ function isFinalDirectResourceFetchError(error) {
27139
+ if (typeof error !== 'object' || error === null) {
27140
+ return false;
27141
+ }
27142
+ if ('name' in error && error.name === 'DirectResourceFetchError') {
27143
+ return !('final' in error) || error.final !== false;
27144
+ }
27145
+ return 'final' in error && error.final === true;
27146
+ }
27147
+
27148
+ ;// ./src/utils/remoteFileFetchPipeline.ts
27149
+
27150
+
27151
+ function rethrowNonRetryablePipelineError(error) {
27152
+ if (isFinalDirectResourceFetchError(error) || error instanceof fileManagerApiError/* FileManagerApiError */.m) {
27153
+ throw error;
27154
+ }
27155
+ }
27156
+ /**
27157
+ * ADR-aligned blob fetch ladder for upload-by-URL:
27158
+ * 1. handleFileProxy (plugin Blob)
27159
+ * 2. handleProxyUrl → fetch rewritten URL (outside engine)
27160
+ * 3. fetchWithProxy (host engine / policy v2)
27161
+ * 4. direct fetch — only without `fetchWithProxy` (engine already includes direct fallback in its chain)
27162
+ */
27163
+ async function fetchRemoteImageBlobByUrl(normalizedUrl, handlers, fetchBlobFromUrl, validateImageBlob, options) {
27164
+ const { fetchWithProxy, handleFileProxy, handleProxyUrl } = handlers;
27165
+ const fetchInit = Object.assign({ mode: 'cors' }, options === null || options === void 0 ? void 0 : options.fetchInit);
27166
+ let lastError;
27167
+ if (handleFileProxy) {
27168
+ try {
27169
+ const proxiedBlob = await Promise.resolve(handleFileProxy(normalizedUrl));
27170
+ if (proxiedBlob) {
27171
+ return validateImageBlob(proxiedBlob);
27172
+ }
27173
+ }
27174
+ catch (error) {
27175
+ rethrowNonRetryablePipelineError(error);
27176
+ lastError = error;
27177
+ console.warn('handleFileProxy failed, falling back to next strategy', error);
27178
+ }
27179
+ }
27180
+ if (handleProxyUrl) {
27181
+ try {
27182
+ const proxiedUrl = await Promise.resolve(handleProxyUrl(normalizedUrl));
27183
+ if (proxiedUrl && proxiedUrl !== normalizedUrl) {
27184
+ const proxiedBlob = await fetchBlobFromUrl(proxiedUrl);
27185
+ return validateImageBlob(proxiedBlob);
27186
+ }
27187
+ }
27188
+ catch (error) {
27189
+ rethrowNonRetryablePipelineError(error);
27190
+ lastError = error;
27191
+ console.warn('handleProxyUrl fetch failed, falling back to next strategy', error);
27192
+ }
27193
+ }
27194
+ if (fetchWithProxy) {
27195
+ try {
27196
+ const proxiedResponse = await Promise.resolve(fetchWithProxy(normalizedUrl, fetchInit, { intent: 'downloadBlob' }));
27197
+ if (!proxiedResponse.ok) {
27198
+ throw new Error(`HTTP ${proxiedResponse.status}`);
27199
+ }
27200
+ const proxiedBlob = await proxiedResponse.blob();
27201
+ return validateImageBlob(proxiedBlob);
27202
+ }
27203
+ catch (error) {
27204
+ rethrowNonRetryablePipelineError(error);
27205
+ lastError = error;
27206
+ console.warn('fetchWithProxy failed', error);
27207
+ }
27208
+ }
27209
+ if (!fetchWithProxy) {
27210
+ try {
27211
+ const directBlob = await fetchBlobFromUrl(normalizedUrl);
27212
+ return validateImageBlob(directBlob);
27213
+ }
27214
+ catch (error) {
27215
+ rethrowNonRetryablePipelineError(error);
27216
+ lastError = error;
27217
+ }
27218
+ }
27219
+ throw lastError instanceof Error ? lastError : new Error('Failed to download file from the URL');
27220
+ }
27221
+
27222
+
27119
27223
  /***/ }),
27120
27224
 
27121
27225
  /***/ 5748:
@@ -31094,6 +31198,8 @@ function isUrlSameOriginAsCurrentPage(url) {
31094
31198
  }
31095
31199
  }
31096
31200
 
31201
+ // EXTERNAL MODULE: ./src/utils/remoteFileFetchPipeline.ts + 1 modules
31202
+ var remoteFileFetchPipeline = __webpack_require__(5597);
31097
31203
  // EXTERNAL MODULE: ./src/utils/dedupeUploadNamesOnClient.ts
31098
31204
  var dedupeUploadNamesOnClient = __webpack_require__(3795);
31099
31205
  // EXTERNAL MODULE: ./src/utils/resolveUniqueUploadName.ts
@@ -31128,6 +31234,7 @@ var fileManagerApiError = __webpack_require__(7036);
31128
31234
 
31129
31235
 
31130
31236
 
31237
+
31131
31238
 
31132
31239
 
31133
31240
  /**
@@ -31439,66 +31546,21 @@ const useFilesAPI = () => {
31439
31546
  }
31440
31547
  let resolvedBlob;
31441
31548
  let resolvedMimeType;
31442
- let lastError;
31443
- const fetchWithProxy = (_a = options === null || options === void 0 ? void 0 : options.config) === null || _a === void 0 ? void 0 : _a.fetchWithProxy;
31444
- const handleFileProxy = (_b = options === null || options === void 0 ? void 0 : options.config) === null || _b === void 0 ? void 0 : _b.handleFileProxy;
31445
- const handleProxyUrl = (_c = options === null || options === void 0 ? void 0 : options.config) === null || _c === void 0 ? void 0 : _c.handleProxyUrl;
31446
- const skipProxy = isUrlSameOriginAsCurrentPage(normalizedUrl);
31447
- if (!skipProxy && fetchWithProxy) {
31448
- try {
31449
- const proxiedResponse = await Promise.resolve(fetchWithProxy(normalizedUrl, { mode: 'cors' }, { intent: 'downloadBlob' }));
31450
- if (!proxiedResponse.ok) {
31451
- throw new fileManagerApiError/* FileManagerApiError */.m(`HTTP ${proxiedResponse.status}`, 'UploadUrlDownloadFailed', proxiedResponse.status);
31452
- }
31453
- const proxiedBlob = await proxiedResponse.blob();
31454
- const validated = validateImageBlob(proxiedBlob, t);
31455
- resolvedBlob = validated.blob;
31456
- resolvedMimeType = validated.mimeType;
31457
- }
31458
- catch (error) {
31459
- lastError = error;
31460
- console.warn('fetchWithProxy failed or returned a non-image blob, falling back to next strategy', error);
31461
- }
31462
- }
31463
- if (!skipProxy && !resolvedBlob && handleFileProxy) {
31464
- try {
31465
- const proxiedBlob = await Promise.resolve(handleFileProxy(normalizedUrl));
31466
- const validated = validateImageBlob(proxiedBlob, t);
31467
- resolvedBlob = validated.blob;
31468
- resolvedMimeType = validated.mimeType;
31469
- }
31470
- catch (error) {
31471
- lastError = error;
31472
- console.warn('handleFileProxy failed or returned a non-image blob, falling back to next strategy', error);
31473
- }
31474
- }
31475
- if (!skipProxy && !resolvedBlob && handleProxyUrl) {
31476
- try {
31477
- const proxiedUrl = await Promise.resolve(handleProxyUrl(normalizedUrl));
31478
- const proxiedBlob = await fetchBlobFromUrl(proxiedUrl);
31479
- const validated = validateImageBlob(proxiedBlob, t);
31480
- resolvedBlob = validated.blob;
31481
- resolvedMimeType = validated.mimeType;
31482
- }
31483
- catch (error) {
31484
- lastError = error;
31485
- console.warn('handleProxyUrl fetch failed or returned a non-image blob, falling back to direct fetch', error);
31486
- }
31549
+ try {
31550
+ const validated = await (0,remoteFileFetchPipeline/* fetchRemoteImageBlobByUrl */.n)(normalizedUrl, {
31551
+ fetchWithProxy: (_a = options === null || options === void 0 ? void 0 : options.config) === null || _a === void 0 ? void 0 : _a.fetchWithProxy,
31552
+ handleFileProxy: (_b = options === null || options === void 0 ? void 0 : options.config) === null || _b === void 0 ? void 0 : _b.handleFileProxy,
31553
+ handleProxyUrl: (_c = options === null || options === void 0 ? void 0 : options.config) === null || _c === void 0 ? void 0 : _c.handleProxyUrl,
31554
+ }, fetchBlobFromUrl, (blob) => validateImageBlob(blob, t));
31555
+ resolvedBlob = validated.blob;
31556
+ resolvedMimeType = validated.mimeType;
31487
31557
  }
31488
- if (!resolvedBlob) {
31489
- try {
31490
- const directBlob = await fetchBlobFromUrl(normalizedUrl);
31491
- const validated = validateImageBlob(directBlob, t);
31492
- resolvedBlob = validated.blob;
31493
- resolvedMimeType = validated.mimeType;
31494
- }
31495
- catch (error) {
31496
- lastError = error;
31558
+ catch (error) {
31559
+ if (error instanceof fileManagerApiError/* FileManagerApiError */.m) {
31560
+ throw error;
31497
31561
  }
31498
- }
31499
- if (!resolvedBlob || !resolvedMimeType) {
31500
- throw lastError instanceof Error
31501
- ? lastError
31562
+ throw error instanceof Error
31563
+ ? error
31502
31564
  : new fileManagerApiError/* FileManagerApiError */.m(t('Failed to download file from the URL.'), 'UploadUrlDownloadFailed');
31503
31565
  }
31504
31566
  const extension = (0,mimeUtils/* getExtensionFromMime */.wh)(resolvedMimeType);
@@ -34842,7 +34904,7 @@ __webpack_require__.d(__webpack_exports__, {
34842
34904
  "default": () => (/* binding */ src)
34843
34905
  });
34844
34906
 
34845
- // UNUSED EXPORTS: FileContent, FileManagerApiError, FileManagerApp, FileManagerAppWithContext, FileModals, FolderSidebar, PixieOnlyApp, init, initFileManager, initPixieEditor, installResizeObserverErrorHandler, mapHttpStatusToErrorCode, uninstallResizeObserverErrorHandler, unmount, unmountPixieEditor
34907
+ // UNUSED EXPORTS: FileContent, FileManagerApiError, FileManagerApp, FileManagerAppWithContext, FileModals, FolderSidebar, PixieOnlyApp, fetchRemoteImageBlobByUrl, init, initFileManager, initPixieEditor, installResizeObserverErrorHandler, mapHttpStatusToErrorCode, uninstallResizeObserverErrorHandler, unmount, unmountPixieEditor
34846
34908
 
34847
34909
  // EXTERNAL MODULE: ./node_modules/react/jsx-runtime.js
34848
34910
  var jsx_runtime = __webpack_require__(4848);
@@ -91165,7 +91227,13 @@ const ImageGif = ({ setImageGifList, imageGifList = [], currentReqGif, setCurren
91165
91227
  }, []); // eslint-disable-line react-hooks/exhaustive-deps
91166
91228
  const handleProxyUrl = config === null || config === void 0 ? void 0 : config.handleProxyUrl;
91167
91229
  const fetchWithProxy = config === null || config === void 0 ? void 0 : config.fetchWithProxy;
91168
- const proxy = async (url) => (handleProxyUrl ? Promise.resolve(handleProxyUrl(url)) : url);
91230
+ const proxy = async (url) => {
91231
+ if (!handleProxyUrl) {
91232
+ return url;
91233
+ }
91234
+ const proxied = await Promise.resolve(handleProxyUrl(url));
91235
+ return proxied !== null && proxied !== void 0 ? proxied : url;
91236
+ };
91169
91237
  const fetchJson = (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useCallback)(async (url) => {
91170
91238
  if (fetchWithProxy) {
91171
91239
  return Promise.resolve(fetchWithProxy(url, undefined, { intent: 'metadata' }));
@@ -91481,7 +91549,13 @@ const ImageStock = ({ imageStockList, setImageStockList, currentReq, setCurrentR
91481
91549
  const searchSeqRef = (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useRef)(0);
91482
91550
  const nextPageRef = (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useRef)(1);
91483
91551
  const inFlightRequestKeysRef = (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useRef)(new Set());
91484
- const proxy = async (url) => (handleProxyUrl ? Promise.resolve(handleProxyUrl(url)) : url);
91552
+ const proxy = async (url) => {
91553
+ if (!handleProxyUrl) {
91554
+ return url;
91555
+ }
91556
+ const proxied = await Promise.resolve(handleProxyUrl(url));
91557
+ return proxied !== null && proxied !== void 0 ? proxied : url;
91558
+ };
91485
91559
  const fetchJson = (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useCallback)(async (url) => {
91486
91560
  if (fetchWithProxy) {
91487
91561
  return Promise.resolve(fetchWithProxy(url, undefined, { intent: 'metadata' }));
@@ -94499,6 +94573,8 @@ const initFileManager = (options) => {
94499
94573
 
94500
94574
  // EXTERNAL MODULE: ./src/shared/fileManagerApiError.ts
94501
94575
  var fileManagerApiError = __webpack_require__(7036);
94576
+ // EXTERNAL MODULE: ./src/utils/remoteFileFetchPipeline.ts + 1 modules
94577
+ var remoteFileFetchPipeline = __webpack_require__(5597);
94502
94578
  ;// ./src/index.ts
94503
94579
 
94504
94580
 
@@ -94511,6 +94587,7 @@ var fileManagerApiError = __webpack_require__(7036);
94511
94587
 
94512
94588
 
94513
94589
 
94590
+
94514
94591
  })();
94515
94592
 
94516
94593
  __webpack_exports__ = __webpack_exports__["default"];
package/index.d.ts CHANGED
@@ -20,4 +20,5 @@ export { installResizeObserverErrorHandler, uninstallResizeObserverErrorHandler
20
20
  export { type Folder, type File, type PathItem, type MenuItem, type FileManagerOptions, type FileManagerHookReturn, type FileManagerErrorCode, type IFileManagerApiError, type SortOptionType, type FileManagerItemMeta, } from './types';
21
21
  export { FileManagerApiError } from './shared/fileManagerApiError';
22
22
  export { mapHttpStatusToErrorCode } from './shared/mapHttpStatusToErrorCode';
23
+ export { fetchRemoteImageBlobByUrl, type FetchRemoteImageBlobOptions, type RemoteFileFetchHandlers, type RemoteFileFetchIntent, } from './utils/remoteFileFetchPipeline';
23
24
  export { type InitPixieEditorOptions, type Options as FileManagerInitOptions, type UniversalInitOptions, } from './file-manager';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@emailmaker/filemanager",
3
- "version": "0.10.88",
3
+ "version": "0.10.89",
4
4
  "main": "./file-manager.js",
5
5
  "module": "./file-manager.esm.js",
6
6
  "types": "./index.d.ts",
package/types.d.ts CHANGED
@@ -507,8 +507,11 @@ export interface Config {
507
507
  * Запрос уходит только для строк с кириллицей. При 404/ошибке сети поиск продолжается по исходной строке (локальный RU-словарь).
508
508
  */
509
509
  iconStockTranslateUrl?: string;
510
- /** Единый хендлер: принимает оригинальный URL, возвращает проксированный (sync или async). Используется для Unsplash, Giphy. */
511
- handleProxyUrl?: (url: string) => string | Promise<string>;
510
+ /**
511
+ * Plugin URL override (PROXY_URL). Возвращает переписанный URL или undefined — тогда
512
+ * upload/metadata идут через `fetchWithProxy` / `getProxiedUrl`, не через display-default proxy.
513
+ */
514
+ handleProxyUrl?: (url: string) => string | null | undefined | Promise<string | null | undefined>;
512
515
  /** Display-controller для `<img src>` через общий proxy runtime-state хоста. */
513
516
  getProxiedUrl?: (url: string) => {
514
517
  src: string;
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Detects a final direct-fetch failure from the host resource proxy engine.
3
+ * Uses error.name for cross-package compatibility (no instanceof across bundles).
4
+ */
5
+ export declare function isFinalDirectResourceFetchError(error: unknown): boolean;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,25 @@
1
+ export type RemoteFileFetchIntent = 'display' | 'downloadBlob' | 'metadata';
2
+ export type RemoteFileFetchHandlers = {
3
+ fetchWithProxy?: (url: string, init?: RequestInit, options?: {
4
+ intent?: RemoteFileFetchIntent;
5
+ }) => Response | Promise<Response>;
6
+ handleFileProxy?: (url: string) => Blob | Promise<Blob | null | undefined>;
7
+ handleProxyUrl?: (url: string) => string | null | undefined | Promise<string | null | undefined>;
8
+ };
9
+ export type FetchBlobFromUrl = (url: string) => Promise<Blob>;
10
+ export type ValidateImageBlobResult = {
11
+ blob: Blob;
12
+ mimeType: string;
13
+ };
14
+ export type ValidateImageBlob = (blob: Blob) => ValidateImageBlobResult;
15
+ export type FetchRemoteImageBlobOptions = {
16
+ fetchInit?: RequestInit;
17
+ };
18
+ /**
19
+ * ADR-aligned blob fetch ladder for upload-by-URL:
20
+ * 1. handleFileProxy (plugin Blob)
21
+ * 2. handleProxyUrl → fetch rewritten URL (outside engine)
22
+ * 3. fetchWithProxy (host engine / policy v2)
23
+ * 4. direct fetch — only without `fetchWithProxy` (engine already includes direct fallback in its chain)
24
+ */
25
+ export declare function fetchRemoteImageBlobByUrl(normalizedUrl: string, handlers: RemoteFileFetchHandlers, fetchBlobFromUrl: FetchBlobFromUrl, validateImageBlob: ValidateImageBlob, options?: FetchRemoteImageBlobOptions): Promise<ValidateImageBlobResult>;
@@ -0,0 +1 @@
1
+ export {};