@nextcloud/files 3.0.0-beta.22 → 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/humanfilesize.d.ts +10 -1
- package/dist/index.cjs +15 -15
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +421 -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 +9 -9
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) {
|
|
@@ -111,7 +111,7 @@ class Ye {
|
|
|
111
111
|
throw new Error("Invalid execBatch function");
|
|
112
112
|
if ("order" in e && typeof e.order != "number")
|
|
113
113
|
throw new Error("Invalid order");
|
|
114
|
-
if (e.default && !Object.values(
|
|
114
|
+
if (e.default && !Object.values(K).includes(e.default))
|
|
115
115
|
throw new Error("Invalid default");
|
|
116
116
|
if ("inline" in e && typeof e.inline != "function")
|
|
117
117
|
throw new Error("Invalid inline function");
|
|
@@ -171,31 +171,31 @@ const ti = function(t) {
|
|
|
171
171
|
return typeof window._nc_filelistheader > "u" && (window._nc_filelistheader = [], m.debug("FileListHeaders initialized")), window._nc_filelistheader;
|
|
172
172
|
};
|
|
173
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 || {});
|
|
174
|
-
const
|
|
175
|
-
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 });
|
|
176
176
|
const i = { ...window._nc_dav_namespaces, ...e };
|
|
177
177
|
if (window._nc_dav_properties.find((n) => n === t))
|
|
178
178
|
return m.error(`${t} already registered`, { prop: t }), !1;
|
|
179
179
|
if (t.startsWith("<") || t.split(":").length !== 2)
|
|
180
180
|
return m.error(`${t} is not valid. See example: 'oc:fileid'`, { prop: t }), !1;
|
|
181
|
-
const
|
|
182
|
-
return i[
|
|
183
|
-
}, F = function() {
|
|
184
|
-
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);
|
|
185
183
|
}, V = function() {
|
|
186
|
-
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(" ");
|
|
187
187
|
}, ni = function() {
|
|
188
188
|
return `<?xml version="1.0"?>
|
|
189
|
-
<d:propfind ${
|
|
189
|
+
<d:propfind ${$()}>
|
|
190
190
|
<d:prop>
|
|
191
|
-
${
|
|
191
|
+
${V()}
|
|
192
192
|
</d:prop>
|
|
193
193
|
</d:propfind>`;
|
|
194
194
|
}, vt = function() {
|
|
195
195
|
return `<?xml version="1.0"?>
|
|
196
|
-
<oc:filter-files ${
|
|
196
|
+
<oc:filter-files ${$()}>
|
|
197
197
|
<d:prop>
|
|
198
|
-
${
|
|
198
|
+
${V()}
|
|
199
199
|
</d:prop>
|
|
200
200
|
<oc:filter-rules>
|
|
201
201
|
<oc:favorite>1</oc:favorite>
|
|
@@ -203,17 +203,17 @@ const K = ["d:getcontentlength", "d:getcontenttype", "d:getetag", "d:getlastmodi
|
|
|
203
203
|
</oc:filter-files>`;
|
|
204
204
|
}, ri = function(t) {
|
|
205
205
|
return `<?xml version="1.0" encoding="UTF-8"?>
|
|
206
|
-
<d:searchrequest ${
|
|
206
|
+
<d:searchrequest ${$()}
|
|
207
207
|
xmlns:ns="https://github.com/icewind1991/SearchDAV/ns">
|
|
208
208
|
<d:basicsearch>
|
|
209
209
|
<d:select>
|
|
210
210
|
<d:prop>
|
|
211
|
-
${
|
|
211
|
+
${V()}
|
|
212
212
|
</d:prop>
|
|
213
213
|
</d:select>
|
|
214
214
|
<d:from>
|
|
215
215
|
<d:scope>
|
|
216
|
-
<d:href>/files/${
|
|
216
|
+
<d:href>/files/${T()?.uid}/</d:href>
|
|
217
217
|
<d:depth>infinity</d:depth>
|
|
218
218
|
</d:scope>
|
|
219
219
|
</d:from>
|
|
@@ -261,10 +261,10 @@ const K = ["d:getcontentlength", "d:getcontenttype", "d:getetag", "d:getlastmodi
|
|
|
261
261
|
let e = v.NONE;
|
|
262
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;
|
|
263
263
|
};
|
|
264
|
-
var
|
|
265
|
-
const
|
|
264
|
+
var k = ((t) => (t.Folder = "folder", t.File = "file", t))(k || {});
|
|
265
|
+
const Z = function(t, e) {
|
|
266
266
|
return t.match(e) !== null;
|
|
267
|
-
},
|
|
267
|
+
}, B = (t, e) => {
|
|
268
268
|
if (t.id && typeof t.id != "number")
|
|
269
269
|
throw new Error("Invalid id type of value");
|
|
270
270
|
if (!t.source)
|
|
@@ -296,23 +296,23 @@ const Y = function(t, e) {
|
|
|
296
296
|
throw new Error("Root must start with a leading slash");
|
|
297
297
|
if (t.root && !t.source.includes(t.root))
|
|
298
298
|
throw new Error("Root must be part of the source");
|
|
299
|
-
if (t.root &&
|
|
299
|
+
if (t.root && Z(t.source, e)) {
|
|
300
300
|
const i = t.source.match(e)[0];
|
|
301
301
|
if (!t.source.includes(dt(i, t.root)))
|
|
302
302
|
throw new Error("The root must be relative to the service. e.g /files/emma");
|
|
303
303
|
}
|
|
304
|
-
if (t.status && !Object.values(
|
|
304
|
+
if (t.status && !Object.values(J).includes(t.status))
|
|
305
305
|
throw new Error("Status must be a valid NodeStatus");
|
|
306
306
|
};
|
|
307
|
-
var
|
|
308
|
-
class
|
|
307
|
+
var J = ((t) => (t.NEW = "new", t.FAILED = "failed", t.LOADING = "loading", t.LOCKED = "locked", t))(J || {});
|
|
308
|
+
class Q {
|
|
309
309
|
_data;
|
|
310
310
|
_attributes;
|
|
311
311
|
_knownDavService = /(remote|public)\.php\/(web)?dav/i;
|
|
312
312
|
constructor(e, i) {
|
|
313
|
-
|
|
314
|
-
const
|
|
315
|
-
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);
|
|
316
316
|
}
|
|
317
317
|
get source() {
|
|
318
318
|
return this._data.source.replace(/\/$/i, "");
|
|
@@ -326,10 +326,10 @@ class J {
|
|
|
326
326
|
get dirname() {
|
|
327
327
|
if (this.root) {
|
|
328
328
|
const i = this.source.indexOf(this.root);
|
|
329
|
-
return
|
|
329
|
+
return A(this.source.slice(i + this.root.length) || "/");
|
|
330
330
|
}
|
|
331
331
|
const e = new URL(this.source);
|
|
332
|
-
return
|
|
332
|
+
return A(e.pathname);
|
|
333
333
|
}
|
|
334
334
|
get mime() {
|
|
335
335
|
return this._data.mime;
|
|
@@ -353,10 +353,10 @@ class J {
|
|
|
353
353
|
return this.isDavRessource ? this._data.owner : null;
|
|
354
354
|
}
|
|
355
355
|
get isDavRessource() {
|
|
356
|
-
return
|
|
356
|
+
return Z(this.source, this._knownDavService);
|
|
357
357
|
}
|
|
358
358
|
get root() {
|
|
359
|
-
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;
|
|
360
360
|
}
|
|
361
361
|
get path() {
|
|
362
362
|
if (this.root) {
|
|
@@ -375,28 +375,28 @@ class J {
|
|
|
375
375
|
this._data.status = e;
|
|
376
376
|
}
|
|
377
377
|
move(e) {
|
|
378
|
-
|
|
378
|
+
B({ ...this._data, source: e }, this._knownDavService), this._data.source = e, this.updateMtime();
|
|
379
379
|
}
|
|
380
380
|
rename(e) {
|
|
381
381
|
if (e.includes("/"))
|
|
382
382
|
throw new Error("Invalid basename");
|
|
383
|
-
this.move(
|
|
383
|
+
this.move(A(this.source) + "/" + e);
|
|
384
384
|
}
|
|
385
385
|
updateMtime() {
|
|
386
386
|
this._data.mtime && (this._data.mtime = /* @__PURE__ */ new Date());
|
|
387
387
|
}
|
|
388
388
|
}
|
|
389
|
-
class xt extends
|
|
389
|
+
class xt extends Q {
|
|
390
390
|
get type() {
|
|
391
|
-
return
|
|
391
|
+
return k.File;
|
|
392
392
|
}
|
|
393
393
|
}
|
|
394
|
-
class bt extends
|
|
394
|
+
class bt extends Q {
|
|
395
395
|
constructor(e) {
|
|
396
396
|
super({ ...e, mime: "httpd/unix-directory" });
|
|
397
397
|
}
|
|
398
398
|
get type() {
|
|
399
|
-
return
|
|
399
|
+
return k.Folder;
|
|
400
400
|
}
|
|
401
401
|
get extension() {
|
|
402
402
|
return null;
|
|
@@ -405,12 +405,12 @@ class bt extends J {
|
|
|
405
405
|
return "httpd/unix-directory";
|
|
406
406
|
}
|
|
407
407
|
}
|
|
408
|
-
const
|
|
408
|
+
const tt = `/files/${T()?.uid}`, et = ht("dav"), si = function(t = et) {
|
|
409
409
|
const e = pt(t, { headers: { requesttoken: at() || "" } });
|
|
410
410
|
return ft().patch("request", (i) => (i.headers?.method && (i.method = i.headers.method, delete i.headers.method), gt(i))), e;
|
|
411
|
-
}, oi = async (t, e = "/", i =
|
|
412
|
-
const
|
|
413
|
-
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);
|
|
414
414
|
};
|
|
415
415
|
class Nt {
|
|
416
416
|
_views = [];
|
|
@@ -421,7 +421,7 @@ class Nt {
|
|
|
421
421
|
this._views.push(e);
|
|
422
422
|
}
|
|
423
423
|
remove(e) {
|
|
424
|
-
const i = this._views.findIndex((
|
|
424
|
+
const i = this._views.findIndex((r) => r.id === e);
|
|
425
425
|
i !== -1 && this._views.splice(i, 1);
|
|
426
426
|
}
|
|
427
427
|
get views() {
|
|
@@ -471,142 +471,142 @@ const At = function(t) {
|
|
|
471
471
|
throw new Error("Column summary must be a function");
|
|
472
472
|
return !0;
|
|
473
473
|
};
|
|
474
|
-
var
|
|
474
|
+
var L = {}, I = {};
|
|
475
475
|
(function(t) {
|
|
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",
|
|
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) {
|
|
477
477
|
const d = [];
|
|
478
|
-
let u =
|
|
478
|
+
let u = l.exec(o);
|
|
479
479
|
for (; u; ) {
|
|
480
|
-
const
|
|
481
|
-
|
|
482
|
-
const
|
|
483
|
-
for (let
|
|
484
|
-
|
|
485
|
-
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);
|
|
486
486
|
}
|
|
487
487
|
return d;
|
|
488
|
-
},
|
|
489
|
-
const
|
|
490
|
-
return !(
|
|
488
|
+
}, a = function(o) {
|
|
489
|
+
const l = n.exec(o);
|
|
490
|
+
return !(l === null || typeof l > "u");
|
|
491
491
|
};
|
|
492
492
|
t.isExist = function(o) {
|
|
493
493
|
return typeof o < "u";
|
|
494
494
|
}, t.isEmptyObject = function(o) {
|
|
495
495
|
return Object.keys(o).length === 0;
|
|
496
|
-
}, t.merge = function(o,
|
|
497
|
-
if (
|
|
498
|
-
const u = Object.keys(
|
|
499
|
-
for (let
|
|
500
|
-
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]];
|
|
501
501
|
}
|
|
502
502
|
}, t.getValue = function(o) {
|
|
503
503
|
return t.isExist(o) ? o : "";
|
|
504
|
-
}, t.isName =
|
|
505
|
-
})(
|
|
506
|
-
const
|
|
507
|
-
|
|
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) {
|
|
508
508
|
e = Object.assign({}, Tt, e);
|
|
509
509
|
const i = [];
|
|
510
|
-
let
|
|
510
|
+
let r = !1, n = !1;
|
|
511
511
|
t[0] === "\uFEFF" && (t = t.substr(1));
|
|
512
|
-
for (let
|
|
513
|
-
if (t[
|
|
514
|
-
if (
|
|
515
|
-
return
|
|
516
|
-
} else if (t[
|
|
517
|
-
let
|
|
518
|
-
if (
|
|
519
|
-
|
|
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);
|
|
520
520
|
continue;
|
|
521
521
|
} else {
|
|
522
522
|
let o = !1;
|
|
523
|
-
t[
|
|
524
|
-
let
|
|
525
|
-
for (;
|
|
526
|
-
` && t[
|
|
527
|
-
|
|
528
|
-
if (
|
|
529
|
-
let
|
|
530
|
-
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));
|
|
531
531
|
}
|
|
532
|
-
const d = Pt(t,
|
|
532
|
+
const d = Pt(t, s);
|
|
533
533
|
if (d === !1)
|
|
534
|
-
return
|
|
534
|
+
return f("InvalidAttr", "Attributes for '" + l + "' have open quote.", g(t, s));
|
|
535
535
|
let u = d.value;
|
|
536
|
-
if (
|
|
537
|
-
const
|
|
536
|
+
if (s = d.index, u[u.length - 1] === "/") {
|
|
537
|
+
const c = s - u.length;
|
|
538
538
|
u = u.substring(0, u.length - 1);
|
|
539
|
-
const
|
|
540
|
-
if (
|
|
541
|
-
|
|
539
|
+
const p = G(u, e);
|
|
540
|
+
if (p === !0)
|
|
541
|
+
r = !0;
|
|
542
542
|
else
|
|
543
|
-
return p
|
|
543
|
+
return f(p.err.code, p.err.msg, g(t, c + p.err.line));
|
|
544
544
|
} else if (o)
|
|
545
545
|
if (d.tagClosed) {
|
|
546
546
|
if (u.trim().length > 0)
|
|
547
|
-
return
|
|
547
|
+
return f("InvalidTag", "Closing tag '" + l + "' can't have attributes or invalid starting.", g(t, a));
|
|
548
548
|
{
|
|
549
|
-
const
|
|
550
|
-
if (
|
|
551
|
-
let
|
|
552
|
-
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));
|
|
553
553
|
}
|
|
554
554
|
i.length == 0 && (n = !0);
|
|
555
555
|
}
|
|
556
556
|
} else
|
|
557
|
-
return
|
|
557
|
+
return f("InvalidTag", "Closing tag '" + l + "' doesn't have proper closing.", g(t, s));
|
|
558
558
|
else {
|
|
559
|
-
const
|
|
560
|
-
if (
|
|
561
|
-
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));
|
|
562
562
|
if (n === !0)
|
|
563
|
-
return
|
|
564
|
-
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;
|
|
565
565
|
}
|
|
566
|
-
for (
|
|
567
|
-
if (t[
|
|
568
|
-
if (t[
|
|
569
|
-
|
|
566
|
+
for (s++; s < t.length; s++)
|
|
567
|
+
if (t[s] === "<")
|
|
568
|
+
if (t[s + 1] === "!") {
|
|
569
|
+
s++, s = z(t, s);
|
|
570
570
|
continue;
|
|
571
|
-
} else if (t[
|
|
572
|
-
if (
|
|
573
|
-
return
|
|
571
|
+
} else if (t[s + 1] === "?") {
|
|
572
|
+
if (s = U(t, ++s), s.err)
|
|
573
|
+
return s;
|
|
574
574
|
} else
|
|
575
575
|
break;
|
|
576
|
-
else if (t[
|
|
577
|
-
const
|
|
578
|
-
if (
|
|
579
|
-
return
|
|
580
|
-
|
|
581
|
-
} else if (n === !0 && !
|
|
582
|
-
return
|
|
583
|
-
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--;
|
|
584
584
|
}
|
|
585
585
|
} else {
|
|
586
|
-
if (
|
|
586
|
+
if (q(t[s]))
|
|
587
587
|
continue;
|
|
588
|
-
return
|
|
588
|
+
return f("InvalidChar", "char '" + t[s] + "' is not expected.", g(t, s));
|
|
589
589
|
}
|
|
590
|
-
if (
|
|
590
|
+
if (r) {
|
|
591
591
|
if (i.length == 1)
|
|
592
|
-
return
|
|
592
|
+
return f("InvalidTag", "Unclosed tag '" + i[0].tagName + "'.", g(t, i[0].tagStartPos));
|
|
593
593
|
if (i.length > 0)
|
|
594
|
-
return
|
|
594
|
+
return f("InvalidXml", "Invalid '" + JSON.stringify(i.map((s) => s.tagName), null, 4).replace(/\r?\n/g, "") + "' found.", { line: 1, col: 1 });
|
|
595
595
|
} else
|
|
596
|
-
return
|
|
596
|
+
return f("InvalidXml", "Start tag expected.", 1);
|
|
597
597
|
return !0;
|
|
598
598
|
};
|
|
599
|
-
function
|
|
599
|
+
function q(t) {
|
|
600
600
|
return t === " " || t === " " || t === `
|
|
601
601
|
` || t === "\r";
|
|
602
602
|
}
|
|
603
|
-
function
|
|
603
|
+
function U(t, e) {
|
|
604
604
|
const i = e;
|
|
605
605
|
for (; e < t.length; e++)
|
|
606
606
|
if (t[e] == "?" || t[e] == " ") {
|
|
607
|
-
const
|
|
608
|
-
if (e > 5 &&
|
|
609
|
-
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));
|
|
610
610
|
if (t[e] == "?" && t[e + 1] == ">") {
|
|
611
611
|
e++;
|
|
612
612
|
break;
|
|
@@ -615,7 +615,7 @@ function q(t, e) {
|
|
|
615
615
|
}
|
|
616
616
|
return e;
|
|
617
617
|
}
|
|
618
|
-
function
|
|
618
|
+
function z(t, e) {
|
|
619
619
|
if (t.length > e + 5 && t[e + 1] === "-" && t[e + 2] === "-") {
|
|
620
620
|
for (e += 3; e < t.length; e++)
|
|
621
621
|
if (t[e] === "-" && t[e + 1] === "-" && t[e + 2] === ">") {
|
|
@@ -640,35 +640,35 @@ function U(t, e) {
|
|
|
640
640
|
}
|
|
641
641
|
const It = '"', Ot = "'";
|
|
642
642
|
function Pt(t, e) {
|
|
643
|
-
let i = "",
|
|
643
|
+
let i = "", r = "", n = !1;
|
|
644
644
|
for (; e < t.length; e++) {
|
|
645
645
|
if (t[e] === It || t[e] === Ot)
|
|
646
|
-
|
|
647
|
-
else if (t[e] === ">" &&
|
|
646
|
+
r === "" ? r = t[e] : r !== t[e] || (r = "");
|
|
647
|
+
else if (t[e] === ">" && r === "") {
|
|
648
648
|
n = !0;
|
|
649
649
|
break;
|
|
650
650
|
}
|
|
651
651
|
i += t[e];
|
|
652
652
|
}
|
|
653
|
-
return
|
|
653
|
+
return r !== "" ? !1 : { value: i, index: e, tagClosed: n };
|
|
654
654
|
}
|
|
655
655
|
const Ct = new RegExp(`(\\s*)([^\\s=]+)(\\s*=)?(\\s*(['"])(([\\s\\S])*?)\\5)?`, "g");
|
|
656
|
-
function
|
|
657
|
-
const i =
|
|
656
|
+
function G(t, e) {
|
|
657
|
+
const i = R.getAllMatches(t, Ct), r = {};
|
|
658
658
|
for (let n = 0; n < i.length; n++) {
|
|
659
659
|
if (i[n][1].length === 0)
|
|
660
|
-
return
|
|
660
|
+
return f("InvalidAttr", "Attribute '" + i[n][2] + "' has no space in starting.", E(i[n]));
|
|
661
661
|
if (i[n][3] !== void 0 && i[n][4] === void 0)
|
|
662
|
-
return
|
|
662
|
+
return f("InvalidAttr", "Attribute '" + i[n][2] + "' is without value.", E(i[n]));
|
|
663
663
|
if (i[n][3] === void 0 && !e.allowBooleanAttributes)
|
|
664
|
-
return
|
|
665
|
-
const
|
|
666
|
-
if (!Ft(
|
|
667
|
-
return
|
|
668
|
-
if (!
|
|
669
|
-
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;
|
|
670
670
|
else
|
|
671
|
-
return
|
|
671
|
+
return f("InvalidAttr", "Attribute '" + s + "' is repeated.", E(i[n]));
|
|
672
672
|
}
|
|
673
673
|
return !0;
|
|
674
674
|
}
|
|
@@ -696,33 +696,33 @@ function St(t, e) {
|
|
|
696
696
|
}
|
|
697
697
|
return e;
|
|
698
698
|
}
|
|
699
|
-
function
|
|
699
|
+
function f(t, e, i) {
|
|
700
700
|
return { err: { code: t, msg: e, line: i.line || i, col: i.col } };
|
|
701
701
|
}
|
|
702
702
|
function Ft(t) {
|
|
703
|
-
return
|
|
703
|
+
return R.isName(t);
|
|
704
704
|
}
|
|
705
705
|
function Vt(t) {
|
|
706
|
-
return
|
|
706
|
+
return R.isName(t);
|
|
707
707
|
}
|
|
708
708
|
function g(t, e) {
|
|
709
709
|
const i = t.substring(0, e).split(/\r?\n/);
|
|
710
710
|
return { line: i.length, col: i[i.length - 1].length + 1 };
|
|
711
711
|
}
|
|
712
|
-
function
|
|
712
|
+
function E(t) {
|
|
713
713
|
return t.startIndex + t[1].length;
|
|
714
714
|
}
|
|
715
|
-
var
|
|
716
|
-
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) {
|
|
717
717
|
return e;
|
|
718
718
|
}, attributeValueProcessor: function(t, e) {
|
|
719
719
|
return e;
|
|
720
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) {
|
|
721
721
|
return t;
|
|
722
722
|
} }, $t = function(t) {
|
|
723
|
-
return Object.assign({},
|
|
723
|
+
return Object.assign({}, it, t);
|
|
724
724
|
};
|
|
725
|
-
|
|
725
|
+
C.buildOptions = $t, C.defaultOptions = it;
|
|
726
726
|
class kt {
|
|
727
727
|
constructor(e) {
|
|
728
728
|
this.tagname = e, this.child = [], this[":@"] = {};
|
|
@@ -735,14 +735,14 @@ class kt {
|
|
|
735
735
|
}
|
|
736
736
|
}
|
|
737
737
|
var Lt = kt;
|
|
738
|
-
const Rt =
|
|
738
|
+
const Rt = I;
|
|
739
739
|
function jt(t, e) {
|
|
740
740
|
const i = {};
|
|
741
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") {
|
|
742
742
|
e = e + 9;
|
|
743
|
-
let
|
|
743
|
+
let r = 1, n = !1, s = !1, a = "";
|
|
744
744
|
for (; e < t.length; e++)
|
|
745
|
-
if (t[e] === "<" && !
|
|
745
|
+
if (t[e] === "<" && !s) {
|
|
746
746
|
if (n && qt(t, e))
|
|
747
747
|
e += 7, [entityName, val, e] = Mt(t, e + 1), val.indexOf("&") === -1 && (i[Xt(entityName)] = { regx: RegExp(`&${entityName};`, "g"), val });
|
|
748
748
|
else if (n && Ut(t, e))
|
|
@@ -752,16 +752,16 @@ function jt(t, e) {
|
|
|
752
752
|
else if (n && Gt(t, e))
|
|
753
753
|
e += 9;
|
|
754
754
|
else if (Bt)
|
|
755
|
-
|
|
755
|
+
s = !0;
|
|
756
756
|
else
|
|
757
757
|
throw new Error("Invalid DOCTYPE");
|
|
758
|
-
|
|
758
|
+
r++, a = "";
|
|
759
759
|
} else if (t[e] === ">") {
|
|
760
|
-
if (
|
|
760
|
+
if (s ? t[e - 1] === "-" && t[e - 2] === "-" && (s = !1, r--) : r--, r === 0)
|
|
761
761
|
break;
|
|
762
762
|
} else
|
|
763
|
-
t[e] === "[" ? n = !0 :
|
|
764
|
-
if (
|
|
763
|
+
t[e] === "[" ? n = !0 : a += t[e];
|
|
764
|
+
if (r !== 0)
|
|
765
765
|
throw new Error("Unclosed DOCTYPE");
|
|
766
766
|
} else
|
|
767
767
|
throw new Error("Invalid Tag instead of DOCTYPE");
|
|
@@ -773,9 +773,9 @@ function Mt(t, e) {
|
|
|
773
773
|
i += t[e];
|
|
774
774
|
if (i = i.trim(), i.indexOf(" ") !== -1)
|
|
775
775
|
throw new Error("External entites are not supported");
|
|
776
|
-
const
|
|
776
|
+
const r = t[e++];
|
|
777
777
|
let n = "";
|
|
778
|
-
for (; e < t.length && t[e] !==
|
|
778
|
+
for (; e < t.length && t[e] !== r; e++)
|
|
779
779
|
n += t[e];
|
|
780
780
|
return [i, n, e];
|
|
781
781
|
}
|
|
@@ -812,16 +812,16 @@ function Zt(t, e = {}) {
|
|
|
812
812
|
if (e.hex && Kt.test(i))
|
|
813
813
|
return Number.parseInt(i, 16);
|
|
814
814
|
{
|
|
815
|
-
const
|
|
816
|
-
if (
|
|
817
|
-
const n =
|
|
818
|
-
let
|
|
819
|
-
const o =
|
|
820
|
-
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] !== ".")
|
|
821
821
|
return t;
|
|
822
822
|
{
|
|
823
|
-
const
|
|
824
|
-
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;
|
|
825
825
|
}
|
|
826
826
|
} else
|
|
827
827
|
return t;
|
|
@@ -831,8 +831,8 @@ function Jt(t) {
|
|
|
831
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;
|
|
832
832
|
}
|
|
833
833
|
var Qt = Zt;
|
|
834
|
-
const
|
|
835
|
-
"<((!\\[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);
|
|
836
836
|
let ie = class {
|
|
837
837
|
constructor(t) {
|
|
838
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;
|
|
@@ -841,15 +841,15 @@ let ie = class {
|
|
|
841
841
|
function ne(t) {
|
|
842
842
|
const e = Object.keys(t);
|
|
843
843
|
for (let i = 0; i < e.length; i++) {
|
|
844
|
-
const
|
|
845
|
-
this.lastEntities[
|
|
844
|
+
const r = e[i];
|
|
845
|
+
this.lastEntities[r] = { regex: new RegExp("&" + r + ";", "g"), val: t[r] };
|
|
846
846
|
}
|
|
847
847
|
}
|
|
848
|
-
function re(t, e, i,
|
|
849
|
-
if (t !== void 0 && (this.options.trimValues && !
|
|
850
|
-
|
|
851
|
-
const o = this.options.tagValueProcessor(e, t, i, n,
|
|
852
|
-
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;
|
|
853
853
|
}
|
|
854
854
|
}
|
|
855
855
|
function se(t) {
|
|
@@ -864,112 +864,114 @@ function se(t) {
|
|
|
864
864
|
const oe = new RegExp(`([^\\s=]+)\\s*(=\\s*(['"])([\\s\\S]*?)\\3)?`, "gm");
|
|
865
865
|
function ae(t, e, i) {
|
|
866
866
|
if (!this.options.ignoreAttributes && typeof t == "string") {
|
|
867
|
-
const
|
|
868
|
-
for (let
|
|
869
|
-
const o = this.resolveNameSpace(
|
|
870
|
-
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;
|
|
871
871
|
if (o.length)
|
|
872
|
-
if (this.options.transformAttributeName && (d = this.options.transformAttributeName(d)), d === "__proto__" && (d = "#__proto__"),
|
|
873
|
-
this.options.trimValues && (
|
|
874
|
-
const u = this.options.attributeValueProcessor(o,
|
|
875
|
-
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);
|
|
876
876
|
} else
|
|
877
|
-
this.options.allowBooleanAttributes && (
|
|
877
|
+
this.options.allowBooleanAttributes && (s[d] = !0);
|
|
878
878
|
}
|
|
879
|
-
if (!Object.keys(
|
|
879
|
+
if (!Object.keys(s).length)
|
|
880
880
|
return;
|
|
881
881
|
if (this.options.attributesGroupName) {
|
|
882
|
-
const
|
|
883
|
-
return
|
|
882
|
+
const a = {};
|
|
883
|
+
return a[this.options.attributesGroupName] = s, a;
|
|
884
884
|
}
|
|
885
|
-
return
|
|
885
|
+
return s;
|
|
886
886
|
}
|
|
887
887
|
}
|
|
888
888
|
const le = function(t) {
|
|
889
889
|
t = t.replace(/\r\n?/g, `
|
|
890
890
|
`);
|
|
891
|
-
const e = new
|
|
892
|
-
let i = e,
|
|
893
|
-
for (let
|
|
894
|
-
if (t[
|
|
895
|
-
if (t[
|
|
896
|
-
const
|
|
897
|
-
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();
|
|
898
898
|
if (this.options.removeNSPrefix) {
|
|
899
899
|
const u = o.indexOf(":");
|
|
900
900
|
u !== -1 && (o = o.substr(u + 1));
|
|
901
901
|
}
|
|
902
|
-
this.options.transformTagName && (o = this.options.transformTagName(o)), i && (
|
|
903
|
-
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);
|
|
904
904
|
if (o && this.options.unpairedTags.indexOf(o) !== -1)
|
|
905
905
|
throw new Error(`Unpaired tag can not be used as closing tag: </${o}>`);
|
|
906
906
|
let d = 0;
|
|
907
|
-
|
|
908
|
-
} else if (t[
|
|
909
|
-
let
|
|
910
|
-
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)
|
|
911
911
|
throw new Error("Pi Tag is not closed.");
|
|
912
|
-
if (
|
|
913
|
-
const o = new
|
|
914
|
-
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);
|
|
915
915
|
}
|
|
916
|
-
|
|
917
|
-
} else if (t.substr(
|
|
918
|
-
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.");
|
|
919
919
|
if (this.options.commentPropName) {
|
|
920
|
-
const o = t.substring(
|
|
921
|
-
|
|
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 }]);
|
|
922
922
|
}
|
|
923
|
-
|
|
924
|
-
} else if (t.substr(
|
|
925
|
-
const
|
|
926
|
-
this.docTypeEntities =
|
|
927
|
-
} else if (t.substr(
|
|
928
|
-
const
|
|
929
|
-
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)
|
|
930
930
|
i.add(this.options.cdataPropName, [{ [this.options.textNodeName]: o }]);
|
|
931
931
|
else {
|
|
932
|
-
let
|
|
933
|
-
|
|
932
|
+
let l = this.parseTextData(o, i.tagname, n, !0, !1, !0);
|
|
933
|
+
l == null && (l = ""), i.add(this.options.textNodeName, l);
|
|
934
934
|
}
|
|
935
|
-
|
|
935
|
+
s = a + 2;
|
|
936
936
|
} else {
|
|
937
|
-
let
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
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;
|
|
944
946
|
else if (this.options.unpairedTags.indexOf(o) !== -1)
|
|
945
|
-
|
|
947
|
+
s = a.closeIndex;
|
|
946
948
|
else {
|
|
947
|
-
const
|
|
948
|
-
if (!
|
|
949
|
-
throw new Error(`Unexpected end of ${
|
|
950
|
-
|
|
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;
|
|
951
953
|
}
|
|
952
|
-
const
|
|
953
|
-
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);
|
|
954
956
|
} else {
|
|
955
|
-
if (
|
|
956
|
-
o[o.length - 1] === "/" ? (o = o.substr(0, o.length - 1), n = n.substr(0, n.length - 1),
|
|
957
|
-
const
|
|
958
|
-
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("."));
|
|
959
961
|
} else {
|
|
960
|
-
const
|
|
961
|
-
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;
|
|
962
964
|
}
|
|
963
|
-
|
|
965
|
+
r = "", s = c;
|
|
964
966
|
}
|
|
965
967
|
}
|
|
966
968
|
else
|
|
967
|
-
|
|
969
|
+
r += t[s];
|
|
968
970
|
return e.child;
|
|
969
971
|
};
|
|
970
972
|
function de(t, e, i) {
|
|
971
|
-
const
|
|
972
|
-
|
|
973
|
+
const r = this.options.updateTag(e.tagname, i, e[":@"]);
|
|
974
|
+
r === !1 || (typeof r == "string" && (e.tagname = r), t.addChild(e));
|
|
973
975
|
}
|
|
974
976
|
const ue = function(t) {
|
|
975
977
|
if (this.options.processEntities) {
|
|
@@ -990,66 +992,68 @@ const ue = function(t) {
|
|
|
990
992
|
}
|
|
991
993
|
return t;
|
|
992
994
|
};
|
|
993
|
-
function ce(t, e, i,
|
|
994
|
-
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;
|
|
995
997
|
}
|
|
996
998
|
function he(t, e, i) {
|
|
997
|
-
const
|
|
999
|
+
const r = "*." + i;
|
|
998
1000
|
for (const n in t) {
|
|
999
|
-
const
|
|
1000
|
-
if (
|
|
1001
|
+
const s = t[n];
|
|
1002
|
+
if (r === s || e === s)
|
|
1001
1003
|
return !0;
|
|
1002
1004
|
}
|
|
1003
1005
|
return !1;
|
|
1004
1006
|
}
|
|
1005
1007
|
function pe(t, e, i = ">") {
|
|
1006
|
-
let
|
|
1007
|
-
for (let
|
|
1008
|
-
let
|
|
1009
|
-
if (
|
|
1010
|
-
|
|
1011
|
-
else if (
|
|
1012
|
-
|
|
1013
|
-
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])
|
|
1014
1016
|
if (i[1]) {
|
|
1015
|
-
if (t[
|
|
1016
|
-
return { data: n, index:
|
|
1017
|
+
if (t[s + 1] === i[1])
|
|
1018
|
+
return { data: n, index: s };
|
|
1017
1019
|
} else
|
|
1018
|
-
return { data: n, index:
|
|
1020
|
+
return { data: n, index: s };
|
|
1019
1021
|
else
|
|
1020
|
-
|
|
1021
|
-
n +=
|
|
1022
|
+
a === " " && (a = " ");
|
|
1023
|
+
n += a;
|
|
1022
1024
|
}
|
|
1023
1025
|
}
|
|
1024
|
-
function x(t, e, i,
|
|
1026
|
+
function x(t, e, i, r) {
|
|
1025
1027
|
const n = t.indexOf(e, i);
|
|
1026
1028
|
if (n === -1)
|
|
1027
|
-
throw new Error(
|
|
1029
|
+
throw new Error(r);
|
|
1028
1030
|
return n + e.length - 1;
|
|
1029
1031
|
}
|
|
1030
|
-
function
|
|
1031
|
-
const n = pe(t, e + 1,
|
|
1032
|
+
function D(t, e, i, r = ">") {
|
|
1033
|
+
const n = pe(t, e + 1, r);
|
|
1032
1034
|
if (!n)
|
|
1033
1035
|
return;
|
|
1034
|
-
let
|
|
1035
|
-
const
|
|
1036
|
-
let
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
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 };
|
|
1042
1046
|
}
|
|
1043
1047
|
function fe(t, e, i) {
|
|
1044
|
-
const
|
|
1048
|
+
const r = i;
|
|
1045
1049
|
let n = 1;
|
|
1046
1050
|
for (; i < t.length; i++)
|
|
1047
1051
|
if (t[i] === "<")
|
|
1048
1052
|
if (t[i + 1] === "/") {
|
|
1049
|
-
const
|
|
1050
|
-
if (t.substring(i + 2,
|
|
1051
|
-
return { tagContent: t.substring(
|
|
1052
|
-
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;
|
|
1053
1057
|
} else if (t[i + 1] === "?")
|
|
1054
1058
|
i = x(t, "?>", i + 1, "StopNode is not closed.");
|
|
1055
1059
|
else if (t.substr(i + 1, 3) === "!--")
|
|
@@ -1057,64 +1061,64 @@ function fe(t, e, i) {
|
|
|
1057
1061
|
else if (t.substr(i + 1, 2) === "![")
|
|
1058
1062
|
i = x(t, "]]>", i, "StopNode is not closed.") - 2;
|
|
1059
1063
|
else {
|
|
1060
|
-
const
|
|
1061
|
-
|
|
1064
|
+
const s = D(t, i, ">");
|
|
1065
|
+
s && ((s && s.tagName) === e && s.tagExp[s.tagExp.length - 1] !== "/" && n++, i = s.closeIndex);
|
|
1062
1066
|
}
|
|
1063
1067
|
}
|
|
1064
|
-
function
|
|
1068
|
+
function S(t, e, i) {
|
|
1065
1069
|
if (e && typeof t == "string") {
|
|
1066
|
-
const
|
|
1067
|
-
return
|
|
1070
|
+
const r = t.trim();
|
|
1071
|
+
return r === "true" ? !0 : r === "false" ? !1 : ee(t, i);
|
|
1068
1072
|
} else
|
|
1069
|
-
return
|
|
1073
|
+
return j.isExist(t) ? t : "";
|
|
1070
1074
|
}
|
|
1071
|
-
var ge = ie,
|
|
1075
|
+
var ge = ie, nt = {};
|
|
1072
1076
|
function me(t, e) {
|
|
1073
|
-
return
|
|
1077
|
+
return rt(t, e);
|
|
1074
1078
|
}
|
|
1075
|
-
function
|
|
1076
|
-
let
|
|
1079
|
+
function rt(t, e, i) {
|
|
1080
|
+
let r;
|
|
1077
1081
|
const n = {};
|
|
1078
|
-
for (let
|
|
1079
|
-
const
|
|
1080
|
-
let
|
|
1081
|
-
if (i === void 0 ?
|
|
1082
|
-
|
|
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];
|
|
1083
1087
|
else {
|
|
1084
1088
|
if (o === void 0)
|
|
1085
1089
|
continue;
|
|
1086
|
-
if (
|
|
1087
|
-
let d =
|
|
1090
|
+
if (a[o]) {
|
|
1091
|
+
let d = rt(a[o], e, l);
|
|
1088
1092
|
const u = ye(d, e);
|
|
1089
|
-
|
|
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;
|
|
1090
1094
|
}
|
|
1091
1095
|
}
|
|
1092
1096
|
}
|
|
1093
|
-
return typeof
|
|
1097
|
+
return typeof r == "string" ? r.length > 0 && (n[e.textNodeName] = r) : r !== void 0 && (n[e.textNodeName] = r), n;
|
|
1094
1098
|
}
|
|
1095
1099
|
function we(t) {
|
|
1096
1100
|
const e = Object.keys(t);
|
|
1097
1101
|
for (let i = 0; i < e.length; i++) {
|
|
1098
|
-
const
|
|
1099
|
-
if (
|
|
1100
|
-
return
|
|
1102
|
+
const r = e[i];
|
|
1103
|
+
if (r !== ":@")
|
|
1104
|
+
return r;
|
|
1101
1105
|
}
|
|
1102
1106
|
}
|
|
1103
|
-
function ve(t, e, i,
|
|
1107
|
+
function ve(t, e, i, r) {
|
|
1104
1108
|
if (e) {
|
|
1105
|
-
const n = Object.keys(e),
|
|
1106
|
-
for (let
|
|
1107
|
-
const o = n[
|
|
1108
|
-
|
|
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];
|
|
1109
1113
|
}
|
|
1110
1114
|
}
|
|
1111
1115
|
}
|
|
1112
1116
|
function ye(t, e) {
|
|
1113
|
-
const { textNodeName: i } = e,
|
|
1114
|
-
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));
|
|
1115
1119
|
}
|
|
1116
|
-
|
|
1117
|
-
const { buildOptions: xe } =
|
|
1120
|
+
nt.prettify = me;
|
|
1121
|
+
const { buildOptions: xe } = C, be = ge, { prettify: Ee } = nt, Ne = L;
|
|
1118
1122
|
let _e = class {
|
|
1119
1123
|
constructor(t) {
|
|
1120
1124
|
this.externalEntities = {}, this.options = xe(t);
|
|
@@ -1133,8 +1137,8 @@ let _e = class {
|
|
|
1133
1137
|
}
|
|
1134
1138
|
const i = new be(this.options);
|
|
1135
1139
|
i.addExternalEntities(this.externalEntities);
|
|
1136
|
-
const
|
|
1137
|
-
return this.options.preserveOrder ||
|
|
1140
|
+
const r = i.parseXml(t);
|
|
1141
|
+
return this.options.preserveOrder || r === void 0 ? r : Ee(r, this.options);
|
|
1138
1142
|
}
|
|
1139
1143
|
addEntity(t, e) {
|
|
1140
1144
|
if (e.indexOf("&") !== -1)
|
|
@@ -1151,66 +1155,70 @@ const Te = `
|
|
|
1151
1155
|
`;
|
|
1152
1156
|
function Ie(t, e) {
|
|
1153
1157
|
let i = "";
|
|
1154
|
-
return e.format && e.indentBy.length > 0 && (i = Te),
|
|
1158
|
+
return e.format && e.indentBy.length > 0 && (i = Te), st(t, e, "", i);
|
|
1155
1159
|
}
|
|
1156
|
-
function
|
|
1157
|
-
let n = "",
|
|
1158
|
-
for (let
|
|
1159
|
-
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;
|
|
1160
1166
|
let d = "";
|
|
1161
|
-
if (i.length === 0 ? d =
|
|
1162
|
-
let w = o[
|
|
1163
|
-
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;
|
|
1164
1170
|
continue;
|
|
1165
|
-
} else if (
|
|
1166
|
-
|
|
1171
|
+
} else if (l === e.cdataPropName) {
|
|
1172
|
+
s && (n += r), n += `<![CDATA[${o[l][0][e.textNodeName]}]]>`, s = !1;
|
|
1167
1173
|
continue;
|
|
1168
|
-
} else if (
|
|
1169
|
-
n +=
|
|
1174
|
+
} else if (l === e.commentPropName) {
|
|
1175
|
+
n += r + `<!--${o[l][0][e.textNodeName]}-->`, s = !0;
|
|
1170
1176
|
continue;
|
|
1171
|
-
} else if (
|
|
1172
|
-
const w =
|
|
1173
|
-
let
|
|
1174
|
-
|
|
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;
|
|
1175
1181
|
continue;
|
|
1176
1182
|
}
|
|
1177
|
-
let u =
|
|
1183
|
+
let u = r;
|
|
1178
1184
|
u !== "" && (u += e.indentBy);
|
|
1179
|
-
const
|
|
1180
|
-
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;
|
|
1181
1187
|
}
|
|
1182
1188
|
return n;
|
|
1183
1189
|
}
|
|
1184
1190
|
function Oe(t) {
|
|
1185
1191
|
const e = Object.keys(t);
|
|
1186
1192
|
for (let i = 0; i < e.length; i++) {
|
|
1187
|
-
const
|
|
1188
|
-
if (
|
|
1189
|
-
return
|
|
1193
|
+
const r = e[i];
|
|
1194
|
+
if (t.hasOwnProperty(r) && r !== ":@")
|
|
1195
|
+
return r;
|
|
1190
1196
|
}
|
|
1191
1197
|
}
|
|
1192
|
-
function
|
|
1198
|
+
function X(t, e) {
|
|
1193
1199
|
let i = "";
|
|
1194
1200
|
if (t && !e.ignoreAttributes)
|
|
1195
|
-
for (let
|
|
1196
|
-
|
|
1197
|
-
|
|
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}"`;
|
|
1198
1206
|
}
|
|
1199
1207
|
return i;
|
|
1200
1208
|
}
|
|
1201
1209
|
function Pe(t, e) {
|
|
1202
1210
|
t = t.substr(0, t.length - e.textNodeName.length - 1);
|
|
1203
1211
|
let i = t.substr(t.lastIndexOf(".") + 1);
|
|
1204
|
-
for (let
|
|
1205
|
-
if (e.stopNodes[
|
|
1212
|
+
for (let r in e.stopNodes)
|
|
1213
|
+
if (e.stopNodes[r] === t || e.stopNodes[r] === "*." + i)
|
|
1206
1214
|
return !0;
|
|
1207
1215
|
return !1;
|
|
1208
1216
|
}
|
|
1209
|
-
function
|
|
1217
|
+
function ot(t, e) {
|
|
1210
1218
|
if (t && t.length > 0 && e.processEntities)
|
|
1211
1219
|
for (let i = 0; i < e.entities.length; i++) {
|
|
1212
|
-
const
|
|
1213
|
-
t = t.replace(
|
|
1220
|
+
const r = e.entities[i];
|
|
1221
|
+
t = t.replace(r.regex, r.val);
|
|
1214
1222
|
}
|
|
1215
1223
|
return t;
|
|
1216
1224
|
}
|
|
@@ -1232,65 +1240,66 @@ function y(t) {
|
|
|
1232
1240
|
y.prototype.build = function(t) {
|
|
1233
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);
|
|
1234
1242
|
}, y.prototype.j2x = function(t, e) {
|
|
1235
|
-
let i = "",
|
|
1243
|
+
let i = "", r = "";
|
|
1236
1244
|
for (let n in t)
|
|
1237
|
-
if (
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
|
|
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]]);
|
|
1250
1273
|
} else
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
const r = t[n].length;
|
|
1254
|
-
let l = "";
|
|
1255
|
-
for (let o = 0; o < r; o++) {
|
|
1256
|
-
const a = t[n][o];
|
|
1257
|
-
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));
|
|
1258
|
-
}
|
|
1259
|
-
this.options.oneListGroup && (l = this.buildObjectNode(l, n, "", e)), s += l;
|
|
1260
|
-
} else if (this.options.attributesGroupName && n === this.options.attributesGroupName) {
|
|
1261
|
-
const r = Object.keys(t[n]), l = r.length;
|
|
1262
|
-
for (let o = 0; o < l; o++)
|
|
1263
|
-
i += this.buildAttrPairStr(r[o], "" + t[n][r[o]]);
|
|
1264
|
-
} else
|
|
1265
|
-
s += this.processTextOrObjNode(t[n], n, e);
|
|
1266
|
-
return { attrStr: i, val: s };
|
|
1274
|
+
r += this.processTextOrObjNode(t[n], n, e);
|
|
1275
|
+
return { attrStr: i, val: r };
|
|
1267
1276
|
}, y.prototype.buildAttrPairStr = function(t, e) {
|
|
1268
1277
|
return e = this.options.attributeValueProcessor(t, "" + e), e = this.replaceEntitiesValue(e), this.options.suppressBooleanAttributes && e === "true" ? " " + t : " " + t + '="' + e + '"';
|
|
1269
1278
|
};
|
|
1270
1279
|
function Fe(t, e, i) {
|
|
1271
|
-
const
|
|
1272
|
-
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);
|
|
1273
1282
|
}
|
|
1274
|
-
y.prototype.buildObjectNode = function(t, e, i,
|
|
1283
|
+
y.prototype.buildObjectNode = function(t, e, i, r) {
|
|
1275
1284
|
if (t === "")
|
|
1276
|
-
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;
|
|
1277
1286
|
{
|
|
1278
|
-
let n = "</" + e + this.tagEndChar,
|
|
1279
|
-
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;
|
|
1280
1289
|
}
|
|
1281
1290
|
}, y.prototype.closeTag = function(t) {
|
|
1282
1291
|
let e = "";
|
|
1283
1292
|
return this.options.unpairedTags.indexOf(t) !== -1 ? this.options.suppressUnpairedNode || (e = "/") : this.options.suppressEmptyNode ? e = "/" : e = `></${t}`, e;
|
|
1284
|
-
}, y.prototype.buildTextValNode = function(t, e, i,
|
|
1293
|
+
}, y.prototype.buildTextValNode = function(t, e, i, r) {
|
|
1285
1294
|
if (this.options.cdataPropName !== !1 && e === this.options.cdataPropName)
|
|
1286
|
-
return this.indentate(
|
|
1295
|
+
return this.indentate(r) + `<![CDATA[${t}]]>` + this.newLine;
|
|
1287
1296
|
if (this.options.commentPropName !== !1 && e === this.options.commentPropName)
|
|
1288
|
-
return this.indentate(
|
|
1297
|
+
return this.indentate(r) + `<!--${t}-->` + this.newLine;
|
|
1289
1298
|
if (e[0] === "?")
|
|
1290
|
-
return this.indentate(
|
|
1299
|
+
return this.indentate(r) + "<" + e + i + "?" + this.tagEndChar;
|
|
1291
1300
|
{
|
|
1292
1301
|
let n = this.options.tagValueProcessor(e, t);
|
|
1293
|
-
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;
|
|
1294
1303
|
}
|
|
1295
1304
|
}, y.prototype.replaceEntitiesValue = function(t) {
|
|
1296
1305
|
if (t && t.length > 0 && this.options.processEntities)
|
|
@@ -1307,15 +1316,15 @@ function $e(t) {
|
|
|
1307
1316
|
return t.startsWith(this.options.attributeNamePrefix) && t !== this.options.textNodeName ? t.substr(this.attrPrefixLen) : !1;
|
|
1308
1317
|
}
|
|
1309
1318
|
var ke = y;
|
|
1310
|
-
const Le =
|
|
1311
|
-
var
|
|
1319
|
+
const Le = L, Re = Ae, je = ke;
|
|
1320
|
+
var H = { XMLParser: Re, XMLValidator: Le, XMLBuilder: je };
|
|
1312
1321
|
function Me(t) {
|
|
1313
1322
|
if (typeof t != "string")
|
|
1314
1323
|
throw new TypeError(`Expected a \`string\`, got \`${typeof t}\``);
|
|
1315
|
-
if (t = t.trim(), t.length === 0 ||
|
|
1324
|
+
if (t = t.trim(), t.length === 0 || H.XMLValidator.validate(t) !== !0)
|
|
1316
1325
|
return !1;
|
|
1317
1326
|
let e;
|
|
1318
|
-
const i = new
|
|
1327
|
+
const i = new H.XMLParser();
|
|
1319
1328
|
try {
|
|
1320
1329
|
e = i.parse(t);
|
|
1321
1330
|
} catch {
|
|
@@ -1414,23 +1423,23 @@ const Be = function(t) {
|
|
|
1414
1423
|
throw new Error("View defaultSortKey must be a string");
|
|
1415
1424
|
return !0;
|
|
1416
1425
|
}, di = function(t) {
|
|
1417
|
-
return
|
|
1426
|
+
return F().registerEntry(t);
|
|
1418
1427
|
}, ui = function(t) {
|
|
1419
|
-
return
|
|
1428
|
+
return F().unregisterEntry(t);
|
|
1420
1429
|
}, ci = function(t) {
|
|
1421
|
-
return
|
|
1430
|
+
return F().getEntries(t);
|
|
1422
1431
|
};
|
|
1423
1432
|
export {
|
|
1424
1433
|
_t as Column,
|
|
1425
|
-
|
|
1434
|
+
K as DefaultType,
|
|
1426
1435
|
xt as File,
|
|
1427
1436
|
Ye as FileAction,
|
|
1428
|
-
|
|
1437
|
+
k as FileType,
|
|
1429
1438
|
bt as Folder,
|
|
1430
1439
|
Qe as Header,
|
|
1431
1440
|
Nt as Navigation,
|
|
1432
|
-
|
|
1433
|
-
|
|
1441
|
+
Q as Node,
|
|
1442
|
+
J as NodeStatus,
|
|
1434
1443
|
v as Permission,
|
|
1435
1444
|
li as View,
|
|
1436
1445
|
di as addNewFileMenuEntry,
|
|
@@ -1439,14 +1448,14 @@ export {
|
|
|
1439
1448
|
vt as davGetFavoritesReport,
|
|
1440
1449
|
ri as davGetRecentSearch,
|
|
1441
1450
|
yt as davParsePermissions,
|
|
1442
|
-
|
|
1451
|
+
et as davRemoteURL,
|
|
1443
1452
|
Et as davResultToNode,
|
|
1444
|
-
|
|
1445
|
-
|
|
1446
|
-
|
|
1453
|
+
tt as davRootPath,
|
|
1454
|
+
Y as defaultDavNamespaces,
|
|
1455
|
+
W as defaultDavProperties,
|
|
1447
1456
|
We as formatFileSize,
|
|
1448
|
-
|
|
1449
|
-
|
|
1457
|
+
$ as getDavNameSpaces,
|
|
1458
|
+
V as getDavProperties,
|
|
1450
1459
|
oi as getFavoriteNodes,
|
|
1451
1460
|
Je as getFileActions,
|
|
1452
1461
|
ei as getFileListHeaders,
|