@deephaven/file-explorer 0.18.0 → 0.18.1-grpc-file-storage.8

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/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # @deephaven/file-explorer
2
2
 
3
- React component for browsing a file explorer server. Has a WebDAV implementation included.
3
+ React component for browsing a file explorer server. Implementation must be provided.
4
4
 
5
5
  ## Install
6
6
 
@@ -10,18 +10,24 @@ npm install --save @deephaven/file-explorer
10
10
 
11
11
  ## Usage
12
12
 
13
- ## Usage
14
-
15
13
  ```jsx
16
- import React, { Component } from 'react'
17
- import FileExplorer, { WebdavFileStorage } from '@deephaven/file-explorer'
14
+ import React, { Component } from 'react';
15
+ import FileExplorer, { FileStorage } from '@deephaven/file-explorer';
16
+
17
+ class MyFileStorage implements FileStorage {
18
+ // Must implement all menthods...
19
+ }
18
20
 
19
- const client = createClient('https://www.example.com/');
20
- const storage = new WebdavFileStorage(client);
21
+ const storage = new MyFileStorage();
21
22
 
22
23
  class Example extends Component {
23
24
  render() {
24
- return <FileExplorer storage={storage} onSelect={item => console.log('Item selected', item)} />
25
+ return (
26
+ <FileExplorer
27
+ storage={storage}
28
+ onSelect={item => console.log('Item selected', item)}
29
+ />
30
+ );
25
31
  }
26
32
  }
27
33
  ```
@@ -1 +1 @@
1
- {"version":3,"sourceRoot":"","sources":["../src/FileExplorerToolbar.scss","../../components/scss/new_variables.scss","../../components/scss/bootstrap_overrides.scss","../../../node_modules/bootstrap/scss/_variables.scss"],"names":[],"mappings":"AAUA;EACE;EACA;EACA;EACA,YATe;EAUf;EACA;EACA;EACA;EACA;EACA;EACA,SCnBS;EDoBT,YAjBe;;AAkBf;EACE;EACA,eCvBO;;ADyBT;EACE;EACA;;AACA;EACE;;AACA;EACE,kBERG;;AFYT;EACE,WG6coC;EH5cpC;EACA;EACA,WAtCgB","file":"FileExplorerToolbar.css"}
1
+ {"version":3,"sourceRoot":"","sources":["../src/FileExplorerToolbar.scss","../../components/scss/new_variables.scss","../../components/scss/bootstrap_overrides.scss","../../../node_modules/bootstrap/scss/_variables.scss"],"names":[],"mappings":"AAUA;EACE;EACA;EACA;EACA,YATe;EAUf;EACA;EACA;EACA;EACA;EACA;EACA,SCnBS;EDoBT,YAjBe;;AAkBf;EACE;EACA,eCvBO;;ADyBT;EACE;EACA;;AACA;EACE;;AACA;EACE,kBERG;;AFYT;EACE,WG8coC;EH7cpC;EACA;EACA,WAtCgB","file":"FileExplorerToolbar.css"}
@@ -94,6 +94,19 @@ export declare class FileUtils {
94
94
  * @param paths The paths to reduce
95
95
  */
96
96
  static reducePaths(paths: string[]): string[];
97
+ /**
98
+ * Removes the root path from the provided file name. Throws if the filename does not start with root.
99
+ * @param root The root to remove
100
+ * @param filename Filename to remove the root path from
101
+ * @returns Filename without the root
102
+ */
103
+ static removeRoot(root: string, filename: string): string;
104
+ /**
105
+ * Add root to the filename as prefix
106
+ * @param path Filename to prefix root to
107
+ * @returns Filename with root at the prefix
108
+ */
109
+ static addRoot(root: string, path: string): string;
97
110
  }
98
111
  export default FileUtils;
99
112
  //# sourceMappingURL=FileUtils.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"FileUtils.d.ts","sourceRoot":"","sources":["../src/FileUtils.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,oBAAY,SAAS;IACnB,MAAM,kBAAkB;IACxB,UAAU,eAAe;IACzB,MAAM,kBAAkB;IACxB,eAAe,8BAA8B;IAC7C,KAAK,iBAAiB;IACtB,OAAO,KAAK;CACb;AAED;;GAEG;AACH,qBAAa,SAAS;IACpB;;;;OAIG;IACH,MAAM,CAAC,qBAAqB,CAAC,SAAS,SAAK,GAAG,MAAM;IAIpD;;;OAGG;IACH,MAAM,CAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM;IAQrC;;;;;OAKG;IACH,MAAM,CAAC,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM;IAQzC;;;;O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package/dist/FileUtils.js CHANGED
@@ -252,6 +252,35 @@ export class FileUtils {
252
252
  var folders = paths.filter(path => FileUtils.isPath(path));
253
253
  return paths.filter(path => !folders.some(folder => path !== folder && path.startsWith(folder)));
254
254
  }
255
+ /**
256
+ * Removes the root path from the provided file name. Throws if the filename does not start with root.
257
+ * @param root The root to remove
258
+ * @param filename Filename to remove the root path from
259
+ * @returns Filename without the root
260
+ */
261
+
262
+
263
+ static removeRoot(root, filename) {
264
+ if (root.length === 0) {
265
+ return filename;
266
+ }
267
+
268
+ if (!filename.startsWith(root)) {
269
+ throw new Error("Filename ".concat(filename, " does not start with expected root ").concat(root));
270
+ }
271
+
272
+ return filename.substring(root.length);
273
+ }
274
+ /**
275
+ * Add root to the filename as prefix
276
+ * @param path Filename to prefix root to
277
+ * @returns Filename with root at the prefix
278
+ */
279
+
280
+
281
+ static addRoot(root, path) {
282
+ return "".concat(root).concat(path);
283
+ }
255
284
 
256
285
  }
257
286
  export default FileUtils;
