@anvilkit/plugin-asset-manager 0.1.9 → 0.1.10

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 (235) hide show
  1. package/README.md +96 -3
  2. package/dist/adapters/data-url.d.cts +1 -0
  3. package/dist/adapters/data-url.d.cts.map +1 -1
  4. package/dist/adapters/data-url.d.ts +1 -0
  5. package/dist/adapters/data-url.d.ts.map +1 -1
  6. package/dist/adapters/s3-multipart.cjs +425 -0
  7. package/dist/adapters/s3-multipart.d.cts +43 -0
  8. package/dist/adapters/s3-multipart.d.cts.map +1 -0
  9. package/dist/adapters/s3-multipart.d.ts +43 -0
  10. package/dist/adapters/s3-multipart.d.ts.map +1 -0
  11. package/dist/adapters/s3-multipart.js +387 -0
  12. package/dist/adapters/s3-presigned.d.cts +2 -0
  13. package/dist/adapters/s3-presigned.d.cts.map +1 -1
  14. package/dist/adapters/s3-presigned.d.ts +2 -0
  15. package/dist/adapters/s3-presigned.d.ts.map +1 -1
  16. package/dist/i18n/provider.d.cts +1 -0
  17. package/dist/i18n/provider.d.cts.map +1 -1
  18. package/dist/i18n/provider.d.ts +1 -0
  19. package/dist/i18n/provider.d.ts.map +1 -1
  20. package/dist/index.cjs +14 -0
  21. package/dist/index.d.cts +9 -3
  22. package/dist/index.d.cts.map +1 -1
  23. package/dist/index.d.ts +9 -3
  24. package/dist/index.d.ts.map +1 -1
  25. package/dist/index.js +3 -1
  26. package/dist/plugin.cjs +152 -12
  27. package/dist/plugin.d.cts +49 -1
  28. package/dist/plugin.d.cts.map +1 -1
  29. package/dist/plugin.d.ts +49 -1
  30. package/dist/plugin.d.ts.map +1 -1
  31. package/dist/plugin.js +147 -13
  32. package/dist/sources/composite-source.cjs +3 -0
  33. package/dist/sources/composite-source.d.cts.map +1 -1
  34. package/dist/sources/composite-source.d.ts.map +1 -1
  35. package/dist/sources/composite-source.js +3 -0
  36. package/dist/sources/federated-search.cjs +45 -7
  37. package/dist/sources/federated-search.d.cts.map +1 -1
  38. package/dist/sources/federated-search.d.ts.map +1 -1
  39. package/dist/sources/federated-search.js +45 -7
  40. package/dist/sources/provider.d.cts +5 -0
  41. package/dist/sources/provider.d.cts.map +1 -1
  42. package/dist/sources/provider.d.ts +5 -0
  43. package/dist/sources/provider.d.ts.map +1 -1
  44. package/dist/sources/unsplash/index.d.cts +1 -0
  45. package/dist/sources/unsplash/index.d.cts.map +1 -1
  46. package/dist/sources/unsplash/index.d.ts +1 -0
  47. package/dist/sources/unsplash/index.d.ts.map +1 -1
  48. package/dist/testing/index.d.cts +4 -0
  49. package/dist/testing/index.d.cts.map +1 -1
  50. package/dist/testing/index.d.ts +4 -0
  51. package/dist/testing/index.d.ts.map +1 -1
  52. package/dist/types/categories.d.cts +3 -0
  53. package/dist/types/categories.d.cts.map +1 -1
  54. package/dist/types/categories.d.ts +3 -0
  55. package/dist/types/categories.d.ts.map +1 -1
  56. package/dist/types/data-source.d.cts +9 -0
  57. package/dist/types/data-source.d.cts.map +1 -1
  58. package/dist/types/data-source.d.ts +9 -0
  59. package/dist/types/data-source.d.ts.map +1 -1
  60. package/dist/types/filter.d.cts +11 -0
  61. package/dist/types/filter.d.cts.map +1 -1
  62. package/dist/types/filter.d.ts +11 -0
  63. package/dist/types/filter.d.ts.map +1 -1
  64. package/dist/types/folders.d.cts +2 -0
  65. package/dist/types/folders.d.cts.map +1 -1
  66. package/dist/types/folders.d.ts +2 -0
  67. package/dist/types/folders.d.ts.map +1 -1
  68. package/dist/types/options.d.cts +57 -1
  69. package/dist/types/options.d.cts.map +1 -1
  70. package/dist/types/options.d.ts +57 -1
  71. package/dist/types/options.d.ts.map +1 -1
  72. package/dist/types/resumable.cjs +42 -0
  73. package/dist/types/resumable.d.cts +204 -0
  74. package/dist/types/resumable.d.cts.map +1 -0
  75. package/dist/types/resumable.d.ts +204 -0
  76. package/dist/types/resumable.d.ts.map +1 -0
  77. package/dist/types/resumable.js +4 -0
  78. package/dist/types/transform.cjs +18 -0
  79. package/dist/types/transform.d.cts +45 -0
  80. package/dist/types/transform.d.cts.map +1 -0
  81. package/dist/types/transform.d.ts +45 -0
  82. package/dist/types/transform.d.ts.map +1 -0
  83. package/dist/types/transform.js +1 -0
  84. package/dist/types/types.d.cts +17 -0
  85. package/dist/types/types.d.cts.map +1 -1
  86. package/dist/types/types.d.ts +17 -0
  87. package/dist/types/types.d.ts.map +1 -1
  88. package/dist/types/unsplash.d.cts +2 -0
  89. package/dist/types/unsplash.d.cts.map +1 -1
  90. package/dist/types/unsplash.d.ts +2 -0
  91. package/dist/types/unsplash.d.ts.map +1 -1
  92. package/dist/ui/AssetBrowser.d.cts +3 -1
  93. package/dist/ui/AssetBrowser.d.cts.map +1 -1
  94. package/dist/ui/AssetBrowser.d.ts +3 -1
  95. package/dist/ui/AssetBrowser.d.ts.map +1 -1
  96. package/dist/ui/AssetCommandPalette.d.cts +4 -1
  97. package/dist/ui/AssetCommandPalette.d.cts.map +1 -1
  98. package/dist/ui/AssetCommandPalette.d.ts +4 -1
  99. package/dist/ui/AssetCommandPalette.d.ts.map +1 -1
  100. package/dist/ui/AssetManagerUI.cjs +3 -1
  101. package/dist/ui/AssetManagerUI.d.cts +11 -2
  102. package/dist/ui/AssetManagerUI.d.cts.map +1 -1
  103. package/dist/ui/AssetManagerUI.d.ts +11 -2
  104. package/dist/ui/AssetManagerUI.d.ts.map +1 -1
  105. package/dist/ui/AssetManagerUI.js +3 -1
  106. package/dist/ui/DeleteAssetDialog.d.cts +4 -1
  107. package/dist/ui/DeleteAssetDialog.d.cts.map +1 -1
  108. package/dist/ui/DeleteAssetDialog.d.ts +4 -1
  109. package/dist/ui/DeleteAssetDialog.d.ts.map +1 -1
  110. package/dist/ui/DeleteFolderDialog.d.cts +4 -1
  111. package/dist/ui/DeleteFolderDialog.d.cts.map +1 -1
  112. package/dist/ui/DeleteFolderDialog.d.ts +4 -1
  113. package/dist/ui/DeleteFolderDialog.d.ts.map +1 -1
  114. package/dist/ui/EmptyFolderState.d.cts +4 -1
  115. package/dist/ui/EmptyFolderState.d.cts.map +1 -1
  116. package/dist/ui/EmptyFolderState.d.ts +4 -1
  117. package/dist/ui/EmptyFolderState.d.ts.map +1 -1
  118. package/dist/ui/FolderBreadcrumb.d.cts +4 -1
  119. package/dist/ui/FolderBreadcrumb.d.cts.map +1 -1
  120. package/dist/ui/FolderBreadcrumb.d.ts +4 -1
  121. package/dist/ui/FolderBreadcrumb.d.ts.map +1 -1
  122. package/dist/ui/FolderNameDialog.d.cts +3 -1
  123. package/dist/ui/FolderNameDialog.d.cts.map +1 -1
  124. package/dist/ui/FolderNameDialog.d.ts +3 -1
  125. package/dist/ui/FolderNameDialog.d.ts.map +1 -1
  126. package/dist/ui/FolderTree.d.cts +4 -1
  127. package/dist/ui/FolderTree.d.cts.map +1 -1
  128. package/dist/ui/FolderTree.d.ts +4 -1
  129. package/dist/ui/FolderTree.d.ts.map +1 -1
  130. package/dist/ui/MetadataPanel.d.cts +4 -1
  131. package/dist/ui/MetadataPanel.d.cts.map +1 -1
  132. package/dist/ui/MetadataPanel.d.ts +4 -1
  133. package/dist/ui/MetadataPanel.d.ts.map +1 -1
  134. package/dist/ui/MoveTargetPicker.d.cts +3 -1
  135. package/dist/ui/MoveTargetPicker.d.cts.map +1 -1
  136. package/dist/ui/MoveTargetPicker.d.ts +3 -1
  137. package/dist/ui/MoveTargetPicker.d.ts.map +1 -1
  138. package/dist/ui/ReplaceAssetDialog.cjs +7 -2
  139. package/dist/ui/ReplaceAssetDialog.d.cts +5 -2
  140. package/dist/ui/ReplaceAssetDialog.d.cts.map +1 -1
  141. package/dist/ui/ReplaceAssetDialog.d.ts +5 -2
  142. package/dist/ui/ReplaceAssetDialog.d.ts.map +1 -1
  143. package/dist/ui/ReplaceAssetDialog.js +7 -2
  144. package/dist/ui/UnsplashPanel.d.cts +4 -1
  145. package/dist/ui/UnsplashPanel.d.cts.map +1 -1
  146. package/dist/ui/UnsplashPanel.d.ts +4 -1
  147. package/dist/ui/UnsplashPanel.d.ts.map +1 -1
  148. package/dist/ui/UploadButton.cjs +7 -2
  149. package/dist/ui/UploadButton.d.cts +6 -2
  150. package/dist/ui/UploadButton.d.cts.map +1 -1
  151. package/dist/ui/UploadButton.d.ts +6 -2
  152. package/dist/ui/UploadButton.d.ts.map +1 -1
  153. package/dist/ui/UploadButton.js +7 -2
  154. package/dist/utils/asset-reference.cjs +87 -4
  155. package/dist/utils/asset-reference.d.cts +30 -6
  156. package/dist/utils/asset-reference.d.cts.map +1 -1
  157. package/dist/utils/asset-reference.d.ts +30 -6
  158. package/dist/utils/asset-reference.d.ts.map +1 -1
  159. package/dist/utils/asset-reference.js +83 -3
  160. package/dist/utils/csp.cjs +16 -0
  161. package/dist/utils/csp.d.cts +23 -0
  162. package/dist/utils/csp.d.cts.map +1 -1
  163. package/dist/utils/csp.d.ts +23 -0
  164. package/dist/utils/csp.d.ts.map +1 -1
  165. package/dist/utils/csp.js +16 -0
  166. package/dist/utils/data-source.cjs +19 -5
  167. package/dist/utils/data-source.d.cts +5 -1
  168. package/dist/utils/data-source.d.cts.map +1 -1
  169. package/dist/utils/data-source.d.ts +5 -1
  170. package/dist/utils/data-source.d.ts.map +1 -1
  171. package/dist/utils/data-source.js +19 -5
  172. package/dist/utils/errors.d.cts +5 -0
  173. package/dist/utils/errors.d.cts.map +1 -1
  174. package/dist/utils/errors.d.ts +5 -0
  175. package/dist/utils/errors.d.ts.map +1 -1
  176. package/dist/utils/query-param-transform.cjs +101 -0
  177. package/dist/utils/query-param-transform.d.cts +46 -0
  178. package/dist/utils/query-param-transform.d.cts.map +1 -0
  179. package/dist/utils/query-param-transform.d.ts +46 -0
  180. package/dist/utils/query-param-transform.d.ts.map +1 -0
  181. package/dist/utils/query-param-transform.js +60 -0
  182. package/dist/utils/registry.cjs +3 -0
  183. package/dist/utils/registry.d.cts +8 -0
  184. package/dist/utils/registry.d.cts.map +1 -1
  185. package/dist/utils/registry.d.ts +8 -0
  186. package/dist/utils/registry.d.ts.map +1 -1
  187. package/dist/utils/registry.js +3 -0
  188. package/dist/utils/resolver.cjs +19 -11
  189. package/dist/utils/resolver.d.cts +24 -0
  190. package/dist/utils/resolver.d.cts.map +1 -1
  191. package/dist/utils/resolver.d.ts +24 -0
  192. package/dist/utils/resolver.d.ts.map +1 -1
  193. package/dist/utils/resolver.js +19 -11
  194. package/dist/utils/retry.d.cts +2 -0
  195. package/dist/utils/retry.d.cts.map +1 -1
  196. package/dist/utils/retry.d.ts +2 -0
  197. package/dist/utils/retry.d.ts.map +1 -1
  198. package/dist/utils/run-resumable-upload.cjs +160 -0
  199. package/dist/utils/run-resumable-upload.d.cts +56 -0
  200. package/dist/utils/run-resumable-upload.d.cts.map +1 -0
  201. package/dist/utils/run-resumable-upload.d.ts +56 -0
  202. package/dist/utils/run-resumable-upload.d.ts.map +1 -0
  203. package/dist/utils/run-resumable-upload.js +122 -0
  204. package/dist/utils/sniff-file-type.cjs +209 -0
  205. package/dist/utils/sniff-file-type.d.cts +25 -0
  206. package/dist/utils/sniff-file-type.d.cts.map +1 -0
  207. package/dist/utils/sniff-file-type.d.ts +25 -0
  208. package/dist/utils/sniff-file-type.d.ts.map +1 -0
  209. package/dist/utils/sniff-file-type.js +164 -0
  210. package/dist/utils/studio-asset-source.cjs +11 -6
  211. package/dist/utils/studio-asset-source.d.cts +5 -1
  212. package/dist/utils/studio-asset-source.d.cts.map +1 -1
  213. package/dist/utils/studio-asset-source.d.ts +5 -1
  214. package/dist/utils/studio-asset-source.d.ts.map +1 -1
  215. package/dist/utils/studio-asset-source.js +11 -6
  216. package/dist/utils/upload-session-store.cjs +125 -0
  217. package/dist/utils/upload-session-store.d.cts +55 -0
  218. package/dist/utils/upload-session-store.d.cts.map +1 -0
  219. package/dist/utils/upload-session-store.d.ts +55 -0
  220. package/dist/utils/upload-session-store.d.ts.map +1 -0
  221. package/dist/utils/upload-session-store.js +84 -0
  222. package/dist/utils/validate-upload-result.cjs +9 -1
  223. package/dist/utils/validate-upload-result.d.cts +1 -0
  224. package/dist/utils/validate-upload-result.d.cts.map +1 -1
  225. package/dist/utils/validate-upload-result.d.ts +1 -0
  226. package/dist/utils/validate-upload-result.d.ts.map +1 -1
  227. package/dist/utils/validate-upload-result.js +9 -1
  228. package/dist/version.cjs +1 -1
  229. package/dist/version.d.cts +1 -1
  230. package/dist/version.d.cts.map +1 -1
  231. package/dist/version.d.ts +1 -1
  232. package/dist/version.d.ts.map +1 -1
  233. package/dist/version.js +1 -1
  234. package/meta/config.json +1 -1
  235. package/package.json +40 -10
