@anvilkit/plugin-asset-manager 0.1.3 → 0.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/adapters/data-url.cjs +4 -4
- package/dist/adapters/data-url.d.cts +1 -1
- package/dist/adapters/data-url.d.cts.map +1 -1
- package/dist/adapters/data-url.d.ts +1 -1
- package/dist/adapters/data-url.d.ts.map +1 -1
- package/dist/adapters/data-url.js +1 -1
- package/dist/adapters/extract-image-dimensions.d.cts.map +1 -1
- package/dist/adapters/extract-image-dimensions.d.ts.map +1 -1
- package/dist/adapters/in-memory.d.cts +1 -1
- package/dist/adapters/in-memory.d.cts.map +1 -1
- package/dist/adapters/in-memory.d.ts +1 -1
- package/dist/adapters/in-memory.d.ts.map +1 -1
- package/dist/adapters/s3-presigned.cjs +15 -15
- package/dist/adapters/s3-presigned.d.cts +4 -4
- package/dist/adapters/s3-presigned.d.cts.map +1 -1
- package/dist/adapters/s3-presigned.d.ts +4 -4
- package/dist/adapters/s3-presigned.d.ts.map +1 -1
- package/dist/adapters/s3-presigned.js +3 -3
- package/dist/index.cjs +20 -20
- package/dist/index.d.cts +13 -13
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.ts +13 -13
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +7 -7
- package/dist/plugin.cjs +27 -29
- package/dist/plugin.d.cts +2 -2
- package/dist/plugin.d.cts.map +1 -1
- package/dist/plugin.d.ts +2 -2
- package/dist/plugin.d.ts.map +1 -1
- package/dist/plugin.js +14 -14
- package/dist/testing/index.cjs +2 -2
- package/dist/testing/index.d.cts +1 -1
- package/dist/testing/index.d.cts.map +1 -1
- package/dist/testing/index.d.ts +1 -1
- package/dist/testing/index.d.ts.map +1 -1
- package/dist/testing/index.js +1 -1
- package/dist/types/types.d.cts.map +1 -0
- package/dist/types/types.d.ts.map +1 -0
- package/dist/types/types.js +1 -0
- package/dist/ui/AssetBrowser.cjs +2 -2
- package/dist/ui/AssetBrowser.d.cts +1 -1
- package/dist/ui/AssetBrowser.d.cts.map +1 -1
- package/dist/ui/AssetBrowser.d.ts +1 -1
- package/dist/ui/AssetBrowser.d.ts.map +1 -1
- package/dist/ui/AssetBrowser.js +1 -1
- package/dist/ui/AssetCommandPalette.cjs +2 -2
- package/dist/ui/AssetCommandPalette.d.cts +1 -1
- package/dist/ui/AssetCommandPalette.d.cts.map +1 -1
- package/dist/ui/AssetCommandPalette.d.ts +1 -1
- package/dist/ui/AssetCommandPalette.d.ts.map +1 -1
- package/dist/ui/AssetCommandPalette.js +1 -1
- package/dist/ui/AssetManagerUI.cjs +2 -2
- package/dist/ui/AssetManagerUI.d.cts +1 -1
- package/dist/ui/AssetManagerUI.d.cts.map +1 -1
- package/dist/ui/AssetManagerUI.d.ts +1 -1
- package/dist/ui/AssetManagerUI.d.ts.map +1 -1
- package/dist/ui/AssetManagerUI.js +1 -1
- package/dist/ui/DeleteAssetDialog.d.cts +1 -1
- package/dist/ui/DeleteAssetDialog.d.cts.map +1 -1
- package/dist/ui/DeleteAssetDialog.d.ts +1 -1
- package/dist/ui/DeleteAssetDialog.d.ts.map +1 -1
- package/dist/ui/MetadataPanel.d.cts +1 -1
- package/dist/ui/MetadataPanel.d.cts.map +1 -1
- package/dist/ui/MetadataPanel.d.ts +1 -1
- package/dist/ui/MetadataPanel.d.ts.map +1 -1
- package/dist/ui/ReplaceAssetDialog.d.cts +1 -1
- package/dist/ui/ReplaceAssetDialog.d.cts.map +1 -1
- package/dist/ui/ReplaceAssetDialog.d.ts +1 -1
- package/dist/ui/ReplaceAssetDialog.d.ts.map +1 -1
- package/dist/ui/UploadButton.cjs +2 -2
- package/dist/ui/UploadButton.d.cts +1 -1
- package/dist/ui/UploadButton.d.cts.map +1 -1
- package/dist/ui/UploadButton.d.ts +1 -1
- package/dist/ui/UploadButton.d.ts.map +1 -1
- package/dist/ui/UploadButton.js +1 -1
- package/dist/ui/index.cjs +5 -5
- package/dist/ui/index.d.cts.map +1 -1
- package/dist/ui/index.d.ts.map +1 -1
- package/dist/utils/asset-reference.d.cts.map +1 -0
- package/dist/utils/asset-reference.d.ts.map +1 -0
- package/dist/utils/csp.d.cts.map +1 -0
- package/dist/utils/csp.d.ts.map +1 -0
- package/dist/utils/errors.d.cts.map +1 -0
- package/dist/utils/errors.d.ts.map +1 -0
- package/dist/utils/header-action.d.cts.map +1 -0
- package/dist/utils/header-action.d.ts.map +1 -0
- package/dist/{infer-kind.d.cts → utils/infer-kind.d.cts} +1 -1
- package/dist/utils/infer-kind.d.cts.map +1 -0
- package/dist/{infer-kind.d.ts → utils/infer-kind.d.ts} +1 -1
- package/dist/utils/infer-kind.d.ts.map +1 -0
- package/dist/utils/registry.d.cts +3 -0
- package/dist/utils/registry.d.cts.map +1 -0
- package/dist/utils/registry.d.ts +3 -0
- package/dist/utils/registry.d.ts.map +1 -0
- package/dist/{resolver.cjs → utils/resolver.cjs} +2 -2
- package/dist/{resolver.d.cts → utils/resolver.d.cts} +1 -1
- package/dist/utils/resolver.d.cts.map +1 -0
- package/dist/{resolver.d.ts → utils/resolver.d.ts} +1 -1
- package/dist/utils/resolver.d.ts.map +1 -0
- package/dist/utils/retry.d.cts.map +1 -0
- package/dist/utils/retry.d.ts.map +1 -0
- package/dist/{studio-asset-source.cjs → utils/studio-asset-source.cjs} +2 -2
- package/dist/{studio-asset-source.d.cts → utils/studio-asset-source.d.cts} +1 -1
- package/dist/utils/studio-asset-source.d.cts.map +1 -0
- package/dist/{studio-asset-source.d.ts → utils/studio-asset-source.d.ts} +1 -1
- package/dist/utils/studio-asset-source.d.ts.map +1 -0
- package/dist/{validate-upload-result.d.cts → utils/validate-upload-result.d.cts} +1 -1
- package/dist/utils/validate-upload-result.d.cts.map +1 -0
- package/dist/{validate-upload-result.d.ts → utils/validate-upload-result.d.ts} +1 -1
- package/dist/utils/validate-upload-result.d.ts.map +1 -0
- package/dist/version.cjs +36 -0
- package/dist/version.d.cts +20 -0
- package/dist/version.d.cts.map +1 -0
- package/dist/version.d.ts +20 -0
- package/dist/version.d.ts.map +1 -0
- package/dist/version.js +2 -0
- package/meta/config.json +8 -0
- package/package.json +23 -22
- package/dist/asset-reference.d.cts.map +0 -1
- package/dist/asset-reference.d.ts.map +0 -1
- package/dist/csp.d.cts.map +0 -1
- package/dist/csp.d.ts.map +0 -1
- package/dist/errors.d.cts.map +0 -1
- package/dist/errors.d.ts.map +0 -1
- package/dist/header-action.d.cts.map +0 -1
- package/dist/header-action.d.ts.map +0 -1
- package/dist/infer-kind.d.cts.map +0 -1
- package/dist/infer-kind.d.ts.map +0 -1
- package/dist/registry.d.cts +0 -3
- package/dist/registry.d.cts.map +0 -1
- package/dist/registry.d.ts +0 -3
- package/dist/registry.d.ts.map +0 -1
- package/dist/resolver.d.cts.map +0 -1
- package/dist/resolver.d.ts.map +0 -1
- package/dist/retry.d.cts.map +0 -1
- package/dist/retry.d.ts.map +0 -1
- package/dist/studio-asset-source.d.cts.map +0 -1
- package/dist/studio-asset-source.d.ts.map +0 -1
- package/dist/types.d.cts.map +0 -1
- package/dist/types.d.ts.map +0 -1
- package/dist/types.js +0 -0
- package/dist/validate-upload-result.d.cts.map +0 -1
- package/dist/validate-upload-result.d.ts.map +0 -1
- /package/dist/{types.cjs → types/types.cjs} +0 -0
- /package/dist/{types.d.cts → types/types.d.cts} +0 -0
- /package/dist/{types.d.ts → types/types.d.ts} +0 -0
- /package/dist/{asset-reference.cjs → utils/asset-reference.cjs} +0 -0
- /package/dist/{asset-reference.d.cts → utils/asset-reference.d.cts} +0 -0
- /package/dist/{asset-reference.d.ts → utils/asset-reference.d.ts} +0 -0
- /package/dist/{asset-reference.js → utils/asset-reference.js} +0 -0
- /package/dist/{csp.cjs → utils/csp.cjs} +0 -0
- /package/dist/{csp.d.cts → utils/csp.d.cts} +0 -0
- /package/dist/{csp.d.ts → utils/csp.d.ts} +0 -0
- /package/dist/{csp.js → utils/csp.js} +0 -0
- /package/dist/{errors.cjs → utils/errors.cjs} +0 -0
- /package/dist/{errors.d.cts → utils/errors.d.cts} +0 -0
- /package/dist/{errors.d.ts → utils/errors.d.ts} +0 -0
- /package/dist/{errors.js → utils/errors.js} +0 -0
- /package/dist/{header-action.cjs → utils/header-action.cjs} +0 -0
- /package/dist/{header-action.d.cts → utils/header-action.d.cts} +0 -0
- /package/dist/{header-action.d.ts → utils/header-action.d.ts} +0 -0
- /package/dist/{header-action.js → utils/header-action.js} +0 -0
- /package/dist/{infer-kind.cjs → utils/infer-kind.cjs} +0 -0
- /package/dist/{infer-kind.js → utils/infer-kind.js} +0 -0
- /package/dist/{registry.cjs → utils/registry.cjs} +0 -0
- /package/dist/{registry.js → utils/registry.js} +0 -0
- /package/dist/{resolver.js → utils/resolver.js} +0 -0
- /package/dist/{retry.cjs → utils/retry.cjs} +0 -0
- /package/dist/{retry.d.cts → utils/retry.d.cts} +0 -0
- /package/dist/{retry.d.ts → utils/retry.d.ts} +0 -0
- /package/dist/{retry.js → utils/retry.js} +0 -0
- /package/dist/{studio-asset-source.js → utils/studio-asset-source.js} +0 -0
- /package/dist/{validate-upload-result.cjs → utils/validate-upload-result.cjs} +0 -0
- /package/dist/{validate-upload-result.js → utils/validate-upload-result.js} +0 -0
|
@@ -26,14 +26,14 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
26
26
|
__webpack_require__.d(__webpack_exports__, {
|
|
27
27
|
dataUrlUploader: ()=>dataUrlUploader
|
|
28
28
|
});
|
|
29
|
-
const
|
|
29
|
+
const errors_cjs_namespaceObject = require("../utils/errors.cjs");
|
|
30
30
|
const external_extract_image_dimensions_cjs_namespaceObject = require("./extract-image-dimensions.cjs");
|
|
31
31
|
const DEFAULT_MAX_BYTES = 1048576;
|
|
32
32
|
function dataUrlUploader(options = {}) {
|
|
33
33
|
const maxBytes = options.maxBytes ?? DEFAULT_MAX_BYTES;
|
|
34
34
|
let counter = 0;
|
|
35
35
|
return async (file, opts)=>{
|
|
36
|
-
if (file.size > maxBytes) throw new
|
|
36
|
+
if (file.size > maxBytes) throw new errors_cjs_namespaceObject.AssetValidationError("DATA_URL_FILE_TOO_LARGE", `File size ${file.size} bytes exceeds the data URL adapter limit of ${maxBytes} bytes.`);
|
|
37
37
|
counter += 1;
|
|
38
38
|
const url = await readAsDataUrl(file);
|
|
39
39
|
const dimensions = await (0, external_extract_image_dimensions_cjs_namespaceObject.extractImageDimensions)(url, file.type, {
|
|
@@ -62,12 +62,12 @@ function readAsDataUrl(file) {
|
|
|
62
62
|
return new Promise((resolve, reject)=>{
|
|
63
63
|
const reader = new FileReader();
|
|
64
64
|
reader.onerror = ()=>{
|
|
65
|
-
reject(new
|
|
65
|
+
reject(new errors_cjs_namespaceObject.AssetValidationError("DATA_URL_READ_FAILED", "Failed to read file as a data URL.", {
|
|
66
66
|
cause: reader.error
|
|
67
67
|
}));
|
|
68
68
|
};
|
|
69
69
|
reader.onload = ()=>{
|
|
70
|
-
if ("string" != typeof reader.result) return void reject(new
|
|
70
|
+
if ("string" != typeof reader.result) return void reject(new errors_cjs_namespaceObject.AssetValidationError("DATA_URL_READ_FAILED", "FileReader did not produce a string data URL."));
|
|
71
71
|
resolve(reader.result);
|
|
72
72
|
};
|
|
73
73
|
reader.readAsDataURL(file);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"data-url.d.cts","sourceRoot":"","sources":["../../src/adapters/data-url.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"data-url.d.cts","sourceRoot":"","sources":["../../src/adapters/data-url.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAgB,MAAM,mBAAmB,CAAC;AAIrE,MAAM,WAAW,sBAAsB;IACtC,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;CAC3B;AAID,wBAAgB,eAAe,CAC9B,OAAO,GAAE,sBAA2B,GAClC,aAAa,CA+Bf"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"data-url.d.ts","sourceRoot":"","sources":["../../src/adapters/data-url.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"data-url.d.ts","sourceRoot":"","sources":["../../src/adapters/data-url.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAgB,MAAM,mBAAmB,CAAC;AAIrE,MAAM,WAAW,sBAAsB;IACtC,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;CAC3B;AAID,wBAAgB,eAAe,CAC9B,OAAO,GAAE,sBAA2B,GAClC,aAAa,CA+Bf"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"extract-image-dimensions.d.cts","sourceRoot":"","sources":["../../src/adapters/extract-image-dimensions.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,MAAM,WAAW,6BAA6B;
|
|
1
|
+
{"version":3,"file":"extract-image-dimensions.d.cts","sourceRoot":"","sources":["../../src/adapters/extract-image-dimensions.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,MAAM,WAAW,6BAA6B;IAC7C,qDAAqD;IACrD,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;IAC5B;;;;OAIG;IACH,QAAQ,CAAC,MAAM,CAAC,EAAE,WAAW,CAAC;CAC9B;AAED,MAAM,WAAW,eAAe;IAC/B,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;CACxB;AAID,wBAAsB,sBAAsB,CAC3C,GAAG,EAAE,MAAM,EACX,QAAQ,EAAE,MAAM,GAAG,SAAS,EAC5B,OAAO,GAAE,6BAAkC,GACzC,OAAO,CAAC,eAAe,GAAG,SAAS,CAAC,CAkEtC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"extract-image-dimensions.d.ts","sourceRoot":"","sources":["../../src/adapters/extract-image-dimensions.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,MAAM,WAAW,6BAA6B;
|
|
1
|
+
{"version":3,"file":"extract-image-dimensions.d.ts","sourceRoot":"","sources":["../../src/adapters/extract-image-dimensions.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,MAAM,WAAW,6BAA6B;IAC7C,qDAAqD;IACrD,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;IAC5B;;;;OAIG;IACH,QAAQ,CAAC,MAAM,CAAC,EAAE,WAAW,CAAC;CAC9B;AAED,MAAM,WAAW,eAAe;IAC/B,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;CACxB;AAID,wBAAsB,sBAAsB,CAC3C,GAAG,EAAE,MAAM,EACX,QAAQ,EAAE,MAAM,GAAG,SAAS,EAC5B,OAAO,GAAE,6BAAkC,GACzC,OAAO,CAAC,eAAe,GAAG,SAAS,CAAC,CAkEtC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"in-memory.d.cts","sourceRoot":"","sources":["../../src/adapters/in-memory.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAgB,MAAM,
|
|
1
|
+
{"version":3,"file":"in-memory.d.cts","sourceRoot":"","sources":["../../src/adapters/in-memory.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAgB,MAAM,mBAAmB,CAAC;AAGrE;;;;;GAKG;AACH,wBAAgB,gBAAgB,IAAI,aAAa,CA8BhD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"in-memory.d.ts","sourceRoot":"","sources":["../../src/adapters/in-memory.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAgB,MAAM,
|
|
1
|
+
{"version":3,"file":"in-memory.d.ts","sourceRoot":"","sources":["../../src/adapters/in-memory.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAgB,MAAM,mBAAmB,CAAC;AAGrE;;;;;GAKG;AACH,wBAAgB,gBAAgB,IAAI,aAAa,CA8BhD"}
|
|
@@ -24,11 +24,11 @@ var __webpack_require__ = {};
|
|
|
24
24
|
var __webpack_exports__ = {};
|
|
25
25
|
__webpack_require__.r(__webpack_exports__);
|
|
26
26
|
__webpack_require__.d(__webpack_exports__, {
|
|
27
|
-
|
|
28
|
-
|
|
27
|
+
RetryableError: ()=>retry_cjs_namespaceObject.RetryableError,
|
|
28
|
+
s3PresignedAdapter: ()=>s3PresignedAdapter
|
|
29
29
|
});
|
|
30
|
-
const
|
|
31
|
-
const
|
|
30
|
+
const errors_cjs_namespaceObject = require("../utils/errors.cjs");
|
|
31
|
+
const retry_cjs_namespaceObject = require("../utils/retry.cjs");
|
|
32
32
|
function s3PresignedAdapter(options) {
|
|
33
33
|
const fetchImpl = options.fetch ?? globalThis.fetch;
|
|
34
34
|
if ("function" != typeof fetchImpl) throw new Error("s3PresignedAdapter: no `fetch` implementation available. Pass `options.fetch`.");
|
|
@@ -36,11 +36,11 @@ function s3PresignedAdapter(options) {
|
|
|
36
36
|
return async (file, callOptions)=>{
|
|
37
37
|
const { signal, dispose } = combineSignals(options.signal, callOptions?.signal);
|
|
38
38
|
try {
|
|
39
|
-
const presign = await (0,
|
|
39
|
+
const presign = await (0, retry_cjs_namespaceObject.withRetry)(()=>requestPresign(file, fetchImpl, options, signal), {
|
|
40
40
|
...options.retry ?? {},
|
|
41
41
|
signal
|
|
42
42
|
});
|
|
43
|
-
await (0,
|
|
43
|
+
await (0, retry_cjs_namespaceObject.withRetry)(()=>putToS3(file, presign, fetchImpl, signal), {
|
|
44
44
|
...options.retry ?? {},
|
|
45
45
|
signal
|
|
46
46
|
});
|
|
@@ -86,23 +86,23 @@ async function requestPresign(file, fetchImpl, options, signal) {
|
|
|
86
86
|
} : {}
|
|
87
87
|
});
|
|
88
88
|
} catch (cause) {
|
|
89
|
-
throw new
|
|
89
|
+
throw new retry_cjs_namespaceObject.RetryableError(`s3PresignedAdapter: presign request failed (${describeError(cause)}).`, {
|
|
90
90
|
cause
|
|
91
91
|
});
|
|
92
92
|
}
|
|
93
|
-
if (response.status >= 500) throw new
|
|
93
|
+
if (response.status >= 500) throw new retry_cjs_namespaceObject.RetryableError(`s3PresignedAdapter: presign returned ${response.status}.`, {
|
|
94
94
|
retryAfterMs: parseRetryAfter(response.headers.get("retry-after"))
|
|
95
95
|
});
|
|
96
|
-
if (!response.ok) throw new
|
|
96
|
+
if (!response.ok) throw new errors_cjs_namespaceObject.AssetValidationError("UPLOAD_FAILED", `s3PresignedAdapter: presign returned ${response.status}.`);
|
|
97
97
|
let payload;
|
|
98
98
|
try {
|
|
99
99
|
payload = await response.json();
|
|
100
100
|
} catch (cause) {
|
|
101
|
-
throw new
|
|
101
|
+
throw new errors_cjs_namespaceObject.AssetValidationError("UPLOAD_FAILED", "s3PresignedAdapter: presign response was not JSON.", {
|
|
102
102
|
cause
|
|
103
103
|
});
|
|
104
104
|
}
|
|
105
|
-
if (!isPresignResponse(payload)) throw new
|
|
105
|
+
if (!isPresignResponse(payload)) throw new errors_cjs_namespaceObject.AssetValidationError("UPLOAD_FAILED", "s3PresignedAdapter: presign response missing `url`.");
|
|
106
106
|
return payload;
|
|
107
107
|
}
|
|
108
108
|
async function putToS3(file, presign, fetchImpl, signal) {
|
|
@@ -123,14 +123,14 @@ async function putToS3(file, presign, fetchImpl, signal) {
|
|
|
123
123
|
} : {}
|
|
124
124
|
});
|
|
125
125
|
} catch (cause) {
|
|
126
|
-
throw new
|
|
126
|
+
throw new retry_cjs_namespaceObject.RetryableError(`s3PresignedAdapter: PUT failed (${describeError(cause)}).`, {
|
|
127
127
|
cause
|
|
128
128
|
});
|
|
129
129
|
}
|
|
130
|
-
if (response.status >= 500) throw new
|
|
130
|
+
if (response.status >= 500) throw new retry_cjs_namespaceObject.RetryableError(`s3PresignedAdapter: PUT returned ${response.status}.`, {
|
|
131
131
|
retryAfterMs: parseRetryAfter(response.headers.get("retry-after"))
|
|
132
132
|
});
|
|
133
|
-
if (!response.ok) throw new
|
|
133
|
+
if (!response.ok) throw new errors_cjs_namespaceObject.AssetValidationError("UPLOAD_FAILED", `s3PresignedAdapter: PUT returned ${response.status}.`);
|
|
134
134
|
}
|
|
135
135
|
function isPresignResponse(value) {
|
|
136
136
|
return null !== value && "object" == typeof value && "string" == typeof value.url && value.url.length > 0;
|
|
@@ -160,7 +160,7 @@ function defaultIdGenerator() {
|
|
|
160
160
|
if (void 0 !== globalThis.crypto && "function" == typeof globalThis.crypto.randomUUID) return globalThis.crypto.randomUUID();
|
|
161
161
|
return `asset-${Math.random().toString(36).slice(2)}-${Date.now()}`;
|
|
162
162
|
}
|
|
163
|
-
const NOOP_DISPOSE = ()=>
|
|
163
|
+
const NOOP_DISPOSE = ()=>void 0;
|
|
164
164
|
function combineSignals(a, b) {
|
|
165
165
|
if (!a) return {
|
|
166
166
|
signal: b,
|
|
@@ -17,11 +17,11 @@
|
|
|
17
17
|
*
|
|
18
18
|
* @experimental Public surface may change before v1.0.
|
|
19
19
|
*/
|
|
20
|
-
import {
|
|
21
|
-
import type
|
|
20
|
+
import type { UploadAdapter } from "../types/types.js";
|
|
21
|
+
import { type RetryOptions } from "../utils/retry.js";
|
|
22
|
+
export type { RetryOptions } from "../utils/retry.js";
|
|
22
23
|
/** @deprecated Import from `@anvilkit/plugin-asset-manager/retry` instead. */
|
|
23
|
-
export { RetryableError } from "../retry.js";
|
|
24
|
-
export type { RetryOptions } from "../retry.js";
|
|
24
|
+
export { RetryableError } from "../utils/retry.js";
|
|
25
25
|
export interface S3PresignedAdapterOptions {
|
|
26
26
|
/** Endpoint that returns a presigned PUT target for the file. */
|
|
27
27
|
readonly presignEndpoint: string | URL;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"s3-presigned.d.cts","sourceRoot":"","sources":["../../src/adapters/s3-presigned.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;
|
|
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,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,wBAAgB,kBAAkB,CACjC,OAAO,EAAE,yBAAyB,GAChC,aAAa,CA+Cf"}
|
|
@@ -17,11 +17,11 @@
|
|
|
17
17
|
*
|
|
18
18
|
* @experimental Public surface may change before v1.0.
|
|
19
19
|
*/
|
|
20
|
-
import {
|
|
21
|
-
import type
|
|
20
|
+
import type { UploadAdapter } from "../types/types.js";
|
|
21
|
+
import { type RetryOptions } from "../utils/retry.js";
|
|
22
|
+
export type { RetryOptions } from "../utils/retry.js";
|
|
22
23
|
/** @deprecated Import from `@anvilkit/plugin-asset-manager/retry` instead. */
|
|
23
|
-
export { RetryableError } from "../retry.js";
|
|
24
|
-
export type { RetryOptions } from "../retry.js";
|
|
24
|
+
export { RetryableError } from "../utils/retry.js";
|
|
25
25
|
export interface S3PresignedAdapterOptions {
|
|
26
26
|
/** Endpoint that returns a presigned PUT target for the file. */
|
|
27
27
|
readonly presignEndpoint: string | URL;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"s3-presigned.d.ts","sourceRoot":"","sources":["../../src/adapters/s3-presigned.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;
|
|
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,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,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,wBAAgB,kBAAkB,CACjC,OAAO,EAAE,yBAAyB,GAChC,aAAa,CA+Cf"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { AssetValidationError } from "../errors.js";
|
|
2
|
-
import { RetryableError, withRetry } from "../retry.js";
|
|
1
|
+
import { AssetValidationError } from "../utils/errors.js";
|
|
2
|
+
import { RetryableError, withRetry } from "../utils/retry.js";
|
|
3
3
|
function s3PresignedAdapter(options) {
|
|
4
4
|
const fetchImpl = options.fetch ?? globalThis.fetch;
|
|
5
5
|
if ("function" != typeof fetchImpl) throw new Error("s3PresignedAdapter: no `fetch` implementation available. Pass `options.fetch`.");
|
|
@@ -131,7 +131,7 @@ function defaultIdGenerator() {
|
|
|
131
131
|
if (void 0 !== globalThis.crypto && "function" == typeof globalThis.crypto.randomUUID) return globalThis.crypto.randomUUID();
|
|
132
132
|
return `asset-${Math.random().toString(36).slice(2)}-${Date.now()}`;
|
|
133
133
|
}
|
|
134
|
-
const NOOP_DISPOSE = ()=>
|
|
134
|
+
const NOOP_DISPOSE = ()=>void 0;
|
|
135
135
|
function combineSignals(a, b) {
|
|
136
136
|
if (!a) return {
|
|
137
137
|
signal: b,
|
package/dist/index.cjs
CHANGED
|
@@ -24,33 +24,33 @@ var __webpack_require__ = {};
|
|
|
24
24
|
var __webpack_exports__ = {};
|
|
25
25
|
__webpack_require__.r(__webpack_exports__);
|
|
26
26
|
__webpack_require__.d(__webpack_exports__, {
|
|
27
|
-
AssetResolutionError: ()=>
|
|
28
|
-
|
|
29
|
-
inferAssetKind: ()=>external_infer_kind_cjs_namespaceObject.inferAssetKind,
|
|
30
|
-
createIRAssetResolver: ()=>external_resolver_cjs_namespaceObject.createIRAssetResolver,
|
|
31
|
-
resolveAssets: ()=>external_resolver_cjs_namespaceObject.resolveAssets,
|
|
27
|
+
AssetResolutionError: ()=>errors_cjs_namespaceObject.AssetResolutionError,
|
|
28
|
+
AssetValidationError: ()=>errors_cjs_namespaceObject.AssetValidationError,
|
|
32
29
|
createAssetManagerPlugin: ()=>external_plugin_cjs_namespaceObject.createAssetManagerPlugin,
|
|
33
|
-
|
|
34
|
-
createAssetRegistry: ()=>
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
getAssetRegistry: ()=>external_plugin_cjs_namespaceObject.getAssetRegistry,
|
|
38
|
-
createStudioAssetSource: ()=>external_studio_asset_source_cjs_namespaceObject.createStudioAssetSource,
|
|
39
|
-
inferStudioAssetKind: ()=>external_studio_asset_source_cjs_namespaceObject.inferStudioAssetKind,
|
|
30
|
+
createAssetReference: ()=>external_plugin_cjs_namespaceObject.createAssetReference,
|
|
31
|
+
createAssetRegistry: ()=>registry_cjs_namespaceObject.createAssetRegistry,
|
|
32
|
+
createIRAssetResolver: ()=>resolver_cjs_namespaceObject.createIRAssetResolver,
|
|
33
|
+
createStudioAssetSource: ()=>studio_asset_source_cjs_namespaceObject.createStudioAssetSource,
|
|
40
34
|
dataUrlUploader: ()=>data_url_cjs_namespaceObject.dataUrlUploader,
|
|
35
|
+
getAssetRegistry: ()=>external_plugin_cjs_namespaceObject.getAssetRegistry,
|
|
36
|
+
getRequiredCsp: ()=>csp_cjs_namespaceObject.getRequiredCsp,
|
|
41
37
|
inMemoryUploader: ()=>in_memory_cjs_namespaceObject.inMemoryUploader,
|
|
42
|
-
|
|
38
|
+
inferAssetKind: ()=>infer_kind_cjs_namespaceObject.inferAssetKind,
|
|
39
|
+
inferStudioAssetKind: ()=>studio_asset_source_cjs_namespaceObject.inferStudioAssetKind,
|
|
40
|
+
resolveAssets: ()=>resolver_cjs_namespaceObject.resolveAssets,
|
|
41
|
+
uploadAsset: ()=>external_plugin_cjs_namespaceObject.uploadAsset,
|
|
42
|
+
validateUploadResult: ()=>validate_upload_result_cjs_namespaceObject.validateUploadResult
|
|
43
43
|
});
|
|
44
44
|
const data_url_cjs_namespaceObject = require("./adapters/data-url.cjs");
|
|
45
45
|
const in_memory_cjs_namespaceObject = require("./adapters/in-memory.cjs");
|
|
46
|
-
const external_csp_cjs_namespaceObject = require("./csp.cjs");
|
|
47
|
-
const external_errors_cjs_namespaceObject = require("./errors.cjs");
|
|
48
|
-
const external_infer_kind_cjs_namespaceObject = require("./infer-kind.cjs");
|
|
49
46
|
const external_plugin_cjs_namespaceObject = require("./plugin.cjs");
|
|
50
|
-
const
|
|
51
|
-
const
|
|
52
|
-
const
|
|
53
|
-
const
|
|
47
|
+
const csp_cjs_namespaceObject = require("./utils/csp.cjs");
|
|
48
|
+
const errors_cjs_namespaceObject = require("./utils/errors.cjs");
|
|
49
|
+
const infer_kind_cjs_namespaceObject = require("./utils/infer-kind.cjs");
|
|
50
|
+
const registry_cjs_namespaceObject = require("./utils/registry.cjs");
|
|
51
|
+
const resolver_cjs_namespaceObject = require("./utils/resolver.cjs");
|
|
52
|
+
const studio_asset_source_cjs_namespaceObject = require("./utils/studio-asset-source.cjs");
|
|
53
|
+
const validate_upload_result_cjs_namespaceObject = require("./utils/validate-upload-result.cjs");
|
|
54
54
|
exports.AssetResolutionError = __webpack_exports__.AssetResolutionError;
|
|
55
55
|
exports.AssetValidationError = __webpack_exports__.AssetValidationError;
|
|
56
56
|
exports.createAssetManagerPlugin = __webpack_exports__.createAssetManagerPlugin;
|
package/dist/index.d.cts
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
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 type { RequiredCsp, RequiredCspOptions, S3CspOptions } from "./csp.js";
|
|
5
|
-
export { getRequiredCsp } from "./csp.js";
|
|
6
|
-
export type { AssetResolutionErrorCode } from "./errors.js";
|
|
7
|
-
export { AssetResolutionError, AssetValidationError } from "./errors.js";
|
|
8
|
-
export { inferAssetKind } from "./infer-kind.js";
|
|
9
4
|
export { createAssetManagerPlugin, createAssetReference, getAssetRegistry, uploadAsset, } from "./plugin.js";
|
|
10
|
-
export {
|
|
11
|
-
export type {
|
|
12
|
-
export {
|
|
13
|
-
export type {
|
|
14
|
-
export {
|
|
15
|
-
export
|
|
16
|
-
export
|
|
17
|
-
export {
|
|
5
|
+
export type { AssetKind, AssetManagerOptions, AssetMeta, AssetRegistry, AssetRegistryListener, AssetSearchOptions, AssetSearchPage, UploadAdapter, UploadAdapterOptions, UploadResult, } from "./types/types.js";
|
|
6
|
+
export type { RequiredCsp, RequiredCspOptions, S3CspOptions, } from "./utils/csp.js";
|
|
7
|
+
export { getRequiredCsp } from "./utils/csp.js";
|
|
8
|
+
export type { AssetResolutionErrorCode } from "./utils/errors.js";
|
|
9
|
+
export { AssetResolutionError, AssetValidationError } from "./utils/errors.js";
|
|
10
|
+
export { inferAssetKind } from "./utils/infer-kind.js";
|
|
11
|
+
export { createAssetRegistry } from "./utils/registry.js";
|
|
12
|
+
export type { CreateIRAssetResolverOptions } from "./utils/resolver.js";
|
|
13
|
+
export { createIRAssetResolver, resolveAssets } from "./utils/resolver.js";
|
|
14
|
+
export type { CreateStudioAssetSourceOptions } from "./utils/studio-asset-source.js";
|
|
15
|
+
export { createStudioAssetSource, inferStudioAssetKind, } from "./utils/studio-asset-source.js";
|
|
16
|
+
export type { ValidateUploadResultOptions } from "./utils/validate-upload-result.js";
|
|
17
|
+
export { validateUploadResult } from "./utils/validate-upload-result.js";
|
|
18
18
|
//# sourceMappingURL=index.d.cts.map
|
package/dist/index.d.cts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.cts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,sBAAsB,EAAE,MAAM,wBAAwB,CAAC;AACrE,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAC3D,
|
|
1
|
+
{"version":3,"file":"index.d.cts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,sBAAsB,EAAE,MAAM,wBAAwB,CAAC;AACrE,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAC3D,OAAO,EACN,wBAAwB,EACxB,oBAAoB,EACpB,gBAAgB,EAChB,WAAW,GACX,MAAM,aAAa,CAAC;AACrB,YAAY,EACX,SAAS,EACT,mBAAmB,EACnB,SAAS,EACT,aAAa,EACb,qBAAqB,EACrB,kBAAkB,EAClB,eAAe,EACf,aAAa,EACb,oBAAoB,EACpB,YAAY,GACZ,MAAM,kBAAkB,CAAC;AAC1B,YAAY,EACX,WAAW,EACX,kBAAkB,EAClB,YAAY,GACZ,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAChD,YAAY,EAAE,wBAAwB,EAAE,MAAM,mBAAmB,CAAC;AAClE,OAAO,EAAE,oBAAoB,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AAC/E,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAC1D,YAAY,EAAE,4BAA4B,EAAE,MAAM,qBAAqB,CAAC;AACxE,OAAO,EAAE,qBAAqB,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAC3E,YAAY,EAAE,8BAA8B,EAAE,MAAM,gCAAgC,CAAC;AACrF,OAAO,EACN,uBAAuB,EACvB,oBAAoB,GACpB,MAAM,gCAAgC,CAAC;AACxC,YAAY,EAAE,2BAA2B,EAAE,MAAM,mCAAmC,CAAC;AACrF,OAAO,EAAE,oBAAoB,EAAE,MAAM,mCAAmC,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
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 type { RequiredCsp, RequiredCspOptions, S3CspOptions } from "./csp.js";
|
|
5
|
-
export { getRequiredCsp } from "./csp.js";
|
|
6
|
-
export type { AssetResolutionErrorCode } from "./errors.js";
|
|
7
|
-
export { AssetResolutionError, AssetValidationError } from "./errors.js";
|
|
8
|
-
export { inferAssetKind } from "./infer-kind.js";
|
|
9
4
|
export { createAssetManagerPlugin, createAssetReference, getAssetRegistry, uploadAsset, } from "./plugin.js";
|
|
10
|
-
export {
|
|
11
|
-
export type {
|
|
12
|
-
export {
|
|
13
|
-
export type {
|
|
14
|
-
export {
|
|
15
|
-
export
|
|
16
|
-
export
|
|
17
|
-
export {
|
|
5
|
+
export type { AssetKind, AssetManagerOptions, AssetMeta, AssetRegistry, AssetRegistryListener, AssetSearchOptions, AssetSearchPage, UploadAdapter, UploadAdapterOptions, UploadResult, } from "./types/types.js";
|
|
6
|
+
export type { RequiredCsp, RequiredCspOptions, S3CspOptions, } from "./utils/csp.js";
|
|
7
|
+
export { getRequiredCsp } from "./utils/csp.js";
|
|
8
|
+
export type { AssetResolutionErrorCode } from "./utils/errors.js";
|
|
9
|
+
export { AssetResolutionError, AssetValidationError } from "./utils/errors.js";
|
|
10
|
+
export { inferAssetKind } from "./utils/infer-kind.js";
|
|
11
|
+
export { createAssetRegistry } from "./utils/registry.js";
|
|
12
|
+
export type { CreateIRAssetResolverOptions } from "./utils/resolver.js";
|
|
13
|
+
export { createIRAssetResolver, resolveAssets } from "./utils/resolver.js";
|
|
14
|
+
export type { CreateStudioAssetSourceOptions } from "./utils/studio-asset-source.js";
|
|
15
|
+
export { createStudioAssetSource, inferStudioAssetKind, } from "./utils/studio-asset-source.js";
|
|
16
|
+
export type { ValidateUploadResultOptions } from "./utils/validate-upload-result.js";
|
|
17
|
+
export { validateUploadResult } from "./utils/validate-upload-result.js";
|
|
18
18
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,sBAAsB,EAAE,MAAM,wBAAwB,CAAC;AACrE,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAC3D,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,sBAAsB,EAAE,MAAM,wBAAwB,CAAC;AACrE,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAC3D,OAAO,EACN,wBAAwB,EACxB,oBAAoB,EACpB,gBAAgB,EAChB,WAAW,GACX,MAAM,aAAa,CAAC;AACrB,YAAY,EACX,SAAS,EACT,mBAAmB,EACnB,SAAS,EACT,aAAa,EACb,qBAAqB,EACrB,kBAAkB,EAClB,eAAe,EACf,aAAa,EACb,oBAAoB,EACpB,YAAY,GACZ,MAAM,kBAAkB,CAAC;AAC1B,YAAY,EACX,WAAW,EACX,kBAAkB,EAClB,YAAY,GACZ,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAChD,YAAY,EAAE,wBAAwB,EAAE,MAAM,mBAAmB,CAAC;AAClE,OAAO,EAAE,oBAAoB,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AAC/E,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAC1D,YAAY,EAAE,4BAA4B,EAAE,MAAM,qBAAqB,CAAC;AACxE,OAAO,EAAE,qBAAqB,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAC3E,YAAY,EAAE,8BAA8B,EAAE,MAAM,gCAAgC,CAAC;AACrF,OAAO,EACN,uBAAuB,EACvB,oBAAoB,GACpB,MAAM,gCAAgC,CAAC;AACxC,YAAY,EAAE,2BAA2B,EAAE,MAAM,mCAAmC,CAAC;AACrF,OAAO,EAAE,oBAAoB,EAAE,MAAM,mCAAmC,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
export { dataUrlUploader } from "./adapters/data-url.js";
|
|
2
2
|
export { inMemoryUploader } from "./adapters/in-memory.js";
|
|
3
|
-
export { getRequiredCsp } from "./csp.js";
|
|
4
|
-
export { AssetResolutionError, AssetValidationError } from "./errors.js";
|
|
5
|
-
export { inferAssetKind } from "./infer-kind.js";
|
|
6
3
|
export { createAssetManagerPlugin, createAssetReference, getAssetRegistry, uploadAsset } from "./plugin.js";
|
|
7
|
-
export {
|
|
8
|
-
export {
|
|
9
|
-
export {
|
|
10
|
-
export {
|
|
4
|
+
export { getRequiredCsp } from "./utils/csp.js";
|
|
5
|
+
export { AssetResolutionError, AssetValidationError } from "./utils/errors.js";
|
|
6
|
+
export { inferAssetKind } from "./utils/infer-kind.js";
|
|
7
|
+
export { createAssetRegistry } from "./utils/registry.js";
|
|
8
|
+
export { createIRAssetResolver, resolveAssets } from "./utils/resolver.js";
|
|
9
|
+
export { createStudioAssetSource, inferStudioAssetKind } from "./utils/studio-asset-source.js";
|
|
10
|
+
export { validateUploadResult } from "./utils/validate-upload-result.js";
|
package/dist/plugin.cjs
CHANGED
|
@@ -33,36 +33,34 @@ var __webpack_require__ = {};
|
|
|
33
33
|
var __webpack_exports__ = {};
|
|
34
34
|
__webpack_require__.r(__webpack_exports__);
|
|
35
35
|
__webpack_require__.d(__webpack_exports__, {
|
|
36
|
-
uploadAsset: ()=>uploadAsset,
|
|
37
|
-
validateSelectedFile: ()=>validateSelectedFile,
|
|
38
36
|
createAssetManagerPlugin: ()=>createAssetManagerPlugin,
|
|
37
|
+
createAssetReference: ()=>asset_reference_cjs_namespaceObject.createAssetReference,
|
|
39
38
|
getAssetRegistry: ()=>getAssetRegistry,
|
|
40
|
-
|
|
39
|
+
uploadAsset: ()=>uploadAsset,
|
|
40
|
+
validateSelectedFile: ()=>validateSelectedFile
|
|
41
41
|
});
|
|
42
|
-
const
|
|
43
|
-
var
|
|
44
|
-
const
|
|
45
|
-
const
|
|
46
|
-
const
|
|
47
|
-
const
|
|
48
|
-
const
|
|
49
|
-
const
|
|
50
|
-
const
|
|
51
|
-
const
|
|
42
|
+
const config_json_namespaceObject = require("../meta/config.json");
|
|
43
|
+
var config_json_default = /*#__PURE__*/ __webpack_require__.n(config_json_namespaceObject);
|
|
44
|
+
const asset_reference_cjs_namespaceObject = require("./utils/asset-reference.cjs");
|
|
45
|
+
const errors_cjs_namespaceObject = require("./utils/errors.cjs");
|
|
46
|
+
const header_action_cjs_namespaceObject = require("./utils/header-action.cjs");
|
|
47
|
+
const infer_kind_cjs_namespaceObject = require("./utils/infer-kind.cjs");
|
|
48
|
+
const registry_cjs_namespaceObject = require("./utils/registry.cjs");
|
|
49
|
+
const resolver_cjs_namespaceObject = require("./utils/resolver.cjs");
|
|
50
|
+
const studio_asset_source_cjs_namespaceObject = require("./utils/studio-asset-source.cjs");
|
|
51
|
+
const validate_upload_result_cjs_namespaceObject = require("./utils/validate-upload-result.cjs");
|
|
52
|
+
const external_version_cjs_namespaceObject = require("./version.cjs");
|
|
52
53
|
const META = {
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
version: external_package_json_default().version,
|
|
56
|
-
coreVersion: "^0.1.0-alpha",
|
|
57
|
-
description: "Headless asset upload plugin with host-provided persistence and a separate React UI subpath."
|
|
54
|
+
...config_json_default(),
|
|
55
|
+
version: external_version_cjs_namespaceObject.ASSET_MANAGER_VERSION
|
|
58
56
|
};
|
|
59
57
|
const stateByToken = new WeakMap();
|
|
60
58
|
const tokenByContext = new WeakMap();
|
|
61
59
|
function createAssetManagerPlugin(options) {
|
|
62
60
|
const token = {};
|
|
63
|
-
const registry = (0,
|
|
61
|
+
const registry = (0, registry_cjs_namespaceObject.createAssetRegistry)();
|
|
64
62
|
const normalizedOptions = normalizeOptions(options);
|
|
65
|
-
const assetResolver = (0,
|
|
63
|
+
const assetResolver = (0, resolver_cjs_namespaceObject.createIRAssetResolver)({
|
|
66
64
|
registry,
|
|
67
65
|
dataUrlAllowlistOptIn: normalizedOptions.dataUrlAllowlistOptIn,
|
|
68
66
|
allowMixedScriptHostnames: normalizedOptions.allowMixedScriptHostnames
|
|
@@ -73,7 +71,7 @@ function createAssetManagerPlugin(options) {
|
|
|
73
71
|
const registration = {
|
|
74
72
|
meta: META,
|
|
75
73
|
headerActions: [
|
|
76
|
-
|
|
74
|
+
header_action_cjs_namespaceObject.uploadAssetAction
|
|
77
75
|
],
|
|
78
76
|
hooks: {
|
|
79
77
|
onInit (initCtx) {
|
|
@@ -85,7 +83,7 @@ function createAssetManagerPlugin(options) {
|
|
|
85
83
|
});
|
|
86
84
|
tokenByContext.set(initCtx, token);
|
|
87
85
|
initCtx.registerAssetResolver(assetResolver);
|
|
88
|
-
const studioAssetSource = (0,
|
|
86
|
+
const studioAssetSource = (0, studio_asset_source_cjs_namespaceObject.createStudioAssetSource)({
|
|
89
87
|
registry,
|
|
90
88
|
upload: (file, opts)=>uploadAsset(initCtx, file, opts?.signal),
|
|
91
89
|
...normalizedOptions.getThumbnail ? {
|
|
@@ -120,18 +118,18 @@ async function uploadAsset(ctx, file, signal) {
|
|
|
120
118
|
signal
|
|
121
119
|
} : void 0);
|
|
122
120
|
if (signal?.aborted) throw makePluginAbortError();
|
|
123
|
-
const validated = (0,
|
|
121
|
+
const validated = (0, validate_upload_result_cjs_namespaceObject.validateUploadResult)(mergeUploadMeta(uploadResult, file), options);
|
|
124
122
|
const tagged = withDerivedTags(validated, file);
|
|
125
123
|
const stored = registry.register(tagged);
|
|
126
124
|
dispatchAssetReference(ctx, stored);
|
|
127
125
|
ctx.emit("asset-manager:uploaded", {
|
|
128
126
|
asset: stored,
|
|
129
|
-
reference: (0,
|
|
127
|
+
reference: (0, asset_reference_cjs_namespaceObject.createAssetReference)(stored.id)
|
|
130
128
|
});
|
|
131
129
|
return stored;
|
|
132
130
|
} catch (error) {
|
|
133
131
|
if (isAbortLikeError(error) || signal?.aborted) throw error;
|
|
134
|
-
const normalizedError = error instanceof
|
|
132
|
+
const normalizedError = error instanceof errors_cjs_namespaceObject.AssetValidationError ? error : new errors_cjs_namespaceObject.AssetValidationError("UPLOAD_FAILED", error instanceof Error ? error.message : String(error), {
|
|
135
133
|
cause: error
|
|
136
134
|
});
|
|
137
135
|
ctx.emit("asset-manager:error", {
|
|
@@ -145,10 +143,10 @@ async function uploadAsset(ctx, file, signal) {
|
|
|
145
143
|
}
|
|
146
144
|
}
|
|
147
145
|
function validateSelectedFile(file, options) {
|
|
148
|
-
if (void 0 !== options.maxFileSize && file.size > options.maxFileSize) throw new
|
|
146
|
+
if (void 0 !== options.maxFileSize && file.size > options.maxFileSize) throw new errors_cjs_namespaceObject.AssetValidationError("FILE_TOO_LARGE", `File size ${file.size} bytes exceeds the configured maxFileSize of ${options.maxFileSize} bytes.`);
|
|
149
147
|
if (options.acceptedMimeTypes && options.acceptedMimeTypes.length > 0 && !mimeTypeMatches(file.type, options.acceptedMimeTypes)) {
|
|
150
148
|
const mimeType = file.type || "unknown";
|
|
151
|
-
throw new
|
|
149
|
+
throw new errors_cjs_namespaceObject.AssetValidationError("UNSUPPORTED_MIME_TYPE", `File MIME type "${mimeType}" is not in acceptedMimeTypes.`);
|
|
152
150
|
}
|
|
153
151
|
}
|
|
154
152
|
function getRuntimeState(ctx) {
|
|
@@ -170,7 +168,7 @@ function normalizeOptions(options) {
|
|
|
170
168
|
function withDerivedTags(asset, file) {
|
|
171
169
|
if (void 0 !== asset.tags && asset.tags.length > 0) return asset;
|
|
172
170
|
const tags = new Set();
|
|
173
|
-
const kind = (0,
|
|
171
|
+
const kind = (0, infer_kind_cjs_namespaceObject.inferAssetKind)(asset);
|
|
174
172
|
if ("other" !== kind) tags.add(kind);
|
|
175
173
|
for (const token of filenameTokens(file.name)){
|
|
176
174
|
if (tags.size >= 3) break;
|
|
@@ -240,7 +238,7 @@ function toIRAsset(asset) {
|
|
|
240
238
|
return {
|
|
241
239
|
id: asset.id,
|
|
242
240
|
kind: inferIRAssetKind(asset.meta?.mimeType, asset.url),
|
|
243
|
-
url: (0,
|
|
241
|
+
url: (0, asset_reference_cjs_namespaceObject.createAssetReference)(asset.id),
|
|
244
242
|
...asset.meta ? {
|
|
245
243
|
meta: asset.meta
|
|
246
244
|
} : {}
|
package/dist/plugin.d.cts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { StudioPlugin, StudioPluginContext } from "@anvilkit/core/types";
|
|
2
2
|
import type { Config as PuckConfig } from "@puckeditor/core";
|
|
3
|
-
import {
|
|
4
|
-
import
|
|
3
|
+
import type { AssetManagerOptions, AssetRegistry, UploadResult } from "./types/types.js";
|
|
4
|
+
import { createAssetReference } from "./utils/asset-reference.js";
|
|
5
5
|
export { createAssetReference };
|
|
6
6
|
export declare function createAssetManagerPlugin<UserConfig extends PuckConfig = PuckConfig>(options: AssetManagerOptions): StudioPlugin<UserConfig>;
|
|
7
7
|
export declare function getAssetRegistry<UserConfig extends PuckConfig = PuckConfig>(ctx: StudioPluginContext<UserConfig>): AssetRegistry | undefined;
|
package/dist/plugin.d.cts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.d.cts","sourceRoot":"","sources":["../src/plugin.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"plugin.d.cts","sourceRoot":"","sources":["../src/plugin.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAEX,YAAY,EACZ,mBAAmB,EAEnB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,KAAK,EAAE,MAAM,IAAI,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAG7D,OAAO,KAAK,EACX,mBAAmB,EAEnB,aAAa,EACb,YAAY,EACZ,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,oBAAoB,EAAE,MAAM,4BAA4B,CAAC;AAUlE,OAAO,EAAE,oBAAoB,EAAE,CAAC;AA0BhC,wBAAgB,wBAAwB,CACvC,UAAU,SAAS,UAAU,GAAG,UAAU,EACzC,OAAO,EAAE,mBAAmB,GAAG,YAAY,CAAC,UAAU,CAAC,CAwDxD;AAED,wBAAgB,gBAAgB,CAAC,UAAU,SAAS,UAAU,GAAG,UAAU,EAC1E,GAAG,EAAE,mBAAmB,CAAC,UAAU,CAAC,GAClC,aAAa,GAAG,SAAS,CAG3B;AAED,wBAAsB,WAAW,CAAC,UAAU,SAAS,UAAU,GAAG,UAAU,EAC3E,GAAG,EAAE,mBAAmB,CAAC,UAAU,CAAC,EACpC,IAAI,EAAE,IAAI,EACV,MAAM,CAAC,EAAE,WAAW,GAClB,OAAO,CAAC,YAAY,CAAC,CAwDvB;AAED,wBAAgB,oBAAoB,CACnC,IAAI,EAAE,IAAI,EACV,OAAO,EAAE,IAAI,CAAC,mBAAmB,EAAE,mBAAmB,GAAG,aAAa,CAAC,GACrE,IAAI,CAmBN"}
|
package/dist/plugin.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { StudioPlugin, StudioPluginContext } from "@anvilkit/core/types";
|
|
2
2
|
import type { Config as PuckConfig } from "@puckeditor/core";
|
|
3
|
-
import {
|
|
4
|
-
import
|
|
3
|
+
import type { AssetManagerOptions, AssetRegistry, UploadResult } from "./types/types.js";
|
|
4
|
+
import { createAssetReference } from "./utils/asset-reference.js";
|
|
5
5
|
export { createAssetReference };
|
|
6
6
|
export declare function createAssetManagerPlugin<UserConfig extends PuckConfig = PuckConfig>(options: AssetManagerOptions): StudioPlugin<UserConfig>;
|
|
7
7
|
export declare function getAssetRegistry<UserConfig extends PuckConfig = PuckConfig>(ctx: StudioPluginContext<UserConfig>): AssetRegistry | undefined;
|
package/dist/plugin.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../src/plugin.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../src/plugin.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAEX,YAAY,EACZ,mBAAmB,EAEnB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,KAAK,EAAE,MAAM,IAAI,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAG7D,OAAO,KAAK,EACX,mBAAmB,EAEnB,aAAa,EACb,YAAY,EACZ,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,oBAAoB,EAAE,MAAM,4BAA4B,CAAC;AAUlE,OAAO,EAAE,oBAAoB,EAAE,CAAC;AA0BhC,wBAAgB,wBAAwB,CACvC,UAAU,SAAS,UAAU,GAAG,UAAU,EACzC,OAAO,EAAE,mBAAmB,GAAG,YAAY,CAAC,UAAU,CAAC,CAwDxD;AAED,wBAAgB,gBAAgB,CAAC,UAAU,SAAS,UAAU,GAAG,UAAU,EAC1E,GAAG,EAAE,mBAAmB,CAAC,UAAU,CAAC,GAClC,aAAa,GAAG,SAAS,CAG3B;AAED,wBAAsB,WAAW,CAAC,UAAU,SAAS,UAAU,GAAG,UAAU,EAC3E,GAAG,EAAE,mBAAmB,CAAC,UAAU,CAAC,EACpC,IAAI,EAAE,IAAI,EACV,MAAM,CAAC,EAAE,WAAW,GAClB,OAAO,CAAC,YAAY,CAAC,CAwDvB;AAED,wBAAgB,oBAAoB,CACnC,IAAI,EAAE,IAAI,EACV,OAAO,EAAE,IAAI,CAAC,mBAAmB,EAAE,mBAAmB,GAAG,aAAa,CAAC,GACrE,IAAI,CAmBN"}
|