@@ -1 +1 @@
1
- {"version":3,"file":"FileUtils.js","names":["ValidationError","MIME_TYPE","FileUtils","fileExtensionToString","extension","length","getDepth","name","hasPath","Error","matches","match","getExtension","components","getBaseName","split","pop","getCopyFileName","originalName","extensionPosition","lastIndexOf","substring","copyName","getMimeType","toLowerCase","GROOVY","PYTHON","PYTHON_COMPILED","SCALA","PLAIN_TEXT","UNKNOWN","getParent","parts","join","getPath","startsWith","isPath","endsWith","makePath","replaceExtension","newExtension","index","nameWithoutExtension","extensionString","validateName","reservedNames","invalidCharsRegex","invalidCharLabels","Map","includes","test","reduce","acc","next","map","char","has","get","reducePaths","paths","folders","filter","path","some","folder"],"sources":["../src/FileUtils.ts"],"sourcesContent":["import { ValidationError } from '@deephaven/utils';\n\n/**\n * A basic list of some common MIME types.\n */\nexport enum MIME_TYPE {\n GROOVY = 'text/x-groovy',\n PLAIN_TEXT = 'text/plain',\n PYTHON = 'text/x-python',\n PYTHON_COMPILED = 'application/x-python-code',\n SCALA = 'text/x-scala',\n UNKNOWN = '',\n}\n\n/**\n * Collection of utils for operating on file names\n */\nexport class FileUtils {\n /**\n * Format file extension\n * @param extension File extension to format, defaults to empty string\n * @returns Formatted string - '' for no extension, '.' for empty extension, '.ext' for non-empty extension\n */\n static fileExtensionToString(extension = ''): string {\n return extension.length === 0 ? '' : `.${extension}`;\n }\n\n /**\n * Get the depth (how many directories deep it is) of the provided filename with path.\n * @param name The full file name to get the depth of\n */\n static getDepth(name: string): number {\n if (!FileUtils.hasPath(name)) {\n throw new Error(`Invalid path provided: ${name}`);\n }\n const matches = name.match(/\\//g) ?? [];\n return matches.length - 1;\n }\n\n /**\n * Get just the extension of file name.\n * Note that it just returns the last extension, so 'example.tar.gz' would just return 'gz'.\n * @param name The file name with or without path to get the extension of\n * @returns The file extension\n */\n static getExtension(name: string): string {\n const components = this.getBaseName(name).split('.');\n if (components.length > 1) {\n return components.pop() ?? '';\n }\n return '';\n }\n\n /**\n * Get the base name portion of the file, eg '/foo/bar.txt' => 'bar.txt'\n * @param name The full name including path of the file\n * @returns Just the file name part of the file\n */\n static getBaseName(name: string): string {\n return name.split('/').pop() ?? '';\n }\n\n /**\n * Create copy file name, used for copying unsaved files so doesn't have to be unique\n * @param originalName File name\n * @returns The file name of the copy\n */\n static getCopyFileName(originalName: string): string {\n const extensionPosition = originalName.lastIndexOf('.');\n let extension = null;\n let name = null;\n if (extensionPosition < 0) {\n // No extension\n name = originalName;\n } else {\n name = originalName.substring(0, extensionPosition);\n extension = originalName.substring(extensionPosition + 1);\n }\n const copyName = name ? `${name}-copy` : 'Copy';\n return extension !== null ? `${copyName}.${extension}` : copyName;\n }\n\n /**\n * Return a MIME type for the provided file\n * @param name The file name to get the type for\n * @returns A known MIME type if recognized\n */\n static getMimeType(name: string): MIME_TYPE {\n const extension = this.getExtension(name).toLowerCase();\n switch (extension) {\n case 'groovy':\n return MIME_TYPE.GROOVY;\n case 'py':\n return MIME_TYPE.PYTHON;\n case 'pyc':\n return MIME_TYPE.PYTHON_COMPILED;\n case 'scala':\n return MIME_TYPE.SCALA;\n case 'txt':\n return MIME_TYPE.PLAIN_TEXT;\n default:\n return MIME_TYPE.UNKNOWN;\n }\n }\n\n /**\n * Pop the last part of the filename component to return the parent path\n * @param name The file name to get the parent path of\n */\n static getParent(name: string): string {\n if (!FileUtils.hasPath(name)) {\n throw new Error(`Invalid name provided: ${name}`);\n }\n\n const parts = name.split('/');\n while (parts.pop() === '');\n if (parts.length === 0) {\n throw new Error(`No parent for path provided: ${name}`);\n }\n return `${parts.join('/')}/`;\n }\n\n /**\n * Get the path name portion of the file\n * @param name The full path with or without filename to get the path of\n * @returns Just the path with out the file name part, including trailing slash\n */\n static getPath(name: string): string {\n if (!FileUtils.hasPath(name)) {\n throw new Error(`Invalid filename provided: ${name}`);\n }\n const parts = name.split('/');\n parts.pop();\n return `${parts.join('/')}/`;\n }\n\n /**\n * Check if a given file name includes the full path\n * @param name The file name to check\n * @returns True if it's a full path, false otherwise\n */\n static hasPath(name: string): boolean {\n return name.startsWith('/');\n }\n\n /**\n * Check a given file name is a path\n * @param name The file name to check\n * @returns True if it's a full path, false otherwise\n */\n static isPath(name: string): boolean {\n return name.startsWith('/') && name.endsWith('/');\n }\n\n /**\n * Turns a directory file name into a path. Basically ensures there's a trailing slash\n * @param name The directory name to make a path\n */\n static makePath(name: string): string {\n if (!name.endsWith('/')) {\n return `${name}/`;\n }\n return name;\n }\n\n /**\n * Replace extension in the item name\n * @param name Name to replace the extension in\n * @param newExtension New extension, defaults to no extension\n */\n static replaceExtension(name: string, newExtension = ''): string {\n const index = name.lastIndexOf('.');\n const nameWithoutExtension = index > -1 ? name.substring(0, index) : name;\n const extensionString = FileUtils.fileExtensionToString(newExtension);\n return `${nameWithoutExtension}${extensionString}`;\n }\n\n /**\n * Validate the provided name. Throws an error if validation fails\n * @param name The item name to validate\n */\n static validateName(name: string): void {\n // Static checks\n const reservedNames = ['.', '..'];\n // Global flag to show all invalid chars, not just the first match\n const invalidCharsRegex = /[\\\\/\\0]/g;\n const invalidCharLabels = new Map([['\\0', 'null']]);\n\n if (!name) {\n throw new ValidationError(`Name cannot be empty`);\n }\n if (reservedNames.includes(name)) {\n throw new ValidationError(`\"${name}\" is a reserved name`);\n }\n if (invalidCharsRegex.test(name)) {\n throw new ValidationError(\n `Invalid characters in name: \"${(name.match(invalidCharsRegex) ?? [])\n // Filter out duplicates\n .reduce(\n (acc, next) => (acc.includes(next) ? acc : [...acc, next]),\n [] as string[]\n )\n .map(char =>\n invalidCharLabels.has(char) ? invalidCharLabels.get(char) : char\n )\n .join('\", \"')}\"`\n );\n }\n }\n\n /**\n * Reduce the provided paths to the minimum selection.\n * Removes any nested files or directories if a parent is already selected.\n * @param paths The paths to reduce\n */\n static reducePaths(paths: string[]): string[] {\n const folders = paths.filter(path => FileUtils.isPath(path));\n return paths.filter(\n path =>\n !folders.some(folder => path !== folder && path.startsWith(folder))\n );\n }\n}\n\nexport default FileUtils;\n"],"mappings":"AAAA,SAASA,eAAT,QAAgC,kBAAhC;AAEA;AACA;AACA;;AACA,WAAYC,SAAZ;AASA;AACA;AACA;;WAXYA,S;EAAAA,S;EAAAA,S;EAAAA,S;EAAAA,S;EAAAA,S;EAAAA,S;GAAAA,S,KAAAA,S;;AAYZ,OAAO,MAAMC,SAAN,CAAgB;EACrB;AACF;AACA;AACA;AACA;EAC8B,OAArBC,qBAAqB,GAAyB;IAAA,IAAxBC,SAAwB,uEAAZ,EAAY;IACnD,OAAOA,SAAS,CAACC,MAAV,KAAqB,CAArB,GAAyB,EAAzB,cAAkCD,SAAlC,CAAP;EACD;EAED;AACF;AACA;AACA;;;EACiB,OAARE,QAAQ,CAACC,IAAD,EAAuB;IAAA;;IACpC,IAAI,CAACL,SAAS,CAACM,OAAV,CAAkBD,IAAlB,CAAL,EAA8B;MAC5B,MAAM,IAAIE,KAAJ,kCAAoCF,IAApC,EAAN;IACD;;IACD,IAAMG,OAAO,kBAAGH,IAAI,CAACI,KAAL,CAAW,KAAX,CAAH,qDAA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AAM,IAAIP,eAAJ,aAAwBO,IAAxB,2BAAN;IACD;;IACD,IAAIuC,iBAAiB,CAACI,IAAlB,CAAuB3C,IAAvB,CAAJ,EAAkC;MAAA;;MAChC,MAAM,IAAIP,eAAJ,yCAC4B,iBAACO,IAAI,CAACI,KAAL,CAAWmC,iBAAX,CAAD,uDAAkC,EAAlC,CAC9B;MAD8B,EAE7BK,MAF6B,CAG5B,CAACC,GAAD,EAAMC,IAAN,KAAgBD,GAAG,CAACH,QAAJ,CAAaI,IAAb,IAAqBD,GAArB,GAA2B,CAAC,GAAGA,GAAJ,EAASC,IAAT,CAHf,EAI5B,EAJ4B,EAM7BC,GAN6B,CAMzBC,IAAI,IACPR,iBAAiB,CAACS,GAAlB,CAAsBD,IAAtB,IAA8BR,iBAAiB,CAACU,GAAlB,CAAsBF,IAAtB,CAA9B,GAA4DA,IAPhC,EAS7BtB,IAT6B,CASxB,MATwB,CAD5B,QAAN;IAYD;EACF;EAED;AACF;AACA;AACA;AACA;;;EACoB,OAAXyB,WAAW,CAACC,KAAD,EAA4B;IAC5C,IAAMC,OAAO,GAAGD,KAAK,CAACE,MAAN,CAAaC,IAAI,IAAI5D,SAAS,CAACkC,MAAV,CAAiB0B,IAAjB,CAArB,CAAhB;IACA,OAAOH,KAAK,CAACE,MAAN,CACLC,IAAI,IACF,CAACF,OAAO,CAACG,IAAR,CAAaC,MAAM,IAAIF,IAAI,KAAKE,MAAT,IAAmBF,IAAI,CAAC3B,UAAL,CAAgB6B,MAAhB,CAA1C,CAFE,CAAP;EAID;;AA5MoB;AA+MvB,eAAe9D,SAAf"}
1
+ {"version":3,"file":"FileUtils.js","names":["ValidationError","MIME_TYPE","FileUtils","fileExtensionToString","extension","length","getDepth","name","hasPath","Error","matches","match","getExtension","components","getBaseName","split","pop","getCopyFileName","originalName","extensionPosition","lastIndexOf","substring","copyName","getMimeType","toLowerCase","GROOVY","PYTHON","PYTHON_COMPILED","SCALA","PLAIN_TEXT","UNKNOWN","getParent","parts","join","getPath","startsWith","isPath","endsWith","makePath","replaceExtension","newExtension","index","nameWithoutExtension","extensionString","validateName","reservedNames","invalidCharsRegex","invalidCharLabels","Map","includes","test","reduce","acc","next","map","char","has","get","reducePaths","paths","folders","filter","path","some","folder","removeRoot","root","filename","addRoot"],"sources":["../src/FileUtils.ts"],"sourcesContent":["import { ValidationError } from '@deephaven/utils';\n\n/**\n * A basic list of some common MIME types.\n */\nexport enum MIME_TYPE {\n GROOVY = 'text/x-groovy',\n PLAIN_TEXT = 'text/plain',\n PYTHON = 'text/x-python',\n PYTHON_COMPILED = 'application/x-python-code',\n SCALA = 'text/x-scala',\n UNKNOWN = '',\n}\n\n/**\n * Collection of utils for operating on file names\n */\nexport class FileUtils {\n /**\n * Format file extension\n * @param extension File extension to format, defaults to empty string\n * @returns Formatted string - '' for no extension, '.' for empty extension, '.ext' for non-empty extension\n */\n static fileExtensionToString(extension = ''): string {\n return extension.length === 0 ? '' : `.${extension}`;\n }\n\n /**\n * Get the depth (how many directories deep it is) of the provided filename with path.\n * @param name The full file name to get the depth of\n */\n static getDepth(name: string): number {\n if (!FileUtils.hasPath(name)) {\n throw new Error(`Invalid path provided: ${name}`);\n }\n const matches = name.match(/\\//g) ?? [];\n return matches.length - 1;\n }\n\n /**\n * Get just the extension of file name.\n * Note that it just returns the last extension, so 'example.tar.gz' would just return 'gz'.\n * @param name The file name with or without path to get the extension of\n * @returns The file extension\n */\n static getExtension(name: string): string {\n const components = this.getBaseName(name).split('.');\n if (components.length > 1) {\n return components.pop() ?? '';\n }\n return '';\n }\n\n /**\n * Get the base name portion of the file, eg '/foo/bar.txt' => 'bar.txt'\n * @param name The full name including path of the file\n * @returns Just the file name part of the file\n */\n static getBaseName(name: string): string {\n return name.split('/').pop() ?? '';\n }\n\n /**\n * Create copy file name, used for copying unsaved files so doesn't have to be unique\n * @param originalName File name\n * @returns The file name of the copy\n */\n static getCopyFileName(originalName: string): string {\n const extensionPosition = originalName.lastIndexOf('.');\n let extension = null;\n let name = null;\n if (extensionPosition < 0) {\n // No extension\n name = originalName;\n } else {\n name = originalName.substring(0, extensionPosition);\n extension = originalName.substring(extensionPosition + 1);\n }\n const copyName = name ? `${name}-copy` : 'Copy';\n return extension !== null ? `${copyName}.${extension}` : copyName;\n }\n\n /**\n * Return a MIME type for the provided file\n * @param name The file name to get the type for\n * @returns A known MIME type if recognized\n */\n static getMimeType(name: string): MIME_TYPE {\n const extension = this.getExtension(name).toLowerCase();\n switch (extension) {\n case 'groovy':\n return MIME_TYPE.GROOVY;\n case 'py':\n return MIME_TYPE.PYTHON;\n case 'pyc':\n return MIME_TYPE.PYTHON_COMPILED;\n case 'scala':\n return MIME_TYPE.SCALA;\n case 'txt':\n return MIME_TYPE.PLAIN_TEXT;\n default:\n return MIME_TYPE.UNKNOWN;\n }\n }\n\n /**\n * Pop the last part of the filename component to return the parent path\n * @param name The file name to get the parent path of\n */\n static getParent(name: string): string {\n if (!FileUtils.hasPath(name)) {\n throw new Error(`Invalid name provided: ${name}`);\n }\n\n const parts = name.split('/');\n while (parts.pop() === '');\n if (parts.length === 0) {\n throw new Error(`No parent for path provided: ${name}`);\n }\n return `${parts.join('/')}/`;\n }\n\n /**\n * Get the path name portion of the file\n * @param name The full path with or without filename to get the path of\n * @returns Just the path with out the file name part, including trailing slash\n */\n static getPath(name: string): string {\n if (!FileUtils.hasPath(name)) {\n throw new Error(`Invalid filename provided: ${name}`);\n }\n const parts = name.split('/');\n parts.pop();\n return `${parts.join('/')}/`;\n }\n\n /**\n * Check if a given file name includes the full path\n * @param name The file name to check\n * @returns True if it's a full path, false otherwise\n */\n static hasPath(name: string): boolean {\n return name.startsWith('/');\n }\n\n /**\n * Check a given file name is a path\n * @param name The file name to check\n * @returns True if it's a full path, false otherwise\n */\n static isPath(name: string): boolean {\n return name.startsWith('/') && name.endsWith('/');\n }\n\n /**\n * Turns a directory file name into a path. Basically ensures there's a trailing slash\n * @param name The directory name to make a path\n */\n static makePath(name: string): string {\n if (!name.endsWith('/')) {\n return `${name}/`;\n }\n return name;\n }\n\n /**\n * Replace extension in the item name\n * @param name Name to replace the extension in\n * @param newExtension New extension, defaults to no extension\n */\n static replaceExtension(name: string, newExtension = ''): string {\n const index = name.lastIndexOf('.');\n const nameWithoutExtension = index > -1 ? name.substring(0, index) : name;\n const extensionString = FileUtils.fileExtensionToString(newExtension);\n return `${nameWithoutExtension}${extensionString}`;\n }\n\n /**\n * Validate the provided name. Throws an error if validation fails\n * @param name The item name to validate\n */\n static validateName(name: string): void {\n // Static checks\n const reservedNames = ['.', '..'];\n // Global flag to show all invalid chars, not just the first match\n const invalidCharsRegex = /[\\\\/\\0]/g;\n const invalidCharLabels = new Map([['\\0', 'null']]);\n\n if (!name) {\n throw new ValidationError(`Name cannot be empty`);\n }\n if (reservedNames.includes(name)) {\n throw new ValidationError(`\"${name}\" is a reserved name`);\n }\n if (invalidCharsRegex.test(name)) {\n throw new ValidationError(\n `Invalid characters in name: \"${(name.match(invalidCharsRegex) ?? [])\n // Filter out duplicates\n .reduce(\n (acc, next) => (acc.includes(next) ? acc : [...acc, next]),\n [] as string[]\n )\n .map(char =>\n invalidCharLabels.has(char) ? invalidCharLabels.get(char) : char\n )\n .join('\", \"')}\"`\n );\n }\n }\n\n /**\n * Reduce the provided paths to the minimum selection.\n * Removes any nested files or directories if a parent is already selected.\n * @param paths The paths to reduce\n */\n static reducePaths(paths: string[]): string[] {\n const folders = paths.filter(path => FileUtils.isPath(path));\n return paths.filter(\n path =>\n !folders.some(folder => path !== folder && path.startsWith(folder))\n );\n }\n\n /**\n * Removes the root path from the provided file name. Throws if the filename does not start with root.\n * @param root The root to remove\n * @param filename Filename to remove the root path from\n * @returns Filename without the root\n */\n static removeRoot(root: string, filename: string): string {\n if (root.length === 0) {\n return filename;\n }\n if (!filename.startsWith(root)) {\n throw new Error(\n `Filename ${filename} does not start with expected root ${root}`\n );\n }\n\n return filename.substring(root.length);\n }\n\n /**\n * Add root to the filename as prefix\n * @param path Filename to prefix root to\n * @returns Filename with root at the prefix\n */\n static addRoot(root: string, path: string): string {\n return `${root}${path}`;\n }\n}\n\nexport default FileUtils;\n"],"mappings":"AAAA,SAASA,eAAT,QAAgC,kBAAhC;AAEA;AACA;AACA;;AACA,WAAYC,SAAZ;AASA;AACA;AACA;;WAXYA,S;EAAAA,S;EAAAA,S;EAAAA,S;EAAAA,S;EAAAA,S;EAAAA,S;GAAAA,S,KAAAA,S;;AAYZ,OAAO,MAAMC,SAAN,CAAgB;EACrB;AACF;AACA;AACA;AACA;EAC8B,OAArBC,qBAAqB,GAAyB;IAAA,IAAxBC,SAAwB,uEAAZ,EAAY;IACnD,OAAOA,SAAS,CAACC,MAAV,KAAqB,CAArB,GAAyB,EAAzB,cAAkCD,SAAlC,CAAP;EACD;EAED;AACF;AACA;AACA;;;EACiB,OAARE,QAAQ,CAACC,IAAD,EAAuB;IAAA;;IACpC,IAAI,CAACL,SAAS,CAACM,OAAV,CAAkBD,IAAlB,CAAL,EAA8B;MAC5B,MAAM,IAAIE,KAAJ,kCAAoCF,IAApC,EAAN;IACD;;IACD,IAAMG,OAAO,kBAAGH,IAAI,CAACI,KAAL,CAAW,KAAX,CAAH,qDAAwB,EAArC;IACA,OAAOD,OAAO,CAACL,MAAR,GAAiB,CAAxB;EACD;EAED;AACF;AACA;AACA;AACA;AACA;;;EACqB,OAAZO,YAAY,CAACL,IAAD,EAAuB;IACxC,IAAMM,UAAU,GAAG,KAAKC,WAAL,CAAiBP,IAAjB,EAAuBQ,KAAvB,CAA6B,GAA7B,CAAnB;;IACA,IAAIF,UAAU,CAACR,MAAX,GAAoB,CAAxB,EAA2B;MAAA;;MACzB,0BAAOQ,UAAU,CAACG,GAAX,EAAP,6DAA2B,EAA3B;IACD;;IACD,OAAO,EAAP;EACD;EAED;AACF;AACA;AACA;AACA;;;EACoB,OAAXF,WAAW,CAACP,IAAD,EAAuB;IAAA;;IACvC,0BAAOA,IAAI,CAACQ,KAAL,CAAW,GAAX,EAAgBC,GAAhB,EAAP,6DAA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,IAAtB,CAA9B,GAA4DA,IAPhC,EAS7BtB,IAT6B,CASxB,MATwB,CAD5B,QAAN;IAYD;EACF;EAED;AACF;AACA;AACA;AACA;;;EACoB,OAAXyB,WAAW,CAACC,KAAD,EAA4B;IAC5C,IAAMC,OAAO,GAAGD,KAAK,CAACE,MAAN,CAAaC,IAAI,IAAI5D,SAAS,CAACkC,MAAV,CAAiB0B,IAAjB,CAArB,CAAhB;IACA,OAAOH,KAAK,CAACE,MAAN,CACLC,IAAI,IACF,CAACF,OAAO,CAACG,IAAR,CAAaC,MAAM,IAAIF,IAAI,KAAKE,MAAT,IAAmBF,IAAI,CAAC3B,UAAL,CAAgB6B,MAAhB,CAA1C,CAFE,CAAP;EAID;EAED;AACF;AACA;AACA;AACA;AACA;;;EACmB,OAAVC,UAAU,CAACC,IAAD,EAAeC,QAAf,EAAyC;IACxD,IAAID,IAAI,CAAC7D,MAAL,KAAgB,CAApB,EAAuB;MACrB,OAAO8D,QAAP;IACD;;IACD,IAAI,CAACA,QAAQ,CAAChC,UAAT,CAAoB+B,IAApB,CAAL,EAAgC;MAC9B,MAAM,IAAIzD,KAAJ,oBACQ0D,QADR,gDACsDD,IADtD,EAAN;IAGD;;IAED,OAAOC,QAAQ,CAAC9C,SAAT,CAAmB6C,IAAI,CAAC7D,MAAxB,CAAP;EACD;EAED;AACF;AACA;AACA;AACA;;;EACgB,OAAP+D,OAAO,CAACF,IAAD,EAAeJ,IAAf,EAAqC;IACjD,iBAAUI,IAAV,SAAiBJ,IAAjB;EACD;;AAxOoB;AA2OvB,eAAe5D,SAAf"}
package/dist/index.d.ts CHANGED
@@ -3,10 +3,11 @@ export * from './FileExplorer';
3
3
  export * from './FileListContainer';