@@ -0,0 +1,43 @@
1
+ /**
2
+ * @file S3 multipart resumable adapter (PRD 0004 §5.1 — M4).
3
+ *
4
+ * A {@link ResumableUploadAdapter} that fronts an S3-compatible multipart
5
+ * upload WITHOUT bundling the AWS SDK — exactly like {@link s3PresignedAdapter}
6
+ * fronts a single presigned PUT. All S3 calls are brokered through one host
7
+ * `endpoint` that the adapter POSTs JSON to, discriminated by `action`:
8
+ *
9
+ * - `create` → host runs `CreateMultipartUpload`, returns `{ uploadId, key?, partSize? }`
10
+ * - `sign-part` → host presigns one `UploadPart` PUT, returns `{ url, headers? }`
11
+ * - `complete` → host runs `CompleteMultipartUpload`, returns `{ url, publicUrl?, id? }`
12
+ * - `abort` → host runs `AbortMultipartUpload`
13
+ * - `list-parts` → host runs `ListParts` for resume, returns `{ parts, key? }` (404 ⇒ gone)
14
+ *
15
+ * Retry split: `begin` / `complete` / `abort` retry internally via `withRetry`
16
+ * (the runner does not retry them). `uploadPart` does NOT retry internally — the
17
+ * runner's per-part `withRetry` re-invokes it, which RE-SIGNS the part URL each
18
+ * attempt (presigned URLs expire), so a fresh URL is used on every retry.
19
+ *
20
+ * @experimental Public surface may change before v1.0.
21
+ */
22
+ import type { ResumableUploadAdapter } from "../types/resumable.js";
23
+ import { type RetryOptions } from "../utils/retry.js";
24
+ /** Configuration for {@link s3MultipartAdapter}. */
25
+ export interface S3MultipartAdapterOptions {
26
+ /** Endpoint that brokers the S3 multipart actions (see file header). */
27
+ readonly endpoint: string | URL;
28
+ /** Injectable `fetch`. Defaults to `globalThis.fetch`. */
29
+ readonly fetch?: typeof globalThis.fetch;
30
+ /** Bytes per part. Clamped to S3's 5 MiB minimum. Defaults to 8 MiB. */
31
+ readonly partSize?: number;
32
+ /** Forwarded to `withRetry()` for `begin` / `complete` / `abort`. */
33
+ readonly retry?: RetryOptions;
34
+ /** Construction-time signal, combined with each call's signal. */
35
+ readonly signal?: AbortSignal;
36
+ /** Extra headers applied to every broker POST (e.g. auth). */
37
+ readonly headers?: Record<string, string>;
38
+ /** Override the fallback asset id generator. Default: `crypto.randomUUID()`. */
39
+ readonly idGenerator?: () => string;
40
+ }
41
+ /** Create a resumable adapter backed by an S3 multipart broker endpoint. */
42
+ export declare function s3MultipartAdapter(options: S3MultipartAdapterOptions): ResumableUploadAdapter;
43
+ //# sourceMappingURL=s3-multipart.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"s3-multipart.d.cts","sourceRoot":"","sources":["../../src/adapters/s3-multipart.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,OAAO,KAAK,EAEX,sBAAsB,EAGtB,MAAM,uBAAuB,CAAC;AAG/B,OAAO,EAEN,KAAK,YAAY,EAEjB,MAAM,mBAAmB,CAAC;AAM3B,oDAAoD;AACpD,MAAM,WAAW,yBAAyB;IACzC,wEAAwE;IACxE,QAAQ,CAAC,QAAQ,EAAE,MAAM,GAAG,GAAG,CAAC;IAChC,0DAA0D;IAC1D,QAAQ,CAAC,KAAK,CAAC,EAAE,OAAO,UAAU,CAAC,KAAK,CAAC;IACzC,wEAAwE;IACxE,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAC3B,qEAAqE;IACrE,QAAQ,CAAC,KAAK,CAAC,EAAE,YAAY,CAAC;IAC9B,kEAAkE;IAClE,QAAQ,CAAC,MAAM,CAAC,EAAE,WAAW,CAAC;IAC9B,8DAA8D;IAC9D,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC1C,gFAAgF;IAChF,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,MAAM,CAAC;CACpC;AAqBD,4EAA4E;AAC5E,wBAAgB,kBAAkB,CACjC,OAAO,EAAE,yBAAyB,GAChC,sBAAsB,CA2JxB"}
@@ -0,0 +1,43 @@
1
+ /**
2
+ * @file S3 multipart resumable adapter (PRD 0004 §5.1 — M4).
3
+ *
4
+ * A {@link ResumableUploadAdapter} that fronts an S3-compatible multipart
5
+ * upload WITHOUT bundling the AWS SDK — exactly like {@link s3PresignedAdapter}
6
+ * fronts a single presigned PUT. All S3 calls are brokered through one host
7
+ * `endpoint` that the adapter POSTs JSON to, discriminated by `action`:
8
+ *
9
+ * - `create` → host runs `CreateMultipartUpload`, returns `{ uploadId, key?, partSize? }`
10
+ * - `sign-part` → host presigns one `UploadPart` PUT, returns `{ url, headers? }`
11
+ * - `complete` → host runs `CompleteMultipartUpload`, returns `{ url, publicUrl?, id? }`
12
+ * - `abort` → host runs `AbortMultipartUpload`
13
+ * - `list-parts` → host runs `ListParts` for resume, returns `{ parts, key? }` (404 ⇒ gone)
14
+ *
15
+ * Retry split: `begin` / `complete` / `abort` retry internally via `withRetry`
16
+ * (the runner does not retry them). `uploadPart` does NOT retry internally — the
17
+ * runner's per-part `withRetry` re-invokes it, which RE-SIGNS the part URL each
18
+ * attempt (presigned URLs expire), so a fresh URL is used on every retry.
19
+ *
20
+ * @experimental Public surface may change before v1.0.
21
+ */
22
+ import type { ResumableUploadAdapter } from "../types/resumable.js";
23
+ import { type RetryOptions } from "../utils/retry.js";
24
+ /** Configuration for {@link s3MultipartAdapter}. */
25
+ export interface S3MultipartAdapterOptions {
26
+ /** Endpoint that brokers the S3 multipart actions (see file header). */
27
+ readonly endpoint: string | URL;
28
+ /** Injectable `fetch`. Defaults to `globalThis.fetch`. */
29
+ readonly fetch?: typeof globalThis.fetch;
30
+ /** Bytes per part. Clamped to S3's 5 MiB minimum. Defaults to 8 MiB. */
31
+ readonly partSize?: number;
32
+ /** Forwarded to `withRetry()` for `begin` / `complete` / `abort`. */
33
+ readonly retry?: RetryOptions;
34
+ /** Construction-time signal, combined with each call's signal. */
35
+ readonly signal?: AbortSignal;
36
+ /** Extra headers applied to every broker POST (e.g. auth). */
37
+ readonly headers?: Record<string, string>;
38
+ /** Override the fallback asset id generator. Default: `crypto.randomUUID()`. */
39
+ readonly idGenerator?: () => string;
40
+ }
41
+ /** Create a resumable adapter backed by an S3 multipart broker endpoint. */
42
+ export declare function s3MultipartAdapter(options: S3MultipartAdapterOptions): ResumableUploadAdapter;
43
+ //# sourceMappingURL=s3-multipart.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"s3-multipart.d.ts","sourceRoot":"","sources":["../../src/adapters/s3-multipart.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,OAAO,KAAK,EAEX,sBAAsB,EAGtB,MAAM,uBAAuB,CAAC;AAG/B,OAAO,EAEN,KAAK,YAAY,EAEjB,MAAM,mBAAmB,CAAC;AAM3B,oDAAoD;AACpD,MAAM,WAAW,yBAAyB;IACzC,wEAAwE;IACxE,QAAQ,CAAC,QAAQ,EAAE,MAAM,GAAG,GAAG,CAAC;IAChC,0DAA0D;IAC1D,QAAQ,CAAC,KAAK,CAAC,EAAE,OAAO,UAAU,CAAC,KAAK,CAAC;IACzC,wEAAwE;IACxE,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAC3B,qEAAqE;IACrE,QAAQ,CAAC,KAAK,CAAC,EAAE,YAAY,CAAC;IAC9B,kEAAkE;IAClE,QAAQ,CAAC,MAAM,CAAC,EAAE,WAAW,CAAC;IAC9B,8DAA8D;IAC9D,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC1C,gFAAgF;IAChF,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,MAAM,CAAC;CACpC;AAqBD,4EAA4E;AAC5E,wBAAgB,kBAAkB,CACjC,OAAO,EAAE,yBAAyB,GAChC,sBAAsB,CA2JxB"}
@@ -0,0 +1,387 @@
1
+ import { AssetValidationError } from "../utils/errors.js";
2
+ import { RetryableError, withRetry } from "../utils/retry.js";
3
+ const DEFAULT_PART_SIZE = 8388608;
4
+ const S3_MIN_PART_SIZE = 5242880;
5
+ function s3MultipartAdapter(options) {
6
+ const fetchImpl = options.fetch ?? globalThis.fetch;
7
+ if ("function" != typeof fetchImpl) throw new Error("s3MultipartAdapter: no `fetch` implementation available. Pass `options.fetch`.");
8
+ const generateId = options.idGenerator ?? defaultIdGenerator;
9
+ const partSize = Math.max(options.partSize ?? DEFAULT_PART_SIZE, S3_MIN_PART_SIZE);
10
+ const endpoint = "string" == typeof options.endpoint ? options.endpoint : options.endpoint.toString();
11
+ const retry = options.retry ?? {};
12
+ const keyOf = (session)=>"string" == typeof session.meta?.key ? session.meta.key : void 0;
13
+ return {
14
+ async begin (file, resume, callOptions) {
15
+ const { signal, dispose } = combineSignals(options.signal, callOptions?.signal);
16
+ try {
17
+ if (resume) {
18
+ const resumeKey = "string" == typeof resume.meta?.key ? resume.meta.key : void 0;
19
+ const listed = await withRetry(()=>listParts(endpoint, fetchImpl, options.headers, resume.uploadId, resumeKey, signal), {
20
+ ...retry,
21
+ ...signal ? {
22
+ signal
23
+ } : {}
24
+ });
25
+ if (void 0 !== listed) {
26
+ const key = resumeKey ?? listed.key;
27
+ return {
28
+ uploadId: resume.uploadId,
29
+ parts: listed.parts,
30
+ partSize: resume.partSize,
31
+ meta: buildMeta(key, resume.meta)
32
+ };
33
+ }
34
+ }
35
+ const created = await withRetry(()=>createSession(endpoint, fetchImpl, options.headers, file, partSize, signal), {
36
+ ...retry,
37
+ ...signal ? {
38
+ signal
39
+ } : {}
40
+ });
41
+ return {
42
+ uploadId: created.uploadId,
43
+ parts: [],
44
+ partSize: clampPartSize(created.partSize) ?? partSize,
45
+ meta: buildMeta(created.key, fileMeta(file))
46
+ };
47
+ } finally{
48
+ dispose();
49
+ }
50
+ },
51
+ async uploadPart (session, part, callOptions) {
52
+ const { signal, dispose } = combineSignals(options.signal, callOptions?.signal);
53
+ try {
54
+ const signed = await signPart(endpoint, fetchImpl, options.headers, session.uploadId, keyOf(session), part.partNumber, signal);
55
+ const etag = await putPart(fetchImpl, signed, part, signal);
56
+ return {
57
+ partNumber: part.partNumber,
58
+ etag
59
+ };
60
+ } finally{
61
+ dispose();
62
+ }
63
+ },
64
+ async complete (session, parts, callOptions) {
65
+ const { signal, dispose } = combineSignals(options.signal, callOptions?.signal);
66
+ try {
67
+ const completed = await withRetry(()=>completeSession(endpoint, fetchImpl, options.headers, session.uploadId, keyOf(session), parts, signal), {
68
+ ...retry,
69
+ ...signal ? {
70
+ signal
71
+ } : {}
72
+ });
73
+ const id = completed.id ?? generateId();
74
+ const url = completed.publicUrl ?? stripQueryAndFragment(completed.url);
75
+ return buildResult(id, url, session.meta);
76
+ } finally{
77
+ dispose();
78
+ }
79
+ },
80
+ async abort (session, callOptions) {
81
+ const { signal, dispose } = combineSignals(options.signal, callOptions?.signal);
82
+ try {
83
+ await withRetry(()=>abortSession(endpoint, fetchImpl, options.headers, session.uploadId, keyOf(session), signal), {
84
+ ...retry,
85
+ ...signal ? {
86
+ signal
87
+ } : {}
88
+ });
89
+ } finally{
90
+ dispose();
91
+ }
92
+ }
93
+ };
94
+ }
95
+ async function createSession(endpoint, fetchImpl, headers, file, partSize, signal) {
96
+ const payload = await postAction(endpoint, fetchImpl, headers, {
97
+ action: "create",
98
+ name: file.name,
99
+ type: file.type,
100
+ size: file.size,
101
+ partSize
102
+ }, signal);
103
+ if (!isObject(payload) || "string" != typeof payload.uploadId || "" === payload.uploadId) throw new AssetValidationError("UPLOAD_FAILED", "s3MultipartAdapter: create response missing `uploadId`.");
104
+ if (!isOptionalString(payload.key)) throw badShape("create", "`key` must be a string");
105
+ if (void 0 !== payload.partSize && !isPositiveSafeInteger(payload.partSize)) throw badShape("create", "`partSize` must be a positive integer");
106
+ return {
107
+ uploadId: payload.uploadId,
108
+ ...void 0 !== payload.key ? {
109
+ key: payload.key
110
+ } : {},
111
+ ...void 0 !== payload.partSize ? {
112
+ partSize: payload.partSize
113
+ } : {}
114
+ };
115
+ }
116
+ async function signPart(endpoint, fetchImpl, headers, uploadId, key, partNumber, signal) {
117
+ const payload = await postAction(endpoint, fetchImpl, headers, {
118
+ action: "sign-part",
119
+ uploadId,
120
+ key,
121
+ partNumber
122
+ }, signal);
123
+ if (!isObject(payload) || "string" != typeof payload.url || "" === payload.url) throw new AssetValidationError("UPLOAD_FAILED", "s3MultipartAdapter: sign-part response missing `url`.");
124
+ if (void 0 !== payload.headers && !isStringRecord(payload.headers)) throw badShape("sign-part", "`headers` must be a string map");
125
+ return {
126
+ url: payload.url,
127
+ ...void 0 !== payload.headers ? {
128
+ headers: payload.headers
129
+ } : {}
130
+ };
131
+ }
132
+ async function completeSession(endpoint, fetchImpl, headers, uploadId, key, parts, signal) {
133
+ const payload = await postAction(endpoint, fetchImpl, headers, {
134
+ action: "complete",
135
+ uploadId,
136
+ key,
137
+ parts
138
+ }, signal);
139
+ if (!isObject(payload) || "string" != typeof payload.url || "" === payload.url) throw new AssetValidationError("UPLOAD_FAILED", "s3MultipartAdapter: complete response missing `url`.");
140
+ if (!isOptionalString(payload.publicUrl)) throw badShape("complete", "`publicUrl` must be a string");
141
+ if (!isOptionalString(payload.id)) throw badShape("complete", "`id` must be a string");
142
+ return {
143
+ url: payload.url,
144
+ ...void 0 !== payload.publicUrl ? {
145
+ publicUrl: payload.publicUrl
146
+ } : {},
147
+ ...void 0 !== payload.id ? {
148
+ id: payload.id
149
+ } : {}
150
+ };
151
+ }
152
+ function abortSession(endpoint, fetchImpl, headers, uploadId, key, signal) {
153
+ return postAction(endpoint, fetchImpl, headers, {
154
+ action: "abort",
155
+ uploadId,
156
+ key
157
+ }, signal);
158
+ }
159
+ async function listParts(endpoint, fetchImpl, headers, uploadId, key, signal) {
160
+ let response;
161
+ try {
162
+ response = await fetchImpl(endpoint, {
163
+ method: "POST",
164
+ headers: {
165
+ "Content-Type": "application/json",
166
+ ...headers ?? {}
167
+ },
168
+ body: JSON.stringify({
169
+ action: "list-parts",
170
+ uploadId,
171
+ key
172
+ }),
173
+ ...signal ? {
174
+ signal
175
+ } : {}
176
+ });
177
+ } catch (cause) {
178
+ throw new RetryableError(`s3MultipartAdapter: list-parts request failed (${describeError(cause)}).`, {
179
+ cause
180
+ });
181
+ }
182
+ if (404 === response.status) return;
183
+ if (response.status >= 500) throw new RetryableError(`s3MultipartAdapter: list-parts returned ${response.status}.`, {
184
+ retryAfterMs: parseRetryAfter(response.headers.get("retry-after"))
185
+ });
186
+ if (!response.ok) throw new AssetValidationError("UPLOAD_FAILED", `s3MultipartAdapter: list-parts returned ${response.status}.`);
187
+ const payload = await parseJson(response, "list-parts");
188
+ if (!isObject(payload) || !isPartTagArray(payload.parts)) throw new AssetValidationError("UPLOAD_FAILED", "s3MultipartAdapter: list-parts response has a missing or malformed `parts` array.");
189
+ if (!isOptionalString(payload.key)) throw badShape("list-parts", "`key` must be a string");
190
+ return {
191
+ parts: payload.parts,
192
+ ...void 0 !== payload.key ? {
193
+ key: payload.key
194
+ } : {}
195
+ };
196
+ }
197
+ async function putPart(fetchImpl, signed, part, signal) {
198
+ let response;
199
+ try {
200
+ response = await fetchImpl(signed.url, {
201
+ method: "PUT",
202
+ body: part.blob,
203
+ ...signed.headers ? {
204
+ headers: signed.headers
205
+ } : {},
206
+ ...signal ? {
207
+ signal
208
+ } : {}
209
+ });
210
+ } catch (cause) {
211
+ throw new RetryableError(`s3MultipartAdapter: part ${part.partNumber} PUT failed (${describeError(cause)}).`, {
212
+ cause
213
+ });
214
+ }
215
+ if (response.status >= 500) throw new RetryableError(`s3MultipartAdapter: part ${part.partNumber} PUT returned ${response.status}.`, {
216
+ retryAfterMs: parseRetryAfter(response.headers.get("retry-after"))
217
+ });
218
+ if (!response.ok) throw new AssetValidationError("UPLOAD_FAILED", `s3MultipartAdapter: part ${part.partNumber} PUT returned ${response.status}.`);
219
+ const etag = response.headers.get("etag");
220
+ if (null === etag || "" === etag) throw new AssetValidationError("UPLOAD_FAILED", `s3MultipartAdapter: part ${part.partNumber} PUT returned no ETag header. Expose it via S3 CORS \`ExposeHeaders: ["ETag"]\`.`);
221
+ return etag;
222
+ }
223
+ async function postAction(endpoint, fetchImpl, headers, body, signal) {
224
+ let response;
225
+ try {
226
+ response = await fetchImpl(endpoint, {
227
+ method: "POST",
228
+ headers: {
229
+ "Content-Type": "application/json",
230
+ ...headers ?? {}
231
+ },
232
+ body: JSON.stringify(body),
233
+ ...signal ? {
234
+ signal
235
+ } : {}
236
+ });
237
+ } catch (cause) {
238
+ throw new RetryableError(`s3MultipartAdapter: ${String(body.action)} request failed (${describeError(cause)}).`, {
239
+ cause
240
+ });
241
+ }
242
+ if (response.status >= 500) throw new RetryableError(`s3MultipartAdapter: ${String(body.action)} returned ${response.status}.`, {
243
+ retryAfterMs: parseRetryAfter(response.headers.get("retry-after"))
244
+ });
245
+ if (!response.ok) throw new AssetValidationError("UPLOAD_FAILED", `s3MultipartAdapter: ${String(body.action)} returned ${response.status}.`);
246
+ if ("abort" === body.action) return;
247
+ return parseJson(response, String(body.action));
248
+ }
249
+ async function parseJson(response, action) {
250
+ try {
251
+ return await response.json();
252
+ } catch (cause) {
253
+ throw new AssetValidationError("UPLOAD_FAILED", `s3MultipartAdapter: ${action} response was not JSON.`, {
254
+ cause
255
+ });
256
+ }
257
+ }
258
+ function fileMeta(file) {
259
+ return {
260
+ name: file.name,
261
+ size: file.size,
262
+ ...file.type ? {
263
+ type: file.type
264
+ } : {}
265
+ };
266
+ }
267
+ function buildMeta(key, base) {
268
+ return Object.freeze({
269
+ ...base ?? {},
270
+ ...void 0 !== key ? {
271
+ key
272
+ } : {}
273
+ });
274
+ }
275
+ function buildResult(id, url, meta) {
276
+ const name = "string" == typeof meta?.name ? meta.name : void 0;
277
+ const size = "number" == typeof meta?.size ? meta.size : void 0;
278
+ const type = "string" == typeof meta?.type ? meta.type : void 0;
279
+ const resultMeta = void 0 !== size || void 0 !== type ? {
280
+ ...void 0 !== size ? {
281
+ size
282
+ } : {},
283
+ ...void 0 !== type ? {
284
+ mimeType: type
285
+ } : {}
286
+ } : void 0;
287
+ return {
288
+ id,
289
+ url,
290
+ ...name ? {
291
+ name
292
+ } : {},
293
+ ...resultMeta ? {
294
+ meta: resultMeta
295
+ } : {}
296
+ };
297
+ }
298
+ function clampPartSize(value) {
299
+ if ("number" != typeof value || !Number.isSafeInteger(value) || value <= 0) return;
300
+ return Math.max(value, S3_MIN_PART_SIZE);
301
+ }
302
+ function isObject(value) {
303
+ return null !== value && "object" == typeof value && !Array.isArray(value);
304
+ }
305
+ function isOptionalString(value) {
306
+ return void 0 === value || "string" == typeof value;
307
+ }
308
+ function isPositiveSafeInteger(value) {
309
+ return "number" == typeof value && Number.isSafeInteger(value) && value > 0;
310
+ }
311
+ function isStringRecord(value) {
312
+ return isObject(value) && Object.values(value).every((v)=>"string" == typeof v);
313
+ }
314
+ function isPartTagArray(value) {
315
+ return Array.isArray(value) && value.every((p)=>isObject(p) && "number" == typeof p.partNumber && Number.isInteger(p.partNumber) && p.partNumber >= 1 && "string" == typeof p.etag);
316
+ }
317
+ function badShape(action, detail) {
318
+ return new AssetValidationError("UPLOAD_FAILED", `s3MultipartAdapter: ${action} response has an invalid shape — ${detail}.`);
319
+ }
320
+ function stripQueryAndFragment(url) {
321
+ const cuts = [
322
+ url.indexOf("?"),
323
+ url.indexOf("#")
324
+ ].filter((i)=>-1 !== i);
325
+ return 0 === cuts.length ? url : url.slice(0, Math.min(...cuts));
326
+ }
327
+ function parseRetryAfter(header) {
328
+ if (null === header) return;
329
+ const seconds = Number(header);
330
+ if (Number.isFinite(seconds) && seconds >= 0) return 1000 * seconds;
331
+ const date = Date.parse(header);
332
+ if (!Number.isNaN(date)) return Math.max(0, date - Date.now());
333
+ }
334
+ function describeError(error) {
335
+ if (error instanceof Error) return error.message || error.name;
336
+ return String(error);
337
+ }
338
+ function defaultIdGenerator() {
339
+ if (void 0 !== globalThis.crypto && "function" == typeof globalThis.crypto.randomUUID) return globalThis.crypto.randomUUID();
340
+ return `asset-${Math.random().toString(36).slice(2)}-${Date.now()}`;
341
+ }
342
+ const NOOP_DISPOSE = ()=>void 0;
343
+ function combineSignals(a, b) {
344
+ if (!a) return {
345
+ signal: b,
346
+ dispose: NOOP_DISPOSE
347
+ };
348
+ if (!b) return {
349
+ signal: a,
350
+ dispose: NOOP_DISPOSE
351
+ };
352
+ if (a === b) return {
353
+ signal: a,
354
+ dispose: NOOP_DISPOSE
355
+ };
356
+ const anyImpl = AbortSignal.any;
357
+ if ("function" == typeof anyImpl) return {
358
+ signal: anyImpl([
359
+ a,
360
+ b
361
+ ]),
362
+ dispose: NOOP_DISPOSE
363
+ };
364
+ const controller = new AbortController();
365
+ const onAbortA = ()=>{
366
+ if (!controller.signal.aborted) controller.abort(a.reason);
367
+ };
368
+ const onAbortB = ()=>{
369
+ if (!controller.signal.aborted) controller.abort(b.reason);
370
+ };
371
+ if (a.aborted) onAbortA();
372
+ else a.addEventListener("abort", onAbortA, {
373
+ once: true
374
+ });
375
+ if (b.aborted) onAbortB();
376
+ else b.addEventListener("abort", onAbortB, {
377
+ once: true
378
+ });
379
+ return {
380
+ signal: controller.signal,
381
+ dispose: ()=>{
382
+ a.removeEventListener("abort", onAbortA);
383
+ b.removeEventListener("abort", onAbortB);
384
+ }
385
+ };
386
+ }
387
+ export { s3MultipartAdapter };
@@ -22,6 +22,7 @@ import { type RetryOptions } from "../utils/retry.js";
22
22
  export type { RetryOptions } from "../utils/retry.js";
