devextreme
Version:
HTML5 JavaScript Component Suite for Responsive Web Development
115 lines (113 loc) • 6.13 kB
JavaScript
/**
* DevExtreme (cjs/__internal/file_management/custom_provider.js)
* Version: 25.2.3
* Build date: Fri Dec 12 2025
*
* Copyright (c) 2012 - 2025 Developer Express Inc. ALL RIGHTS RESERVED
* Read about DevExtreme licensing here: https://js.devexpress.com/Licensing/
*/
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _common = require("../../core/utils/common");
var _data = require("../../core/utils/data");
var _type = require("../../core/utils/type");
var _provider_base = _interopRequireDefault(require("../file_management/provider_base"));
function _interopRequireDefault(e) {
return e && e.__esModule ? e : {
default: e
}
}
class CustomFileSystemProvider extends _provider_base.default {
constructor(options) {
options = (0, _common.ensureDefined)(options, {});
super(options);
this._hasSubDirsGetter = (0, _data.compileGetter)(options.hasSubDirectoriesExpr ?? "hasSubDirectories");
this._getItemsFunction = this._ensureFunction(options.getItems, (() => []));
this._renameItemFunction = this._ensureFunction(options.renameItem);
this._createDirectoryFunction = this._ensureFunction(options.createDirectory);
this._deleteItemFunction = this._ensureFunction(options.deleteItem);
this._moveItemFunction = this._ensureFunction(options.moveItem);
this._copyItemFunction = this._ensureFunction(options.copyItem);
this._uploadFileChunkFunction = this._ensureFunction(options.uploadFileChunk);
this._abortFileUploadFunction = this._ensureFunction(options.abortFileUpload);
this._downloadItemsFunction = this._ensureFunction(options.downloadItems);
this._getItemsContentFunction = this._ensureFunction(options.getItemsContent)
}
getItems(parentDirectory) {
const pathInfo = parentDirectory.getFullPathInfo();
return this._executeActionAsDeferred((() => {
var _this$_getItemsFuncti;
return null === (_this$_getItemsFuncti = this._getItemsFunction) || void 0 === _this$_getItemsFuncti ? void 0 : _this$_getItemsFuncti.call(this, parentDirectory)
}), true).then((dataItems => this._convertDataObjectsToFileItems(dataItems, pathInfo)))
}
renameItem(item, name) {
return this._executeActionAsDeferred((() => {
var _this$_renameItemFunc;
return null === (_this$_renameItemFunc = this._renameItemFunction) || void 0 === _this$_renameItemFunc ? void 0 : _this$_renameItemFunc.call(this, item, name)
}))
}
createDirectory(parentDirectory, name) {
return this._executeActionAsDeferred((() => {
var _this$_createDirector;
return null === (_this$_createDirector = this._createDirectoryFunction) || void 0 === _this$_createDirector ? void 0 : _this$_createDirector.call(this, parentDirectory, name)
}))
}
deleteItems(items) {
return items.map((item => this._executeActionAsDeferred((() => {
var _this$_deleteItemFunc;
return null === (_this$_deleteItemFunc = this._deleteItemFunction) || void 0 === _this$_deleteItemFunc ? void 0 : _this$_deleteItemFunc.call(this, item)
}))))
}
moveItems(items, destinationDirectory) {
return items.map((item => this._executeActionAsDeferred((() => {
var _this$_moveItemFuncti;
return null === (_this$_moveItemFuncti = this._moveItemFunction) || void 0 === _this$_moveItemFuncti ? void 0 : _this$_moveItemFuncti.call(this, item, destinationDirectory)
}))))
}
copyItems(items, destinationFolder) {
return items.map((item => this._executeActionAsDeferred((() => {
var _this$_copyItemFuncti;
return null === (_this$_copyItemFuncti = this._copyItemFunction) || void 0 === _this$_copyItemFuncti ? void 0 : _this$_copyItemFuncti.call(this, item, destinationFolder)
}))))
}
uploadFileChunk(fileData, chunksInfo, destinationDirectory) {
return this._executeActionAsDeferred((() => {
var _this$_uploadFileChun;
return null === (_this$_uploadFileChun = this._uploadFileChunkFunction) || void 0 === _this$_uploadFileChun ? void 0 : _this$_uploadFileChun.call(this, fileData, chunksInfo, destinationDirectory)
}))
}
abortFileUpload(fileData, chunksInfo, destinationDirectory) {
return this._executeActionAsDeferred((() => {
var _this$_abortFileUploa;
return null === (_this$_abortFileUploa = this._abortFileUploadFunction) || void 0 === _this$_abortFileUploa ? void 0 : _this$_abortFileUploa.call(this, fileData, chunksInfo, destinationDirectory)
}))
}
downloadItems(items) {
return this._executeActionAsDeferred((() => {
var _this$_downloadItemsF;
return null === (_this$_downloadItemsF = this._downloadItemsFunction) || void 0 === _this$_downloadItemsF ? void 0 : _this$_downloadItemsF.call(this, items)
}))
}
getItemsContent(items) {
return this._executeActionAsDeferred((() => {
var _this$_getItemsConten;
return null === (_this$_getItemsConten = this._getItemsContentFunction) || void 0 === _this$_getItemsConten ? void 0 : _this$_getItemsConten.call(this, items)
}))
}
_hasSubDirs(dataObj) {
var _this$_hasSubDirsGett;
const hasSubDirs = null === (_this$_hasSubDirsGett = this._hasSubDirsGetter) || void 0 === _this$_hasSubDirsGett ? void 0 : _this$_hasSubDirsGett.call(this, dataObj);
return "boolean" === typeof hasSubDirs ? hasSubDirs : true
}
_getKeyExpr(options) {
return options.keyExpr ?? "key"
}
_ensureFunction(functionObject, defaultFunction) {
defaultFunction = defaultFunction ?? _common.noop;
return (0, _type.isFunction)(functionObject) ? functionObject : defaultFunction
}
}
var _default = exports.default = CustomFileSystemProvider;