4
4
  export * from './FileList';
5
5
  export * from './FileStorage';
6
+ export { default as FileExistsError } from './FileExistsError';
7
+ export { default as FileNotFoundError } from './FileNotFoundError';
6
8
  export { default as SHORTCUTS } from './FileExplorerShortcuts';
7
9
  export { default as NewItemModal } from './NewItemModal';
8
10
  export { default as FileExplorerToolbar } from './FileExplorerToolbar';
9
11
  export { default as FileUtils } from './FileUtils';
10
- export { default as WebdavFileStorage } from './WebdavFileStorage';
11
12
  export default FileExplorer;
12
13
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,YAAY,MAAM,gBAAgB,CAAC;AAE1C,cAAc,gBAAgB,CAAC;AAC/B,cAAc,qBAAqB,CAAC;AACpC,cAAc,YAAY,CAAC;AAC3B,cAAc,eAAe,CAAC;AAC9B,OAAO,EAAE,OAAO,IAAI,SAAS,EAAE,MAAM,yBAAyB,CAAC;AAC/D,OAAO,EAAE,OAAO,IAAI,YAAY,EAAE,MAAM,gBAAgB,CAAC;AACzD,OAAO,EAAE,OAAO,IAAI,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AACvE,OAAO,EAAE,OAAO,IAAI,SAAS,EAAE,MAAM,aAAa,CAAC;AACnD,OAAO,EAAE,OAAO,IAAI,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAEnE,eAAe,YAAY,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,YAAY,MAAM,gBAAgB,CAAC;AAE1C,cAAc,gBAAgB,CAAC;AAC/B,cAAc,qBAAqB,CAAC;AACpC,cAAc,YAAY,CAAC;AAC3B,cAAc,eAAe,CAAC;AAC9B,OAAO,EAAE,OAAO,IAAI,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAC/D,OAAO,EAAE,OAAO,IAAI,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACnE,OAAO,EAAE,OAAO,IAAI,SAAS,EAAE,MAAM,yBAAyB,CAAC;AAC/D,OAAO,EAAE,OAAO,IAAI,YAAY,EAAE,MAAM,gBAAgB,CAAC;AACzD,OAAO,EAAE,OAAO,IAAI,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AACvE,OAAO,EAAE,OAAO,IAAI,SAAS,EAAE,MAAM,aAAa,CAAC;AAEnD,eAAe,YAAY,CAAC"}
package/dist/index.js CHANGED
@@ -3,10 +3,11 @@ export * from "./FileExplorer.js";
3
3
  export * from "./FileListContainer.js";