23
23
  /** @deprecated Import from `@anvilkit/plugin-asset-manager/retry` instead. */
24
24
  export { RetryableError } from "../utils/retry.js";
25
+ /** Configuration for uploads through a host-provided S3 presign endpoint. */
25
26
  export interface S3PresignedAdapterOptions {
26
27
  /** Endpoint that returns a presigned PUT target for the file. */
27
28
  readonly presignEndpoint: string | URL;
@@ -56,5 +57,6 @@ export interface S3PresignResponse {
56
57
  /** Optional asset id; falls back to `idGenerator()`. */
57
58
  readonly id?: string;
58
59
  }
60
+ /** Create an upload adapter backed by a host presign endpoint and S3 PUT. */
59
61
  export declare function s3PresignedAdapter(options: S3PresignedAdapterOptions): UploadAdapter;
60
62
  //# sourceMappingURL=s3-presigned.d.cts.map
@@ -1 +1 @@
1
- {"version":3,"file":"s3-presigned.d.cts","sourceRoot":"","sources":["../../src/adapters/s3-presigned.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAgB,MAAM,mBAAmB,CAAC;AAErE,OAAO,EAEN,KAAK,YAAY,EAEjB,MAAM,mBAAmB,CAAC;AAE3B,YAAY,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAMtD,8EAA8E;AAC9E,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAEnD,MAAM,WAAW,yBAAyB;IACzC,iEAAiE;IACjE,QAAQ,CAAC,eAAe,EAAE,MAAM,GAAG,GAAG,CAAC;IACvC;;;;OAIG;IACH,QAAQ,CAAC,KAAK,CAAC,EAAE,OAAO,UAAU,CAAC,KAAK,CAAC;IACzC,yEAAyE;IACzE,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IACzB,kDAAkD;IAClD,QAAQ,CAAC,KAAK,CAAC,EAAE,YAAY,CAAC;IAC9B,iEAAiE;IACjE,QAAQ,CAAC,MAAM,CAAC,EAAE,WAAW,CAAC;IAC9B,6DAA6D;IAC7D,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC1C,uEAAuE;IACvE,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,MAAM,CAAC;CACpC;AAED;;;GAGG;AACH,MAAM,WAAW,iBAAiB;IACjC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AAC,EAAE,MAAM,MAAM,CAAC;CACpC;AAED;;;GAGG;AACH,MAAM,WAAW,iBAAiB;IACjC,yBAAyB;IACzB,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,yEAAyE;IACzE,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;IAC5B,+DAA+D;IAC/D,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC1C,wDAAwD;IACxD,QAAQ,CAAC,EAAE,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,6EAA6E;AAC7E,wBAAgB,kBAAkB,CACjC,OAAO,EAAE,yBAAyB,GAChC,aAAa,CA+Cf"}
@@ -22,6 +22,7 @@ import { type RetryOptions } from "../utils/retry.js";
22
22
  export type { RetryOptions } from "../utils/retry.js";
23
23
  /** @deprecated Import from `@anvilkit/plugin-asset-manager/retry` instead. */
24
24
  export { RetryableError } from "../utils/retry.js";
25
+ /** Configuration for uploads through a host-provided S3 presign endpoint. */
25
26
  export interface S3PresignedAdapterOptions {
26
27
  /** Endpoint that returns a presigned PUT target for the file. */
27
28
  readonly presignEndpoint: string | URL;
@@ -56,5 +57,6 @@ export interface S3PresignResponse {
56
57
  /** Optional asset id; falls back to `idGenerator()`. */
57
58
  readonly id?: string;
58
59
  }
60
+ /** Create an upload adapter backed by a host presign endpoint and S3 PUT. */
59
61
  export declare function s3PresignedAdapter(options: S3PresignedAdapterOptions): UploadAdapter;
60
62
  //# sourceMappingURL=s3-presigned.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"s3-presigned.d.ts","sourceRoot":"","sources":["../../src/adapters/s3-presigned.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAgB,MAAM,mBAAmB,CAAC;AAErE,OAAO,EAEN,KAAK,YAAY,EAEjB,MAAM,mBAAmB,CAAC;AAE3B,YAAY,EAAE,YAAY,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ager i18n messages for standalone UI subpath mounts. */
13
14
  export declare function AssetManagerI18nProvider({ children, }: {
14
15
  readonly children: ReactNode;
15
16
  }): ReactNode;
@@ -1 +1 @@
1
- {"version":3,"file":"provider.d.cts","sourceRoot":"","sources":["../../src/i18n/provider.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAGH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAKvC,OAAO,EAAuB,KAAK,sBAAsB,EAAE,MAAM,YAAY,CAAC;AAE9E,wBAAgB,wBAAwB,CAAC,EACxC,QAAQ,GACR,EAAE;IACF,QAAQ,CAAC,QAAQ,EAAE,SAAS,CAAC;CAC7B,GAAG,SAAS,CAMZ;AAGD,OAAO,QAAQ,qBAAqB,CAAC;IACpC,UAAU,gBAAiB,SAAQ,MAAM,CAAC,sBAAsB,EAAE,MAAM,CAAC;KAAG;CAC5E"}
1
+ {"version":3,"file":"provider.d.cts","sourceRoot":"","sources":["../../src/i18n/provider.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAGH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAKvC,OAAO,EAAuB,KAAK,sBAAsB,EAAE,MAAM,YAAY,CAAC;AAE9E,4EAA4E;AAC5E,wBAAgB,wBAAwB,CAAC,EACxC,QAAQ,GACR,EAAE;IACF,QAAQ,CAAC,QAAQ,EAAE,SAAS,CAAC;CAC7B,GAAG,SAAS,CAMZ;AAGD,OAAO,QAAQ,qBAAqB,CAAC;IACpC,UAAU,gBAAiB,SAAQ,MAAM,CAAC,sBAAsB,EAAE,MAAM,CAAC;KAAG;CAC5E"}
@@ -10,6 +10,7 @@
10
10
  */
11
11
  import type { ReactNode } from "react";
12
12
  import { type AssetManagerMessageKey } from "./entry.js";
13
+ /** Provide asset-manager i18n messages for standalone UI subpath mounts. */
13
14
  export declare function AssetManagerI18nProvider({ children, }: {
14
15
  readonly children: ReactNode;
15
16
  }): ReactNode;
@@ -1 +1 @@
1
- {"version":3,"file":"provider.d.ts","sourceRoot":"","sources":["../../src/i18n/provider.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAGH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAKvC,OAAO,EAAuB,KAAK,sBAAsB,EAAE,MAAM,YAAY,CAAC;AAE9E,wBAAgB,wBAAwB,CAAC,EACxC,QAAQ,GACR,EAAE;IACF,QAAQ,CAAC,QAAQ,EAAE,SAAS,CAAC;CAC7B,GAAG,SAAS,CAMZ;AAGD,OAAO,QAAQ,qBAAqB,CAAC;IACpC,UAAU,gBAAiB,SAAQ,MAAM,CAAC,sBAAsB,EAAE,MAAM,CAAC;KAAG;CAC5E"}
1
+ {"version":3,"file":"provider.d.ts","sourceRoot":"","sources":["../../src/i18n/provider.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAGH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAKvC,OAAO,EAAuB,KAAK,sBAAsB,EAAE,MAAM,YAAY,CAAC;AAE9E,4EAA4E;AAC5E,wBAAgB,wBAAwB,CAAC,EACxC,QAAQ,GACR,EAAE;IACF,QAAQ,CAAC,QAAQ,EAAE,SAAS,CAAC;CAC7B,GAAG,SAAS,CAMZ;AAGD,OAAO,QAAQ,qBAAqB,CAAC;IACpC,UAAU,gBAAiB,SAAQ,MAAM,CAAC,sBAAsB,EAAE,MAAM,CAAC;KAAG;CAC5E"}
package/dist/index.cjs CHANGED
@@ -28,6 +28,8 @@ var __webpack_require__ = {};
28
28
  var __webpack_exports__ = {};
29
29
  __webpack_require__.r(__webpack_exports__);
30
30
  __webpack_require__.d(__webpack_exports__, {
31
+ ASSET_MANAGER_ERROR_EVENT: ()=>external_plugin_cjs_namespaceObject.ASSET_MANAGER_ERROR_EVENT,
32
+ ASSET_MANAGER_UPLOADED_EVENT: ()=>external_plugin_cjs_namespaceObject.ASSET_MANAGER_UPLOADED_EVENT,
31
33
  AssetResolutionError: ()=>errors_cjs_namespaceObject.AssetResolutionError,
32
34
  AssetSourceError: ()=>errors_cjs_namespaceObject.AssetSourceError,
33
35
  AssetValidationError: ()=>errors_cjs_namespaceObject.AssetValidationError,
@@ -42,6 +44,8 @@ __webpack_require__.d(__webpack_exports__, {
42
44
  inMemoryUploader: ()=>in_memory_cjs_namespaceObject.inMemoryUploader,
43
45
  inferAssetKind: ()=>infer_kind_cjs_namespaceObject.inferAssetKind,
44
46
  inferStudioAssetKind: ()=>studio_asset_source_cjs_namespaceObject.inferStudioAssetKind,
47
+ isResumableAdapter: ()=>resumable_cjs_namespaceObject.isResumableAdapter,
48
+ parseAssetReference: ()=>asset_reference_cjs_namespaceObject.parseAssetReference,
45
49
  resolveAssets: ()=>resolver_cjs_namespaceObject.resolveAssets,
46
50
  resolveFolderId: ()=>folders_cjs_namespaceObject.resolveFolderId,
47
51
  uploadAsset: ()=>external_plugin_cjs_namespaceObject.uploadAsset,
@@ -51,6 +55,8 @@ const data_url_cjs_namespaceObject = require("./adapters/data-url.cjs");
51
55
  const in_memory_cjs_namespaceObject = require("./adapters/in-memory.cjs");
52
56
  const external_plugin_cjs_namespaceObject = require("./plugin.cjs");
53
57
  const folders_cjs_namespaceObject = require("./types/folders.cjs");
58
+ const resumable_cjs_namespaceObject = require("./types/resumable.cjs");
59
+ const asset_reference_cjs_namespaceObject = require("./utils/asset-reference.cjs");
54
60
  const csp_cjs_namespaceObject = require("./utils/csp.cjs");
55
61
  const errors_cjs_namespaceObject = require("./utils/errors.cjs");
56
62
  const infer_kind_cjs_namespaceObject = require("./utils/infer-kind.cjs");
@@ -58,6 +64,8 @@ const registry_cjs_namespaceObject = require("./utils/registry.cjs");
58
64
  const resolver_cjs_namespaceObject = require("./utils/resolver.cjs");
59
65
  const studio_asset_source_cjs_namespaceObject = require("./utils/studio-asset-source.cjs");
60
66
  const validate_upload_result_cjs_namespaceObject = require("./utils/validate-upload-result.cjs");
67
+ exports.ASSET_MANAGER_ERROR_EVENT = __webpack_exports__.ASSET_MANAGER_ERROR_EVENT;
68
+ exports.ASSET_MANAGER_UPLOADED_EVENT = __webpack_exports__.ASSET_MANAGER_UPLOADED_EVENT;
61
69
  exports.AssetResolutionError = __webpack_exports__.AssetResolutionError;
62
70
  exports.AssetSourceError = __webpack_exports__.AssetSourceError;
63
71
  exports.AssetValidationError = __webpack_exports__.AssetValidationError;
@@ -72,11 +80,15 @@ exports.getRequiredCsp = __webpack_exports__.getRequiredCsp;
72
80
  exports.inMemoryUploader = __webpack_exports__.inMemoryUploader;
73
81
  exports.inferAssetKind = __webpack_exports__.inferAssetKind;
74
82
  exports.inferStudioAssetKind = __webpack_exports__.inferStudioAssetKind;
83
+ exports.isResumableAdapter = __webpack_exports__.isResumableAdapter;
84
+ exports.parseAssetReference = __webpack_exports__.parseAssetReference;
75
85
  exports.resolveAssets = __webpack_exports__.resolveAssets;
76
86
  exports.resolveFolderId = __webpack_exports__.resolveFolderId;
77
87
  exports.uploadAsset = __webpack_exports__.uploadAsset;
78
88
  exports.validateUploadResult = __webpack_exports__.validateUploadResult;
79
89
  for(var __rspack_i in __webpack_exports__)if (-1 === [
90
+ "ASSET_MANAGER_ERROR_EVENT",
91
+ "ASSET_MANAGER_UPLOADED_EVENT",
80
92
  "AssetResolutionError",
81
93
  "AssetSourceError",
82
94
  "AssetValidationError",
@@ -91,6 +103,8 @@ for(var __rspack_i in __webpack_exports__)if (-1 === [
91
103
  "inMemoryUploader",
92
104
  "inferAssetKind",
93
105
  "inferStudioAssetKind",
106
+ "isResumableAdapter",
107
+ "parseAssetReference",
94
108
  "resolveAssets",
95
109
  "resolveFolderId",
96
110
  "uploadAsset",
package/dist/index.d.cts CHANGED
@@ -1,7 +1,8 @@
1
1
  export type { DataUrlUploaderOptions } from "./adapters/data-url.js";
2
2
  export { dataUrlUploader } from "./adapters/data-url.js";
3
3
  export { inMemoryUploader } from "./adapters/in-memory.js";
4
- export { createAssetManagerPlugin, createAssetReference, getAssetRegistry, uploadAsset, } from "./plugin.js";
4
+ export type { AssetManagerErrorEvent, AssetManagerEventMap, AssetManagerEventName, AssetManagerUploadedEvent, } from "./plugin.js";
5
+ export { ASSET_MANAGER_ERROR_EVENT, ASSET_MANAGER_UPLOADED_EVENT, createAssetManagerPlugin, createAssetReference, getAssetRegistry, uploadAsset, } from "./plugin.js";
5
6
  export type { AssetSourceCapabilities, AssetSourceProvider, AssetTheme, } from "./sources/provider.js";
6
7
  export type { AssetCategory, AssetFacetDefinition, AssetFacetOption, } from "./types/categories.js";
7
8
  export type { AssetDataSource, AssetSourceStatus, ReplacePayload, } from "./types/data-source.js";
@@ -9,9 +10,14 @@ export type { AssetFilter, AssetListPage, AssetSort, AssetSortField, AssetSource
9
10
  export type { AssetFolder, FolderId, FolderOptions } from "./types/folders.js";
10
11
  export { resolveFolderId } from "./types/folders.js";
11
12
  export type { AssetManagerOptions } from "./types/options.js";
12
- export type { AssetKind, AssetMeta, AssetRegistry, AssetRegistryListener, AssetSearchOptions, AssetSearchPage, UploadAdapter, UploadAdapterOptions, UploadResult, } from "./types/types.js";
13
+ export type { JsonValue, PartTag, PersistedUploadSession, ResumableUploadAdapter, ResumableUploadConfig, UploadPart, UploadSession, UploadSessionStore, } from "./types/resumable.js";
14
+ export { isResumableAdapter } from "./types/resumable.js";
15
+ export type { AssetTransform, TransformResolver, } from "./types/transform.js";
16
+ export type { AssetDeletedHook, AssetKind, AssetMeta, AssetRegistry, AssetRegistryListener, AssetSearchOptions, AssetSearchPage, UploadAdapter, UploadAdapterOptions, UploadResult, } from "./types/types.js";
13
17
  export type { UnsplashSourceOptions, UnsplashTheme, UnsplashThemeConfig, } from "./types/unsplash.js";
14
- export type { RequiredCsp, RequiredCspOptions, S3CspOptions, } from "./utils/csp.js";
18
+ export type { ParsedAssetReference } from "./utils/asset-reference.js";
19
+ export { parseAssetReference } from "./utils/asset-reference.js";
20
+ export type { RequiredCsp, RequiredCspOptions, S3CspOptions, S3MultipartCspOptions, } from "./utils/csp.js";
15
21
  export { getRequiredCsp } from "./utils/csp.js";
16
22
  export type { AssetResolutionErrorCode, AssetSourceErrorCode, } from "./utils/errors.js";
17
23
  export { AssetResolutionError, AssetSourceError, AssetValidationError, } from "./utils/errors.js";