@nextcloud/files 3.8.0 → 3.9.1
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/fileAction.d.ts +7 -2
- package/dist/fileListFilters.d.ts +4 -0
- package/dist/files/file.d.ts +4 -0
- package/dist/files/folder.d.ts +4 -0
- package/dist/files/node.d.ts +8 -0
- package/dist/index.cjs +65 -14
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.mjs +65 -14
- package/dist/index.mjs.map +1 -1
- package/dist/navigation/view.d.ts +7 -4
- package/dist/vendor.LICENSE.txt +2 -2
- package/package.json +14 -14
package/dist/index.d.ts
CHANGED
|
@@ -12,6 +12,7 @@ export { FileType } from './files/fileType';
|
|
|
12
12
|
export { File, type IFile } from './files/file';
|
|
13
13
|
export { Folder, type IFolder } from './files/folder';
|
|
14
14
|
export { Node, NodeStatus, type INode } from './files/node';
|
|
15
|
+
export type { NodeData } from './files/nodeData.ts';
|
|
15
16
|
export * from './utils/filename-validation';
|
|
16
17
|
export { getUniqueName } from './utils/filename';
|
|
17
18
|
export { formatFileSize, parseFileSize } from './utils/fileSize';
|
package/dist/index.mjs
CHANGED
|
@@ -117,6 +117,9 @@ class FileAction {
|
|
|
117
117
|
get default() {
|
|
118
118
|
return this._action.default;
|
|
119
119
|
}
|
|
120
|
+
get destructive() {
|
|
121
|
+
return this._action.destructive;
|
|
122
|
+
}
|
|
120
123
|
get inline() {
|
|
121
124
|
return this._action.inline;
|
|
122
125
|
}
|
|
@@ -148,6 +151,9 @@ class FileAction {
|
|
|
148
151
|
if ("order" in action && typeof action.order !== "number") {
|
|
149
152
|
throw new Error("Invalid order");
|
|
150
153
|
}
|
|
154
|
+
if (action.destructive !== void 0 && typeof action.destructive !== "boolean") {
|
|
155
|
+
throw new Error("Invalid destructive flag");
|
|
156
|
+
}
|
|
151
157
|
if ("parent" in action && typeof action.parent !== "string") {
|
|
152
158
|
throw new Error("Invalid parent");
|
|
153
159
|
}
|
|
@@ -712,6 +718,12 @@ class Node {
|
|
|
712
718
|
set status(status) {
|
|
713
719
|
this._data.status = status;
|
|
714
720
|
}
|
|
721
|
+
/**
|
|
722
|
+
* Get the node data
|
|
723
|
+
*/
|
|
724
|
+
get data() {
|
|
725
|
+
return structuredClone(this._data);
|
|
726
|
+
}
|
|
715
727
|
/**
|
|
716
728
|
* Move the node to a new destination
|
|
717
729
|
*
|
|
@@ -774,6 +786,12 @@ class File extends Node {
|
|
|
774
786
|
get type() {
|
|
775
787
|
return FileType.File;
|
|
776
788
|
}
|
|
789
|
+
/**
|
|
790
|
+
* Returns a clone of the file
|
|
791
|
+
*/
|
|
792
|
+
clone() {
|
|
793
|
+
return new File(this.data);
|
|
794
|
+
}
|
|
777
795
|
}
|
|
778
796
|
class Folder extends Node {
|
|
779
797
|
constructor(data) {
|
|
@@ -791,6 +809,12 @@ class Folder extends Node {
|
|
|
791
809
|
get mime() {
|
|
792
810
|
return "httpd/unix-directory";
|
|
793
811
|
}
|
|
812
|
+
/**
|
|
813
|
+
* Returns a clone of the folder
|
|
814
|
+
*/
|
|
815
|
+
clone() {
|
|
816
|
+
return new Folder(this.data);
|
|
817
|
+
}
|
|
794
818
|
}
|
|
795
819
|
function davGetRootPath() {
|
|
796
820
|
if (isPublicShare()) {
|
|
@@ -1072,7 +1096,7 @@ function sortNodes(nodes, options = {}) {
|
|
|
1072
1096
|
// 3: Use sorting mode if NOT basename (to be able to use display name too)
|
|
1073
1097
|
...sortingOptions.sortingMode !== "basename" ? [(v) => v[sortingOptions.sortingMode]] : [],
|
|
1074
1098
|
// 4: Use display name if available, fallback to name
|
|
1075
|
-
(v) => basename2(v.attributes?.displayname || v.basename),
|
|
1099
|
+
(v) => basename2(v.displayname || v.attributes?.displayname || v.basename),
|
|
1076
1100
|
// 5: Finally, use basename if all previous sorting methods failed
|
|
1077
1101
|
(v) => v.basename
|
|
1078
1102
|
];
|
|
@@ -1785,10 +1809,30 @@ function trimZeros(numStr) {
|
|
|
1785
1809
|
return numStr;
|
|
1786
1810
|
}
|
|
1787
1811
|
var strnum = toNumber$1;
|
|
1812
|
+
function getIgnoreAttributesFn$2(ignoreAttributes2) {
|
|
1813
|
+
if (typeof ignoreAttributes2 === "function") {
|
|
1814
|
+
return ignoreAttributes2;
|
|
1815
|
+
}
|
|
1816
|
+
if (Array.isArray(ignoreAttributes2)) {
|
|
1817
|
+
return (attrName) => {
|
|
1818
|
+
for (const pattern of ignoreAttributes2) {
|
|
1819
|
+
if (typeof pattern === "string" && attrName === pattern) {
|
|
1820
|
+
return true;
|
|
1821
|
+
}
|
|
1822
|
+
if (pattern instanceof RegExp && pattern.test(attrName)) {
|
|
1823
|
+
return true;
|
|
1824
|
+
}
|
|
1825
|
+
}
|
|
1826
|
+
};
|
|
1827
|
+
}
|
|
1828
|
+
return () => false;
|
|
1829
|
+
}
|
|
1830
|
+
var ignoreAttributes = getIgnoreAttributesFn$2;
|
|
1788
1831
|
const util = util$3;
|
|
1789
1832
|
const xmlNode = xmlNode$1;
|
|
1790
1833
|
const readDocType = DocTypeReader;
|
|
1791
1834
|
const toNumber = strnum;
|
|
1835
|
+
const getIgnoreAttributesFn$1 = ignoreAttributes;
|
|
1792
1836
|
let OrderedObjParser$1 = class OrderedObjParser {
|
|
1793
1837
|
constructor(options) {
|
|
1794
1838
|
this.options = options;
|
|
@@ -1829,6 +1873,7 @@ let OrderedObjParser$1 = class OrderedObjParser {
|
|
|
1829
1873
|
this.readStopNodeData = readStopNodeData;
|
|
1830
1874
|
this.saveTextToParentTag = saveTextToParentTag;
|
|
1831
1875
|
this.addChild = addChild;
|
|
1876
|
+
this.ignoreAttributesFn = getIgnoreAttributesFn$1(this.options.ignoreAttributes);
|
|
1832
1877
|
}
|
|
1833
1878
|
};
|
|
1834
1879
|
function addExternalEntities(externalEntities) {
|
|
@@ -1881,12 +1926,15 @@ function resolveNameSpace(tagname) {
|
|
|
1881
1926
|
}
|
|
1882
1927
|
const attrsRegx = new RegExp(`([^\\s=]+)\\s*(=\\s*(['"])([\\s\\S]*?)\\3)?`, "gm");
|
|
1883
1928
|
function buildAttributesMap(attrStr, jPath, tagName) {
|
|
1884
|
-
if (
|
|
1929
|
+
if (this.options.ignoreAttributes !== true && typeof attrStr === "string") {
|
|
1885
1930
|
const matches = util.getAllMatches(attrStr, attrsRegx);
|
|
1886
1931
|
const len = matches.length;
|
|
1887
1932
|
const attrs = {};
|
|
1888
1933
|
for (let i = 0; i < len; i++) {
|
|
1889
1934
|
const attrName = this.resolveNameSpace(matches[i][1]);
|
|
1935
|
+
if (this.ignoreAttributesFn(attrName, jPath)) {
|
|
1936
|
+
continue;
|
|
1937
|
+
}
|
|
1890
1938
|
let oldVal = matches[i][4];
|
|
1891
1939
|
let aName = this.options.attributeNamePrefix + attrName;
|
|
1892
1940
|
if (attrName.length) {
|
|
@@ -2521,6 +2569,7 @@ function replaceEntitiesValue(textValue, options) {
|
|
|
2521
2569
|
}
|
|
2522
2570
|
var orderedJs2Xml = toXml;
|
|
2523
2571
|
const buildFromOrderedJs = orderedJs2Xml;
|
|
2572
|
+
const getIgnoreAttributesFn = ignoreAttributes;
|
|
2524
2573
|
const defaultOptions = {
|
|
2525
2574
|
attributeNamePrefix: "@_",
|
|
2526
2575
|
attributesGroupName: false,
|
|
@@ -2557,11 +2606,12 @@ const defaultOptions = {
|
|
|
2557
2606
|
};
|
|
2558
2607
|
function Builder(options) {
|
|
2559
2608
|
this.options = Object.assign({}, defaultOptions, options);
|
|
2560
|
-
if (this.options.ignoreAttributes || this.options.attributesGroupName) {
|
|
2609
|
+
if (this.options.ignoreAttributes === true || this.options.attributesGroupName) {
|
|
2561
2610
|
this.isAttribute = function() {
|
|
2562
2611
|
return false;
|
|
2563
2612
|
};
|
|
2564
2613
|
} else {
|
|
2614
|
+
this.ignoreAttributesFn = getIgnoreAttributesFn(this.options.ignoreAttributes);
|
|
2565
2615
|
this.attrPrefixLen = this.options.attributeNamePrefix.length;
|
|
2566
2616
|
this.isAttribute = isAttribute;
|
|
2567
2617
|
}
|
|
@@ -2587,12 +2637,13 @@ Builder.prototype.build = function(jObj) {
|
|
|
2587
2637
|
[this.options.arrayNodeName]: jObj
|
|
2588
2638
|
};
|
|
2589
2639
|
}
|
|
2590
|
-
return this.j2x(jObj, 0).val;
|
|
2640
|
+
return this.j2x(jObj, 0, []).val;
|
|
2591
2641
|
}
|
|
2592
2642
|
};
|
|
2593
|
-
Builder.prototype.j2x = function(jObj, level) {
|
|
2643
|
+
Builder.prototype.j2x = function(jObj, level, ajPath) {
|
|
2594
2644
|
let attrStr = "";
|
|
2595
2645
|
let val2 = "";
|
|
2646
|
+
const jPath = ajPath.join(".");
|
|
2596
2647
|
for (let key in jObj) {
|
|
2597
2648
|
if (!Object.prototype.hasOwnProperty.call(jObj, key)) continue;
|
|
2598
2649
|
if (typeof jObj[key] === "undefined") {
|
|
@@ -2611,9 +2662,9 @@ Builder.prototype.j2x = function(jObj, level) {
|
|
|
2611
2662
|
val2 += this.buildTextValNode(jObj[key], key, "", level);
|
|
2612
2663
|
} else if (typeof jObj[key] !== "object") {
|
|
2613
2664
|
const attr = this.isAttribute(key);
|
|
2614
|
-
if (attr) {
|
|
2665
|
+
if (attr && !this.ignoreAttributesFn(attr, jPath)) {
|
|
2615
2666
|
attrStr += this.buildAttrPairStr(attr, "" + jObj[key]);
|
|
2616
|
-
} else {
|
|
2667
|
+
} else if (!attr) {
|
|
2617
2668
|
if (key === this.options.textNodeName) {
|
|
2618
2669
|
let newval = this.options.tagValueProcessor(key, "" + jObj[key]);
|
|
2619
2670
|
val2 += this.replaceEntitiesValue(newval);
|
|
@@ -2633,13 +2684,13 @@ Builder.prototype.j2x = function(jObj, level) {
|
|
|
2633
2684
|
else val2 += this.indentate(level) + "<" + key + "/" + this.tagEndChar;
|
|
2634
2685
|
} else if (typeof item === "object") {
|
|
2635
2686
|
if (this.options.oneListGroup) {
|
|
2636
|
-
const result = this.j2x(item, level + 1);
|
|
2687
|
+
const result = this.j2x(item, level + 1, ajPath.concat(key));
|
|
2637
2688
|
listTagVal += result.val;
|
|
2638
2689
|
if (this.options.attributesGroupName && item.hasOwnProperty(this.options.attributesGroupName)) {
|
|
2639
2690
|
listTagAttr += result.attrStr;
|
|
2640
2691
|
}
|
|
2641
2692
|
} else {
|
|
2642
|
-
listTagVal += this.processTextOrObjNode(item, key, level);
|
|
2693
|
+
listTagVal += this.processTextOrObjNode(item, key, level, ajPath);
|
|
2643
2694
|
}
|
|
2644
2695
|
} else {
|
|
2645
2696
|
if (this.options.oneListGroup) {
|
|
@@ -2663,7 +2714,7 @@ Builder.prototype.j2x = function(jObj, level) {
|
|
|
2663
2714
|
attrStr += this.buildAttrPairStr(Ks[j], "" + jObj[key][Ks[j]]);
|
|
2664
2715
|
}
|
|
2665
2716
|
} else {
|
|
2666
|
-
val2 += this.processTextOrObjNode(jObj[key], key, level);
|
|
2717
|
+
val2 += this.processTextOrObjNode(jObj[key], key, level, ajPath);
|
|
2667
2718
|
}
|
|
2668
2719
|
}
|
|
2669
2720
|
}
|
|
@@ -2676,8 +2727,8 @@ Builder.prototype.buildAttrPairStr = function(attrName, val2) {
|
|
|
2676
2727
|
return " " + attrName;
|
|
2677
2728
|
} else return " " + attrName + '="' + val2 + '"';
|
|
2678
2729
|
};
|
|
2679
|
-
function processTextOrObjNode(object, key, level) {
|
|
2680
|
-
const result = this.j2x(object, level + 1);
|
|
2730
|
+
function processTextOrObjNode(object, key, level, ajPath) {
|
|
2731
|
+
const result = this.j2x(object, level + 1, ajPath.concat(key));
|
|
2681
2732
|
if (object[this.options.textNodeName] !== void 0 && Object.keys(object).length === 1) {
|
|
2682
2733
|
return this.buildTextValNode(object[this.options.textNodeName], key, result.attrStr, level);
|
|
2683
2734
|
} else {
|
|
@@ -2871,8 +2922,8 @@ const isValidView = function(view) {
|
|
|
2871
2922
|
if (!view.icon || typeof view.icon !== "string" || !isSvg(view.icon)) {
|
|
2872
2923
|
throw new Error("View icon is required and must be a valid svg string");
|
|
2873
2924
|
}
|
|
2874
|
-
if (
|
|
2875
|
-
throw new Error("View order
|
|
2925
|
+
if ("order" in view && typeof view.order !== "number") {
|
|
2926
|
+
throw new Error("View order must be a number");
|
|
2876
2927
|
}
|
|
2877
2928
|
if (view.columns) {
|
|
2878
2929
|
view.columns.forEach((column) => {
|