4
4
  export * from "./FileList.js";
5
5
  export * from "./FileStorage.js";
6
+ export { default as FileExistsError } from "./FileExistsError.js";
7
+ export { default as FileNotFoundError } from "./FileNotFoundError.js";
6
8
  export { default as SHORTCUTS } from "./FileExplorerShortcuts.js";
7
9
  export { default as NewItemModal } from "./NewItemModal.js";
8
10
  export { default as FileExplorerToolbar } from "./FileExplorerToolbar.js";
9
11
  export { default as FileUtils } from "./FileUtils.js";
10
- export { default as WebdavFileStorage } from "./WebdavFileStorage.js";
11
12
  export default FileExplorer;
12
13
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["FileExplorer","default","SHORTCUTS","NewItemModal","FileExplorerToolbar","FileUtils","WebdavFileStorage"],"sources":["../src/index.ts"],"sourcesContent":["import FileExplorer from './FileExplorer';\n\nexport * from './FileExplorer';\nexport * from './FileListContainer';\nexport * from './FileList';\nexport * from './FileStorage';\nexport { default as SHORTCUTS } from './FileExplorerShortcuts';\nexport { default as NewItemModal } from './NewItemModal';\nexport { default as FileExplorerToolbar } from './FileExplorerToolbar';\nexport { default as FileUtils } from './FileUtils';\nexport { default as WebdavFileStorage } from './WebdavFileStorage';\n\nexport default FileExplorer;\n"],"mappings":"OAAOA,Y;;;;;SAMEC,OAAO,IAAIC,S;SACXD,OAAO,IAAIE,Y;SACXF,OAAO,IAAIG,mB;SACXH,OAAO,IAAII,S;SACXJ,OAAO,IAAIK,iB;AAEpB,eAAeN,YAAf"}
1
+ {"version":3,"file":"index.js","names":["FileExplorer","default","FileExistsError","FileNotFoundError","SHORTCUTS","NewItemModal","FileExplorerToolbar","FileUtils"],"sources":["../src/index.ts"],"sourcesContent":["import FileExplorer from './FileExplorer';\n\nexport * from './FileExplorer';\nexport * from './FileListContainer';\nexport * from './FileList';\nexport * from './FileStorage';\nexport { default as FileExistsError } from './FileExistsError';\nexport { default as FileNotFoundError } from './FileNotFoundError';\nexport { default as SHORTCUTS } from './FileExplorerShortcuts';\nexport { default as NewItemModal } from './NewItemModal';\nexport { default as FileExplorerToolbar } from './FileExplorerToolbar';\nexport { default as FileUtils } from './FileUtils';\n\nexport default FileExplorer;\n"],"mappings":"OAAOA,Y;;;;;SAMEC,OAAO,IAAIC,e;SACXD,OAAO,IAAIE,iB;SACXF,OAAO,IAAIG,S;SACXH,OAAO,IAAII,Y;SACXJ,OAAO,IAAIK,mB;SACXL,OAAO,IAAIM,S;AAEpB,eAAeP,YAAf"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@deephaven/file-explorer",
3
- "version": "0.18.0",
3
+ "version": "0.18.1-grpc-file-storage.8+3bec154",
4
4
  "description": "Deephaven File Explorer React component",
5
5
  "author": "Deephaven Data Labs LLC",
6
6
  "license": "Apache-2.0",
@@ -30,23 +30,22 @@
30
30
  "start": "cross-env NODE_ENV=development npm run watch"
31
31
  },
