@nextcloud/files 3.3.1 → 3.4.0
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/files/node.d.ts +3 -2
- package/dist/index.cjs +182 -84
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +4 -2
- package/dist/index.mjs +183 -85
- package/dist/index.mjs.map +1 -1
- package/dist/utils/fileSorting.d.ts +34 -0
- package/dist/utils/sorting.d.ts +12 -0
- package/dist/vendor.LICENSE.txt +1 -1
- package/package.json +3 -3
- /package/dist/{humanfilesize.d.ts → utils/fileSize.d.ts} +0 -0
- /package/dist/{filename.d.ts → utils/filename.d.ts} +0 -0
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","sources":["../lib/utils/logger.ts","../lib/newFileMenu.ts","../lib/humanfilesize.ts","../lib/fileAction.ts","../lib/fileListHeaders.ts","../lib/permissions.ts","../lib/dav/davProperties.ts","../lib/dav/davPermissions.ts","../lib/files/fileType.ts","../lib/files/nodeData.ts","../lib/files/node.ts","../lib/files/file.ts","../lib/files/folder.ts","../lib/dav/dav.ts","../lib/filename.ts","../lib/navigation/navigation.ts","../lib/navigation/column.ts","../node_modules/fast-xml-parser/src/util.js","../node_modules/fast-xml-parser/src/validator.js","../node_modules/fast-xml-parser/src/xmlparser/OptionsBuilder.js","../node_modules/fast-xml-parser/src/xmlparser/xmlNode.js","../node_modules/fast-xml-parser/src/xmlparser/DocTypeReader.js","../node_modules/strnum/strnum.js","../node_modules/fast-xml-parser/src/xmlparser/OrderedObjParser.js","../node_modules/fast-xml-parser/src/xmlparser/node2json.js","../node_modules/fast-xml-parser/src/xmlparser/XMLParser.js","../node_modules/fast-xml-parser/src/xmlbuilder/orderedJs2Xml.js","../node_modules/fast-xml-parser/src/xmlbuilder/json2xml.js","../node_modules/fast-xml-parser/src/fxp.js","../node_modules/is-svg/index.js","../lib/navigation/view.ts","../lib/index.ts"],"sourcesContent":["/**\n * @copyright 2019 Christoph Wurst <christoph@winzerhof-wurst.at>\n *\n * @author Christoph Wurst <christoph@winzerhof-wurst.at>\n *\n * @license AGPL-3.0-or-later\n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see <http://www.gnu.org/licenses/>.\n *\n */\n\nimport { getCurrentUser } from '@nextcloud/auth'\nimport { getLoggerBuilder } from '@nextcloud/logger'\n\nconst getLogger = user => {\n\tif (user === null) {\n\t\treturn getLoggerBuilder()\n\t\t\t.setApp('files')\n\t\t\t.build()\n\t}\n\treturn getLoggerBuilder()\n\t\t.setApp('files')\n\t\t.setUid(user.uid)\n\t\t.build()\n}\n\nexport default getLogger(getCurrentUser())\n","/**\n * @copyright Copyright (c) 2021 John Molakvoæ <skjnldsv@protonmail.com>\n *\n * @author John Molakvoæ <skjnldsv@protonmail.com>\n *\n * @license AGPL-3.0-or-later\n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see <http://www.gnu.org/licenses/>.\n *\n */\n\nimport type { Folder, Node } from './index'\nimport logger from './utils/logger'\n\nexport enum NewMenuEntryCategory {\n\t/**\n\t * For actions where the user is intended to upload from their device\n\t */\n\tUploadFromDevice = 0,\n\t/**\n\t * For actions that create new nodes on the server without uploading\n\t */\n\tCreateNew = 1,\n\t/**\n\t * For everything not matching the other categories\n\t */\n\tOther = 2,\n}\n\nexport interface Entry {\n\t/** Unique ID */\n\tid: string\n\n\t/**\n\t * Category to put this entry in\n\t * (supported since Nextcloud 30)\n\t * @since 3.3.0\n\t * @default NewMenuEntryCategory.CreateNew\n\t */\n\tcategory?: NewMenuEntryCategory\n\n\t/** Translatable string displayed in the menu */\n\tdisplayName: string\n\n\t/**\n\t * Condition wether this entry is shown or not\n\t * @param context the creation context. Usually the current folder\n\t */\n\tenabled?: (context: Folder) => boolean\n\n\t/**\n\t * Either iconSvgInline or iconClass must be defined\n\t * Svg as inline string. <svg><path fill=\"...\" /></svg>\n\t */\n\ticonSvgInline?: string\n\n\t/**\n\t * Existing icon css class\n\t * @deprecated use iconSvgInline instead\n\t */\n\ticonClass?: string\n\n\t/** Order of the entry in the menu */\n\torder?: number\n\n\t/**\n\t * Function to be run after creation\n\t * @param context the creation context. Usually the current folder\n\t * @param content list of file/folders present in the context folder\n\t */\n\thandler: (context: Folder, content: Node[]) => void\n}\n\nexport class NewFileMenu {\n\n\tprivate _entries: Array<Entry> = []\n\n\tpublic registerEntry(entry: Entry) {\n\t\tthis.validateEntry(entry)\n\t\tentry.category = entry.category ?? NewMenuEntryCategory.CreateNew\n\t\tthis._entries.push(entry)\n\t}\n\n\tpublic unregisterEntry(entry: Entry | string) {\n\t\tconst entryIndex = typeof entry === 'string'\n\t\t\t? this.getEntryIndex(entry)\n\t\t\t: this.getEntryIndex(entry.id)\n\n\t\tif (entryIndex === -1) {\n\t\t\tlogger.warn('Entry not found, nothing removed', { entry, entries: this.getEntries() })\n\t\t\treturn\n\t\t}\n\n\t\tthis._entries.splice(entryIndex, 1)\n\t}\n\n\t/**\n\t * Get the list of registered entries\n\t *\n\t * @param {Folder} context the creation context. Usually the current folder\n\t */\n\tpublic getEntries(context?: Folder): Array<Entry> {\n\t\tif (context) {\n\t\t\treturn this._entries\n\t\t\t\t.filter(entry => typeof entry.enabled === 'function' ? entry.enabled(context) : true)\n\t\t}\n\t\treturn this._entries\n\t}\n\n\tprivate getEntryIndex(id: string): number {\n\t\treturn this._entries.findIndex(entry => entry.id === id)\n\t}\n\n\tprivate validateEntry(entry: Entry) {\n\t\tif (!entry.id || !entry.displayName || !(entry.iconSvgInline || entry.iconClass) || !entry.handler) {\n\t\t\tthrow new Error('Invalid entry')\n\t\t}\n\n\t\tif (typeof entry.id !== 'string'\n\t\t\t|| typeof entry.displayName !== 'string') {\n\t\t\tthrow new Error('Invalid id or displayName property')\n\t\t}\n\n\t\tif ((entry.iconClass && typeof entry.iconClass !== 'string')\n\t\t\t|| (entry.iconSvgInline && typeof entry.iconSvgInline !== 'string')) {\n\t\t\tthrow new Error('Invalid icon provided')\n\t\t}\n\n\t\tif (entry.enabled !== undefined && typeof entry.enabled !== 'function') {\n\t\t\tthrow new Error('Invalid enabled property')\n\t\t}\n\n\t\tif (typeof entry.handler !== 'function') {\n\t\t\tthrow new Error('Invalid handler property')\n\t\t}\n\n\t\tif ('order' in entry && typeof entry.order !== 'number') {\n\t\t\tthrow new Error('Invalid order property')\n\t\t}\n\n\t\tif (this.getEntryIndex(entry.id) !== -1) {\n\t\t\tthrow new Error('Duplicate entry')\n\t\t}\n\t}\n\n}\n\nexport const getNewFileMenu = function(): NewFileMenu {\n\tif (typeof window._nc_newfilemenu === 'undefined') {\n\t\twindow._nc_newfilemenu = new NewFileMenu()\n\t\tlogger.debug('NewFileMenu initialized')\n\t}\n\treturn window._nc_newfilemenu\n}\n","/**\n * @copyright 2019 Christoph Wurst <christoph@winzerhof-wurst.at>\n *\n * @author Christoph Wurst <christoph@winzerhof-wurst.at>\n * @author John Molakvoæ <skjnldsv@protonmail.com>\n *\n * @license AGPL-3.0-or-later\n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see <http://www.gnu.org/licenses/>.\n *\n */\n\nimport { getCanonicalLocale } from '@nextcloud/l10n'\n\nconst humanList = ['B', 'KB', 'MB', 'GB', 'TB', 'PB']\nconst humanListBinary = ['B', 'KiB', 'MiB', 'GiB', 'TiB', 'PiB']\n\n/**\n * Format a file size in a human-like format. e.g. 42GB\n *\n * The default for Nextcloud is like Windows using binary sizes but showing decimal units,\n * meaning 1024 bytes will show as 1KB instead of 1KiB or like on Apple 1.02 KB\n *\n * @param size in bytes\n * @param skipSmallSizes avoid rendering tiny sizes and return '< 1 KB' instead\n * @param binaryPrefixes True if size binary prefixes like `KiB` should be used as per IEC 80000-13\n * @param base1000 Set to true to use base 1000 as per SI or used by Apple (default is base 1024 like Linux or Windows)\n */\nexport function formatFileSize(size: number|string, skipSmallSizes = false, binaryPrefixes = false, base1000 = false): string {\n\t// Binary prefixes only work with base 1024\n\tbinaryPrefixes = binaryPrefixes && !base1000\n\n\tif (typeof size === 'string') {\n\t\tsize = Number(size)\n\t}\n\n\t// Calculate Log with base 1024 or 1000: size = base ** order\n\tlet order = size > 0 ? Math.floor(Math.log(size) / Math.log(base1000 ? 1000 : 1024)) : 0\n\n\t// Stay in range of the byte sizes that are defined\n\torder = Math.min((binaryPrefixes ? humanListBinary.length : humanList.length) - 1, order)\n\n\tconst readableFormat = binaryPrefixes ? humanListBinary[order] : humanList[order]\n\tlet relativeSize = (size / Math.pow(base1000 ? 1000 : 1024, order)).toFixed(1)\n\n\tif (skipSmallSizes === true && order === 0) {\n\t\treturn (relativeSize !== '0.0' ? '< 1 ' : '0 ') + (binaryPrefixes ? humanListBinary[1] : humanList[1])\n\t}\n\n\tif (order < 2) {\n\t\trelativeSize = parseFloat(relativeSize).toFixed(0)\n\t} else {\n\t\trelativeSize = parseFloat(relativeSize).toLocaleString(getCanonicalLocale())\n\t}\n\n\treturn relativeSize + ' ' + readableFormat\n}\n\n/**\n * Returns a file size in bytes from a humanly readable string\n * Note: `b` and `B` are both parsed as bytes and not as bit or byte.\n *\n * @param {string} value file size in human-readable format\n * @param {boolean} forceBinary for backwards compatibility this allows values to be base 2 (so 2KB means 2048 bytes instead of 2000 bytes)\n * @return {number} or null if string could not be parsed\n */\nexport function parseFileSize(value: string, forceBinary = false) {\n\ttry {\n\t\tvalue = `${value}`.toLocaleLowerCase().replaceAll(/\\s+/g, '').replaceAll(',', '.')\n\t} catch (e) {\n\t\treturn null\n\t}\n\n\tconst match = value.match(/^([0-9]*(\\.[0-9]*)?)([kmgtp]?)(i?)b?$/)\n\t// ignore not found, missing pre- and decimal, empty number\n\tif (match === null || match[1] === '.' || match[1] === '') {\n\t\treturn null\n\t}\n\n\tconst bytesArray = {\n\t\t'': 0,\n\t\tk: 1,\n\t\tm: 2,\n\t\tg: 3,\n\t\tt: 4,\n\t\tp: 5,\n\t\te: 6,\n\t}\n\n\tconst decimalString = `${match[1]}`\n\tconst base = (match[4] === 'i' || forceBinary) ? 1024 : 1000\n\n\treturn Math.round(Number.parseFloat(decimalString) * (base ** bytesArray[match[3]]))\n}\n","/**\n * @copyright Copyright (c) 2023 John Molakvoæ <skjnldsv@protonmail.com>\n *\n * @author John Molakvoæ <skjnldsv@protonmail.com>\n *\n * @license AGPL-3.0-or-later\n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see <http://www.gnu.org/licenses/>.\n *\n */\n\nimport { Node } from './files/node'\nimport { View } from './navigation/view'\nimport logger from './utils/logger'\n\nexport enum DefaultType {\n\tDEFAULT = 'default',\n\tHIDDEN = 'hidden',\n}\n\ninterface FileActionData {\n\t/** Unique ID */\n\tid: string\n\t/** Translatable string displayed in the menu */\n\tdisplayName: (files: Node[], view: View) => string\n\t/** Translatable title for of the action */\n\ttitle?: (files: Node[], view: View) => string\n\t/** Svg as inline string. <svg><path fill=\"...\" /></svg> */\n\ticonSvgInline: (files: Node[], view: View) => string\n\t/** Condition wether this action is shown or not */\n\tenabled?: (files: Node[], view: View) => boolean\n\n\t/**\n\t * Function executed on single file action\n\t * @return true if the action was executed successfully,\n\t * false otherwise and null if the action is silent/undefined.\n\t * @throws Error if the action failed\n\t */\n\texec: (file: Node, view: View, dir: string) => Promise<boolean|null>,\n\t/**\n\t * Function executed on multiple files action\n\t * @return true if the action was executed successfully,\n\t * false otherwise and null if the action is silent/undefined.\n\t * @throws Error if the action failed\n\t */\n\texecBatch?: (files: Node[], view: View, dir: string) => Promise<(boolean|null)[]>\n\n\t/** This action order in the list */\n\torder?: number,\n\n\t/**\n\t * This action's parent id in the list.\n\t * If none found, will be displayed as a top-level action.\n\t */\n\tparent?: string,\n\n\t/**\n\t * Make this action the default.\n\t * If multiple actions are default, the first one\n\t * will be used. The other ones will be put as first\n\t * entries in the actions menu iff DefaultType.Hidden is not used.\n\t * A DefaultType.Hidden action will never be shown\n\t * in the actions menu even if another action takes\n\t * its place as default.\n\t */\n\tdefault?: DefaultType,\n\t/**\n\t * If true, the renderInline function will be called\n\t */\n\tinline?: (file: Node, view: View) => boolean,\n\t/**\n\t * If defined, the returned html element will be\n\t * appended before the actions menu.\n\t */\n\trenderInline?: (file: Node, view: View) => Promise<HTMLElement | null>,\n}\n\nexport class FileAction {\n\n\tprivate _action: FileActionData\n\n\tconstructor(action: FileActionData) {\n\t\tthis.validateAction(action)\n\t\tthis._action = action\n\t}\n\n\tget id() {\n\t\treturn this._action.id\n\t}\n\n\tget displayName() {\n\t\treturn this._action.displayName\n\t}\n\n\tget title() {\n\t\treturn this._action.title\n\t}\n\n\tget iconSvgInline() {\n\t\treturn this._action.iconSvgInline\n\t}\n\n\tget enabled() {\n\t\treturn this._action.enabled\n\t}\n\n\tget exec() {\n\t\treturn this._action.exec\n\t}\n\n\tget execBatch() {\n\t\treturn this._action.execBatch\n\t}\n\n\tget order() {\n\t\treturn this._action.order\n\t}\n\n\tget parent() {\n\t\treturn this._action.parent\n\t}\n\n\tget default() {\n\t\treturn this._action.default\n\t}\n\n\tget inline() {\n\t\treturn this._action.inline\n\t}\n\n\tget renderInline() {\n\t\treturn this._action.renderInline\n\t}\n\n\tprivate validateAction(action: FileActionData) {\n\t\tif (!action.id || typeof action.id !== 'string') {\n\t\t\tthrow new Error('Invalid id')\n\t\t}\n\n\t\tif (!action.displayName || typeof action.displayName !== 'function') {\n\t\t\tthrow new Error('Invalid displayName function')\n\t\t}\n\n\t\tif ('title' in action && typeof action.title !== 'function') {\n\t\t\tthrow new Error('Invalid title function')\n\t\t}\n\n\t\tif (!action.iconSvgInline || typeof action.iconSvgInline !== 'function') {\n\t\t\tthrow new Error('Invalid iconSvgInline function')\n\t\t}\n\n\t\tif (!action.exec || typeof action.exec !== 'function') {\n\t\t\tthrow new Error('Invalid exec function')\n\t\t}\n\n\t\t// Optional properties --------------------------------------------\n\t\tif ('enabled' in action && typeof action.enabled !== 'function') {\n\t\t\tthrow new Error('Invalid enabled function')\n\t\t}\n\n\t\tif ('execBatch' in action && typeof action.execBatch !== 'function') {\n\t\t\tthrow new Error('Invalid execBatch function')\n\t\t}\n\n\t\tif ('order' in action && typeof action.order !== 'number') {\n\t\t\tthrow new Error('Invalid order')\n\t\t}\n\n\t\tif ('parent' in action && typeof action.parent !== 'string') {\n\t\t\tthrow new Error('Invalid parent')\n\t\t}\n\n\t\tif (action.default && !Object.values(DefaultType).includes(action.default)) {\n\t\t\tthrow new Error('Invalid default')\n\t\t}\n\n\t\tif ('inline' in action && typeof action.inline !== 'function') {\n\t\t\tthrow new Error('Invalid inline function')\n\t\t}\n\n\t\tif ('renderInline' in action && typeof action.renderInline !== 'function') {\n\t\t\tthrow new Error('Invalid renderInline function')\n\t\t}\n\t}\n\n}\n\nexport const registerFileAction = function(action: FileAction): void {\n\tif (typeof window._nc_fileactions === 'undefined') {\n\t\twindow._nc_fileactions = []\n\t\tlogger.debug('FileActions initialized')\n\t}\n\n\t// Check duplicates\n\tif (window._nc_fileactions.find(search => search.id === action.id)) {\n\t\tlogger.error(`FileAction ${action.id} already registered`, { action })\n\t\treturn\n\t}\n\n\twindow._nc_fileactions.push(action)\n}\n\nexport const getFileActions = function(): FileAction[] {\n\tif (typeof window._nc_fileactions === 'undefined') {\n\t\twindow._nc_fileactions = []\n\t\tlogger.debug('FileActions initialized')\n\t}\n\n\treturn window._nc_fileactions\n}\n","/**\n * @copyright Copyright (c) 2023 John Molakvoæ <skjnldsv@protonmail.com>\n *\n * @author John Molakvoæ <skjnldsv@protonmail.com>\n *\n * @license AGPL-3.0-or-later\n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see <http://www.gnu.org/licenses/>.\n *\n */\n\nimport { Folder } from './files/folder'\nimport { View } from './navigation/view'\nimport logger from './utils/logger'\n\nexport interface HeaderData {\n\t/** Unique ID */\n\tid: string\n\t/** Order */\n\torder: number\n\t/** Condition wether this header is shown or not */\n\tenabled?: (folder: Folder, view: View) => boolean\n\t/** Executed when file list is initialized */\n\trender: (el: HTMLElement, folder: Folder, view: View) => void\n\t/** Executed when root folder changed */\n\tupdated(folder: Folder, view: View)\n}\n\nexport class Header {\n\n\tprivate _header: HeaderData\n\n\tconstructor(header: HeaderData) {\n\t\tthis.validateHeader(header)\n\t\tthis._header = header\n\t}\n\n\tget id() {\n\t\treturn this._header.id\n\t}\n\n\tget order() {\n\t\treturn this._header.order\n\t}\n\n\tget enabled() {\n\t\treturn this._header.enabled\n\t}\n\n\tget render() {\n\t\treturn this._header.render\n\t}\n\n\tget updated() {\n\t\treturn this._header.updated\n\t}\n\n\tprivate validateHeader(header: HeaderData) {\n\t\tif (!header.id || !header.render || !header.updated) {\n\t\t\tthrow new Error('Invalid header: id, render and updated are required')\n\t\t}\n\n\t\tif (typeof header.id !== 'string') {\n\t\t\tthrow new Error('Invalid id property')\n\t\t}\n\n\t\tif (header.enabled !== undefined && typeof header.enabled !== 'function') {\n\t\t\tthrow new Error('Invalid enabled property')\n\t\t}\n\n\t\tif (header.render && typeof header.render !== 'function') {\n\t\t\tthrow new Error('Invalid render property')\n\t\t}\n\n\t\tif (header.updated && typeof header.updated !== 'function') {\n\t\t\tthrow new Error('Invalid updated property')\n\t\t}\n\t}\n\n}\n\nexport const registerFileListHeaders = function(header: Header): void {\n\tif (typeof window._nc_filelistheader === 'undefined') {\n\t\twindow._nc_filelistheader = []\n\t\tlogger.debug('FileListHeaders initialized')\n\t}\n\n\t// Check duplicates\n\tif (window._nc_filelistheader.find(search => search.id === header.id)) {\n\t\tlogger.error(`Header ${header.id} already registered`, { header })\n\t\treturn\n\t}\n\n\twindow._nc_filelistheader.push(header)\n}\n\nexport const getFileListHeaders = function(): Header[] {\n\tif (typeof window._nc_filelistheader === 'undefined') {\n\t\twindow._nc_filelistheader = []\n\t\tlogger.debug('FileListHeaders initialized')\n\t}\n\n\treturn window._nc_filelistheader\n}\n","/**\n * @copyright Copyright (c) 2022 John Molakvoæ <skjnldsv@protonmail.com>\n *\n * @author John Molakvoæ <skjnldsv@protonmail.com>\n *\n * @license AGPL-3.0-or-later\n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see <http://www.gnu.org/licenses/>.\n *\n */\n\n/**\n * Node permissions\n */\nexport enum Permission {\n\tNONE = 0,\n\tCREATE = 4,\n\tREAD = 1,\n\tUPDATE = 2,\n\tDELETE = 8,\n\tSHARE = 16,\n\tALL = 31,\n}\n","/**\n * @copyright Copyright (c) 2023 John Molakvoæ <skjnldsv@protonmail.com>\n *\n * @author John Molakvoæ <skjnldsv@protonmail.com>\n * @author Ferdinand Thiessen <opensource@fthiessen.de>\n *\n * @license AGPL-3.0-or-later\n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see <http://www.gnu.org/licenses/>.\n *\n */\nimport { getCurrentUser } from '@nextcloud/auth'\nimport logger from '../utils/logger'\n\nexport type DavProperty = { [key: string]: string }\n\nexport const defaultDavProperties = [\n\t'd:getcontentlength',\n\t'd:getcontenttype',\n\t'd:getetag',\n\t'd:getlastmodified',\n\t'd:quota-available-bytes',\n\t'd:resourcetype',\n\t'nc:has-preview',\n\t'nc:is-encrypted',\n\t'nc:mount-type',\n\t'oc:comments-unread',\n\t'oc:favorite',\n\t'oc:fileid',\n\t'oc:owner-display-name',\n\t'oc:owner-id',\n\t'oc:permissions',\n\t'oc:size',\n]\n\nexport const defaultDavNamespaces = {\n\td: 'DAV:',\n\tnc: 'http://nextcloud.org/ns',\n\toc: 'http://owncloud.org/ns',\n\tocs: 'http://open-collaboration-services.org/ns',\n}\n\n/**\n * Register custom DAV properties\n *\n * Can be used if your app introduces custom DAV properties, so e.g. the files app can make use of it.\n *\n * @param prop The property\n * @param namespace The namespace of the property\n */\nexport const registerDavProperty = function(prop: string, namespace: DavProperty = { nc: 'http://nextcloud.org/ns' }): boolean {\n\tif (typeof window._nc_dav_properties === 'undefined') {\n\t\twindow._nc_dav_properties = [...defaultDavProperties]\n\t\twindow._nc_dav_namespaces = { ...defaultDavNamespaces }\n\t}\n\n\tconst namespaces = { ...window._nc_dav_namespaces, ...namespace }\n\n\t// Check duplicates\n\tif (window._nc_dav_properties.find((search) => search === prop)) {\n\t\tlogger.warn(`${prop} already registered`, { prop })\n\t\treturn false\n\t}\n\n\tif (prop.startsWith('<') || prop.split(':').length !== 2) {\n\t\tlogger.error(`${prop} is not valid. See example: 'oc:fileid'`, { prop })\n\t\treturn false\n\t}\n\n\tconst ns = prop.split(':')[0]\n\tif (!namespaces[ns]) {\n\t\tlogger.error(`${prop} namespace unknown`, { prop, namespaces })\n\t\treturn false\n\t}\n\n\twindow._nc_dav_properties.push(prop)\n\twindow._nc_dav_namespaces = namespaces\n\treturn true\n}\n\n/**\n * Get the registered dav properties\n */\nexport const getDavProperties = function(): string {\n\tif (typeof window._nc_dav_properties === 'undefined') {\n\t\twindow._nc_dav_properties = [...defaultDavProperties]\n\t}\n\n\treturn window._nc_dav_properties.map((prop) => `<${prop} />`).join(' ')\n}\n\n/**\n * Get the registered dav namespaces\n */\nexport const getDavNameSpaces = function(): string {\n\tif (typeof window._nc_dav_namespaces === 'undefined') {\n\t\twindow._nc_dav_namespaces = { ...defaultDavNamespaces }\n\t}\n\n\treturn Object.keys(window._nc_dav_namespaces)\n\t\t.map((ns) => `xmlns:${ns}=\"${window._nc_dav_namespaces?.[ns]}\"`)\n\t\t.join(' ')\n}\n\n/**\n * Get the default PROPFIND request body\n */\nexport const davGetDefaultPropfind = function(): string {\n\treturn `<?xml version=\"1.0\"?>\n\t\t<d:propfind ${getDavNameSpaces()}>\n\t\t\t<d:prop>\n\t\t\t\t${getDavProperties()}\n\t\t\t</d:prop>\n\t\t</d:propfind>`\n}\n\n/**\n * Get the REPORT body to filter for favorite nodes\n */\nexport const davGetFavoritesReport = function(): string {\n\treturn `<?xml version=\"1.0\"?>\n\t\t<oc:filter-files ${getDavNameSpaces()}>\n\t\t\t<d:prop>\n\t\t\t\t${getDavProperties()}\n\t\t\t</d:prop>\n\t\t\t<oc:filter-rules>\n\t\t\t\t<oc:favorite>1</oc:favorite>\n\t\t\t</oc:filter-rules>\n\t\t</oc:filter-files>`\n}\n\n/**\n * Get the SEARCH body to search for recently modified files\n *\n * @param lastModified Oldest timestamp to include (Unix timestamp)\n * @example\n * ```ts\n * // SEARCH for recent files need a different DAV endpoint\n * const client = davGetClient(generateRemoteUrl('dav'))\n * // Timestamp of last week\n * const lastWeek = Math.round(Date.now() / 1000) - (60 * 60 * 24 * 7)\n * const contentsResponse = await client.getDirectoryContents(path, {\n * details: true,\n * data: davGetRecentSearch(lastWeek),\n * headers: {\n * method: 'SEARCH',\n * 'Content-Type': 'application/xml; charset=utf-8',\n * },\n * deep: true,\n * }) as ResponseDataDetailed<FileStat[]>\n * ```\n */\nexport const davGetRecentSearch = function(lastModified: number): string {\n\treturn `<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<d:searchrequest ${getDavNameSpaces()}\n\txmlns:ns=\"https://github.com/icewind1991/SearchDAV/ns\">\n\t<d:basicsearch>\n\t\t<d:select>\n\t\t\t<d:prop>\n\t\t\t\t${getDavProperties()}\n\t\t\t</d:prop>\n\t\t</d:select>\n\t\t<d:from>\n\t\t\t<d:scope>\n\t\t\t\t<d:href>/files/${getCurrentUser()?.uid}/</d:href>\n\t\t\t\t<d:depth>infinity</d:depth>\n\t\t\t</d:scope>\n\t\t</d:from>\n\t\t<d:where>\n\t\t\t<d:and>\n\t\t\t\t<d:or>\n\t\t\t\t\t<d:not>\n\t\t\t\t\t\t<d:eq>\n\t\t\t\t\t\t\t<d:prop>\n\t\t\t\t\t\t\t\t<d:getcontenttype/>\n\t\t\t\t\t\t\t</d:prop>\n\t\t\t\t\t\t\t<d:literal>httpd/unix-directory</d:literal>\n\t\t\t\t\t\t</d:eq>\n\t\t\t\t\t</d:not>\n\t\t\t\t\t<d:eq>\n\t\t\t\t\t\t<d:prop>\n\t\t\t\t\t\t\t<oc:size/>\n\t\t\t\t\t\t</d:prop>\n\t\t\t\t\t\t<d:literal>0</d:literal>\n\t\t\t\t\t</d:eq>\n\t\t\t\t</d:or>\n\t\t\t\t<d:gt>\n\t\t\t\t\t<d:prop>\n\t\t\t\t\t\t<d:getlastmodified/>\n\t\t\t\t\t</d:prop>\n\t\t\t\t\t<d:literal>${lastModified}</d:literal>\n\t\t\t\t</d:gt>\n\t\t\t</d:and>\n\t\t</d:where>\n\t\t<d:orderby>\n\t\t\t<d:order>\n\t\t\t\t<d:prop>\n\t\t\t\t\t<d:getlastmodified/>\n\t\t\t\t</d:prop>\n\t\t\t\t<d:descending/>\n\t\t\t</d:order>\n\t\t</d:orderby>\n\t\t<d:limit>\n\t\t\t<d:nresults>100</d:nresults>\n\t\t\t<ns:firstresult>0</ns:firstresult>\n\t\t</d:limit>\n\t</d:basicsearch>\n</d:searchrequest>`\n}\n","/**\n * @copyright Copyright (c) 2023 John Molakvoæ <skjnldsv@protonmail.com>\n *\n * @author John Molakvoæ <skjnldsv@protonmail.com>\n * @author Ferdinand Thiessen <opensource@fthiessen.de>\n *\n * @license AGPL-3.0-or-later\n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see <http://www.gnu.org/licenses/>.\n *\n */\nimport { Permission } from '../permissions'\n\n/**\n * Parse the webdav permission string to a permission enum\n *\n * @param permString The DAV permission string\n */\nexport const davParsePermissions = function(permString = ''): number {\n\tlet permissions = Permission.NONE\n\n\tif (!permString) { return permissions }\n\n\tif (permString.includes('C') || permString.includes('K')) { permissions |= Permission.CREATE }\n\n\tif (permString.includes('G')) { permissions |= Permission.READ }\n\n\tif (permString.includes('W') || permString.includes('N') || permString.includes('V')) { permissions |= Permission.UPDATE }\n\n\tif (permString.includes('D')) { permissions |= Permission.DELETE }\n\n\tif (permString.includes('R')) { permissions |= Permission.SHARE }\n\n\treturn permissions\n}\n","/**\n * @copyright Copyright (c) 2022 John Molakvoæ <skjnldsv@protonmail.com>\n *\n * @author John Molakvoæ <skjnldsv@protonmail.com>\n *\n * @license AGPL-3.0-or-later\n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see <http://www.gnu.org/licenses/>.\n *\n */\nexport enum FileType {\n\tFolder = 'folder',\n\tFile = 'file',\n}\n","/**\n * @copyright Copyright (c) 2022 John Molakvoæ <skjnldsv@protonmail.com>\n *\n * @author John Molakvoæ <skjnldsv@protonmail.com>\n *\n * @license AGPL-3.0-or-later\n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see <http://www.gnu.org/licenses/>.\n *\n */\n\nimport { join } from 'path'\nimport { Permission } from '../permissions'\nimport { NodeStatus } from './node'\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport interface Attribute { [key: string]: any }\n\nexport interface NodeData {\n\t/** Unique ID */\n\tid?: number\n\n\t/**\n\t * URL to the ressource.\n\t * e.g. https://cloud.domain.com/remote.php/dav/files/emma/Photos/picture.jpg\n\t * or https://domain.com/Photos/picture.jpg\n\t */\n\tsource: string\n\n\t/** Last modified time */\n\tmtime?: Date\n\n\t/** Creation time */\n\tcrtime?: Date\n\n\t/** The mime type Optional for folders only */\n\tmime?: string\n\n\t/** The node size type */\n\tsize?: number\n\n\t/** The node permissions */\n\tpermissions?: Permission\n\n\t/** The owner UID of this node */\n\towner: string|null\n\n\t/** The node attributes */\n\tattributes?: Attribute\n\n\t/**\n\t * The absolute root of the home relative to the service.\n\t * It is highly recommended to provide that information.\n\t * e.g. /files/emma\n\t */\n\troot?: string\n\n\t/** The node status */\n\tstatus?: NodeStatus\n}\n\n/**\n * Check if a node source is from a specific DAV service\n *\n * @param source The source to check\n * @param davService Pattern to check if source is DAV ressource\n */\nexport const isDavRessource = function(source: string, davService: RegExp): boolean {\n\treturn source.match(davService) !== null\n}\n\n/**\n * Validate Node construct data\n *\n * @param data The node data\n * @param davService Pattern to check if source is DAV ressource\n */\nexport const validateData = (data: NodeData, davService: RegExp) => {\n\tif (data.id && typeof data.id !== 'number') {\n\t\tthrow new Error('Invalid id type of value')\n\t}\n\n\tif (!data.source) {\n\t\tthrow new Error('Missing mandatory source')\n\t}\n\n\ttry {\n\t\t// eslint-disable-next-line no-new\n\t\tnew URL(data.source)\n\t} catch (e) {\n\t\tthrow new Error('Invalid source format, source must be a valid URL')\n\t}\n\n\tif (!data.source.startsWith('http')) {\n\t\tthrow new Error('Invalid source format, only http(s) is supported')\n\t}\n\n\tif (data.mtime && !(data.mtime instanceof Date)) {\n\t\tthrow new Error('Invalid mtime type')\n\t}\n\n\tif (data.crtime && !(data.crtime instanceof Date)) {\n\t\tthrow new Error('Invalid crtime type')\n\t}\n\n\tif (!data.mime || typeof data.mime !== 'string'\n\t\t|| !data.mime.match(/^[-\\w.]+\\/[-+\\w.]+$/gi)) {\n\t\tthrow new Error('Missing or invalid mandatory mime')\n\t}\n\n\t// Allow size to be 0\n\tif ('size' in data && typeof data.size !== 'number' && data.size !== undefined) {\n\t\tthrow new Error('Invalid size type')\n\t}\n\n\t// Allow permissions to be 0\n\tif ('permissions' in data\n\t\t&& data.permissions !== undefined\n\t\t&& !(typeof data.permissions === 'number'\n\t\t\t&& data.permissions >= Permission.NONE\n\t\t\t&& data.permissions <= Permission.ALL\n\t\t)) {\n\t\tthrow new Error('Invalid permissions')\n\t}\n\n\tif (data.owner\n\t\t&& data.owner !== null\n\t\t&& typeof data.owner !== 'string') {\n\t\tthrow new Error('Invalid owner type')\n\t}\n\n\tif (data.attributes && typeof data.attributes !== 'object') {\n\t\tthrow new Error('Invalid attributes type')\n\t}\n\n\tif (data.root && typeof data.root !== 'string') {\n\t\tthrow new Error('Invalid root type')\n\t}\n\n\tif (data.root && !data.root.startsWith('/')) {\n\t\tthrow new Error('Root must start with a leading slash')\n\t}\n\n\tif (data.root && !data.source.includes(data.root)) {\n\t\tthrow new Error('Root must be part of the source')\n\t}\n\n\tif (data.root && isDavRessource(data.source, davService)) {\n\t\tconst service = data.source.match(davService)![0]\n\t\tif (!data.source.includes(join(service, data.root))) {\n\t\t\tthrow new Error('The root must be relative to the service. e.g /files/emma')\n\t\t}\n\t}\n\n\tif (data.status && !Object.values(NodeStatus).includes(data.status)) {\n\t\tthrow new Error('Status must be a valid NodeStatus')\n\t}\n}\n","/**\n * @copyright Copyright (c) 2022 John Molakvoæ <skjnldsv@protonmail.com>\n *\n * @author John Molakvoæ <skjnldsv@protonmail.com>\n *\n * @license AGPL-3.0-or-later\n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see <http://www.gnu.org/licenses/>.\n *\n */\nimport { basename, extname, dirname } from 'path'\nimport { encodePath } from '@nextcloud/paths'\n\nimport { Permission } from '../permissions'\nimport { FileType } from './fileType'\nimport { Attribute, NodeData, isDavRessource, validateData } from './nodeData'\nimport logger from '../utils/logger'\n\nexport enum NodeStatus {\n\t/** This is a new node and it doesn't exists on the filesystem yet */\n\tNEW = 'new',\n\t/** This node has failed and is unavailable */\n\tFAILED = 'failed',\n\t/** This node is currently loading or have an operation in progress */\n\tLOADING = 'loading',\n\t/** This node is locked and cannot be modified */\n\tLOCKED = 'locked',\n}\n\nexport abstract class Node {\n\n\tprivate _data: NodeData\n\tprivate _attributes: Attribute\n\tprivate _knownDavService = /(remote|public)\\.php\\/(web)?dav/i\n\n\tprivate handler = {\n\t\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\t\tset: (target: Attribute, prop: string, value: any): any => {\n\t\t\t// Edit modification time\n\t\t\tthis.updateMtime()\n\t\t\t// Apply original changes\n\t\t\treturn Reflect.set(target, prop, value)\n\t\t},\n\t\tdeleteProperty: (target: Attribute, prop: string) => {\n\t\t\t// Edit modification time\n\t\t\tthis.updateMtime()\n\t\t\t// Apply original changes\n\t\t\treturn Reflect.deleteProperty(target, prop)\n\t\t},\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\t} as ProxyHandler<any>\n\n\tconstructor(data: NodeData, davService?: RegExp) {\n\t\t// Validate data\n\t\tvalidateData(data, davService || this._knownDavService)\n\n\t\tthis._data = data\n\n\t\t// Proxy the attributes to update the mtime on change\n\t\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\t\tthis._attributes = new Proxy(this.cleanAttributes(data.attributes || {}) as any, this.handler)\n\t\tdelete this._data.attributes\n\n\t\tif (davService) {\n\t\t\tthis._knownDavService = davService\n\t\t}\n\t}\n\n\t/**\n\t * Get the source url to this object\n\t * There is no setter as the source is not meant to be changed manually.\n\t * You can use the rename or move method to change the source.\n\t */\n\tget source(): string {\n\t\t// strip any ending slash\n\t\treturn this._data.source.replace(/\\/$/i, '')\n\t}\n\n\t/**\n\t * Get the encoded source url to this object for requests purposes\n\t */\n\tget encodedSource(): string {\n\t\tconst { origin } = new URL(this.source)\n\t\treturn origin + encodePath(this.source.slice(origin.length))\n\t}\n\n\t/**\n\t * Get this object name\n\t * There is no setter as the source is not meant to be changed manually.\n\t * You can use the rename or move method to change the source.\n\t */\n\tget basename(): string {\n\t\treturn basename(this.source)\n\t}\n\n\t/**\n\t * Get this object's extension\n\t * There is no setter as the source is not meant to be changed manually.\n\t * You can use the rename or move method to change the source.\n\t */\n\tget extension(): string|null {\n\t\treturn extname(this.source)\n\t}\n\n\t/**\n\t * Get the directory path leading to this object\n\t * Will use the relative path to root if available\n\t *\n\t * There is no setter as the source is not meant to be changed manually.\n\t * You can use the rename or move method to change the source.\n\t */\n\tget dirname(): string {\n\t\tif (this.root) {\n\t\t\tlet source = this.source\n\t\t\tif (this.isDavRessource) {\n\t\t\t\t// ensure we only work on the real path in case root is not distinct\n\t\t\t\tsource = source.split(this._knownDavService).pop()!\n\t\t\t}\n\t\t\t// Using replace would remove all part matching root\n\t\t\tconst firstMatch = source.indexOf(this.root)\n\t\t\t// Ensure we do not remove the leading slash\n\t\t\tconst root = this.root.replace(/\\/$/, '')\n\t\t\treturn dirname(source.slice(firstMatch + root.length) || '/')\n\t\t}\n\n\t\t// This should always be a valid URL\n\t\t// as this is tested in the constructor\n\t\tconst url = new URL(this.source)\n\t\treturn dirname(url.pathname)\n\t}\n\n\t/**\n\t * Is it a file or a folder ?\n\t */\n\tabstract get type(): FileType\n\n\t/**\n\t * Get the file mime\n\t * There is no setter as the mime is not meant to be changed\n\t */\n\tget mime(): string|undefined {\n\t\treturn this._data.mime\n\t}\n\n\t/**\n\t * Get the file modification time\n\t * There is no setter as the modification time is not meant to be changed manually.\n\t * It will be automatically updated when the attributes are changed.\n\t */\n\tget mtime(): Date|undefined {\n\t\treturn this._data.mtime\n\t}\n\n\t/**\n\t * Get the file creation time\n\t * There is no setter as the creation time is not meant to be changed\n\t */\n\tget crtime(): Date|undefined {\n\t\treturn this._data.crtime\n\t}\n\n\t/**\n\t * Get the file size\n\t */\n\tget size(): number|undefined {\n\t\treturn this._data.size\n\t}\n\n\t/**\n\t * Set the file size\n\t */\n\tset size(size: number|undefined) {\n\t\tthis.updateMtime()\n\t\tthis._data.size = size\n\t}\n\n\t/**\n\t * Get the file attribute\n\t */\n\tget attributes(): Attribute {\n\t\treturn this._attributes\n\t}\n\n\t/**\n\t * Get the file permissions\n\t */\n\tget permissions(): Permission {\n\t\t// If this is not a dav ressource, we can only read it\n\t\tif (this.owner === null && !this.isDavRessource) {\n\t\t\treturn Permission.READ\n\t\t}\n\n\t\t// If the permissions are not defined, we have none\n\t\treturn this._data.permissions !== undefined\n\t\t\t? this._data.permissions\n\t\t\t: Permission.NONE\n\t}\n\n\t/**\n\t * Set the file permissions\n\t */\n\tset permissions(permissions: Permission) {\n\t\tthis.updateMtime()\n\t\tthis._data.permissions = permissions\n\t}\n\n\t/**\n\t * Get the file owner\n\t * There is no setter as the owner is not meant to be changed\n\t */\n\tget owner(): string|null {\n\t\t// Remote ressources have no owner\n\t\tif (!this.isDavRessource) {\n\t\t\treturn null\n\t\t}\n\t\treturn this._data.owner\n\t}\n\n\t/**\n\t * Is this a dav-related ressource ?\n\t */\n\tget isDavRessource(): boolean {\n\t\treturn isDavRessource(this.source, this._knownDavService)\n\t}\n\n\t/**\n\t * Get the dav root of this object\n\t * There is no setter as the root is not meant to be changed\n\t */\n\tget root(): string|null {\n\t\t// If provided (recommended), use the root and strip away the ending slash\n\t\tif (this._data.root) {\n\t\t\treturn this._data.root.replace(/^(.+)\\/$/, '$1')\n\t\t}\n\n\t\t// Use the source to get the root from the dav service\n\t\tif (this.isDavRessource) {\n\t\t\tconst root = dirname(this.source)\n\t\t\treturn root.split(this._knownDavService).pop() || null\n\t\t}\n\n\t\treturn null\n\t}\n\n\t/**\n\t * Get the absolute path of this object relative to the root\n\t */\n\tget path(): string {\n\t\tif (this.root) {\n\t\t\tlet source = this.source\n\t\t\tif (this.isDavRessource) {\n\t\t\t\t// ensure we only work on the real path in case root is not distinct\n\t\t\t\tsource = source.split(this._knownDavService).pop()!\n\t\t\t}\n\t\t\t// Using replace would remove all part matching root\n\t\t\tconst firstMatch = source.indexOf(this.root)\n\t\t\t// Ensure we do not remove the leading slash\n\t\t\tconst root = this.root.replace(/\\/$/, '')\n\t\t\treturn source.slice(firstMatch + root.length) || '/'\n\t\t}\n\t\treturn (this.dirname + '/' + this.basename).replace(/\\/\\//g, '/')\n\t}\n\n\t/**\n\t * Get the node id if defined.\n\t * There is no setter as the fileid is not meant to be changed\n\t */\n\tget fileid(): number|undefined {\n\t\treturn this._data?.id\n\t}\n\n\t/**\n\t * Get the node status.\n\t */\n\tget status(): NodeStatus|undefined {\n\t\treturn this._data?.status\n\t}\n\n\t/**\n\t * Set the node status.\n\t */\n\tset status(status: NodeStatus|undefined) {\n\t\tthis._data.status = status\n\t}\n\n\t/**\n\t * Move the node to a new destination\n\t *\n\t * @param {string} destination the new source.\n\t * e.g. https://cloud.domain.com/remote.php/dav/files/emma/Photos/picture.jpg\n\t */\n\tmove(destination: string) {\n\t\tvalidateData({ ...this._data, source: destination }, this._knownDavService)\n\t\tthis._data.source = destination\n\t\tthis.updateMtime()\n\t}\n\n\t/**\n\t * Rename the node\n\t * This aliases the move method for easier usage\n\t *\n\t * @param basename The new name of the node\n\t */\n\trename(basename: string) {\n\t\tif (basename.includes('/')) {\n\t\t\tthrow new Error('Invalid basename')\n\t\t}\n\t\tthis.move(dirname(this.source) + '/' + basename)\n\t}\n\n\t/**\n\t * Update the mtime if exists.\n\t */\n\tprivate updateMtime() {\n\t\tif (this._data.mtime) {\n\t\t\tthis._data.mtime = new Date()\n\t\t}\n\t}\n\n\t/**\n\t * Update the attributes of the node\n\t *\n\t * @param attributes The new attributes to update\n\t */\n\tupdate(attributes: Attribute) {\n\t\t// Proxy the attributes to update the mtime on change\n\t\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\t\tthis._attributes = new Proxy(this.cleanAttributes(attributes) as any, this.handler)\n\t}\n\n\tprivate cleanAttributes(attributes: Attribute): Attribute {\n\t\tconst getters = Object.entries(Object.getOwnPropertyDescriptors(Node.prototype))\n\t\t\t.filter(e => typeof e[1].get === 'function' && e[0] !== '__proto__')\n\t\t\t.map(e => e[0])\n\n\t\t// Remove protected getters from the attributes\n\t\t// you cannot update them\n\t\tconst clean: Attribute = {}\n\t\tfor (const key in attributes) {\n\t\t\tif (getters.includes(key)) {\n\t\t\t\tlogger.debug(`Discarding protected attribute ${key}`, { node: this, attributes })\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tclean[key] = attributes[key]\n\t\t}\n\n\t\treturn clean\n\t}\n\n}\n","/**\n * @copyright Copyright (c) 2022 John Molakvoæ <skjnldsv@protonmail.com>\n *\n * @author John Molakvoæ <skjnldsv@protonmail.com>\n *\n * @license AGPL-3.0-or-later\n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see <http://www.gnu.org/licenses/>.\n *\n */\nimport { FileType } from './fileType'\nimport { Node } from './node'\n\nexport class File extends Node {\n\n\tget type(): FileType {\n\t\treturn FileType.File\n\t}\n\n}\n","/**\n * @copyright Copyright (c) 2022 John Molakvoæ <skjnldsv@protonmail.com>\n *\n * @author John Molakvoæ <skjnldsv@protonmail.com>\n *\n * @license AGPL-3.0-or-later\n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see <http://www.gnu.org/licenses/>.\n *\n */\nimport { FileType } from './fileType'\nimport { Node } from './node'\nimport { NodeData } from './nodeData'\n\nexport class Folder extends Node {\n\n\tconstructor(data: NodeData) {\n\t\t// enforcing mimes\n\t\tsuper({\n\t\t\t...data,\n\t\t\tmime: 'httpd/unix-directory',\n\t\t})\n\t}\n\n\tget type(): FileType {\n\t\treturn FileType.Folder\n\t}\n\n\tget extension(): string|null {\n\t\treturn null\n\t}\n\n\tget mime(): string {\n\t\treturn 'httpd/unix-directory'\n\t}\n\n}\n","/**\n * @copyright Copyright (c) 2023 John Molakvoæ <skjnldsv@protonmail.com>\n *\n * @author John Molakvoæ <skjnldsv@protonmail.com>\n * @author Ferdinand Thiessen <opensource@fthiessen.de>\n *\n * @license AGPL-3.0-or-later\n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see <http://www.gnu.org/licenses/>.\n *\n */\nimport type { DAVResultResponseProps, FileStat, ResponseDataDetailed, WebDAVClient } from 'webdav'\nimport type { Node } from '../files/node'\n\nimport { File } from '../files/file'\nimport { Folder } from '../files/folder'\nimport { NodeData } from '../files/nodeData'\nimport { davParsePermissions } from './davPermissions'\nimport { davGetFavoritesReport } from './davProperties'\n\nimport { getCurrentUser, getRequestToken, onRequestTokenUpdate } from '@nextcloud/auth'\nimport { generateRemoteUrl } from '@nextcloud/router'\nimport { createClient, getPatcher } from 'webdav'\nimport { CancelablePromise } from 'cancelable-promise'\n\n/**\n * Nextcloud DAV result response\n */\ninterface ResponseProps extends DAVResultResponseProps {\n\tpermissions: string\n\tmime: string\n\tfileid: number\n\tsize: number\n\t'owner-id': string | number\n}\n\n/**\n * The DAV root path for the current user\n */\nexport const davRootPath = `/files/${getCurrentUser()?.uid}`\n\n/**\n * The DAV remote URL used as base URL for the WebDAV client\n */\nexport const davRemoteURL = generateRemoteUrl('dav')\n\n/**\n * Get a WebDAV client configured to include the Nextcloud request token\n *\n * @param remoteURL The DAV server remote URL\n * @param headers Optional additional headers to set for every request\n */\nexport const davGetClient = function(remoteURL = davRemoteURL, headers: Record<string, string> = {}) {\n\tconst client = createClient(remoteURL, { headers })\n\n\t/**\n\t * Set headers for DAV requests\n\t * @param token CSRF token\n\t */\n\tfunction setHeaders(token: string | null) {\n\t\tclient.setHeaders({\n\t\t\t...headers,\n\t\t\t// Add this so the server knows it is an request from the browser\n\t\t\t'X-Requested-With': 'XMLHttpRequest',\n\t\t\t// Inject user auth\n\t\t\trequesttoken: token ?? '',\n\t\t})\n\t}\n\n\t// refresh headers when request token changes\n\tonRequestTokenUpdate(setHeaders)\n\tsetHeaders(getRequestToken())\n\n\t/**\n\t * Allow to override the METHOD to support dav REPORT\n\t *\n\t * @see https://github.com/perry-mitchell/webdav-client/blob/8d9694613c978ce7404e26a401c39a41f125f87f/source/request.ts\n\t */\n\tconst patcher = getPatcher()\n\t// eslint-disable-next-line @typescript-eslint/ban-ts-comment\n\t// @ts-ignore\n\t// https://github.com/perry-mitchell/hot-patcher/issues/6\n\tpatcher.patch('fetch', (url: string, options: RequestInit): Promise<Response> => {\n\t\tconst headers = options.headers as Record<string, string>\n\t\tif (headers?.method) {\n\t\t\toptions.method = headers.method\n\t\t\tdelete headers.method\n\t\t}\n\t\treturn fetch(url, options)\n\t})\n\n\treturn client\n}\n\n/**\n * Use WebDAV to query for favorite Nodes\n *\n * @param davClient The WebDAV client to use for performing the request\n * @param path Base path for the favorites, if unset all favorites are queried\n * @param davRoot The root path for the DAV user (defaults to `davRootPath`)\n * @example\n * ```js\n * import { davGetClient, davRootPath, getFavoriteNodes } from '@nextcloud/files'\n *\n * const client = davGetClient()\n * // query favorites for the root\n * const favorites = await getFavoriteNodes(client)\n * // which is the same as writing:\n * const favorites = await getFavoriteNodes(client, '/', davRootPath)\n * ```\n */\nexport const getFavoriteNodes = (davClient: WebDAVClient, path = '/', davRoot = davRootPath): CancelablePromise<Node[]> => {\n\tconst controller = new AbortController()\n\treturn new CancelablePromise(async (resolve, reject, onCancel) => {\n\t\tonCancel(() => controller.abort())\n\t\ttry {\n\t\t\tconst contentsResponse = await davClient.getDirectoryContents(`${davRoot}${path}`, {\n\t\t\t\tsignal: controller.signal,\n\t\t\t\tdetails: true,\n\t\t\t\tdata: davGetFavoritesReport(),\n\t\t\t\theaders: {\n\t\t\t\t\t// see davGetClient for patched webdav client\n\t\t\t\t\tmethod: 'REPORT',\n\t\t\t\t},\n\t\t\t\tincludeSelf: true,\n\t\t\t}) as ResponseDataDetailed<FileStat[]>\n\n\t\t\tconst nodes = contentsResponse.data\n\t\t\t\t.filter(node => node.filename !== path) // exclude current dir\n\t\t\t\t.map((result) => davResultToNode(result, davRoot))\n\t\t\tresolve(nodes)\n\t\t} catch (error) {\n\t\t\treject(error)\n\t\t}\n\t})\n}\n\n/**\n * Covert DAV result `FileStat` to `Node`\n *\n * @param node The DAV result\n * @param filesRoot The DAV files root path\n * @param remoteURL The DAV server remote URL (same as on `davGetClient`)\n */\nexport const davResultToNode = function(node: FileStat, filesRoot = davRootPath, remoteURL = davRemoteURL): Node {\n\tlet userId = getCurrentUser()?.uid\n\tconst isPublic = document.querySelector<HTMLInputElement>('input#isPublic')?.value\n\tif (isPublic) {\n\t\tuserId = userId ?? document.querySelector<HTMLInputElement>('input#sharingUserId')?.value\n\t\tuserId = userId ?? 'anonymous'\n\t} else if (!userId) {\n\t\tthrow new Error('No user id found')\n\t}\n\n\tconst props = node.props as ResponseProps\n\tconst permissions = davParsePermissions(props?.permissions)\n\tconst owner = String(props?.['owner-id'] || userId)\n\n\tconst nodeData: NodeData = {\n\t\tid: props?.fileid || 0,\n\t\tsource: `${remoteURL}${node.filename}`,\n\t\tmtime: new Date(Date.parse(node.lastmod)),\n\t\tmime: node.mime || 'application/octet-stream',\n\t\tsize: props?.size || Number.parseInt(props.getcontentlength || '0'),\n\t\tpermissions,\n\t\towner,\n\t\troot: filesRoot,\n\t\tattributes: {\n\t\t\t...node,\n\t\t\t...props,\n\t\t\thasPreview: props?.['has-preview'],\n\t\t},\n\t}\n\n\tdelete nodeData.attributes?.props\n\n\treturn node.type === 'file' ? new File(nodeData) : new Folder(nodeData)\n}\n","/**\n * SPDX-FileCopyrightText: Ferdinand Thiessen <opensource@fthiessen.de>\n * SPDX-License-Identifier: AGPL-3.0-or-later or LGPL-3.0-or-later\n */\n\nconst forbiddenCharacters = window._oc_config?.forbidden_filenames_characters ?? ['/', '\\\\']\nconst forbiddenFilenameRegex = window._oc_config?.blacklist_files_regex ? new RegExp(window._oc_config.blacklist_files_regex) : null\n\n/**\n * Check the validity of a filename\n * This is a convinient wrapper for `checkFilenameValidity` to only return a boolean for the valid\n * @param filename Filename to check validity\n */\nexport function isFilenameValid(filename: string): boolean {\n\t// Check forbidden characters (available with Nextcloud 29)\n\tif (forbiddenCharacters.some((character) => filename.includes(character))) {\n\t\treturn false\n\t}\n\t// Check forbidden filename regex\n\tif (forbiddenFilenameRegex !== null && filename.match(forbiddenFilenameRegex)) {\n\t\treturn false\n\t}\n\t// in Nextcloud 30 also check forbidden file extensions and file prefixes\n\treturn true\n}\n","/**\n * @copyright Copyright (c) 2022 John Molakvoæ <skjnldsv@protonmail.com>\n *\n * @author John Molakvoæ <skjnldsv@protonmail.com>\n *\n * @license AGPL-3.0-or-later\n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see <http://www.gnu.org/licenses/>.\n *\n */\nimport { View } from './view'\nimport logger from '../utils/logger'\n\nexport class Navigation {\n\n\tprivate _views: View[] = []\n\tprivate _currentView: View | null = null\n\n\tregister(view: View) {\n\t\tif (this._views.find(search => search.id === view.id)) {\n\t\t\tthrow new Error(`View id ${view.id} is already registered`)\n\t\t}\n\n\t\tthis._views.push(view)\n\t}\n\n\tremove(id: string) {\n\t\tconst index = this._views.findIndex(view => view.id === id)\n\t\tif (index !== -1) {\n\t\t\tthis._views.splice(index, 1)\n\t\t}\n\t}\n\n\tget views(): View[] {\n\t\treturn this._views\n\t}\n\n\tsetActive(view: View | null) {\n\t\tthis._currentView = view\n\t}\n\n\tget active(): View | null {\n\t\treturn this._currentView\n\t}\n\n}\n\nexport const getNavigation = function(): Navigation {\n\tif (typeof window._nc_navigation === 'undefined') {\n\t\twindow._nc_navigation = new Navigation()\n\t\tlogger.debug('Navigation service initialized')\n\t}\n\n\treturn window._nc_navigation\n}\n","/**\n * @copyright Copyright (c) 2022 John Molakvoæ <skjnldsv@protonmail.com>\n *\n * @author John Molakvoæ <skjnldsv@protonmail.com>\n *\n * @license AGPL-3.0-or-later\n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see <http://www.gnu.org/licenses/>.\n *\n */\nimport { View } from './view'\nimport { Node } from '../files/node'\n\ninterface ColumnData {\n\t/** Unique column ID */\n\tid: string\n\t/** Translated column title */\n\ttitle: string\n\t/** The content of the cell. The element will be appended within */\n\trender: (node: Node, view: View) => HTMLElement\n\t/** Function used to sort Nodes between them */\n\tsort?: (nodeA: Node, nodeB: Node) => number\n\t/**\n\t * Custom summary of the column to display at the end of the list.\n\t * Will not be displayed if nothing is provided\n\t */\n\tsummary?: (node: Node[], view: View) => string\n}\n\nexport class Column implements ColumnData {\n\n\tprivate _column: ColumnData\n\n\tconstructor(column: ColumnData) {\n\t\tisValidColumn(column)\n\t\tthis._column = column\n\t}\n\n\tget id() {\n\t\treturn this._column.id\n\t}\n\n\tget title() {\n\t\treturn this._column.title\n\t}\n\n\tget render() {\n\t\treturn this._column.render\n\t}\n\n\tget sort() {\n\t\treturn this._column.sort\n\t}\n\n\tget summary() {\n\t\treturn this._column.summary\n\t}\n\n}\n\n/**\n * Typescript cannot validate an interface.\n * Please keep in sync with the Column interface requirements.\n *\n * @param {ColumnData} column the column to check\n * @return {boolean} true if the column is valid\n */\nconst isValidColumn = function(column: ColumnData): boolean {\n\tif (!column.id || typeof column.id !== 'string') {\n\t\tthrow new Error('A column id is required')\n\t}\n\n\tif (!column.title || typeof column.title !== 'string') {\n\t\tthrow new Error('A column title is required')\n\t}\n\n\tif (!column.render || typeof column.render !== 'function') {\n\t\tthrow new Error('A render function is required')\n\t}\n\n\t// Optional properties\n\tif (column.sort && typeof column.sort !== 'function') {\n\t\tthrow new Error('Column sortFunction must be a function')\n\t}\n\n\tif (column.summary && typeof column.summary !== 'function') {\n\t\tthrow new Error('Column summary must be a function')\n\t}\n\n\treturn true\n}\n","'use strict';\n\nconst nameStartChar = ':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';\nconst nameChar = nameStartChar + '\\\\-.\\\\d\\\\u00B7\\\\u0300-\\\\u036F\\\\u203F-\\\\u2040';\nconst nameRegexp = '[' + nameStartChar + '][' + nameChar + ']*'\nconst regexName = new RegExp('^' + nameRegexp + '$');\n\nconst getAllMatches = function(string, regex) {\n const matches = [];\n let match = regex.exec(string);\n while (match) {\n const allmatches = [];\n allmatches.startIndex = regex.lastIndex - match[0].length;\n const len = match.length;\n for (let index = 0; index < len; index++) {\n allmatches.push(match[index]);\n }\n matches.push(allmatches);\n match = regex.exec(string);\n }\n return matches;\n};\n\nconst isName = function(string) {\n const match = regexName.exec(string);\n return !(match === null || typeof match === 'undefined');\n};\n\nexports.isExist = function(v) {\n return typeof v !== 'undefined';\n};\n\nexports.isEmptyObject = function(obj) {\n return Object.keys(obj).length === 0;\n};\n\n/**\n * Copy all the properties of a into b.\n * @param {*} target\n * @param {*} a\n */\nexports.merge = function(target, a, arrayMode) {\n if (a) {\n const keys = Object.keys(a); // will return an array of own properties\n const len = keys.length; //don't make it inline\n for (let i = 0; i < len; i++) {\n if (arrayMode === 'strict') {\n target[keys[i]] = [ a[keys[i]] ];\n } else {\n target[keys[i]] = a[keys[i]];\n }\n }\n }\n};\n/* exports.merge =function (b,a){\n return Object.assign(b,a);\n} */\n\nexports.getValue = function(v) {\n if (exports.isExist(v)) {\n return v;\n } else {\n return '';\n }\n};\n\n// const fakeCall = function(a) {return a;};\n// const fakeCallNoReturn = function() {};\n\nexports.isName = isName;\nexports.getAllMatches = getAllMatches;\nexports.nameRegexp = nameRegexp;\n","'use strict';\n\nconst util = require('./util');\n\nconst defaultOptions = {\n allowBooleanAttributes: false, //A tag can have attributes without any value\n unpairedTags: []\n};\n\n//const tagsPattern = new RegExp(\"<\\\\/?([\\\\w:\\\\-_\\.]+)\\\\s*\\/?>\",\"g\");\nexports.validate = function (xmlData, options) {\n options = Object.assign({}, defaultOptions, options);\n\n //xmlData = xmlData.replace(/(\\r\\n|\\n|\\r)/gm,\"\");//make it single line\n //xmlData = xmlData.replace(/(^\\s*<\\?xml.*?\\?>)/g,\"\");//Remove XML starting tag\n //xmlData = xmlData.replace(/(<!DOCTYPE[\\s\\w\\\"\\.\\/\\-\\:]+(\\[.*\\])*\\s*>)/g,\"\");//Remove DOCTYPE\n const tags = [];\n let tagFound = false;\n\n //indicates that the root tag has been closed (aka. depth 0 has been reached)\n let reachedRoot = false;\n\n if (xmlData[0] === '\\ufeff') {\n // check for byte order mark (BOM)\n xmlData = xmlData.substr(1);\n }\n \n for (let i = 0; i < xmlData.length; i++) {\n\n if (xmlData[i] === '<' && xmlData[i+1] === '?') {\n i+=2;\n i = readPI(xmlData,i);\n if (i.err) return i;\n }else if (xmlData[i] === '<') {\n //starting of tag\n //read until you reach to '>' avoiding any '>' in attribute value\n let tagStartPos = i;\n i++;\n \n if (xmlData[i] === '!') {\n i = readCommentAndCDATA(xmlData, i);\n continue;\n } else {\n let closingTag = false;\n if (xmlData[i] === '/') {\n //closing tag\n closingTag = true;\n i++;\n }\n //read tagname\n let tagName = '';\n for (; i < xmlData.length &&\n xmlData[i] !== '>' &&\n xmlData[i] !== ' ' &&\n xmlData[i] !== '\\t' &&\n xmlData[i] !== '\\n' &&\n xmlData[i] !== '\\r'; i++\n ) {\n tagName += xmlData[i];\n }\n tagName = tagName.trim();\n //console.log(tagName);\n\n if (tagName[tagName.length - 1] === '/') {\n //self closing tag without attributes\n tagName = tagName.substring(0, tagName.length - 1);\n //continue;\n i--;\n }\n if (!validateTagName(tagName)) {\n let msg;\n if (tagName.trim().length === 0) {\n msg = \"Invalid space after '<'.\";\n } else {\n msg = \"Tag '\"+tagName+\"' is an invalid name.\";\n }\n return getErrorObject('InvalidTag', msg, getLineNumberForPosition(xmlData, i));\n }\n\n const result = readAttributeStr(xmlData, i);\n if (result === false) {\n return getErrorObject('InvalidAttr', \"Attributes for '\"+tagName+\"' have open quote.\", getLineNumberForPosition(xmlData, i));\n }\n let attrStr = result.value;\n i = result.index;\n\n if (attrStr[attrStr.length - 1] === '/') {\n //self closing tag\n const attrStrStart = i - attrStr.length;\n attrStr = attrStr.substring(0, attrStr.length - 1);\n const isValid = validateAttributeString(attrStr, options);\n if (isValid === true) {\n tagFound = true;\n //continue; //text may presents after self closing tag\n } else {\n //the result from the nested function returns the position of the error within the attribute\n //in order to get the 'true' error line, we need to calculate the position where the attribute begins (i - attrStr.length) and then add the position within the attribute\n //this gives us the absolute index in the entire xml, which we can use to find the line at last\n return getErrorObject(isValid.err.code, isValid.err.msg, getLineNumberForPosition(xmlData, attrStrStart + isValid.err.line));\n }\n } else if (closingTag) {\n if (!result.tagClosed) {\n return getErrorObject('InvalidTag', \"Closing tag '\"+tagName+\"' doesn't have proper closing.\", getLineNumberForPosition(xmlData, i));\n } else if (attrStr.trim().length > 0) {\n return getErrorObject('InvalidTag', \"Closing tag '\"+tagName+\"' can't have attributes or invalid starting.\", getLineNumberForPosition(xmlData, tagStartPos));\n } else {\n const otg = tags.pop();\n if (tagName !== otg.tagName) {\n let openPos = getLineNumberForPosition(xmlData, otg.tagStartPos);\n return getErrorObject('InvalidTag',\n \"Expected closing tag '\"+otg.tagName+\"' (opened in line \"+openPos.line+\", col \"+openPos.col+\") instead of closing tag '\"+tagName+\"'.\",\n getLineNumberForPosition(xmlData, tagStartPos));\n }\n\n //when there are no more tags, we reached the root level.\n if (tags.length == 0) {\n reachedRoot = true;\n }\n }\n } else {\n const isValid = validateAttributeString(attrStr, options);\n if (isValid !== true) {\n //the result from the nested function returns the position of the error within the attribute\n //in order to get the 'true' error line, we need to calculate the position where the attribute begins (i - attrStr.length) and then add the position within the attribute\n //this gives us the absolute index in the entire xml, which we can use to find the line at last\n return getErrorObject(isValid.err.code, isValid.err.msg, getLineNumberForPosition(xmlData, i - attrStr.length + isValid.err.line));\n }\n\n //if the root level has been reached before ...\n if (reachedRoot === true) {\n return getErrorObject('InvalidXml', 'Multiple possible root nodes found.', getLineNumberForPosition(xmlData, i));\n } else if(options.unpairedTags.indexOf(tagName) !== -1){\n //don't push into stack\n } else {\n tags.push({tagName, tagStartPos});\n }\n tagFound = true;\n }\n\n //skip tag text value\n //It may include comments and CDATA value\n for (i++; i < xmlData.length; i++) {\n if (xmlData[i] === '<') {\n if (xmlData[i + 1] === '!') {\n //comment or CADATA\n i++;\n i = readCommentAndCDATA(xmlData, i);\n continue;\n } else if (xmlData[i+1] === '?') {\n i = readPI(xmlData, ++i);\n if (i.err) return i;\n } else{\n break;\n }\n } else if (xmlData[i] === '&') {\n const afterAmp = validateAmpersand(xmlData, i);\n if (afterAmp == -1)\n return getErrorObject('InvalidChar', \"char '&' is not expected.\", getLineNumberForPosition(xmlData, i));\n i = afterAmp;\n }else{\n if (reachedRoot === true && !isWhiteSpace(xmlData[i])) {\n return getErrorObject('InvalidXml', \"Extra text at the end\", getLineNumberForPosition(xmlData, i));\n }\n }\n } //end of reading tag text value\n if (xmlData[i] === '<') {\n i--;\n }\n }\n } else {\n if ( isWhiteSpace(xmlData[i])) {\n continue;\n }\n return getErrorObject('InvalidChar', \"char '\"+xmlData[i]+\"' is not expected.\", getLineNumberForPosition(xmlData, i));\n }\n }\n\n if (!tagFound) {\n return getErrorObject('InvalidXml', 'Start tag expected.', 1);\n }else if (tags.length == 1) {\n return getErrorObject('InvalidTag', \"Unclosed tag '\"+tags[0].tagName+\"'.\", getLineNumberForPosition(xmlData, tags[0].tagStartPos));\n }else if (tags.length > 0) {\n return getErrorObject('InvalidXml', \"Invalid '\"+\n JSON.stringify(tags.map(t => t.tagName), null, 4).replace(/\\r?\\n/g, '')+\n \"' found.\", {line: 1, col: 1});\n }\n\n return true;\n};\n\nfunction isWhiteSpace(char){\n return char === ' ' || char === '\\t' || char === '\\n' || char === '\\r';\n}\n/**\n * Read Processing insstructions and skip\n * @param {*} xmlData\n * @param {*} i\n */\nfunction readPI(xmlData, i) {\n const start = i;\n for (; i < xmlData.length; i++) {\n if (xmlData[i] == '?' || xmlData[i] == ' ') {\n //tagname\n const tagname = xmlData.substr(start, i - start);\n if (i > 5 && tagname === 'xml') {\n return getErrorObject('InvalidXml', 'XML declaration allowed only at the start of the document.', getLineNumberForPosition(xmlData, i));\n } else if (xmlData[i] == '?' && xmlData[i + 1] == '>') {\n //check if valid attribut string\n i++;\n break;\n } else {\n continue;\n }\n }\n }\n return i;\n}\n\nfunction readCommentAndCDATA(xmlData, i) {\n if (xmlData.length > i + 5 && xmlData[i + 1] === '-' && xmlData[i + 2] === '-') {\n //comment\n for (i += 3; i < xmlData.length; i++) {\n if (xmlData[i] === '-' && xmlData[i + 1] === '-' && xmlData[i + 2] === '>') {\n i += 2;\n break;\n }\n }\n } else if (\n xmlData.length > i + 8 &&\n xmlData[i + 1] === 'D' &&\n xmlData[i + 2] === 'O' &&\n xmlData[i + 3] === 'C' &&\n xmlData[i + 4] === 'T' &&\n xmlData[i + 5] === 'Y' &&\n xmlData[i + 6] === 'P' &&\n xmlData[i + 7] === 'E'\n ) {\n let angleBracketsCount = 1;\n for (i += 8; i < xmlData.length; i++) {\n if (xmlData[i] === '<') {\n angleBracketsCount++;\n } else if (xmlData[i] === '>') {\n angleBracketsCount--;\n if (angleBracketsCount === 0) {\n break;\n }\n }\n }\n } else if (\n xmlData.length > i + 9 &&\n xmlData[i + 1] === '[' &&\n xmlData[i + 2] === 'C' &&\n xmlData[i + 3] === 'D' &&\n xmlData[i + 4] === 'A' &&\n xmlData[i + 5] === 'T' &&\n xmlData[i + 6] === 'A' &&\n xmlData[i + 7] === '['\n ) {\n for (i += 8; i < xmlData.length; i++) {\n if (xmlData[i] === ']' && xmlData[i + 1] === ']' && xmlData[i + 2] === '>') {\n i += 2;\n break;\n }\n }\n }\n\n return i;\n}\n\nconst doubleQuote = '\"';\nconst singleQuote = \"'\";\n\n/**\n * Keep reading xmlData until '<' is found outside the attribute value.\n * @param {string} xmlData\n * @param {number} i\n */\nfunction readAttributeStr(xmlData, i) {\n let attrStr = '';\n let startChar = '';\n let tagClosed = false;\n for (; i < xmlData.length; i++) {\n if (xmlData[i] === doubleQuote || xmlData[i] === singleQuote) {\n if (startChar === '') {\n startChar = xmlData[i];\n } else if (startChar !== xmlData[i]) {\n //if vaue is enclosed with double quote then single quotes are allowed inside the value and vice versa\n } else {\n startChar = '';\n }\n } else if (xmlData[i] === '>') {\n if (startChar === '') {\n tagClosed = true;\n break;\n }\n }\n attrStr += xmlData[i];\n }\n if (startChar !== '') {\n return false;\n }\n\n return {\n value: attrStr,\n index: i,\n tagClosed: tagClosed\n };\n}\n\n/**\n * Select all the attributes whether valid or invalid.\n */\nconst validAttrStrRegxp = new RegExp('(\\\\s*)([^\\\\s=]+)(\\\\s*=)?(\\\\s*([\\'\"])(([\\\\s\\\\S])*?)\\\\5)?', 'g');\n\n//attr, =\"sd\", a=\"amit's\", a=\"sd\"b=\"saf\", ab cd=\"\"\n\nfunction validateAttributeString(attrStr, options) {\n //console.log(\"start:\"+attrStr+\":end\");\n\n //if(attrStr.trim().length === 0) return true; //empty string\n\n const matches = util.getAllMatches(attrStr, validAttrStrRegxp);\n const attrNames = {};\n\n for (let i = 0; i < matches.length; i++) {\n if (matches[i][1].length === 0) {\n //nospace before attribute name: a=\"sd\"b=\"saf\"\n return getErrorObject('InvalidAttr', \"Attribute '\"+matches[i][2]+\"' has no space in starting.\", getPositionFromMatch(matches[i]))\n } else if (matches[i][3] !== undefined && matches[i][4] === undefined) {\n return getErrorObject('InvalidAttr', \"Attribute '\"+matches[i][2]+\"' is without value.\", getPositionFromMatch(matches[i]));\n } else if (matches[i][3] === undefined && !options.allowBooleanAttributes) {\n //independent attribute: ab\n return getErrorObject('InvalidAttr', \"boolean attribute '\"+matches[i][2]+\"' is not allowed.\", getPositionFromMatch(matches[i]));\n }\n /* else if(matches[i][6] === undefined){//attribute without value: ab=\n return { err: { code:\"InvalidAttr\",msg:\"attribute \" + matches[i][2] + \" has no value assigned.\"}};\n } */\n const attrName = matches[i][2];\n if (!validateAttrName(attrName)) {\n return getErrorObject('InvalidAttr', \"Attribute '\"+attrName+\"' is an invalid name.\", getPositionFromMatch(matches[i]));\n }\n if (!attrNames.hasOwnProperty(attrName)) {\n //check for duplicate attribute.\n attrNames[attrName] = 1;\n } else {\n return getErrorObject('InvalidAttr', \"Attribute '\"+attrName+\"' is repeated.\", getPositionFromMatch(matches[i]));\n }\n }\n\n return true;\n}\n\nfunction validateNumberAmpersand(xmlData, i) {\n let re = /\\d/;\n if (xmlData[i] === 'x') {\n i++;\n re = /[\\da-fA-F]/;\n }\n for (; i < xmlData.length; i++) {\n if (xmlData[i] === ';')\n return i;\n if (!xmlData[i].match(re))\n break;\n }\n return -1;\n}\n\nfunction validateAmpersand(xmlData, i) {\n // https://www.w3.org/TR/xml/#dt-charref\n i++;\n if (xmlData[i] === ';')\n return -1;\n if (xmlData[i] === '#') {\n i++;\n return validateNumberAmpersand(xmlData, i);\n }\n let count = 0;\n for (; i < xmlData.length; i++, count++) {\n if (xmlData[i].match(/\\w/) && count < 20)\n continue;\n if (xmlData[i] === ';')\n break;\n return -1;\n }\n return i;\n}\n\nfunction getErrorObject(code, message, lineNumber) {\n return {\n err: {\n code: code,\n msg: message,\n line: lineNumber.line || lineNumber,\n col: lineNumber.col,\n },\n };\n}\n\nfunction validateAttrName(attrName) {\n return util.isName(attrName);\n}\n\n// const startsWithXML = /^xml/i;\n\nfunction validateTagName(tagname) {\n return util.isName(tagname) /* && !tagname.match(startsWithXML) */;\n}\n\n//this function returns the line number for the character at the given index\nfunction getLineNumberForPosition(xmlData, index) {\n const lines = xmlData.substring(0, index).split(/\\r?\\n/);\n return {\n line: lines.length,\n\n // column number is last line's length + 1, because column numbering starts at 1:\n col: lines[lines.length - 1].length + 1\n };\n}\n\n//this function returns the position of the first character of match within attrStr\nfunction getPositionFromMatch(match) {\n return match.startIndex + match[1].length;\n}\n","\nconst defaultOptions = {\n preserveOrder: false,\n attributeNamePrefix: '@_',\n attributesGroupName: false,\n textNodeName: '#text',\n ignoreAttributes: true,\n removeNSPrefix: false, // remove NS from tag name or attribute name if true\n allowBooleanAttributes: false, //a tag can have attributes without any value\n //ignoreRootElement : false,\n parseTagValue: true,\n parseAttributeValue: false,\n trimValues: true, //Trim string values of tag and attributes\n cdataPropName: false,\n numberParseOptions: {\n hex: true,\n leadingZeros: true,\n eNotation: true\n },\n tagValueProcessor: function(tagName, val) {\n return val;\n },\n attributeValueProcessor: function(attrName, val) {\n return val;\n },\n stopNodes: [], //nested tags will not be parsed even for errors\n alwaysCreateTextNode: false,\n isArray: () => false,\n commentPropName: false,\n unpairedTags: [],\n processEntities: true,\n htmlEntities: false,\n ignoreDeclaration: false,\n ignorePiTags: false,\n transformTagName: false,\n transformAttributeName: false,\n updateTag: function(tagName, jPath, attrs){\n return tagName\n },\n // skipEmptyListItem: false\n};\n \nconst buildOptions = function(options) {\n return Object.assign({}, defaultOptions, options);\n};\n\nexports.buildOptions = buildOptions;\nexports.defaultOptions = defaultOptions;","'use strict';\n\nclass XmlNode{\n constructor(tagname) {\n this.tagname = tagname;\n this.child = []; //nested tags, text, cdata, comments in order\n this[\":@\"] = {}; //attributes map\n }\n add(key,val){\n // this.child.push( {name : key, val: val, isCdata: isCdata });\n if(key === \"__proto__\") key = \"#__proto__\";\n this.child.push( {[key]: val });\n }\n addChild(node) {\n if(node.tagname === \"__proto__\") node.tagname = \"#__proto__\";\n if(node[\":@\"] && Object.keys(node[\":@\"]).length > 0){\n this.child.push( { [node.tagname]: node.child, [\":@\"]: node[\":@\"] });\n }else{\n this.child.push( { [node.tagname]: node.child });\n }\n };\n};\n\n\nmodule.exports = XmlNode;","const util = require('../util');\n\n//TODO: handle comments\nfunction readDocType(xmlData, i){\n \n const entities = {};\n if( xmlData[i + 3] === 'O' &&\n xmlData[i + 4] === 'C' &&\n xmlData[i + 5] === 'T' &&\n xmlData[i + 6] === 'Y' &&\n xmlData[i + 7] === 'P' &&\n xmlData[i + 8] === 'E')\n { \n i = i+9;\n let angleBracketsCount = 1;\n let hasBody = false, comment = false;\n let exp = \"\";\n for(;i<xmlData.length;i++){\n if (xmlData[i] === '<' && !comment) { //Determine the tag type\n if( hasBody && isEntity(xmlData, i)){\n i += 7; \n [entityName, val,i] = readEntityExp(xmlData,i+1);\n if(val.indexOf(\"&\") === -1) //Parameter entities are not supported\n entities[ validateEntityName(entityName) ] = {\n regx : RegExp( `&${entityName};`,\"g\"),\n val: val\n };\n }\n else if( hasBody && isElement(xmlData, i)) i += 8;//Not supported\n else if( hasBody && isAttlist(xmlData, i)) i += 8;//Not supported\n else if( hasBody && isNotation(xmlData, i)) i += 9;//Not supported\n else if( isComment) comment = true;\n else throw new Error(\"Invalid DOCTYPE\");\n\n angleBracketsCount++;\n exp = \"\";\n } else if (xmlData[i] === '>') { //Read tag content\n if(comment){\n if( xmlData[i - 1] === \"-\" && xmlData[i - 2] === \"-\"){\n comment = false;\n angleBracketsCount--;\n }\n }else{\n angleBracketsCount--;\n }\n if (angleBracketsCount === 0) {\n break;\n }\n }else if( xmlData[i] === '['){\n hasBody = true;\n }else{\n exp += xmlData[i];\n }\n }\n if(angleBracketsCount !== 0){\n throw new Error(`Unclosed DOCTYPE`);\n }\n }else{\n throw new Error(`Invalid Tag instead of DOCTYPE`);\n }\n return {entities, i};\n}\n\nfunction readEntityExp(xmlData,i){\n //External entities are not supported\n // <!ENTITY ext SYSTEM \"http://normal-website.com\" >\n\n //Parameter entities are not supported\n // <!ENTITY entityname \"&anotherElement;\">\n\n //Internal entities are supported\n // <!ENTITY entityname \"replacement text\">\n \n //read EntityName\n let entityName = \"\";\n for (; i < xmlData.length && (xmlData[i] !== \"'\" && xmlData[i] !== '\"' ); i++) {\n // if(xmlData[i] === \" \") continue;\n // else \n entityName += xmlData[i];\n }\n entityName = entityName.trim();\n if(entityName.indexOf(\" \") !== -1) throw new Error(\"External entites are not supported\");\n\n //read Entity Value\n const startChar = xmlData[i++];\n let val = \"\"\n for (; i < xmlData.length && xmlData[i] !== startChar ; i++) {\n val += xmlData[i];\n }\n return [entityName, val, i];\n}\n\nfunction isComment(xmlData, i){\n if(xmlData[i+1] === '!' &&\n xmlData[i+2] === '-' &&\n xmlData[i+3] === '-') return true\n return false\n}\nfunction isEntity(xmlData, i){\n if(xmlData[i+1] === '!' &&\n xmlData[i+2] === 'E' &&\n xmlData[i+3] === 'N' &&\n xmlData[i+4] === 'T' &&\n xmlData[i+5] === 'I' &&\n xmlData[i+6] === 'T' &&\n xmlData[i+7] === 'Y') return true\n return false\n}\nfunction isElement(xmlData, i){\n if(xmlData[i+1] === '!' &&\n xmlData[i+2] === 'E' &&\n xmlData[i+3] === 'L' &&\n xmlData[i+4] === 'E' &&\n xmlData[i+5] === 'M' &&\n xmlData[i+6] === 'E' &&\n xmlData[i+7] === 'N' &&\n xmlData[i+8] === 'T') return true\n return false\n}\n\nfunction isAttlist(xmlData, i){\n if(xmlData[i+1] === '!' &&\n xmlData[i+2] === 'A' &&\n xmlData[i+3] === 'T' &&\n xmlData[i+4] === 'T' &&\n xmlData[i+5] === 'L' &&\n xmlData[i+6] === 'I' &&\n xmlData[i+7] === 'S' &&\n xmlData[i+8] === 'T') return true\n return false\n}\nfunction isNotation(xmlData, i){\n if(xmlData[i+1] === '!' &&\n xmlData[i+2] === 'N' &&\n xmlData[i+3] === 'O' &&\n xmlData[i+4] === 'T' &&\n xmlData[i+5] === 'A' &&\n xmlData[i+6] === 'T' &&\n xmlData[i+7] === 'I' &&\n xmlData[i+8] === 'O' &&\n xmlData[i+9] === 'N') return true\n return false\n}\n\nfunction validateEntityName(name){\n if (util.isName(name))\n\treturn name;\n else\n throw new Error(`Invalid entity name ${name}`);\n}\n\nmodule.exports = readDocType;\n","const hexRegex = /^[-+]?0x[a-fA-F0-9]+$/;\nconst numRegex = /^([\\-\\+])?(0*)(\\.[0-9]+([eE]\\-?[0-9]+)?|[0-9]+(\\.[0-9]+([eE]\\-?[0-9]+)?)?)$/;\n// const octRegex = /0x[a-z0-9]+/;\n// const binRegex = /0x[a-z0-9]+/;\n\n\n//polyfill\nif (!Number.parseInt && window.parseInt) {\n Number.parseInt = window.parseInt;\n}\nif (!Number.parseFloat && window.parseFloat) {\n Number.parseFloat = window.parseFloat;\n}\n\n \nconst consider = {\n hex : true,\n leadingZeros: true,\n decimalPoint: \"\\.\",\n eNotation: true\n //skipLike: /regex/\n};\n\nfunction toNumber(str, options = {}){\n // const options = Object.assign({}, consider);\n // if(opt.leadingZeros === false){\n // options.leadingZeros = false;\n // }else if(opt.hex === false){\n // options.hex = false;\n // }\n\n options = Object.assign({}, consider, options );\n if(!str || typeof str !== \"string\" ) return str;\n \n let trimmedStr = str.trim();\n // if(trimmedStr === \"0.0\") return 0;\n // else if(trimmedStr === \"+0.0\") return 0;\n // else if(trimmedStr === \"-0.0\") return -0;\n\n if(options.skipLike !== undefined && options.skipLike.test(trimmedStr)) return str;\n else if (options.hex && hexRegex.test(trimmedStr)) {\n return Number.parseInt(trimmedStr, 16);\n // } else if (options.parseOct && octRegex.test(str)) {\n // return Number.parseInt(val, 8);\n // }else if (options.parseBin && binRegex.test(str)) {\n // return Number.parseInt(val, 2);\n }else{\n //separate negative sign, leading zeros, and rest number\n const match = numRegex.exec(trimmedStr);\n if(match){\n const sign = match[1];\n const leadingZeros = match[2];\n let numTrimmedByZeros = trimZeros(match[3]); //complete num without leading zeros\n //trim ending zeros for floating number\n \n const eNotation = match[4] || match[6];\n if(!options.leadingZeros && leadingZeros.length > 0 && sign && trimmedStr[2] !== \".\") return str; //-0123\n else if(!options.leadingZeros && leadingZeros.length > 0 && !sign && trimmedStr[1] !== \".\") return str; //0123\n else{//no leading zeros or leading zeros are allowed\n const num = Number(trimmedStr);\n const numStr = \"\" + num;\n if(numStr.search(/[eE]/) !== -1){ //given number is long and parsed to eNotation\n if(options.eNotation) return num;\n else return str;\n }else if(eNotation){ //given number has enotation\n if(options.eNotation) return num;\n else return str;\n }else if(trimmedStr.indexOf(\".\") !== -1){ //floating number\n // const decimalPart = match[5].substr(1);\n // const intPart = trimmedStr.substr(0,trimmedStr.indexOf(\".\"));\n\n \n // const p = numStr.indexOf(\".\");\n // const givenIntPart = numStr.substr(0,p);\n // const givenDecPart = numStr.substr(p+1);\n if(numStr === \"0\" && (numTrimmedByZeros === \"\") ) return num; //0.0\n else if(numStr === numTrimmedByZeros) return num; //0.456. 0.79000\n else if( sign && numStr === \"-\"+numTrimmedByZeros) return num;\n else return str;\n }\n \n if(leadingZeros){\n // if(numTrimmedByZeros === numStr){\n // if(options.leadingZeros) return num;\n // else return str;\n // }else return str;\n if(numTrimmedByZeros === numStr) return num;\n else if(sign+numTrimmedByZeros === numStr) return num;\n else return str;\n }\n\n if(trimmedStr === numStr) return num;\n else if(trimmedStr === sign+numStr) return num;\n // else{\n // //number with +/- sign\n // trimmedStr.test(/[-+][0-9]);\n\n // }\n return str;\n }\n // else if(!eNotation && trimmedStr && trimmedStr !== Number(trimmedStr) ) return str;\n \n }else{ //non-numeric string\n return str;\n }\n }\n}\n\n/**\n * \n * @param {string} numStr without leading zeros\n * @returns \n */\nfunction trimZeros(numStr){\n if(numStr && numStr.indexOf(\".\") !== -1){//float\n numStr = numStr.replace(/0+$/, \"\"); //remove ending zeros\n if(numStr === \".\") numStr = \"0\";\n else if(numStr[0] === \".\") numStr = \"0\"+numStr;\n else if(numStr[numStr.length-1] === \".\") numStr = numStr.substr(0,numStr.length-1);\n return numStr;\n }\n return numStr;\n}\nmodule.exports = toNumber\n","'use strict';\n///@ts-check\n\nconst util = require('../util');\nconst xmlNode = require('./xmlNode');\nconst readDocType = require(\"./DocTypeReader\");\nconst toNumber = require(\"strnum\");\n\n// const regx =\n// '<((!\\\\[CDATA\\\\[([\\\\s\\\\S]*?)(]]>))|((NAME:)?(NAME))([^>]*)>|((\\\\/)(NAME)\\\\s*>))([^<]*)'\n// .replace(/NAME/g, util.nameRegexp);\n\n//const tagsRegx = new RegExp(\"<(\\\\/?[\\\\w:\\\\-\\._]+)([^>]*)>(\\\\s*\"+cdataRegx+\")*([^<]+)?\",\"g\");\n//const tagsRegx = new RegExp(\"<(\\\\/?)((\\\\w*:)?([\\\\w:\\\\-\\._]+))([^>]*)>([^<]*)(\"+cdataRegx+\"([^<]*))*([^<]+)?\",\"g\");\n\nclass OrderedObjParser{\n constructor(options){\n this.options = options;\n this.currentNode = null;\n this.tagsNodeStack = [];\n this.docTypeEntities = {};\n this.lastEntities = {\n \"apos\" : { regex: /&(apos|#39|#x27);/g, val : \"'\"},\n \"gt\" : { regex: /&(gt|#62|#x3E);/g, val : \">\"},\n \"lt\" : { regex: /&(lt|#60|#x3C);/g, val : \"<\"},\n \"quot\" : { regex: /&(quot|#34|#x22);/g, val : \"\\\"\"},\n };\n this.ampEntity = { regex: /&(amp|#38|#x26);/g, val : \"&\"};\n this.htmlEntities = {\n \"space\": { regex: /&(nbsp|#160);/g, val: \" \" },\n // \"lt\" : { regex: /&(lt|#60);/g, val: \"<\" },\n // \"gt\" : { regex: /&(gt|#62);/g, val: \">\" },\n // \"amp\" : { regex: /&(amp|#38);/g, val: \"&\" },\n // \"quot\" : { regex: /&(quot|#34);/g, val: \"\\\"\" },\n // \"apos\" : { regex: /&(apos|#39);/g, val: \"'\" },\n \"cent\" : { regex: /&(cent|#162);/g, val: \"¢\" },\n \"pound\" : { regex: /&(pound|#163);/g, val: \"£\" },\n \"yen\" : { regex: /&(yen|#165);/g, val: \"¥\" },\n \"euro\" : { regex: /&(euro|#8364);/g, val: \"€\" },\n \"copyright\" : { regex: /&(copy|#169);/g, val: \"©\" },\n \"reg\" : { regex: /&(reg|#174);/g, val: \"®\" },\n \"inr\" : { regex: /&(inr|#8377);/g, val: \"₹\" },\n \"num_dec\": { regex: /&#([0-9]{1,7});/g, val : (_, str) => String.fromCharCode(Number.parseInt(str, 10)) },\n \"num_hex\": { regex: /&#x([0-9a-fA-F]{1,6});/g, val : (_, str) => String.fromCharCode(Number.parseInt(str, 16)) },\n };\n this.addExternalEntities = addExternalEntities;\n this.parseXml = parseXml;\n this.parseTextData = parseTextData;\n this.resolveNameSpace = resolveNameSpace;\n this.buildAttributesMap = buildAttributesMap;\n this.isItStopNode = isItStopNode;\n this.replaceEntitiesValue = replaceEntitiesValue;\n this.readStopNodeData = readStopNodeData;\n this.saveTextToParentTag = saveTextToParentTag;\n this.addChild = addChild;\n }\n\n}\n\nfunction addExternalEntities(externalEntities){\n const entKeys = Object.keys(externalEntities);\n for (let i = 0; i < entKeys.length; i++) {\n const ent = entKeys[i];\n this.lastEntities[ent] = {\n regex: new RegExp(\"&\"+ent+\";\",\"g\"),\n val : externalEntities[ent]\n }\n }\n}\n\n/**\n * @param {string} val\n * @param {string} tagName\n * @param {string} jPath\n * @param {boolean} dontTrim\n * @param {boolean} hasAttributes\n * @param {boolean} isLeafNode\n * @param {boolean} escapeEntities\n */\nfunction parseTextData(val, tagName, jPath, dontTrim, hasAttributes, isLeafNode, escapeEntities) {\n if (val !== undefined) {\n if (this.options.trimValues && !dontTrim) {\n val = val.trim();\n }\n if(val.length > 0){\n if(!escapeEntities) val = this.replaceEntitiesValue(val);\n \n const newval = this.options.tagValueProcessor(tagName, val, jPath, hasAttributes, isLeafNode);\n if(newval === null || newval === undefined){\n //don't parse\n return val;\n }else if(typeof newval !== typeof val || newval !== val){\n //overwrite\n return newval;\n }else if(this.options.trimValues){\n return parseValue(val, this.options.parseTagValue, this.options.numberParseOptions);\n }else{\n const trimmedVal = val.trim();\n if(trimmedVal === val){\n return parseValue(val, this.options.parseTagValue, this.options.numberParseOptions);\n }else{\n return val;\n }\n }\n }\n }\n}\n\nfunction resolveNameSpace(tagname) {\n if (this.options.removeNSPrefix) {\n const tags = tagname.split(':');\n const prefix = tagname.charAt(0) === '/' ? '/' : '';\n if (tags[0] === 'xmlns') {\n return '';\n }\n if (tags.length === 2) {\n tagname = prefix + tags[1];\n }\n }\n return tagname;\n}\n\n//TODO: change regex to capture NS\n//const attrsRegx = new RegExp(\"([\\\\w\\\\-\\\\.\\\\:]+)\\\\s*=\\\\s*(['\\\"])((.|\\n)*?)\\\\2\",\"gm\");\nconst attrsRegx = new RegExp('([^\\\\s=]+)\\\\s*(=\\\\s*([\\'\"])([\\\\s\\\\S]*?)\\\\3)?', 'gm');\n\nfunction buildAttributesMap(attrStr, jPath, tagName) {\n if (!this.options.ignoreAttributes && typeof attrStr === 'string') {\n // attrStr = attrStr.replace(/\\r?\\n/g, ' ');\n //attrStr = attrStr || attrStr.trim();\n\n const matches = util.getAllMatches(attrStr, attrsRegx);\n const len = matches.length; //don't make it inline\n const attrs = {};\n for (let i = 0; i < len; i++) {\n const attrName = this.resolveNameSpace(matches[i][1]);\n let oldVal = matches[i][4];\n let aName = this.options.attributeNamePrefix + attrName;\n if (attrName.length) {\n if (this.options.transformAttributeName) {\n aName = this.options.transformAttributeName(aName);\n }\n if(aName === \"__proto__\") aName = \"#__proto__\";\n if (oldVal !== undefined) {\n if (this.options.trimValues) {\n oldVal = oldVal.trim();\n }\n oldVal = this.replaceEntitiesValue(oldVal);\n const newVal = this.options.attributeValueProcessor(attrName, oldVal, jPath);\n if(newVal === null || newVal === undefined){\n //don't parse\n attrs[aName] = oldVal;\n }else if(typeof newVal !== typeof oldVal || newVal !== oldVal){\n //overwrite\n attrs[aName] = newVal;\n }else{\n //parse\n attrs[aName] = parseValue(\n oldVal,\n this.options.parseAttributeValue,\n this.options.numberParseOptions\n );\n }\n } else if (this.options.allowBooleanAttributes) {\n attrs[aName] = true;\n }\n }\n }\n if (!Object.keys(attrs).length) {\n return;\n }\n if (this.options.attributesGroupName) {\n const attrCollection = {};\n attrCollection[this.options.attributesGroupName] = attrs;\n return attrCollection;\n }\n return attrs\n }\n}\n\nconst parseXml = function(xmlData) {\n xmlData = xmlData.replace(/\\r\\n?/g, \"\\n\"); //TODO: remove this line\n const xmlObj = new xmlNode('!xml');\n let currentNode = xmlObj;\n let textData = \"\";\n let jPath = \"\";\n for(let i=0; i< xmlData.length; i++){//for each char in XML data\n const ch = xmlData[i];\n if(ch === '<'){\n // const nextIndex = i+1;\n // const _2ndChar = xmlData[nextIndex];\n if( xmlData[i+1] === '/') {//Closing Tag\n const closeIndex = findClosingIndex(xmlData, \">\", i, \"Closing Tag is not closed.\")\n let tagName = xmlData.substring(i+2,closeIndex).trim();\n\n if(this.options.removeNSPrefix){\n const colonIndex = tagName.indexOf(\":\");\n if(colonIndex !== -1){\n tagName = tagName.substr(colonIndex+1);\n }\n }\n\n if(this.options.transformTagName) {\n tagName = this.options.transformTagName(tagName);\n }\n\n if(currentNode){\n textData = this.saveTextToParentTag(textData, currentNode, jPath);\n }\n\n //check if last tag of nested tag was unpaired tag\n const lastTagName = jPath.substring(jPath.lastIndexOf(\".\")+1);\n if(tagName && this.options.unpairedTags.indexOf(tagName) !== -1 ){\n throw new Error(`Unpaired tag can not be used as closing tag: </${tagName}>`);\n }\n let propIndex = 0\n if(lastTagName && this.options.unpairedTags.indexOf(lastTagName) !== -1 ){\n propIndex = jPath.lastIndexOf('.', jPath.lastIndexOf('.')-1)\n this.tagsNodeStack.pop();\n }else{\n propIndex = jPath.lastIndexOf(\".\");\n }\n jPath = jPath.substring(0, propIndex);\n\n currentNode = this.tagsNodeStack.pop();//avoid recursion, set the parent tag scope\n textData = \"\";\n i = closeIndex;\n } else if( xmlData[i+1] === '?') {\n\n let tagData = readTagExp(xmlData,i, false, \"?>\");\n if(!tagData) throw new Error(\"Pi Tag is not closed.\");\n\n textData = this.saveTextToParentTag(textData, currentNode, jPath);\n if( (this.options.ignoreDeclaration && tagData.tagName === \"?xml\") || this.options.ignorePiTags){\n\n }else{\n \n const childNode = new xmlNode(tagData.tagName);\n childNode.add(this.options.textNodeName, \"\");\n \n if(tagData.tagName !== tagData.tagExp && tagData.attrExpPresent){\n childNode[\":@\"] = this.buildAttributesMap(tagData.tagExp, jPath, tagData.tagName);\n }\n this.addChild(currentNode, childNode, jPath)\n\n }\n\n\n i = tagData.closeIndex + 1;\n } else if(xmlData.substr(i + 1, 3) === '!--') {\n const endIndex = findClosingIndex(xmlData, \"-->\", i+4, \"Comment is not closed.\")\n if(this.options.commentPropName){\n const comment = xmlData.substring(i + 4, endIndex - 2);\n\n textData = this.saveTextToParentTag(textData, currentNode, jPath);\n\n currentNode.add(this.options.commentPropName, [ { [this.options.textNodeName] : comment } ]);\n }\n i = endIndex;\n } else if( xmlData.substr(i + 1, 2) === '!D') {\n const result = readDocType(xmlData, i);\n this.docTypeEntities = result.entities;\n i = result.i;\n }else if(xmlData.substr(i + 1, 2) === '![') {\n const closeIndex = findClosingIndex(xmlData, \"]]>\", i, \"CDATA is not closed.\") - 2;\n const tagExp = xmlData.substring(i + 9,closeIndex);\n\n textData = this.saveTextToParentTag(textData, currentNode, jPath);\n\n let val = this.parseTextData(tagExp, currentNode.tagname, jPath, true, false, true, true);\n if(val == undefined) val = \"\";\n\n //cdata should be set even if it is 0 length string\n if(this.options.cdataPropName){\n currentNode.add(this.options.cdataPropName, [ { [this.options.textNodeName] : tagExp } ]);\n }else{\n currentNode.add(this.options.textNodeName, val);\n }\n \n i = closeIndex + 2;\n }else {//Opening tag\n let result = readTagExp(xmlData,i, this.options.removeNSPrefix);\n let tagName= result.tagName;\n const rawTagName = result.rawTagName;\n let tagExp = result.tagExp;\n let attrExpPresent = result.attrExpPresent;\n let closeIndex = result.closeIndex;\n\n if (this.options.transformTagName) {\n tagName = this.options.transformTagName(tagName);\n }\n \n //save text as child node\n if (currentNode && textData) {\n if(currentNode.tagname !== '!xml'){\n //when nested tag is found\n textData = this.saveTextToParentTag(textData, currentNode, jPath, false);\n }\n }\n\n //check if last tag was unpaired tag\n const lastTag = currentNode;\n if(lastTag && this.options.unpairedTags.indexOf(lastTag.tagname) !== -1 ){\n currentNode = this.tagsNodeStack.pop();\n jPath = jPath.substring(0, jPath.lastIndexOf(\".\"));\n }\n if(tagName !== xmlObj.tagname){\n jPath += jPath ? \".\" + tagName : tagName;\n }\n if (this.isItStopNode(this.options.stopNodes, jPath, tagName)) {\n let tagContent = \"\";\n //self-closing tag\n if(tagExp.length > 0 && tagExp.lastIndexOf(\"/\") === tagExp.length - 1){\n i = result.closeIndex;\n }\n //unpaired tag\n else if(this.options.unpairedTags.indexOf(tagName) !== -1){\n i = result.closeIndex;\n }\n //normal tag\n else{\n //read until closing tag is found\n const result = this.readStopNodeData(xmlData, rawTagName, closeIndex + 1);\n if(!result) throw new Error(`Unexpected end of ${rawTagName}`);\n i = result.i;\n tagContent = result.tagContent;\n }\n\n const childNode = new xmlNode(tagName);\n if(tagName !== tagExp && attrExpPresent){\n childNode[\":@\"] = this.buildAttributesMap(tagExp, jPath, tagName);\n }\n if(tagContent) {\n tagContent = this.parseTextData(tagContent, tagName, jPath, true, attrExpPresent, true, true);\n }\n \n jPath = jPath.substr(0, jPath.lastIndexOf(\".\"));\n childNode.add(this.options.textNodeName, tagContent);\n \n this.addChild(currentNode, childNode, jPath)\n }else{\n //selfClosing tag\n if(tagExp.length > 0 && tagExp.lastIndexOf(\"/\") === tagExp.length - 1){\n if(tagName[tagName.length - 1] === \"/\"){ //remove trailing '/'\n tagName = tagName.substr(0, tagName.length - 1);\n jPath = jPath.substr(0, jPath.length - 1);\n tagExp = tagName;\n }else{\n tagExp = tagExp.substr(0, tagExp.length - 1);\n }\n \n if(this.options.transformTagName) {\n tagName = this.options.transformTagName(tagName);\n }\n\n const childNode = new xmlNode(tagName);\n if(tagName !== tagExp && attrExpPresent){\n childNode[\":@\"] = this.buildAttributesMap(tagExp, jPath, tagName);\n }\n this.addChild(currentNode, childNode, jPath)\n jPath = jPath.substr(0, jPath.lastIndexOf(\".\"));\n }\n //opening tag\n else{\n const childNode = new xmlNode( tagName);\n this.tagsNodeStack.push(currentNode);\n \n if(tagName !== tagExp && attrExpPresent){\n childNode[\":@\"] = this.buildAttributesMap(tagExp, jPath, tagName);\n }\n this.addChild(currentNode, childNode, jPath)\n currentNode = childNode;\n }\n textData = \"\";\n i = closeIndex;\n }\n }\n }else{\n textData += xmlData[i];\n }\n }\n return xmlObj.child;\n}\n\nfunction addChild(currentNode, childNode, jPath){\n const result = this.options.updateTag(childNode.tagname, jPath, childNode[\":@\"])\n if(result === false){\n }else if(typeof result === \"string\"){\n childNode.tagname = result\n currentNode.addChild(childNode);\n }else{\n currentNode.addChild(childNode);\n }\n}\n\nconst replaceEntitiesValue = function(val){\n\n if(this.options.processEntities){\n for(let entityName in this.docTypeEntities){\n const entity = this.docTypeEntities[entityName];\n val = val.replace( entity.regx, entity.val);\n }\n for(let entityName in this.lastEntities){\n const entity = this.lastEntities[entityName];\n val = val.replace( entity.regex, entity.val);\n }\n if(this.options.htmlEntities){\n for(let entityName in this.htmlEntities){\n const entity = this.htmlEntities[entityName];\n val = val.replace( entity.regex, entity.val);\n }\n }\n val = val.replace( this.ampEntity.regex, this.ampEntity.val);\n }\n return val;\n}\nfunction saveTextToParentTag(textData, currentNode, jPath, isLeafNode) {\n if (textData) { //store previously collected data as textNode\n if(isLeafNode === undefined) isLeafNode = Object.keys(currentNode.child).length === 0\n \n textData = this.parseTextData(textData,\n currentNode.tagname,\n jPath,\n false,\n currentNode[\":@\"] ? Object.keys(currentNode[\":@\"]).length !== 0 : false,\n isLeafNode);\n\n if (textData !== undefined && textData !== \"\")\n currentNode.add(this.options.textNodeName, textData);\n textData = \"\";\n }\n return textData;\n}\n\n//TODO: use jPath to simplify the logic\n/**\n * \n * @param {string[]} stopNodes \n * @param {string} jPath\n * @param {string} currentTagName \n */\nfunction isItStopNode(stopNodes, jPath, currentTagName){\n const allNodesExp = \"*.\" + currentTagName;\n for (const stopNodePath in stopNodes) {\n const stopNodeExp = stopNodes[stopNodePath];\n if( allNodesExp === stopNodeExp || jPath === stopNodeExp ) return true;\n }\n return false;\n}\n\n/**\n * Returns the tag Expression and where it is ending handling single-double quotes situation\n * @param {string} xmlData \n * @param {number} i starting index\n * @returns \n */\nfunction tagExpWithClosingIndex(xmlData, i, closingChar = \">\"){\n let attrBoundary;\n let tagExp = \"\";\n for (let index = i; index < xmlData.length; index++) {\n let ch = xmlData[index];\n if (attrBoundary) {\n if (ch === attrBoundary) attrBoundary = \"\";//reset\n } else if (ch === '\"' || ch === \"'\") {\n attrBoundary = ch;\n } else if (ch === closingChar[0]) {\n if(closingChar[1]){\n if(xmlData[index + 1] === closingChar[1]){\n return {\n data: tagExp,\n index: index\n }\n }\n }else{\n return {\n data: tagExp,\n index: index\n }\n }\n } else if (ch === '\\t') {\n ch = \" \"\n }\n tagExp += ch;\n }\n}\n\nfunction findClosingIndex(xmlData, str, i, errMsg){\n const closingIndex = xmlData.indexOf(str, i);\n if(closingIndex === -1){\n throw new Error(errMsg)\n }else{\n return closingIndex + str.length - 1;\n }\n}\n\nfunction readTagExp(xmlData,i, removeNSPrefix, closingChar = \">\"){\n const result = tagExpWithClosingIndex(xmlData, i+1, closingChar);\n if(!result) return;\n let tagExp = result.data;\n const closeIndex = result.index;\n const separatorIndex = tagExp.search(/\\s/);\n let tagName = tagExp;\n let attrExpPresent = true;\n if(separatorIndex !== -1){//separate tag name and attributes expression\n tagName = tagExp.substring(0, separatorIndex);\n tagExp = tagExp.substring(separatorIndex + 1).trimStart();\n }\n\n const rawTagName = tagName;\n if(removeNSPrefix){\n const colonIndex = tagName.indexOf(\":\");\n if(colonIndex !== -1){\n tagName = tagName.substr(colonIndex+1);\n attrExpPresent = tagName !== result.data.substr(colonIndex + 1);\n }\n }\n\n return {\n tagName: tagName,\n tagExp: tagExp,\n closeIndex: closeIndex,\n attrExpPresent: attrExpPresent,\n rawTagName: rawTagName,\n }\n}\n/**\n * find paired tag for a stop node\n * @param {string} xmlData \n * @param {string} tagName \n * @param {number} i \n */\nfunction readStopNodeData(xmlData, tagName, i){\n const startIndex = i;\n // Starting at 1 since we already have an open tag\n let openTagCount = 1;\n\n for (; i < xmlData.length; i++) {\n if( xmlData[i] === \"<\"){ \n if (xmlData[i+1] === \"/\") {//close tag\n const closeIndex = findClosingIndex(xmlData, \">\", i, `${tagName} is not closed`);\n let closeTagName = xmlData.substring(i+2,closeIndex).trim();\n if(closeTagName === tagName){\n openTagCount--;\n if (openTagCount === 0) {\n return {\n tagContent: xmlData.substring(startIndex, i),\n i : closeIndex\n }\n }\n }\n i=closeIndex;\n } else if(xmlData[i+1] === '?') { \n const closeIndex = findClosingIndex(xmlData, \"?>\", i+1, \"StopNode is not closed.\")\n i=closeIndex;\n } else if(xmlData.substr(i + 1, 3) === '!--') { \n const closeIndex = findClosingIndex(xmlData, \"-->\", i+3, \"StopNode is not closed.\")\n i=closeIndex;\n } else if(xmlData.substr(i + 1, 2) === '![') { \n const closeIndex = findClosingIndex(xmlData, \"]]>\", i, \"StopNode is not closed.\") - 2;\n i=closeIndex;\n } else {\n const tagData = readTagExp(xmlData, i, '>')\n\n if (tagData) {\n const openTagName = tagData && tagData.tagName;\n if (openTagName === tagName && tagData.tagExp[tagData.tagExp.length-1] !== \"/\") {\n openTagCount++;\n }\n i=tagData.closeIndex;\n }\n }\n }\n }//end for loop\n}\n\nfunction parseValue(val, shouldParse, options) {\n if (shouldParse && typeof val === 'string') {\n //console.log(options)\n const newval = val.trim();\n if(newval === 'true' ) return true;\n else if(newval === 'false' ) return false;\n else return toNumber(val, options);\n } else {\n if (util.isExist(val)) {\n return val;\n } else {\n return '';\n }\n }\n}\n\n\nmodule.exports = OrderedObjParser;\n","'use strict';\n\n/**\n * \n * @param {array} node \n * @param {any} options \n * @returns \n */\nfunction prettify(node, options){\n return compress( node, options);\n}\n\n/**\n * \n * @param {array} arr \n * @param {object} options \n * @param {string} jPath \n * @returns object\n */\nfunction compress(arr, options, jPath){\n let text;\n const compressedObj = {};\n for (let i = 0; i < arr.length; i++) {\n const tagObj = arr[i];\n const property = propName(tagObj);\n let newJpath = \"\";\n if(jPath === undefined) newJpath = property;\n else newJpath = jPath + \".\" + property;\n\n if(property === options.textNodeName){\n if(text === undefined) text = tagObj[property];\n else text += \"\" + tagObj[property];\n }else if(property === undefined){\n continue;\n }else if(tagObj[property]){\n \n let val = compress(tagObj[property], options, newJpath);\n const isLeaf = isLeafTag(val, options);\n\n if(tagObj[\":@\"]){\n assignAttributes( val, tagObj[\":@\"], newJpath, options);\n }else if(Object.keys(val).length === 1 && val[options.textNodeName] !== undefined && !options.alwaysCreateTextNode){\n val = val[options.textNodeName];\n }else if(Object.keys(val).length === 0){\n if(options.alwaysCreateTextNode) val[options.textNodeName] = \"\";\n else val = \"\";\n }\n\n if(compressedObj[property] !== undefined && compressedObj.hasOwnProperty(property)) {\n if(!Array.isArray(compressedObj[property])) {\n compressedObj[property] = [ compressedObj[property] ];\n }\n compressedObj[property].push(val);\n }else{\n //TODO: if a node is not an array, then check if it should be an array\n //also determine if it is a leaf node\n if (options.isArray(property, newJpath, isLeaf )) {\n compressedObj[property] = [val];\n }else{\n compressedObj[property] = val;\n }\n }\n }\n \n }\n // if(text && text.length > 0) compressedObj[options.textNodeName] = text;\n if(typeof text === \"string\"){\n if(text.length > 0) compressedObj[options.textNodeName] = text;\n }else if(text !== undefined) compressedObj[options.textNodeName] = text;\n return compressedObj;\n}\n\nfunction propName(obj){\n const keys = Object.keys(obj);\n for (let i = 0; i < keys.length; i++) {\n const key = keys[i];\n if(key !== \":@\") return key;\n }\n}\n\nfunction assignAttributes(obj, attrMap, jpath, options){\n if (attrMap) {\n const keys = Object.keys(attrMap);\n const len = keys.length; //don't make it inline\n for (let i = 0; i < len; i++) {\n const atrrName = keys[i];\n if (options.isArray(atrrName, jpath + \".\" + atrrName, true, true)) {\n obj[atrrName] = [ attrMap[atrrName] ];\n } else {\n obj[atrrName] = attrMap[atrrName];\n }\n }\n }\n}\n\nfunction isLeafTag(obj, options){\n const { textNodeName } = options;\n const propCount = Object.keys(obj).length;\n \n if (propCount === 0) {\n return true;\n }\n\n if (\n propCount === 1 &&\n (obj[textNodeName] || typeof obj[textNodeName] === \"boolean\" || obj[textNodeName] === 0)\n ) {\n return true;\n }\n\n return false;\n}\nexports.prettify = prettify;\n","const { buildOptions} = require(\"./OptionsBuilder\");\nconst OrderedObjParser = require(\"./OrderedObjParser\");\nconst { prettify} = require(\"./node2json\");\nconst validator = require('../validator');\n\nclass XMLParser{\n \n constructor(options){\n this.externalEntities = {};\n this.options = buildOptions(options);\n \n }\n /**\n * Parse XML dats to JS object \n * @param {string|Buffer} xmlData \n * @param {boolean|Object} validationOption \n */\n parse(xmlData,validationOption){\n if(typeof xmlData === \"string\"){\n }else if( xmlData.toString){\n xmlData = xmlData.toString();\n }else{\n throw new Error(\"XML data is accepted in String or Bytes[] form.\")\n }\n if( validationOption){\n if(validationOption === true) validationOption = {}; //validate with default options\n \n const result = validator.validate(xmlData, validationOption);\n if (result !== true) {\n throw Error( `${result.err.msg}:${result.err.line}:${result.err.col}` )\n }\n }\n const orderedObjParser = new OrderedObjParser(this.options);\n orderedObjParser.addExternalEntities(this.externalEntities);\n const orderedResult = orderedObjParser.parseXml(xmlData);\n if(this.options.preserveOrder || orderedResult === undefined) return orderedResult;\n else return prettify(orderedResult, this.options);\n }\n\n /**\n * Add Entity which is not by default supported by this library\n * @param {string} key \n * @param {string} value \n */\n addEntity(key, value){\n if(value.indexOf(\"&\") !== -1){\n throw new Error(\"Entity value can't have '&'\")\n }else if(key.indexOf(\"&\") !== -1 || key.indexOf(\";\") !== -1){\n throw new Error(\"An entity must be set without '&' and ';'. Eg. use '#xD' for '
'\")\n }else if(value === \"&\"){\n throw new Error(\"An entity with value '&' is not permitted\");\n }else{\n this.externalEntities[key] = value;\n }\n }\n}\n\nmodule.exports = XMLParser;","const EOL = \"\\n\";\n\n/**\n * \n * @param {array} jArray \n * @param {any} options \n * @returns \n */\nfunction toXml(jArray, options) {\n let indentation = \"\";\n if (options.format && options.indentBy.length > 0) {\n indentation = EOL;\n }\n return arrToStr(jArray, options, \"\", indentation);\n}\n\nfunction arrToStr(arr, options, jPath, indentation) {\n let xmlStr = \"\";\n let isPreviousElementTag = false;\n\n for (let i = 0; i < arr.length; i++) {\n const tagObj = arr[i];\n const tagName = propName(tagObj);\n if(tagName === undefined) continue;\n\n let newJPath = \"\";\n if (jPath.length === 0) newJPath = tagName\n else newJPath = `${jPath}.${tagName}`;\n\n if (tagName === options.textNodeName) {\n let tagText = tagObj[tagName];\n if (!isStopNode(newJPath, options)) {\n tagText = options.tagValueProcessor(tagName, tagText);\n tagText = replaceEntitiesValue(tagText, options);\n }\n if (isPreviousElementTag) {\n xmlStr += indentation;\n }\n xmlStr += tagText;\n isPreviousElementTag = false;\n continue;\n } else if (tagName === options.cdataPropName) {\n if (isPreviousElementTag) {\n xmlStr += indentation;\n }\n xmlStr += `<![CDATA[${tagObj[tagName][0][options.textNodeName]}]]>`;\n isPreviousElementTag = false;\n continue;\n } else if (tagName === options.commentPropName) {\n xmlStr += indentation + `<!--${tagObj[tagName][0][options.textNodeName]}-->`;\n isPreviousElementTag = true;\n continue;\n } else if (tagName[0] === \"?\") {\n const attStr = attr_to_str(tagObj[\":@\"], options);\n const tempInd = tagName === \"?xml\" ? \"\" : indentation;\n let piTextNodeName = tagObj[tagName][0][options.textNodeName];\n piTextNodeName = piTextNodeName.length !== 0 ? \" \" + piTextNodeName : \"\"; //remove extra spacing\n xmlStr += tempInd + `<${tagName}${piTextNodeName}${attStr}?>`;\n isPreviousElementTag = true;\n continue;\n }\n let newIdentation = indentation;\n if (newIdentation !== \"\") {\n newIdentation += options.indentBy;\n }\n const attStr = attr_to_str(tagObj[\":@\"], options);\n const tagStart = indentation + `<${tagName}${attStr}`;\n const tagValue = arrToStr(tagObj[tagName], options, newJPath, newIdentation);\n if (options.unpairedTags.indexOf(tagName) !== -1) {\n if (options.suppressUnpairedNode) xmlStr += tagStart + \">\";\n else xmlStr += tagStart + \"/>\";\n } else if ((!tagValue || tagValue.length === 0) && options.suppressEmptyNode) {\n xmlStr += tagStart + \"/>\";\n } else if (tagValue && tagValue.endsWith(\">\")) {\n xmlStr += tagStart + `>${tagValue}${indentation}</${tagName}>`;\n } else {\n xmlStr += tagStart + \">\";\n if (tagValue && indentation !== \"\" && (tagValue.includes(\"/>\") || tagValue.includes(\"</\"))) {\n xmlStr += indentation + options.indentBy + tagValue + indentation;\n } else {\n xmlStr += tagValue;\n }\n xmlStr += `</${tagName}>`;\n }\n isPreviousElementTag = true;\n }\n\n return xmlStr;\n}\n\nfunction propName(obj) {\n const keys = Object.keys(obj);\n for (let i = 0; i < keys.length; i++) {\n const key = keys[i];\n if(!obj.hasOwnProperty(key)) continue;\n if (key !== \":@\") return key;\n }\n}\n\nfunction attr_to_str(attrMap, options) {\n let attrStr = \"\";\n if (attrMap && !options.ignoreAttributes) {\n for (let attr in attrMap) {\n if(!attrMap.hasOwnProperty(attr)) continue;\n let attrVal = options.attributeValueProcessor(attr, attrMap[attr]);\n attrVal = replaceEntitiesValue(attrVal, options);\n if (attrVal === true && options.suppressBooleanAttributes) {\n attrStr += ` ${attr.substr(options.attributeNamePrefix.length)}`;\n } else {\n attrStr += ` ${attr.substr(options.attributeNamePrefix.length)}=\"${attrVal}\"`;\n }\n }\n }\n return attrStr;\n}\n\nfunction isStopNode(jPath, options) {\n jPath = jPath.substr(0, jPath.length - options.textNodeName.length - 1);\n let tagName = jPath.substr(jPath.lastIndexOf(\".\") + 1);\n for (let index in options.stopNodes) {\n if (options.stopNodes[index] === jPath || options.stopNodes[index] === \"*.\" + tagName) return true;\n }\n return false;\n}\n\nfunction replaceEntitiesValue(textValue, options) {\n if (textValue && textValue.length > 0 && options.processEntities) {\n for (let i = 0; i < options.entities.length; i++) {\n const entity = options.entities[i];\n textValue = textValue.replace(entity.regex, entity.val);\n }\n }\n return textValue;\n}\nmodule.exports = toXml;\n","'use strict';\n//parse Empty Node as self closing node\nconst buildFromOrderedJs = require('./orderedJs2Xml');\n\nconst defaultOptions = {\n attributeNamePrefix: '@_',\n attributesGroupName: false,\n textNodeName: '#text',\n ignoreAttributes: true,\n cdataPropName: false,\n format: false,\n indentBy: ' ',\n suppressEmptyNode: false,\n suppressUnpairedNode: true,\n suppressBooleanAttributes: true,\n tagValueProcessor: function(key, a) {\n return a;\n },\n attributeValueProcessor: function(attrName, a) {\n return a;\n },\n preserveOrder: false,\n commentPropName: false,\n unpairedTags: [],\n entities: [\n { regex: new RegExp(\"&\", \"g\"), val: \"&\" },//it must be on top\n { regex: new RegExp(\">\", \"g\"), val: \">\" },\n { regex: new RegExp(\"<\", \"g\"), val: \"<\" },\n { regex: new RegExp(\"\\'\", \"g\"), val: \"'\" },\n { regex: new RegExp(\"\\\"\", \"g\"), val: \""\" }\n ],\n processEntities: true,\n stopNodes: [],\n // transformTagName: false,\n // transformAttributeName: false,\n oneListGroup: false\n};\n\nfunction Builder(options) {\n this.options = Object.assign({}, defaultOptions, options);\n if (this.options.ignoreAttributes || this.options.attributesGroupName) {\n this.isAttribute = function(/*a*/) {\n return false;\n };\n } else {\n this.attrPrefixLen = this.options.attributeNamePrefix.length;\n this.isAttribute = isAttribute;\n }\n\n this.processTextOrObjNode = processTextOrObjNode\n\n if (this.options.format) {\n this.indentate = indentate;\n this.tagEndChar = '>\\n';\n this.newLine = '\\n';\n } else {\n this.indentate = function() {\n return '';\n };\n this.tagEndChar = '>';\n this.newLine = '';\n }\n}\n\nBuilder.prototype.build = function(jObj) {\n if(this.options.preserveOrder){\n return buildFromOrderedJs(jObj, this.options);\n }else {\n if(Array.isArray(jObj) && this.options.arrayNodeName && this.options.arrayNodeName.length > 1){\n jObj = {\n [this.options.arrayNodeName] : jObj\n }\n }\n return this.j2x(jObj, 0).val;\n }\n};\n\nBuilder.prototype.j2x = function(jObj, level) {\n let attrStr = '';\n let val = '';\n for (let key in jObj) {\n if(!Object.prototype.hasOwnProperty.call(jObj, key)) continue;\n if (typeof jObj[key] === 'undefined') {\n // supress undefined node only if it is not an attribute\n if (this.isAttribute(key)) {\n val += '';\n }\n } else if (jObj[key] === null) {\n // null attribute should be ignored by the attribute list, but should not cause the tag closing\n if (this.isAttribute(key)) {\n val += '';\n } else if (key[0] === '?') {\n val += this.indentate(level) + '<' + key + '?' + this.tagEndChar;\n } else {\n val += this.indentate(level) + '<' + key + '/' + this.tagEndChar;\n }\n // val += this.indentate(level) + '<' + key + '/' + this.tagEndChar;\n } else if (jObj[key] instanceof Date) {\n val += this.buildTextValNode(jObj[key], key, '', level);\n } else if (typeof jObj[key] !== 'object') {\n //premitive type\n const attr = this.isAttribute(key);\n if (attr) {\n attrStr += this.buildAttrPairStr(attr, '' + jObj[key]);\n }else {\n //tag value\n if (key === this.options.textNodeName) {\n let newval = this.options.tagValueProcessor(key, '' + jObj[key]);\n val += this.replaceEntitiesValue(newval);\n } else {\n val += this.buildTextValNode(jObj[key], key, '', level);\n }\n }\n } else if (Array.isArray(jObj[key])) {\n //repeated nodes\n const arrLen = jObj[key].length;\n let listTagVal = \"\";\n for (let j = 0; j < arrLen; j++) {\n const item = jObj[key][j];\n if (typeof item === 'undefined') {\n // supress undefined node\n } else if (item === null) {\n if(key[0] === \"?\") val += this.indentate(level) + '<' + key + '?' + this.tagEndChar;\n else val += this.indentate(level) + '<' + key + '/' + this.tagEndChar;\n // val += this.indentate(level) + '<' + key + '/' + this.tagEndChar;\n } else if (typeof item === 'object') {\n if(this.options.oneListGroup ){\n listTagVal += this.j2x(item, level + 1).val;\n }else{\n listTagVal += this.processTextOrObjNode(item, key, level)\n }\n } else {\n listTagVal += this.buildTextValNode(item, key, '', level);\n }\n }\n if(this.options.oneListGroup){\n listTagVal = this.buildObjectNode(listTagVal, key, '', level);\n }\n val += listTagVal;\n } else {\n //nested node\n if (this.options.attributesGroupName && key === this.options.attributesGroupName) {\n const Ks = Object.keys(jObj[key]);\n const L = Ks.length;\n for (let j = 0; j < L; j++) {\n attrStr += this.buildAttrPairStr(Ks[j], '' + jObj[key][Ks[j]]);\n }\n } else {\n val += this.processTextOrObjNode(jObj[key], key, level)\n }\n }\n }\n return {attrStr: attrStr, val: val};\n};\n\nBuilder.prototype.buildAttrPairStr = function(attrName, val){\n val = this.options.attributeValueProcessor(attrName, '' + val);\n val = this.replaceEntitiesValue(val);\n if (this.options.suppressBooleanAttributes && val === \"true\") {\n return ' ' + attrName;\n } else return ' ' + attrName + '=\"' + val + '\"';\n}\n\nfunction processTextOrObjNode (object, key, level) {\n const result = this.j2x(object, level + 1);\n if (object[this.options.textNodeName] !== undefined && Object.keys(object).length === 1) {\n return this.buildTextValNode(object[this.options.textNodeName], key, result.attrStr, level);\n } else {\n return this.buildObjectNode(result.val, key, result.attrStr, level);\n }\n}\n\nBuilder.prototype.buildObjectNode = function(val, key, attrStr, level) {\n if(val === \"\"){\n if(key[0] === \"?\") return this.indentate(level) + '<' + key + attrStr+ '?' + this.tagEndChar;\n else {\n return this.indentate(level) + '<' + key + attrStr + this.closeTag(key) + this.tagEndChar;\n }\n }else{\n\n let tagEndExp = '</' + key + this.tagEndChar;\n let piClosingChar = \"\";\n \n if(key[0] === \"?\") {\n piClosingChar = \"?\";\n tagEndExp = \"\";\n }\n \n // attrStr is an empty string in case the attribute came as undefined or null\n if ((attrStr || attrStr === '') && val.indexOf('<') === -1) {\n return ( this.indentate(level) + '<' + key + attrStr + piClosingChar + '>' + val + tagEndExp );\n } else if (this.options.commentPropName !== false && key === this.options.commentPropName && piClosingChar.length === 0) {\n return this.indentate(level) + `<!--${val}-->` + this.newLine;\n }else {\n return (\n this.indentate(level) + '<' + key + attrStr + piClosingChar + this.tagEndChar +\n val +\n this.indentate(level) + tagEndExp );\n }\n }\n}\n\nBuilder.prototype.closeTag = function(key){\n let closeTag = \"\";\n if(this.options.unpairedTags.indexOf(key) !== -1){ //unpaired\n if(!this.options.suppressUnpairedNode) closeTag = \"/\"\n }else if(this.options.suppressEmptyNode){ //empty\n closeTag = \"/\";\n }else{\n closeTag = `></${key}`\n }\n return closeTag;\n}\n\nfunction buildEmptyObjNode(val, key, attrStr, level) {\n if (val !== '') {\n return this.buildObjectNode(val, key, attrStr, level);\n } else {\n if(key[0] === \"?\") return this.indentate(level) + '<' + key + attrStr+ '?' + this.tagEndChar;\n else {\n return this.indentate(level) + '<' + key + attrStr + '/' + this.tagEndChar;\n // return this.buildTagStr(level,key, attrStr);\n }\n }\n}\n\nBuilder.prototype.buildTextValNode = function(val, key, attrStr, level) {\n if (this.options.cdataPropName !== false && key === this.options.cdataPropName) {\n return this.indentate(level) + `<![CDATA[${val}]]>` + this.newLine;\n }else if (this.options.commentPropName !== false && key === this.options.commentPropName) {\n return this.indentate(level) + `<!--${val}-->` + this.newLine;\n }else if(key[0] === \"?\") {//PI tag\n return this.indentate(level) + '<' + key + attrStr+ '?' + this.tagEndChar; \n }else{\n let textValue = this.options.tagValueProcessor(key, val);\n textValue = this.replaceEntitiesValue(textValue);\n \n if( textValue === ''){\n return this.indentate(level) + '<' + key + attrStr + this.closeTag(key) + this.tagEndChar;\n }else{\n return this.indentate(level) + '<' + key + attrStr + '>' +\n textValue +\n '</' + key + this.tagEndChar;\n }\n }\n}\n\nBuilder.prototype.replaceEntitiesValue = function(textValue){\n if(textValue && textValue.length > 0 && this.options.processEntities){\n for (let i=0; i<this.options.entities.length; i++) {\n const entity = this.options.entities[i];\n textValue = textValue.replace(entity.regex, entity.val);\n }\n }\n return textValue;\n}\n\nfunction indentate(level) {\n return this.options.indentBy.repeat(level);\n}\n\nfunction isAttribute(name /*, options*/) {\n if (name.startsWith(this.options.attributeNamePrefix) && name !== this.options.textNodeName) {\n return name.substr(this.attrPrefixLen);\n } else {\n return false;\n }\n}\n\nmodule.exports = Builder;\n","'use strict';\n\nconst validator = require('./validator');\nconst XMLParser = require('./xmlparser/XMLParser');\nconst XMLBuilder = require('./xmlbuilder/json2xml');\n\nmodule.exports = {\n XMLParser: XMLParser,\n XMLValidator: validator,\n XMLBuilder: XMLBuilder\n}","import {XMLParser, XMLValidator} from 'fast-xml-parser';\n\nexport default function isSvg(string) {\n\tif (typeof string !== 'string') {\n\t\tthrow new TypeError(`Expected a \\`string\\`, got \\`${typeof string}\\``);\n\t}\n\n\tstring = string.trim();\n\n\tif (string.length === 0) {\n\t\treturn false;\n\t}\n\n\t// Has to be `!==` as it can also return an object with error info.\n\tif (XMLValidator.validate(string) !== true) {\n\t\treturn false;\n\t}\n\n\tlet jsonObject;\n\tconst parser = new XMLParser();\n\n\ttry {\n\t\tjsonObject = parser.parse(string);\n\t} catch {\n\t\treturn false;\n\t}\n\n\tif (!jsonObject) {\n\t\treturn false;\n\t}\n\n\tif (!Object.keys(jsonObject).some(x => x.toLowerCase() === 'svg')) {\n\t\treturn false;\n\t}\n\n\treturn true;\n}\n","/**\n * @copyright Copyright (c) 2022 John Molakvoæ <skjnldsv@protonmail.com>\n *\n * @author John Molakvoæ <skjnldsv@protonmail.com>\n *\n * @license AGPL-3.0-or-later\n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see <http://www.gnu.org/licenses/>.\n *\n */\nimport type { Folder } from '../files/folder'\nimport type { Node } from '../files/node'\nimport isSvg from 'is-svg'\n\nimport { Column } from './column.js'\n\nexport type ContentsWithRoot = {\n\tfolder: Folder,\n\tcontents: Node[]\n}\n\ninterface ViewData {\n\t/** Unique view ID */\n\tid: string\n\t/** Translated view name */\n\tname: string\n\t/** Translated accessible description of the view */\n\tcaption?: string\n\n\t/** Translated title of the empty view */\n\temptyTitle?: string\n\t/** Translated description of the empty view */\n\temptyCaption?: string\n\n\t/**\n\t * Method return the content of the provided path\n\t * This ideally should be a cancellable promise.\n\t * promise.cancel(reason) will be called when the directory\n\t * change and the promise is not resolved yet.\n\t * You _must_ also return the current directory\n\t * information alongside with its content.\n\t */\n\tgetContents: (path: string) => Promise<ContentsWithRoot>\n\t/** The view icon as an inline svg */\n\ticon: string\n\t/** The view order */\n\torder: number\n\n\t/**\n\t * Custom params to give to the router on click\n\t * If defined, will be treated as a dummy view and\n\t * will just redirect and not fetch any contents.\n\t */\n\tparams?: Record<string, string>\n\n\t/**\n\t * This view column(s). Name and actions are\n\t * by default always included\n\t */\n\tcolumns?: Column[]\n\t/** The empty view element to render your empty content into */\n\temptyView?: (div: HTMLDivElement) => void\n\t/** The parent unique ID */\n\tparent?: string\n\t/** This view is sticky (sent at the bottom) */\n\tsticky?: boolean\n\n\t/**\n\t * This view has children and is expanded (by default)\n\t * or not. This will be overridden by user config.\n\t */\n\texpanded?: boolean\n\n\t/**\n\t * Will be used as default if the user\n\t * haven't customized their sorting column\n\t */\n\tdefaultSortKey?: string\n}\n\nexport class View implements ViewData {\n\n\tprivate _view: ViewData\n\n\tconstructor(view: ViewData) {\n\t\tisValidView(view)\n\t\tthis._view = view\n\t}\n\n\tget id() {\n\t\treturn this._view.id\n\t}\n\n\tget name() {\n\t\treturn this._view.name\n\t}\n\n\tget caption() {\n\t\treturn this._view.caption\n\t}\n\n\tget emptyTitle() {\n\t\treturn this._view.emptyTitle\n\t}\n\n\tget emptyCaption() {\n\t\treturn this._view.emptyCaption\n\t}\n\n\tget getContents() {\n\t\treturn this._view.getContents\n\t}\n\n\tget icon() {\n\t\treturn this._view.icon\n\t}\n\n\tset icon(icon) {\n\t\tthis._view.icon = icon\n\t}\n\n\tget order() {\n\t\treturn this._view.order\n\t}\n\n\tset order(order) {\n\t\tthis._view.order = order\n\t}\n\n\tget params() {\n\t\treturn this._view.params\n\t}\n\n\tset params(params) {\n\t\tthis._view.params = params\n\t}\n\n\tget columns() {\n\t\treturn this._view.columns\n\t}\n\n\tget emptyView() {\n\t\treturn this._view.emptyView\n\t}\n\n\tget parent() {\n\t\treturn this._view.parent\n\t}\n\n\tget sticky() {\n\t\treturn this._view.sticky\n\t}\n\n\tget expanded() {\n\t\treturn this._view.expanded\n\t}\n\n\tset expanded(expanded: boolean | undefined) {\n\t\tthis._view.expanded = expanded\n\t}\n\n\tget defaultSortKey() {\n\t\treturn this._view.defaultSortKey\n\t}\n\n}\n\n/**\n * Typescript cannot validate an interface.\n * Please keep in sync with the View interface requirements.\n *\n * @param {ViewData} view the view to check\n * @return {boolean} true if the column is valid\n * @throws {Error} if the view is not valid\n */\nconst isValidView = function(view: ViewData): boolean {\n\tif (!view.id || typeof view.id !== 'string') {\n\t\tthrow new Error('View id is required and must be a string')\n\t}\n\n\tif (!view.name || typeof view.name !== 'string') {\n\t\tthrow new Error('View name is required and must be a string')\n\t}\n\n\tif (view.columns && view.columns.length > 0\n\t\t&& (!view.caption || typeof view.caption !== 'string')) {\n\t\tthrow new Error('View caption is required for top-level views and must be a string')\n\t}\n\n\tif (!view.getContents || typeof view.getContents !== 'function') {\n\t\tthrow new Error('View getContents is required and must be a function')\n\t}\n\n\tif (!view.icon || typeof view.icon !== 'string' || !isSvg(view.icon)) {\n\t\tthrow new Error('View icon is required and must be a valid svg string')\n\t}\n\n\tif (!('order' in view) || typeof view.order !== 'number') {\n\t\tthrow new Error('View order is required and must be a number')\n\t}\n\n\t// Optional properties\n\tif (view.columns) {\n\t\tview.columns.forEach((column) => {\n\t\t\tif (!(column instanceof Column)) {\n\t\t\t\tthrow new Error('View columns must be an array of Column. Invalid column found')\n\t\t\t}\n\t\t})\n\t}\n\n\tif (view.emptyView && typeof view.emptyView !== 'function') {\n\t\tthrow new Error('View emptyView must be a function')\n\t}\n\n\tif (view.parent && typeof view.parent !== 'string') {\n\t\tthrow new Error('View parent must be a string')\n\t}\n\n\tif ('sticky' in view && typeof view.sticky !== 'boolean') {\n\t\tthrow new Error('View sticky must be a boolean')\n\t}\n\n\tif ('expanded' in view && typeof view.expanded !== 'boolean') {\n\t\tthrow new Error('View expanded must be a boolean')\n\t}\n\n\tif (view.defaultSortKey && typeof view.defaultSortKey !== 'string') {\n\t\tthrow new Error('View defaultSortKey must be a string')\n\t}\n\n\treturn true\n}\n","/**\n * @copyright 2019 Christoph Wurst <christoph@winzerhof-wurst.at>\n *\n * @author Christoph Wurst <christoph@winzerhof-wurst.at>\n * @author John Molakvoæ <skjnldsv@protonmail.com>\n *\n * @license AGPL-3.0-or-later\n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see <http://www.gnu.org/licenses/>.\n *\n */\n\nimport { type Entry, getNewFileMenu } from './newFileMenu'\nimport { type Folder } from './files/folder'\n\nexport { formatFileSize, parseFileSize } from './humanfilesize'\nexport { FileAction, getFileActions, registerFileAction, DefaultType } from './fileAction'\nexport { Header, getFileListHeaders, registerFileListHeaders } from './fileListHeaders'\nexport { type Entry, NewMenuEntryCategory } from './newFileMenu'\nexport { Permission } from './permissions'\n\nexport * from './dav/davProperties'\nexport * from './dav/davPermissions'\nexport * from './dav/dav'\n\nexport { FileType } from './files/fileType'\nexport { File } from './files/file'\nexport { Folder } from './files/folder'\nexport { Node, NodeStatus } from './files/node'\nexport { isFilenameValid } from './filename'\n\nexport * from './navigation/navigation'\nexport * from './navigation/column'\nexport * from './navigation/view'\n\n/**\n * Add a new menu entry to the upload manager menu\n *\n * @param entry The new file menu entry\n */\nexport const addNewFileMenuEntry = function(entry: Entry) {\n\tconst newFileMenu = getNewFileMenu()\n\treturn newFileMenu.registerEntry(entry)\n}\n\n/**\n * Remove a previously registered entry from the upload menu\n *\n * @param entry Entry to remove (or name of entry)\n */\nexport const removeNewFileMenuEntry = function(entry: Entry | string) {\n\tconst newFileMenu = getNewFileMenu()\n\treturn newFileMenu.unregisterEntry(entry)\n}\n\n/**\n * Get the list of registered entries from the upload menu\n *\n * @param {Folder} context the creation context. Usually the current folder FileInfo\n */\nexport const getNewFileMenuEntries = function(context?: Folder) {\n\tconst newFileMenu = getNewFileMenu()\n\treturn newFileMenu.getEntries(context).sort((a: Entry, b: Entry) => {\n\t\t// If defined and different, sort by order\n\t\tif (a.order !== undefined\n\t\t\t&& b.order !== undefined\n\t\t\t&& a.order !== b.order) {\n\t\t\treturn a.order - b.order\n\t\t}\n\t\t// else sort by display name\n\t\treturn a.displayName.localeCompare(b.displayName, undefined, { numeric: true, sensitivity: 'base' })\n\t})\n}\n"],"names":["NewMenuEntryCategory","DefaultType","Permission","FileType","NodeStatus","basename","headers","util","require$$0","defaultOptions","validator","val","buildOptions","xmlNode","readDocType","entityName","toNumber","require$$1","require$$2","require$$3","replaceEntitiesValue","result","OrderedObjParser","prettify","propName","XMLParser","attStr","XMLValidator"],"mappings":";;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAyBA,MAAM,YAAY,CAAQ,SAAA;AACzB,MAAI,SAAS,MAAM;AAClB,WAAO,iBAAiB,EACtB,OAAO,OAAO,EACd,MAAM;AAAA,EACT;AACO,SAAA,iBAAA,EACL,OAAO,OAAO,EACd,OAAO,KAAK,GAAG,EACf;AACH;AAEA,MAAA,SAAe,UAAU,gBAAgB;ACrCzC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAyBY,IAAA,yCAAAA,0BAAL;AAINA,wBAAAA,sBAAA,sBAAmB,CAAnB,IAAA;AAIAA,wBAAAA,sBAAA,eAAY,CAAZ,IAAA;AAIAA,wBAAAA,sBAAA,WAAQ,CAAR,IAAA;AAZWA,SAAAA;AAAA,GAAA,wBAAA,CAAA,CAAA;AA2DL,MAAM,YAAY;AAAA,EAEhB,WAAyB,CAA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K;AACzC;AAOa,MAAA,wBAAwB,SAAS,SAAkB;AAC/D,QAAM,cAAc;AACpB,SAAO,YAAY,WAAW,OAAO,EAAE,KAAK,CAAC,GAAU,MAAa;AAE/D,QAAA,EAAE,UAAU,UACZ,EAAE,UAAU,UACZ,EAAE,UAAU,EAAE,OAAO;AACjB,aAAA,EAAE,QAAQ,EAAE;AAAA,IACpB;AAEO,WAAA,EAAE,YAAY,cAAc,EAAE,aAAa,QAAW,EAAE,SAAS,MAAM,aAAa,OAAQ,CAAA;AAAA,EAAA,CACnG;AACF;","x_google_ignoreList":[17,18,19,20,21,22,23,24,25,26,27,28,29]}
|
|
1
|
+
{"version":3,"file":"index.mjs","sources":["../lib/utils/logger.ts","../lib/newFileMenu.ts","../lib/fileAction.ts","../lib/fileListHeaders.ts","../lib/permissions.ts","../lib/dav/davProperties.ts","../lib/dav/davPermissions.ts","../lib/files/fileType.ts","../lib/files/nodeData.ts","../lib/files/node.ts","../lib/files/file.ts","../lib/files/folder.ts","../lib/dav/dav.ts","../lib/utils/filename.ts","../lib/utils/fileSize.ts","../lib/utils/sorting.ts","../lib/utils/fileSorting.ts","../lib/navigation/navigation.ts","../lib/navigation/column.ts","../node_modules/fast-xml-parser/src/util.js","../node_modules/fast-xml-parser/src/validator.js","../node_modules/fast-xml-parser/src/xmlparser/OptionsBuilder.js","../node_modules/fast-xml-parser/src/xmlparser/xmlNode.js","../node_modules/fast-xml-parser/src/xmlparser/DocTypeReader.js","../node_modules/strnum/strnum.js","../node_modules/fast-xml-parser/src/xmlparser/OrderedObjParser.js","../node_modules/fast-xml-parser/src/xmlparser/node2json.js","../node_modules/fast-xml-parser/src/xmlparser/XMLParser.js","../node_modules/fast-xml-parser/src/xmlbuilder/orderedJs2Xml.js","../node_modules/fast-xml-parser/src/xmlbuilder/json2xml.js","../node_modules/fast-xml-parser/src/fxp.js","../node_modules/is-svg/index.js","../lib/navigation/view.ts","../lib/index.ts"],"sourcesContent":["/**\n * @copyright 2019 Christoph Wurst <christoph@winzerhof-wurst.at>\n *\n * @author Christoph Wurst <christoph@winzerhof-wurst.at>\n *\n * @license AGPL-3.0-or-later\n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see <http://www.gnu.org/licenses/>.\n *\n */\n\nimport { getCurrentUser } from '@nextcloud/auth'\nimport { getLoggerBuilder } from '@nextcloud/logger'\n\nconst getLogger = user => {\n\tif (user === null) {\n\t\treturn getLoggerBuilder()\n\t\t\t.setApp('files')\n\t\t\t.build()\n\t}\n\treturn getLoggerBuilder()\n\t\t.setApp('files')\n\t\t.setUid(user.uid)\n\t\t.build()\n}\n\nexport default getLogger(getCurrentUser())\n","/**\n * @copyright Copyright (c) 2021 John Molakvoæ <skjnldsv@protonmail.com>\n *\n * @author John Molakvoæ <skjnldsv@protonmail.com>\n *\n * @license AGPL-3.0-or-later\n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see <http://www.gnu.org/licenses/>.\n *\n */\n\nimport type { Folder, Node } from './index'\nimport logger from './utils/logger'\n\nexport enum NewMenuEntryCategory {\n\t/**\n\t * For actions where the user is intended to upload from their device\n\t */\n\tUploadFromDevice = 0,\n\t/**\n\t * For actions that create new nodes on the server without uploading\n\t */\n\tCreateNew = 1,\n\t/**\n\t * For everything not matching the other categories\n\t */\n\tOther = 2,\n}\n\nexport interface Entry {\n\t/** Unique ID */\n\tid: string\n\n\t/**\n\t * Category to put this entry in\n\t * (supported since Nextcloud 30)\n\t * @since 3.3.0\n\t * @default NewMenuEntryCategory.CreateNew\n\t */\n\tcategory?: NewMenuEntryCategory\n\n\t/** Translatable string displayed in the menu */\n\tdisplayName: string\n\n\t/**\n\t * Condition wether this entry is shown or not\n\t * @param context the creation context. Usually the current folder\n\t */\n\tenabled?: (context: Folder) => boolean\n\n\t/**\n\t * Either iconSvgInline or iconClass must be defined\n\t * Svg as inline string. <svg><path fill=\"...\" /></svg>\n\t */\n\ticonSvgInline?: string\n\n\t/**\n\t * Existing icon css class\n\t * @deprecated use iconSvgInline instead\n\t */\n\ticonClass?: string\n\n\t/** Order of the entry in the menu */\n\torder?: number\n\n\t/**\n\t * Function to be run after creation\n\t * @param context the creation context. Usually the current folder\n\t * @param content list of file/folders present in the context folder\n\t */\n\thandler: (context: Folder, content: Node[]) => void\n}\n\nexport class NewFileMenu {\n\n\tprivate _entries: Array<Entry> = []\n\n\tpublic registerEntry(entry: Entry) {\n\t\tthis.validateEntry(entry)\n\t\tentry.category = entry.category ?? NewMenuEntryCategory.CreateNew\n\t\tthis._entries.push(entry)\n\t}\n\n\tpublic unregisterEntry(entry: Entry | string) {\n\t\tconst entryIndex = typeof entry === 'string'\n\t\t\t? this.getEntryIndex(entry)\n\t\t\t: this.getEntryIndex(entry.id)\n\n\t\tif (entryIndex === -1) {\n\t\t\tlogger.warn('Entry not found, nothing removed', { entry, entries: this.getEntries() })\n\t\t\treturn\n\t\t}\n\n\t\tthis._entries.splice(entryIndex, 1)\n\t}\n\n\t/**\n\t * Get the list of registered entries\n\t *\n\t * @param {Folder} context the creation context. Usually the current folder\n\t */\n\tpublic getEntries(context?: Folder): Array<Entry> {\n\t\tif (context) {\n\t\t\treturn this._entries\n\t\t\t\t.filter(entry => typeof entry.enabled === 'function' ? entry.enabled(context) : true)\n\t\t}\n\t\treturn this._entries\n\t}\n\n\tprivate getEntryIndex(id: string): number {\n\t\treturn this._entries.findIndex(entry => entry.id === id)\n\t}\n\n\tprivate validateEntry(entry: Entry) {\n\t\tif (!entry.id || !entry.displayName || !(entry.iconSvgInline || entry.iconClass) || !entry.handler) {\n\t\t\tthrow new Error('Invalid entry')\n\t\t}\n\n\t\tif (typeof entry.id !== 'string'\n\t\t\t|| typeof entry.displayName !== 'string') {\n\t\t\tthrow new Error('Invalid id or displayName property')\n\t\t}\n\n\t\tif ((entry.iconClass && typeof entry.iconClass !== 'string')\n\t\t\t|| (entry.iconSvgInline && typeof entry.iconSvgInline !== 'string')) {\n\t\t\tthrow new Error('Invalid icon provided')\n\t\t}\n\n\t\tif (entry.enabled !== undefined && typeof entry.enabled !== 'function') {\n\t\t\tthrow new Error('Invalid enabled property')\n\t\t}\n\n\t\tif (typeof entry.handler !== 'function') {\n\t\t\tthrow new Error('Invalid handler property')\n\t\t}\n\n\t\tif ('order' in entry && typeof entry.order !== 'number') {\n\t\t\tthrow new Error('Invalid order property')\n\t\t}\n\n\t\tif (this.getEntryIndex(entry.id) !== -1) {\n\t\t\tthrow new Error('Duplicate entry')\n\t\t}\n\t}\n\n}\n\nexport const getNewFileMenu = function(): NewFileMenu {\n\tif (typeof window._nc_newfilemenu === 'undefined') {\n\t\twindow._nc_newfilemenu = new NewFileMenu()\n\t\tlogger.debug('NewFileMenu initialized')\n\t}\n\treturn window._nc_newfilemenu\n}\n","/**\n * @copyright Copyright (c) 2023 John Molakvoæ <skjnldsv@protonmail.com>\n *\n * @author John Molakvoæ <skjnldsv@protonmail.com>\n *\n * @license AGPL-3.0-or-later\n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see <http://www.gnu.org/licenses/>.\n *\n */\n\nimport { Node } from './files/node'\nimport { View } from './navigation/view'\nimport logger from './utils/logger'\n\nexport enum DefaultType {\n\tDEFAULT = 'default',\n\tHIDDEN = 'hidden',\n}\n\ninterface FileActionData {\n\t/** Unique ID */\n\tid: string\n\t/** Translatable string displayed in the menu */\n\tdisplayName: (files: Node[], view: View) => string\n\t/** Translatable title for of the action */\n\ttitle?: (files: Node[], view: View) => string\n\t/** Svg as inline string. <svg><path fill=\"...\" /></svg> */\n\ticonSvgInline: (files: Node[], view: View) => string\n\t/** Condition wether this action is shown or not */\n\tenabled?: (files: Node[], view: View) => boolean\n\n\t/**\n\t * Function executed on single file action\n\t * @return true if the action was executed successfully,\n\t * false otherwise and null if the action is silent/undefined.\n\t * @throws Error if the action failed\n\t */\n\texec: (file: Node, view: View, dir: string) => Promise<boolean|null>,\n\t/**\n\t * Function executed on multiple files action\n\t * @return true if the action was executed successfully,\n\t * false otherwise and null if the action is silent/undefined.\n\t * @throws Error if the action failed\n\t */\n\texecBatch?: (files: Node[], view: View, dir: string) => Promise<(boolean|null)[]>\n\n\t/** This action order in the list */\n\torder?: number,\n\n\t/**\n\t * This action's parent id in the list.\n\t * If none found, will be displayed as a top-level action.\n\t */\n\tparent?: string,\n\n\t/**\n\t * Make this action the default.\n\t * If multiple actions are default, the first one\n\t * will be used. The other ones will be put as first\n\t * entries in the actions menu iff DefaultType.Hidden is not used.\n\t * A DefaultType.Hidden action will never be shown\n\t * in the actions menu even if another action takes\n\t * its place as default.\n\t */\n\tdefault?: DefaultType,\n\t/**\n\t * If true, the renderInline function will be called\n\t */\n\tinline?: (file: Node, view: View) => boolean,\n\t/**\n\t * If defined, the returned html element will be\n\t * appended before the actions menu.\n\t */\n\trenderInline?: (file: Node, view: View) => Promise<HTMLElement | null>,\n}\n\nexport class FileAction {\n\n\tprivate _action: FileActionData\n\n\tconstructor(action: FileActionData) {\n\t\tthis.validateAction(action)\n\t\tthis._action = action\n\t}\n\n\tget id() {\n\t\treturn this._action.id\n\t}\n\n\tget displayName() {\n\t\treturn this._action.displayName\n\t}\n\n\tget title() {\n\t\treturn this._action.title\n\t}\n\n\tget iconSvgInline() {\n\t\treturn this._action.iconSvgInline\n\t}\n\n\tget enabled() {\n\t\treturn this._action.enabled\n\t}\n\n\tget exec() {\n\t\treturn this._action.exec\n\t}\n\n\tget execBatch() {\n\t\treturn this._action.execBatch\n\t}\n\n\tget order() {\n\t\treturn this._action.order\n\t}\n\n\tget parent() {\n\t\treturn this._action.parent\n\t}\n\n\tget default() {\n\t\treturn this._action.default\n\t}\n\n\tget inline() {\n\t\treturn this._action.inline\n\t}\n\n\tget renderInline() {\n\t\treturn this._action.renderInline\n\t}\n\n\tprivate validateAction(action: FileActionData) {\n\t\tif (!action.id || typeof action.id !== 'string') {\n\t\t\tthrow new Error('Invalid id')\n\t\t}\n\n\t\tif (!action.displayName || typeof action.displayName !== 'function') {\n\t\t\tthrow new Error('Invalid displayName function')\n\t\t}\n\n\t\tif ('title' in action && typeof action.title !== 'function') {\n\t\t\tthrow new Error('Invalid title function')\n\t\t}\n\n\t\tif (!action.iconSvgInline || typeof action.iconSvgInline !== 'function') {\n\t\t\tthrow new Error('Invalid iconSvgInline function')\n\t\t}\n\n\t\tif (!action.exec || typeof action.exec !== 'function') {\n\t\t\tthrow new Error('Invalid exec function')\n\t\t}\n\n\t\t// Optional properties --------------------------------------------\n\t\tif ('enabled' in action && typeof action.enabled !== 'function') {\n\t\t\tthrow new Error('Invalid enabled function')\n\t\t}\n\n\t\tif ('execBatch' in action && typeof action.execBatch !== 'function') {\n\t\t\tthrow new Error('Invalid execBatch function')\n\t\t}\n\n\t\tif ('order' in action && typeof action.order !== 'number') {\n\t\t\tthrow new Error('Invalid order')\n\t\t}\n\n\t\tif ('parent' in action && typeof action.parent !== 'string') {\n\t\t\tthrow new Error('Invalid parent')\n\t\t}\n\n\t\tif (action.default && !Object.values(DefaultType).includes(action.default)) {\n\t\t\tthrow new Error('Invalid default')\n\t\t}\n\n\t\tif ('inline' in action && typeof action.inline !== 'function') {\n\t\t\tthrow new Error('Invalid inline function')\n\t\t}\n\n\t\tif ('renderInline' in action && typeof action.renderInline !== 'function') {\n\t\t\tthrow new Error('Invalid renderInline function')\n\t\t}\n\t}\n\n}\n\nexport const registerFileAction = function(action: FileAction): void {\n\tif (typeof window._nc_fileactions === 'undefined') {\n\t\twindow._nc_fileactions = []\n\t\tlogger.debug('FileActions initialized')\n\t}\n\n\t// Check duplicates\n\tif (window._nc_fileactions.find(search => search.id === action.id)) {\n\t\tlogger.error(`FileAction ${action.id} already registered`, { action })\n\t\treturn\n\t}\n\n\twindow._nc_fileactions.push(action)\n}\n\nexport const getFileActions = function(): FileAction[] {\n\tif (typeof window._nc_fileactions === 'undefined') {\n\t\twindow._nc_fileactions = []\n\t\tlogger.debug('FileActions initialized')\n\t}\n\n\treturn window._nc_fileactions\n}\n","/**\n * @copyright Copyright (c) 2023 John Molakvoæ <skjnldsv@protonmail.com>\n *\n * @author John Molakvoæ <skjnldsv@protonmail.com>\n *\n * @license AGPL-3.0-or-later\n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see <http://www.gnu.org/licenses/>.\n *\n */\n\nimport { Folder } from './files/folder'\nimport { View } from './navigation/view'\nimport logger from './utils/logger'\n\nexport interface HeaderData {\n\t/** Unique ID */\n\tid: string\n\t/** Order */\n\torder: number\n\t/** Condition wether this header is shown or not */\n\tenabled?: (folder: Folder, view: View) => boolean\n\t/** Executed when file list is initialized */\n\trender: (el: HTMLElement, folder: Folder, view: View) => void\n\t/** Executed when root folder changed */\n\tupdated(folder: Folder, view: View)\n}\n\nexport class Header {\n\n\tprivate _header: HeaderData\n\n\tconstructor(header: HeaderData) {\n\t\tthis.validateHeader(header)\n\t\tthis._header = header\n\t}\n\n\tget id() {\n\t\treturn this._header.id\n\t}\n\n\tget order() {\n\t\treturn this._header.order\n\t}\n\n\tget enabled() {\n\t\treturn this._header.enabled\n\t}\n\n\tget render() {\n\t\treturn this._header.render\n\t}\n\n\tget updated() {\n\t\treturn this._header.updated\n\t}\n\n\tprivate validateHeader(header: HeaderData) {\n\t\tif (!header.id || !header.render || !header.updated) {\n\t\t\tthrow new Error('Invalid header: id, render and updated are required')\n\t\t}\n\n\t\tif (typeof header.id !== 'string') {\n\t\t\tthrow new Error('Invalid id property')\n\t\t}\n\n\t\tif (header.enabled !== undefined && typeof header.enabled !== 'function') {\n\t\t\tthrow new Error('Invalid enabled property')\n\t\t}\n\n\t\tif (header.render && typeof header.render !== 'function') {\n\t\t\tthrow new Error('Invalid render property')\n\t\t}\n\n\t\tif (header.updated && typeof header.updated !== 'function') {\n\t\t\tthrow new Error('Invalid updated property')\n\t\t}\n\t}\n\n}\n\nexport const registerFileListHeaders = function(header: Header): void {\n\tif (typeof window._nc_filelistheader === 'undefined') {\n\t\twindow._nc_filelistheader = []\n\t\tlogger.debug('FileListHeaders initialized')\n\t}\n\n\t// Check duplicates\n\tif (window._nc_filelistheader.find(search => search.id === header.id)) {\n\t\tlogger.error(`Header ${header.id} already registered`, { header })\n\t\treturn\n\t}\n\n\twindow._nc_filelistheader.push(header)\n}\n\nexport const getFileListHeaders = function(): Header[] {\n\tif (typeof window._nc_filelistheader === 'undefined') {\n\t\twindow._nc_filelistheader = []\n\t\tlogger.debug('FileListHeaders initialized')\n\t}\n\n\treturn window._nc_filelistheader\n}\n","/**\n * @copyright Copyright (c) 2022 John Molakvoæ <skjnldsv@protonmail.com>\n *\n * @author John Molakvoæ <skjnldsv@protonmail.com>\n *\n * @license AGPL-3.0-or-later\n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see <http://www.gnu.org/licenses/>.\n *\n */\n\n/**\n * Node permissions\n */\nexport enum Permission {\n\tNONE = 0,\n\tCREATE = 4,\n\tREAD = 1,\n\tUPDATE = 2,\n\tDELETE = 8,\n\tSHARE = 16,\n\tALL = 31,\n}\n","/**\n * @copyright Copyright (c) 2023 John Molakvoæ <skjnldsv@protonmail.com>\n *\n * @author John Molakvoæ <skjnldsv@protonmail.com>\n * @author Ferdinand Thiessen <opensource@fthiessen.de>\n *\n * @license AGPL-3.0-or-later\n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see <http://www.gnu.org/licenses/>.\n *\n */\nimport { getCurrentUser } from '@nextcloud/auth'\nimport logger from '../utils/logger'\n\nexport type DavProperty = { [key: string]: string }\n\nexport const defaultDavProperties = [\n\t'd:getcontentlength',\n\t'd:getcontenttype',\n\t'd:getetag',\n\t'd:getlastmodified',\n\t'd:quota-available-bytes',\n\t'd:resourcetype',\n\t'nc:has-preview',\n\t'nc:is-encrypted',\n\t'nc:mount-type',\n\t'oc:comments-unread',\n\t'oc:favorite',\n\t'oc:fileid',\n\t'oc:owner-display-name',\n\t'oc:owner-id',\n\t'oc:permissions',\n\t'oc:size',\n]\n\nexport const defaultDavNamespaces = {\n\td: 'DAV:',\n\tnc: 'http://nextcloud.org/ns',\n\toc: 'http://owncloud.org/ns',\n\tocs: 'http://open-collaboration-services.org/ns',\n}\n\n/**\n * Register custom DAV properties\n *\n * Can be used if your app introduces custom DAV properties, so e.g. the files app can make use of it.\n *\n * @param prop The property\n * @param namespace The namespace of the property\n */\nexport const registerDavProperty = function(prop: string, namespace: DavProperty = { nc: 'http://nextcloud.org/ns' }): boolean {\n\tif (typeof window._nc_dav_properties === 'undefined') {\n\t\twindow._nc_dav_properties = [...defaultDavProperties]\n\t\twindow._nc_dav_namespaces = { ...defaultDavNamespaces }\n\t}\n\n\tconst namespaces = { ...window._nc_dav_namespaces, ...namespace }\n\n\t// Check duplicates\n\tif (window._nc_dav_properties.find((search) => search === prop)) {\n\t\tlogger.warn(`${prop} already registered`, { prop })\n\t\treturn false\n\t}\n\n\tif (prop.startsWith('<') || prop.split(':').length !== 2) {\n\t\tlogger.error(`${prop} is not valid. See example: 'oc:fileid'`, { prop })\n\t\treturn false\n\t}\n\n\tconst ns = prop.split(':')[0]\n\tif (!namespaces[ns]) {\n\t\tlogger.error(`${prop} namespace unknown`, { prop, namespaces })\n\t\treturn false\n\t}\n\n\twindow._nc_dav_properties.push(prop)\n\twindow._nc_dav_namespaces = namespaces\n\treturn true\n}\n\n/**\n * Get the registered dav properties\n */\nexport const getDavProperties = function(): string {\n\tif (typeof window._nc_dav_properties === 'undefined') {\n\t\twindow._nc_dav_properties = [...defaultDavProperties]\n\t}\n\n\treturn window._nc_dav_properties.map((prop) => `<${prop} />`).join(' ')\n}\n\n/**\n * Get the registered dav namespaces\n */\nexport const getDavNameSpaces = function(): string {\n\tif (typeof window._nc_dav_namespaces === 'undefined') {\n\t\twindow._nc_dav_namespaces = { ...defaultDavNamespaces }\n\t}\n\n\treturn Object.keys(window._nc_dav_namespaces)\n\t\t.map((ns) => `xmlns:${ns}=\"${window._nc_dav_namespaces?.[ns]}\"`)\n\t\t.join(' ')\n}\n\n/**\n * Get the default PROPFIND request body\n */\nexport const davGetDefaultPropfind = function(): string {\n\treturn `<?xml version=\"1.0\"?>\n\t\t<d:propfind ${getDavNameSpaces()}>\n\t\t\t<d:prop>\n\t\t\t\t${getDavProperties()}\n\t\t\t</d:prop>\n\t\t</d:propfind>`\n}\n\n/**\n * Get the REPORT body to filter for favorite nodes\n */\nexport const davGetFavoritesReport = function(): string {\n\treturn `<?xml version=\"1.0\"?>\n\t\t<oc:filter-files ${getDavNameSpaces()}>\n\t\t\t<d:prop>\n\t\t\t\t${getDavProperties()}\n\t\t\t</d:prop>\n\t\t\t<oc:filter-rules>\n\t\t\t\t<oc:favorite>1</oc:favorite>\n\t\t\t</oc:filter-rules>\n\t\t</oc:filter-files>`\n}\n\n/**\n * Get the SEARCH body to search for recently modified files\n *\n * @param lastModified Oldest timestamp to include (Unix timestamp)\n * @example\n * ```ts\n * // SEARCH for recent files need a different DAV endpoint\n * const client = davGetClient(generateRemoteUrl('dav'))\n * // Timestamp of last week\n * const lastWeek = Math.round(Date.now() / 1000) - (60 * 60 * 24 * 7)\n * const contentsResponse = await client.getDirectoryContents(path, {\n * details: true,\n * data: davGetRecentSearch(lastWeek),\n * headers: {\n * method: 'SEARCH',\n * 'Content-Type': 'application/xml; charset=utf-8',\n * },\n * deep: true,\n * }) as ResponseDataDetailed<FileStat[]>\n * ```\n */\nexport const davGetRecentSearch = function(lastModified: number): string {\n\treturn `<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<d:searchrequest ${getDavNameSpaces()}\n\txmlns:ns=\"https://github.com/icewind1991/SearchDAV/ns\">\n\t<d:basicsearch>\n\t\t<d:select>\n\t\t\t<d:prop>\n\t\t\t\t${getDavProperties()}\n\t\t\t</d:prop>\n\t\t</d:select>\n\t\t<d:from>\n\t\t\t<d:scope>\n\t\t\t\t<d:href>/files/${getCurrentUser()?.uid}/</d:href>\n\t\t\t\t<d:depth>infinity</d:depth>\n\t\t\t</d:scope>\n\t\t</d:from>\n\t\t<d:where>\n\t\t\t<d:and>\n\t\t\t\t<d:or>\n\t\t\t\t\t<d:not>\n\t\t\t\t\t\t<d:eq>\n\t\t\t\t\t\t\t<d:prop>\n\t\t\t\t\t\t\t\t<d:getcontenttype/>\n\t\t\t\t\t\t\t</d:prop>\n\t\t\t\t\t\t\t<d:literal>httpd/unix-directory</d:literal>\n\t\t\t\t\t\t</d:eq>\n\t\t\t\t\t</d:not>\n\t\t\t\t\t<d:eq>\n\t\t\t\t\t\t<d:prop>\n\t\t\t\t\t\t\t<oc:size/>\n\t\t\t\t\t\t</d:prop>\n\t\t\t\t\t\t<d:literal>0</d:literal>\n\t\t\t\t\t</d:eq>\n\t\t\t\t</d:or>\n\t\t\t\t<d:gt>\n\t\t\t\t\t<d:prop>\n\t\t\t\t\t\t<d:getlastmodified/>\n\t\t\t\t\t</d:prop>\n\t\t\t\t\t<d:literal>${lastModified}</d:literal>\n\t\t\t\t</d:gt>\n\t\t\t</d:and>\n\t\t</d:where>\n\t\t<d:orderby>\n\t\t\t<d:order>\n\t\t\t\t<d:prop>\n\t\t\t\t\t<d:getlastmodified/>\n\t\t\t\t</d:prop>\n\t\t\t\t<d:descending/>\n\t\t\t</d:order>\n\t\t</d:orderby>\n\t\t<d:limit>\n\t\t\t<d:nresults>100</d:nresults>\n\t\t\t<ns:firstresult>0</ns:firstresult>\n\t\t</d:limit>\n\t</d:basicsearch>\n</d:searchrequest>`\n}\n","/**\n * @copyright Copyright (c) 2023 John Molakvoæ <skjnldsv@protonmail.com>\n *\n * @author John Molakvoæ <skjnldsv@protonmail.com>\n * @author Ferdinand Thiessen <opensource@fthiessen.de>\n *\n * @license AGPL-3.0-or-later\n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see <http://www.gnu.org/licenses/>.\n *\n */\nimport { Permission } from '../permissions'\n\n/**\n * Parse the webdav permission string to a permission enum\n *\n * @param permString The DAV permission string\n */\nexport const davParsePermissions = function(permString = ''): number {\n\tlet permissions = Permission.NONE\n\n\tif (!permString) { return permissions }\n\n\tif (permString.includes('C') || permString.includes('K')) { permissions |= Permission.CREATE }\n\n\tif (permString.includes('G')) { permissions |= Permission.READ }\n\n\tif (permString.includes('W') || permString.includes('N') || permString.includes('V')) { permissions |= Permission.UPDATE }\n\n\tif (permString.includes('D')) { permissions |= Permission.DELETE }\n\n\tif (permString.includes('R')) { permissions |= Permission.SHARE }\n\n\treturn permissions\n}\n","/**\n * @copyright Copyright (c) 2022 John Molakvoæ <skjnldsv@protonmail.com>\n *\n * @author John Molakvoæ <skjnldsv@protonmail.com>\n *\n * @license AGPL-3.0-or-later\n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see <http://www.gnu.org/licenses/>.\n *\n */\nexport enum FileType {\n\tFolder = 'folder',\n\tFile = 'file',\n}\n","/**\n * @copyright Copyright (c) 2022 John Molakvoæ <skjnldsv@protonmail.com>\n *\n * @author John Molakvoæ <skjnldsv@protonmail.com>\n *\n * @license AGPL-3.0-or-later\n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see <http://www.gnu.org/licenses/>.\n *\n */\n\nimport { join } from 'path'\nimport { Permission } from '../permissions'\nimport { NodeStatus } from './node'\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport interface Attribute { [key: string]: any }\n\nexport interface NodeData {\n\t/** Unique ID */\n\tid?: number\n\n\t/**\n\t * URL to the ressource.\n\t * e.g. https://cloud.domain.com/remote.php/dav/files/emma/Photos/picture.jpg\n\t * or https://domain.com/Photos/picture.jpg\n\t */\n\tsource: string\n\n\t/** Last modified time */\n\tmtime?: Date\n\n\t/** Creation time */\n\tcrtime?: Date\n\n\t/** The mime type Optional for folders only */\n\tmime?: string\n\n\t/** The node size type */\n\tsize?: number\n\n\t/** The node permissions */\n\tpermissions?: Permission\n\n\t/** The owner UID of this node */\n\towner: string|null\n\n\t/** The node attributes */\n\tattributes?: Attribute\n\n\t/**\n\t * The absolute root of the home relative to the service.\n\t * It is highly recommended to provide that information.\n\t * e.g. /files/emma\n\t */\n\troot?: string\n\n\t/** The node status */\n\tstatus?: NodeStatus\n}\n\n/**\n * Check if a node source is from a specific DAV service\n *\n * @param source The source to check\n * @param davService Pattern to check if source is DAV ressource\n */\nexport const isDavRessource = function(source: string, davService: RegExp): boolean {\n\treturn source.match(davService) !== null\n}\n\n/**\n * Validate Node construct data\n *\n * @param data The node data\n * @param davService Pattern to check if source is DAV ressource\n */\nexport const validateData = (data: NodeData, davService: RegExp) => {\n\tif (data.id && typeof data.id !== 'number') {\n\t\tthrow new Error('Invalid id type of value')\n\t}\n\n\tif (!data.source) {\n\t\tthrow new Error('Missing mandatory source')\n\t}\n\n\ttry {\n\t\t// eslint-disable-next-line no-new\n\t\tnew URL(data.source)\n\t} catch (e) {\n\t\tthrow new Error('Invalid source format, source must be a valid URL')\n\t}\n\n\tif (!data.source.startsWith('http')) {\n\t\tthrow new Error('Invalid source format, only http(s) is supported')\n\t}\n\n\tif (data.mtime && !(data.mtime instanceof Date)) {\n\t\tthrow new Error('Invalid mtime type')\n\t}\n\n\tif (data.crtime && !(data.crtime instanceof Date)) {\n\t\tthrow new Error('Invalid crtime type')\n\t}\n\n\tif (!data.mime || typeof data.mime !== 'string'\n\t\t|| !data.mime.match(/^[-\\w.]+\\/[-+\\w.]+$/gi)) {\n\t\tthrow new Error('Missing or invalid mandatory mime')\n\t}\n\n\t// Allow size to be 0\n\tif ('size' in data && typeof data.size !== 'number' && data.size !== undefined) {\n\t\tthrow new Error('Invalid size type')\n\t}\n\n\t// Allow permissions to be 0\n\tif ('permissions' in data\n\t\t&& data.permissions !== undefined\n\t\t&& !(typeof data.permissions === 'number'\n\t\t\t&& data.permissions >= Permission.NONE\n\t\t\t&& data.permissions <= Permission.ALL\n\t\t)) {\n\t\tthrow new Error('Invalid permissions')\n\t}\n\n\tif (data.owner\n\t\t&& data.owner !== null\n\t\t&& typeof data.owner !== 'string') {\n\t\tthrow new Error('Invalid owner type')\n\t}\n\n\tif (data.attributes && typeof data.attributes !== 'object') {\n\t\tthrow new Error('Invalid attributes type')\n\t}\n\n\tif (data.root && typeof data.root !== 'string') {\n\t\tthrow new Error('Invalid root type')\n\t}\n\n\tif (data.root && !data.root.startsWith('/')) {\n\t\tthrow new Error('Root must start with a leading slash')\n\t}\n\n\tif (data.root && !data.source.includes(data.root)) {\n\t\tthrow new Error('Root must be part of the source')\n\t}\n\n\tif (data.root && isDavRessource(data.source, davService)) {\n\t\tconst service = data.source.match(davService)![0]\n\t\tif (!data.source.includes(join(service, data.root))) {\n\t\t\tthrow new Error('The root must be relative to the service. e.g /files/emma')\n\t\t}\n\t}\n\n\tif (data.status && !Object.values(NodeStatus).includes(data.status)) {\n\t\tthrow new Error('Status must be a valid NodeStatus')\n\t}\n}\n","/**\n * @copyright Copyright (c) 2022 John Molakvoæ <skjnldsv@protonmail.com>\n *\n * @author John Molakvoæ <skjnldsv@protonmail.com>\n *\n * @license AGPL-3.0-or-later\n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see <http://www.gnu.org/licenses/>.\n *\n */\nimport { basename, extname, dirname } from 'path'\nimport { encodePath } from '@nextcloud/paths'\n\nimport { Permission } from '../permissions'\nimport { FileType } from './fileType'\nimport { Attribute, NodeData, isDavRessource, validateData } from './nodeData'\nimport logger from '../utils/logger'\n\nexport enum NodeStatus {\n\t/** This is a new node and it doesn't exists on the filesystem yet */\n\tNEW = 'new',\n\t/** This node has failed and is unavailable */\n\tFAILED = 'failed',\n\t/** This node is currently loading or have an operation in progress */\n\tLOADING = 'loading',\n\t/** This node is locked and cannot be modified */\n\tLOCKED = 'locked',\n}\n\nexport abstract class Node {\n\n\tprivate _data: NodeData\n\tprivate _attributes: Attribute\n\tprivate _knownDavService = /(remote|public)\\.php\\/(web)?dav/i\n\n\tprivate readonlyAttributes = Object.entries(Object.getOwnPropertyDescriptors(Node.prototype))\n\t\t.filter(e => typeof e[1].get === 'function' && e[0] !== '__proto__')\n\t\t.map(e => e[0])\n\n\tprivate handler = {\n\t\tset: (target: Attribute, prop: string, value: unknown): boolean => {\n\t\t\tif (this.readonlyAttributes.includes(prop)) {\n\t\t\t\treturn false\n\t\t\t}\n\t\t\t// Edit modification time\n\t\t\tthis.updateMtime()\n\t\t\t// Apply original changes\n\t\t\treturn Reflect.set(target, prop, value)\n\t\t},\n\t\tdeleteProperty: (target: Attribute, prop: string): boolean => {\n\t\t\tif (this.readonlyAttributes.includes(prop)) {\n\t\t\t\treturn false\n\t\t\t}\n\t\t\t// Edit modification time\n\t\t\tthis.updateMtime()\n\t\t\t// Apply original changes\n\t\t\treturn Reflect.deleteProperty(target, prop)\n\t\t},\n\t\t// TODO: This is deprecated and only needed for files v3\n\t\tget: (target: Attribute, prop: string, receiver) => {\n\t\t\tif (this.readonlyAttributes.includes(prop)) {\n\t\t\t\tlogger.warn(`Accessing \"Node.attributes.${prop}\" is deprecated, access it directly on the Node instance.`)\n\t\t\t\treturn Reflect.get(this, prop)\n\t\t\t}\n\t\t\treturn Reflect.get(target, prop, receiver)\n\t\t},\n\t} as ProxyHandler<Attribute>\n\n\tconstructor(data: NodeData, davService?: RegExp) {\n\t\t// Validate data\n\t\tvalidateData(data, davService || this._knownDavService)\n\n\t\tthis._data = { ...data, attributes: {} }\n\n\t\t// Proxy the attributes to update the mtime on change\n\t\tthis._attributes = new Proxy(this._data.attributes!, this.handler)\n\n\t\t// Update attributes, this sanitizes the attributes to only contain valid attributes\n\t\tthis.update(data.attributes ?? {})\n\n\t\t// Reset the mtime if changed while updating the attributes\n\t\tthis._data.mtime = data.mtime\n\n\t\tif (davService) {\n\t\t\tthis._knownDavService = davService\n\t\t}\n\t}\n\n\t/**\n\t * Get the source url to this object\n\t * There is no setter as the source is not meant to be changed manually.\n\t * You can use the rename or move method to change the source.\n\t */\n\tget source(): string {\n\t\t// strip any ending slash\n\t\treturn this._data.source.replace(/\\/$/i, '')\n\t}\n\n\t/**\n\t * Get the encoded source url to this object for requests purposes\n\t */\n\tget encodedSource(): string {\n\t\tconst { origin } = new URL(this.source)\n\t\treturn origin + encodePath(this.source.slice(origin.length))\n\t}\n\n\t/**\n\t * Get this object name\n\t * There is no setter as the source is not meant to be changed manually.\n\t * You can use the rename or move method to change the source.\n\t */\n\tget basename(): string {\n\t\treturn basename(this.source)\n\t}\n\n\t/**\n\t * Get this object's extension\n\t * There is no setter as the source is not meant to be changed manually.\n\t * You can use the rename or move method to change the source.\n\t */\n\tget extension(): string|null {\n\t\treturn extname(this.source)\n\t}\n\n\t/**\n\t * Get the directory path leading to this object\n\t * Will use the relative path to root if available\n\t *\n\t * There is no setter as the source is not meant to be changed manually.\n\t * You can use the rename or move method to change the source.\n\t */\n\tget dirname(): string {\n\t\tif (this.root) {\n\t\t\tlet source = this.source\n\t\t\tif (this.isDavRessource) {\n\t\t\t\t// ensure we only work on the real path in case root is not distinct\n\t\t\t\tsource = source.split(this._knownDavService).pop()!\n\t\t\t}\n\t\t\t// Using replace would remove all part matching root\n\t\t\tconst firstMatch = source.indexOf(this.root)\n\t\t\t// Ensure we do not remove the leading slash\n\t\t\tconst root = this.root.replace(/\\/$/, '')\n\t\t\treturn dirname(source.slice(firstMatch + root.length) || '/')\n\t\t}\n\n\t\t// This should always be a valid URL\n\t\t// as this is tested in the constructor\n\t\tconst url = new URL(this.source)\n\t\treturn dirname(url.pathname)\n\t}\n\n\t/**\n\t * Is it a file or a folder ?\n\t */\n\tabstract get type(): FileType\n\n\t/**\n\t * Get the file mime\n\t * There is no setter as the mime is not meant to be changed\n\t */\n\tget mime(): string|undefined {\n\t\treturn this._data.mime\n\t}\n\n\t/**\n\t * Get the file modification time\n\t * There is no setter as the modification time is not meant to be changed manually.\n\t * It will be automatically updated when the attributes are changed.\n\t */\n\tget mtime(): Date|undefined {\n\t\treturn this._data.mtime\n\t}\n\n\t/**\n\t * Get the file creation time\n\t * There is no setter as the creation time is not meant to be changed\n\t */\n\tget crtime(): Date|undefined {\n\t\treturn this._data.crtime\n\t}\n\n\t/**\n\t * Get the file size\n\t */\n\tget size(): number|undefined {\n\t\treturn this._data.size\n\t}\n\n\t/**\n\t * Set the file size\n\t */\n\tset size(size: number|undefined) {\n\t\tthis.updateMtime()\n\t\tthis._data.size = size\n\t}\n\n\t/**\n\t * Get the file attribute\n\t * This contains all additional attributes not provided by the Node class\n\t */\n\tget attributes(): Attribute {\n\t\treturn this._attributes\n\t}\n\n\t/**\n\t * Get the file permissions\n\t */\n\tget permissions(): Permission {\n\t\t// If this is not a dav ressource, we can only read it\n\t\tif (this.owner === null && !this.isDavRessource) {\n\t\t\treturn Permission.READ\n\t\t}\n\n\t\t// If the permissions are not defined, we have none\n\t\treturn this._data.permissions !== undefined\n\t\t\t? this._data.permissions\n\t\t\t: Permission.NONE\n\t}\n\n\t/**\n\t * Set the file permissions\n\t */\n\tset permissions(permissions: Permission) {\n\t\tthis.updateMtime()\n\t\tthis._data.permissions = permissions\n\t}\n\n\t/**\n\t * Get the file owner\n\t * There is no setter as the owner is not meant to be changed\n\t */\n\tget owner(): string|null {\n\t\t// Remote ressources have no owner\n\t\tif (!this.isDavRessource) {\n\t\t\treturn null\n\t\t}\n\t\treturn this._data.owner\n\t}\n\n\t/**\n\t * Is this a dav-related ressource ?\n\t */\n\tget isDavRessource(): boolean {\n\t\treturn isDavRessource(this.source, this._knownDavService)\n\t}\n\n\t/**\n\t * Get the dav root of this object\n\t * There is no setter as the root is not meant to be changed\n\t */\n\tget root(): string|null {\n\t\t// If provided (recommended), use the root and strip away the ending slash\n\t\tif (this._data.root) {\n\t\t\treturn this._data.root.replace(/^(.+)\\/$/, '$1')\n\t\t}\n\n\t\t// Use the source to get the root from the dav service\n\t\tif (this.isDavRessource) {\n\t\t\tconst root = dirname(this.source)\n\t\t\treturn root.split(this._knownDavService).pop() || null\n\t\t}\n\n\t\treturn null\n\t}\n\n\t/**\n\t * Get the absolute path of this object relative to the root\n\t */\n\tget path(): string {\n\t\tif (this.root) {\n\t\t\tlet source = this.source\n\t\t\tif (this.isDavRessource) {\n\t\t\t\t// ensure we only work on the real path in case root is not distinct\n\t\t\t\tsource = source.split(this._knownDavService).pop()!\n\t\t\t}\n\t\t\t// Using replace would remove all part matching root\n\t\t\tconst firstMatch = source.indexOf(this.root)\n\t\t\t// Ensure we do not remove the leading slash\n\t\t\tconst root = this.root.replace(/\\/$/, '')\n\t\t\treturn source.slice(firstMatch + root.length) || '/'\n\t\t}\n\t\treturn (this.dirname + '/' + this.basename).replace(/\\/\\//g, '/')\n\t}\n\n\t/**\n\t * Get the node id if defined.\n\t * There is no setter as the fileid is not meant to be changed\n\t */\n\tget fileid(): number|undefined {\n\t\treturn this._data?.id\n\t}\n\n\t/**\n\t * Get the node status.\n\t */\n\tget status(): NodeStatus|undefined {\n\t\treturn this._data?.status\n\t}\n\n\t/**\n\t * Set the node status.\n\t */\n\tset status(status: NodeStatus|undefined) {\n\t\tthis._data.status = status\n\t}\n\n\t/**\n\t * Move the node to a new destination\n\t *\n\t * @param {string} destination the new source.\n\t * e.g. https://cloud.domain.com/remote.php/dav/files/emma/Photos/picture.jpg\n\t */\n\tmove(destination: string) {\n\t\tvalidateData({ ...this._data, source: destination }, this._knownDavService)\n\t\tthis._data.source = destination\n\t\tthis.updateMtime()\n\t}\n\n\t/**\n\t * Rename the node\n\t * This aliases the move method for easier usage\n\t *\n\t * @param basename The new name of the node\n\t */\n\trename(basename: string) {\n\t\tif (basename.includes('/')) {\n\t\t\tthrow new Error('Invalid basename')\n\t\t}\n\t\tthis.move(dirname(this.source) + '/' + basename)\n\t}\n\n\t/**\n\t * Update the mtime if exists.\n\t */\n\tprivate updateMtime() {\n\t\tif (this._data.mtime) {\n\t\t\tthis._data.mtime = new Date()\n\t\t}\n\t}\n\n\t/**\n\t * Update the attributes of the node\n\t *\n\t * @param attributes The new attributes to update on the Node attributes\n\t */\n\tupdate(attributes: Attribute) {\n\t\tfor (const [name, value] of Object.entries(attributes)) {\n\t\t\ttry {\n\t\t\t\tif (value === undefined) {\n\t\t\t\t\tdelete this.attributes[name]\n\t\t\t\t} else {\n\t\t\t\t\tthis.attributes[name] = value\n\t\t\t\t}\n\t\t\t} catch (e) {\n\t\t\t\t// Ignore readonly attributes\n\t\t\t\tif (e instanceof TypeError) {\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\t\t\t\t// Throw all other exceptions\n\t\t\t\tthrow e\n\t\t\t}\n\t\t}\n\t}\n\n}\n","/**\n * @copyright Copyright (c) 2022 John Molakvoæ <skjnldsv@protonmail.com>\n *\n * @author John Molakvoæ <skjnldsv@protonmail.com>\n *\n * @license AGPL-3.0-or-later\n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see <http://www.gnu.org/licenses/>.\n *\n */\nimport { FileType } from './fileType'\nimport { Node } from './node'\n\nexport class File extends Node {\n\n\tget type(): FileType {\n\t\treturn FileType.File\n\t}\n\n}\n","/**\n * @copyright Copyright (c) 2022 John Molakvoæ <skjnldsv@protonmail.com>\n *\n * @author John Molakvoæ <skjnldsv@protonmail.com>\n *\n * @license AGPL-3.0-or-later\n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see <http://www.gnu.org/licenses/>.\n *\n */\nimport { FileType } from './fileType'\nimport { Node } from './node'\nimport { NodeData } from './nodeData'\n\nexport class Folder extends Node {\n\n\tconstructor(data: NodeData) {\n\t\t// enforcing mimes\n\t\tsuper({\n\t\t\t...data,\n\t\t\tmime: 'httpd/unix-directory',\n\t\t})\n\t}\n\n\tget type(): FileType {\n\t\treturn FileType.Folder\n\t}\n\n\tget extension(): string|null {\n\t\treturn null\n\t}\n\n\tget mime(): string {\n\t\treturn 'httpd/unix-directory'\n\t}\n\n}\n","/**\n * @copyright Copyright (c) 2023 John Molakvoæ <skjnldsv@protonmail.com>\n *\n * @author John Molakvoæ <skjnldsv@protonmail.com>\n * @author Ferdinand Thiessen <opensource@fthiessen.de>\n *\n * @license AGPL-3.0-or-later\n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see <http://www.gnu.org/licenses/>.\n *\n */\nimport type { DAVResultResponseProps, FileStat, ResponseDataDetailed, WebDAVClient } from 'webdav'\nimport type { Node } from '../files/node'\n\nimport { File } from '../files/file'\nimport { Folder } from '../files/folder'\nimport { NodeData } from '../files/nodeData'\nimport { davParsePermissions } from './davPermissions'\nimport { davGetFavoritesReport } from './davProperties'\n\nimport { getCurrentUser, getRequestToken, onRequestTokenUpdate } from '@nextcloud/auth'\nimport { generateRemoteUrl } from '@nextcloud/router'\nimport { createClient, getPatcher } from 'webdav'\nimport { CancelablePromise } from 'cancelable-promise'\n\n/**\n * Nextcloud DAV result response\n */\ninterface ResponseProps extends DAVResultResponseProps {\n\tpermissions: string\n\tmime: string\n\tfileid: number\n\tsize: number\n\t'owner-id': string | number\n}\n\n/**\n * The DAV root path for the current user\n */\nexport const davRootPath = `/files/${getCurrentUser()?.uid}`\n\n/**\n * The DAV remote URL used as base URL for the WebDAV client\n */\nexport const davRemoteURL = generateRemoteUrl('dav')\n\n/**\n * Get a WebDAV client configured to include the Nextcloud request token\n *\n * @param remoteURL The DAV server remote URL\n * @param headers Optional additional headers to set for every request\n */\nexport const davGetClient = function(remoteURL = davRemoteURL, headers: Record<string, string> = {}) {\n\tconst client = createClient(remoteURL, { headers })\n\n\t/**\n\t * Set headers for DAV requests\n\t * @param token CSRF token\n\t */\n\tfunction setHeaders(token: string | null) {\n\t\tclient.setHeaders({\n\t\t\t...headers,\n\t\t\t// Add this so the server knows it is an request from the browser\n\t\t\t'X-Requested-With': 'XMLHttpRequest',\n\t\t\t// Inject user auth\n\t\t\trequesttoken: token ?? '',\n\t\t})\n\t}\n\n\t// refresh headers when request token changes\n\tonRequestTokenUpdate(setHeaders)\n\tsetHeaders(getRequestToken())\n\n\t/**\n\t * Allow to override the METHOD to support dav REPORT\n\t *\n\t * @see https://github.com/perry-mitchell/webdav-client/blob/8d9694613c978ce7404e26a401c39a41f125f87f/source/request.ts\n\t */\n\tconst patcher = getPatcher()\n\t// eslint-disable-next-line @typescript-eslint/ban-ts-comment\n\t// @ts-ignore\n\t// https://github.com/perry-mitchell/hot-patcher/issues/6\n\tpatcher.patch('fetch', (url: string, options: RequestInit): Promise<Response> => {\n\t\tconst headers = options.headers as Record<string, string>\n\t\tif (headers?.method) {\n\t\t\toptions.method = headers.method\n\t\t\tdelete headers.method\n\t\t}\n\t\treturn fetch(url, options)\n\t})\n\n\treturn client\n}\n\n/**\n * Use WebDAV to query for favorite Nodes\n *\n * @param davClient The WebDAV client to use for performing the request\n * @param path Base path for the favorites, if unset all favorites are queried\n * @param davRoot The root path for the DAV user (defaults to `davRootPath`)\n * @example\n * ```js\n * import { davGetClient, davRootPath, getFavoriteNodes } from '@nextcloud/files'\n *\n * const client = davGetClient()\n * // query favorites for the root\n * const favorites = await getFavoriteNodes(client)\n * // which is the same as writing:\n * const favorites = await getFavoriteNodes(client, '/', davRootPath)\n * ```\n */\nexport const getFavoriteNodes = (davClient: WebDAVClient, path = '/', davRoot = davRootPath): CancelablePromise<Node[]> => {\n\tconst controller = new AbortController()\n\treturn new CancelablePromise(async (resolve, reject, onCancel) => {\n\t\tonCancel(() => controller.abort())\n\t\ttry {\n\t\t\tconst contentsResponse = await davClient.getDirectoryContents(`${davRoot}${path}`, {\n\t\t\t\tsignal: controller.signal,\n\t\t\t\tdetails: true,\n\t\t\t\tdata: davGetFavoritesReport(),\n\t\t\t\theaders: {\n\t\t\t\t\t// see davGetClient for patched webdav client\n\t\t\t\t\tmethod: 'REPORT',\n\t\t\t\t},\n\t\t\t\tincludeSelf: true,\n\t\t\t}) as ResponseDataDetailed<FileStat[]>\n\n\t\t\tconst nodes = contentsResponse.data\n\t\t\t\t.filter(node => node.filename !== path) // exclude current dir\n\t\t\t\t.map((result) => davResultToNode(result, davRoot))\n\t\t\tresolve(nodes)\n\t\t} catch (error) {\n\t\t\treject(error)\n\t\t}\n\t})\n}\n\n/**\n * Covert DAV result `FileStat` to `Node`\n *\n * @param node The DAV result\n * @param filesRoot The DAV files root path\n * @param remoteURL The DAV server remote URL (same as on `davGetClient`)\n */\nexport const davResultToNode = function(node: FileStat, filesRoot = davRootPath, remoteURL = davRemoteURL): Node {\n\tlet userId = getCurrentUser()?.uid\n\tconst isPublic = document.querySelector<HTMLInputElement>('input#isPublic')?.value\n\tif (isPublic) {\n\t\tuserId = userId ?? document.querySelector<HTMLInputElement>('input#sharingUserId')?.value\n\t\tuserId = userId ?? 'anonymous'\n\t} else if (!userId) {\n\t\tthrow new Error('No user id found')\n\t}\n\n\tconst props = node.props as ResponseProps\n\tconst permissions = davParsePermissions(props?.permissions)\n\tconst owner = String(props?.['owner-id'] || userId)\n\n\tconst nodeData: NodeData = {\n\t\tid: props?.fileid || 0,\n\t\tsource: `${remoteURL}${node.filename}`,\n\t\tmtime: new Date(Date.parse(node.lastmod)),\n\t\tmime: node.mime || 'application/octet-stream',\n\t\tsize: props?.size || Number.parseInt(props.getcontentlength || '0'),\n\t\tpermissions,\n\t\towner,\n\t\troot: filesRoot,\n\t\tattributes: {\n\t\t\t...node,\n\t\t\t...props,\n\t\t\thasPreview: props?.['has-preview'],\n\t\t},\n\t}\n\n\tdelete nodeData.attributes?.props\n\n\treturn node.type === 'file' ? new File(nodeData) : new Folder(nodeData)\n}\n","/**\n * SPDX-FileCopyrightText: Ferdinand Thiessen <opensource@fthiessen.de>\n * SPDX-License-Identifier: AGPL-3.0-or-later or LGPL-3.0-or-later\n */\n\nconst forbiddenCharacters = window._oc_config?.forbidden_filenames_characters ?? ['/', '\\\\']\nconst forbiddenFilenameRegex = window._oc_config?.blacklist_files_regex ? new RegExp(window._oc_config.blacklist_files_regex) : null\n\n/**\n * Check the validity of a filename\n * This is a convinient wrapper for `checkFilenameValidity` to only return a boolean for the valid\n * @param filename Filename to check validity\n */\nexport function isFilenameValid(filename: string): boolean {\n\t// Check forbidden characters (available with Nextcloud 29)\n\tif (forbiddenCharacters.some((character) => filename.includes(character))) {\n\t\treturn false\n\t}\n\t// Check forbidden filename regex\n\tif (forbiddenFilenameRegex !== null && filename.match(forbiddenFilenameRegex)) {\n\t\treturn false\n\t}\n\t// in Nextcloud 30 also check forbidden file extensions and file prefixes\n\treturn true\n}\n","/**\n * @copyright 2019 Christoph Wurst <christoph@winzerhof-wurst.at>\n *\n * @author Christoph Wurst <christoph@winzerhof-wurst.at>\n * @author John Molakvoæ <skjnldsv@protonmail.com>\n *\n * @license AGPL-3.0-or-later\n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see <http://www.gnu.org/licenses/>.\n *\n */\n\nimport { getCanonicalLocale } from '@nextcloud/l10n'\n\nconst humanList = ['B', 'KB', 'MB', 'GB', 'TB', 'PB']\nconst humanListBinary = ['B', 'KiB', 'MiB', 'GiB', 'TiB', 'PiB']\n\n/**\n * Format a file size in a human-like format. e.g. 42GB\n *\n * The default for Nextcloud is like Windows using binary sizes but showing decimal units,\n * meaning 1024 bytes will show as 1KB instead of 1KiB or like on Apple 1.02 KB\n *\n * @param size in bytes\n * @param skipSmallSizes avoid rendering tiny sizes and return '< 1 KB' instead\n * @param binaryPrefixes True if size binary prefixes like `KiB` should be used as per IEC 80000-13\n * @param base1000 Set to true to use base 1000 as per SI or used by Apple (default is base 1024 like Linux or Windows)\n */\nexport function formatFileSize(size: number|string, skipSmallSizes = false, binaryPrefixes = false, base1000 = false): string {\n\t// Binary prefixes only work with base 1024\n\tbinaryPrefixes = binaryPrefixes && !base1000\n\n\tif (typeof size === 'string') {\n\t\tsize = Number(size)\n\t}\n\n\t// Calculate Log with base 1024 or 1000: size = base ** order\n\tlet order = size > 0 ? Math.floor(Math.log(size) / Math.log(base1000 ? 1000 : 1024)) : 0\n\n\t// Stay in range of the byte sizes that are defined\n\torder = Math.min((binaryPrefixes ? humanListBinary.length : humanList.length) - 1, order)\n\n\tconst readableFormat = binaryPrefixes ? humanListBinary[order] : humanList[order]\n\tlet relativeSize = (size / Math.pow(base1000 ? 1000 : 1024, order)).toFixed(1)\n\n\tif (skipSmallSizes === true && order === 0) {\n\t\treturn (relativeSize !== '0.0' ? '< 1 ' : '0 ') + (binaryPrefixes ? humanListBinary[1] : humanList[1])\n\t}\n\n\tif (order < 2) {\n\t\trelativeSize = parseFloat(relativeSize).toFixed(0)\n\t} else {\n\t\trelativeSize = parseFloat(relativeSize).toLocaleString(getCanonicalLocale())\n\t}\n\n\treturn relativeSize + ' ' + readableFormat\n}\n\n/**\n * Returns a file size in bytes from a humanly readable string\n * Note: `b` and `B` are both parsed as bytes and not as bit or byte.\n *\n * @param {string} value file size in human-readable format\n * @param {boolean} forceBinary for backwards compatibility this allows values to be base 2 (so 2KB means 2048 bytes instead of 2000 bytes)\n * @return {number} or null if string could not be parsed\n */\nexport function parseFileSize(value: string, forceBinary = false) {\n\ttry {\n\t\tvalue = `${value}`.toLocaleLowerCase().replaceAll(/\\s+/g, '').replaceAll(',', '.')\n\t} catch (e) {\n\t\treturn null\n\t}\n\n\tconst match = value.match(/^([0-9]*(\\.[0-9]*)?)([kmgtp]?)(i?)b?$/)\n\t// ignore not found, missing pre- and decimal, empty number\n\tif (match === null || match[1] === '.' || match[1] === '') {\n\t\treturn null\n\t}\n\n\tconst bytesArray = {\n\t\t'': 0,\n\t\tk: 1,\n\t\tm: 2,\n\t\tg: 3,\n\t\tt: 4,\n\t\tp: 5,\n\t\te: 6,\n\t}\n\n\tconst decimalString = `${match[1]}`\n\tconst base = (match[4] === 'i' || forceBinary) ? 1024 : 1000\n\n\treturn Math.round(Number.parseFloat(decimalString) * (base ** bytesArray[match[3]]))\n}\n","/**\n * SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors\n * SPDX-License-Identifier: AGPL-3.0-or-later\n */\nimport { getCanonicalLocale, getLanguage } from '@nextcloud/l10n'\n\ntype IdentifierFn<T> = (v: T) => unknown\ntype SortingOrder = 'asc'|'desc'\n\n/**\n * Helper to create string representation\n * @param value Value to stringify\n */\nfunction stringify(value: unknown) {\n\t// The default representation of Date is not sortable because of the weekday names in front of it\n\tif (value instanceof Date) {\n\t\treturn value.toISOString()\n\t}\n\treturn String(value)\n}\n\n/**\n * Natural order a collection\n * You can define identifiers as callback functions, that get the element and return the value to sort.\n *\n * @param collection The collection to order\n * @param identifiers An array of identifiers to use, by default the identity of the element is used\n * @param orders Array of orders, by default all identifiers are sorted ascening\n */\nexport function orderBy<T>(collection: readonly T[], identifiers?: IdentifierFn<T>[], orders?: SortingOrder[]): T[] {\n\t// If not identifiers are set we use the identity of the value\n\tidentifiers = identifiers ?? [(value) => value]\n\t// By default sort the collection ascending\n\torders = orders ?? []\n\tconst sorting = identifiers.map((_, index) => (orders[index] ?? 'asc') === 'asc' ? 1 : -1)\n\n\tconst collator = Intl.Collator(\n\t\t[getLanguage(), getCanonicalLocale()],\n\t\t{\n\t\t\t// handle 10 as ten and not as one-zero\n\t\t\tnumeric: true,\n\t\t\tusage: 'sort',\n\t\t},\n\t)\n\n\treturn [...collection].sort((a, b) => {\n\t\tfor (const [index, identifier] of identifiers.entries()) {\n\t\t\t// Get the local compare of stringified value a and b\n\t\t\tconst value = collator.compare(stringify(identifier(a)), stringify(identifier(b)))\n\t\t\t// If they do not match return the order\n\t\t\tif (value !== 0) {\n\t\t\t\treturn value * sorting[index]\n\t\t\t}\n\t\t\t// If they match we need to continue with the next identifier\n\t\t}\n\t\t// If all are equal we need to return equality\n\t\treturn 0\n\t})\n}\n","import type { Node } from '../files/node'\nimport { orderBy } from './sorting'\n\nexport enum FilesSortingMode {\n\tName = 'basename',\n\tModified = 'mtime',\n\tSize = 'size',\n}\n\nexport interface FilesSortingOptions {\n\t/**\n\t * They key to order the files by\n\t * @default FilesSortingMode.Name\n\t */\n\tsortingMode?: FilesSortingMode\n\n\t/**\n\t * @default 'asc'\n\t */\n\tsortingOrder?: 'asc'|'desc'\n\n\t/**\n\t * If set to true nodes marked as favorites are ordered on top of all other nodes\n\t * @default false\n\t */\n\tsortFavoritesFirst?: boolean\n\n\t/**\n\t * If set to true folders are ordered on top of files\n\t * @default false\n\t */\n\tsortFoldersFirst?: boolean\n}\n\n/**\n * Sort files and folders according to the sorting options\n * @param nodes Nodes to sort\n * @param options Sorting options\n */\nexport function sortNodes(nodes: Node[], options: FilesSortingOptions = {}): Node[] {\n\tconst sortingOptions = {\n\t\t// Default to sort by name\n\t\tsortingMode: FilesSortingMode.Name,\n\t\t// Default to sort ascending\n\t\tsortingOrder: 'asc' as const,\n\t\t...options,\n\t}\n\n\tconst identifiers = [\n\t\t// 1: Sort favorites first if enabled\n\t\t...(sortingOptions.sortFavoritesFirst ? [(v: Node) => v.attributes?.favorite !== 1] : []),\n\t\t// 2: Sort folders first if sorting by name\n\t\t...(sortingOptions.sortFoldersFirst ? [(v: Node) => v.type !== 'folder'] : []),\n\t\t// 3: Use sorting mode if NOT basename (to be able to use displayName too)\n\t\t...(sortingOptions.sortingMode !== FilesSortingMode.Name ? [(v: Node) => v[sortingOptions.sortingMode]] : []),\n\t\t// 4: Use displayName if available, fallback to name\n\t\t(v: Node) => v.attributes?.displayName || v.basename,\n\t\t// 5: Finally, use basename if all previous sorting methods failed\n\t\t(v: Node) => v.basename,\n\t]\n\tconst orders = [\n\t\t// (for 1): always sort favorites before normal files\n\t\t...(sortingOptions.sortFavoritesFirst ? ['asc'] : []),\n\t\t// (for 2): always sort folders before files\n\t\t...(sortingOptions.sortFoldersFirst ? ['asc'] : []),\n\t\t// (for 3): Reverse if sorting by mtime as mtime higher means edited more recent -> lower\n\t\t...(sortingOptions.sortingMode === FilesSortingMode.Modified ? [sortingOptions.sortingOrder === 'asc' ? 'desc' : 'asc'] : []),\n\t\t// (also for 3 so make sure not to conflict with 2 and 3)\n\t\t...(sortingOptions.sortingMode !== FilesSortingMode.Modified && sortingOptions.sortingMode !== FilesSortingMode.Name ? [sortingOptions.sortingOrder] : []),\n\t\t// for 4: use configured sorting direction\n\t\tsortingOptions.sortingOrder,\n\t\t// for 5: use configured sorting direction\n\t\tsortingOptions.sortingOrder,\n\t] as ('asc'|'desc')[]\n\n\treturn orderBy(nodes, identifiers, orders)\n}\n","/**\n * @copyright Copyright (c) 2022 John Molakvoæ <skjnldsv@protonmail.com>\n *\n * @author John Molakvoæ <skjnldsv@protonmail.com>\n *\n * @license AGPL-3.0-or-later\n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see <http://www.gnu.org/licenses/>.\n *\n */\nimport { View } from './view'\nimport logger from '../utils/logger'\n\nexport class Navigation {\n\n\tprivate _views: View[] = []\n\tprivate _currentView: View | null = null\n\n\tregister(view: View) {\n\t\tif (this._views.find(search => search.id === view.id)) {\n\t\t\tthrow new Error(`View id ${view.id} is already registered`)\n\t\t}\n\n\t\tthis._views.push(view)\n\t}\n\n\tremove(id: string) {\n\t\tconst index = this._views.findIndex(view => view.id === id)\n\t\tif (index !== -1) {\n\t\t\tthis._views.splice(index, 1)\n\t\t}\n\t}\n\n\tget views(): View[] {\n\t\treturn this._views\n\t}\n\n\tsetActive(view: View | null) {\n\t\tthis._currentView = view\n\t}\n\n\tget active(): View | null {\n\t\treturn this._currentView\n\t}\n\n}\n\nexport const getNavigation = function(): Navigation {\n\tif (typeof window._nc_navigation === 'undefined') {\n\t\twindow._nc_navigation = new Navigation()\n\t\tlogger.debug('Navigation service initialized')\n\t}\n\n\treturn window._nc_navigation\n}\n","/**\n * @copyright Copyright (c) 2022 John Molakvoæ <skjnldsv@protonmail.com>\n *\n * @author John Molakvoæ <skjnldsv@protonmail.com>\n *\n * @license AGPL-3.0-or-later\n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see <http://www.gnu.org/licenses/>.\n *\n */\nimport { View } from './view'\nimport { Node } from '../files/node'\n\ninterface ColumnData {\n\t/** Unique column ID */\n\tid: string\n\t/** Translated column title */\n\ttitle: string\n\t/** The content of the cell. The element will be appended within */\n\trender: (node: Node, view: View) => HTMLElement\n\t/** Function used to sort Nodes between them */\n\tsort?: (nodeA: Node, nodeB: Node) => number\n\t/**\n\t * Custom summary of the column to display at the end of the list.\n\t * Will not be displayed if nothing is provided\n\t */\n\tsummary?: (node: Node[], view: View) => string\n}\n\nexport class Column implements ColumnData {\n\n\tprivate _column: ColumnData\n\n\tconstructor(column: ColumnData) {\n\t\tisValidColumn(column)\n\t\tthis._column = column\n\t}\n\n\tget id() {\n\t\treturn this._column.id\n\t}\n\n\tget title() {\n\t\treturn this._column.title\n\t}\n\n\tget render() {\n\t\treturn this._column.render\n\t}\n\n\tget sort() {\n\t\treturn this._column.sort\n\t}\n\n\tget summary() {\n\t\treturn this._column.summary\n\t}\n\n}\n\n/**\n * Typescript cannot validate an interface.\n * Please keep in sync with the Column interface requirements.\n *\n * @param {ColumnData} column the column to check\n * @return {boolean} true if the column is valid\n */\nconst isValidColumn = function(column: ColumnData): boolean {\n\tif (!column.id || typeof column.id !== 'string') {\n\t\tthrow new Error('A column id is required')\n\t}\n\n\tif (!column.title || typeof column.title !== 'string') {\n\t\tthrow new Error('A column title is required')\n\t}\n\n\tif (!column.render || typeof column.render !== 'function') {\n\t\tthrow new Error('A render function is required')\n\t}\n\n\t// Optional properties\n\tif (column.sort && typeof column.sort !== 'function') {\n\t\tthrow new Error('Column sortFunction must be a function')\n\t}\n\n\tif (column.summary && typeof column.summary !== 'function') {\n\t\tthrow new Error('Column summary must be a function')\n\t}\n\n\treturn true\n}\n","'use strict';\n\nconst nameStartChar = ':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';\nconst nameChar = nameStartChar + '\\\\-.\\\\d\\\\u00B7\\\\u0300-\\\\u036F\\\\u203F-\\\\u2040';\nconst nameRegexp = '[' + nameStartChar + '][' + nameChar + ']*'\nconst regexName = new RegExp('^' + nameRegexp + '$');\n\nconst getAllMatches = function(string, regex) {\n const matches = [];\n let match = regex.exec(string);\n while (match) {\n const allmatches = [];\n allmatches.startIndex = regex.lastIndex - match[0].length;\n const len = match.length;\n for (let index = 0; index < len; index++) {\n allmatches.push(match[index]);\n }\n matches.push(allmatches);\n match = regex.exec(string);\n }\n return matches;\n};\n\nconst isName = function(string) {\n const match = regexName.exec(string);\n return !(match === null || typeof match === 'undefined');\n};\n\nexports.isExist = function(v) {\n return typeof v !== 'undefined';\n};\n\nexports.isEmptyObject = function(obj) {\n return Object.keys(obj).length === 0;\n};\n\n/**\n * Copy all the properties of a into b.\n * @param {*} target\n * @param {*} a\n */\nexports.merge = function(target, a, arrayMode) {\n if (a) {\n const keys = Object.keys(a); // will return an array of own properties\n const len = keys.length; //don't make it inline\n for (let i = 0; i < len; i++) {\n if (arrayMode === 'strict') {\n target[keys[i]] = [ a[keys[i]] ];\n } else {\n target[keys[i]] = a[keys[i]];\n }\n }\n }\n};\n/* exports.merge =function (b,a){\n return Object.assign(b,a);\n} */\n\nexports.getValue = function(v) {\n if (exports.isExist(v)) {\n return v;\n } else {\n return '';\n }\n};\n\n// const fakeCall = function(a) {return a;};\n// const fakeCallNoReturn = function() {};\n\nexports.isName = isName;\nexports.getAllMatches = getAllMatches;\nexports.nameRegexp = nameRegexp;\n","'use strict';\n\nconst util = require('./util');\n\nconst defaultOptions = {\n allowBooleanAttributes: false, //A tag can have attributes without any value\n unpairedTags: []\n};\n\n//const tagsPattern = new RegExp(\"<\\\\/?([\\\\w:\\\\-_\\.]+)\\\\s*\\/?>\",\"g\");\nexports.validate = function (xmlData, options) {\n options = Object.assign({}, defaultOptions, options);\n\n //xmlData = xmlData.replace(/(\\r\\n|\\n|\\r)/gm,\"\");//make it single line\n //xmlData = xmlData.replace(/(^\\s*<\\?xml.*?\\?>)/g,\"\");//Remove XML starting tag\n //xmlData = xmlData.replace(/(<!DOCTYPE[\\s\\w\\\"\\.\\/\\-\\:]+(\\[.*\\])*\\s*>)/g,\"\");//Remove DOCTYPE\n const tags = [];\n let tagFound = false;\n\n //indicates that the root tag has been closed (aka. depth 0 has been reached)\n let reachedRoot = false;\n\n if (xmlData[0] === '\\ufeff') {\n // check for byte order mark (BOM)\n xmlData = xmlData.substr(1);\n }\n \n for (let i = 0; i < xmlData.length; i++) {\n\n if (xmlData[i] === '<' && xmlData[i+1] === '?') {\n i+=2;\n i = readPI(xmlData,i);\n if (i.err) return i;\n }else if (xmlData[i] === '<') {\n //starting of tag\n //read until you reach to '>' avoiding any '>' in attribute value\n let tagStartPos = i;\n i++;\n \n if (xmlData[i] === '!') {\n i = readCommentAndCDATA(xmlData, i);\n continue;\n } else {\n let closingTag = false;\n if (xmlData[i] === '/') {\n //closing tag\n closingTag = true;\n i++;\n }\n //read tagname\n let tagName = '';\n for (; i < xmlData.length &&\n xmlData[i] !== '>' &&\n xmlData[i] !== ' ' &&\n xmlData[i] !== '\\t' &&\n xmlData[i] !== '\\n' &&\n xmlData[i] !== '\\r'; i++\n ) {\n tagName += xmlData[i];\n }\n tagName = tagName.trim();\n //console.log(tagName);\n\n if (tagName[tagName.length - 1] === '/') {\n //self closing tag without attributes\n tagName = tagName.substring(0, tagName.length - 1);\n //continue;\n i--;\n }\n if (!validateTagName(tagName)) {\n let msg;\n if (tagName.trim().length === 0) {\n msg = \"Invalid space after '<'.\";\n } else {\n msg = \"Tag '\"+tagName+\"' is an invalid name.\";\n }\n return getErrorObject('InvalidTag', msg, getLineNumberForPosition(xmlData, i));\n }\n\n const result = readAttributeStr(xmlData, i);\n if (result === false) {\n return getErrorObject('InvalidAttr', \"Attributes for '\"+tagName+\"' have open quote.\", getLineNumberForPosition(xmlData, i));\n }\n let attrStr = result.value;\n i = result.index;\n\n if (attrStr[attrStr.length - 1] === '/') {\n //self closing tag\n const attrStrStart = i - attrStr.length;\n attrStr = attrStr.substring(0, attrStr.length - 1);\n const isValid = validateAttributeString(attrStr, options);\n if (isValid === true) {\n tagFound = true;\n //continue; //text may presents after self closing tag\n } else {\n //the result from the nested function returns the position of the error within the attribute\n //in order to get the 'true' error line, we need to calculate the position where the attribute begins (i - attrStr.length) and then add the position within the attribute\n //this gives us the absolute index in the entire xml, which we can use to find the line at last\n return getErrorObject(isValid.err.code, isValid.err.msg, getLineNumberForPosition(xmlData, attrStrStart + isValid.err.line));\n }\n } else if (closingTag) {\n if (!result.tagClosed) {\n return getErrorObject('InvalidTag', \"Closing tag '\"+tagName+\"' doesn't have proper closing.\", getLineNumberForPosition(xmlData, i));\n } else if (attrStr.trim().length > 0) {\n return getErrorObject('InvalidTag', \"Closing tag '\"+tagName+\"' can't have attributes or invalid starting.\", getLineNumberForPosition(xmlData, tagStartPos));\n } else if (tags.length === 0) {\n return getErrorObject('InvalidTag', \"Closing tag '\"+tagName+\"' has not been opened.\", getLineNumberForPosition(xmlData, tagStartPos));\n } else {\n const otg = tags.pop();\n if (tagName !== otg.tagName) {\n let openPos = getLineNumberForPosition(xmlData, otg.tagStartPos);\n return getErrorObject('InvalidTag',\n \"Expected closing tag '\"+otg.tagName+\"' (opened in line \"+openPos.line+\", col \"+openPos.col+\") instead of closing tag '\"+tagName+\"'.\",\n getLineNumberForPosition(xmlData, tagStartPos));\n }\n\n //when there are no more tags, we reached the root level.\n if (tags.length == 0) {\n reachedRoot = true;\n }\n }\n } else {\n const isValid = validateAttributeString(attrStr, options);\n if (isValid !== true) {\n //the result from the nested function returns the position of the error within the attribute\n //in order to get the 'true' error line, we need to calculate the position where the attribute begins (i - attrStr.length) and then add the position within the attribute\n //this gives us the absolute index in the entire xml, which we can use to find the line at last\n return getErrorObject(isValid.err.code, isValid.err.msg, getLineNumberForPosition(xmlData, i - attrStr.length + isValid.err.line));\n }\n\n //if the root level has been reached before ...\n if (reachedRoot === true) {\n return getErrorObject('InvalidXml', 'Multiple possible root nodes found.', getLineNumberForPosition(xmlData, i));\n } else if(options.unpairedTags.indexOf(tagName) !== -1){\n //don't push into stack\n } else {\n tags.push({tagName, tagStartPos});\n }\n tagFound = true;\n }\n\n //skip tag text value\n //It may include comments and CDATA value\n for (i++; i < xmlData.length; i++) {\n if (xmlData[i] === '<') {\n if (xmlData[i + 1] === '!') {\n //comment or CADATA\n i++;\n i = readCommentAndCDATA(xmlData, i);\n continue;\n } else if (xmlData[i+1] === '?') {\n i = readPI(xmlData, ++i);\n if (i.err) return i;\n } else{\n break;\n }\n } else if (xmlData[i] === '&') {\n const afterAmp = validateAmpersand(xmlData, i);\n if (afterAmp == -1)\n return getErrorObject('InvalidChar', \"char '&' is not expected.\", getLineNumberForPosition(xmlData, i));\n i = afterAmp;\n }else{\n if (reachedRoot === true && !isWhiteSpace(xmlData[i])) {\n return getErrorObject('InvalidXml', \"Extra text at the end\", getLineNumberForPosition(xmlData, i));\n }\n }\n } //end of reading tag text value\n if (xmlData[i] === '<') {\n i--;\n }\n }\n } else {\n if ( isWhiteSpace(xmlData[i])) {\n continue;\n }\n return getErrorObject('InvalidChar', \"char '\"+xmlData[i]+\"' is not expected.\", getLineNumberForPosition(xmlData, i));\n }\n }\n\n if (!tagFound) {\n return getErrorObject('InvalidXml', 'Start tag expected.', 1);\n }else if (tags.length == 1) {\n return getErrorObject('InvalidTag', \"Unclosed tag '\"+tags[0].tagName+\"'.\", getLineNumberForPosition(xmlData, tags[0].tagStartPos));\n }else if (tags.length > 0) {\n return getErrorObject('InvalidXml', \"Invalid '\"+\n JSON.stringify(tags.map(t => t.tagName), null, 4).replace(/\\r?\\n/g, '')+\n \"' found.\", {line: 1, col: 1});\n }\n\n return true;\n};\n\nfunction isWhiteSpace(char){\n return char === ' ' || char === '\\t' || char === '\\n' || char === '\\r';\n}\n/**\n * Read Processing insstructions and skip\n * @param {*} xmlData\n * @param {*} i\n */\nfunction readPI(xmlData, i) {\n const start = i;\n for (; i < xmlData.length; i++) {\n if (xmlData[i] == '?' || xmlData[i] == ' ') {\n //tagname\n const tagname = xmlData.substr(start, i - start);\n if (i > 5 && tagname === 'xml') {\n return getErrorObject('InvalidXml', 'XML declaration allowed only at the start of the document.', getLineNumberForPosition(xmlData, i));\n } else if (xmlData[i] == '?' && xmlData[i + 1] == '>') {\n //check if valid attribut string\n i++;\n break;\n } else {\n continue;\n }\n }\n }\n return i;\n}\n\nfunction readCommentAndCDATA(xmlData, i) {\n if (xmlData.length > i + 5 && xmlData[i + 1] === '-' && xmlData[i + 2] === '-') {\n //comment\n for (i += 3; i < xmlData.length; i++) {\n if (xmlData[i] === '-' && xmlData[i + 1] === '-' && xmlData[i + 2] === '>') {\n i += 2;\n break;\n }\n }\n } else if (\n xmlData.length > i + 8 &&\n xmlData[i + 1] === 'D' &&\n xmlData[i + 2] === 'O' &&\n xmlData[i + 3] === 'C' &&\n xmlData[i + 4] === 'T' &&\n xmlData[i + 5] === 'Y' &&\n xmlData[i + 6] === 'P' &&\n xmlData[i + 7] === 'E'\n ) {\n let angleBracketsCount = 1;\n for (i += 8; i < xmlData.length; i++) {\n if (xmlData[i] === '<') {\n angleBracketsCount++;\n } else if (xmlData[i] === '>') {\n angleBracketsCount--;\n if (angleBracketsCount === 0) {\n break;\n }\n }\n }\n } else if (\n xmlData.length > i + 9 &&\n xmlData[i + 1] === '[' &&\n xmlData[i + 2] === 'C' &&\n xmlData[i + 3] === 'D' &&\n xmlData[i + 4] === 'A' &&\n xmlData[i + 5] === 'T' &&\n xmlData[i + 6] === 'A' &&\n xmlData[i + 7] === '['\n ) {\n for (i += 8; i < xmlData.length; i++) {\n if (xmlData[i] === ']' && xmlData[i + 1] === ']' && xmlData[i + 2] === '>') {\n i += 2;\n break;\n }\n }\n }\n\n return i;\n}\n\nconst doubleQuote = '\"';\nconst singleQuote = \"'\";\n\n/**\n * Keep reading xmlData until '<' is found outside the attribute value.\n * @param {string} xmlData\n * @param {number} i\n */\nfunction readAttributeStr(xmlData, i) {\n let attrStr = '';\n let startChar = '';\n let tagClosed = false;\n for (; i < xmlData.length; i++) {\n if (xmlData[i] === doubleQuote || xmlData[i] === singleQuote) {\n if (startChar === '') {\n startChar = xmlData[i];\n } else if (startChar !== xmlData[i]) {\n //if vaue is enclosed with double quote then single quotes are allowed inside the value and vice versa\n } else {\n startChar = '';\n }\n } else if (xmlData[i] === '>') {\n if (startChar === '') {\n tagClosed = true;\n break;\n }\n }\n attrStr += xmlData[i];\n }\n if (startChar !== '') {\n return false;\n }\n\n return {\n value: attrStr,\n index: i,\n tagClosed: tagClosed\n };\n}\n\n/**\n * Select all the attributes whether valid or invalid.\n */\nconst validAttrStrRegxp = new RegExp('(\\\\s*)([^\\\\s=]+)(\\\\s*=)?(\\\\s*([\\'\"])(([\\\\s\\\\S])*?)\\\\5)?', 'g');\n\n//attr, =\"sd\", a=\"amit's\", a=\"sd\"b=\"saf\", ab cd=\"\"\n\nfunction validateAttributeString(attrStr, options) {\n //console.log(\"start:\"+attrStr+\":end\");\n\n //if(attrStr.trim().length === 0) return true; //empty string\n\n const matches = util.getAllMatches(attrStr, validAttrStrRegxp);\n const attrNames = {};\n\n for (let i = 0; i < matches.length; i++) {\n if (matches[i][1].length === 0) {\n //nospace before attribute name: a=\"sd\"b=\"saf\"\n return getErrorObject('InvalidAttr', \"Attribute '\"+matches[i][2]+\"' has no space in starting.\", getPositionFromMatch(matches[i]))\n } else if (matches[i][3] !== undefined && matches[i][4] === undefined) {\n return getErrorObject('InvalidAttr', \"Attribute '\"+matches[i][2]+\"' is without value.\", getPositionFromMatch(matches[i]));\n } else if (matches[i][3] === undefined && !options.allowBooleanAttributes) {\n //independent attribute: ab\n return getErrorObject('InvalidAttr', \"boolean attribute '\"+matches[i][2]+\"' is not allowed.\", getPositionFromMatch(matches[i]));\n }\n /* else if(matches[i][6] === undefined){//attribute without value: ab=\n return { err: { code:\"InvalidAttr\",msg:\"attribute \" + matches[i][2] + \" has no value assigned.\"}};\n } */\n const attrName = matches[i][2];\n if (!validateAttrName(attrName)) {\n return getErrorObject('InvalidAttr', \"Attribute '\"+attrName+\"' is an invalid name.\", getPositionFromMatch(matches[i]));\n }\n if (!attrNames.hasOwnProperty(attrName)) {\n //check for duplicate attribute.\n attrNames[attrName] = 1;\n } else {\n return getErrorObject('InvalidAttr', \"Attribute '\"+attrName+\"' is repeated.\", getPositionFromMatch(matches[i]));\n }\n }\n\n return true;\n}\n\nfunction validateNumberAmpersand(xmlData, i) {\n let re = /\\d/;\n if (xmlData[i] === 'x') {\n i++;\n re = /[\\da-fA-F]/;\n }\n for (; i < xmlData.length; i++) {\n if (xmlData[i] === ';')\n return i;\n if (!xmlData[i].match(re))\n break;\n }\n return -1;\n}\n\nfunction validateAmpersand(xmlData, i) {\n // https://www.w3.org/TR/xml/#dt-charref\n i++;\n if (xmlData[i] === ';')\n return -1;\n if (xmlData[i] === '#') {\n i++;\n return validateNumberAmpersand(xmlData, i);\n }\n let count = 0;\n for (; i < xmlData.length; i++, count++) {\n if (xmlData[i].match(/\\w/) && count < 20)\n continue;\n if (xmlData[i] === ';')\n break;\n return -1;\n }\n return i;\n}\n\nfunction getErrorObject(code, message, lineNumber) {\n return {\n err: {\n code: code,\n msg: message,\n line: lineNumber.line || lineNumber,\n col: lineNumber.col,\n },\n };\n}\n\nfunction validateAttrName(attrName) {\n return util.isName(attrName);\n}\n\n// const startsWithXML = /^xml/i;\n\nfunction validateTagName(tagname) {\n return util.isName(tagname) /* && !tagname.match(startsWithXML) */;\n}\n\n//this function returns the line number for the character at the given index\nfunction getLineNumberForPosition(xmlData, index) {\n const lines = xmlData.substring(0, index).split(/\\r?\\n/);\n return {\n line: lines.length,\n\n // column number is last line's length + 1, because column numbering starts at 1:\n col: lines[lines.length - 1].length + 1\n };\n}\n\n//this function returns the position of the first character of match within attrStr\nfunction getPositionFromMatch(match) {\n return match.startIndex + match[1].length;\n}\n","\nconst defaultOptions = {\n preserveOrder: false,\n attributeNamePrefix: '@_',\n attributesGroupName: false,\n textNodeName: '#text',\n ignoreAttributes: true,\n removeNSPrefix: false, // remove NS from tag name or attribute name if true\n allowBooleanAttributes: false, //a tag can have attributes without any value\n //ignoreRootElement : false,\n parseTagValue: true,\n parseAttributeValue: false,\n trimValues: true, //Trim string values of tag and attributes\n cdataPropName: false,\n numberParseOptions: {\n hex: true,\n leadingZeros: true,\n eNotation: true\n },\n tagValueProcessor: function(tagName, val) {\n return val;\n },\n attributeValueProcessor: function(attrName, val) {\n return val;\n },\n stopNodes: [], //nested tags will not be parsed even for errors\n alwaysCreateTextNode: false,\n isArray: () => false,\n commentPropName: false,\n unpairedTags: [],\n processEntities: true,\n htmlEntities: false,\n ignoreDeclaration: false,\n ignorePiTags: false,\n transformTagName: false,\n transformAttributeName: false,\n updateTag: function(tagName, jPath, attrs){\n return tagName\n },\n // skipEmptyListItem: false\n};\n \nconst buildOptions = function(options) {\n return Object.assign({}, defaultOptions, options);\n};\n\nexports.buildOptions = buildOptions;\nexports.defaultOptions = defaultOptions;","'use strict';\n\nclass XmlNode{\n constructor(tagname) {\n this.tagname = tagname;\n this.child = []; //nested tags, text, cdata, comments in order\n this[\":@\"] = {}; //attributes map\n }\n add(key,val){\n // this.child.push( {name : key, val: val, isCdata: isCdata });\n if(key === \"__proto__\") key = \"#__proto__\";\n this.child.push( {[key]: val });\n }\n addChild(node) {\n if(node.tagname === \"__proto__\") node.tagname = \"#__proto__\";\n if(node[\":@\"] && Object.keys(node[\":@\"]).length > 0){\n this.child.push( { [node.tagname]: node.child, [\":@\"]: node[\":@\"] });\n }else{\n this.child.push( { [node.tagname]: node.child });\n }\n };\n};\n\n\nmodule.exports = XmlNode;","const util = require('../util');\n\n//TODO: handle comments\nfunction readDocType(xmlData, i){\n \n const entities = {};\n if( xmlData[i + 3] === 'O' &&\n xmlData[i + 4] === 'C' &&\n xmlData[i + 5] === 'T' &&\n xmlData[i + 6] === 'Y' &&\n xmlData[i + 7] === 'P' &&\n xmlData[i + 8] === 'E')\n { \n i = i+9;\n let angleBracketsCount = 1;\n let hasBody = false, comment = false;\n let exp = \"\";\n for(;i<xmlData.length;i++){\n if (xmlData[i] === '<' && !comment) { //Determine the tag type\n if( hasBody && isEntity(xmlData, i)){\n i += 7; \n [entityName, val,i] = readEntityExp(xmlData,i+1);\n if(val.indexOf(\"&\") === -1) //Parameter entities are not supported\n entities[ validateEntityName(entityName) ] = {\n regx : RegExp( `&${entityName};`,\"g\"),\n val: val\n };\n }\n else if( hasBody && isElement(xmlData, i)) i += 8;//Not supported\n else if( hasBody && isAttlist(xmlData, i)) i += 8;//Not supported\n else if( hasBody && isNotation(xmlData, i)) i += 9;//Not supported\n else if( isComment) comment = true;\n else throw new Error(\"Invalid DOCTYPE\");\n\n angleBracketsCount++;\n exp = \"\";\n } else if (xmlData[i] === '>') { //Read tag content\n if(comment){\n if( xmlData[i - 1] === \"-\" && xmlData[i - 2] === \"-\"){\n comment = false;\n angleBracketsCount--;\n }\n }else{\n angleBracketsCount--;\n }\n if (angleBracketsCount === 0) {\n break;\n }\n }else if( xmlData[i] === '['){\n hasBody = true;\n }else{\n exp += xmlData[i];\n }\n }\n if(angleBracketsCount !== 0){\n throw new Error(`Unclosed DOCTYPE`);\n }\n }else{\n throw new Error(`Invalid Tag instead of DOCTYPE`);\n }\n return {entities, i};\n}\n\nfunction readEntityExp(xmlData,i){\n //External entities are not supported\n // <!ENTITY ext SYSTEM \"http://normal-website.com\" >\n\n //Parameter entities are not supported\n // <!ENTITY entityname \"&anotherElement;\">\n\n //Internal entities are supported\n // <!ENTITY entityname \"replacement text\">\n \n //read EntityName\n let entityName = \"\";\n for (; i < xmlData.length && (xmlData[i] !== \"'\" && xmlData[i] !== '\"' ); i++) {\n // if(xmlData[i] === \" \") continue;\n // else \n entityName += xmlData[i];\n }\n entityName = entityName.trim();\n if(entityName.indexOf(\" \") !== -1) throw new Error(\"External entites are not supported\");\n\n //read Entity Value\n const startChar = xmlData[i++];\n let val = \"\"\n for (; i < xmlData.length && xmlData[i] !== startChar ; i++) {\n val += xmlData[i];\n }\n return [entityName, val, i];\n}\n\nfunction isComment(xmlData, i){\n if(xmlData[i+1] === '!' &&\n xmlData[i+2] === '-' &&\n xmlData[i+3] === '-') return true\n return false\n}\nfunction isEntity(xmlData, i){\n if(xmlData[i+1] === '!' &&\n xmlData[i+2] === 'E' &&\n xmlData[i+3] === 'N' &&\n xmlData[i+4] === 'T' &&\n xmlData[i+5] === 'I' &&\n xmlData[i+6] === 'T' &&\n xmlData[i+7] === 'Y') return true\n return false\n}\nfunction isElement(xmlData, i){\n if(xmlData[i+1] === '!' &&\n xmlData[i+2] === 'E' &&\n xmlData[i+3] === 'L' &&\n xmlData[i+4] === 'E' &&\n xmlData[i+5] === 'M' &&\n xmlData[i+6] === 'E' &&\n xmlData[i+7] === 'N' &&\n xmlData[i+8] === 'T') return true\n return false\n}\n\nfunction isAttlist(xmlData, i){\n if(xmlData[i+1] === '!' &&\n xmlData[i+2] === 'A' &&\n xmlData[i+3] === 'T' &&\n xmlData[i+4] === 'T' &&\n xmlData[i+5] === 'L' &&\n xmlData[i+6] === 'I' &&\n xmlData[i+7] === 'S' &&\n xmlData[i+8] === 'T') return true\n return false\n}\nfunction isNotation(xmlData, i){\n if(xmlData[i+1] === '!' &&\n xmlData[i+2] === 'N' &&\n xmlData[i+3] === 'O' &&\n xmlData[i+4] === 'T' &&\n xmlData[i+5] === 'A' &&\n xmlData[i+6] === 'T' &&\n xmlData[i+7] === 'I' &&\n xmlData[i+8] === 'O' &&\n xmlData[i+9] === 'N') return true\n return false\n}\n\nfunction validateEntityName(name){\n if (util.isName(name))\n\treturn name;\n else\n throw new Error(`Invalid entity name ${name}`);\n}\n\nmodule.exports = readDocType;\n","const hexRegex = /^[-+]?0x[a-fA-F0-9]+$/;\nconst numRegex = /^([\\-\\+])?(0*)(\\.[0-9]+([eE]\\-?[0-9]+)?|[0-9]+(\\.[0-9]+([eE]\\-?[0-9]+)?)?)$/;\n// const octRegex = /0x[a-z0-9]+/;\n// const binRegex = /0x[a-z0-9]+/;\n\n\n//polyfill\nif (!Number.parseInt && window.parseInt) {\n Number.parseInt = window.parseInt;\n}\nif (!Number.parseFloat && window.parseFloat) {\n Number.parseFloat = window.parseFloat;\n}\n\n \nconst consider = {\n hex : true,\n leadingZeros: true,\n decimalPoint: \"\\.\",\n eNotation: true\n //skipLike: /regex/\n};\n\nfunction toNumber(str, options = {}){\n // const options = Object.assign({}, consider);\n // if(opt.leadingZeros === false){\n // options.leadingZeros = false;\n // }else if(opt.hex === false){\n // options.hex = false;\n // }\n\n options = Object.assign({}, consider, options );\n if(!str || typeof str !== \"string\" ) return str;\n \n let trimmedStr = str.trim();\n // if(trimmedStr === \"0.0\") return 0;\n // else if(trimmedStr === \"+0.0\") return 0;\n // else if(trimmedStr === \"-0.0\") return -0;\n\n if(options.skipLike !== undefined && options.skipLike.test(trimmedStr)) return str;\n else if (options.hex && hexRegex.test(trimmedStr)) {\n return Number.parseInt(trimmedStr, 16);\n // } else if (options.parseOct && octRegex.test(str)) {\n // return Number.parseInt(val, 8);\n // }else if (options.parseBin && binRegex.test(str)) {\n // return Number.parseInt(val, 2);\n }else{\n //separate negative sign, leading zeros, and rest number\n const match = numRegex.exec(trimmedStr);\n if(match){\n const sign = match[1];\n const leadingZeros = match[2];\n let numTrimmedByZeros = trimZeros(match[3]); //complete num without leading zeros\n //trim ending zeros for floating number\n \n const eNotation = match[4] || match[6];\n if(!options.leadingZeros && leadingZeros.length > 0 && sign && trimmedStr[2] !== \".\") return str; //-0123\n else if(!options.leadingZeros && leadingZeros.length > 0 && !sign && trimmedStr[1] !== \".\") return str; //0123\n else{//no leading zeros or leading zeros are allowed\n const num = Number(trimmedStr);\n const numStr = \"\" + num;\n if(numStr.search(/[eE]/) !== -1){ //given number is long and parsed to eNotation\n if(options.eNotation) return num;\n else return str;\n }else if(eNotation){ //given number has enotation\n if(options.eNotation) return num;\n else return str;\n }else if(trimmedStr.indexOf(\".\") !== -1){ //floating number\n // const decimalPart = match[5].substr(1);\n // const intPart = trimmedStr.substr(0,trimmedStr.indexOf(\".\"));\n\n \n // const p = numStr.indexOf(\".\");\n // const givenIntPart = numStr.substr(0,p);\n // const givenDecPart = numStr.substr(p+1);\n if(numStr === \"0\" && (numTrimmedByZeros === \"\") ) return num; //0.0\n else if(numStr === numTrimmedByZeros) return num; //0.456. 0.79000\n else if( sign && numStr === \"-\"+numTrimmedByZeros) return num;\n else return str;\n }\n \n if(leadingZeros){\n // if(numTrimmedByZeros === numStr){\n // if(options.leadingZeros) return num;\n // else return str;\n // }else return str;\n if(numTrimmedByZeros === numStr) return num;\n else if(sign+numTrimmedByZeros === numStr) return num;\n else return str;\n }\n\n if(trimmedStr === numStr) return num;\n else if(trimmedStr === sign+numStr) return num;\n // else{\n // //number with +/- sign\n // trimmedStr.test(/[-+][0-9]);\n\n // }\n return str;\n }\n // else if(!eNotation && trimmedStr && trimmedStr !== Number(trimmedStr) ) return str;\n \n }else{ //non-numeric string\n return str;\n }\n }\n}\n\n/**\n * \n * @param {string} numStr without leading zeros\n * @returns \n */\nfunction trimZeros(numStr){\n if(numStr && numStr.indexOf(\".\") !== -1){//float\n numStr = numStr.replace(/0+$/, \"\"); //remove ending zeros\n if(numStr === \".\") numStr = \"0\";\n else if(numStr[0] === \".\") numStr = \"0\"+numStr;\n else if(numStr[numStr.length-1] === \".\") numStr = numStr.substr(0,numStr.length-1);\n return numStr;\n }\n return numStr;\n}\nmodule.exports = toNumber\n","'use strict';\n///@ts-check\n\nconst util = require('../util');\nconst xmlNode = require('./xmlNode');\nconst readDocType = require(\"./DocTypeReader\");\nconst toNumber = require(\"strnum\");\n\n// const regx =\n// '<((!\\\\[CDATA\\\\[([\\\\s\\\\S]*?)(]]>))|((NAME:)?(NAME))([^>]*)>|((\\\\/)(NAME)\\\\s*>))([^<]*)'\n// .replace(/NAME/g, util.nameRegexp);\n\n//const tagsRegx = new RegExp(\"<(\\\\/?[\\\\w:\\\\-\\._]+)([^>]*)>(\\\\s*\"+cdataRegx+\")*([^<]+)?\",\"g\");\n//const tagsRegx = new RegExp(\"<(\\\\/?)((\\\\w*:)?([\\\\w:\\\\-\\._]+))([^>]*)>([^<]*)(\"+cdataRegx+\"([^<]*))*([^<]+)?\",\"g\");\n\nclass OrderedObjParser{\n constructor(options){\n this.options = options;\n this.currentNode = null;\n this.tagsNodeStack = [];\n this.docTypeEntities = {};\n this.lastEntities = {\n \"apos\" : { regex: /&(apos|#39|#x27);/g, val : \"'\"},\n \"gt\" : { regex: /&(gt|#62|#x3E);/g, val : \">\"},\n \"lt\" : { regex: /&(lt|#60|#x3C);/g, val : \"<\"},\n \"quot\" : { regex: /&(quot|#34|#x22);/g, val : \"\\\"\"},\n };\n this.ampEntity = { regex: /&(amp|#38|#x26);/g, val : \"&\"};\n this.htmlEntities = {\n \"space\": { regex: /&(nbsp|#160);/g, val: \" \" },\n // \"lt\" : { regex: /&(lt|#60);/g, val: \"<\" },\n // \"gt\" : { regex: /&(gt|#62);/g, val: \">\" },\n // \"amp\" : { regex: /&(amp|#38);/g, val: \"&\" },\n // \"quot\" : { regex: /&(quot|#34);/g, val: \"\\\"\" },\n // \"apos\" : { regex: /&(apos|#39);/g, val: \"'\" },\n \"cent\" : { regex: /&(cent|#162);/g, val: \"¢\" },\n \"pound\" : { regex: /&(pound|#163);/g, val: \"£\" },\n \"yen\" : { regex: /&(yen|#165);/g, val: \"¥\" },\n \"euro\" : { regex: /&(euro|#8364);/g, val: \"€\" },\n \"copyright\" : { regex: /&(copy|#169);/g, val: \"©\" },\n \"reg\" : { regex: /&(reg|#174);/g, val: \"®\" },\n \"inr\" : { regex: /&(inr|#8377);/g, val: \"₹\" },\n \"num_dec\": { regex: /&#([0-9]{1,7});/g, val : (_, str) => String.fromCharCode(Number.parseInt(str, 10)) },\n \"num_hex\": { regex: /&#x([0-9a-fA-F]{1,6});/g, val : (_, str) => String.fromCharCode(Number.parseInt(str, 16)) },\n };\n this.addExternalEntities = addExternalEntities;\n this.parseXml = parseXml;\n this.parseTextData = parseTextData;\n this.resolveNameSpace = resolveNameSpace;\n this.buildAttributesMap = buildAttributesMap;\n this.isItStopNode = isItStopNode;\n this.replaceEntitiesValue = replaceEntitiesValue;\n this.readStopNodeData = readStopNodeData;\n this.saveTextToParentTag = saveTextToParentTag;\n this.addChild = addChild;\n }\n\n}\n\nfunction addExternalEntities(externalEntities){\n const entKeys = Object.keys(externalEntities);\n for (let i = 0; i < entKeys.length; i++) {\n const ent = entKeys[i];\n this.lastEntities[ent] = {\n regex: new RegExp(\"&\"+ent+\";\",\"g\"),\n val : externalEntities[ent]\n }\n }\n}\n\n/**\n * @param {string} val\n * @param {string} tagName\n * @param {string} jPath\n * @param {boolean} dontTrim\n * @param {boolean} hasAttributes\n * @param {boolean} isLeafNode\n * @param {boolean} escapeEntities\n */\nfunction parseTextData(val, tagName, jPath, dontTrim, hasAttributes, isLeafNode, escapeEntities) {\n if (val !== undefined) {\n if (this.options.trimValues && !dontTrim) {\n val = val.trim();\n }\n if(val.length > 0){\n if(!escapeEntities) val = this.replaceEntitiesValue(val);\n \n const newval = this.options.tagValueProcessor(tagName, val, jPath, hasAttributes, isLeafNode);\n if(newval === null || newval === undefined){\n //don't parse\n return val;\n }else if(typeof newval !== typeof val || newval !== val){\n //overwrite\n return newval;\n }else if(this.options.trimValues){\n return parseValue(val, this.options.parseTagValue, this.options.numberParseOptions);\n }else{\n const trimmedVal = val.trim();\n if(trimmedVal === val){\n return parseValue(val, this.options.parseTagValue, this.options.numberParseOptions);\n }else{\n return val;\n }\n }\n }\n }\n}\n\nfunction resolveNameSpace(tagname) {\n if (this.options.removeNSPrefix) {\n const tags = tagname.split(':');\n const prefix = tagname.charAt(0) === '/' ? '/' : '';\n if (tags[0] === 'xmlns') {\n return '';\n }\n if (tags.length === 2) {\n tagname = prefix + tags[1];\n }\n }\n return tagname;\n}\n\n//TODO: change regex to capture NS\n//const attrsRegx = new RegExp(\"([\\\\w\\\\-\\\\.\\\\:]+)\\\\s*=\\\\s*(['\\\"])((.|\\n)*?)\\\\2\",\"gm\");\nconst attrsRegx = new RegExp('([^\\\\s=]+)\\\\s*(=\\\\s*([\\'\"])([\\\\s\\\\S]*?)\\\\3)?', 'gm');\n\nfunction buildAttributesMap(attrStr, jPath, tagName) {\n if (!this.options.ignoreAttributes && typeof attrStr === 'string') {\n // attrStr = attrStr.replace(/\\r?\\n/g, ' ');\n //attrStr = attrStr || attrStr.trim();\n\n const matches = util.getAllMatches(attrStr, attrsRegx);\n const len = matches.length; //don't make it inline\n const attrs = {};\n for (let i = 0; i < len; i++) {\n const attrName = this.resolveNameSpace(matches[i][1]);\n let oldVal = matches[i][4];\n let aName = this.options.attributeNamePrefix + attrName;\n if (attrName.length) {\n if (this.options.transformAttributeName) {\n aName = this.options.transformAttributeName(aName);\n }\n if(aName === \"__proto__\") aName = \"#__proto__\";\n if (oldVal !== undefined) {\n if (this.options.trimValues) {\n oldVal = oldVal.trim();\n }\n oldVal = this.replaceEntitiesValue(oldVal);\n const newVal = this.options.attributeValueProcessor(attrName, oldVal, jPath);\n if(newVal === null || newVal === undefined){\n //don't parse\n attrs[aName] = oldVal;\n }else if(typeof newVal !== typeof oldVal || newVal !== oldVal){\n //overwrite\n attrs[aName] = newVal;\n }else{\n //parse\n attrs[aName] = parseValue(\n oldVal,\n this.options.parseAttributeValue,\n this.options.numberParseOptions\n );\n }\n } else if (this.options.allowBooleanAttributes) {\n attrs[aName] = true;\n }\n }\n }\n if (!Object.keys(attrs).length) {\n return;\n }\n if (this.options.attributesGroupName) {\n const attrCollection = {};\n attrCollection[this.options.attributesGroupName] = attrs;\n return attrCollection;\n }\n return attrs\n }\n}\n\nconst parseXml = function(xmlData) {\n xmlData = xmlData.replace(/\\r\\n?/g, \"\\n\"); //TODO: remove this line\n const xmlObj = new xmlNode('!xml');\n let currentNode = xmlObj;\n let textData = \"\";\n let jPath = \"\";\n for(let i=0; i< xmlData.length; i++){//for each char in XML data\n const ch = xmlData[i];\n if(ch === '<'){\n // const nextIndex = i+1;\n // const _2ndChar = xmlData[nextIndex];\n if( xmlData[i+1] === '/') {//Closing Tag\n const closeIndex = findClosingIndex(xmlData, \">\", i, \"Closing Tag is not closed.\")\n let tagName = xmlData.substring(i+2,closeIndex).trim();\n\n if(this.options.removeNSPrefix){\n const colonIndex = tagName.indexOf(\":\");\n if(colonIndex !== -1){\n tagName = tagName.substr(colonIndex+1);\n }\n }\n\n if(this.options.transformTagName) {\n tagName = this.options.transformTagName(tagName);\n }\n\n if(currentNode){\n textData = this.saveTextToParentTag(textData, currentNode, jPath);\n }\n\n //check if last tag of nested tag was unpaired tag\n const lastTagName = jPath.substring(jPath.lastIndexOf(\".\")+1);\n if(tagName && this.options.unpairedTags.indexOf(tagName) !== -1 ){\n throw new Error(`Unpaired tag can not be used as closing tag: </${tagName}>`);\n }\n let propIndex = 0\n if(lastTagName && this.options.unpairedTags.indexOf(lastTagName) !== -1 ){\n propIndex = jPath.lastIndexOf('.', jPath.lastIndexOf('.')-1)\n this.tagsNodeStack.pop();\n }else{\n propIndex = jPath.lastIndexOf(\".\");\n }\n jPath = jPath.substring(0, propIndex);\n\n currentNode = this.tagsNodeStack.pop();//avoid recursion, set the parent tag scope\n textData = \"\";\n i = closeIndex;\n } else if( xmlData[i+1] === '?') {\n\n let tagData = readTagExp(xmlData,i, false, \"?>\");\n if(!tagData) throw new Error(\"Pi Tag is not closed.\");\n\n textData = this.saveTextToParentTag(textData, currentNode, jPath);\n if( (this.options.ignoreDeclaration && tagData.tagName === \"?xml\") || this.options.ignorePiTags){\n\n }else{\n \n const childNode = new xmlNode(tagData.tagName);\n childNode.add(this.options.textNodeName, \"\");\n \n if(tagData.tagName !== tagData.tagExp && tagData.attrExpPresent){\n childNode[\":@\"] = this.buildAttributesMap(tagData.tagExp, jPath, tagData.tagName);\n }\n this.addChild(currentNode, childNode, jPath)\n\n }\n\n\n i = tagData.closeIndex + 1;\n } else if(xmlData.substr(i + 1, 3) === '!--') {\n const endIndex = findClosingIndex(xmlData, \"-->\", i+4, \"Comment is not closed.\")\n if(this.options.commentPropName){\n const comment = xmlData.substring(i + 4, endIndex - 2);\n\n textData = this.saveTextToParentTag(textData, currentNode, jPath);\n\n currentNode.add(this.options.commentPropName, [ { [this.options.textNodeName] : comment } ]);\n }\n i = endIndex;\n } else if( xmlData.substr(i + 1, 2) === '!D') {\n const result = readDocType(xmlData, i);\n this.docTypeEntities = result.entities;\n i = result.i;\n }else if(xmlData.substr(i + 1, 2) === '![') {\n const closeIndex = findClosingIndex(xmlData, \"]]>\", i, \"CDATA is not closed.\") - 2;\n const tagExp = xmlData.substring(i + 9,closeIndex);\n\n textData = this.saveTextToParentTag(textData, currentNode, jPath);\n\n let val = this.parseTextData(tagExp, currentNode.tagname, jPath, true, false, true, true);\n if(val == undefined) val = \"\";\n\n //cdata should be set even if it is 0 length string\n if(this.options.cdataPropName){\n currentNode.add(this.options.cdataPropName, [ { [this.options.textNodeName] : tagExp } ]);\n }else{\n currentNode.add(this.options.textNodeName, val);\n }\n \n i = closeIndex + 2;\n }else {//Opening tag\n let result = readTagExp(xmlData,i, this.options.removeNSPrefix);\n let tagName= result.tagName;\n const rawTagName = result.rawTagName;\n let tagExp = result.tagExp;\n let attrExpPresent = result.attrExpPresent;\n let closeIndex = result.closeIndex;\n\n if (this.options.transformTagName) {\n tagName = this.options.transformTagName(tagName);\n }\n \n //save text as child node\n if (currentNode && textData) {\n if(currentNode.tagname !== '!xml'){\n //when nested tag is found\n textData = this.saveTextToParentTag(textData, currentNode, jPath, false);\n }\n }\n\n //check if last tag was unpaired tag\n const lastTag = currentNode;\n if(lastTag && this.options.unpairedTags.indexOf(lastTag.tagname) !== -1 ){\n currentNode = this.tagsNodeStack.pop();\n jPath = jPath.substring(0, jPath.lastIndexOf(\".\"));\n }\n if(tagName !== xmlObj.tagname){\n jPath += jPath ? \".\" + tagName : tagName;\n }\n if (this.isItStopNode(this.options.stopNodes, jPath, tagName)) {\n let tagContent = \"\";\n //self-closing tag\n if(tagExp.length > 0 && tagExp.lastIndexOf(\"/\") === tagExp.length - 1){\n if(tagName[tagName.length - 1] === \"/\"){ //remove trailing '/'\n tagName = tagName.substr(0, tagName.length - 1);\n jPath = jPath.substr(0, jPath.length - 1);\n tagExp = tagName;\n }else{\n tagExp = tagExp.substr(0, tagExp.length - 1);\n }\n i = result.closeIndex;\n }\n //unpaired tag\n else if(this.options.unpairedTags.indexOf(tagName) !== -1){\n \n i = result.closeIndex;\n }\n //normal tag\n else{\n //read until closing tag is found\n const result = this.readStopNodeData(xmlData, rawTagName, closeIndex + 1);\n if(!result) throw new Error(`Unexpected end of ${rawTagName}`);\n i = result.i;\n tagContent = result.tagContent;\n }\n\n const childNode = new xmlNode(tagName);\n if(tagName !== tagExp && attrExpPresent){\n childNode[\":@\"] = this.buildAttributesMap(tagExp, jPath, tagName);\n }\n if(tagContent) {\n tagContent = this.parseTextData(tagContent, tagName, jPath, true, attrExpPresent, true, true);\n }\n \n jPath = jPath.substr(0, jPath.lastIndexOf(\".\"));\n childNode.add(this.options.textNodeName, tagContent);\n \n this.addChild(currentNode, childNode, jPath)\n }else{\n //selfClosing tag\n if(tagExp.length > 0 && tagExp.lastIndexOf(\"/\") === tagExp.length - 1){\n if(tagName[tagName.length - 1] === \"/\"){ //remove trailing '/'\n tagName = tagName.substr(0, tagName.length - 1);\n jPath = jPath.substr(0, jPath.length - 1);\n tagExp = tagName;\n }else{\n tagExp = tagExp.substr(0, tagExp.length - 1);\n }\n \n if(this.options.transformTagName) {\n tagName = this.options.transformTagName(tagName);\n }\n\n const childNode = new xmlNode(tagName);\n if(tagName !== tagExp && attrExpPresent){\n childNode[\":@\"] = this.buildAttributesMap(tagExp, jPath, tagName);\n }\n this.addChild(currentNode, childNode, jPath)\n jPath = jPath.substr(0, jPath.lastIndexOf(\".\"));\n }\n //opening tag\n else{\n const childNode = new xmlNode( tagName);\n this.tagsNodeStack.push(currentNode);\n \n if(tagName !== tagExp && attrExpPresent){\n childNode[\":@\"] = this.buildAttributesMap(tagExp, jPath, tagName);\n }\n this.addChild(currentNode, childNode, jPath)\n currentNode = childNode;\n }\n textData = \"\";\n i = closeIndex;\n }\n }\n }else{\n textData += xmlData[i];\n }\n }\n return xmlObj.child;\n}\n\nfunction addChild(currentNode, childNode, jPath){\n const result = this.options.updateTag(childNode.tagname, jPath, childNode[\":@\"])\n if(result === false){\n }else if(typeof result === \"string\"){\n childNode.tagname = result\n currentNode.addChild(childNode);\n }else{\n currentNode.addChild(childNode);\n }\n}\n\nconst replaceEntitiesValue = function(val){\n\n if(this.options.processEntities){\n for(let entityName in this.docTypeEntities){\n const entity = this.docTypeEntities[entityName];\n val = val.replace( entity.regx, entity.val);\n }\n for(let entityName in this.lastEntities){\n const entity = this.lastEntities[entityName];\n val = val.replace( entity.regex, entity.val);\n }\n if(this.options.htmlEntities){\n for(let entityName in this.htmlEntities){\n const entity = this.htmlEntities[entityName];\n val = val.replace( entity.regex, entity.val);\n }\n }\n val = val.replace( this.ampEntity.regex, this.ampEntity.val);\n }\n return val;\n}\nfunction saveTextToParentTag(textData, currentNode, jPath, isLeafNode) {\n if (textData) { //store previously collected data as textNode\n if(isLeafNode === undefined) isLeafNode = Object.keys(currentNode.child).length === 0\n \n textData = this.parseTextData(textData,\n currentNode.tagname,\n jPath,\n false,\n currentNode[\":@\"] ? Object.keys(currentNode[\":@\"]).length !== 0 : false,\n isLeafNode);\n\n if (textData !== undefined && textData !== \"\")\n currentNode.add(this.options.textNodeName, textData);\n textData = \"\";\n }\n return textData;\n}\n\n//TODO: use jPath to simplify the logic\n/**\n * \n * @param {string[]} stopNodes \n * @param {string} jPath\n * @param {string} currentTagName \n */\nfunction isItStopNode(stopNodes, jPath, currentTagName){\n const allNodesExp = \"*.\" + currentTagName;\n for (const stopNodePath in stopNodes) {\n const stopNodeExp = stopNodes[stopNodePath];\n if( allNodesExp === stopNodeExp || jPath === stopNodeExp ) return true;\n }\n return false;\n}\n\n/**\n * Returns the tag Expression and where it is ending handling single-double quotes situation\n * @param {string} xmlData \n * @param {number} i starting index\n * @returns \n */\nfunction tagExpWithClosingIndex(xmlData, i, closingChar = \">\"){\n let attrBoundary;\n let tagExp = \"\";\n for (let index = i; index < xmlData.length; index++) {\n let ch = xmlData[index];\n if (attrBoundary) {\n if (ch === attrBoundary) attrBoundary = \"\";//reset\n } else if (ch === '\"' || ch === \"'\") {\n attrBoundary = ch;\n } else if (ch === closingChar[0]) {\n if(closingChar[1]){\n if(xmlData[index + 1] === closingChar[1]){\n return {\n data: tagExp,\n index: index\n }\n }\n }else{\n return {\n data: tagExp,\n index: index\n }\n }\n } else if (ch === '\\t') {\n ch = \" \"\n }\n tagExp += ch;\n }\n}\n\nfunction findClosingIndex(xmlData, str, i, errMsg){\n const closingIndex = xmlData.indexOf(str, i);\n if(closingIndex === -1){\n throw new Error(errMsg)\n }else{\n return closingIndex + str.length - 1;\n }\n}\n\nfunction readTagExp(xmlData,i, removeNSPrefix, closingChar = \">\"){\n const result = tagExpWithClosingIndex(xmlData, i+1, closingChar);\n if(!result) return;\n let tagExp = result.data;\n const closeIndex = result.index;\n const separatorIndex = tagExp.search(/\\s/);\n let tagName = tagExp;\n let attrExpPresent = true;\n if(separatorIndex !== -1){//separate tag name and attributes expression\n tagName = tagExp.substring(0, separatorIndex);\n tagExp = tagExp.substring(separatorIndex + 1).trimStart();\n }\n\n const rawTagName = tagName;\n if(removeNSPrefix){\n const colonIndex = tagName.indexOf(\":\");\n if(colonIndex !== -1){\n tagName = tagName.substr(colonIndex+1);\n attrExpPresent = tagName !== result.data.substr(colonIndex + 1);\n }\n }\n\n return {\n tagName: tagName,\n tagExp: tagExp,\n closeIndex: closeIndex,\n attrExpPresent: attrExpPresent,\n rawTagName: rawTagName,\n }\n}\n/**\n * find paired tag for a stop node\n * @param {string} xmlData \n * @param {string} tagName \n * @param {number} i \n */\nfunction readStopNodeData(xmlData, tagName, i){\n const startIndex = i;\n // Starting at 1 since we already have an open tag\n let openTagCount = 1;\n\n for (; i < xmlData.length; i++) {\n if( xmlData[i] === \"<\"){ \n if (xmlData[i+1] === \"/\") {//close tag\n const closeIndex = findClosingIndex(xmlData, \">\", i, `${tagName} is not closed`);\n let closeTagName = xmlData.substring(i+2,closeIndex).trim();\n if(closeTagName === tagName){\n openTagCount--;\n if (openTagCount === 0) {\n return {\n tagContent: xmlData.substring(startIndex, i),\n i : closeIndex\n }\n }\n }\n i=closeIndex;\n } else if(xmlData[i+1] === '?') { \n const closeIndex = findClosingIndex(xmlData, \"?>\", i+1, \"StopNode is not closed.\")\n i=closeIndex;\n } else if(xmlData.substr(i + 1, 3) === '!--') { \n const closeIndex = findClosingIndex(xmlData, \"-->\", i+3, \"StopNode is not closed.\")\n i=closeIndex;\n } else if(xmlData.substr(i + 1, 2) === '![') { \n const closeIndex = findClosingIndex(xmlData, \"]]>\", i, \"StopNode is not closed.\") - 2;\n i=closeIndex;\n } else {\n const tagData = readTagExp(xmlData, i, '>')\n\n if (tagData) {\n const openTagName = tagData && tagData.tagName;\n if (openTagName === tagName && tagData.tagExp[tagData.tagExp.length-1] !== \"/\") {\n openTagCount++;\n }\n i=tagData.closeIndex;\n }\n }\n }\n }//end for loop\n}\n\nfunction parseValue(val, shouldParse, options) {\n if (shouldParse && typeof val === 'string') {\n //console.log(options)\n const newval = val.trim();\n if(newval === 'true' ) return true;\n else if(newval === 'false' ) return false;\n else return toNumber(val, options);\n } else {\n if (util.isExist(val)) {\n return val;\n } else {\n return '';\n }\n }\n}\n\n\nmodule.exports = OrderedObjParser;\n","'use strict';\n\n/**\n * \n * @param {array} node \n * @param {any} options \n * @returns \n */\nfunction prettify(node, options){\n return compress( node, options);\n}\n\n/**\n * \n * @param {array} arr \n * @param {object} options \n * @param {string} jPath \n * @returns object\n */\nfunction compress(arr, options, jPath){\n let text;\n const compressedObj = {};\n for (let i = 0; i < arr.length; i++) {\n const tagObj = arr[i];\n const property = propName(tagObj);\n let newJpath = \"\";\n if(jPath === undefined) newJpath = property;\n else newJpath = jPath + \".\" + property;\n\n if(property === options.textNodeName){\n if(text === undefined) text = tagObj[property];\n else text += \"\" + tagObj[property];\n }else if(property === undefined){\n continue;\n }else if(tagObj[property]){\n \n let val = compress(tagObj[property], options, newJpath);\n const isLeaf = isLeafTag(val, options);\n\n if(tagObj[\":@\"]){\n assignAttributes( val, tagObj[\":@\"], newJpath, options);\n }else if(Object.keys(val).length === 1 && val[options.textNodeName] !== undefined && !options.alwaysCreateTextNode){\n val = val[options.textNodeName];\n }else if(Object.keys(val).length === 0){\n if(options.alwaysCreateTextNode) val[options.textNodeName] = \"\";\n else val = \"\";\n }\n\n if(compressedObj[property] !== undefined && compressedObj.hasOwnProperty(property)) {\n if(!Array.isArray(compressedObj[property])) {\n compressedObj[property] = [ compressedObj[property] ];\n }\n compressedObj[property].push(val);\n }else{\n //TODO: if a node is not an array, then check if it should be an array\n //also determine if it is a leaf node\n if (options.isArray(property, newJpath, isLeaf )) {\n compressedObj[property] = [val];\n }else{\n compressedObj[property] = val;\n }\n }\n }\n \n }\n // if(text && text.length > 0) compressedObj[options.textNodeName] = text;\n if(typeof text === \"string\"){\n if(text.length > 0) compressedObj[options.textNodeName] = text;\n }else if(text !== undefined) compressedObj[options.textNodeName] = text;\n return compressedObj;\n}\n\nfunction propName(obj){\n const keys = Object.keys(obj);\n for (let i = 0; i < keys.length; i++) {\n const key = keys[i];\n if(key !== \":@\") return key;\n }\n}\n\nfunction assignAttributes(obj, attrMap, jpath, options){\n if (attrMap) {\n const keys = Object.keys(attrMap);\n const len = keys.length; //don't make it inline\n for (let i = 0; i < len; i++) {\n const atrrName = keys[i];\n if (options.isArray(atrrName, jpath + \".\" + atrrName, true, true)) {\n obj[atrrName] = [ attrMap[atrrName] ];\n } else {\n obj[atrrName] = attrMap[atrrName];\n }\n }\n }\n}\n\nfunction isLeafTag(obj, options){\n const { textNodeName } = options;\n const propCount = Object.keys(obj).length;\n \n if (propCount === 0) {\n return true;\n }\n\n if (\n propCount === 1 &&\n (obj[textNodeName] || typeof obj[textNodeName] === \"boolean\" || obj[textNodeName] === 0)\n ) {\n return true;\n }\n\n return false;\n}\nexports.prettify = prettify;\n","const { buildOptions} = require(\"./OptionsBuilder\");\nconst OrderedObjParser = require(\"./OrderedObjParser\");\nconst { prettify} = require(\"./node2json\");\nconst validator = require('../validator');\n\nclass XMLParser{\n \n constructor(options){\n this.externalEntities = {};\n this.options = buildOptions(options);\n \n }\n /**\n * Parse XML dats to JS object \n * @param {string|Buffer} xmlData \n * @param {boolean|Object} validationOption \n */\n parse(xmlData,validationOption){\n if(typeof xmlData === \"string\"){\n }else if( xmlData.toString){\n xmlData = xmlData.toString();\n }else{\n throw new Error(\"XML data is accepted in String or Bytes[] form.\")\n }\n if( validationOption){\n if(validationOption === true) validationOption = {}; //validate with default options\n \n const result = validator.validate(xmlData, validationOption);\n if (result !== true) {\n throw Error( `${result.err.msg}:${result.err.line}:${result.err.col}` )\n }\n }\n const orderedObjParser = new OrderedObjParser(this.options);\n orderedObjParser.addExternalEntities(this.externalEntities);\n const orderedResult = orderedObjParser.parseXml(xmlData);\n if(this.options.preserveOrder || orderedResult === undefined) return orderedResult;\n else return prettify(orderedResult, this.options);\n }\n\n /**\n * Add Entity which is not by default supported by this library\n * @param {string} key \n * @param {string} value \n */\n addEntity(key, value){\n if(value.indexOf(\"&\") !== -1){\n throw new Error(\"Entity value can't have '&'\")\n }else if(key.indexOf(\"&\") !== -1 || key.indexOf(\";\") !== -1){\n throw new Error(\"An entity must be set without '&' and ';'. Eg. use '#xD' for '
'\")\n }else if(value === \"&\"){\n throw new Error(\"An entity with value '&' is not permitted\");\n }else{\n this.externalEntities[key] = value;\n }\n }\n}\n\nmodule.exports = XMLParser;","const EOL = \"\\n\";\n\n/**\n * \n * @param {array} jArray \n * @param {any} options \n * @returns \n */\nfunction toXml(jArray, options) {\n let indentation = \"\";\n if (options.format && options.indentBy.length > 0) {\n indentation = EOL;\n }\n return arrToStr(jArray, options, \"\", indentation);\n}\n\nfunction arrToStr(arr, options, jPath, indentation) {\n let xmlStr = \"\";\n let isPreviousElementTag = false;\n\n for (let i = 0; i < arr.length; i++) {\n const tagObj = arr[i];\n const tagName = propName(tagObj);\n if(tagName === undefined) continue;\n\n let newJPath = \"\";\n if (jPath.length === 0) newJPath = tagName\n else newJPath = `${jPath}.${tagName}`;\n\n if (tagName === options.textNodeName) {\n let tagText = tagObj[tagName];\n if (!isStopNode(newJPath, options)) {\n tagText = options.tagValueProcessor(tagName, tagText);\n tagText = replaceEntitiesValue(tagText, options);\n }\n if (isPreviousElementTag) {\n xmlStr += indentation;\n }\n xmlStr += tagText;\n isPreviousElementTag = false;\n continue;\n } else if (tagName === options.cdataPropName) {\n if (isPreviousElementTag) {\n xmlStr += indentation;\n }\n xmlStr += `<![CDATA[${tagObj[tagName][0][options.textNodeName]}]]>`;\n isPreviousElementTag = false;\n continue;\n } else if (tagName === options.commentPropName) {\n xmlStr += indentation + `<!--${tagObj[tagName][0][options.textNodeName]}-->`;\n isPreviousElementTag = true;\n continue;\n } else if (tagName[0] === \"?\") {\n const attStr = attr_to_str(tagObj[\":@\"], options);\n const tempInd = tagName === \"?xml\" ? \"\" : indentation;\n let piTextNodeName = tagObj[tagName][0][options.textNodeName];\n piTextNodeName = piTextNodeName.length !== 0 ? \" \" + piTextNodeName : \"\"; //remove extra spacing\n xmlStr += tempInd + `<${tagName}${piTextNodeName}${attStr}?>`;\n isPreviousElementTag = true;\n continue;\n }\n let newIdentation = indentation;\n if (newIdentation !== \"\") {\n newIdentation += options.indentBy;\n }\n const attStr = attr_to_str(tagObj[\":@\"], options);\n const tagStart = indentation + `<${tagName}${attStr}`;\n const tagValue = arrToStr(tagObj[tagName], options, newJPath, newIdentation);\n if (options.unpairedTags.indexOf(tagName) !== -1) {\n if (options.suppressUnpairedNode) xmlStr += tagStart + \">\";\n else xmlStr += tagStart + \"/>\";\n } else if ((!tagValue || tagValue.length === 0) && options.suppressEmptyNode) {\n xmlStr += tagStart + \"/>\";\n } else if (tagValue && tagValue.endsWith(\">\")) {\n xmlStr += tagStart + `>${tagValue}${indentation}</${tagName}>`;\n } else {\n xmlStr += tagStart + \">\";\n if (tagValue && indentation !== \"\" && (tagValue.includes(\"/>\") || tagValue.includes(\"</\"))) {\n xmlStr += indentation + options.indentBy + tagValue + indentation;\n } else {\n xmlStr += tagValue;\n }\n xmlStr += `</${tagName}>`;\n }\n isPreviousElementTag = true;\n }\n\n return xmlStr;\n}\n\nfunction propName(obj) {\n const keys = Object.keys(obj);\n for (let i = 0; i < keys.length; i++) {\n const key = keys[i];\n if(!obj.hasOwnProperty(key)) continue;\n if (key !== \":@\") return key;\n }\n}\n\nfunction attr_to_str(attrMap, options) {\n let attrStr = \"\";\n if (attrMap && !options.ignoreAttributes) {\n for (let attr in attrMap) {\n if(!attrMap.hasOwnProperty(attr)) continue;\n let attrVal = options.attributeValueProcessor(attr, attrMap[attr]);\n attrVal = replaceEntitiesValue(attrVal, options);\n if (attrVal === true && options.suppressBooleanAttributes) {\n attrStr += ` ${attr.substr(options.attributeNamePrefix.length)}`;\n } else {\n attrStr += ` ${attr.substr(options.attributeNamePrefix.length)}=\"${attrVal}\"`;\n }\n }\n }\n return attrStr;\n}\n\nfunction isStopNode(jPath, options) {\n jPath = jPath.substr(0, jPath.length - options.textNodeName.length - 1);\n let tagName = jPath.substr(jPath.lastIndexOf(\".\") + 1);\n for (let index in options.stopNodes) {\n if (options.stopNodes[index] === jPath || options.stopNodes[index] === \"*.\" + tagName) return true;\n }\n return false;\n}\n\nfunction replaceEntitiesValue(textValue, options) {\n if (textValue && textValue.length > 0 && options.processEntities) {\n for (let i = 0; i < options.entities.length; i++) {\n const entity = options.entities[i];\n textValue = textValue.replace(entity.regex, entity.val);\n }\n }\n return textValue;\n}\nmodule.exports = toXml;\n","'use strict';\n//parse Empty Node as self closing node\nconst buildFromOrderedJs = require('./orderedJs2Xml');\n\nconst defaultOptions = {\n attributeNamePrefix: '@_',\n attributesGroupName: false,\n textNodeName: '#text',\n ignoreAttributes: true,\n cdataPropName: false,\n format: false,\n indentBy: ' ',\n suppressEmptyNode: false,\n suppressUnpairedNode: true,\n suppressBooleanAttributes: true,\n tagValueProcessor: function(key, a) {\n return a;\n },\n attributeValueProcessor: function(attrName, a) {\n return a;\n },\n preserveOrder: false,\n commentPropName: false,\n unpairedTags: [],\n entities: [\n { regex: new RegExp(\"&\", \"g\"), val: \"&\" },//it must be on top\n { regex: new RegExp(\">\", \"g\"), val: \">\" },\n { regex: new RegExp(\"<\", \"g\"), val: \"<\" },\n { regex: new RegExp(\"\\'\", \"g\"), val: \"'\" },\n { regex: new RegExp(\"\\\"\", \"g\"), val: \""\" }\n ],\n processEntities: true,\n stopNodes: [],\n // transformTagName: false,\n // transformAttributeName: false,\n oneListGroup: false\n};\n\nfunction Builder(options) {\n this.options = Object.assign({}, defaultOptions, options);\n if (this.options.ignoreAttributes || this.options.attributesGroupName) {\n this.isAttribute = function(/*a*/) {\n return false;\n };\n } else {\n this.attrPrefixLen = this.options.attributeNamePrefix.length;\n this.isAttribute = isAttribute;\n }\n\n this.processTextOrObjNode = processTextOrObjNode\n\n if (this.options.format) {\n this.indentate = indentate;\n this.tagEndChar = '>\\n';\n this.newLine = '\\n';\n } else {\n this.indentate = function() {\n return '';\n };\n this.tagEndChar = '>';\n this.newLine = '';\n }\n}\n\nBuilder.prototype.build = function(jObj) {\n if(this.options.preserveOrder){\n return buildFromOrderedJs(jObj, this.options);\n }else {\n if(Array.isArray(jObj) && this.options.arrayNodeName && this.options.arrayNodeName.length > 1){\n jObj = {\n [this.options.arrayNodeName] : jObj\n }\n }\n return this.j2x(jObj, 0).val;\n }\n};\n\nBuilder.prototype.j2x = function(jObj, level) {\n let attrStr = '';\n let val = '';\n for (let key in jObj) {\n if(!Object.prototype.hasOwnProperty.call(jObj, key)) continue;\n if (typeof jObj[key] === 'undefined') {\n // supress undefined node only if it is not an attribute\n if (this.isAttribute(key)) {\n val += '';\n }\n } else if (jObj[key] === null) {\n // null attribute should be ignored by the attribute list, but should not cause the tag closing\n if (this.isAttribute(key)) {\n val += '';\n } else if (key[0] === '?') {\n val += this.indentate(level) + '<' + key + '?' + this.tagEndChar;\n } else {\n val += this.indentate(level) + '<' + key + '/' + this.tagEndChar;\n }\n // val += this.indentate(level) + '<' + key + '/' + this.tagEndChar;\n } else if (jObj[key] instanceof Date) {\n val += this.buildTextValNode(jObj[key], key, '', level);\n } else if (typeof jObj[key] !== 'object') {\n //premitive type\n const attr = this.isAttribute(key);\n if (attr) {\n attrStr += this.buildAttrPairStr(attr, '' + jObj[key]);\n }else {\n //tag value\n if (key === this.options.textNodeName) {\n let newval = this.options.tagValueProcessor(key, '' + jObj[key]);\n val += this.replaceEntitiesValue(newval);\n } else {\n val += this.buildTextValNode(jObj[key], key, '', level);\n }\n }\n } else if (Array.isArray(jObj[key])) {\n //repeated nodes\n const arrLen = jObj[key].length;\n let listTagVal = \"\";\n for (let j = 0; j < arrLen; j++) {\n const item = jObj[key][j];\n if (typeof item === 'undefined') {\n // supress undefined node\n } else if (item === null) {\n if(key[0] === \"?\") val += this.indentate(level) + '<' + key + '?' + this.tagEndChar;\n else val += this.indentate(level) + '<' + key + '/' + this.tagEndChar;\n // val += this.indentate(level) + '<' + key + '/' + this.tagEndChar;\n } else if (typeof item === 'object') {\n if(this.options.oneListGroup ){\n listTagVal += this.j2x(item, level + 1).val;\n }else{\n listTagVal += this.processTextOrObjNode(item, key, level)\n }\n } else {\n listTagVal += this.buildTextValNode(item, key, '', level);\n }\n }\n if(this.options.oneListGroup){\n listTagVal = this.buildObjectNode(listTagVal, key, '', level);\n }\n val += listTagVal;\n } else {\n //nested node\n if (this.options.attributesGroupName && key === this.options.attributesGroupName) {\n const Ks = Object.keys(jObj[key]);\n const L = Ks.length;\n for (let j = 0; j < L; j++) {\n attrStr += this.buildAttrPairStr(Ks[j], '' + jObj[key][Ks[j]]);\n }\n } else {\n val += this.processTextOrObjNode(jObj[key], key, level)\n }\n }\n }\n return {attrStr: attrStr, val: val};\n};\n\nBuilder.prototype.buildAttrPairStr = function(attrName, val){\n val = this.options.attributeValueProcessor(attrName, '' + val);\n val = this.replaceEntitiesValue(val);\n if (this.options.suppressBooleanAttributes && val === \"true\") {\n return ' ' + attrName;\n } else return ' ' + attrName + '=\"' + val + '\"';\n}\n\nfunction processTextOrObjNode (object, key, level) {\n const result = this.j2x(object, level + 1);\n if (object[this.options.textNodeName] !== undefined && Object.keys(object).length === 1) {\n return this.buildTextValNode(object[this.options.textNodeName], key, result.attrStr, level);\n } else {\n return this.buildObjectNode(result.val, key, result.attrStr, level);\n }\n}\n\nBuilder.prototype.buildObjectNode = function(val, key, attrStr, level) {\n if(val === \"\"){\n if(key[0] === \"?\") return this.indentate(level) + '<' + key + attrStr+ '?' + this.tagEndChar;\n else {\n return this.indentate(level) + '<' + key + attrStr + this.closeTag(key) + this.tagEndChar;\n }\n }else{\n\n let tagEndExp = '</' + key + this.tagEndChar;\n let piClosingChar = \"\";\n \n if(key[0] === \"?\") {\n piClosingChar = \"?\";\n tagEndExp = \"\";\n }\n \n // attrStr is an empty string in case the attribute came as undefined or null\n if ((attrStr || attrStr === '') && val.indexOf('<') === -1) {\n return ( this.indentate(level) + '<' + key + attrStr + piClosingChar + '>' + val + tagEndExp );\n } else if (this.options.commentPropName !== false && key === this.options.commentPropName && piClosingChar.length === 0) {\n return this.indentate(level) + `<!--${val}-->` + this.newLine;\n }else {\n return (\n this.indentate(level) + '<' + key + attrStr + piClosingChar + this.tagEndChar +\n val +\n this.indentate(level) + tagEndExp );\n }\n }\n}\n\nBuilder.prototype.closeTag = function(key){\n let closeTag = \"\";\n if(this.options.unpairedTags.indexOf(key) !== -1){ //unpaired\n if(!this.options.suppressUnpairedNode) closeTag = \"/\"\n }else if(this.options.suppressEmptyNode){ //empty\n closeTag = \"/\";\n }else{\n closeTag = `></${key}`\n }\n return closeTag;\n}\n\nfunction buildEmptyObjNode(val, key, attrStr, level) {\n if (val !== '') {\n return this.buildObjectNode(val, key, attrStr, level);\n } else {\n if(key[0] === \"?\") return this.indentate(level) + '<' + key + attrStr+ '?' + this.tagEndChar;\n else {\n return this.indentate(level) + '<' + key + attrStr + '/' + this.tagEndChar;\n // return this.buildTagStr(level,key, attrStr);\n }\n }\n}\n\nBuilder.prototype.buildTextValNode = function(val, key, attrStr, level) {\n if (this.options.cdataPropName !== false && key === this.options.cdataPropName) {\n return this.indentate(level) + `<![CDATA[${val}]]>` + this.newLine;\n }else if (this.options.commentPropName !== false && key === this.options.commentPropName) {\n return this.indentate(level) + `<!--${val}-->` + this.newLine;\n }else if(key[0] === \"?\") {//PI tag\n return this.indentate(level) + '<' + key + attrStr+ '?' + this.tagEndChar; \n }else{\n let textValue = this.options.tagValueProcessor(key, val);\n textValue = this.replaceEntitiesValue(textValue);\n \n if( textValue === ''){\n return this.indentate(level) + '<' + key + attrStr + this.closeTag(key) + this.tagEndChar;\n }else{\n return this.indentate(level) + '<' + key + attrStr + '>' +\n textValue +\n '</' + key + this.tagEndChar;\n }\n }\n}\n\nBuilder.prototype.replaceEntitiesValue = function(textValue){\n if(textValue && textValue.length > 0 && this.options.processEntities){\n for (let i=0; i<this.options.entities.length; i++) {\n const entity = this.options.entities[i];\n textValue = textValue.replace(entity.regex, entity.val);\n }\n }\n return textValue;\n}\n\nfunction indentate(level) {\n return this.options.indentBy.repeat(level);\n}\n\nfunction isAttribute(name /*, options*/) {\n if (name.startsWith(this.options.attributeNamePrefix) && name !== this.options.textNodeName) {\n return name.substr(this.attrPrefixLen);\n } else {\n return false;\n }\n}\n\nmodule.exports = Builder;\n","'use strict';\n\nconst validator = require('./validator');\nconst XMLParser = require('./xmlparser/XMLParser');\nconst XMLBuilder = require('./xmlbuilder/json2xml');\n\nmodule.exports = {\n XMLParser: XMLParser,\n XMLValidator: validator,\n XMLBuilder: XMLBuilder\n}","import {XMLParser, XMLValidator} from 'fast-xml-parser';\n\nexport default function isSvg(string) {\n\tif (typeof string !== 'string') {\n\t\tthrow new TypeError(`Expected a \\`string\\`, got \\`${typeof string}\\``);\n\t}\n\n\tstring = string.trim();\n\n\tif (string.length === 0) {\n\t\treturn false;\n\t}\n\n\t// Has to be `!==` as it can also return an object with error info.\n\tif (XMLValidator.validate(string) !== true) {\n\t\treturn false;\n\t}\n\n\tlet jsonObject;\n\tconst parser = new XMLParser();\n\n\ttry {\n\t\tjsonObject = parser.parse(string);\n\t} catch {\n\t\treturn false;\n\t}\n\n\tif (!jsonObject) {\n\t\treturn false;\n\t}\n\n\tif (!Object.keys(jsonObject).some(x => x.toLowerCase() === 'svg')) {\n\t\treturn false;\n\t}\n\n\treturn true;\n}\n","/**\n * @copyright Copyright (c) 2022 John Molakvoæ <skjnldsv@protonmail.com>\n *\n * @author John Molakvoæ <skjnldsv@protonmail.com>\n *\n * @license AGPL-3.0-or-later\n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see <http://www.gnu.org/licenses/>.\n *\n */\nimport type { Folder } from '../files/folder'\nimport type { Node } from '../files/node'\nimport isSvg from 'is-svg'\n\nimport { Column } from './column.js'\n\nexport type ContentsWithRoot = {\n\tfolder: Folder,\n\tcontents: Node[]\n}\n\ninterface ViewData {\n\t/** Unique view ID */\n\tid: string\n\t/** Translated view name */\n\tname: string\n\t/** Translated accessible description of the view */\n\tcaption?: string\n\n\t/** Translated title of the empty view */\n\temptyTitle?: string\n\t/** Translated description of the empty view */\n\temptyCaption?: string\n\n\t/**\n\t * Method return the content of the provided path\n\t * This ideally should be a cancellable promise.\n\t * promise.cancel(reason) will be called when the directory\n\t * change and the promise is not resolved yet.\n\t * You _must_ also return the current directory\n\t * information alongside with its content.\n\t */\n\tgetContents: (path: string) => Promise<ContentsWithRoot>\n\t/** The view icon as an inline svg */\n\ticon: string\n\t/** The view order */\n\torder: number\n\n\t/**\n\t * Custom params to give to the router on click\n\t * If defined, will be treated as a dummy view and\n\t * will just redirect and not fetch any contents.\n\t */\n\tparams?: Record<string, string>\n\n\t/**\n\t * This view column(s). Name and actions are\n\t * by default always included\n\t */\n\tcolumns?: Column[]\n\t/** The empty view element to render your empty content into */\n\temptyView?: (div: HTMLDivElement) => void\n\t/** The parent unique ID */\n\tparent?: string\n\t/** This view is sticky (sent at the bottom) */\n\tsticky?: boolean\n\n\t/**\n\t * This view has children and is expanded (by default)\n\t * or not. This will be overridden by user config.\n\t */\n\texpanded?: boolean\n\n\t/**\n\t * Will be used as default if the user\n\t * haven't customized their sorting column\n\t */\n\tdefaultSortKey?: string\n}\n\nexport class View implements ViewData {\n\n\tprivate _view: ViewData\n\n\tconstructor(view: ViewData) {\n\t\tisValidView(view)\n\t\tthis._view = view\n\t}\n\n\tget id() {\n\t\treturn this._view.id\n\t}\n\n\tget name() {\n\t\treturn this._view.name\n\t}\n\n\tget caption() {\n\t\treturn this._view.caption\n\t}\n\n\tget emptyTitle() {\n\t\treturn this._view.emptyTitle\n\t}\n\n\tget emptyCaption() {\n\t\treturn this._view.emptyCaption\n\t}\n\n\tget getContents() {\n\t\treturn this._view.getContents\n\t}\n\n\tget icon() {\n\t\treturn this._view.icon\n\t}\n\n\tset icon(icon) {\n\t\tthis._view.icon = icon\n\t}\n\n\tget order() {\n\t\treturn this._view.order\n\t}\n\n\tset order(order) {\n\t\tthis._view.order = order\n\t}\n\n\tget params() {\n\t\treturn this._view.params\n\t}\n\n\tset params(params) {\n\t\tthis._view.params = params\n\t}\n\n\tget columns() {\n\t\treturn this._view.columns\n\t}\n\n\tget emptyView() {\n\t\treturn this._view.emptyView\n\t}\n\n\tget parent() {\n\t\treturn this._view.parent\n\t}\n\n\tget sticky() {\n\t\treturn this._view.sticky\n\t}\n\n\tget expanded() {\n\t\treturn this._view.expanded\n\t}\n\n\tset expanded(expanded: boolean | undefined) {\n\t\tthis._view.expanded = expanded\n\t}\n\n\tget defaultSortKey() {\n\t\treturn this._view.defaultSortKey\n\t}\n\n}\n\n/**\n * Typescript cannot validate an interface.\n * Please keep in sync with the View interface requirements.\n *\n * @param {ViewData} view the view to check\n * @return {boolean} true if the column is valid\n * @throws {Error} if the view is not valid\n */\nconst isValidView = function(view: ViewData): boolean {\n\tif (!view.id || typeof view.id !== 'string') {\n\t\tthrow new Error('View id is required and must be a string')\n\t}\n\n\tif (!view.name || typeof view.name !== 'string') {\n\t\tthrow new Error('View name is required and must be a string')\n\t}\n\n\tif (view.columns && view.columns.length > 0\n\t\t&& (!view.caption || typeof view.caption !== 'string')) {\n\t\tthrow new Error('View caption is required for top-level views and must be a string')\n\t}\n\n\tif (!view.getContents || typeof view.getContents !== 'function') {\n\t\tthrow new Error('View getContents is required and must be a function')\n\t}\n\n\tif (!view.icon || typeof view.icon !== 'string' || !isSvg(view.icon)) {\n\t\tthrow new Error('View icon is required and must be a valid svg string')\n\t}\n\n\tif (!('order' in view) || typeof view.order !== 'number') {\n\t\tthrow new Error('View order is required and must be a number')\n\t}\n\n\t// Optional properties\n\tif (view.columns) {\n\t\tview.columns.forEach((column) => {\n\t\t\tif (!(column instanceof Column)) {\n\t\t\t\tthrow new Error('View columns must be an array of Column. Invalid column found')\n\t\t\t}\n\t\t})\n\t}\n\n\tif (view.emptyView && typeof view.emptyView !== 'function') {\n\t\tthrow new Error('View emptyView must be a function')\n\t}\n\n\tif (view.parent && typeof view.parent !== 'string') {\n\t\tthrow new Error('View parent must be a string')\n\t}\n\n\tif ('sticky' in view && typeof view.sticky !== 'boolean') {\n\t\tthrow new Error('View sticky must be a boolean')\n\t}\n\n\tif ('expanded' in view && typeof view.expanded !== 'boolean') {\n\t\tthrow new Error('View expanded must be a boolean')\n\t}\n\n\tif (view.defaultSortKey && typeof view.defaultSortKey !== 'string') {\n\t\tthrow new Error('View defaultSortKey must be a string')\n\t}\n\n\treturn true\n}\n","/**\n * @copyright 2019 Christoph Wurst <christoph@winzerhof-wurst.at>\n *\n * @author Christoph Wurst <christoph@winzerhof-wurst.at>\n * @author John Molakvoæ <skjnldsv@protonmail.com>\n *\n * @license AGPL-3.0-or-later\n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with this program. If not, see <http://www.gnu.org/licenses/>.\n *\n */\n\nimport { type Entry, getNewFileMenu } from './newFileMenu'\nimport { type Folder } from './files/folder'\n\nexport { FileAction, getFileActions, registerFileAction, DefaultType } from './fileAction'\nexport { Header, getFileListHeaders, registerFileListHeaders } from './fileListHeaders'\nexport { type Entry, NewMenuEntryCategory } from './newFileMenu'\nexport { Permission } from './permissions'\n\nexport * from './dav/davProperties'\nexport * from './dav/davPermissions'\nexport * from './dav/dav'\n\nexport { FileType } from './files/fileType'\nexport { File } from './files/file'\nexport { Folder } from './files/folder'\nexport { Node, NodeStatus } from './files/node'\n\nexport { isFilenameValid } from './utils/filename'\nexport { formatFileSize, parseFileSize } from './utils/fileSize'\nexport { orderBy } from './utils/sorting'\nexport { sortNodes, FilesSortingMode, type FilesSortingOptions } from './utils/fileSorting'\n\nexport * from './navigation/navigation'\nexport * from './navigation/column'\nexport * from './navigation/view'\n\n/**\n * Add a new menu entry to the upload manager menu\n *\n * @param entry The new file menu entry\n */\nexport const addNewFileMenuEntry = function(entry: Entry) {\n\tconst newFileMenu = getNewFileMenu()\n\treturn newFileMenu.registerEntry(entry)\n}\n\n/**\n * Remove a previously registered entry from the upload menu\n *\n * @param entry Entry to remove (or name of entry)\n */\nexport const removeNewFileMenuEntry = function(entry: Entry | string) {\n\tconst newFileMenu = getNewFileMenu()\n\treturn newFileMenu.unregisterEntry(entry)\n}\n\n/**\n * Get the list of registered entries from the upload menu\n *\n * @param {Folder} context the creation context. Usually the current folder FileInfo\n */\nexport const getNewFileMenuEntries = function(context?: Folder) {\n\tconst newFileMenu = getNewFileMenu()\n\treturn newFileMenu.getEntries(context).sort((a: Entry, b: Entry) => {\n\t\t// If defined and different, sort by order\n\t\tif (a.order !== undefined\n\t\t\t&& b.order !== undefined\n\t\t\t&& a.order !== b.order) {\n\t\t\treturn a.order - b.order\n\t\t}\n\t\t// else sort by display name\n\t\treturn a.displayName.localeCompare(b.displayName, undefined, { numeric: true, sensitivity: 'base' })\n\t})\n}\n"],"names":["NewMenuEntryCategory","DefaultType","Permission","FileType","NodeStatus","basename","headers","FilesSortingMode","util","require$$0","defaultOptions","validator","val","buildOptions","xmlNode","readDocType","entityName","toNumber","require$$1","require$$2","require$$3","replaceEntitiesValue","result","OrderedObjParser","prettify","propName","XMLParser","attStr","XMLValidator"],"mappings":";;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAyBA,MAAM,YAAY,CAAQ,SAAA;AACzB,MAAI,SAAS,MAAM;AAClB,WAAO,iBAAiB,EACtB,OAAO,OAAO,EACd,MAAM;AAAA,EACT;AACO,SAAA,iBAAA,EACL,OAAO,OAAO,EACd,OAAO,KAAK,GAAG,EACf;AACH;AAEA,MAAA,SAAe,UAAU,gBAAgB;ACrCzC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAyBY,IAAA,yCAAAA,0BAAL;AAINA,wBAAAA,sBAAA,sBAAmB,CAAnB,IAAA;AAIAA,wBAAAA,sBAAA,eAAY,CAAZ,IAAA;AAIAA,wBAAAA,sBAAA,WAAQ,CAAR,IAAA;AAZWA,SAAAA;AAAA,GAAA,wBAAA,CAAA,CAAA;AA2DL,MAAM,YAAY;AAAA,EAEhB,WAAyB,CAAA;AAAA,EAE1B,cAAc,OAAc;AAClC,SAAK,cAAc,KAAK;AAClB,UAAA,WAAW,MAAM,YAAY;AAC9B,SAAA,SAAS,KAAK,KAAK;AAAA,EACzB;AAAA,EAEO,gBAAgB,OAAuB;AACvC,UAAA,aAAa,OAAO,UAAU,WACjC,KAAK,cAAc,KAAK,IACxB,KAAK,cAAc,MAAM,EAAE;AAE9B,QAAI,eAAe,IAAI;AACf,aAAA,KAAK,oCAAoC,EAAE,O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