@anvilkit/plugin-asset-manager 0.1.6 → 0.1.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +28 -20
- package/dist/adapters/data-url.d.cts +13 -0
- package/dist/adapters/data-url.d.cts.map +1 -1
- package/dist/adapters/data-url.d.ts +13 -0
- package/dist/adapters/data-url.d.ts.map +1 -1
- package/dist/adapters/in-memory.d.cts +8 -1
- package/dist/adapters/in-memory.d.cts.map +1 -1
- package/dist/adapters/in-memory.d.ts +8 -1
- package/dist/adapters/in-memory.d.ts.map +1 -1
- package/dist/i18n/entry.cjs +75 -0
- package/dist/i18n/entry.d.cts +15 -0
- package/dist/i18n/entry.d.cts.map +1 -0
- package/dist/i18n/entry.d.ts +15 -0
- package/dist/i18n/entry.d.ts.map +1 -0
- package/dist/i18n/entry.js +29 -0
- package/dist/i18n/provider.cjs +49 -0
- package/dist/i18n/provider.d.cts +20 -0
- package/dist/i18n/provider.d.cts.map +1 -0
- package/dist/i18n/provider.d.ts +20 -0
- package/dist/i18n/provider.d.ts.map +1 -0
- package/dist/i18n/provider.js +11 -0
- package/dist/index.cjs +7 -0
- package/dist/index.d.cts +11 -3
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.ts +11 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -1
- package/dist/plugin.cjs +70 -5
- package/dist/plugin.d.cts +3 -2
- package/dist/plugin.d.cts.map +1 -1
- package/dist/plugin.d.ts +3 -2
- package/dist/plugin.d.ts.map +1 -1
- package/dist/plugin.js +70 -5
- package/dist/sources/composite-source.cjs +138 -0
- package/dist/sources/composite-source.d.cts +39 -0
- package/dist/sources/composite-source.d.cts.map +1 -0
- package/dist/sources/composite-source.d.ts +39 -0
- package/dist/sources/composite-source.d.ts.map +1 -0
- package/dist/sources/composite-source.js +100 -0
- package/dist/sources/federated-search.cjs +173 -0
- package/dist/sources/federated-search.d.cts +33 -0
- package/dist/sources/federated-search.d.cts.map +1 -0
- package/dist/sources/federated-search.d.ts +33 -0
- package/dist/sources/federated-search.d.ts.map +1 -0
- package/dist/sources/federated-search.js +123 -0
- package/dist/sources/provider.cjs +18 -0
- package/dist/sources/provider.d.cts +51 -0
- package/dist/sources/provider.d.cts.map +1 -0
- package/dist/sources/provider.d.ts +51 -0
- package/dist/sources/provider.d.ts.map +1 -0
- package/dist/sources/provider.js +1 -0
- package/dist/sources/unsplash/client.cjs +189 -0
- package/dist/sources/unsplash/client.d.cts +87 -0
- package/dist/sources/unsplash/client.d.cts.map +1 -0
- package/dist/sources/unsplash/client.d.ts +87 -0
- package/dist/sources/unsplash/client.d.ts.map +1 -0
- package/dist/sources/unsplash/client.js +151 -0
- package/dist/sources/unsplash/index.cjs +194 -0
- package/dist/sources/unsplash/index.d.cts +16 -0
- package/dist/sources/unsplash/index.d.cts.map +1 -0
- package/dist/sources/unsplash/index.d.ts +16 -0
- package/dist/sources/unsplash/index.d.ts.map +1 -0
- package/dist/sources/unsplash/index.js +150 -0
- package/dist/sources/unsplash/themes.cjs +141 -0
- package/dist/sources/unsplash/themes.d.cts +18 -0
- package/dist/sources/unsplash/themes.d.cts.map +1 -0
- package/dist/sources/unsplash/themes.d.ts +18 -0
- package/dist/sources/unsplash/themes.d.ts.map +1 -0
- package/dist/sources/unsplash/themes.js +93 -0
- package/dist/sources/unsplash/throttle-cache.cjs +86 -0
- package/dist/sources/unsplash/throttle-cache.d.cts +25 -0
- package/dist/sources/unsplash/throttle-cache.d.cts.map +1 -0
- package/dist/sources/unsplash/throttle-cache.d.ts +25 -0
- package/dist/sources/unsplash/throttle-cache.d.ts.map +1 -0
- package/dist/sources/unsplash/throttle-cache.js +45 -0
- package/dist/types/categories.cjs +18 -0
- package/dist/types/categories.d.cts +48 -0
- package/dist/types/categories.d.cts.map +1 -0
- package/dist/types/categories.d.ts +48 -0
- package/dist/types/categories.d.ts.map +1 -0
- package/dist/types/categories.js +1 -0
- package/dist/types/data-source.cjs +18 -0
- package/dist/types/data-source.d.cts +59 -0
- package/dist/types/data-source.d.cts.map +1 -0
- package/dist/types/data-source.d.ts +59 -0
- package/dist/types/data-source.d.ts.map +1 -0
- package/dist/types/data-source.js +1 -0
- package/dist/types/filter.cjs +18 -0
- package/dist/types/filter.d.cts +55 -0
- package/dist/types/filter.d.cts.map +1 -0
- package/dist/types/filter.d.ts +55 -0
- package/dist/types/filter.d.ts.map +1 -0
- package/dist/types/filter.js +1 -0
- package/dist/types/folders.cjs +42 -0
- package/dist/types/folders.d.cts +46 -0
- package/dist/types/folders.d.cts.map +1 -0
- package/dist/types/folders.d.ts +46 -0
- package/dist/types/folders.d.ts.map +1 -0
- package/dist/types/folders.js +4 -0
- package/dist/types/options.cjs +18 -0
- package/dist/types/options.d.cts +68 -0
- package/dist/types/options.d.cts.map +1 -0
- package/dist/types/options.d.ts +68 -0
- package/dist/types/options.d.ts.map +1 -0
- package/dist/types/options.js +1 -0
- package/dist/types/types.d.cts +21 -27
- package/dist/types/types.d.cts.map +1 -1
- package/dist/types/types.d.ts +21 -27
- package/dist/types/types.d.ts.map +1 -1
- package/dist/types/unsplash.cjs +18 -0
- package/dist/types/unsplash.d.cts +60 -0
- package/dist/types/unsplash.d.cts.map +1 -0
- package/dist/types/unsplash.d.ts +60 -0
- package/dist/types/unsplash.d.ts.map +1 -0
- package/dist/types/unsplash.js +1 -0
- package/dist/ui/AssetBrowser.cjs +183 -121
- package/dist/ui/AssetBrowser.d.cts +12 -1
- package/dist/ui/AssetBrowser.d.cts.map +1 -1
- package/dist/ui/AssetBrowser.d.ts +12 -1
- package/dist/ui/AssetBrowser.d.ts.map +1 -1
- package/dist/ui/AssetBrowser.js +183 -121
- package/dist/ui/AssetCommandPalette.cjs +20 -18
- package/dist/ui/AssetCommandPalette.d.cts.map +1 -1
- package/dist/ui/AssetCommandPalette.d.ts.map +1 -1
- package/dist/ui/AssetCommandPalette.js +20 -18
- package/dist/ui/AssetManagerUI.cjs +31 -17
- package/dist/ui/AssetManagerUI.d.cts +19 -3
- package/dist/ui/AssetManagerUI.d.cts.map +1 -1
- package/dist/ui/AssetManagerUI.d.ts +19 -3
- package/dist/ui/AssetManagerUI.d.ts.map +1 -1
- package/dist/ui/AssetManagerUI.js +31 -17
- package/dist/ui/DeleteAssetDialog.cjs +5 -3
- package/dist/ui/DeleteAssetDialog.d.cts.map +1 -1
- package/dist/ui/DeleteAssetDialog.d.ts.map +1 -1
- package/dist/ui/DeleteAssetDialog.js +5 -3
- package/dist/ui/DeleteFolderDialog.cjs +80 -0
- package/dist/ui/DeleteFolderDialog.d.cts +11 -0
- package/dist/ui/DeleteFolderDialog.d.cts.map +1 -0
- package/dist/ui/DeleteFolderDialog.d.ts +11 -0
- package/dist/ui/DeleteFolderDialog.d.ts.map +1 -0
- package/dist/ui/DeleteFolderDialog.js +42 -0
- package/dist/ui/EmptyFolderState.cjs +56 -0
- package/dist/ui/EmptyFolderState.d.cts +6 -0
- package/dist/ui/EmptyFolderState.d.cts.map +1 -0
- package/dist/ui/EmptyFolderState.d.ts +6 -0
- package/dist/ui/EmptyFolderState.d.ts.map +1 -0
- package/dist/ui/EmptyFolderState.js +18 -0
- package/dist/ui/FolderBreadcrumb.cjs +76 -0
- package/dist/ui/FolderBreadcrumb.d.cts +9 -0
- package/dist/ui/FolderBreadcrumb.d.cts.map +1 -0
- package/dist/ui/FolderBreadcrumb.d.ts +9 -0
- package/dist/ui/FolderBreadcrumb.d.ts.map +1 -0
- package/dist/ui/FolderBreadcrumb.js +38 -0
- package/dist/ui/FolderNameDialog.cjs +105 -0
- package/dist/ui/FolderNameDialog.d.cts +14 -0
- package/dist/ui/FolderNameDialog.d.cts.map +1 -0
- package/dist/ui/FolderNameDialog.d.ts +14 -0
- package/dist/ui/FolderNameDialog.d.ts.map +1 -0
- package/dist/ui/FolderNameDialog.js +67 -0
- package/dist/ui/FolderTree.cjs +85 -0
- package/dist/ui/FolderTree.d.cts +13 -0
- package/dist/ui/FolderTree.d.cts.map +1 -0
- package/dist/ui/FolderTree.d.ts +13 -0
- package/dist/ui/FolderTree.d.ts.map +1 -0
- package/dist/ui/FolderTree.js +44 -0
- package/dist/ui/MetadataPanel.cjs +23 -17
- package/dist/ui/MetadataPanel.d.cts.map +1 -1
- package/dist/ui/MetadataPanel.d.ts.map +1 -1
- package/dist/ui/MetadataPanel.js +23 -17
- package/dist/ui/MoveTargetPicker.cjs +87 -0
- package/dist/ui/MoveTargetPicker.d.cts +16 -0
- package/dist/ui/MoveTargetPicker.d.cts.map +1 -0
- package/dist/ui/MoveTargetPicker.d.ts +16 -0
- package/dist/ui/MoveTargetPicker.d.ts.map +1 -0
- package/dist/ui/MoveTargetPicker.js +49 -0
- package/dist/ui/ReplaceAssetDialog.cjs +19 -17
- package/dist/ui/ReplaceAssetDialog.d.cts +2 -1
- package/dist/ui/ReplaceAssetDialog.d.cts.map +1 -1
- package/dist/ui/ReplaceAssetDialog.d.ts +2 -1
- package/dist/ui/ReplaceAssetDialog.d.ts.map +1 -1
- package/dist/ui/ReplaceAssetDialog.js +19 -17
- package/dist/ui/UnsplashPanel.cjs +137 -0
- package/dist/ui/UnsplashPanel.d.cts +28 -0
- package/dist/ui/UnsplashPanel.d.cts.map +1 -0
- package/dist/ui/UnsplashPanel.d.ts +28 -0
- package/dist/ui/UnsplashPanel.d.ts.map +1 -0
- package/dist/ui/UnsplashPanel.js +99 -0
- package/dist/ui/UploadButton.cjs +12 -13
- package/dist/ui/UploadButton.d.cts +9 -2
- package/dist/ui/UploadButton.d.cts.map +1 -1
- package/dist/ui/UploadButton.d.ts +9 -2
- package/dist/ui/UploadButton.d.ts.map +1 -1
- package/dist/ui/UploadButton.js +12 -13
- package/dist/ui/index.cjs +41 -0
- package/dist/ui/index.d.cts +15 -0
- package/dist/ui/index.d.cts.map +1 -1
- package/dist/ui/index.d.ts +15 -0
- package/dist/ui/index.d.ts.map +1 -1
- package/dist/ui/index.js +8 -0
- package/dist/utils/data-source.cjs +190 -0
- package/dist/utils/data-source.d.cts +63 -0
- package/dist/utils/data-source.d.cts.map +1 -0
- package/dist/utils/data-source.d.ts +63 -0
- package/dist/utils/data-source.d.ts.map +1 -0
- package/dist/utils/data-source.js +149 -0
- package/dist/utils/errors.cjs +18 -0
- package/dist/utils/errors.d.cts +27 -0
- package/dist/utils/errors.d.cts.map +1 -1
- package/dist/utils/errors.d.ts +27 -0
- package/dist/utils/errors.d.ts.map +1 -1
- package/dist/utils/errors.js +16 -1
- package/dist/utils/folders.cjs +335 -0
- package/dist/utils/folders.d.cts +54 -0
- package/dist/utils/folders.d.cts.map +1 -0
- package/dist/utils/folders.d.ts +54 -0
- package/dist/utils/folders.d.ts.map +1 -0
- package/dist/utils/folders.js +297 -0
- package/dist/utils/header-action.cjs +1 -1
- package/dist/utils/header-action.d.cts.map +1 -1
- package/dist/utils/header-action.d.ts.map +1 -1
- package/dist/utils/header-action.js +1 -1
- package/dist/utils/registry.cjs +38 -12
- package/dist/utils/registry.d.cts +29 -1
- package/dist/utils/registry.d.cts.map +1 -1
- package/dist/utils/registry.d.ts +29 -1
- package/dist/utils/registry.d.ts.map +1 -1
- package/dist/utils/registry.js +31 -11
- package/dist/utils/resolver.cjs +5 -4
- package/dist/utils/resolver.d.cts.map +1 -1
- package/dist/utils/resolver.d.ts.map +1 -1
- package/dist/utils/resolver.js +5 -4
- package/dist/utils/studio-asset-source.cjs +13 -4
- package/dist/utils/studio-asset-source.d.cts +6 -1
- package/dist/utils/studio-asset-source.d.cts.map +1 -1
- package/dist/utils/studio-asset-source.d.ts +6 -1
- package/dist/utils/studio-asset-source.d.ts.map +1 -1
- package/dist/utils/studio-asset-source.js +9 -3
- package/dist/utils/validate-upload-result.d.cts +2 -1
- package/dist/utils/validate-upload-result.d.cts.map +1 -1
- package/dist/utils/validate-upload-result.d.ts +2 -1
- package/dist/utils/validate-upload-result.d.ts.map +1 -1
- package/dist/version.cjs +1 -1
- package/dist/version.d.cts +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/i18n/messages/en.json +99 -0
- package/i18n/messages/ja.json +99 -0
- package/i18n/messages/ko.json +99 -0
- package/i18n/messages/zh.json +99 -0
- package/meta/config.json +1 -1
- package/package.json +19 -8
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __webpack_require__ = {};
|
|
3
|
+
(()=>{
|
|
4
|
+
__webpack_require__.d = (exports1, getters, values)=>{
|
|
5
|
+
var define = (defs, kind)=>{
|
|
6
|
+
for(var key in defs)if (__webpack_require__.o(defs, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
[kind]: defs[key]
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
define(getters, "get");
|
|
12
|
+
define(values, "value");
|
|
13
|
+
};
|
|
14
|
+
})();
|
|
15
|
+
(()=>{
|
|
16
|
+
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
17
|
+
})();
|
|
18
|
+
(()=>{
|
|
19
|
+
__webpack_require__.r = (exports1)=>{
|
|
20
|
+
if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
21
|
+
value: 'Module'
|
|
22
|
+
});
|
|
23
|
+
Object.defineProperty(exports1, '__esModule', {
|
|
24
|
+
value: true
|
|
25
|
+
});
|
|
26
|
+
};
|
|
27
|
+
})();
|
|
28
|
+
var __webpack_exports__ = {};
|
|
29
|
+
__webpack_require__.r(__webpack_exports__);
|
|
30
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
31
|
+
createLocalProvider: ()=>createLocalProvider,
|
|
32
|
+
decodeCompositeCursor: ()=>decodeCompositeCursor,
|
|
33
|
+
encodeCompositeCursor: ()=>encodeCompositeCursor,
|
|
34
|
+
federatedSearch: ()=>federatedSearch,
|
|
35
|
+
providerCanSatisfy: ()=>providerCanSatisfy
|
|
36
|
+
});
|
|
37
|
+
const infer_kind_cjs_namespaceObject = require("../utils/infer-kind.cjs");
|
|
38
|
+
function toBase64Url(json) {
|
|
39
|
+
return btoa(json).replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/, "");
|
|
40
|
+
}
|
|
41
|
+
function fromBase64Url(token) {
|
|
42
|
+
const padded = token.length % 4 === 0 ? token : token + "=".repeat(4 - token.length % 4);
|
|
43
|
+
return atob(padded.replace(/-/g, "+").replace(/_/g, "/"));
|
|
44
|
+
}
|
|
45
|
+
function encodeCompositeCursor(cursor) {
|
|
46
|
+
return toBase64Url(JSON.stringify(cursor));
|
|
47
|
+
}
|
|
48
|
+
function decodeCompositeCursor(token) {
|
|
49
|
+
if (void 0 === token || "" === token) return {};
|
|
50
|
+
try {
|
|
51
|
+
const parsed = JSON.parse(fromBase64Url(token));
|
|
52
|
+
return "object" == typeof parsed && null !== parsed ? parsed : {};
|
|
53
|
+
} catch {
|
|
54
|
+
return {};
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
function providerCanSatisfy(provider, filter) {
|
|
58
|
+
if (void 0 !== filter.folderId && true !== provider.capabilities.folders) return false;
|
|
59
|
+
return true;
|
|
60
|
+
}
|
|
61
|
+
function createLocalProvider(source, registry, label = "assetManager.source.library") {
|
|
62
|
+
return {
|
|
63
|
+
id: "local",
|
|
64
|
+
label,
|
|
65
|
+
capabilities: {
|
|
66
|
+
searchable: true,
|
|
67
|
+
themed: false,
|
|
68
|
+
mutable: true,
|
|
69
|
+
requiresAttribution: false,
|
|
70
|
+
folders: true
|
|
71
|
+
},
|
|
72
|
+
listThemes: ()=>[],
|
|
73
|
+
search: (filter, page, signal)=>source.list(void 0 !== page ? {
|
|
74
|
+
...filter,
|
|
75
|
+
cursor: page
|
|
76
|
+
} : filter, signal),
|
|
77
|
+
pickResult: async (asset)=>registry.get(asset.id) ?? {
|
|
78
|
+
id: asset.id,
|
|
79
|
+
url: asset.url
|
|
80
|
+
}
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
function sortKey(entry, field) {
|
|
84
|
+
switch(field){
|
|
85
|
+
case "name":
|
|
86
|
+
return (entry.name ?? "").toLowerCase();
|
|
87
|
+
case "size":
|
|
88
|
+
return entry.meta?.size ?? 0;
|
|
89
|
+
case "kind":
|
|
90
|
+
return (0, infer_kind_cjs_namespaceObject.inferAssetKind)(entry);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
function compareEntries(a, b, field) {
|
|
94
|
+
const ka = sortKey(a, field);
|
|
95
|
+
const kb = sortKey(b, field);
|
|
96
|
+
if ("number" == typeof ka && "number" == typeof kb) return ka - kb;
|
|
97
|
+
return String(ka).localeCompare(String(kb));
|
|
98
|
+
}
|
|
99
|
+
function mergePages(pages, filter, carryForward = {}) {
|
|
100
|
+
const field = filter.sort?.field ?? "recent";
|
|
101
|
+
const comparable = "name" === field || "size" === field || "kind" === field;
|
|
102
|
+
const items = pages.flatMap((p)=>[
|
|
103
|
+
...p.page.items
|
|
104
|
+
]);
|
|
105
|
+
if (comparable) {
|
|
106
|
+
const dir = filter.sort?.direction ?? ("name" === field ? "asc" : "desc");
|
|
107
|
+
const sign = "asc" === dir ? 1 : -1;
|
|
108
|
+
items.sort((a, b)=>compareEntries(a, b, field) * sign);
|
|
109
|
+
}
|
|
110
|
+
const total = pages.reduce((n, p)=>n + p.page.total, 0);
|
|
111
|
+
const sourceCursors = {
|
|
112
|
+
...carryForward
|
|
113
|
+
};
|
|
114
|
+
const next = {
|
|
115
|
+
...carryForward
|
|
116
|
+
};
|
|
117
|
+
let hasNext = Object.keys(carryForward).length > 0;
|
|
118
|
+
for (const { provider, page } of pages){
|
|
119
|
+
sourceCursors[provider.id] = page.nextCursor;
|
|
120
|
+
if (void 0 !== page.nextCursor) {
|
|
121
|
+
next[provider.id] = page.nextCursor;
|
|
122
|
+
hasNext = true;
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
return {
|
|
126
|
+
items: Object.freeze(items),
|
|
127
|
+
total,
|
|
128
|
+
nextCursor: hasNext ? encodeCompositeCursor(next) : void 0,
|
|
129
|
+
sourceCursors
|
|
130
|
+
};
|
|
131
|
+
}
|
|
132
|
+
async function federatedSearch(input) {
|
|
133
|
+
const { providers, filter, signal } = input;
|
|
134
|
+
const eligible = providers.filter((p)=>providerCanSatisfy(p, filter));
|
|
135
|
+
const targets = filter.sources && filter.sources.length > 0 ? eligible.filter((p)=>filter.sources?.includes(p.id)) : eligible;
|
|
136
|
+
if (0 === targets.length) return {
|
|
137
|
+
items: Object.freeze([]),
|
|
138
|
+
total: 0,
|
|
139
|
+
nextCursor: void 0
|
|
140
|
+
};
|
|
141
|
+
const cursors = decodeCompositeCursor(filter.cursor);
|
|
142
|
+
const settled = await Promise.allSettled(targets.map((p)=>p.search(filter, cursors[p.id], signal)));
|
|
143
|
+
const ok = [];
|
|
144
|
+
const carryForward = {};
|
|
145
|
+
settled.forEach((result, index)=>{
|
|
146
|
+
const provider = targets[index];
|
|
147
|
+
if (void 0 === provider) return;
|
|
148
|
+
if ("fulfilled" === result.status) ok.push({
|
|
149
|
+
provider,
|
|
150
|
+
page: result.value
|
|
151
|
+
});
|
|
152
|
+
else {
|
|
153
|
+
const incoming = cursors[provider.id];
|
|
154
|
+
if (void 0 !== incoming) carryForward[provider.id] = incoming;
|
|
155
|
+
}
|
|
156
|
+
});
|
|
157
|
+
return mergePages(ok, filter, carryForward);
|
|
158
|
+
}
|
|
159
|
+
exports.createLocalProvider = __webpack_exports__.createLocalProvider;
|
|
160
|
+
exports.decodeCompositeCursor = __webpack_exports__.decodeCompositeCursor;
|
|
161
|
+
exports.encodeCompositeCursor = __webpack_exports__.encodeCompositeCursor;
|
|
162
|
+
exports.federatedSearch = __webpack_exports__.federatedSearch;
|
|
163
|
+
exports.providerCanSatisfy = __webpack_exports__.providerCanSatisfy;
|
|
164
|
+
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
165
|
+
"createLocalProvider",
|
|
166
|
+
"decodeCompositeCursor",
|
|
167
|
+
"encodeCompositeCursor",
|
|
168
|
+
"federatedSearch",
|
|
169
|
+
"providerCanSatisfy"
|
|
170
|
+
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
171
|
+
Object.defineProperty(exports, '__esModule', {
|
|
172
|
+
value: true
|
|
173
|
+
});
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file Federated search across asset source providers (PRD 0002 §9.3).
|
|
3
|
+
*
|
|
4
|
+
* Routes a single-source query to one provider, or federates across many with
|
|
5
|
+
* `Promise.allSettled` (one failing remote never blanks the rest). The page
|
|
6
|
+
* cursor is an OPAQUE composite token carrying one sub-cursor per source, so
|
|
7
|
+
* each provider paginates independently. Comparable sorts (name/size/kind) are
|
|
8
|
+
* k-way merged; `recent`/`relevance` fall back to provider-grouped order
|
|
9
|
+
* (incomparable across heterogeneous sources).
|
|
10
|
+
*/
|
|
11
|
+
import type { AssetFilter, AssetListPage } from "../types/filter.js";
|
|
12
|
+
import type { AssetRegistry } from "../types/types.js";
|
|
13
|
+
import type { ResolvedAssetDataSource } from "../utils/data-source.js";
|
|
14
|
+
import type { AssetSourceProvider } from "./provider.js";
|
|
15
|
+
type CompositeCursor = Record<string, string | undefined>;
|
|
16
|
+
export declare function encodeCompositeCursor(cursor: CompositeCursor): string;
|
|
17
|
+
export declare function decodeCompositeCursor(token: string | undefined): CompositeCursor;
|
|
18
|
+
/** A provider is eligible only if it can satisfy every required axis of the filter. */
|
|
19
|
+
export declare function providerCanSatisfy(provider: AssetSourceProvider, filter: AssetFilter): boolean;
|
|
20
|
+
/** Adapt the resolved (local) data source into an `AssetSourceProvider`. */
|
|
21
|
+
export declare function createLocalProvider(source: ResolvedAssetDataSource, registry: AssetRegistry, label?: string): AssetSourceProvider;
|
|
22
|
+
export interface FederatedSearchInput {
|
|
23
|
+
readonly providers: readonly AssetSourceProvider[];
|
|
24
|
+
readonly filter: AssetFilter;
|
|
25
|
+
readonly signal?: AbortSignal;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Run a filter across providers. `filter.sources` naming exactly one provider
|
|
29
|
+
* ROUTES to it (zero other calls); otherwise eligible providers FEDERATE.
|
|
30
|
+
*/
|
|
31
|
+
export declare function federatedSearch(input: FederatedSearchInput): Promise<AssetListPage>;
|
|
32
|
+
export {};
|
|
33
|
+
//# sourceMappingURL=federated-search.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"federated-search.d.cts","sourceRoot":"","sources":["../../src/sources/federated-search.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACrE,OAAO,KAAK,EAAE,aAAa,EAAgB,MAAM,mBAAmB,CAAC;AACrE,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,yBAAyB,CAAC;AAEvE,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AAEzD,KAAK,eAAe,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,CAAC;AAY1D,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,eAAe,GAAG,MAAM,CAErE;AAED,wBAAgB,qBAAqB,CACpC,KAAK,EAAE,MAAM,GAAG,SAAS,GACvB,eAAe,CAUjB;AAED,uFAAuF;AACvF,wBAAgB,kBAAkB,CACjC,QAAQ,EAAE,mBAAmB,EAC7B,MAAM,EAAE,WAAW,GACjB,OAAO,CAKT;AAED,4EAA4E;AAC5E,wBAAgB,mBAAmB,CAClC,MAAM,EAAE,uBAAuB,EAC/B,QAAQ,EAAE,aAAa,EACvB,KAAK,SAAgC,GACnC,mBAAmB,CAqBrB;AAmED,MAAM,WAAW,oBAAoB;IACpC,QAAQ,CAAC,SAAS,EAAE,SAAS,mBAAmB,EAAE,CAAC;IACnD,QAAQ,CAAC,MAAM,EAAE,WAAW,CAAC;IAC7B,QAAQ,CAAC,MAAM,CAAC,EAAE,WAAW,CAAC;CAC9B;AAED;;;GAGG;AACH,wBAAsB,eAAe,CACpC,KAAK,EAAE,oBAAoB,GACzB,OAAO,CAAC,aAAa,CAAC,CAqCxB"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file Federated search across asset source providers (PRD 0002 §9.3).
|
|
3
|
+
*
|
|
4
|
+
* Routes a single-source query to one provider, or federates across many with
|
|
5
|
+
* `Promise.allSettled` (one failing remote never blanks the rest). The page
|
|
6
|
+
* cursor is an OPAQUE composite token carrying one sub-cursor per source, so
|
|
7
|
+
* each provider paginates independently. Comparable sorts (name/size/kind) are
|
|
8
|
+
* k-way merged; `recent`/`relevance` fall back to provider-grouped order
|
|
9
|
+
* (incomparable across heterogeneous sources).
|
|
10
|
+
*/
|
|
11
|
+
import type { AssetFilter, AssetListPage } from "../types/filter.js";
|
|
12
|
+
import type { AssetRegistry } from "../types/types.js";
|
|
13
|
+
import type { ResolvedAssetDataSource } from "../utils/data-source.js";
|
|
14
|
+
import type { AssetSourceProvider } from "./provider.js";
|
|
15
|
+
type CompositeCursor = Record<string, string | undefined>;
|
|
16
|
+
export declare function encodeCompositeCursor(cursor: CompositeCursor): string;
|
|
17
|
+
export declare function decodeCompositeCursor(token: string | undefined): CompositeCursor;
|
|
18
|
+
/** A provider is eligible only if it can satisfy every required axis of the filter. */
|
|
19
|
+
export declare function providerCanSatisfy(provider: AssetSourceProvider, filter: AssetFilter): boolean;
|
|
20
|
+
/** Adapt the resolved (local) data source into an `AssetSourceProvider`. */
|
|
21
|
+
export declare function createLocalProvider(source: ResolvedAssetDataSource, registry: AssetRegistry, label?: string): AssetSourceProvider;
|
|
22
|
+
export interface FederatedSearchInput {
|
|
23
|
+
readonly providers: readonly AssetSourceProvider[];
|
|
24
|
+
readonly filter: AssetFilter;
|
|
25
|
+
readonly signal?: AbortSignal;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Run a filter across providers. `filter.sources` naming exactly one provider
|
|
29
|
+
* ROUTES to it (zero other calls); otherwise eligible providers FEDERATE.
|
|
30
|
+
*/
|
|
31
|
+
export declare function federatedSearch(input: FederatedSearchInput): Promise<AssetListPage>;
|
|
32
|
+
export {};
|
|
33
|
+
//# sourceMappingURL=federated-search.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"federated-search.d.ts","sourceRoot":"","sources":["../../src/sources/federated-search.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACrE,OAAO,KAAK,EAAE,aAAa,EAAgB,MAAM,mBAAmB,CAAC;AACrE,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,yBAAyB,CAAC;AAEvE,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AAEzD,KAAK,eAAe,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,CAAC;AAY1D,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,eAAe,GAAG,MAAM,CAErE;AAED,wBAAgB,qBAAqB,CACpC,KAAK,EAAE,MAAM,GAAG,SAAS,GACvB,eAAe,CAUjB;AAED,uFAAuF;AACvF,wBAAgB,kBAAkB,CACjC,QAAQ,EAAE,mBAAmB,EAC7B,MAAM,EAAE,WAAW,GACjB,OAAO,CAKT;AAED,4EAA4E;AAC5E,wBAAgB,mBAAmB,CAClC,MAAM,EAAE,uBAAuB,EAC/B,QAAQ,EAAE,aAAa,EACvB,KAAK,SAAgC,GACnC,mBAAmB,CAqBrB;AAmED,MAAM,WAAW,oBAAoB;IACpC,QAAQ,CAAC,SAAS,EAAE,SAAS,mBAAmB,EAAE,CAAC;IACnD,QAAQ,CAAC,MAAM,EAAE,WAAW,CAAC;IAC7B,QAAQ,CAAC,MAAM,CAAC,EAAE,WAAW,CAAC;CAC9B;AAED;;;GAGG;AACH,wBAAsB,eAAe,CACpC,KAAK,EAAE,oBAAoB,GACzB,OAAO,CAAC,aAAa,CAAC,CAqCxB"}
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import { inferAssetKind } from "../utils/infer-kind.js";
|
|
2
|
+
function toBase64Url(json) {
|
|
3
|
+
return btoa(json).replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/, "");
|
|
4
|
+
}
|
|
5
|
+
function fromBase64Url(token) {
|
|
6
|
+
const padded = token.length % 4 === 0 ? token : token + "=".repeat(4 - token.length % 4);
|
|
7
|
+
return atob(padded.replace(/-/g, "+").replace(/_/g, "/"));
|
|
8
|
+
}
|
|
9
|
+
function encodeCompositeCursor(cursor) {
|
|
10
|
+
return toBase64Url(JSON.stringify(cursor));
|
|
11
|
+
}
|
|
12
|
+
function decodeCompositeCursor(token) {
|
|
13
|
+
if (void 0 === token || "" === token) return {};
|
|
14
|
+
try {
|
|
15
|
+
const parsed = JSON.parse(fromBase64Url(token));
|
|
16
|
+
return "object" == typeof parsed && null !== parsed ? parsed : {};
|
|
17
|
+
} catch {
|
|
18
|
+
return {};
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
function providerCanSatisfy(provider, filter) {
|
|
22
|
+
if (void 0 !== filter.folderId && true !== provider.capabilities.folders) return false;
|
|
23
|
+
return true;
|
|
24
|
+
}
|
|
25
|
+
function createLocalProvider(source, registry, label = "assetManager.source.library") {
|
|
26
|
+
return {
|
|
27
|
+
id: "local",
|
|
28
|
+
label,
|
|
29
|
+
capabilities: {
|
|
30
|
+
searchable: true,
|
|
31
|
+
themed: false,
|
|
32
|
+
mutable: true,
|
|
33
|
+
requiresAttribution: false,
|
|
34
|
+
folders: true
|
|
35
|
+
},
|
|
36
|
+
listThemes: ()=>[],
|
|
37
|
+
search: (filter, page, signal)=>source.list(void 0 !== page ? {
|
|
38
|
+
...filter,
|
|
39
|
+
cursor: page
|
|
40
|
+
} : filter, signal),
|
|
41
|
+
pickResult: async (asset)=>registry.get(asset.id) ?? {
|
|
42
|
+
id: asset.id,
|
|
43
|
+
url: asset.url
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
function sortKey(entry, field) {
|
|
48
|
+
switch(field){
|
|
49
|
+
case "name":
|
|
50
|
+
return (entry.name ?? "").toLowerCase();
|
|
51
|
+
case "size":
|
|
52
|
+
return entry.meta?.size ?? 0;
|
|
53
|
+
case "kind":
|
|
54
|
+
return inferAssetKind(entry);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
function compareEntries(a, b, field) {
|
|
58
|
+
const ka = sortKey(a, field);
|
|
59
|
+
const kb = sortKey(b, field);
|
|
60
|
+
if ("number" == typeof ka && "number" == typeof kb) return ka - kb;
|
|
61
|
+
return String(ka).localeCompare(String(kb));
|
|
62
|
+
}
|
|
63
|
+
function mergePages(pages, filter, carryForward = {}) {
|
|
64
|
+
const field = filter.sort?.field ?? "recent";
|
|
65
|
+
const comparable = "name" === field || "size" === field || "kind" === field;
|
|
66
|
+
const items = pages.flatMap((p)=>[
|
|
67
|
+
...p.page.items
|
|
68
|
+
]);
|
|
69
|
+
if (comparable) {
|
|
70
|
+
const dir = filter.sort?.direction ?? ("name" === field ? "asc" : "desc");
|
|
71
|
+
const sign = "asc" === dir ? 1 : -1;
|
|
72
|
+
items.sort((a, b)=>compareEntries(a, b, field) * sign);
|
|
73
|
+
}
|
|
74
|
+
const total = pages.reduce((n, p)=>n + p.page.total, 0);
|
|
75
|
+
const sourceCursors = {
|
|
76
|
+
...carryForward
|
|
77
|
+
};
|
|
78
|
+
const next = {
|
|
79
|
+
...carryForward
|
|
80
|
+
};
|
|
81
|
+
let hasNext = Object.keys(carryForward).length > 0;
|
|
82
|
+
for (const { provider, page } of pages){
|
|
83
|
+
sourceCursors[provider.id] = page.nextCursor;
|
|
84
|
+
if (void 0 !== page.nextCursor) {
|
|
85
|
+
next[provider.id] = page.nextCursor;
|
|
86
|
+
hasNext = true;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
return {
|
|
90
|
+
items: Object.freeze(items),
|
|
91
|
+
total,
|
|
92
|
+
nextCursor: hasNext ? encodeCompositeCursor(next) : void 0,
|
|
93
|
+
sourceCursors
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
async function federatedSearch(input) {
|
|
97
|
+
const { providers, filter, signal } = input;
|
|
98
|
+
const eligible = providers.filter((p)=>providerCanSatisfy(p, filter));
|
|
99
|
+
const targets = filter.sources && filter.sources.length > 0 ? eligible.filter((p)=>filter.sources?.includes(p.id)) : eligible;
|
|
100
|
+
if (0 === targets.length) return {
|
|
101
|
+
items: Object.freeze([]),
|
|
102
|
+
total: 0,
|
|
103
|
+
nextCursor: void 0
|
|
104
|
+
};
|
|
105
|
+
const cursors = decodeCompositeCursor(filter.cursor);
|
|
106
|
+
const settled = await Promise.allSettled(targets.map((p)=>p.search(filter, cursors[p.id], signal)));
|
|
107
|
+
const ok = [];
|
|
108
|
+
const carryForward = {};
|
|
109
|
+
settled.forEach((result, index)=>{
|
|
110
|
+
const provider = targets[index];
|
|
111
|
+
if (void 0 === provider) return;
|
|
112
|
+
if ("fulfilled" === result.status) ok.push({
|
|
113
|
+
provider,
|
|
114
|
+
page: result.value
|
|
115
|
+
});
|
|
116
|
+
else {
|
|
117
|
+
const incoming = cursors[provider.id];
|
|
118
|
+
if (void 0 !== incoming) carryForward[provider.id] = incoming;
|
|
119
|
+
}
|
|
120
|
+
});
|
|
121
|
+
return mergePages(ok, filter, carryForward);
|
|
122
|
+
}
|
|
123
|
+
export { createLocalProvider, decodeCompositeCursor, encodeCompositeCursor, federatedSearch, providerCanSatisfy };
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __webpack_require__ = {};
|
|
3
|
+
(()=>{
|
|
4
|
+
__webpack_require__.r = (exports1)=>{
|
|
5
|
+
if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
6
|
+
value: 'Module'
|
|
7
|
+
});
|
|
8
|
+
Object.defineProperty(exports1, '__esModule', {
|
|
9
|
+
value: true
|
|
10
|
+
});
|
|
11
|
+
};
|
|
12
|
+
})();
|
|
13
|
+
var __webpack_exports__ = {};
|
|
14
|
+
__webpack_require__.r(__webpack_exports__);
|
|
15
|
+
for(var __rspack_i in __webpack_exports__)exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
16
|
+
Object.defineProperty(exports, '__esModule', {
|
|
17
|
+
value: true
|
|
18
|
+
});
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file External read-only source provider contract (PRD 0002 §3.4, §8).
|
|
3
|
+
*
|
|
4
|
+
* Unsplash (and any host-defined stock source) implements this. All providers
|
|
5
|
+
* compose behind the single `StudioAssetSource` the plugin registers; the
|
|
6
|
+
* built-in `local` provider wraps the resolved `AssetDataSource`. These are
|
|
7
|
+
* types only — erased at runtime, zero bytes in any chunk.
|
|
8
|
+
*/
|
|
9
|
+
import type { StudioAsset } from "@anvilkit/core/types";
|
|
10
|
+
import type { AssetFilter, AssetListPage, AssetSourceId } from "../types/filter.js";
|
|
11
|
+
import type { UploadResult } from "../types/types.js";
|
|
12
|
+
export interface AssetSourceCapabilities {
|
|
13
|
+
readonly searchable: boolean;
|
|
14
|
+
readonly themed: boolean;
|
|
15
|
+
/** Unsplash = false (browse + insert only). */
|
|
16
|
+
readonly mutable: boolean;
|
|
17
|
+
/** Unsplash = true. */
|
|
18
|
+
readonly requiresAttribution: boolean;
|
|
19
|
+
/**
|
|
20
|
+
* Supports folder scoping. Only the local library provider sets this; a
|
|
21
|
+
* folder-scoped query (`AssetFilter.folderId`) drops providers without it
|
|
22
|
+
* from the federation. Defaults to `false` when omitted.
|
|
23
|
+
*/
|
|
24
|
+
readonly folders?: boolean;
|
|
25
|
+
}
|
|
26
|
+
export interface AssetTheme {
|
|
27
|
+
readonly id: string;
|
|
28
|
+
/** i18n message key (not inline copy). */
|
|
29
|
+
readonly label: string;
|
|
30
|
+
readonly description?: string;
|
|
31
|
+
}
|
|
32
|
+
export interface AssetSourceProvider {
|
|
33
|
+
/** `"unsplash"` | host id. The built-in `"local"` provider wraps the data source. */
|
|
34
|
+
readonly id: AssetSourceId;
|
|
35
|
+
readonly label: string;
|
|
36
|
+
readonly capabilities: AssetSourceCapabilities;
|
|
37
|
+
/** Content-Security-Policy hosts this provider needs (e.g. Unsplash img/connect src). */
|
|
38
|
+
readonly requiredCsp?: () => {
|
|
39
|
+
readonly connectSrc?: readonly string[];
|
|
40
|
+
readonly imgSrc?: readonly string[];
|
|
41
|
+
};
|
|
42
|
+
listThemes(): readonly AssetTheme[] | Promise<readonly AssetTheme[]>;
|
|
43
|
+
search(query: AssetFilter, page: string | undefined, signal?: AbortSignal): Promise<AssetListPage>;
|
|
44
|
+
/**
|
|
45
|
+
* Convert a browsed result into a real asset (fires the source's
|
|
46
|
+
* download-trigger / attribution work) and feed it into the existing
|
|
47
|
+
* registry → IR → `asset://` pipeline.
|
|
48
|
+
*/
|
|
49
|
+
pickResult(asset: StudioAsset, signal?: AbortSignal): Promise<UploadResult>;
|
|
50
|
+
}
|
|
51
|
+
//# sourceMappingURL=provider.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"provider.d.cts","sourceRoot":"","sources":["../../src/sources/provider.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAExD,OAAO,KAAK,EACX,WAAW,EACX,aAAa,EACb,aAAa,EACb,MAAM,oBAAoB,CAAC;AAC5B,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAEtD,MAAM,WAAW,uBAAuB;IACvC,QAAQ,CAAC,UAAU,EAAE,OAAO,CAAC;IAC7B,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC;IACzB,+CAA+C;IAC/C,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;IAC1B,uBAAuB;IACvB,QAAQ,CAAC,mBAAmB,EAAE,OAAO,CAAC;IACtC;;;;OAIG;IACH,QAAQ,CAAC,OAAO,CAAC,EAAE,OAAO,CAAC;CAC3B;AAED,MAAM,WAAW,UAAU;IAC1B,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,0CAA0C;IAC1C,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC;CAC9B;AAED,MAAM,WAAW,mBAAmB;IACnC,qFAAqF;IACrF,QAAQ,CAAC,EAAE,EAAE,aAAa,CAAC;IAC3B,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,YAAY,EAAE,uBAAuB,CAAC;IAC/C,yFAAyF;IACzF,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM;QAC5B,QAAQ,CAAC,UAAU,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;QACxC,QAAQ,CAAC,MAAM,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;KACpC,CAAC;IACF,UAAU,IAAI,SAAS,UAAU,EAAE,GAAG,OAAO,CAAC,SAAS,UAAU,EAAE,CAAC,CAAC;IACrE,MAAM,CACL,KAAK,EAAE,WAAW,EAClB,IAAI,EAAE,MAAM,GAAG,SAAS,EACxB,MAAM,CAAC,EAAE,WAAW,GAClB,OAAO,CAAC,aAAa,CAAC,CAAC;IAC1B;;;;OAIG;IACH,UAAU,CAAC,KAAK,EAAE,WAAW,EAAE,MAAM,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,YAAY,CAAC,CAAC;CAC5E"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file External read-only source provider contract (PRD 0002 §3.4, §8).
|
|
3
|
+
*
|
|
4
|
+
* Unsplash (and any host-defined stock source) implements this. All providers
|
|
5
|
+
* compose behind the single `StudioAssetSource` the plugin registers; the
|
|
6
|
+
* built-in `local` provider wraps the resolved `AssetDataSource`. These are
|
|
7
|
+
* types only — erased at runtime, zero bytes in any chunk.
|
|
8
|
+
*/
|
|
9
|
+
import type { StudioAsset } from "@anvilkit/core/types";
|
|
10
|
+
import type { AssetFilter, AssetListPage, AssetSourceId } from "../types/filter.js";
|
|
11
|
+
import type { UploadResult } from "../types/types.js";
|
|
12
|
+
export interface AssetSourceCapabilities {
|
|
13
|
+
readonly searchable: boolean;
|
|
14
|
+
readonly themed: boolean;
|
|
15
|
+
/** Unsplash = false (browse + insert only). */
|
|
16
|
+
readonly mutable: boolean;
|
|
17
|
+
/** Unsplash = true. */
|
|
18
|
+
readonly requiresAttribution: boolean;
|
|
19
|
+
/**
|
|
20
|
+
* Supports folder scoping. Only the local library provider sets this; a
|
|
21
|
+
* folder-scoped query (`AssetFilter.folderId`) drops providers without it
|
|
22
|
+
* from the federation. Defaults to `false` when omitted.
|
|
23
|
+
*/
|
|
24
|
+
readonly folders?: boolean;
|
|
25
|
+
}
|
|
26
|
+
export interface AssetTheme {
|
|
27
|
+
readonly id: string;
|
|
28
|
+
/** i18n message key (not inline copy). */
|
|
29
|
+
readonly label: string;
|
|
30
|
+
readonly description?: string;
|
|
31
|
+
}
|
|
32
|
+
export interface AssetSourceProvider {
|
|
33
|
+
/** `"unsplash"` | host id. The built-in `"local"` provider wraps the data source. */
|
|
34
|
+
readonly id: AssetSourceId;
|
|
35
|
+
readonly label: string;
|
|
36
|
+
readonly capabilities: AssetSourceCapabilities;
|
|
37
|
+
/** Content-Security-Policy hosts this provider needs (e.g. Unsplash img/connect src). */
|
|
38
|
+
readonly requiredCsp?: () => {
|
|
39
|
+
readonly connectSrc?: readonly string[];
|
|
40
|
+
readonly imgSrc?: readonly string[];
|
|
41
|
+
};
|
|
42
|
+
listThemes(): readonly AssetTheme[] | Promise<readonly AssetTheme[]>;
|
|
43
|
+
search(query: AssetFilter, page: string | undefined, signal?: AbortSignal): Promise<AssetListPage>;
|
|
44
|
+
/**
|
|
45
|
+
* Convert a browsed result into a real asset (fires the source's
|
|
46
|
+
* download-trigger / attribution work) and feed it into the existing
|
|
47
|
+
* registry → IR → `asset://` pipeline.
|
|
48
|
+
*/
|
|
49
|
+
pickResult(asset: StudioAsset, signal?: AbortSignal): Promise<UploadResult>;
|
|
50
|
+
}
|
|
51
|
+
//# sourceMappingURL=provider.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"provider.d.ts","sourceRoot":"","sources":["../../src/sources/provider.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAExD,OAAO,KAAK,EACX,WAAW,EACX,aAAa,EACb,aAAa,EACb,MAAM,oBAAoB,CAAC;AAC5B,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAEtD,MAAM,WAAW,uBAAuB;IACvC,QAAQ,CAAC,UAAU,EAAE,OAAO,CAAC;IAC7B,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC;IACzB,+CAA+C;IAC/C,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;IAC1B,uBAAuB;IACvB,QAAQ,CAAC,mBAAmB,EAAE,OAAO,CAAC;IACtC;;;;OAIG;IACH,QAAQ,CAAC,OAAO,CAAC,EAAE,OAAO,CAAC;CAC3B;AAED,MAAM,WAAW,UAAU;IAC1B,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,0CAA0C;IAC1C,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC;CAC9B;AAED,MAAM,WAAW,mBAAmB;IACnC,qFAAqF;IACrF,QAAQ,CAAC,EAAE,EAAE,aAAa,CAAC;IAC3B,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,YAAY,EAAE,uBAAuB,CAAC;IAC/C,yFAAyF;IACzF,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM;QAC5B,QAAQ,CAAC,UAAU,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;QACxC,QAAQ,CAAC,MAAM,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;KACpC,CAAC;IACF,UAAU,IAAI,SAAS,UAAU,EAAE,GAAG,OAAO,CAAC,SAAS,UAAU,EAAE,CAAC,CAAC;IACrE,MAAM,CACL,KAAK,EAAE,WAAW,EAClB,IAAI,EAAE,MAAM,GAAG,SAAS,EACxB,MAAM,CAAC,EAAE,WAAW,GAClB,OAAO,CAAC,aAAa,CAAC,CAAC;IAC1B;;;;OAIG;IACH,UAAU,CAAC,KAAK,EAAE,WAAW,EAAE,MAAM,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,YAAY,CAAC,CAAC;CAC5E"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { };
|