32
32
  "dependencies": {
33
- "@deephaven/components": "^0.18.0",
34
- "@deephaven/icons": "^0.18.0",
35
- "@deephaven/log": "^0.18.0",
36
- "@deephaven/storage": "^0.18.0",
37
- "@deephaven/utils": "^0.18.0",
33
+ "@deephaven/components": "^0.18.1-grpc-file-storage.8+3bec154",
34
+ "@deephaven/icons": "^0.18.1-grpc-file-storage.8+3bec154",
35
+ "@deephaven/log": "^0.18.1-grpc-file-storage.8+3bec154",
36
+ "@deephaven/storage": "^0.18.1-grpc-file-storage.8+3bec154",
37
+ "@deephaven/utils": "^0.18.1-grpc-file-storage.8+3bec154",
38
38
  "@fortawesome/fontawesome-svg-core": "^6.1.1",
39
39
  "@fortawesome/react-fontawesome": "^0.1.18",
40
40
  "classnames": "^2.3.1",
41
41
  "lodash.throttle": "^4.1.1",
42
- "prop-types": "^15.7.2",
43
- "webdav": "^4.6.1"
42
+ "prop-types": "^15.7.2"
44
43
  },
45
44
  "peerDependencies": {
46
45
  "react": "^17.0.0"
47
46
  },
48
47
  "devDependencies": {
49
- "@deephaven/tsconfig": "^0.18.0"
48
+ "@deephaven/tsconfig": "^0.18.1-grpc-file-storage.8+3bec154"
50
49
  },
51
50
  "files": [
52
51
  "dist"
@@ -54,5 +53,5 @@
54
53
  "publishConfig": {
55
54
  "access": "public"
56
55
  },
57
- "gitHead": "3295265e760a8dc9133e5cc3e4cd857173ec7c29"
56
+ "gitHead": "3bec1545adc57b13cc3ce74dbcb6975e47ff14e6"
58
57
  }
