@nextcloud/files 4.0.0-rc.0 → 4.0.0-rc.2
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/actions/fileAction.d.ts +4 -23
- package/dist/actions/fileListAction.d.ts +3 -15
- package/dist/actions/index.d.ts +4 -3
- package/dist/chunks/{folder-CeyZUHai.mjs → folder-C9vrC6sc.mjs} +11 -11
- package/dist/chunks/folder-C9vrC6sc.mjs.map +1 -0
- package/dist/dav.mjs +2 -1
- package/dist/dav.mjs.map +1 -1
- package/dist/filters/functions.d.ts +20 -0
- package/dist/filters/index.d.ts +7 -0
- package/dist/{fileListFilters.d.ts → filters/listFilters.d.ts} +1 -20
- package/dist/headers/index.d.ts +2 -0
- package/dist/headers/listHeaders.d.ts +24 -0
- package/dist/index.d.ts +3 -2
- package/dist/index.mjs +128 -829
- package/dist/index.mjs.map +1 -1
- package/dist/navigation/navigation.d.ts +2 -2
- package/dist/node/fileType.d.ts +1 -1
- package/dist/node/index.d.ts +4 -2
- package/dist/node/node.d.ts +5 -16
- package/dist/node/nodeData.d.ts +16 -2
- package/dist/registry.d.ts +28 -0
- package/package.json +7 -8
- package/dist/chunks/folder-CeyZUHai.mjs.map +0 -1
- package/dist/fileListHeaders.d.ts +0 -34
package/dist/index.mjs
CHANGED
|
@@ -1,798 +1,145 @@
|
|
|
1
|
-
import { l as logger, F as FileType } from "./chunks/folder-CeyZUHai.mjs";
|
|
2
|
-
import { a, b, N, c, P } from "./chunks/folder-CeyZUHai.mjs";
|
|
3
1
|
import { TypedEventTarget } from "typescript-event-target";
|
|
2
|
+
import { l as logger, F as FileType } from "./chunks/folder-C9vrC6sc.mjs";
|
|
3
|
+
import { a, b, N, c, P } from "./chunks/folder-C9vrC6sc.mjs";
|
|
4
4
|
import isSvg from "is-svg";
|
|
5
5
|
import { getCapabilities } from "@nextcloud/capabilities";
|
|
6
6
|
import { extname, basename } from "@nextcloud/paths";
|
|
7
7
|
import { getCanonicalLocale, getLanguage } from "@nextcloud/l10n";
|
|
8
|
+
class FilesRegistryV4 extends TypedEventTarget {
|
|
9
|
+
}
|
|
10
|
+
function getRegistry() {
|
|
11
|
+
window._nc_files_registry_v4 ??= new FilesRegistryV4();
|
|
12
|
+
return window._nc_files_registry_v4;
|
|
13
|
+
}
|
|
14
|
+
function getFilesRegistry() {
|
|
15
|
+
return getRegistry();
|
|
16
|
+
}
|
|
8
17
|
const DefaultType = Object.freeze({
|
|
9
18
|
DEFAULT: "default",
|
|
10
19
|
HIDDEN: "hidden"
|
|
11
20
|
});
|
|
12
|
-
class FileAction {
|
|
13
|
-
_action;
|
|
14
|
-
constructor(action) {
|
|
15
|
-
this.validateAction(action);
|
|
16
|
-
this._action = action;
|
|
17
|
-
}
|
|
18
|
-
get id() {
|
|
19
|
-
return this._action.id;
|
|
20
|
-
}
|
|
21
|
-
get displayName() {
|
|
22
|
-
return this._action.displayName;
|
|
23
|
-
}
|
|
24
|
-
get title() {
|
|
25
|
-
return this._action.title;
|
|
26
|
-
}
|
|
27
|
-
get iconSvgInline() {
|
|
28
|
-
return this._action.iconSvgInline;
|
|
29
|
-
}
|
|
30
|
-
get enabled() {
|
|
31
|
-
return this._action.enabled;
|
|
32
|
-
}
|
|
33
|
-
get exec() {
|
|
34
|
-
return this._action.exec;
|
|
35
|
-
}
|
|
36
|
-
get execBatch() {
|
|
37
|
-
return this._action.execBatch;
|
|
38
|
-
}
|
|
39
|
-
get hotkey() {
|
|
40
|
-
return this._action.hotkey;
|
|
41
|
-
}
|
|
42
|
-
get order() {
|
|
43
|
-
return this._action.order;
|
|
44
|
-
}
|
|
45
|
-
get parent() {
|
|
46
|
-
return this._action.parent;
|
|
47
|
-
}
|
|
48
|
-
get default() {
|
|
49
|
-
return this._action.default;
|
|
50
|
-
}
|
|
51
|
-
get destructive() {
|
|
52
|
-
return this._action.destructive;
|
|
53
|
-
}
|
|
54
|
-
get inline() {
|
|
55
|
-
return this._action.inline;
|
|
56
|
-
}
|
|
57
|
-
get renderInline() {
|
|
58
|
-
return this._action.renderInline;
|
|
59
|
-
}
|
|
60
|
-
validateAction(action) {
|
|
61
|
-
if (!action.id || typeof action.id !== "string") {
|
|
62
|
-
throw new Error("Invalid id");
|
|
63
|
-
}
|
|
64
|
-
if (!action.displayName || typeof action.displayName !== "function") {
|
|
65
|
-
throw new Error("Invalid displayName function");
|
|
66
|
-
}
|
|
67
|
-
if ("title" in action && typeof action.title !== "function") {
|
|
68
|
-
throw new Error("Invalid title function");
|
|
69
|
-
}
|
|
70
|
-
if (!action.iconSvgInline || typeof action.iconSvgInline !== "function") {
|
|
71
|
-
throw new Error("Invalid iconSvgInline function");
|
|
72
|
-
}
|
|
73
|
-
if (!action.exec || typeof action.exec !== "function") {
|
|
74
|
-
throw new Error("Invalid exec function");
|
|
75
|
-
}
|
|
76
|
-
if ("enabled" in action && typeof action.enabled !== "function") {
|
|
77
|
-
throw new Error("Invalid enabled function");
|
|
78
|
-
}
|
|
79
|
-
if ("execBatch" in action && typeof action.execBatch !== "function") {
|
|
80
|
-
throw new Error("Invalid execBatch function");
|
|
81
|
-
}
|
|
82
|
-
if ("order" in action && typeof action.order !== "number") {
|
|
83
|
-
throw new Error("Invalid order");
|
|
84
|
-
}
|
|
85
|
-
if (action.destructive !== void 0 && typeof action.destructive !== "boolean") {
|
|
86
|
-
throw new Error("Invalid destructive flag");
|
|
87
|
-
}
|
|
88
|
-
if ("parent" in action && typeof action.parent !== "string") {
|
|
89
|
-
throw new Error("Invalid parent");
|
|
90
|
-
}
|
|
91
|
-
if (action.default && !Object.values(DefaultType).includes(action.default)) {
|
|
92
|
-
throw new Error("Invalid default");
|
|
93
|
-
}
|
|
94
|
-
if ("inline" in action && typeof action.inline !== "function") {
|
|
95
|
-
throw new Error("Invalid inline function");
|
|
96
|
-
}
|
|
97
|
-
if ("renderInline" in action && typeof action.renderInline !== "function") {
|
|
98
|
-
throw new Error("Invalid renderInline function");
|
|
99
|
-
}
|
|
100
|
-
if ("hotkey" in action && action.hotkey !== void 0) {
|
|
101
|
-
if (typeof action.hotkey !== "object") {
|
|
102
|
-
throw new Error("Invalid hotkey configuration");
|
|
103
|
-
}
|
|
104
|
-
if (typeof action.hotkey.key !== "string" || !action.hotkey.key) {
|
|
105
|
-
throw new Error("Missing or invalid hotkey key");
|
|
106
|
-
}
|
|
107
|
-
if (typeof action.hotkey.description !== "string" || !action.hotkey.description) {
|
|
108
|
-
throw new Error("Missing or invalid hotkey description");
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
21
|
function registerFileAction(action) {
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
logger.debug("FileActions initialized");
|
|
117
|
-
}
|
|
22
|
+
validateAction$1(action);
|
|
23
|
+
window._nc_fileactions ??= [];
|
|
118
24
|
if (window._nc_fileactions.find((search) => search.id === action.id)) {
|
|
119
25
|
logger.error(`FileAction ${action.id} already registered`, { action });
|
|
120
26
|
return;
|
|
121
27
|
}
|
|
122
28
|
window._nc_fileactions.push(action);
|
|
29
|
+
getRegistry().dispatchTypedEvent("register:action", new CustomEvent("register:action", { detail: action }));
|
|
123
30
|
}
|
|
124
31
|
function getFileActions() {
|
|
125
|
-
|
|
126
|
-
window._nc_fileactions = [];
|
|
127
|
-
logger.debug("FileActions initialized");
|
|
128
|
-
}
|
|
129
|
-
return window._nc_fileactions;
|
|
32
|
+
return window._nc_fileactions ?? [];
|
|
130
33
|
}
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
this.validateAction(action);
|
|
135
|
-
this._action = action;
|
|
34
|
+
function validateAction$1(action) {
|
|
35
|
+
if (!action.id || typeof action.id !== "string") {
|
|
36
|
+
throw new Error("Invalid id");
|
|
136
37
|
}
|
|
137
|
-
|
|
138
|
-
|
|
38
|
+
if (!action.displayName || typeof action.displayName !== "function") {
|
|
39
|
+
throw new Error("Invalid displayName function");
|
|
40
|
+
}
|
|
41
|
+
if ("title" in action && typeof action.title !== "function") {
|
|
42
|
+
throw new Error("Invalid title function");
|
|
139
43
|
}
|
|
140
|
-
|
|
141
|
-
|
|
44
|
+
if (!action.iconSvgInline || typeof action.iconSvgInline !== "function") {
|
|
45
|
+
throw new Error("Invalid iconSvgInline function");
|
|
142
46
|
}
|
|
143
|
-
|
|
144
|
-
|
|
47
|
+
if (!action.exec || typeof action.exec !== "function") {
|
|
48
|
+
throw new Error("Invalid exec function");
|
|
145
49
|
}
|
|
146
|
-
|
|
147
|
-
|
|
50
|
+
if ("enabled" in action && typeof action.enabled !== "function") {
|
|
51
|
+
throw new Error("Invalid enabled function");
|
|
148
52
|
}
|
|
149
|
-
|
|
150
|
-
|
|
53
|
+
if ("execBatch" in action && typeof action.execBatch !== "function") {
|
|
54
|
+
throw new Error("Invalid execBatch function");
|
|
151
55
|
}
|
|
152
|
-
|
|
153
|
-
|
|
56
|
+
if ("order" in action && typeof action.order !== "number") {
|
|
57
|
+
throw new Error("Invalid order");
|
|
154
58
|
}
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
59
|
+
if (action.destructive !== void 0 && typeof action.destructive !== "boolean") {
|
|
60
|
+
throw new Error("Invalid destructive flag");
|
|
61
|
+
}
|
|
62
|
+
if ("parent" in action && typeof action.parent !== "string") {
|
|
63
|
+
throw new Error("Invalid parent");
|
|
64
|
+
}
|
|
65
|
+
if (action.default && !Object.values(DefaultType).includes(action.default)) {
|
|
66
|
+
throw new Error("Invalid default");
|
|
67
|
+
}
|
|
68
|
+
if ("inline" in action && typeof action.inline !== "function") {
|
|
69
|
+
throw new Error("Invalid inline function");
|
|
70
|
+
}
|
|
71
|
+
if ("renderInline" in action && typeof action.renderInline !== "function") {
|
|
72
|
+
throw new Error("Invalid renderInline function");
|
|
73
|
+
}
|
|
74
|
+
if ("hotkey" in action && action.hotkey !== void 0) {
|
|
75
|
+
if (typeof action.hotkey !== "object") {
|
|
76
|
+
throw new Error("Invalid hotkey configuration");
|
|
167
77
|
}
|
|
168
|
-
if (
|
|
169
|
-
throw new Error("
|
|
78
|
+
if (typeof action.hotkey.key !== "string" || !action.hotkey.key) {
|
|
79
|
+
throw new Error("Missing or invalid hotkey key");
|
|
170
80
|
}
|
|
171
|
-
if (
|
|
172
|
-
throw new Error("
|
|
81
|
+
if (typeof action.hotkey.description !== "string" || !action.hotkey.description) {
|
|
82
|
+
throw new Error("Missing or invalid hotkey description");
|
|
173
83
|
}
|
|
174
84
|
}
|
|
175
85
|
}
|
|
176
86
|
function registerFileListAction(action) {
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
}
|
|
87
|
+
validateAction(action);
|
|
88
|
+
window._nc_filelistactions ??= [];
|
|
180
89
|
if (window._nc_filelistactions.find((listAction) => listAction.id === action.id)) {
|
|
181
90
|
logger.error(`FileListAction with id "${action.id}" is already registered`, { action });
|
|
182
91
|
return;
|
|
183
92
|
}
|
|
184
93
|
window._nc_filelistactions.push(action);
|
|
94
|
+
getRegistry().dispatchTypedEvent("register:listAction", new CustomEvent("register:listAction", { detail: action }));
|
|
185
95
|
}
|
|
186
96
|
function getFileListActions() {
|
|
187
|
-
|
|
188
|
-
window._nc_filelistactions = [];
|
|
189
|
-
}
|
|
190
|
-
return window._nc_filelistactions;
|
|
191
|
-
}
|
|
192
|
-
function getDefaultExportFromCjs(x) {
|
|
193
|
-
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, "default") ? x["default"] : x;
|
|
194
|
-
}
|
|
195
|
-
var debug_1;
|
|
196
|
-
var hasRequiredDebug;
|
|
197
|
-
function requireDebug() {
|
|
198
|
-
if (hasRequiredDebug) return debug_1;
|
|
199
|
-
hasRequiredDebug = 1;
|
|
200
|
-
const debug = typeof process === "object" && process.env && process.env.NODE_DEBUG && /\bsemver\b/i.test(process.env.NODE_DEBUG) ? (...args) => console.error("SEMVER", ...args) : () => {
|
|
201
|
-
};
|
|
202
|
-
debug_1 = debug;
|
|
203
|
-
return debug_1;
|
|
204
|
-
}
|
|
205
|
-
var constants;
|
|
206
|
-
var hasRequiredConstants;
|
|
207
|
-
function requireConstants() {
|
|
208
|
-
if (hasRequiredConstants) return constants;
|
|
209
|
-
hasRequiredConstants = 1;
|
|
210
|
-
const SEMVER_SPEC_VERSION = "2.0.0";
|
|
211
|
-
const MAX_LENGTH = 256;
|
|
212
|
-
const MAX_SAFE_INTEGER = Number.MAX_SAFE_INTEGER || /* istanbul ignore next */
|
|
213
|
-
9007199254740991;
|
|
214
|
-
const MAX_SAFE_COMPONENT_LENGTH = 16;
|
|
215
|
-
const MAX_SAFE_BUILD_LENGTH = MAX_LENGTH - 6;
|
|
216
|
-
const RELEASE_TYPES = [
|
|
217
|
-
"major",
|
|
218
|
-
"premajor",
|
|
219
|
-
"minor",
|
|
220
|
-
"preminor",
|
|
221
|
-
"patch",
|
|
222
|
-
"prepatch",
|
|
223
|
-
"prerelease"
|
|
224
|
-
];
|
|
225
|
-
constants = {
|
|
226
|
-
MAX_LENGTH,
|
|
227
|
-
MAX_SAFE_COMPONENT_LENGTH,
|
|
228
|
-
MAX_SAFE_BUILD_LENGTH,
|
|
229
|
-
MAX_SAFE_INTEGER,
|
|
230
|
-
RELEASE_TYPES,
|
|
231
|
-
SEMVER_SPEC_VERSION,
|
|
232
|
-
FLAG_INCLUDE_PRERELEASE: 1,
|
|
233
|
-
FLAG_LOOSE: 2
|
|
234
|
-
};
|
|
235
|
-
return constants;
|
|
236
|
-
}
|
|
237
|
-
var re = { exports: {} };
|
|
238
|
-
var hasRequiredRe;
|
|
239
|
-
function requireRe() {
|
|
240
|
-
if (hasRequiredRe) return re.exports;
|
|
241
|
-
hasRequiredRe = 1;
|
|
242
|
-
(function(module, exports) {
|
|
243
|
-
const {
|
|
244
|
-
MAX_SAFE_COMPONENT_LENGTH,
|
|
245
|
-
MAX_SAFE_BUILD_LENGTH,
|
|
246
|
-
MAX_LENGTH
|
|
247
|
-
} = requireConstants();
|
|
248
|
-
const debug = requireDebug();
|
|
249
|
-
exports = module.exports = {};
|
|
250
|
-
const re2 = exports.re = [];
|
|
251
|
-
const safeRe = exports.safeRe = [];
|
|
252
|
-
const src = exports.src = [];
|
|
253
|
-
const safeSrc = exports.safeSrc = [];
|
|
254
|
-
const t = exports.t = {};
|
|
255
|
-
let R = 0;
|
|
256
|
-
const LETTERDASHNUMBER = "[a-zA-Z0-9-]";
|
|
257
|
-
const safeRegexReplacements = [
|
|
258
|
-
["\\s", 1],
|
|
259
|
-
["\\d", MAX_LENGTH],
|
|
260
|
-
[LETTERDASHNUMBER, MAX_SAFE_BUILD_LENGTH]
|
|
261
|
-
];
|
|
262
|
-
const makeSafeRegex = (value) => {
|
|
263
|
-
for (const [token, max] of safeRegexReplacements) {
|
|
264
|
-
value = value.split(`${token}*`).join(`${token}{0,${max}}`).split(`${token}+`).join(`${token}{1,${max}}`);
|
|
265
|
-
}
|
|
266
|
-
return value;
|
|
267
|
-
};
|
|
268
|
-
const createToken = (name, value, isGlobal) => {
|
|
269
|
-
const safe = makeSafeRegex(value);
|
|
270
|
-
const index = R++;
|
|
271
|
-
debug(name, index, value);
|
|
272
|
-
t[name] = index;
|
|
273
|
-
src[index] = value;
|
|
274
|
-
safeSrc[index] = safe;
|
|
275
|
-
re2[index] = new RegExp(value, isGlobal ? "g" : void 0);
|
|
276
|
-
safeRe[index] = new RegExp(safe, isGlobal ? "g" : void 0);
|
|
277
|
-
};
|
|
278
|
-
createToken("NUMERICIDENTIFIER", "0|[1-9]\\d*");
|
|
279
|
-
createToken("NUMERICIDENTIFIERLOOSE", "\\d+");
|
|
280
|
-
createToken("NONNUMERICIDENTIFIER", `\\d*[a-zA-Z-]${LETTERDASHNUMBER}*`);
|
|
281
|
-
createToken("MAINVERSION", `(${src[t.NUMERICIDENTIFIER]})\\.(${src[t.NUMERICIDENTIFIER]})\\.(${src[t.NUMERICIDENTIFIER]})`);
|
|
282
|
-
createToken("MAINVERSIONLOOSE", `(${src[t.NUMERICIDENTIFIERLOOSE]})\\.(${src[t.NUMERICIDENTIFIERLOOSE]})\\.(${src[t.NUMERICIDENTIFIERLOOSE]})`);
|
|
283
|
-
createToken("PRERELEASEIDENTIFIER", `(?:${src[t.NONNUMERICIDENTIFIER]}|${src[t.NUMERICIDENTIFIER]})`);
|
|
284
|
-
createToken("PRERELEASEIDENTIFIERLOOSE", `(?:${src[t.NONNUMERICIDENTIFIER]}|${src[t.NUMERICIDENTIFIERLOOSE]})`);
|
|
285
|
-
createToken("PRERELEASE", `(?:-(${src[t.PRERELEASEIDENTIFIER]}(?:\\.${src[t.PRERELEASEIDENTIFIER]})*))`);
|
|
286
|
-
createToken("PRERELEASELOOSE", `(?:-?(${src[t.PRERELEASEIDENTIFIERLOOSE]}(?:\\.${src[t.PRERELEASEIDENTIFIERLOOSE]})*))`);
|
|
287
|
-
createToken("BUILDIDENTIFIER", `${LETTERDASHNUMBER}+`);
|
|
288
|
-
createToken("BUILD", `(?:\\+(${src[t.BUILDIDENTIFIER]}(?:\\.${src[t.BUILDIDENTIFIER]})*))`);
|
|
289
|
-
createToken("FULLPLAIN", `v?${src[t.MAINVERSION]}${src[t.PRERELEASE]}?${src[t.BUILD]}?`);
|
|
290
|
-
createToken("FULL", `^${src[t.FULLPLAIN]}$`);
|
|
291
|
-
createToken("LOOSEPLAIN", `[v=\\s]*${src[t.MAINVERSIONLOOSE]}${src[t.PRERELEASELOOSE]}?${src[t.BUILD]}?`);
|
|
292
|
-
createToken("LOOSE", `^${src[t.LOOSEPLAIN]}$`);
|
|
293
|
-
createToken("GTLT", "((?:<|>)?=?)");
|
|
294
|
-
createToken("XRANGEIDENTIFIERLOOSE", `${src[t.NUMERICIDENTIFIERLOOSE]}|x|X|\\*`);
|
|
295
|
-
createToken("XRANGEIDENTIFIER", `${src[t.NUMERICIDENTIFIER]}|x|X|\\*`);
|
|
296
|
-
createToken("XRANGEPLAIN", `[v=\\s]*(${src[t.XRANGEIDENTIFIER]})(?:\\.(${src[t.XRANGEIDENTIFIER]})(?:\\.(${src[t.XRANGEIDENTIFIER]})(?:${src[t.PRERELEASE]})?${src[t.BUILD]}?)?)?`);
|
|
297
|
-
createToken("XRANGEPLAINLOOSE", `[v=\\s]*(${src[t.XRANGEIDENTIFIERLOOSE]})(?:\\.(${src[t.XRANGEIDENTIFIERLOOSE]})(?:\\.(${src[t.XRANGEIDENTIFIERLOOSE]})(?:${src[t.PRERELEASELOOSE]})?${src[t.BUILD]}?)?)?`);
|
|
298
|
-
createToken("XRANGE", `^${src[t.GTLT]}\\s*${src[t.XRANGEPLAIN]}$`);
|
|
299
|
-
createToken("XRANGELOOSE", `^${src[t.GTLT]}\\s*${src[t.XRANGEPLAINLOOSE]}$`);
|
|
300
|
-
createToken("COERCEPLAIN", `${"(^|[^\\d])(\\d{1,"}${MAX_SAFE_COMPONENT_LENGTH}})(?:\\.(\\d{1,${MAX_SAFE_COMPONENT_LENGTH}}))?(?:\\.(\\d{1,${MAX_SAFE_COMPONENT_LENGTH}}))?`);
|
|
301
|
-
createToken("COERCE", `${src[t.COERCEPLAIN]}(?:$|[^\\d])`);
|
|
302
|
-
createToken("COERCEFULL", src[t.COERCEPLAIN] + `(?:${src[t.PRERELEASE]})?(?:${src[t.BUILD]})?(?:$|[^\\d])`);
|
|
303
|
-
createToken("COERCERTL", src[t.COERCE], true);
|
|
304
|
-
createToken("COERCERTLFULL", src[t.COERCEFULL], true);
|
|
305
|
-
createToken("LONETILDE", "(?:~>?)");
|
|
306
|
-
createToken("TILDETRIM", `(\\s*)${src[t.LONETILDE]}\\s+`, true);
|
|
307
|
-
exports.tildeTrimReplace = "$1~";
|
|
308
|
-
createToken("TILDE", `^${src[t.LONETILDE]}${src[t.XRANGEPLAIN]}$`);
|
|
309
|
-
createToken("TILDELOOSE", `^${src[t.LONETILDE]}${src[t.XRANGEPLAINLOOSE]}$`);
|
|
310
|
-
createToken("LONECARET", "(?:\\^)");
|
|
311
|
-
createToken("CARETTRIM", `(\\s*)${src[t.LONECARET]}\\s+`, true);
|
|
312
|
-
exports.caretTrimReplace = "$1^";
|
|
313
|
-
createToken("CARET", `^${src[t.LONECARET]}${src[t.XRANGEPLAIN]}$`);
|
|
314
|
-
createToken("CARETLOOSE", `^${src[t.LONECARET]}${src[t.XRANGEPLAINLOOSE]}$`);
|
|
315
|
-
createToken("COMPARATORLOOSE", `^${src[t.GTLT]}\\s*(${src[t.LOOSEPLAIN]})$|^$`);
|
|
316
|
-
createToken("COMPARATOR", `^${src[t.GTLT]}\\s*(${src[t.FULLPLAIN]})$|^$`);
|
|
317
|
-
createToken("COMPARATORTRIM", `(\\s*)${src[t.GTLT]}\\s*(${src[t.LOOSEPLAIN]}|${src[t.XRANGEPLAIN]})`, true);
|
|
318
|
-
exports.comparatorTrimReplace = "$1$2$3";
|
|
319
|
-
createToken("HYPHENRANGE", `^\\s*(${src[t.XRANGEPLAIN]})\\s+-\\s+(${src[t.XRANGEPLAIN]})\\s*$`);
|
|
320
|
-
createToken("HYPHENRANGELOOSE", `^\\s*(${src[t.XRANGEPLAINLOOSE]})\\s+-\\s+(${src[t.XRANGEPLAINLOOSE]})\\s*$`);
|
|
321
|
-
createToken("STAR", "(<|>)?=?\\s*\\*");
|
|
322
|
-
createToken("GTE0", "^\\s*>=\\s*0\\.0\\.0\\s*$");
|
|
323
|
-
createToken("GTE0PRE", "^\\s*>=\\s*0\\.0\\.0-0\\s*$");
|
|
324
|
-
})(re, re.exports);
|
|
325
|
-
return re.exports;
|
|
326
|
-
}
|
|
327
|
-
var parseOptions_1;
|
|
328
|
-
var hasRequiredParseOptions;
|
|
329
|
-
function requireParseOptions() {
|
|
330
|
-
if (hasRequiredParseOptions) return parseOptions_1;
|
|
331
|
-
hasRequiredParseOptions = 1;
|
|
332
|
-
const looseOption = Object.freeze({ loose: true });
|
|
333
|
-
const emptyOpts = Object.freeze({});
|
|
334
|
-
const parseOptions = (options) => {
|
|
335
|
-
if (!options) {
|
|
336
|
-
return emptyOpts;
|
|
337
|
-
}
|
|
338
|
-
if (typeof options !== "object") {
|
|
339
|
-
return looseOption;
|
|
340
|
-
}
|
|
341
|
-
return options;
|
|
342
|
-
};
|
|
343
|
-
parseOptions_1 = parseOptions;
|
|
344
|
-
return parseOptions_1;
|
|
345
|
-
}
|
|
346
|
-
var identifiers;
|
|
347
|
-
var hasRequiredIdentifiers;
|
|
348
|
-
function requireIdentifiers() {
|
|
349
|
-
if (hasRequiredIdentifiers) return identifiers;
|
|
350
|
-
hasRequiredIdentifiers = 1;
|
|
351
|
-
const numeric = /^[0-9]+$/;
|
|
352
|
-
const compareIdentifiers = (a2, b2) => {
|
|
353
|
-
if (typeof a2 === "number" && typeof b2 === "number") {
|
|
354
|
-
return a2 === b2 ? 0 : a2 < b2 ? -1 : 1;
|
|
355
|
-
}
|
|
356
|
-
const anum = numeric.test(a2);
|
|
357
|
-
const bnum = numeric.test(b2);
|
|
358
|
-
if (anum && bnum) {
|
|
359
|
-
a2 = +a2;
|
|
360
|
-
b2 = +b2;
|
|
361
|
-
}
|
|
362
|
-
return a2 === b2 ? 0 : anum && !bnum ? -1 : bnum && !anum ? 1 : a2 < b2 ? -1 : 1;
|
|
363
|
-
};
|
|
364
|
-
const rcompareIdentifiers = (a2, b2) => compareIdentifiers(b2, a2);
|
|
365
|
-
identifiers = {
|
|
366
|
-
compareIdentifiers,
|
|
367
|
-
rcompareIdentifiers
|
|
368
|
-
};
|
|
369
|
-
return identifiers;
|
|
97
|
+
return [...window._nc_filelistactions ?? []];
|
|
370
98
|
}
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
if (hasRequiredSemver) return semver;
|
|
375
|
-
hasRequiredSemver = 1;
|
|
376
|
-
const debug = requireDebug();
|
|
377
|
-
const { MAX_LENGTH, MAX_SAFE_INTEGER } = requireConstants();
|
|
378
|
-
const { safeRe: re2, t } = requireRe();
|
|
379
|
-
const parseOptions = requireParseOptions();
|
|
380
|
-
const { compareIdentifiers } = requireIdentifiers();
|
|
381
|
-
class SemVer {
|
|
382
|
-
constructor(version, options) {
|
|
383
|
-
options = parseOptions(options);
|
|
384
|
-
if (version instanceof SemVer) {
|
|
385
|
-
if (version.loose === !!options.loose && version.includePrerelease === !!options.includePrerelease) {
|
|
386
|
-
return version;
|
|
387
|
-
} else {
|
|
388
|
-
version = version.version;
|
|
389
|
-
}
|
|
390
|
-
} else if (typeof version !== "string") {
|
|
391
|
-
throw new TypeError(`Invalid version. Must be a string. Got type "${typeof version}".`);
|
|
392
|
-
}
|
|
393
|
-
if (version.length > MAX_LENGTH) {
|
|
394
|
-
throw new TypeError(
|
|
395
|
-
`version is longer than ${MAX_LENGTH} characters`
|
|
396
|
-
);
|
|
397
|
-
}
|
|
398
|
-
debug("SemVer", version, options);
|
|
399
|
-
this.options = options;
|
|
400
|
-
this.loose = !!options.loose;
|
|
401
|
-
this.includePrerelease = !!options.includePrerelease;
|
|
402
|
-
const m = version.trim().match(options.loose ? re2[t.LOOSE] : re2[t.FULL]);
|
|
403
|
-
if (!m) {
|
|
404
|
-
throw new TypeError(`Invalid Version: ${version}`);
|
|
405
|
-
}
|
|
406
|
-
this.raw = version;
|
|
407
|
-
this.major = +m[1];
|
|
408
|
-
this.minor = +m[2];
|
|
409
|
-
this.patch = +m[3];
|
|
410
|
-
if (this.major > MAX_SAFE_INTEGER || this.major < 0) {
|
|
411
|
-
throw new TypeError("Invalid major version");
|
|
412
|
-
}
|
|
413
|
-
if (this.minor > MAX_SAFE_INTEGER || this.minor < 0) {
|
|
414
|
-
throw new TypeError("Invalid minor version");
|
|
415
|
-
}
|
|
416
|
-
if (this.patch > MAX_SAFE_INTEGER || this.patch < 0) {
|
|
417
|
-
throw new TypeError("Invalid patch version");
|
|
418
|
-
}
|
|
419
|
-
if (!m[4]) {
|
|
420
|
-
this.prerelease = [];
|
|
421
|
-
} else {
|
|
422
|
-
this.prerelease = m[4].split(".").map((id) => {
|
|
423
|
-
if (/^[0-9]+$/.test(id)) {
|
|
424
|
-
const num = +id;
|
|
425
|
-
if (num >= 0 && num < MAX_SAFE_INTEGER) {
|
|
426
|
-
return num;
|
|
427
|
-
}
|
|
428
|
-
}
|
|
429
|
-
return id;
|
|
430
|
-
});
|
|
431
|
-
}
|
|
432
|
-
this.build = m[5] ? m[5].split(".") : [];
|
|
433
|
-
this.format();
|
|
434
|
-
}
|
|
435
|
-
format() {
|
|
436
|
-
this.version = `${this.major}.${this.minor}.${this.patch}`;
|
|
437
|
-
if (this.prerelease.length) {
|
|
438
|
-
this.version += `-${this.prerelease.join(".")}`;
|
|
439
|
-
}
|
|
440
|
-
return this.version;
|
|
441
|
-
}
|
|
442
|
-
toString() {
|
|
443
|
-
return this.version;
|
|
444
|
-
}
|
|
445
|
-
compare(other) {
|
|
446
|
-
debug("SemVer.compare", this.version, this.options, other);
|
|
447
|
-
if (!(other instanceof SemVer)) {
|
|
448
|
-
if (typeof other === "string" && other === this.version) {
|
|
449
|
-
return 0;
|
|
450
|
-
}
|
|
451
|
-
other = new SemVer(other, this.options);
|
|
452
|
-
}
|
|
453
|
-
if (other.version === this.version) {
|
|
454
|
-
return 0;
|
|
455
|
-
}
|
|
456
|
-
return this.compareMain(other) || this.comparePre(other);
|
|
457
|
-
}
|
|
458
|
-
compareMain(other) {
|
|
459
|
-
if (!(other instanceof SemVer)) {
|
|
460
|
-
other = new SemVer(other, this.options);
|
|
461
|
-
}
|
|
462
|
-
if (this.major < other.major) {
|
|
463
|
-
return -1;
|
|
464
|
-
}
|
|
465
|
-
if (this.major > other.major) {
|
|
466
|
-
return 1;
|
|
467
|
-
}
|
|
468
|
-
if (this.minor < other.minor) {
|
|
469
|
-
return -1;
|
|
470
|
-
}
|
|
471
|
-
if (this.minor > other.minor) {
|
|
472
|
-
return 1;
|
|
473
|
-
}
|
|
474
|
-
if (this.patch < other.patch) {
|
|
475
|
-
return -1;
|
|
476
|
-
}
|
|
477
|
-
if (this.patch > other.patch) {
|
|
478
|
-
return 1;
|
|
479
|
-
}
|
|
480
|
-
return 0;
|
|
481
|
-
}
|
|
482
|
-
comparePre(other) {
|
|
483
|
-
if (!(other instanceof SemVer)) {
|
|
484
|
-
other = new SemVer(other, this.options);
|
|
485
|
-
}
|
|
486
|
-
if (this.prerelease.length && !other.prerelease.length) {
|
|
487
|
-
return -1;
|
|
488
|
-
} else if (!this.prerelease.length && other.prerelease.length) {
|
|
489
|
-
return 1;
|
|
490
|
-
} else if (!this.prerelease.length && !other.prerelease.length) {
|
|
491
|
-
return 0;
|
|
492
|
-
}
|
|
493
|
-
let i = 0;
|
|
494
|
-
do {
|
|
495
|
-
const a2 = this.prerelease[i];
|
|
496
|
-
const b2 = other.prerelease[i];
|
|
497
|
-
debug("prerelease compare", i, a2, b2);
|
|
498
|
-
if (a2 === void 0 && b2 === void 0) {
|
|
499
|
-
return 0;
|
|
500
|
-
} else if (b2 === void 0) {
|
|
501
|
-
return 1;
|
|
502
|
-
} else if (a2 === void 0) {
|
|
503
|
-
return -1;
|
|
504
|
-
} else if (a2 === b2) {
|
|
505
|
-
continue;
|
|
506
|
-
} else {
|
|
507
|
-
return compareIdentifiers(a2, b2);
|
|
508
|
-
}
|
|
509
|
-
} while (++i);
|
|
510
|
-
}
|
|
511
|
-
compareBuild(other) {
|
|
512
|
-
if (!(other instanceof SemVer)) {
|
|
513
|
-
other = new SemVer(other, this.options);
|
|
514
|
-
}
|
|
515
|
-
let i = 0;
|
|
516
|
-
do {
|
|
517
|
-
const a2 = this.build[i];
|
|
518
|
-
const b2 = other.build[i];
|
|
519
|
-
debug("build compare", i, a2, b2);
|
|
520
|
-
if (a2 === void 0 && b2 === void 0) {
|
|
521
|
-
return 0;
|
|
522
|
-
} else if (b2 === void 0) {
|
|
523
|
-
return 1;
|
|
524
|
-
} else if (a2 === void 0) {
|
|
525
|
-
return -1;
|
|
526
|
-
} else if (a2 === b2) {
|
|
527
|
-
continue;
|
|
528
|
-
} else {
|
|
529
|
-
return compareIdentifiers(a2, b2);
|
|
530
|
-
}
|
|
531
|
-
} while (++i);
|
|
532
|
-
}
|
|
533
|
-
// preminor will bump the version up to the next minor release, and immediately
|
|
534
|
-
// down to pre-release. premajor and prepatch work the same way.
|
|
535
|
-
inc(release, identifier, identifierBase) {
|
|
536
|
-
if (release.startsWith("pre")) {
|
|
537
|
-
if (!identifier && identifierBase === false) {
|
|
538
|
-
throw new Error("invalid increment argument: identifier is empty");
|
|
539
|
-
}
|
|
540
|
-
if (identifier) {
|
|
541
|
-
const match = `-${identifier}`.match(this.options.loose ? re2[t.PRERELEASELOOSE] : re2[t.PRERELEASE]);
|
|
542
|
-
if (!match || match[1] !== identifier) {
|
|
543
|
-
throw new Error(`invalid identifier: ${identifier}`);
|
|
544
|
-
}
|
|
545
|
-
}
|
|
546
|
-
}
|
|
547
|
-
switch (release) {
|
|
548
|
-
case "premajor":
|
|
549
|
-
this.prerelease.length = 0;
|
|
550
|
-
this.patch = 0;
|
|
551
|
-
this.minor = 0;
|
|
552
|
-
this.major++;
|
|
553
|
-
this.inc("pre", identifier, identifierBase);
|
|
554
|
-
break;
|
|
555
|
-
case "preminor":
|
|
556
|
-
this.prerelease.length = 0;
|
|
557
|
-
this.patch = 0;
|
|
558
|
-
this.minor++;
|
|
559
|
-
this.inc("pre", identifier, identifierBase);
|
|
560
|
-
break;
|
|
561
|
-
case "prepatch":
|
|
562
|
-
this.prerelease.length = 0;
|
|
563
|
-
this.inc("patch", identifier, identifierBase);
|
|
564
|
-
this.inc("pre", identifier, identifierBase);
|
|
565
|
-
break;
|
|
566
|
-
// If the input is a non-prerelease version, this acts the same as
|
|
567
|
-
// prepatch.
|
|
568
|
-
case "prerelease":
|
|
569
|
-
if (this.prerelease.length === 0) {
|
|
570
|
-
this.inc("patch", identifier, identifierBase);
|
|
571
|
-
}
|
|
572
|
-
this.inc("pre", identifier, identifierBase);
|
|
573
|
-
break;
|
|
574
|
-
case "release":
|
|
575
|
-
if (this.prerelease.length === 0) {
|
|
576
|
-
throw new Error(`version ${this.raw} is not a prerelease`);
|
|
577
|
-
}
|
|
578
|
-
this.prerelease.length = 0;
|
|
579
|
-
break;
|
|
580
|
-
case "major":
|
|
581
|
-
if (this.minor !== 0 || this.patch !== 0 || this.prerelease.length === 0) {
|
|
582
|
-
this.major++;
|
|
583
|
-
}
|
|
584
|
-
this.minor = 0;
|
|
585
|
-
this.patch = 0;
|
|
586
|
-
this.prerelease = [];
|
|
587
|
-
break;
|
|
588
|
-
case "minor":
|
|
589
|
-
if (this.patch !== 0 || this.prerelease.length === 0) {
|
|
590
|
-
this.minor++;
|
|
591
|
-
}
|
|
592
|
-
this.patch = 0;
|
|
593
|
-
this.prerelease = [];
|
|
594
|
-
break;
|
|
595
|
-
case "patch":
|
|
596
|
-
if (this.prerelease.length === 0) {
|
|
597
|
-
this.patch++;
|
|
598
|
-
}
|
|
599
|
-
this.prerelease = [];
|
|
600
|
-
break;
|
|
601
|
-
// This probably shouldn't be used publicly.
|
|
602
|
-
// 1.0.0 'pre' would become 1.0.0-0 which is the wrong direction.
|
|
603
|
-
case "pre": {
|
|
604
|
-
const base = Number(identifierBase) ? 1 : 0;
|
|
605
|
-
if (this.prerelease.length === 0) {
|
|
606
|
-
this.prerelease = [base];
|
|
607
|
-
} else {
|
|
608
|
-
let i = this.prerelease.length;
|
|
609
|
-
while (--i >= 0) {
|
|
610
|
-
if (typeof this.prerelease[i] === "number") {
|
|
611
|
-
this.prerelease[i]++;
|
|
612
|
-
i = -2;
|
|
613
|
-
}
|
|
614
|
-
}
|
|
615
|
-
if (i === -1) {
|
|
616
|
-
if (identifier === this.prerelease.join(".") && identifierBase === false) {
|
|
617
|
-
throw new Error("invalid increment argument: identifier already exists");
|
|
618
|
-
}
|
|
619
|
-
this.prerelease.push(base);
|
|
620
|
-
}
|
|
621
|
-
}
|
|
622
|
-
if (identifier) {
|
|
623
|
-
let prerelease = [identifier, base];
|
|
624
|
-
if (identifierBase === false) {
|
|
625
|
-
prerelease = [identifier];
|
|
626
|
-
}
|
|
627
|
-
if (compareIdentifiers(this.prerelease[0], identifier) === 0) {
|
|
628
|
-
if (isNaN(this.prerelease[1])) {
|
|
629
|
-
this.prerelease = prerelease;
|
|
630
|
-
}
|
|
631
|
-
} else {
|
|
632
|
-
this.prerelease = prerelease;
|
|
633
|
-
}
|
|
634
|
-
}
|
|
635
|
-
break;
|
|
636
|
-
}
|
|
637
|
-
default:
|
|
638
|
-
throw new Error(`invalid increment argument: ${release}`);
|
|
639
|
-
}
|
|
640
|
-
this.raw = this.format();
|
|
641
|
-
if (this.build.length) {
|
|
642
|
-
this.raw += `+${this.build.join(".")}`;
|
|
643
|
-
}
|
|
644
|
-
return this;
|
|
645
|
-
}
|
|
99
|
+
function validateAction(action) {
|
|
100
|
+
if (!action.id || typeof action.id !== "string") {
|
|
101
|
+
throw new Error("Invalid id");
|
|
646
102
|
}
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
}
|
|
650
|
-
var major_1;
|
|
651
|
-
var hasRequiredMajor;
|
|
652
|
-
function requireMajor() {
|
|
653
|
-
if (hasRequiredMajor) return major_1;
|
|
654
|
-
hasRequiredMajor = 1;
|
|
655
|
-
const SemVer = requireSemver();
|
|
656
|
-
const major2 = (a2, loose) => new SemVer(a2, loose).major;
|
|
657
|
-
major_1 = major2;
|
|
658
|
-
return major_1;
|
|
659
|
-
}
|
|
660
|
-
var majorExports = requireMajor();
|
|
661
|
-
const major = /* @__PURE__ */ getDefaultExportFromCjs(majorExports);
|
|
662
|
-
var parse_1;
|
|
663
|
-
var hasRequiredParse;
|
|
664
|
-
function requireParse() {
|
|
665
|
-
if (hasRequiredParse) return parse_1;
|
|
666
|
-
hasRequiredParse = 1;
|
|
667
|
-
const SemVer = requireSemver();
|
|
668
|
-
const parse = (version, options, throwErrors = false) => {
|
|
669
|
-
if (version instanceof SemVer) {
|
|
670
|
-
return version;
|
|
671
|
-
}
|
|
672
|
-
try {
|
|
673
|
-
return new SemVer(version, options);
|
|
674
|
-
} catch (er) {
|
|
675
|
-
if (!throwErrors) {
|
|
676
|
-
return null;
|
|
677
|
-
}
|
|
678
|
-
throw er;
|
|
679
|
-
}
|
|
680
|
-
};
|
|
681
|
-
parse_1 = parse;
|
|
682
|
-
return parse_1;
|
|
683
|
-
}
|
|
684
|
-
var valid_1;
|
|
685
|
-
var hasRequiredValid;
|
|
686
|
-
function requireValid() {
|
|
687
|
-
if (hasRequiredValid) return valid_1;
|
|
688
|
-
hasRequiredValid = 1;
|
|
689
|
-
const parse = requireParse();
|
|
690
|
-
const valid2 = (version, options) => {
|
|
691
|
-
const v = parse(version, options);
|
|
692
|
-
return v ? v.version : null;
|
|
693
|
-
};
|
|
694
|
-
valid_1 = valid2;
|
|
695
|
-
return valid_1;
|
|
696
|
-
}
|
|
697
|
-
var validExports = requireValid();
|
|
698
|
-
const valid = /* @__PURE__ */ getDefaultExportFromCjs(validExports);
|
|
699
|
-
/*!
|
|
700
|
-
* SPDX-FileCopyrightText: 2019 Nextcloud GmbH and Nextcloud contributors
|
|
701
|
-
* SPDX-License-Identifier: GPL-3.0-or-later
|
|
702
|
-
*/
|
|
703
|
-
class ProxyBus {
|
|
704
|
-
bus;
|
|
705
|
-
constructor(bus2) {
|
|
706
|
-
if (typeof bus2.getVersion !== "function" || !valid(bus2.getVersion())) {
|
|
707
|
-
console.warn("Proxying an event bus with an unknown or invalid version");
|
|
708
|
-
} else if (major(bus2.getVersion()) !== major(this.getVersion())) {
|
|
709
|
-
console.warn(
|
|
710
|
-
"Proxying an event bus of version " + bus2.getVersion() + " with " + this.getVersion()
|
|
711
|
-
);
|
|
712
|
-
}
|
|
713
|
-
this.bus = bus2;
|
|
103
|
+
if (!action.displayName || typeof action.displayName !== "function") {
|
|
104
|
+
throw new Error("Invalid displayName function");
|
|
714
105
|
}
|
|
715
|
-
|
|
716
|
-
|
|
106
|
+
if ("iconSvgInline" in action && typeof action.iconSvgInline !== "function") {
|
|
107
|
+
throw new Error("Invalid iconSvgInline function");
|
|
717
108
|
}
|
|
718
|
-
|
|
719
|
-
|
|
109
|
+
if ("order" in action && typeof action.order !== "number") {
|
|
110
|
+
throw new Error("Invalid order");
|
|
720
111
|
}
|
|
721
|
-
|
|
722
|
-
|
|
112
|
+
if ("enabled" in action && typeof action.enabled !== "function") {
|
|
113
|
+
throw new Error("Invalid enabled function");
|
|
723
114
|
}
|
|
724
|
-
|
|
725
|
-
|
|
115
|
+
if (!action.exec || typeof action.exec !== "function") {
|
|
116
|
+
throw new Error("Invalid exec function");
|
|
726
117
|
}
|
|
727
118
|
}
|
|
728
119
|
/*!
|
|
729
|
-
* SPDX-FileCopyrightText:
|
|
730
|
-
* SPDX-License-Identifier:
|
|
120
|
+
* SPDX-FileCopyrightText: 2023 Nextcloud GmbH and Nextcloud contributors
|
|
121
|
+
* SPDX-License-Identifier: AGPL-3.0-or-later
|
|
731
122
|
*/
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
}
|
|
737
|
-
subscribe(name, handler) {
|
|
738
|
-
this.handlers.set(
|
|
739
|
-
name,
|
|
740
|
-
(this.handlers.get(name) || []).concat(
|
|
741
|
-
handler
|
|
742
|
-
)
|
|
743
|
-
);
|
|
744
|
-
}
|
|
745
|
-
unsubscribe(name, handler) {
|
|
746
|
-
this.handlers.set(
|
|
747
|
-
name,
|
|
748
|
-
(this.handlers.get(name) || []).filter((h) => h !== handler)
|
|
749
|
-
);
|
|
750
|
-
}
|
|
751
|
-
emit(name, ...event) {
|
|
752
|
-
const handlers = this.handlers.get(name) || [];
|
|
753
|
-
handlers.forEach((h) => {
|
|
754
|
-
try {
|
|
755
|
-
;
|
|
756
|
-
h(event[0]);
|
|
757
|
-
} catch (e) {
|
|
758
|
-
console.error("could not invoke event listener", e);
|
|
759
|
-
}
|
|
760
|
-
});
|
|
123
|
+
function registerFileListFilter(filter) {
|
|
124
|
+
window._nc_filelist_filters ??= /* @__PURE__ */ new Map();
|
|
125
|
+
if (window._nc_filelist_filters.has(filter.id)) {
|
|
126
|
+
throw new Error(`File list filter "${filter.id}" already registered`);
|
|
761
127
|
}
|
|
128
|
+
window._nc_filelist_filters.set(filter.id, filter);
|
|
129
|
+
getRegistry().dispatchTypedEvent("register:listFilter", new CustomEvent("register:listFilter", { detail: filter }));
|
|
762
130
|
}
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
function getBus() {
|
|
769
|
-
if (bus !== null) {
|
|
770
|
-
return bus;
|
|
771
|
-
}
|
|
772
|
-
if (typeof window === "undefined") {
|
|
773
|
-
return new Proxy({}, {
|
|
774
|
-
get: () => {
|
|
775
|
-
return () => console.error(
|
|
776
|
-
"Window not available, EventBus can not be established!"
|
|
777
|
-
);
|
|
778
|
-
}
|
|
779
|
-
});
|
|
780
|
-
}
|
|
781
|
-
if (window.OC?._eventBus && typeof window._nc_event_bus === "undefined") {
|
|
782
|
-
console.warn(
|
|
783
|
-
"found old event bus instance at OC._eventBus. Update your version!"
|
|
784
|
-
);
|
|
785
|
-
window._nc_event_bus = window.OC._eventBus;
|
|
786
|
-
}
|
|
787
|
-
if (typeof window?._nc_event_bus !== "undefined") {
|
|
788
|
-
bus = new ProxyBus(window._nc_event_bus);
|
|
789
|
-
} else {
|
|
790
|
-
bus = window._nc_event_bus = new SimpleBus();
|
|
131
|
+
function unregisterFileListFilter(filterId) {
|
|
132
|
+
if (window._nc_filelist_filters && window._nc_filelist_filters.has(filterId)) {
|
|
133
|
+
const filter = window._nc_filelist_filters.get(filterId);
|
|
134
|
+
window._nc_filelist_filters.delete(filterId);
|
|
135
|
+
getRegistry().dispatchTypedEvent("unregister:listFilter", new CustomEvent("unregister:listFilter", { detail: filter }));
|
|
791
136
|
}
|
|
792
|
-
return bus;
|
|
793
137
|
}
|
|
794
|
-
function
|
|
795
|
-
|
|
138
|
+
function getFileListFilters() {
|
|
139
|
+
if (!window._nc_filelist_filters) {
|
|
140
|
+
return [];
|
|
141
|
+
}
|
|
142
|
+
return [...window._nc_filelist_filters.values()];
|
|
796
143
|
}
|
|
797
144
|
/*!
|
|
798
145
|
* SPDX-FileCopyrightText: 2023 Nextcloud GmbH and Nextcloud contributors
|
|
@@ -816,84 +163,36 @@ class FileListFilter extends TypedEventTarget {
|
|
|
816
163
|
this.dispatchTypedEvent("update:filter", new CustomEvent("update:filter"));
|
|
817
164
|
}
|
|
818
165
|
}
|
|
819
|
-
function
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
}
|
|
823
|
-
if (window._nc_filelist_filters.has(filter.id)) {
|
|
824
|
-
throw new Error(`File list filter "${filter.id}" already registered`);
|
|
825
|
-
}
|
|
826
|
-
window._nc_filelist_filters.set(filter.id, filter);
|
|
827
|
-
emit("files:filter:added", filter);
|
|
828
|
-
}
|
|
829
|
-
function unregisterFileListFilter(filterId) {
|
|
830
|
-
if (window._nc_filelist_filters && window._nc_filelist_filters.has(filterId)) {
|
|
831
|
-
window._nc_filelist_filters.delete(filterId);
|
|
832
|
-
emit("files:filter:removed", filterId);
|
|
833
|
-
}
|
|
834
|
-
}
|
|
835
|
-
function getFileListFilters() {
|
|
836
|
-
if (!window._nc_filelist_filters) {
|
|
837
|
-
return [];
|
|
838
|
-
}
|
|
839
|
-
return [...window._nc_filelist_filters.values()];
|
|
840
|
-
}
|
|
841
|
-
class Header {
|
|
842
|
-
_header;
|
|
843
|
-
constructor(header) {
|
|
844
|
-
this.validateHeader(header);
|
|
845
|
-
this._header = header;
|
|
846
|
-
}
|
|
847
|
-
get id() {
|
|
848
|
-
return this._header.id;
|
|
849
|
-
}
|
|
850
|
-
get order() {
|
|
851
|
-
return this._header.order;
|
|
852
|
-
}
|
|
853
|
-
get enabled() {
|
|
854
|
-
return this._header.enabled;
|
|
855
|
-
}
|
|
856
|
-
get render() {
|
|
857
|
-
return this._header.render;
|
|
858
|
-
}
|
|
859
|
-
get updated() {
|
|
860
|
-
return this._header.updated;
|
|
861
|
-
}
|
|
862
|
-
validateHeader(header) {
|
|
863
|
-
if (!header.id || !header.render || !header.updated) {
|
|
864
|
-
throw new Error("Invalid header: id, render and updated are required");
|
|
865
|
-
}
|
|
866
|
-
if (typeof header.id !== "string") {
|
|
867
|
-
throw new Error("Invalid id property");
|
|
868
|
-
}
|
|
869
|
-
if (header.enabled !== void 0 && typeof header.enabled !== "function") {
|
|
870
|
-
throw new Error("Invalid enabled property");
|
|
871
|
-
}
|
|
872
|
-
if (header.render && typeof header.render !== "function") {
|
|
873
|
-
throw new Error("Invalid render property");
|
|
874
|
-
}
|
|
875
|
-
if (header.updated && typeof header.updated !== "function") {
|
|
876
|
-
throw new Error("Invalid updated property");
|
|
877
|
-
}
|
|
878
|
-
}
|
|
879
|
-
}
|
|
880
|
-
function registerFileListHeaders(header) {
|
|
881
|
-
if (typeof window._nc_filelistheader === "undefined") {
|
|
882
|
-
window._nc_filelistheader = [];
|
|
883
|
-
logger.debug("FileListHeaders initialized");
|
|
884
|
-
}
|
|
166
|
+
function registerFileListHeader(header) {
|
|
167
|
+
validateHeader(header);
|
|
168
|
+
window._nc_filelistheader ??= [];
|
|
885
169
|
if (window._nc_filelistheader.find((search) => search.id === header.id)) {
|
|
886
170
|
logger.error(`Header ${header.id} already registered`, { header });
|
|
887
171
|
return;
|
|
888
172
|
}
|
|
889
173
|
window._nc_filelistheader.push(header);
|
|
174
|
+
getRegistry().dispatchTypedEvent("register:listHeader", new CustomEvent("register:listHeader", { detail: header }));
|
|
890
175
|
}
|
|
891
176
|
function getFileListHeaders() {
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
177
|
+
window._nc_filelistheader ??= [];
|
|
178
|
+
return [...window._nc_filelistheader];
|
|
179
|
+
}
|
|
180
|
+
function validateHeader(header) {
|
|
181
|
+
if (!header.id || !header.render || !header.updated) {
|
|
182
|
+
throw new Error("Invalid header: id, render and updated are required");
|
|
183
|
+
}
|
|
184
|
+
if (typeof header.id !== "string") {
|
|
185
|
+
throw new Error("Invalid id property");
|
|
186
|
+
}
|
|
187
|
+
if (header.enabled !== void 0 && typeof header.enabled !== "function") {
|
|
188
|
+
throw new Error("Invalid enabled property");
|
|
189
|
+
}
|
|
190
|
+
if (header.render && typeof header.render !== "function") {
|
|
191
|
+
throw new Error("Invalid render property");
|
|
192
|
+
}
|
|
193
|
+
if (header.updated && typeof header.updated !== "function") {
|
|
194
|
+
throw new Error("Invalid updated property");
|
|
895
195
|
}
|
|
896
|
-
return window._nc_filelistheader;
|
|
897
196
|
}
|
|
898
197
|
function checkOptionalProperty(obj, property, type) {
|
|
899
198
|
if (typeof obj[property] !== "undefined") {
|
|
@@ -1056,16 +355,18 @@ class Navigation extends TypedEventTarget {
|
|
|
1056
355
|
/**
|
|
1057
356
|
* Register a new view on the navigation
|
|
1058
357
|
*
|
|
1059
|
-
* @param
|
|
358
|
+
* @param views The views to register
|
|
1060
359
|
* @throws {Error} if a view with the same id is already registered
|
|
1061
360
|
* @throws {Error} if the registered view is invalid
|
|
1062
361
|
*/
|
|
1063
|
-
register(
|
|
1064
|
-
|
|
1065
|
-
|
|
362
|
+
register(...views) {
|
|
363
|
+
for (const view of views) {
|
|
364
|
+
if (this._views.find((search) => search.id === view.id)) {
|
|
365
|
+
throw new Error(`IView id ${view.id} is already registered`);
|
|
366
|
+
}
|
|
367
|
+
validateView(view);
|
|
1066
368
|
}
|
|
1067
|
-
|
|
1068
|
-
this._views.push(view);
|
|
369
|
+
this._views.push(...views);
|
|
1069
370
|
this.dispatchTypedEvent("update", new CustomEvent("update"));
|
|
1070
371
|
}
|
|
1071
372
|
/**
|
|
@@ -1463,10 +764,10 @@ function stringify(value) {
|
|
|
1463
764
|
}
|
|
1464
765
|
return String(value);
|
|
1465
766
|
}
|
|
1466
|
-
function orderBy(collection,
|
|
1467
|
-
|
|
767
|
+
function orderBy(collection, identifiers, orders) {
|
|
768
|
+
identifiers = identifiers ?? [(value) => value];
|
|
1468
769
|
orders = orders ?? [];
|
|
1469
|
-
const sorting =
|
|
770
|
+
const sorting = identifiers.map((_, index) => (orders[index] ?? "asc") === "asc" ? 1 : -1);
|
|
1470
771
|
const collator = Intl.Collator(
|
|
1471
772
|
[getLanguage(), getCanonicalLocale()],
|
|
1472
773
|
{
|
|
@@ -1476,7 +777,7 @@ function orderBy(collection, identifiers2, orders) {
|
|
|
1476
777
|
}
|
|
1477
778
|
);
|
|
1478
779
|
return [...collection].sort((a2, b2) => {
|
|
1479
|
-
for (const [index, identifier] of
|
|
780
|
+
for (const [index, identifier] of identifiers.entries()) {
|
|
1480
781
|
const value = collator.compare(stringify(identifier(a2)), stringify(identifier(b2)));
|
|
1481
782
|
if (value !== 0) {
|
|
1482
783
|
return value * sorting[index];
|
|
@@ -1505,7 +806,7 @@ function sortNodes(nodes, options = {}) {
|
|
|
1505
806
|
}
|
|
1506
807
|
return name.lastIndexOf(".") > 0 ? name.slice(0, name.lastIndexOf(".")) : name;
|
|
1507
808
|
}
|
|
1508
|
-
const
|
|
809
|
+
const identifiers = [
|
|
1509
810
|
// 1: Sort favorites first if enabled
|
|
1510
811
|
...sortingOptions.sortFavoritesFirst ? [(v) => v.attributes?.favorite !== 1] : [],
|
|
1511
812
|
// 2: Sort folders first if sorting by name
|
|
@@ -1531,19 +832,16 @@ function sortNodes(nodes, options = {}) {
|
|
|
1531
832
|
// for 5: use configured sorting direction
|
|
1532
833
|
sortingOptions.sortingOrder
|
|
1533
834
|
];
|
|
1534
|
-
return orderBy(nodes,
|
|
835
|
+
return orderBy(nodes, identifiers, orders);
|
|
1535
836
|
}
|
|
1536
837
|
export {
|
|
1537
838
|
Column,
|
|
1538
839
|
DefaultType,
|
|
1539
840
|
a as File,
|
|
1540
|
-
FileAction,
|
|
1541
|
-
FileListAction,
|
|
1542
841
|
FileListFilter,
|
|
1543
842
|
FileType,
|
|
1544
843
|
FilesSortingMode,
|
|
1545
844
|
b as Folder,
|
|
1546
|
-
Header,
|
|
1547
845
|
InvalidFilenameError,
|
|
1548
846
|
InvalidFilenameErrorReason,
|
|
1549
847
|
Navigation,
|
|
@@ -1558,6 +856,7 @@ export {
|
|
|
1558
856
|
getFileListActions,
|
|
1559
857
|
getFileListFilters,
|
|
1560
858
|
getFileListHeaders,
|
|
859
|
+
getFilesRegistry,
|
|
1561
860
|
getNavigation,
|
|
1562
861
|
getNewFileMenu,
|
|
1563
862
|
getNewFileMenuEntries,
|
|
@@ -1571,7 +870,7 @@ export {
|
|
|
1571
870
|
registerFileAction,
|
|
1572
871
|
registerFileListAction,
|
|
1573
872
|
registerFileListFilter,
|
|
1574
|
-
|
|
873
|
+
registerFileListHeader,
|
|
1575
874
|
registerSidebarAction,
|
|
1576
875
|
registerSidebarTab,
|
|
1577
876
|
removeNewFileMenuEntry,
|