@nextcloud/files 3.0.0-beta.21 → 3.0.0-beta.23
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 +3 -0
- package/dist/humanfilesize.d.ts +10 -1
- package/dist/index.cjs +15 -15
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +426 -412
- package/dist/index.mjs.map +1 -1
- package/dist/newFileMenu.d.ts +1 -1
- package/dist/utils/logger.d.ts +1 -1
- package/dist/vendor.LICENSE.txt +1 -1
- package/package.json +14 -14
package/dist/index.mjs
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { getCurrentUser as
|
|
2
|
-
import { getLoggerBuilder as
|
|
1
|
+
import { getCurrentUser as T, getRequestToken as at } from "@nextcloud/auth";
|
|
2
|
+
import { getLoggerBuilder as M } from "@nextcloud/logger";
|
|
3
3
|
import { getCanonicalLocale as lt } from "@nextcloud/l10n";
|
|
4
|
-
import { join as dt, basename as ut, extname as ct, dirname as
|
|
4
|
+
import { join as dt, basename as ut, extname as ct, dirname as A } from "path";
|
|
5
5
|
import { generateRemoteUrl as ht } from "@nextcloud/router";
|
|
6
6
|
import { createClient as pt, getPatcher as ft } from "webdav";
|
|
7
7
|
import { request as gt } from "webdav/dist/node/request.js";
|
|
8
|
-
const mt = (t) => t === null ?
|
|
8
|
+
const mt = (t) => t === null ? M().setApp("files").build() : M().setApp("files").setUid(t.uid).build(), m = mt(T());
|
|
9
9
|
class wt {
|
|
10
10
|
_entries = [];
|
|
11
11
|
registerEntry(e) {
|
|
@@ -44,18 +44,18 @@ class wt {
|
|
|
44
44
|
throw new Error("Duplicate entry");
|
|
45
45
|
}
|
|
46
46
|
}
|
|
47
|
-
const
|
|
47
|
+
const F = function() {
|
|
48
48
|
return typeof window._nc_newfilemenu > "u" && (window._nc_newfilemenu = new wt(), m.debug("NewFileMenu initialized")), window._nc_newfilemenu;
|
|
49
|
-
},
|
|
50
|
-
function We(t, e = !1, i = !
|
|
49
|
+
}, O = ["B", "KB", "MB", "GB", "TB", "PB"], P = ["B", "KiB", "MiB", "GiB", "TiB", "PiB"];
|
|
50
|
+
function We(t, e = !1, i = !0) {
|
|
51
51
|
typeof t == "string" && (t = Number(t));
|
|
52
|
-
let
|
|
53
|
-
|
|
54
|
-
const n = i ?
|
|
55
|
-
let
|
|
56
|
-
return e === !0 &&
|
|
52
|
+
let r = t > 0 ? Math.floor(Math.log(t) / Math.log(i ? 1024 : 1e3)) : 0;
|
|
53
|
+
r = Math.min((i ? P.length : O.length) - 1, r);
|
|
54
|
+
const n = i ? P[r] : O[r];
|
|
55
|
+
let s = (t / Math.pow(i ? 1024 : 1e3, r)).toFixed(1);
|
|
56
|
+
return e === !0 && r === 0 ? (s !== "0.0" ? "< 1 " : "0 ") + (i ? P[1] : O[1]) : (r < 2 ? s = parseFloat(s).toFixed(0) : s = parseFloat(s).toLocaleString(lt()), s + " " + n);
|
|
57
57
|
}
|
|
58
|
-
var
|
|
58
|
+
var K = ((t) => (t.DEFAULT = "default", t.HIDDEN = "hidden", t))(K || {});
|
|
59
59
|
class Ye {
|
|
60
60
|
_action;
|
|
61
61
|
constructor(e) {
|
|
@@ -67,6 +67,9 @@ class Ye {
|
|
|
67
67
|
get displayName() {
|
|
68
68
|
return this._action.displayName;
|
|
69
69
|
}
|
|
70
|
+
get title() {
|
|
71
|
+
return this._action.title;
|
|
72
|
+
}
|
|
70
73
|
get iconSvgInline() {
|
|
71
74
|
return this._action.iconSvgInline;
|
|
72
75
|
}
|
|
@@ -96,6 +99,8 @@ class Ye {
|
|
|
96
99
|
throw new Error("Invalid id");
|
|
97
100
|
if (!e.displayName || typeof e.displayName != "function")
|
|
98
101
|
throw new Error("Invalid displayName function");
|
|
102
|
+
if ("title" in e && typeof e.title != "function")
|
|
103
|
+
throw new Error("Invalid title function");
|
|
99
104
|
if (!e.iconSvgInline || typeof e.iconSvgInline != "function")
|
|
100
105
|
throw new Error("Invalid iconSvgInline function");
|
|
101
106
|
if (!e.exec || typeof e.exec != "function")
|
|
@@ -106,7 +111,7 @@ class Ye {
|
|
|
106
111
|
throw new Error("Invalid execBatch function");
|
|
107
112
|
if ("order" in e && typeof e.order != "number")
|
|
108
113
|
throw new Error("Invalid order");
|
|
109
|
-
if (e.default && !Object.values(
|
|
114
|
+
if (e.default && !Object.values(K).includes(e.default))
|
|
110
115
|
throw new Error("Invalid default");
|
|
111
116
|
if ("inline" in e && typeof e.inline != "function")
|
|
112
117
|
throw new Error("Invalid inline function");
|
|
@@ -166,31 +171,31 @@ const ti = function(t) {
|
|
|
166
171
|
return typeof window._nc_filelistheader > "u" && (window._nc_filelistheader = [], m.debug("FileListHeaders initialized")), window._nc_filelistheader;
|
|
167
172
|
};
|
|
168
173
|
var v = ((t) => (t[t.NONE = 0] = "NONE", t[t.CREATE = 4] = "CREATE", t[t.READ = 1] = "READ", t[t.UPDATE = 2] = "UPDATE", t[t.DELETE = 8] = "DELETE", t[t.SHARE = 16] = "SHARE", t[t.ALL = 31] = "ALL", t))(v || {});
|
|
169
|
-
const
|
|
170
|
-
typeof window._nc_dav_properties > "u" && (window._nc_dav_properties = [...
|
|
174
|
+
const W = ["d:getcontentlength", "d:getcontenttype", "d:getetag", "d:getlastmodified", "d:quota-available-bytes", "d:resourcetype", "nc:has-preview", "nc:is-encrypted", "nc:mount-type", "nc:share-attributes", "oc:comments-unread", "oc:favorite", "oc:fileid", "oc:owner-display-name", "oc:owner-id", "oc:permissions", "oc:share-types", "oc:size", "ocs:share-permissions"], Y = { d: "DAV:", nc: "http://nextcloud.org/ns", oc: "http://owncloud.org/ns", ocs: "http://open-collaboration-services.org/ns" }, ii = function(t, e = { nc: "http://nextcloud.org/ns" }) {
|
|
175
|
+
typeof window._nc_dav_properties > "u" && (window._nc_dav_properties = [...W], window._nc_dav_namespaces = { ...Y });
|
|
171
176
|
const i = { ...window._nc_dav_namespaces, ...e };
|
|
172
177
|
if (window._nc_dav_properties.find((n) => n === t))
|
|
173
178
|
return m.error(`${t} already registered`, { prop: t }), !1;
|
|
174
179
|
if (t.startsWith("<") || t.split(":").length !== 2)
|
|
175
180
|
return m.error(`${t} is not valid. See example: 'oc:fileid'`, { prop: t }), !1;
|
|
176
|
-
const
|
|
177
|
-
return i[
|
|
178
|
-
}, F = function() {
|
|
179
|
-
return typeof window._nc_dav_properties > "u" && (window._nc_dav_properties = [...K]), window._nc_dav_properties.map((t) => `<${t} />`).join(" ");
|
|
181
|
+
const r = t.split(":")[0];
|
|
182
|
+
return i[r] ? (window._nc_dav_properties.push(t), window._nc_dav_namespaces = i, !0) : (m.error(`${t} namespace unknown`, { prop: t, namespaces: i }), !1);
|
|
180
183
|
}, V = function() {
|
|
181
|
-
return typeof window.
|
|
184
|
+
return typeof window._nc_dav_properties > "u" && (window._nc_dav_properties = [...W]), window._nc_dav_properties.map((t) => `<${t} />`).join(" ");
|
|
185
|
+
}, $ = function() {
|
|
186
|
+
return typeof window._nc_dav_namespaces > "u" && (window._nc_dav_namespaces = { ...Y }), Object.keys(window._nc_dav_namespaces).map((t) => `xmlns:${t}="${window._nc_dav_namespaces?.[t]}"`).join(" ");
|
|
182
187
|
}, ni = function() {
|
|
183
188
|
return `<?xml version="1.0"?>
|
|
184
|
-
<d:propfind ${
|
|
189
|
+
<d:propfind ${$()}>
|
|
185
190
|
<d:prop>
|
|
186
|
-
${
|
|
191
|
+
${V()}
|
|
187
192
|
</d:prop>
|
|
188
193
|
</d:propfind>`;
|
|
189
194
|
}, vt = function() {
|
|
190
195
|
return `<?xml version="1.0"?>
|
|
191
|
-
<oc:filter-files ${
|
|
196
|
+
<oc:filter-files ${$()}>
|
|
192
197
|
<d:prop>
|
|
193
|
-
${
|
|
198
|
+
${V()}
|
|
194
199
|
</d:prop>
|
|
195
200
|
<oc:filter-rules>
|
|
196
201
|
<oc:favorite>1</oc:favorite>
|
|
@@ -198,17 +203,17 @@ const K = ["d:getcontentlength", "d:getcontenttype", "d:getetag", "d:getlastmodi
|
|
|
198
203
|
</oc:filter-files>`;
|
|
199
204
|
}, ri = function(t) {
|
|
200
205
|
return `<?xml version="1.0" encoding="UTF-8"?>
|
|
201
|
-
<d:searchrequest ${
|
|
206
|
+
<d:searchrequest ${$()}
|
|
202
207
|
xmlns:ns="https://github.com/icewind1991/SearchDAV/ns">
|
|
203
208
|
<d:basicsearch>
|
|
204
209
|
<d:select>
|
|
205
210
|
<d:prop>
|
|
206
|
-
${
|
|
211
|
+
${V()}
|
|
207
212
|
</d:prop>
|
|
208
213
|
</d:select>
|
|
209
214
|
<d:from>
|
|
210
215
|
<d:scope>
|
|
211
|
-
<d:href>/files/${
|
|
216
|
+
<d:href>/files/${T()?.uid}/</d:href>
|
|
212
217
|
<d:depth>infinity</d:depth>
|
|
213
218
|
</d:scope>
|
|
214
219
|
</d:from>
|
|
@@ -256,10 +261,10 @@ const K = ["d:getcontentlength", "d:getcontenttype", "d:getetag", "d:getlastmodi
|
|
|
256
261
|
let e = v.NONE;
|
|
257
262
|
return t && ((t.includes("C") || t.includes("K")) && (e |= v.CREATE), t.includes("G") && (e |= v.READ), (t.includes("W") || t.includes("N") || t.includes("V")) && (e |= v.UPDATE), t.includes("D") && (e |= v.DELETE), t.includes("R") && (e |= v.SHARE)), e;
|
|
258
263
|
};
|
|
259
|
-
var
|
|
260
|
-
const
|
|
264
|
+
var k = ((t) => (t.Folder = "folder", t.File = "file", t))(k || {});
|
|
265
|
+
const Z = function(t, e) {
|
|
261
266
|
return t.match(e) !== null;
|
|
262
|
-
},
|
|
267
|
+
}, B = (t, e) => {
|
|
263
268
|
if (t.id && typeof t.id != "number")
|
|
264
269
|
throw new Error("Invalid id type of value");
|
|
265
270
|
if (!t.source)
|
|
@@ -291,23 +296,23 @@ const Y = function(t, e) {
|
|
|
291
296
|
throw new Error("Root must start with a leading slash");
|
|
292
297
|
if (t.root && !t.source.includes(t.root))
|
|
293
298
|
throw new Error("Root must be part of the source");
|
|
294
|
-
if (t.root &&
|
|
299
|
+
if (t.root && Z(t.source, e)) {
|
|
295
300
|
const i = t.source.match(e)[0];
|
|
296
301
|
if (!t.source.includes(dt(i, t.root)))
|
|
297
302
|
throw new Error("The root must be relative to the service. e.g /files/emma");
|
|
298
303
|
}
|
|
299
|
-
if (t.status && !Object.values(
|
|
304
|
+
if (t.status && !Object.values(J).includes(t.status))
|
|
300
305
|
throw new Error("Status must be a valid NodeStatus");
|
|
301
306
|
};
|
|
302
|
-
var
|
|
303
|
-
class
|
|
307
|
+
var J = ((t) => (t.NEW = "new", t.FAILED = "failed", t.LOADING = "loading", t.LOCKED = "locked", t))(J || {});
|
|
308
|
+
class Q {
|
|
304
309
|
_data;
|
|
305
310
|
_attributes;
|
|
306
311
|
_knownDavService = /(remote|public)\.php\/(web)?dav/i;
|
|
307
312
|
constructor(e, i) {
|
|
308
|
-
|
|
309
|
-
const
|
|
310
|
-
this._attributes = new Proxy(e.attributes || {},
|
|
313
|
+
B(e, i || this._knownDavService), this._data = e;
|
|
314
|
+
const r = { set: (n, s, a) => (this.updateMtime(), Reflect.set(n, s, a)), deleteProperty: (n, s) => (this.updateMtime(), Reflect.deleteProperty(n, s)) };
|
|
315
|
+
this._attributes = new Proxy(e.attributes || {}, r), delete this._data.attributes, i && (this._knownDavService = i);
|
|
311
316
|
}
|
|
312
317
|
get source() {
|
|
313
318
|
return this._data.source.replace(/\/$/i, "");
|
|
@@ -321,10 +326,10 @@ class J {
|
|
|
321
326
|
get dirname() {
|
|
322
327
|
if (this.root) {
|
|
323
328
|
const i = this.source.indexOf(this.root);
|
|
324
|
-
return
|
|
329
|
+
return A(this.source.slice(i + this.root.length) || "/");
|
|
325
330
|
}
|
|
326
331
|
const e = new URL(this.source);
|
|
327
|
-
return
|
|
332
|
+
return A(e.pathname);
|
|
328
333
|
}
|
|
329
334
|
get mime() {
|
|
330
335
|
return this._data.mime;
|
|
@@ -348,10 +353,10 @@ class J {
|
|
|
348
353
|
return this.isDavRessource ? this._data.owner : null;
|
|
349
354
|
}
|
|
350
355
|
get isDavRessource() {
|
|
351
|
-
return
|
|
356
|
+
return Z(this.source, this._knownDavService);
|
|
352
357
|
}
|
|
353
358
|
get root() {
|
|
354
|
-
return this._data.root ? this._data.root.replace(/^(.+)\/$/, "$1") : this.isDavRessource &&
|
|
359
|
+
return this._data.root ? this._data.root.replace(/^(.+)\/$/, "$1") : this.isDavRessource && A(this.source).split(this._knownDavService).pop() || null;
|
|
355
360
|
}
|
|
356
361
|
get path() {
|
|
357
362
|
if (this.root) {
|
|
@@ -370,28 +375,28 @@ class J {
|
|
|
370
375
|
this._data.status = e;
|
|
371
376
|
}
|
|
372
377
|
move(e) {
|
|
373
|
-
|
|
378
|
+
B({ ...this._data, source: e }, this._knownDavService), this._data.source = e, this.updateMtime();
|
|
374
379
|
}
|
|
375
380
|
rename(e) {
|
|
376
381
|
if (e.includes("/"))
|
|
377
382
|
throw new Error("Invalid basename");
|
|
378
|
-
this.move(
|
|
383
|
+
this.move(A(this.source) + "/" + e);
|
|
379
384
|
}
|
|
380
385
|
updateMtime() {
|
|
381
386
|
this._data.mtime && (this._data.mtime = /* @__PURE__ */ new Date());
|
|
382
387
|
}
|
|
383
388
|
}
|
|
384
|
-
class xt extends
|
|
389
|
+
class xt extends Q {
|
|
385
390
|
get type() {
|
|
386
|
-
return
|
|
391
|
+
return k.File;
|
|
387
392
|
}
|
|
388
393
|
}
|
|
389
|
-
class bt extends
|
|
394
|
+
class bt extends Q {
|
|
390
395
|
constructor(e) {
|
|
391
396
|
super({ ...e, mime: "httpd/unix-directory" });
|
|
392
397
|
}
|
|
393
398
|
get type() {
|
|
394
|
-
return
|
|
399
|
+
return k.Folder;
|
|
395
400
|
}
|
|
396
401
|
get extension() {
|
|
397
402
|
return null;
|
|
@@ -400,12 +405,12 @@ class bt extends J {
|
|
|
400
405
|
return "httpd/unix-directory";
|
|
401
406
|
}
|
|
402
407
|
}
|
|
403
|
-
const
|
|
408
|
+
const tt = `/files/${T()?.uid}`, et = ht("dav"), si = function(t = et) {
|
|
404
409
|
const e = pt(t, { headers: { requesttoken: at() || "" } });
|
|
405
410
|
return ft().patch("request", (i) => (i.headers?.method && (i.method = i.headers.method, delete i.headers.method), gt(i))), e;
|
|
406
|
-
}, oi = async (t, e = "/", i =
|
|
407
|
-
const
|
|
408
|
-
return delete
|
|
411
|
+
}, oi = async (t, e = "/", i = tt) => (await t.getDirectoryContents(`${i}${e}`, { details: !0, data: vt(), headers: { method: "REPORT" }, includeSelf: !0 })).data.filter((r) => r.filename !== e).map((r) => Et(r, i)), Et = function(t, e = tt, i = et) {
|
|
412
|
+
const r = t.props, n = yt(r?.permissions), s = T()?.uid, a = { id: r?.fileid || 0, source: `${i}${t.filename}`, mtime: new Date(Date.parse(t.lastmod)), mime: t.mime, size: r?.size || Number.parseInt(r.getcontentlength || "0"), permissions: n, owner: s, root: e, attributes: { ...t, ...r, hasPreview: r?.["has-preview"] } };
|
|
413
|
+
return delete a.attributes?.props, t.type === "file" ? new xt(a) : new bt(a);
|
|
409
414
|
};
|
|
410
415
|
class Nt {
|
|
411
416
|
_views = [];
|
|
@@ -416,7 +421,7 @@ class Nt {
|
|
|
416
421
|
this._views.push(e);
|
|
417
422
|
}
|
|
418
423
|
remove(e) {
|
|
419
|
-
const i = this._views.findIndex((
|
|
424
|
+
const i = this._views.findIndex((r) => r.id === e);
|
|
420
425
|
i !== -1 && this._views.splice(i, 1);
|
|
421
426
|
}
|
|
422
427
|
get views() {
|
|
@@ -466,142 +471,142 @@ const At = function(t) {
|
|
|
466
471
|
throw new Error("Column summary must be a function");
|
|
467
472
|
return !0;
|
|
468
473
|
};
|
|
469
|
-
var
|
|
474
|
+
var L = {}, I = {};
|
|
470
475
|
(function(t) {
|
|
471
|
-
const e = ":A-Za-z_\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD", i = e + "\\-.\\d\\u00B7\\u0300-\\u036F\\u203F-\\u2040",
|
|
476
|
+
const e = ":A-Za-z_\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD", i = e + "\\-.\\d\\u00B7\\u0300-\\u036F\\u203F-\\u2040", r = "[" + e + "][" + i + "]*", n = new RegExp("^" + r + "$"), s = function(o, l) {
|
|
472
477
|
const d = [];
|
|
473
|
-
let u =
|
|
478
|
+
let u = l.exec(o);
|
|
474
479
|
for (; u; ) {
|
|
475
|
-
const
|
|
476
|
-
|
|
477
|
-
const
|
|
478
|
-
for (let
|
|
479
|
-
|
|
480
|
-
d.push(
|
|
480
|
+
const c = [];
|
|
481
|
+
c.startIndex = l.lastIndex - u[0].length;
|
|
482
|
+
const p = u.length;
|
|
483
|
+
for (let h = 0; h < p; h++)
|
|
484
|
+
c.push(u[h]);
|
|
485
|
+
d.push(c), u = l.exec(o);
|
|
481
486
|
}
|
|
482
487
|
return d;
|
|
483
|
-
},
|
|
484
|
-
const
|
|
485
|
-
return !(
|
|
488
|
+
}, a = function(o) {
|
|
489
|
+
const l = n.exec(o);
|
|
490
|
+
return !(l === null || typeof l > "u");
|
|
486
491
|
};
|
|
487
492
|
t.isExist = function(o) {
|
|
488
493
|
return typeof o < "u";
|
|
489
494
|
}, t.isEmptyObject = function(o) {
|
|
490
495
|
return Object.keys(o).length === 0;
|
|
491
|
-
}, t.merge = function(o,
|
|
492
|
-
if (
|
|
493
|
-
const u = Object.keys(
|
|
494
|
-
for (let
|
|
495
|
-
d === "strict" ? o[u[
|
|
496
|
+
}, t.merge = function(o, l, d) {
|
|
497
|
+
if (l) {
|
|
498
|
+
const u = Object.keys(l), c = u.length;
|
|
499
|
+
for (let p = 0; p < c; p++)
|
|
500
|
+
d === "strict" ? o[u[p]] = [l[u[p]]] : o[u[p]] = l[u[p]];
|
|
496
501
|
}
|
|
497
502
|
}, t.getValue = function(o) {
|
|
498
503
|
return t.isExist(o) ? o : "";
|
|
499
|
-
}, t.isName =
|
|
500
|
-
})(
|
|
501
|
-
const
|
|
502
|
-
|
|
504
|
+
}, t.isName = a, t.getAllMatches = s, t.nameRegexp = r;
|
|
505
|
+
})(I);
|
|
506
|
+
const R = I, Tt = { allowBooleanAttributes: !1, unpairedTags: [] };
|
|
507
|
+
L.validate = function(t, e) {
|
|
503
508
|
e = Object.assign({}, Tt, e);
|
|
504
509
|
const i = [];
|
|
505
|
-
let
|
|
510
|
+
let r = !1, n = !1;
|
|
506
511
|
t[0] === "\uFEFF" && (t = t.substr(1));
|
|
507
|
-
for (let
|
|
508
|
-
if (t[
|
|
509
|
-
if (
|
|
510
|
-
return
|
|
511
|
-
} else if (t[
|
|
512
|
-
let
|
|
513
|
-
if (
|
|
514
|
-
|
|
512
|
+
for (let s = 0; s < t.length; s++)
|
|
513
|
+
if (t[s] === "<" && t[s + 1] === "?") {
|
|
514
|
+
if (s += 2, s = U(t, s), s.err)
|
|
515
|
+
return s;
|
|
516
|
+
} else if (t[s] === "<") {
|
|
517
|
+
let a = s;
|
|
518
|
+
if (s++, t[s] === "!") {
|
|
519
|
+
s = z(t, s);
|
|
515
520
|
continue;
|
|
516
521
|
} else {
|
|
517
522
|
let o = !1;
|
|
518
|
-
t[
|
|
519
|
-
let
|
|
520
|
-
for (;
|
|
521
|
-
` && t[
|
|
522
|
-
|
|
523
|
-
if (
|
|
524
|
-
let
|
|
525
|
-
return
|
|
523
|
+
t[s] === "/" && (o = !0, s++);
|
|
524
|
+
let l = "";
|
|
525
|
+
for (; s < t.length && t[s] !== ">" && t[s] !== " " && t[s] !== " " && t[s] !== `
|
|
526
|
+
` && t[s] !== "\r"; s++)
|
|
527
|
+
l += t[s];
|
|
528
|
+
if (l = l.trim(), l[l.length - 1] === "/" && (l = l.substring(0, l.length - 1), s--), !Vt(l)) {
|
|
529
|
+
let c;
|
|
530
|
+
return l.trim().length === 0 ? c = "Invalid space after '<'." : c = "Tag '" + l + "' is an invalid name.", f("InvalidTag", c, g(t, s));
|
|
526
531
|
}
|
|
527
|
-
const d = Pt(t,
|
|
532
|
+
const d = Pt(t, s);
|
|
528
533
|
if (d === !1)
|
|
529
|
-
return
|
|
534
|
+
return f("InvalidAttr", "Attributes for '" + l + "' have open quote.", g(t, s));
|
|
530
535
|
let u = d.value;
|
|
531
|
-
if (
|
|
532
|
-
const
|
|
536
|
+
if (s = d.index, u[u.length - 1] === "/") {
|
|
537
|
+
const c = s - u.length;
|
|
533
538
|
u = u.substring(0, u.length - 1);
|
|
534
|
-
const
|
|
535
|
-
if (
|
|
536
|
-
|
|
539
|
+
const p = G(u, e);
|
|
540
|
+
if (p === !0)
|
|
541
|
+
r = !0;
|
|
537
542
|
else
|
|
538
|
-
return p
|
|
543
|
+
return f(p.err.code, p.err.msg, g(t, c + p.err.line));
|
|
539
544
|
} else if (o)
|
|
540
545
|
if (d.tagClosed) {
|
|
541
546
|
if (u.trim().length > 0)
|
|
542
|
-
return
|
|
547
|
+
return f("InvalidTag", "Closing tag '" + l + "' can't have attributes or invalid starting.", g(t, a));
|
|
543
548
|
{
|
|
544
|
-
const
|
|
545
|
-
if (
|
|
546
|
-
let
|
|
547
|
-
return
|
|
549
|
+
const c = i.pop();
|
|
550
|
+
if (l !== c.tagName) {
|
|
551
|
+
let p = g(t, c.tagStartPos);
|
|
552
|
+
return f("InvalidTag", "Expected closing tag '" + c.tagName + "' (opened in line " + p.line + ", col " + p.col + ") instead of closing tag '" + l + "'.", g(t, a));
|
|
548
553
|
}
|
|
549
554
|
i.length == 0 && (n = !0);
|
|
550
555
|
}
|
|
551
556
|
} else
|
|
552
|
-
return
|
|
557
|
+
return f("InvalidTag", "Closing tag '" + l + "' doesn't have proper closing.", g(t, s));
|
|
553
558
|
else {
|
|
554
|
-
const
|
|
555
|
-
if (
|
|
556
|
-
return
|
|
559
|
+
const c = G(u, e);
|
|
560
|
+
if (c !== !0)
|
|
561
|
+
return f(c.err.code, c.err.msg, g(t, s - u.length + c.err.line));
|
|
557
562
|
if (n === !0)
|
|
558
|
-
return
|
|
559
|
-
e.unpairedTags.indexOf(
|
|
563
|
+
return f("InvalidXml", "Multiple possible root nodes found.", g(t, s));
|
|
564
|
+
e.unpairedTags.indexOf(l) !== -1 || i.push({ tagName: l, tagStartPos: a }), r = !0;
|
|
560
565
|
}
|
|
561
|
-
for (
|
|
562
|
-
if (t[
|
|
563
|
-
if (t[
|
|
564
|
-
|
|
566
|
+
for (s++; s < t.length; s++)
|
|
567
|
+
if (t[s] === "<")
|
|
568
|
+
if (t[s + 1] === "!") {
|
|
569
|
+
s++, s = z(t, s);
|
|
565
570
|
continue;
|
|
566
|
-
} else if (t[
|
|
567
|
-
if (
|
|
568
|
-
return
|
|
571
|
+
} else if (t[s + 1] === "?") {
|
|
572
|
+
if (s = U(t, ++s), s.err)
|
|
573
|
+
return s;
|
|
569
574
|
} else
|
|
570
575
|
break;
|
|
571
|
-
else if (t[
|
|
572
|
-
const
|
|
573
|
-
if (
|
|
574
|
-
return
|
|
575
|
-
|
|
576
|
-
} else if (n === !0 && !
|
|
577
|
-
return
|
|
578
|
-
t[
|
|
576
|
+
else if (t[s] === "&") {
|
|
577
|
+
const c = St(t, s);
|
|
578
|
+
if (c == -1)
|
|
579
|
+
return f("InvalidChar", "char '&' is not expected.", g(t, s));
|
|
580
|
+
s = c;
|
|
581
|
+
} else if (n === !0 && !q(t[s]))
|
|
582
|
+
return f("InvalidXml", "Extra text at the end", g(t, s));
|
|
583
|
+
t[s] === "<" && s--;
|
|
579
584
|
}
|
|
580
585
|
} else {
|
|
581
|
-
if (
|
|
586
|
+
if (q(t[s]))
|
|
582
587
|
continue;
|
|
583
|
-
return
|
|
588
|
+
return f("InvalidChar", "char '" + t[s] + "' is not expected.", g(t, s));
|
|
584
589
|
}
|
|
585
|
-
if (
|
|
590
|
+
if (r) {
|
|
586
591
|
if (i.length == 1)
|
|
587
|
-
return
|
|
592
|
+
return f("InvalidTag", "Unclosed tag '" + i[0].tagName + "'.", g(t, i[0].tagStartPos));
|
|
588
593
|
if (i.length > 0)
|
|
589
|
-
return
|
|
594
|
+
return f("InvalidXml", "Invalid '" + JSON.stringify(i.map((s) => s.tagName), null, 4).replace(/\r?\n/g, "") + "' found.", { line: 1, col: 1 });
|
|
590
595
|
} else
|
|
591
|
-
return
|
|
596
|
+
return f("InvalidXml", "Start tag expected.", 1);
|
|
592
597
|
return !0;
|
|
593
598
|
};
|
|
594
|
-
function
|
|
599
|
+
function q(t) {
|
|
595
600
|
return t === " " || t === " " || t === `
|
|
596
601
|
` || t === "\r";
|
|
597
602
|
}
|
|
598
|
-
function
|
|
603
|
+
function U(t, e) {
|
|
599
604
|
const i = e;
|
|
600
605
|
for (; e < t.length; e++)
|
|
601
606
|
if (t[e] == "?" || t[e] == " ") {
|
|
602
|
-
const
|
|
603
|
-
if (e > 5 &&
|
|
604
|
-
return
|
|
607
|
+
const r = t.substr(i, e - i);
|
|
608
|
+
if (e > 5 && r === "xml")
|
|
609
|
+
return f("InvalidXml", "XML declaration allowed only at the start of the document.", g(t, e));
|
|
605
610
|
if (t[e] == "?" && t[e + 1] == ">") {
|
|
606
611
|
e++;
|
|
607
612
|
break;
|
|
@@ -610,7 +615,7 @@ function q(t, e) {
|
|
|
610
615
|
}
|
|
611
616
|
return e;
|
|
612
617
|
}
|
|
613
|
-
function
|
|
618
|
+
function z(t, e) {
|
|
614
619
|
if (t.length > e + 5 && t[e + 1] === "-" && t[e + 2] === "-") {
|
|
615
620
|
for (e += 3; e < t.length; e++)
|
|
616
621
|
if (t[e] === "-" && t[e + 1] === "-" && t[e + 2] === ">") {
|
|
@@ -635,35 +640,35 @@ function U(t, e) {
|
|
|
635
640
|
}
|
|
636
641
|
const It = '"', Ot = "'";
|
|
637
642
|
function Pt(t, e) {
|
|
638
|
-
let i = "",
|
|
643
|
+
let i = "", r = "", n = !1;
|
|
639
644
|
for (; e < t.length; e++) {
|
|
640
645
|
if (t[e] === It || t[e] === Ot)
|
|
641
|
-
|
|
642
|
-
else if (t[e] === ">" &&
|
|
646
|
+
r === "" ? r = t[e] : r !== t[e] || (r = "");
|
|
647
|
+
else if (t[e] === ">" && r === "") {
|
|
643
648
|
n = !0;
|
|
644
649
|
break;
|
|
645
650
|
}
|
|
646
651
|
i += t[e];
|
|
647
652
|
}
|
|
648
|
-
return
|
|
653
|
+
return r !== "" ? !1 : { value: i, index: e, tagClosed: n };
|
|
649
654
|
}
|
|
650
655
|
const Ct = new RegExp(`(\\s*)([^\\s=]+)(\\s*=)?(\\s*(['"])(([\\s\\S])*?)\\5)?`, "g");
|
|
651
|
-
function
|
|
652
|
-
const i =
|
|
656
|
+
function G(t, e) {
|
|
657
|
+
const i = R.getAllMatches(t, Ct), r = {};
|
|
653
658
|
for (let n = 0; n < i.length; n++) {
|
|
654
659
|
if (i[n][1].length === 0)
|
|
655
|
-
return
|
|
660
|
+
return f("InvalidAttr", "Attribute '" + i[n][2] + "' has no space in starting.", E(i[n]));
|
|
656
661
|
if (i[n][3] !== void 0 && i[n][4] === void 0)
|
|
657
|
-
return
|
|
662
|
+
return f("InvalidAttr", "Attribute '" + i[n][2] + "' is without value.", E(i[n]));
|
|
658
663
|
if (i[n][3] === void 0 && !e.allowBooleanAttributes)
|
|
659
|
-
return
|
|
660
|
-
const
|
|
661
|
-
if (!Ft(
|
|
662
|
-
return
|
|
663
|
-
if (!
|
|
664
|
-
s
|
|
664
|
+
return f("InvalidAttr", "boolean attribute '" + i[n][2] + "' is not allowed.", E(i[n]));
|
|
665
|
+
const s = i[n][2];
|
|
666
|
+
if (!Ft(s))
|
|
667
|
+
return f("InvalidAttr", "Attribute '" + s + "' is an invalid name.", E(i[n]));
|
|
668
|
+
if (!r.hasOwnProperty(s))
|
|
669
|
+
r[s] = 1;
|
|
665
670
|
else
|
|
666
|
-
return
|
|
671
|
+
return f("InvalidAttr", "Attribute '" + s + "' is repeated.", E(i[n]));
|
|
667
672
|
}
|
|
668
673
|
return !0;
|
|
669
674
|
}
|
|
@@ -691,33 +696,33 @@ function St(t, e) {
|
|
|
691
696
|
}
|
|
692
697
|
return e;
|
|
693
698
|
}
|
|
694
|
-
function
|
|
699
|
+
function f(t, e, i) {
|
|
695
700
|
return { err: { code: t, msg: e, line: i.line || i, col: i.col } };
|
|
696
701
|
}
|
|
697
702
|
function Ft(t) {
|
|
698
|
-
return
|
|
703
|
+
return R.isName(t);
|
|
699
704
|
}
|
|
700
705
|
function Vt(t) {
|
|
701
|
-
return
|
|
706
|
+
return R.isName(t);
|
|
702
707
|
}
|
|
703
708
|
function g(t, e) {
|
|
704
709
|
const i = t.substring(0, e).split(/\r?\n/);
|
|
705
710
|
return { line: i.length, col: i[i.length - 1].length + 1 };
|
|
706
711
|
}
|
|
707
|
-
function
|
|
712
|
+
function E(t) {
|
|
708
713
|
return t.startIndex + t[1].length;
|
|
709
714
|
}
|
|
710
|
-
var
|
|
711
|
-
const
|
|
715
|
+
var C = {};
|
|
716
|
+
const it = { preserveOrder: !1, attributeNamePrefix: "@_", attributesGroupName: !1, textNodeName: "#text", ignoreAttributes: !0, removeNSPrefix: !1, allowBooleanAttributes: !1, parseTagValue: !0, parseAttributeValue: !1, trimValues: !0, cdataPropName: !1, numberParseOptions: { hex: !0, leadingZeros: !0, eNotation: !0 }, tagValueProcessor: function(t, e) {
|
|
712
717
|
return e;
|
|
713
718
|
}, attributeValueProcessor: function(t, e) {
|
|
714
719
|
return e;
|
|
715
720
|
}, stopNodes: [], alwaysCreateTextNode: !1, isArray: () => !1, commentPropName: !1, unpairedTags: [], processEntities: !0, htmlEntities: !1, ignoreDeclaration: !1, ignorePiTags: !1, transformTagName: !1, transformAttributeName: !1, updateTag: function(t, e, i) {
|
|
716
721
|
return t;
|
|
717
722
|
} }, $t = function(t) {
|
|
718
|
-
return Object.assign({},
|
|
723
|
+
return Object.assign({}, it, t);
|
|
719
724
|
};
|
|
720
|
-
|
|
725
|
+
C.buildOptions = $t, C.defaultOptions = it;
|
|
721
726
|
class kt {
|
|
722
727
|
constructor(e) {
|
|
723
728
|
this.tagname = e, this.child = [], this[":@"] = {};
|
|
@@ -730,14 +735,14 @@ class kt {
|
|
|
730
735
|
}
|
|
731
736
|
}
|
|
732
737
|
var Lt = kt;
|
|
733
|
-
const Rt =
|
|
738
|
+
const Rt = I;
|
|
734
739
|
function jt(t, e) {
|
|
735
740
|
const i = {};
|
|
736
741
|
if (t[e + 3] === "O" && t[e + 4] === "C" && t[e + 5] === "T" && t[e + 6] === "Y" && t[e + 7] === "P" && t[e + 8] === "E") {
|
|
737
742
|
e = e + 9;
|
|
738
|
-
let
|
|
743
|
+
let r = 1, n = !1, s = !1, a = "";
|
|
739
744
|
for (; e < t.length; e++)
|
|
740
|
-
if (t[e] === "<" && !
|
|
745
|
+
if (t[e] === "<" && !s) {
|
|
741
746
|
if (n && qt(t, e))
|
|
742
747
|
e += 7, [entityName, val, e] = Mt(t, e + 1), val.indexOf("&") === -1 && (i[Xt(entityName)] = { regx: RegExp(`&${entityName};`, "g"), val });
|
|
743
748
|
else if (n && Ut(t, e))
|
|
@@ -747,16 +752,16 @@ function jt(t, e) {
|
|
|
747
752
|
else if (n && Gt(t, e))
|
|
748
753
|
e += 9;
|
|
749
754
|
else if (Bt)
|
|
750
|
-
|
|
755
|
+
s = !0;
|
|
751
756
|
else
|
|
752
757
|
throw new Error("Invalid DOCTYPE");
|
|
753
|
-
|
|
758
|
+
r++, a = "";
|
|
754
759
|
} else if (t[e] === ">") {
|
|
755
|
-
if (
|
|
760
|
+
if (s ? t[e - 1] === "-" && t[e - 2] === "-" && (s = !1, r--) : r--, r === 0)
|
|
756
761
|
break;
|
|
757
762
|
} else
|
|
758
|
-
t[e] === "[" ? n = !0 :
|
|
759
|
-
if (
|
|
763
|
+
t[e] === "[" ? n = !0 : a += t[e];
|
|
764
|
+
if (r !== 0)
|
|
760
765
|
throw new Error("Unclosed DOCTYPE");
|
|
761
766
|
} else
|
|
762
767
|
throw new Error("Invalid Tag instead of DOCTYPE");
|
|
@@ -768,9 +773,9 @@ function Mt(t, e) {
|
|
|
768
773
|
i += t[e];
|
|
769
774
|
if (i = i.trim(), i.indexOf(" ") !== -1)
|
|
770
775
|
throw new Error("External entites are not supported");
|
|
771
|
-
const
|
|
776
|
+
const r = t[e++];
|
|
772
777
|
let n = "";
|
|
773
|
-
for (; e < t.length && t[e] !==
|
|
778
|
+
for (; e < t.length && t[e] !== r; e++)
|
|
774
779
|
n += t[e];
|
|
775
780
|
return [i, n, e];
|
|
776
781
|
}
|
|
@@ -807,16 +812,16 @@ function Zt(t, e = {}) {
|
|
|
807
812
|
if (e.hex && Kt.test(i))
|
|
808
813
|
return Number.parseInt(i, 16);
|
|
809
814
|
{
|
|
810
|
-
const
|
|
811
|
-
if (
|
|
812
|
-
const n =
|
|
813
|
-
let
|
|
814
|
-
const o =
|
|
815
|
-
if (!e.leadingZeros &&
|
|
815
|
+
const r = Wt.exec(i);
|
|
816
|
+
if (r) {
|
|
817
|
+
const n = r[1], s = r[2];
|
|
818
|
+
let a = Jt(r[3]);
|
|
819
|
+
const o = r[4] || r[6];
|
|
820
|
+
if (!e.leadingZeros && s.length > 0 && n && i[2] !== "." || !e.leadingZeros && s.length > 0 && !n && i[1] !== ".")
|
|
816
821
|
return t;
|
|
817
822
|
{
|
|
818
|
-
const
|
|
819
|
-
return d.search(/[eE]/) !== -1 || o ? e.eNotation ?
|
|
823
|
+
const l = Number(i), d = "" + l;
|
|
824
|
+
return d.search(/[eE]/) !== -1 || o ? e.eNotation ? l : t : i.indexOf(".") !== -1 ? d === "0" && a === "" || d === a || n && d === "-" + a ? l : t : s ? a === d || n + a === d ? l : t : i === d || i === n + d ? l : t;
|
|
820
825
|
}
|
|
821
826
|
} else
|
|
822
827
|
return t;
|
|
@@ -826,8 +831,8 @@ function Jt(t) {
|
|
|
826
831
|
return t && t.indexOf(".") !== -1 && (t = t.replace(/0+$/, ""), t === "." ? t = "0" : t[0] === "." ? t = "0" + t : t[t.length - 1] === "." && (t = t.substr(0, t.length - 1))), t;
|
|
827
832
|
}
|
|
828
833
|
var Qt = Zt;
|
|
829
|
-
const
|
|
830
|
-
"<((!\\[CDATA\\[([\\s\\S]*?)(]]>))|((NAME:)?(NAME))([^>]*)>|((\\/)(NAME)\\s*>))([^<]*)".replace(/NAME/g,
|
|
834
|
+
const j = I, N = Lt, te = Ht, ee = Qt;
|
|
835
|
+
"<((!\\[CDATA\\[([\\s\\S]*?)(]]>))|((NAME:)?(NAME))([^>]*)>|((\\/)(NAME)\\s*>))([^<]*)".replace(/NAME/g, j.nameRegexp);
|
|
831
836
|
let ie = class {
|
|
832
837
|
constructor(t) {
|
|
833
838
|
this.options = t, this.currentNode = null, this.tagsNodeStack = [], this.docTypeEntities = {}, this.lastEntities = { apos: { regex: /&(apos|#39|#x27);/g, val: "'" }, gt: { regex: /&(gt|#62|#x3E);/g, val: ">" }, lt: { regex: /&(lt|#60|#x3C);/g, val: "<" }, quot: { regex: /&(quot|#34|#x22);/g, val: '"' } }, this.ampEntity = { regex: /&(amp|#38|#x26);/g, val: "&" }, this.htmlEntities = { space: { regex: /&(nbsp|#160);/g, val: " " }, cent: { regex: /&(cent|#162);/g, val: "¢" }, pound: { regex: /&(pound|#163);/g, val: "£" }, yen: { regex: /&(yen|#165);/g, val: "¥" }, euro: { regex: /&(euro|#8364);/g, val: "€" }, copyright: { regex: /&(copy|#169);/g, val: "©" }, reg: { regex: /&(reg|#174);/g, val: "®" }, inr: { regex: /&(inr|#8377);/g, val: "₹" } }, this.addExternalEntities = ne, this.parseXml = le, this.parseTextData = re, this.resolveNameSpace = se, this.buildAttributesMap = ae, this.isItStopNode = he, this.replaceEntitiesValue = ue, this.readStopNodeData = fe, this.saveTextToParentTag = ce, this.addChild = de;
|
|
@@ -836,15 +841,15 @@ let ie = class {
|
|
|
836
841
|
function ne(t) {
|
|
837
842
|
const e = Object.keys(t);
|
|
838
843
|
for (let i = 0; i < e.length; i++) {
|
|
839
|
-
const
|
|
840
|
-
this.lastEntities[
|
|
844
|
+
const r = e[i];
|
|
845
|
+
this.lastEntities[r] = { regex: new RegExp("&" + r + ";", "g"), val: t[r] };
|
|
841
846
|
}
|
|
842
847
|
}
|
|
843
|
-
function re(t, e, i,
|
|
844
|
-
if (t !== void 0 && (this.options.trimValues && !
|
|
845
|
-
|
|
846
|
-
const o = this.options.tagValueProcessor(e, t, i, n,
|
|
847
|
-
return o == null ? t : typeof o != typeof t || o !== t ? o : this.options.trimValues ?
|
|
848
|
+
function re(t, e, i, r, n, s, a) {
|
|
849
|
+
if (t !== void 0 && (this.options.trimValues && !r && (t = t.trim()), t.length > 0)) {
|
|
850
|
+
a || (t = this.replaceEntitiesValue(t));
|
|
851
|
+
const o = this.options.tagValueProcessor(e, t, i, n, s);
|
|
852
|
+
return o == null ? t : typeof o != typeof t || o !== t ? o : this.options.trimValues ? S(t, this.options.parseTagValue, this.options.numberParseOptions) : t.trim() === t ? S(t, this.options.parseTagValue, this.options.numberParseOptions) : t;
|
|
848
853
|
}
|
|
849
854
|
}
|
|
850
855
|
function se(t) {
|
|
@@ -859,112 +864,114 @@ function se(t) {
|
|
|
859
864
|
const oe = new RegExp(`([^\\s=]+)\\s*(=\\s*(['"])([\\s\\S]*?)\\3)?`, "gm");
|
|
860
865
|
function ae(t, e, i) {
|
|
861
866
|
if (!this.options.ignoreAttributes && typeof t == "string") {
|
|
862
|
-
const
|
|
863
|
-
for (let
|
|
864
|
-
const o = this.resolveNameSpace(
|
|
865
|
-
let
|
|
867
|
+
const r = j.getAllMatches(t, oe), n = r.length, s = {};
|
|
868
|
+
for (let a = 0; a < n; a++) {
|
|
869
|
+
const o = this.resolveNameSpace(r[a][1]);
|
|
870
|
+
let l = r[a][4], d = this.options.attributeNamePrefix + o;
|
|
866
871
|
if (o.length)
|
|
867
|
-
if (this.options.transformAttributeName && (d = this.options.transformAttributeName(d)), d === "__proto__" && (d = "#__proto__"),
|
|
868
|
-
this.options.trimValues && (
|
|
869
|
-
const u = this.options.attributeValueProcessor(o,
|
|
870
|
-
u == null ?
|
|
872
|
+
if (this.options.transformAttributeName && (d = this.options.transformAttributeName(d)), d === "__proto__" && (d = "#__proto__"), l !== void 0) {
|
|
873
|
+
this.options.trimValues && (l = l.trim()), l = this.replaceEntitiesValue(l);
|
|
874
|
+
const u = this.options.attributeValueProcessor(o, l, e);
|
|
875
|
+
u == null ? s[d] = l : typeof u != typeof l || u !== l ? s[d] = u : s[d] = S(l, this.options.parseAttributeValue, this.options.numberParseOptions);
|
|
871
876
|
} else
|
|
872
|
-
this.options.allowBooleanAttributes && (
|
|
877
|
+
this.options.allowBooleanAttributes && (s[d] = !0);
|
|
873
878
|
}
|
|
874
|
-
if (!Object.keys(
|
|
879
|
+
if (!Object.keys(s).length)
|
|
875
880
|
return;
|
|
876
881
|
if (this.options.attributesGroupName) {
|
|
877
|
-
const
|
|
878
|
-
return
|
|
882
|
+
const a = {};
|
|
883
|
+
return a[this.options.attributesGroupName] = s, a;
|
|
879
884
|
}
|
|
880
|
-
return
|
|
885
|
+
return s;
|
|
881
886
|
}
|
|
882
887
|
}
|
|
883
888
|
const le = function(t) {
|
|
884
889
|
t = t.replace(/\r\n?/g, `
|
|
885
890
|
`);
|
|
886
|
-
const e = new
|
|
887
|
-
let i = e,
|
|
888
|
-
for (let
|
|
889
|
-
if (t[
|
|
890
|
-
if (t[
|
|
891
|
-
const
|
|
892
|
-
let o = t.substring(
|
|
891
|
+
const e = new N("!xml");
|
|
892
|
+
let i = e, r = "", n = "";
|
|
893
|
+
for (let s = 0; s < t.length; s++)
|
|
894
|
+
if (t[s] === "<")
|
|
895
|
+
if (t[s + 1] === "/") {
|
|
896
|
+
const a = x(t, ">", s, "Closing Tag is not closed.");
|
|
897
|
+
let o = t.substring(s + 2, a).trim();
|
|
893
898
|
if (this.options.removeNSPrefix) {
|
|
894
899
|
const u = o.indexOf(":");
|
|
895
900
|
u !== -1 && (o = o.substr(u + 1));
|
|
896
901
|
}
|
|
897
|
-
this.options.transformTagName && (o = this.options.transformTagName(o)), i && (
|
|
898
|
-
const
|
|
902
|
+
this.options.transformTagName && (o = this.options.transformTagName(o)), i && (r = this.saveTextToParentTag(r, i, n));
|
|
903
|
+
const l = n.substring(n.lastIndexOf(".") + 1);
|
|
899
904
|
if (o && this.options.unpairedTags.indexOf(o) !== -1)
|
|
900
905
|
throw new Error(`Unpaired tag can not be used as closing tag: </${o}>`);
|
|
901
906
|
let d = 0;
|
|
902
|
-
|
|
903
|
-
} else if (t[
|
|
904
|
-
let
|
|
905
|
-
if (!
|
|
907
|
+
l && this.options.unpairedTags.indexOf(l) !== -1 ? (d = n.lastIndexOf(".", n.lastIndexOf(".") - 1), this.tagsNodeStack.pop()) : d = n.lastIndexOf("."), n = n.substring(0, d), i = this.tagsNodeStack.pop(), r = "", s = a;
|
|
908
|
+
} else if (t[s + 1] === "?") {
|
|
909
|
+
let a = D(t, s, !1, "?>");
|
|
910
|
+
if (!a)
|
|
906
911
|
throw new Error("Pi Tag is not closed.");
|
|
907
|
-
if (
|
|
908
|
-
const o = new
|
|
909
|
-
o.add(this.options.textNodeName, ""),
|
|
912
|
+
if (r = this.saveTextToParentTag(r, i, n), !(this.options.ignoreDeclaration && a.tagName === "?xml" || this.options.ignorePiTags)) {
|
|
913
|
+
const o = new N(a.tagName);
|
|
914
|
+
o.add(this.options.textNodeName, ""), a.tagName !== a.tagExp && a.attrExpPresent && (o[":@"] = this.buildAttributesMap(a.tagExp, n, a.tagName)), this.addChild(i, o, n);
|
|
910
915
|
}
|
|
911
|
-
|
|
912
|
-
} else if (t.substr(
|
|
913
|
-
const
|
|
916
|
+
s = a.closeIndex + 1;
|
|
917
|
+
} else if (t.substr(s + 1, 3) === "!--") {
|
|
918
|
+
const a = x(t, "-->", s + 4, "Comment is not closed.");
|
|
914
919
|
if (this.options.commentPropName) {
|
|
915
|
-
const o = t.substring(
|
|
916
|
-
|
|
920
|
+
const o = t.substring(s + 4, a - 2);
|
|
921
|
+
r = this.saveTextToParentTag(r, i, n), i.add(this.options.commentPropName, [{ [this.options.textNodeName]: o }]);
|
|
917
922
|
}
|
|
918
|
-
|
|
919
|
-
} else if (t.substr(
|
|
920
|
-
const
|
|
921
|
-
this.docTypeEntities =
|
|
922
|
-
} else if (t.substr(
|
|
923
|
-
const
|
|
924
|
-
if (
|
|
923
|
+
s = a;
|
|
924
|
+
} else if (t.substr(s + 1, 2) === "!D") {
|
|
925
|
+
const a = te(t, s);
|
|
926
|
+
this.docTypeEntities = a.entities, s = a.i;
|
|
927
|
+
} else if (t.substr(s + 1, 2) === "![") {
|
|
928
|
+
const a = x(t, "]]>", s, "CDATA is not closed.") - 2, o = t.substring(s + 9, a);
|
|
929
|
+
if (r = this.saveTextToParentTag(r, i, n), this.options.cdataPropName)
|
|
925
930
|
i.add(this.options.cdataPropName, [{ [this.options.textNodeName]: o }]);
|
|
926
931
|
else {
|
|
927
|
-
let
|
|
928
|
-
|
|
932
|
+
let l = this.parseTextData(o, i.tagname, n, !0, !1, !0);
|
|
933
|
+
l == null && (l = ""), i.add(this.options.textNodeName, l);
|
|
929
934
|
}
|
|
930
|
-
|
|
935
|
+
s = a + 2;
|
|
931
936
|
} else {
|
|
932
|
-
let
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
937
|
+
let a = D(t, s, this.options.removeNSPrefix), o = a.tagName;
|
|
938
|
+
const l = a.rawTagName;
|
|
939
|
+
let d = a.tagExp, u = a.attrExpPresent, c = a.closeIndex;
|
|
940
|
+
this.options.transformTagName && (o = this.options.transformTagName(o)), i && r && i.tagname !== "!xml" && (r = this.saveTextToParentTag(r, i, n, !1));
|
|
941
|
+
const p = i;
|
|
942
|
+
if (p && this.options.unpairedTags.indexOf(p.tagname) !== -1 && (i = this.tagsNodeStack.pop(), n = n.substring(0, n.lastIndexOf("."))), o !== e.tagname && (n += n ? "." + o : o), this.isItStopNode(this.options.stopNodes, n, o)) {
|
|
943
|
+
let h = "";
|
|
944
|
+
if (d.length > 0 && d.lastIndexOf("/") === d.length - 1)
|
|
945
|
+
s = a.closeIndex;
|
|
939
946
|
else if (this.options.unpairedTags.indexOf(o) !== -1)
|
|
940
|
-
|
|
947
|
+
s = a.closeIndex;
|
|
941
948
|
else {
|
|
942
|
-
const
|
|
943
|
-
if (!
|
|
944
|
-
throw new Error(`Unexpected end of ${
|
|
945
|
-
|
|
949
|
+
const b = this.readStopNodeData(t, l, c + 1);
|
|
950
|
+
if (!b)
|
|
951
|
+
throw new Error(`Unexpected end of ${l}`);
|
|
952
|
+
s = b.i, h = b.tagContent;
|
|
946
953
|
}
|
|
947
|
-
const
|
|
948
|
-
o !==
|
|
954
|
+
const w = new N(o);
|
|
955
|
+
o !== d && u && (w[":@"] = this.buildAttributesMap(d, n, o)), h && (h = this.parseTextData(h, o, n, !0, u, !0, !0)), n = n.substr(0, n.lastIndexOf(".")), w.add(this.options.textNodeName, h), this.addChild(i, w, n);
|
|
949
956
|
} else {
|
|
950
|
-
if (
|
|
951
|
-
o[o.length - 1] === "/" ? (o = o.substr(0, o.length - 1), n = n.substr(0, n.length - 1),
|
|
952
|
-
const
|
|
953
|
-
o !==
|
|
957
|
+
if (d.length > 0 && d.lastIndexOf("/") === d.length - 1) {
|
|
958
|
+
o[o.length - 1] === "/" ? (o = o.substr(0, o.length - 1), n = n.substr(0, n.length - 1), d = o) : d = d.substr(0, d.length - 1), this.options.transformTagName && (o = this.options.transformTagName(o));
|
|
959
|
+
const h = new N(o);
|
|
960
|
+
o !== d && u && (h[":@"] = this.buildAttributesMap(d, n, o)), this.addChild(i, h, n), n = n.substr(0, n.lastIndexOf("."));
|
|
954
961
|
} else {
|
|
955
|
-
const
|
|
956
|
-
this.tagsNodeStack.push(i), o !==
|
|
962
|
+
const h = new N(o);
|
|
963
|
+
this.tagsNodeStack.push(i), o !== d && u && (h[":@"] = this.buildAttributesMap(d, n, o)), this.addChild(i, h, n), i = h;
|
|
957
964
|
}
|
|
958
|
-
|
|
965
|
+
r = "", s = c;
|
|
959
966
|
}
|
|
960
967
|
}
|
|
961
968
|
else
|
|
962
|
-
|
|
969
|
+
r += t[s];
|
|
963
970
|
return e.child;
|
|
964
971
|
};
|
|
965
972
|
function de(t, e, i) {
|
|
966
|
-
const
|
|
967
|
-
|
|
973
|
+
const r = this.options.updateTag(e.tagname, i, e[":@"]);
|
|
974
|
+
r === !1 || (typeof r == "string" && (e.tagname = r), t.addChild(e));
|
|
968
975
|
}
|
|
969
976
|
const ue = function(t) {
|
|
970
977
|
if (this.options.processEntities) {
|
|
@@ -985,66 +992,68 @@ const ue = function(t) {
|
|
|
985
992
|
}
|
|
986
993
|
return t;
|
|
987
994
|
};
|
|
988
|
-
function ce(t, e, i,
|
|
989
|
-
return t && (
|
|
995
|
+
function ce(t, e, i, r) {
|
|
996
|
+
return t && (r === void 0 && (r = Object.keys(e.child).length === 0), t = this.parseTextData(t, e.tagname, i, !1, e[":@"] ? Object.keys(e[":@"]).length !== 0 : !1, r), t !== void 0 && t !== "" && e.add(this.options.textNodeName, t), t = ""), t;
|
|
990
997
|
}
|
|
991
998
|
function he(t, e, i) {
|
|
992
|
-
const
|
|
999
|
+
const r = "*." + i;
|
|
993
1000
|
for (const n in t) {
|
|
994
|
-
const
|
|
995
|
-
if (
|
|
1001
|
+
const s = t[n];
|
|
1002
|
+
if (r === s || e === s)
|
|
996
1003
|
return !0;
|
|
997
1004
|
}
|
|
998
1005
|
return !1;
|
|
999
1006
|
}
|
|
1000
1007
|
function pe(t, e, i = ">") {
|
|
1001
|
-
let
|
|
1002
|
-
for (let
|
|
1003
|
-
let
|
|
1004
|
-
if (
|
|
1005
|
-
|
|
1006
|
-
else if (
|
|
1007
|
-
|
|
1008
|
-
else if (
|
|
1008
|
+
let r, n = "";
|
|
1009
|
+
for (let s = e; s < t.length; s++) {
|
|
1010
|
+
let a = t[s];
|
|
1011
|
+
if (r)
|
|
1012
|
+
a === r && (r = "");
|
|
1013
|
+
else if (a === '"' || a === "'")
|
|
1014
|
+
r = a;
|
|
1015
|
+
else if (a === i[0])
|
|
1009
1016
|
if (i[1]) {
|
|
1010
|
-
if (t[
|
|
1011
|
-
return { data: n, index:
|
|
1017
|
+
if (t[s + 1] === i[1])
|
|
1018
|
+
return { data: n, index: s };
|
|
1012
1019
|
} else
|
|
1013
|
-
return { data: n, index:
|
|
1020
|
+
return { data: n, index: s };
|
|
1014
1021
|
else
|
|
1015
|
-
|
|
1016
|
-
n +=
|
|
1022
|
+
a === " " && (a = " ");
|
|
1023
|
+
n += a;
|
|
1017
1024
|
}
|
|
1018
1025
|
}
|
|
1019
|
-
function x(t, e, i,
|
|
1026
|
+
function x(t, e, i, r) {
|
|
1020
1027
|
const n = t.indexOf(e, i);
|
|
1021
1028
|
if (n === -1)
|
|
1022
|
-
throw new Error(
|
|
1029
|
+
throw new Error(r);
|
|
1023
1030
|
return n + e.length - 1;
|
|
1024
1031
|
}
|
|
1025
|
-
function
|
|
1026
|
-
const n = pe(t, e + 1,
|
|
1032
|
+
function D(t, e, i, r = ">") {
|
|
1033
|
+
const n = pe(t, e + 1, r);
|
|
1027
1034
|
if (!n)
|
|
1028
1035
|
return;
|
|
1029
|
-
let
|
|
1030
|
-
const
|
|
1031
|
-
let
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1036
|
+
let s = n.data;
|
|
1037
|
+
const a = n.index, o = s.search(/\s/);
|
|
1038
|
+
let l = s, d = !0;
|
|
1039
|
+
o !== -1 && (l = s.substr(0, o).replace(/\s\s*$/, ""), s = s.substr(o + 1));
|
|
1040
|
+
const u = l;
|
|
1041
|
+
if (i) {
|
|
1042
|
+
const c = l.indexOf(":");
|
|
1043
|
+
c !== -1 && (l = l.substr(c + 1), d = l !== n.data.substr(c + 1));
|
|
1044
|
+
}
|
|
1045
|
+
return { tagName: l, tagExp: s, closeIndex: a, attrExpPresent: d, rawTagName: u };
|
|
1037
1046
|
}
|
|
1038
1047
|
function fe(t, e, i) {
|
|
1039
|
-
const
|
|
1048
|
+
const r = i;
|
|
1040
1049
|
let n = 1;
|
|
1041
1050
|
for (; i < t.length; i++)
|
|
1042
1051
|
if (t[i] === "<")
|
|
1043
1052
|
if (t[i + 1] === "/") {
|
|
1044
|
-
const
|
|
1045
|
-
if (t.substring(i + 2,
|
|
1046
|
-
return { tagContent: t.substring(
|
|
1047
|
-
i =
|
|
1053
|
+
const s = x(t, ">", i, `${e} is not closed`);
|
|
1054
|
+
if (t.substring(i + 2, s).trim() === e && (n--, n === 0))
|
|
1055
|
+
return { tagContent: t.substring(r, i), i: s };
|
|
1056
|
+
i = s;
|
|
1048
1057
|
} else if (t[i + 1] === "?")
|
|
1049
1058
|
i = x(t, "?>", i + 1, "StopNode is not closed.");
|
|
1050
1059
|
else if (t.substr(i + 1, 3) === "!--")
|
|
@@ -1052,64 +1061,64 @@ function fe(t, e, i) {
|
|
|
1052
1061
|
else if (t.substr(i + 1, 2) === "![")
|
|
1053
1062
|
i = x(t, "]]>", i, "StopNode is not closed.") - 2;
|
|
1054
1063
|
else {
|
|
1055
|
-
const
|
|
1056
|
-
|
|
1064
|
+
const s = D(t, i, ">");
|
|
1065
|
+
s && ((s && s.tagName) === e && s.tagExp[s.tagExp.length - 1] !== "/" && n++, i = s.closeIndex);
|
|
1057
1066
|
}
|
|
1058
1067
|
}
|
|
1059
|
-
function
|
|
1068
|
+
function S(t, e, i) {
|
|
1060
1069
|
if (e && typeof t == "string") {
|
|
1061
|
-
const
|
|
1062
|
-
return
|
|
1070
|
+
const r = t.trim();
|
|
1071
|
+
return r === "true" ? !0 : r === "false" ? !1 : ee(t, i);
|
|
1063
1072
|
} else
|
|
1064
|
-
return
|
|
1073
|
+
return j.isExist(t) ? t : "";
|
|
1065
1074
|
}
|
|
1066
|
-
var ge = ie,
|
|
1075
|
+
var ge = ie, nt = {};
|
|
1067
1076
|
function me(t, e) {
|
|
1068
|
-
return
|
|
1077
|
+
return rt(t, e);
|
|
1069
1078
|
}
|
|
1070
|
-
function
|
|
1071
|
-
let
|
|
1079
|
+
function rt(t, e, i) {
|
|
1080
|
+
let r;
|
|
1072
1081
|
const n = {};
|
|
1073
|
-
for (let
|
|
1074
|
-
const
|
|
1075
|
-
let
|
|
1076
|
-
if (i === void 0 ?
|
|
1077
|
-
|
|
1082
|
+
for (let s = 0; s < t.length; s++) {
|
|
1083
|
+
const a = t[s], o = we(a);
|
|
1084
|
+
let l = "";
|
|
1085
|
+
if (i === void 0 ? l = o : l = i + "." + o, o === e.textNodeName)
|
|
1086
|
+
r === void 0 ? r = a[o] : r += "" + a[o];
|
|
1078
1087
|
else {
|
|
1079
1088
|
if (o === void 0)
|
|
1080
1089
|
continue;
|
|
1081
|
-
if (
|
|
1082
|
-
let d =
|
|
1090
|
+
if (a[o]) {
|
|
1091
|
+
let d = rt(a[o], e, l);
|
|
1083
1092
|
const u = ye(d, e);
|
|
1084
|
-
|
|
1093
|
+
a[":@"] ? ve(d, a[":@"], l, e) : Object.keys(d).length === 1 && d[e.textNodeName] !== void 0 && !e.alwaysCreateTextNode ? d = d[e.textNodeName] : Object.keys(d).length === 0 && (e.alwaysCreateTextNode ? d[e.textNodeName] = "" : d = ""), n[o] !== void 0 && n.hasOwnProperty(o) ? (Array.isArray(n[o]) || (n[o] = [n[o]]), n[o].push(d)) : e.isArray(o, l, u) ? n[o] = [d] : n[o] = d;
|
|
1085
1094
|
}
|
|
1086
1095
|
}
|
|
1087
1096
|
}
|
|
1088
|
-
return typeof
|
|
1097
|
+
return typeof r == "string" ? r.length > 0 && (n[e.textNodeName] = r) : r !== void 0 && (n[e.textNodeName] = r), n;
|
|
1089
1098
|
}
|
|
1090
1099
|
function we(t) {
|
|
1091
1100
|
const e = Object.keys(t);
|
|
1092
1101
|
for (let i = 0; i < e.length; i++) {
|
|
1093
|
-
const
|
|
1094
|
-
if (
|
|
1095
|
-
return
|
|
1102
|
+
const r = e[i];
|
|
1103
|
+
if (r !== ":@")
|
|
1104
|
+
return r;
|
|
1096
1105
|
}
|
|
1097
1106
|
}
|
|
1098
|
-
function ve(t, e, i,
|
|
1107
|
+
function ve(t, e, i, r) {
|
|
1099
1108
|
if (e) {
|
|
1100
|
-
const n = Object.keys(e),
|
|
1101
|
-
for (let
|
|
1102
|
-
const o = n[
|
|
1103
|
-
|
|
1109
|
+
const n = Object.keys(e), s = n.length;
|
|
1110
|
+
for (let a = 0; a < s; a++) {
|
|
1111
|
+
const o = n[a];
|
|
1112
|
+
r.isArray(o, i + "." + o, !0, !0) ? t[o] = [e[o]] : t[o] = e[o];
|
|
1104
1113
|
}
|
|
1105
1114
|
}
|
|
1106
1115
|
}
|
|
1107
1116
|
function ye(t, e) {
|
|
1108
|
-
const { textNodeName: i } = e,
|
|
1109
|
-
return !!(
|
|
1117
|
+
const { textNodeName: i } = e, r = Object.keys(t).length;
|
|
1118
|
+
return !!(r === 0 || r === 1 && (t[i] || typeof t[i] == "boolean" || t[i] === 0));
|
|
1110
1119
|
}
|
|
1111
|
-
|
|
1112
|
-
const { buildOptions: xe } =
|
|
1120
|
+
nt.prettify = me;
|
|
1121
|
+
const { buildOptions: xe } = C, be = ge, { prettify: Ee } = nt, Ne = L;
|
|
1113
1122
|
let _e = class {
|
|
1114
1123
|
constructor(t) {
|
|
1115
1124
|
this.externalEntities = {}, this.options = xe(t);
|
|
@@ -1128,8 +1137,8 @@ let _e = class {
|
|
|
1128
1137
|
}
|
|
1129
1138
|
const i = new be(this.options);
|
|
1130
1139
|
i.addExternalEntities(this.externalEntities);
|
|
1131
|
-
const
|
|
1132
|
-
return this.options.preserveOrder ||
|
|
1140
|
+
const r = i.parseXml(t);
|
|
1141
|
+
return this.options.preserveOrder || r === void 0 ? r : Ee(r, this.options);
|
|
1133
1142
|
}
|
|
1134
1143
|
addEntity(t, e) {
|
|
1135
1144
|
if (e.indexOf("&") !== -1)
|
|
@@ -1146,66 +1155,70 @@ const Te = `
|
|
|
1146
1155
|
`;
|
|
1147
1156
|
function Ie(t, e) {
|
|
1148
1157
|
let i = "";
|
|
1149
|
-
return e.format && e.indentBy.length > 0 && (i = Te),
|
|
1158
|
+
return e.format && e.indentBy.length > 0 && (i = Te), st(t, e, "", i);
|
|
1150
1159
|
}
|
|
1151
|
-
function
|
|
1152
|
-
let n = "",
|
|
1153
|
-
for (let
|
|
1154
|
-
const o = t[
|
|
1160
|
+
function st(t, e, i, r) {
|
|
1161
|
+
let n = "", s = !1;
|
|
1162
|
+
for (let a = 0; a < t.length; a++) {
|
|
1163
|
+
const o = t[a], l = Oe(o);
|
|
1164
|
+
if (l === void 0)
|
|
1165
|
+
continue;
|
|
1155
1166
|
let d = "";
|
|
1156
|
-
if (i.length === 0 ? d =
|
|
1157
|
-
let w = o[
|
|
1158
|
-
Pe(d, e) || (w = e.tagValueProcessor(
|
|
1167
|
+
if (i.length === 0 ? d = l : d = `${i}.${l}`, l === e.textNodeName) {
|
|
1168
|
+
let w = o[l];
|
|
1169
|
+
Pe(d, e) || (w = e.tagValueProcessor(l, w), w = ot(w, e)), s && (n += r), n += w, s = !1;
|
|
1159
1170
|
continue;
|
|
1160
|
-
} else if (
|
|
1161
|
-
|
|
1171
|
+
} else if (l === e.cdataPropName) {
|
|
1172
|
+
s && (n += r), n += `<![CDATA[${o[l][0][e.textNodeName]}]]>`, s = !1;
|
|
1162
1173
|
continue;
|
|
1163
|
-
} else if (
|
|
1164
|
-
n +=
|
|
1174
|
+
} else if (l === e.commentPropName) {
|
|
1175
|
+
n += r + `<!--${o[l][0][e.textNodeName]}-->`, s = !0;
|
|
1165
1176
|
continue;
|
|
1166
|
-
} else if (
|
|
1167
|
-
const w =
|
|
1168
|
-
let
|
|
1169
|
-
|
|
1177
|
+
} else if (l[0] === "?") {
|
|
1178
|
+
const w = X(o[":@"], e), b = l === "?xml" ? "" : r;
|
|
1179
|
+
let _ = o[l][0][e.textNodeName];
|
|
1180
|
+
_ = _.length !== 0 ? " " + _ : "", n += b + `<${l}${_}${w}?>`, s = !0;
|
|
1170
1181
|
continue;
|
|
1171
1182
|
}
|
|
1172
|
-
let u =
|
|
1183
|
+
let u = r;
|
|
1173
1184
|
u !== "" && (u += e.indentBy);
|
|
1174
|
-
const
|
|
1175
|
-
e.unpairedTags.indexOf(
|
|
1185
|
+
const c = X(o[":@"], e), p = r + `<${l}${c}`, h = st(o[l], e, d, u);
|
|
1186
|
+
e.unpairedTags.indexOf(l) !== -1 ? e.suppressUnpairedNode ? n += p + ">" : n += p + "/>" : (!h || h.length === 0) && e.suppressEmptyNode ? n += p + "/>" : h && h.endsWith(">") ? n += p + `>${h}${r}</${l}>` : (n += p + ">", h && r !== "" && (h.includes("/>") || h.includes("</")) ? n += r + e.indentBy + h + r : n += h, n += `</${l}>`), s = !0;
|
|
1176
1187
|
}
|
|
1177
1188
|
return n;
|
|
1178
1189
|
}
|
|
1179
1190
|
function Oe(t) {
|
|
1180
1191
|
const e = Object.keys(t);
|
|
1181
1192
|
for (let i = 0; i < e.length; i++) {
|
|
1182
|
-
const
|
|
1183
|
-
if (
|
|
1184
|
-
return
|
|
1193
|
+
const r = e[i];
|
|
1194
|
+
if (t.hasOwnProperty(r) && r !== ":@")
|
|
1195
|
+
return r;
|
|
1185
1196
|
}
|
|
1186
1197
|
}
|
|
1187
|
-
function
|
|
1198
|
+
function X(t, e) {
|
|
1188
1199
|
let i = "";
|
|
1189
1200
|
if (t && !e.ignoreAttributes)
|
|
1190
|
-
for (let
|
|
1191
|
-
|
|
1192
|
-
|
|
1201
|
+
for (let r in t) {
|
|
1202
|
+
if (!t.hasOwnProperty(r))
|
|
1203
|
+
continue;
|
|
1204
|
+
let n = e.attributeValueProcessor(r, t[r]);
|
|
1205
|
+
n = ot(n, e), n === !0 && e.suppressBooleanAttributes ? i += ` ${r.substr(e.attributeNamePrefix.length)}` : i += ` ${r.substr(e.attributeNamePrefix.length)}="${n}"`;
|
|
1193
1206
|
}
|
|
1194
1207
|
return i;
|
|
1195
1208
|
}
|
|
1196
1209
|
function Pe(t, e) {
|
|
1197
1210
|
t = t.substr(0, t.length - e.textNodeName.length - 1);
|
|
1198
1211
|
let i = t.substr(t.lastIndexOf(".") + 1);
|
|
1199
|
-
for (let
|
|
1200
|
-
if (e.stopNodes[
|
|
1212
|
+
for (let r in e.stopNodes)
|
|
1213
|
+
if (e.stopNodes[r] === t || e.stopNodes[r] === "*." + i)
|
|
1201
1214
|
return !0;
|
|
1202
1215
|
return !1;
|
|
1203
1216
|
}
|
|
1204
|
-
function
|
|
1217
|
+
function ot(t, e) {
|
|
1205
1218
|
if (t && t.length > 0 && e.processEntities)
|
|
1206
1219
|
for (let i = 0; i < e.entities.length; i++) {
|
|
1207
|
-
const
|
|
1208
|
-
t = t.replace(
|
|
1220
|
+
const r = e.entities[i];
|
|
1221
|
+
t = t.replace(r.regex, r.val);
|
|
1209
1222
|
}
|
|
1210
1223
|
return t;
|
|
1211
1224
|
}
|
|
@@ -1227,65 +1240,66 @@ function y(t) {
|
|
|
1227
1240
|
y.prototype.build = function(t) {
|
|
1228
1241
|
return this.options.preserveOrder ? De(t, this.options) : (Array.isArray(t) && this.options.arrayNodeName && this.options.arrayNodeName.length > 1 && (t = { [this.options.arrayNodeName]: t }), this.j2x(t, 0).val);
|
|
1229
1242
|
}, y.prototype.j2x = function(t, e) {
|
|
1230
|
-
let i = "",
|
|
1243
|
+
let i = "", r = "";
|
|
1231
1244
|
for (let n in t)
|
|
1232
|
-
if (
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
+
if (t.hasOwnProperty(n))
|
|
1246
|
+
if (typeof t[n] > "u")
|
|
1247
|
+
this.isAttribute(n) && (r += "");
|
|
1248
|
+
else if (t[n] === null)
|
|
1249
|
+
this.isAttribute(n) ? r += "" : n[0] === "?" ? r += this.indentate(e) + "<" + n + "?" + this.tagEndChar : r += this.indentate(e) + "<" + n + "/" + this.tagEndChar;
|
|
1250
|
+
else if (t[n] instanceof Date)
|
|
1251
|
+
r += this.buildTextValNode(t[n], n, "", e);
|
|
1252
|
+
else if (typeof t[n] != "object") {
|
|
1253
|
+
const s = this.isAttribute(n);
|
|
1254
|
+
if (s)
|
|
1255
|
+
i += this.buildAttrPairStr(s, "" + t[n]);
|
|
1256
|
+
else if (n === this.options.textNodeName) {
|
|
1257
|
+
let a = this.options.tagValueProcessor(n, "" + t[n]);
|
|
1258
|
+
r += this.replaceEntitiesValue(a);
|
|
1259
|
+
} else
|
|
1260
|
+
r += this.buildTextValNode(t[n], n, "", e);
|
|
1261
|
+
} else if (Array.isArray(t[n])) {
|
|
1262
|
+
const s = t[n].length;
|
|
1263
|
+
let a = "";
|
|
1264
|
+
for (let o = 0; o < s; o++) {
|
|
1265
|
+
const l = t[n][o];
|
|
1266
|
+
typeof l > "u" || (l === null ? n[0] === "?" ? r += this.indentate(e) + "<" + n + "?" + this.tagEndChar : r += this.indentate(e) + "<" + n + "/" + this.tagEndChar : typeof l == "object" ? this.options.oneListGroup ? a += this.j2x(l, e + 1).val : a += this.processTextOrObjNode(l, n, e) : a += this.buildTextValNode(l, n, "", e));
|
|
1267
|
+
}
|
|
1268
|
+
this.options.oneListGroup && (a = this.buildObjectNode(a, n, "", e)), r += a;
|
|
1269
|
+
} else if (this.options.attributesGroupName && n === this.options.attributesGroupName) {
|
|
1270
|
+
const s = Object.keys(t[n]), a = s.length;
|
|
1271
|
+
for (let o = 0; o < a; o++)
|
|
1272
|
+
i += this.buildAttrPairStr(s[o], "" + t[n][s[o]]);
|
|
1245
1273
|
} else
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
const r = t[n].length;
|
|
1249
|
-
let l = "";
|
|
1250
|
-
for (let o = 0; o < r; o++) {
|
|
1251
|
-
const a = t[n][o];
|
|
1252
|
-
typeof a > "u" || (a === null ? n[0] === "?" ? s += this.indentate(e) + "<" + n + "?" + this.tagEndChar : s += this.indentate(e) + "<" + n + "/" + this.tagEndChar : typeof a == "object" ? this.options.oneListGroup ? l += this.j2x(a, e + 1).val : l += this.processTextOrObjNode(a, n, e) : l += this.buildTextValNode(a, n, "", e));
|
|
1253
|
-
}
|
|
1254
|
-
this.options.oneListGroup && (l = this.buildObjectNode(l, n, "", e)), s += l;
|
|
1255
|
-
} else if (this.options.attributesGroupName && n === this.options.attributesGroupName) {
|
|
1256
|
-
const r = Object.keys(t[n]), l = r.length;
|
|
1257
|
-
for (let o = 0; o < l; o++)
|
|
1258
|
-
i += this.buildAttrPairStr(r[o], "" + t[n][r[o]]);
|
|
1259
|
-
} else
|
|
1260
|
-
s += this.processTextOrObjNode(t[n], n, e);
|
|
1261
|
-
return { attrStr: i, val: s };
|
|
1274
|
+
r += this.processTextOrObjNode(t[n], n, e);
|
|
1275
|
+
return { attrStr: i, val: r };
|
|
1262
1276
|
}, y.prototype.buildAttrPairStr = function(t, e) {
|
|
1263
1277
|
return e = this.options.attributeValueProcessor(t, "" + e), e = this.replaceEntitiesValue(e), this.options.suppressBooleanAttributes && e === "true" ? " " + t : " " + t + '="' + e + '"';
|
|
1264
1278
|
};
|
|
1265
1279
|
function Fe(t, e, i) {
|
|
1266
|
-
const
|
|
1267
|
-
return t[this.options.textNodeName] !== void 0 && Object.keys(t).length === 1 ? this.buildTextValNode(t[this.options.textNodeName], e,
|
|
1280
|
+
const r = this.j2x(t, i + 1);
|
|
1281
|
+
return t[this.options.textNodeName] !== void 0 && Object.keys(t).length === 1 ? this.buildTextValNode(t[this.options.textNodeName], e, r.attrStr, i) : this.buildObjectNode(r.val, e, r.attrStr, i);
|
|
1268
1282
|
}
|
|
1269
|
-
y.prototype.buildObjectNode = function(t, e, i,
|
|
1283
|
+
y.prototype.buildObjectNode = function(t, e, i, r) {
|
|
1270
1284
|
if (t === "")
|
|
1271
|
-
return e[0] === "?" ? this.indentate(
|
|
1285
|
+
return e[0] === "?" ? this.indentate(r) + "<" + e + i + "?" + this.tagEndChar : this.indentate(r) + "<" + e + i + this.closeTag(e) + this.tagEndChar;
|
|
1272
1286
|
{
|
|
1273
|
-
let n = "</" + e + this.tagEndChar,
|
|
1274
|
-
return e[0] === "?" && (
|
|
1287
|
+
let n = "</" + e + this.tagEndChar, s = "";
|
|
1288
|
+
return e[0] === "?" && (s = "?", n = ""), (i || i === "") && t.indexOf("<") === -1 ? this.indentate(r) + "<" + e + i + s + ">" + t + n : this.options.commentPropName !== !1 && e === this.options.commentPropName && s.length === 0 ? this.indentate(r) + `<!--${t}-->` + this.newLine : this.indentate(r) + "<" + e + i + s + this.tagEndChar + t + this.indentate(r) + n;
|
|
1275
1289
|
}
|
|
1276
1290
|
}, y.prototype.closeTag = function(t) {
|
|
1277
1291
|
let e = "";
|
|
1278
1292
|
return this.options.unpairedTags.indexOf(t) !== -1 ? this.options.suppressUnpairedNode || (e = "/") : this.options.suppressEmptyNode ? e = "/" : e = `></${t}`, e;
|
|
1279
|
-
}, y.prototype.buildTextValNode = function(t, e, i,
|
|
1293
|
+
}, y.prototype.buildTextValNode = function(t, e, i, r) {
|
|
1280
1294
|
if (this.options.cdataPropName !== !1 && e === this.options.cdataPropName)
|
|
1281
|
-
return this.indentate(
|
|
1295
|
+
return this.indentate(r) + `<![CDATA[${t}]]>` + this.newLine;
|
|
1282
1296
|
if (this.options.commentPropName !== !1 && e === this.options.commentPropName)
|
|
1283
|
-
return this.indentate(
|
|
1297
|
+
return this.indentate(r) + `<!--${t}-->` + this.newLine;
|
|
1284
1298
|
if (e[0] === "?")
|
|
1285
|
-
return this.indentate(
|
|
1299
|
+
return this.indentate(r) + "<" + e + i + "?" + this.tagEndChar;
|
|
1286
1300
|
{
|
|
1287
1301
|
let n = this.options.tagValueProcessor(e, t);
|
|
1288
|
-
return n = this.replaceEntitiesValue(n), n === "" ? this.indentate(
|
|
1302
|
+
return n = this.replaceEntitiesValue(n), n === "" ? this.indentate(r) + "<" + e + i + this.closeTag(e) + this.tagEndChar : this.indentate(r) + "<" + e + i + ">" + n + "</" + e + this.tagEndChar;
|
|
1289
1303
|
}
|
|
1290
1304
|
}, y.prototype.replaceEntitiesValue = function(t) {
|
|
1291
1305
|
if (t && t.length > 0 && this.options.processEntities)
|
|
@@ -1302,15 +1316,15 @@ function $e(t) {
|
|
|
1302
1316
|
return t.startsWith(this.options.attributeNamePrefix) && t !== this.options.textNodeName ? t.substr(this.attrPrefixLen) : !1;
|
|
1303
1317
|
}
|
|
1304
1318
|
var ke = y;
|
|
1305
|
-
const Le =
|
|
1306
|
-
var
|
|
1319
|
+
const Le = L, Re = Ae, je = ke;
|
|
1320
|
+
var H = { XMLParser: Re, XMLValidator: Le, XMLBuilder: je };
|
|
1307
1321
|
function Me(t) {
|
|
1308
1322
|
if (typeof t != "string")
|
|
1309
1323
|
throw new TypeError(`Expected a \`string\`, got \`${typeof t}\``);
|
|
1310
|
-
if (t = t.trim(), t.length === 0 ||
|
|
1324
|
+
if (t = t.trim(), t.length === 0 || H.XMLValidator.validate(t) !== !0)
|
|
1311
1325
|
return !1;
|
|
1312
1326
|
let e;
|
|
1313
|
-
const i = new
|
|
1327
|
+
const i = new H.XMLParser();
|
|
1314
1328
|
try {
|
|
1315
1329
|
e = i.parse(t);
|
|
1316
1330
|
} catch {
|
|
@@ -1409,23 +1423,23 @@ const Be = function(t) {
|
|
|
1409
1423
|
throw new Error("View defaultSortKey must be a string");
|
|
1410
1424
|
return !0;
|
|
1411
1425
|
}, di = function(t) {
|
|
1412
|
-
return
|
|
1426
|
+
return F().registerEntry(t);
|
|
1413
1427
|
}, ui = function(t) {
|
|
1414
|
-
return
|
|
1428
|
+
return F().unregisterEntry(t);
|
|
1415
1429
|
}, ci = function(t) {
|
|
1416
|
-
return
|
|
1430
|
+
return F().getEntries(t);
|
|
1417
1431
|
};
|
|
1418
1432
|
export {
|
|
1419
1433
|
_t as Column,
|
|
1420
|
-
|
|
1434
|
+
K as DefaultType,
|
|
1421
1435
|
xt as File,
|
|
1422
1436
|
Ye as FileAction,
|
|
1423
|
-
|
|
1437
|
+
k as FileType,
|
|
1424
1438
|
bt as Folder,
|
|
1425
1439
|
Qe as Header,
|
|
1426
1440
|
Nt as Navigation,
|
|
1427
|
-
|
|
1428
|
-
|
|
1441
|
+
Q as Node,
|
|
1442
|
+
J as NodeStatus,
|
|
1429
1443
|
v as Permission,
|
|
1430
1444
|
li as View,
|
|
1431
1445
|
di as addNewFileMenuEntry,
|
|
@@ -1434,14 +1448,14 @@ export {
|
|
|
1434
1448
|
vt as davGetFavoritesReport,
|
|
1435
1449
|
ri as davGetRecentSearch,
|
|
1436
1450
|
yt as davParsePermissions,
|
|
1437
|
-
|
|
1451
|
+
et as davRemoteURL,
|
|
1438
1452
|
Et as davResultToNode,
|
|
1439
|
-
|
|
1440
|
-
|
|
1441
|
-
|
|
1453
|
+
tt as davRootPath,
|
|
1454
|
+
Y as defaultDavNamespaces,
|
|
1455
|
+
W as defaultDavProperties,
|
|
1442
1456
|
We as formatFileSize,
|
|
1443
|
-
|
|
1444
|
-
|
|
1457
|
+
$ as getDavNameSpaces,
|
|
1458
|
+
V as getDavProperties,
|
|
1445
1459
|
oi as getFavoriteNodes,
|
|
1446
1460
|
Je as getFileActions,
|
|
1447
1461
|
ei as getFileListHeaders,
|