@@ -1,18 +0,0 @@
1
- import { WebDAVClient } from 'webdav/web';
2
- import FileStorage, { File, FileStorageItem, FileStorageTable } from './FileStorage';
3
- export declare class WebdavFileStorage implements FileStorage {
4
- private static readonly REFRESH_THROTTLE;
5
- readonly client: WebDAVClient;
6
- private tables;
7
- constructor(client: WebDAVClient);
8
- createDirectory(path: string): Promise<FileStorageItem>;
9
- getTable(): Promise<FileStorageTable>;
10
- saveFile(file: File): Promise<File>;
11
- loadFile(name: string): Promise<File>;
12
- deleteFile(name: string): Promise<void>;
13
- moveFile(name: string, newName: string): Promise<void>;
14
- info(name: string): Promise<FileStorageItem>;
15
- private refreshTables;
16
- }
17
- export default WebdavFileStorage;
18
- //# sourceMappingURL=WebdavFileStorage.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"WebdavFileStorage.d.ts","sourceRoot":"","sources":["../src/WebdavFileStorage.ts"],"names":[],"mappings":"AAEA,OAAO,EAAY,YAAY,EAAE,MAAM,YAAY,CAAC;AAGpD,OAAO,WAAW,EAAE,EAClB,IAAI,EACJ,eAAe,EACf,gBAAgB,EACjB,MAAM,eAAe,CAAC;AAIvB,qBAAa,iBAAkB,YAAW,WAAW;IACnD,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,gBAAgB,CAAO;IAE/C,QAAQ,CAAC,MAAM,eAAC;IAEhB,OAAO,CAAC,MAAM,CAAkC;gBAEpC,MAAM,EAAE,YAAY;IAI1B,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,eAAe,CAAC;IAWvD,QAAQ,IAAI,OAAO,CAAC,gBAAgB,CAAC;IAMrC,QAAQ,CAAC,IAAI,EAAE,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC;IAYnC,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAWrC,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAKvC,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAKtD,IAAI,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,eAAe,CAAC;IAclD,OAAO,CAAC,aAAa,CAEkB;CACxC;AAED,eAAe,iBAAiB,CAAC"}
@@ -1,128 +0,0 @@
1
- function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
2
-
3
- function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
4
-
5
- function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
6
-
7
- /* eslint-disable class-methods-use-this */
8
- import throttle from 'lodash.throttle';
9
- import FileNotFoundError from "./FileNotFoundError.js";
10
- import FileUtils from "./FileUtils.js";
11
- import WebdavFileStorageTable from "./WebdavFileStorageTable.js";
12
- export class WebdavFileStorage {
13
- constructor(client) {
14
- _defineProperty(this, "client", void 0);
15
-
16
- _defineProperty(this, "tables", []);
17
-
18
- _defineProperty(this, "refreshTables", throttle(() => {
19
- this.tables.every(table => table.refresh().catch(() => undefined));
20
- }, WebdavFileStorage.REFRESH_THROTTLE));
21
-
22
- this.client = client;
23
- }
24
-
25
- createDirectory(path) {
26
- var _this = this;
27
-
28
- return _asyncToGenerator(function* () {
29
- yield _this.client.createDirectory(path);
30
-
31
- _this.refreshTables();
32
-
33
- return {
34
- type: 'directory',
35
- id: path,
36
- filename: path,
37
- basename: FileUtils.getBaseName(path)
38
- };
39
- })();
40
- }
41
-
42
- getTable() {
43
- var _this2 = this;
44
-
45
- return _asyncToGenerator(function* () {
46
- var table = new WebdavFileStorageTable(_this2.client);
47
-
48
- _this2.tables.push(table);
49
-
50
- return table;
51
- })();
52
- }
53
-
54
- saveFile(file) {
55
- var _this3 = this;
56
-
57
- return _asyncToGenerator(function* () {
58
- var success = yield _this3.client.putFileContents(file.filename, file.content);
59
-
60
- if (!success) {
61
- throw new Error('Unable to write file');
62
- }
63
-
64
- _this3.refreshTables();
65
-
66
- return file;
67
- })();
68
- }
69
-
70
- loadFile(name) {
71
- var _this4 = this;
72
-
73
- return _asyncToGenerator(function* () {
74
- var content = yield _this4.client.getFileContents(name, {
75
- format: 'text'
76
- });
77
- return {
78
- filename: name,
79
- basename: FileUtils.getBaseName(name),
80
- content
81
- };
82
- })();
83
- }
84
-
85
- deleteFile(name) {
86
- var _this5 = this;
87
-
88
- return _asyncToGenerator(function* () {
89
- yield _this5.client.deleteFile(name);
90
-
91
- _this5.refreshTables();
92
- })();
93
- }
94
-
95
- moveFile(name, newName) {
96
- var _this6 = this;
97
-
98
- return _asyncToGenerator(function* () {
99
- yield _this6.client.moveFile(name, newName);
100
-
101
- _this6.refreshTables();
102
- })();
103
- }
104
-
105
- info(name) {
106
- var _this7 = this;
107
-
108
- return _asyncToGenerator(function* () {
109
- try {
110
- var stat = yield _this7.client.stat(name);
111
- return {
112
- filename: stat.filename,
113
- basename: stat.basename,
114
- id: stat.filename,
115
- type: stat.type
116
- };
117
- } catch (e) {
118
- throw new FileNotFoundError();
119
- }
120
- })();
121
- }
122
-
123
- }
124
-
125
- _defineProperty(WebdavFileStorage, "REFRESH_THROTTLE", 150);
126
-
127
- export default WebdavFileStorage;
128
- //# sourceMappingURL=WebdavFileStorage.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"WebdavFileStorage.js","names":["throttle","FileNotFoundError","FileUtils","WebdavFileStorageTable","WebdavFileStorage","constructor","client","tables","every","table","refresh","catch","undefined","REFRESH_THROTTLE","createDirectory","path","refreshTables","type","id","filename","basename","getBaseName","getTable","push","saveFile","file","success","putFileContents","content","Error","loadFile","name","getFileContents","format","deleteFile","moveFile","newName","info","stat","e"],"sources":["../src/WebdavFileStorage.ts"],"sourcesContent":["/* eslint-disable class-methods-use-this */\n\nimport { FileStat, WebDAVClient } from 'webdav/web';\nimport throttle from 'lodash.throttle';\nimport FileNotFoundError from './FileNotFoundError';\nimport FileStorage, {\n File,\n FileStorageItem,\n FileStorageTable,\n} from './FileStorage';\nimport FileUtils from './FileUtils';\nimport WebdavFileStorageTable from './WebdavFileStorageTable';\n\nexport class WebdavFileStorage implements FileStorage {\n private static readonly REFRESH_THROTTLE = 150;\n\n readonly client;\n\n private tables = [] as WebdavFileStorageTable[];\n\n constructor(client: WebDAVClient) {\n this.client = client;\n }\n\n async createDirectory(path: string): Promise<FileStorageItem> {\n await this.client.createDirectory(path);\n this.refreshTables();\n return {\n type: 'directory',\n id: path,\n filename: path,\n basename: FileUtils.getBaseName(path),\n };\n }\n\n async getTable(): Promise<FileStorageTable> {\n const table = new WebdavFileStorageTable(this.client);\n this.tables.push(table);\n return table;\n }\n\n async saveFile(file: File): Promise<File> {\n const success = await this.client.putFileContents(\n file.filename,\n file.content\n );\n if (!success) {\n throw new Error('Unable to write file');\n }\n this.refreshTables();\n return file;\n }\n\n async loadFile(name: string): Promise<File> {\n const content = (await this.client.getFileContents(name, {\n format: 'text',\n })) as string;\n return {\n filename: name,\n basename: FileUtils.getBaseName(name),\n content,\n };\n }\n\n async deleteFile(name: string): Promise<void> {\n await this.client.deleteFile(name);\n this.refreshTables();\n }\n\n async moveFile(name: string, newName: string): Promise<void> {\n await this.client.moveFile(name, newName);\n this.refreshTables();\n }\n\n async info(name: string): Promise<FileStorageItem> {\n try {\n const stat = (await this.client.stat(name)) as FileStat;\n return {\n filename: stat.filename,\n basename: stat.basename,\n id: stat.filename,\n type: stat.type,\n };\n } catch (e) {\n throw new FileNotFoundError();\n }\n }\n\n private refreshTables = throttle(() => {\n this.tables.every(table => table.refresh().catch(() => undefined));\n }, WebdavFileStorage.REFRESH_THROTTLE);\n}\n\nexport default WebdavFileStorage;\n"],"mappings":";;;;;;AAAA;AAGA,OAAOA,QAAP,MAAqB,iBAArB;OACOC,iB;OAMAC,S;OACAC,sB;AAEP,OAAO,MAAMC,iBAAN,CAA+C;EAOpDC,WAAW,CAACC,MAAD,EAAuB;IAAA;;IAAA,gCAFjB,EAEiB;;IAAA,uCAoEVN,QAAQ,CAAC,MAAM;MACrC,KAAKO,MAAL,CAAYC,KAAZ,CAAkBC,KAAK,IAAIA,KAAK,CAACC,OAAN,GAAgBC,KAAhB,CAAsB,MAAMC,SAA5B,CAA3B;IACD,CAF+B,EAE7BR,iBAAiB,CAACS,gBAFW,CApEE;;IAChC,KAAKP,MAAL,GAAcA,MAAd;EACD;;EAEKQ,eAAe,CAACC,IAAD,EAAyC;IAAA;;IAAA;MAC5D,MAAM,KAAI,CAACT,MAAL,CAAYQ,eAAZ,CAA4BC,IAA5B,CAAN;;MACA,KAAI,CAACC,aAAL;;MACA,OAAO;QACLC,IAAI,EAAE,WADD;QAELC,EAAE,EAAEH,IAFC;QAGLI,QAAQ,EAAEJ,IAHL;QAILK,QAAQ,EAAElB,SAAS,CAACmB,WAAV,CAAsBN,IAAtB;MAJL,CAAP;IAH4D;EAS7D;;EAEKO,Q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AAI,CAAChC,MAAL,CAAYgC,IAAZ,CAAiBP,IAAjB,CAApB;QACA,OAAO;UACLZ,QAAQ,EAAEmB,IAAI,CAACnB,QADV;UAELC,QAAQ,EAAEkB,IAAI,CAAClB,QAFV;UAGLF,EAAE,EAAEoB,IAAI,CAACnB,QAHJ;UAILF,IAAI,EAAEqB,IAAI,CAACrB;QAJN,CAAP;MAMD,CARD,CAQE,OAAOsB,CAAP,EAAU;QACV,MAAM,IAAItC,iBAAJ,EAAN;MACD;IAXgD;EAYlD;;AAzEmD;;gBAAzCG,iB,sBACgC,G;;AA+E7C,eAAeA,iBAAf"}
@@ -1,47 +0,0 @@
1
- import { WebDAVClient } from 'webdav/web';
2
- import { StorageTableViewport, StorageListenerRemover, ViewportUpdateCallback, ViewportData, IndexRange, StorageSnapshot } from '@deephaven/storage';
3
- import { FileStorageTable, FileStorageItem } from './FileStorage';
4
- /**
5
- * Implementation of FileStorageTable for WebDAV.
6
- * Takes a path to specify what root this table should start at.
7
- */
8
- export declare class WebdavFileStorageTable implements FileStorageTable {
9
- readonly client: WebDAVClient;
10
- readonly root: string;
11
- private currentSize;
12
- private currentViewport?;
13
- private listeners;
14
- private viewportUpdatePromise?;
15
- private currentViewportData?;
16
- /**
17
- * Map of expanded directory paths to the tables that manage that path.
18
- * We use a tree of tables to query the server so we just get the directories that are expanded.
19
- * Also the nginx module we are using does not support a depth of infinity: https://github.com/arut/nginx-dav-ext-module/blob/f5e30888a256136d9c550bf1ada77d6ea78a48af/ngx_http_dav_ext_module.c#L757
20
- */
21
- private childTables;
22
- /**
23
- * @param client The WebDAV client instance to use
24
- * @param root The root path for this storage table
25
- */
26
- constructor(client: WebDAVClient, root?: string);
27
- getViewportData(): Promise<ViewportData<FileStorageItem>>;
28
- getSnapshot(sortedRanges: IndexRange[]): Promise<StorageSnapshot<FileStorageItem>>;
29
- get size(): number;
30
- setExpanded(path: string, expanded: boolean): Promise<void>;
31
- setSearch(search: string): void;
32
- setViewport(viewport: StorageTableViewport): void;
33
- setFilters(): void;
34
- setSorts(): void;
35
- setReversed(): void;
36
- close(): void;
37
- onUpdate(callback: ViewportUpdateCallback<FileStorageItem>): StorageListenerRemover;
38
- refresh(): Promise<ViewportData<FileStorageItem>>;
39
- /**
40
- * Refreshes data, but catches any errors and logs them
41
- */
42
- private refreshInternal;
43
- private fetchData;
44
- private sendUpdate;
45
- }
46
- export default WebdavFileStorageTable;
47
- //# sourceMappingURL=WebdavFileStorageTable.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"WebdavFileStorageTable.d.ts","sourceRoot":"","sources":["../src/WebdavFileStorageTable.ts"],"names":[],"mappings":"AAAA,OAAO,EAAY,YAAY,EAAE,MAAM,YAAY,CAAC;AAEpD,OAAO,EACL,oBAAoB,EACpB,sBAAsB,EACtB,sBAAsB,EACtB,YAAY,EACZ,UAAU,EACV,eAAe,EAChB,MAAM,oBAAoB,CAAC;AAE5B,OAAO,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAIlE;;;GAGG;AACH,qBAAa,sBAAuB,YAAW,gBAAgB;IAC7D,QAAQ,CAAC,MAAM,EAAE,YAAY,CAAC;IAE9B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAEtB,OAAO,CAAC,WAAW,CAAK;IAExB,OAAO,CAAC,eAAe,CAAC,CAAuB;IAE/C,OAAO,CAAC,SAAS,CAAiD;IAElE,OAAO,CAAC,qBAAqB,CAAC,CAE5B;IAEF,OAAO,CAAC,mBAAmB,CAAC,CAAgC;IAE5D;;;;OAIG;IACH,OAAO,CAAC,WAAW,CAAkD;IAErE;;;OAGG;gBACS,MAAM,EAAE,YAAY,EAAE,IAAI,SAAM;IAK5C,eAAe,IAAI,OAAO,CAAC,YAAY,CAAC,eAAe,CAAC,CAAC;IAUzD,WAAW,CACT,YAAY,EAAE,UAAU,EAAE,GACzB,OAAO,CAAC,eAAe,CAAC,eAAe,CAAC,CAAC;IAI5C,IAAI,IAAI,IAAI,MAAM,CAEjB;IAEK,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC;IAoCjE,SAAS,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI;IAI/B,WAAW,CAAC,QAAQ,EAAE,oBAAoB,GAAG,IAAI;IAOjD,UAAU,IAAI,IAAI;IAKlB,QAAQ,IAAI,IAAI;IAKhB,WAAW,IAAI,IAAI;IAInB,KAAK,IAAI,IAAI;IAIb,QAAQ,CACN,QAAQ,EAAE,sBAAsB,CAAC,eAAe,CAAC,GAChD,sBAAsB;IAOnB,OAAO,IAAI,OAAO,CAAC,YAAY,CAAC,eAAe,CAAC,CAAC;IAgBvD;;OAEG;YACW,eAAe;YAUf,SAAS;IAmDvB,OAAO,CAAC,UAAU;CAQnB;AAED,eAAe,sBAAsB,CAAC"}
@@ -1,268 +0,0 @@
1
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
2
-
3
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
4
-
5
- function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
6
-
7
- function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
8
-
9
- function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
10
-
11
- import Log from '@deephaven/log';
12
- import { PromiseUtils } from '@deephaven/utils';
13
- var log = Log.module('WebdavFileStorageTable');
14
- /**
15
- * Implementation of FileStorageTable for WebDAV.
16
- * Takes a path to specify what root this table should start at.
17
- */
18
-
19
- export class WebdavFileStorageTable {
20
- /**
21
- * Map of expanded directory paths to the tables that manage that path.
22
- * We use a tree of tables to query the server so we just get the directories that are expanded.
23
- * Also the nginx module we are using does not support a depth of infinity: https://github.com/arut/nginx-dav-ext-module/blob/f5e30888a256136d9c550bf1ada77d6ea78a48af/ngx_http_dav_ext_module.c#L757
24
- */
25
-
26
- /**
27
- * @param client The WebDAV client instance to use
28
- * @param root The root path for this storage table
29
- */
30
- constructor(client) {
31
- var root = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '/';
32
-
33
- _defineProperty(this, "client", void 0);
34
-
35
- _defineProperty(this, "root", void 0);
36
-
37
- _defineProperty(this, "currentSize", 0);
38
-
39
- _defineProperty(this, "currentViewport", void 0);
40
-
41
- _defineProperty(this, "listeners", []);
42
-
43
- _defineProperty(this, "viewportUpdatePromise", void 0);
44
-
45
- _defineProperty(this, "currentViewportData", void 0);
46
-
47
- _defineProperty(this, "childTables", new Map());
48
-
49
- this.client = client;
50
- this.root = root;
51
- }
52
-
53
- getViewportData() {
54
- var _this$viewportUpdateP;
55
-
56
- if (!this.viewportUpdatePromise) {
57
- this.refreshInternal();
58
- }
59
-
60
- return (_this$viewportUpdateP = this.viewportUpdatePromise) !== null && _this$viewportUpdateP !== void 0 ? _this$viewportUpdateP : Promise.resolve({
61
- items: [],
62
- offset: 0
63
- });
64
- } // eslint-disable-next-line class-methods-use-this
65
-
66
-
67
- getSnapshot(sortedRanges) {
68
- throw new Error('Method not implemented.');
69
- }
70
-
71
- get size() {
72
- return this.currentSize;
73
- }
74
-
75
- setExpanded(path, expanded) {
76
- var _this = this;
77
-
78
- return _asyncToGenerator(function* () {
79
- var paths = path.split('/');
80
- var nextPath = paths.shift();
81
-
82
- if (!nextPath) {
83
- nextPath = paths.shift();
84
- }
85
-
86
- if (!nextPath) {
87
- throw new Error("Invalid path: ".concat(path));
88
- }
89
-
90
- var remainingPath = paths.join('/');
91
-
92
- if (expanded) {
93
- if (!_this.childTables.has(nextPath)) {
94
- var childTable = new WebdavFileStorageTable(_this.client, "".concat(_this.root).concat(nextPath, "/"));
95
-
96
- _this.childTables.set(nextPath, childTable);
97
- }
98
-
99
- if (remainingPath) {
100
- var _childTable = _this.childTables.get(nextPath);
101
-
102
- _childTable === null || _childTable === void 0 ? void 0 : _childTable.setExpanded(remainingPath, expanded);
103
- }
104
- } else if (_this.childTables.has(nextPath)) {
105
- if (remainingPath) {
106
- var _childTable2 = _this.childTables.get(nextPath);
107
-
108
- _childTable2 === null || _childTable2 === void 0 ? void 0 : _childTable2.setExpanded(remainingPath, expanded);
109
- } else {
110
- _this.childTables.delete(nextPath);
111
- }
112
- }
113
-
114
- if (_this.currentViewport) {
115
- yield _this.refreshInternal();
116
- }
117
- })();
118
- } // eslint-disable-next-line class-methods-use-this
119
-
120
-
121
- setSearch(search) {
122
- throw new Error('Method not implemented.');
123
- }
124
-
125
- setViewport(viewport) {
126
- this.currentViewport = viewport;
127
- this.refreshInternal();
128
- } // eslint-disable-next-line class-methods-use-this
129
-
130
-
131
- setFilters() {
132
- throw new Error('Method not implemented.');
133
- } // eslint-disable-next-line class-methods-use-this
134
-
135
-
136
- setSorts() {
137
- throw new Error('Method not implemented.');
138
- } // eslint-disable-next-line class-methods-use-this
139
-
140
-
141
- setReversed() {
142
- throw new Error('Method not implemented.');
143
- }
144
-
145
- close() {
146
- this.listeners = [];
147
- }
148
-
149
- onUpdate(callback) {
150
- this.listeners = [...this.listeners, callback];
151
- return () => {
152
- this.listeners = this.listeners.filter(other => other !== callback);
153
- };
154
- }
155
-
156
- refresh() {
157
- var _this2 = this;
158
-
159
- return _asyncToGenerator(function* () {
160
- var _this2$viewportUpdate;
161
-
162
- log.debug2(_this2.root, 'refreshData');
163
- (_this2$viewportUpdate = _this2.viewportUpdatePromise) === null || _this2$viewportUpdate === void 0 ? void 0 : _this2$viewportUpdate.cancel();
164
- _this2.viewportUpdatePromise = PromiseUtils.makeCancelable(_this2.fetchData());
165
- var viewportData = yield _this2.viewportUpdatePromise;
166
- _this2.currentViewportData = viewportData;
167
-
168
- _this2.sendUpdate();
169
-
170
- return viewportData;
171
- })();
172
- }
173
- /**
174
- * Refreshes data, but catches any errors and logs them
175
- */
176
-
177
-
178
- refreshInternal() {
179
- var _this3 = this;
180
-
181
- return _asyncToGenerator(function* () {
182
- try {
183
- yield _this3.refresh();
184
- } catch (e) {
185
- if (!PromiseUtils.isCanceled(e)) {
186
- log.error('Unable to refresh data', e);
187
- }
188
- }
189
- })();
190
- }
191
-
192
- fetchData() {
193
- var _this4 = this;
194
-
195
- return _asyncToGenerator(function* () {
196
- var {
197
- currentViewport: viewport
198
- } = _this4;
199
-
200
- if (!viewport) {
201
- throw new Error('No viewport set');
202
- } // First get the root directory contents
203
-
204
-
205
- var items = yield _this4.client.getDirectoryContents(_this4.root).then(dirContents => dirContents.map(file => _objectSpread(_objectSpread({}, file), {}, {
206
- id: file.filename,
207
- isExpanded: file.type === 'directory' ? _this4.childTables.has(file.basename) : undefined
208
- })).sort((a, b) => {
209
- if (a.type !== b.type) {
210
- return a.type === 'directory' ? -1 : 1;
211
- }
212
-
213
- return a.basename.localeCompare(b.basename);
214
- })); // Get the data from all expanded directories
215
-
216
- for (var i = 0; i < items.length; i += 1) {
217
- var item = items[i];
218
- var {
219
- basename,
220
- filename
221
- } = item;
222
-
223
- if (filename === "".concat(_this4.root).concat(basename) && item.type === 'directory') {
224
- var childTable = _this4.childTables.get(basename);
225
-
226
- if (childTable != null) {
227
- childTable.setViewport({
228
- top: 0,
229
- bottom: viewport.bottom - i
230
- }); // eslint-disable-next-line no-await-in-loop
231
-
232
- var childViewportData = yield childTable.getViewportData();
233
- items.splice(i + 1, 0, ...childViewportData.items);
234
- }
235
- }
236
- }
237
-
238
- _this4.currentSize = items.length;
239
- log.debug2(_this4.root, 'items', items, viewport); // Slice it to the correct viewport
240
-
241
- items = items.slice(viewport.top, viewport.bottom);
242
- return {
243
- items,
244
- offset: viewport.top
245
- };
246
- })();
247
- }
248
-
249
- sendUpdate() {
250
- var _this$currentViewport;
251
-
252
- // Retain a reference to it in case a listener gets removed while sending an update
253
- var {
254
- listeners
255
- } = this;
256
- var data = (_this$currentViewport = this.currentViewportData) !== null && _this$currentViewport !== void 0 ? _this$currentViewport : {
257
- items: [],
258
- offset: 0
259
- };
260
-
261
- for (var i = 0; i < listeners.length; i += 1) {
262
- listeners[i](data);
263
- }
264
- }
265
-
266
- }
267
- export default WebdavFileStorageTable;
268
- //# sourceMappingURL=WebdavFileStorageTable.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"WebdavFileStorageTable.js","names":["Log","PromiseUtils","log","module","WebdavFileStorageTable","constructor","client","root","Map","getViewportData","viewportUpdatePromise","refreshInternal","Promise","resolve","items","offset","getSnapshot","sortedRanges","Error","size","currentSize","setExpanded","path","expanded","paths","split","nextPath","shift","remainingPath","join","childTables","has","childTable","set","get","delete","currentViewport","setSearch","search","setViewport","viewport","setFilters","setSorts","setReversed","close","listeners","onUpdate","callback","filter","other","refresh","debug2","cancel","makeCancelable","fetchData","viewportData","currentViewportData","sendUpdate","e","isCanceled","error","getDirectoryContents","then","dirContents","map","file","id","filename","isExpanded","type","basename","undefined","sort","a","b","localeCompare","i","length","item","top","bottom","childViewportData","splice","slice","data"],"sources":["../src/WebdavFileStorageTable.ts"],"sourcesContent":["import { FileStat, WebDAVClient } from 'webdav/web';\nimport Log from '@deephaven/log';\nimport {\n StorageTableViewport,\n StorageListenerRemover,\n ViewportUpdateCallback,\n ViewportData,\n IndexRange,\n StorageSnapshot,\n} from '@deephaven/storage';\nimport { CancelablePromise, PromiseUtils } from '@deephaven/utils';\nimport { FileStorageTable, FileStorageItem } from './FileStorage';\n\nconst log = Log.module('WebdavFileStorageTable');\n\n/**\n * Implementation of FileStorageTable for WebDAV.\n * Takes a path to specify what root this table should start at.\n */\nexport class WebdavFileStorageTable implements FileStorageTable {\n readonly client: WebDAVClient;\n\n readonly root: string;\n\n private currentSize = 0;\n\n private currentViewport?: StorageTableViewport;\n\n private listeners: ViewportUpdateCallback<FileStorageItem>[] = [];\n\n private viewportUpdatePromise?: CancelablePromise<\n ViewportData<FileStorageItem>\n >;\n\n private currentViewportData?: ViewportData<FileStorageItem>;\n\n /**\n * Map of expanded directory paths to the tables that manage that path.\n * We use a tree of tables to query the server so we just get the directories that are expanded.\n * Also the nginx module we are using does not support a depth of infinity: https://github.com/arut/nginx-dav-ext-module/blob/f5e30888a256136d9c550bf1ada77d6ea78a48af/ngx_http_dav_ext_module.c#L757\n */\n private childTables: Map<string, WebdavFileStorageTable> = new Map();\n\n /**\n * @param client The WebDAV client instance to use\n * @param root The root path for this storage table\n */\n constructor(client: WebDAVClient, root = '/') {\n this.client = client;\n this.root = root;\n }\n\n getViewportData(): Promise<ViewportData<FileStorageItem>> {\n if (!this.viewportUpdatePromise) {\n this.refreshInternal();\n }\n return (\n this.viewportUpdatePromise ?? Promise.resolve({ items: [], offset: 0 })\n );\n }\n\n // eslint-disable-next-line class-methods-use-this\n getSnapshot(\n sortedRanges: IndexRange[]\n ): Promise<StorageSnapshot<FileStorageItem>> {\n throw new Error('Method not implemented.');\n }\n\n get size(): number {\n return this.currentSize;\n }\n\n async setExpanded(path: string, expanded: boolean): Promise<void> {\n const paths = path.split('/');\n let nextPath = paths.shift();\n if (!nextPath) {\n nextPath = paths.shift();\n }\n if (!nextPath) {\n throw new Error(`Invalid path: ${path}`);\n }\n const remainingPath = paths.join('/');\n if (expanded) {\n if (!this.childTables.has(nextPath)) {\n const childTable = new WebdavFileStorageTable(\n this.client,\n `${this.root}${nextPath}/`\n );\n this.childTables.set(nextPath, childTable);\n }\n if (remainingPath) {\n const childTable = this.childTables.get(nextPath);\n childTable?.setExpanded(remainingPath, expanded);\n }\n } else if (this.childTables.has(nextPath)) {\n if (remainingPath) {\n const childTable = this.childTables.get(nextPath);\n childTable?.setExpanded(remainingPath, expanded);\n } else {\n this.childTables.delete(nextPath);\n }\n }\n if (this.currentViewport) {\n await this.refreshInternal();\n }\n }\n\n // eslint-disable-next-line class-methods-use-this\n setSearch(search: string): void {\n throw new Error('Method not implemented.');\n }\n\n setViewport(viewport: StorageTableViewport): void {\n this.currentViewport = viewport;\n\n this.refreshInternal();\n }\n\n // eslint-disable-next-line class-methods-use-this\n setFilters(): void {\n throw new Error('Method not implemented.');\n }\n\n // eslint-disable-next-line class-methods-use-this\n setSorts(): void {\n throw new Error('Method not implemented.');\n }\n\n // eslint-disable-next-line class-methods-use-this\n setReversed(): void {\n throw new Error('Method not implemented.');\n }\n\n close(): void {\n this.listeners = [];\n }\n\n onUpdate(\n callback: ViewportUpdateCallback<FileStorageItem>\n ): StorageListenerRemover {\n this.listeners = [...this.listeners, callback];\n return () => {\n this.listeners = this.listeners.filter(other => other !== callback);\n };\n }\n\n async refresh(): Promise<ViewportData<FileStorageItem>> {\n log.debug2(this.root, 'refreshData');\n\n this.viewportUpdatePromise?.cancel();\n\n this.viewportUpdatePromise = PromiseUtils.makeCancelable(this.fetchData());\n\n const viewportData = await this.viewportUpdatePromise;\n\n this.currentViewportData = viewportData;\n\n this.sendUpdate();\n\n return viewportData;\n }\n\n /**\n * Refreshes data, but catches any errors and logs them\n */\n private async refreshInternal(): Promise<void> {\n try {\n await this.refresh();\n } catch (e) {\n if (!PromiseUtils.isCanceled(e)) {\n log.error('Unable to refresh data', e);\n }\n }\n }\n\n private async fetchData(): Promise<ViewportData<FileStorageItem>> {\n const { currentViewport: viewport } = this;\n if (!viewport) {\n throw new Error('No viewport set');\n }\n\n // First get the root directory contents\n let items = await this.client.getDirectoryContents(this.root).then(\n dirContents =>\n (dirContents as FileStat[])\n .map(file => ({\n ...file,\n id: file.filename,\n isExpanded:\n file.type === 'directory'\n ? this.childTables.has(file.basename)\n : undefined,\n }))\n .sort((a, b) => {\n if (a.type !== b.type) {\n return a.type === 'directory' ? -1 : 1;\n }\n return a.basename.localeCompare(b.basename);\n }) as FileStorageItem[]\n );\n\n // Get the data from all expanded directories\n for (let i = 0; i < items.length; i += 1) {\n const item = items[i];\n const { basename, filename } = item;\n if (filename === `${this.root}${basename}` && item.type === 'directory') {\n const childTable = this.childTables.get(basename);\n if (childTable != null) {\n childTable.setViewport({ top: 0, bottom: viewport.bottom - i });\n // eslint-disable-next-line no-await-in-loop\n const childViewportData = await childTable.getViewportData();\n items.splice(i + 1, 0, ...childViewportData.items);\n }\n }\n }\n\n this.currentSize = items.length;\n\n log.debug2(this.root, 'items', items, viewport);\n\n // Slice it to the correct viewport\n items = items.slice(viewport.top, viewport.bottom);\n\n return { items, offset: viewport.top };\n }\n\n private sendUpdate() {\n // Retain a reference to it in case a listener gets removed while sending an update\n const { listeners } = this;\n const data = this.currentViewportData ?? { items: [], offset: 0 };\n for (let i = 0; i < listeners.length; i += 1) {\n listeners[i](data);\n }\n }\n}\n\nexport default WebdavFileStorageTable;\n"],"mappings":";;;;;;;;;;AACA,OAAOA,GAAP,MAAgB,gBAAhB;AASA,SAA4BC,YAA5B,QAAgD,kBAAhD;AAGA,IAAMC,GAAG,GAAGF,GAAG,CAACG,MAAJ,CAAW,wBAAX,CAAZ;AAEA;AACA;AACA;AACA;;AACA,OAAO,MAAMC,sBAAN,CAAyD;EAiB9D;AACF;AACA;AACA;AACA;;EAGE;AACF;AACA;AACA;EACEC,WAAW,CAACC,MAAD,EAAmC;IAAA,IAAZC,IAAY,uEAAL,GAAK;;IAAA;;IAAA;;IAAA,qCAvBxB,CAuBw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