@rainbow-oh/yee-c 0.9.1 → 0.10.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.
Files changed (127) hide show
  1. package/dist/cjs/Badge/badge.js +5 -3
  2. package/dist/cjs/Badge/interface.d.ts +4 -0
  3. package/dist/cjs/Input/style/index.less +1 -0
  4. package/dist/cjs/Popconfirm/interface.d.ts +0 -4
  5. package/dist/cjs/Select/select.js +2 -1
  6. package/dist/cjs/TableSelect/table-select.js +2 -2
  7. package/dist/cjs/Tabs/demo/overflow-center.d.ts +3 -0
  8. package/dist/cjs/Tabs/demo/overflow-center.js +54 -0
  9. package/dist/cjs/Tabs/hooks/useNavListMove.d.ts +2 -1
  10. package/dist/cjs/Tabs/hooks/useNavListMove.js +51 -16
  11. package/dist/cjs/Tabs/hooks/useTabScroll.d.ts +1 -0
  12. package/dist/cjs/Tabs/hooks/useTabScroll.js +5 -1
  13. package/dist/cjs/Tabs/interface.d.ts +9 -0
  14. package/dist/cjs/Tabs/style/index.less +5 -0
  15. package/dist/cjs/Tabs/tab-header/index.d.ts +1 -0
  16. package/dist/cjs/Tabs/tab-header/index.js +9 -2
  17. package/dist/cjs/Tabs/tabs.js +4 -1
  18. package/dist/cjs/TreeSelect/tree-select.js +1 -1
  19. package/dist/cjs/Upload/demo/auto-upload.d.ts +3 -0
  20. package/dist/cjs/Upload/demo/auto-upload.js +65 -0
  21. package/dist/cjs/Upload/demo/basic.js +5 -10
  22. package/dist/cjs/Upload/demo/controlled.js +4 -4
  23. package/dist/cjs/Upload/demo/pictureWall.js +14 -13
  24. package/dist/cjs/Upload/dragger.d.ts +2 -1
  25. package/dist/cjs/Upload/dragger.js +32 -21
  26. package/dist/cjs/Upload/index.d.ts +1 -1
  27. package/dist/cjs/Upload/interface.d.ts +67 -120
  28. package/dist/cjs/Upload/style/index.less +40 -13
  29. package/dist/cjs/Upload/upload.d.ts +2 -2
  30. package/dist/cjs/Upload/upload.js +435 -185
  31. package/dist/cjs/Upload/uploaded-list/index.d.ts +2 -1
  32. package/dist/cjs/Upload/uploaded-list/index.js +6 -3
  33. package/dist/cjs/Upload/uploaded-list/uploaded-item.d.ts +6 -3
  34. package/dist/cjs/Upload/uploaded-list/uploaded-item.js +127 -138
  35. package/dist/cjs/style/size.css +1 -1
  36. package/dist/cjs/style/themes.css +1 -1
  37. package/dist/cjs/style/variables.css +2 -2
  38. package/dist/cjs/utils/ax/core.d.ts +3 -1
  39. package/dist/cjs/utils/ax/core.js +24 -37
  40. package/dist/cjs/utils/ax/index.d.ts +3 -1
  41. package/dist/cjs/utils/folder-scanner.d.ts +1 -1
  42. package/dist/cjs/utils/folder-scanner.js +43 -34
  43. package/dist/cjs/version.d.ts +1 -1
  44. package/dist/cjs/version.js +1 -1
  45. package/dist/esm/Badge/badge.js +3 -2
  46. package/dist/esm/Badge/interface.d.ts +4 -0
  47. package/dist/esm/Input/style/index.less +1 -0
  48. package/dist/esm/Popconfirm/interface.d.ts +0 -4
  49. package/dist/esm/Select/select.js +2 -1
  50. package/dist/esm/TableSelect/table-select.js +2 -2
  51. package/dist/esm/Tabs/demo/overflow-center.d.ts +3 -0
  52. package/dist/esm/Tabs/demo/overflow-center.js +61 -0
  53. package/dist/esm/Tabs/hooks/useNavListMove.d.ts +2 -1
  54. package/dist/esm/Tabs/hooks/useNavListMove.js +62 -25
  55. package/dist/esm/Tabs/hooks/useTabScroll.d.ts +1 -0
  56. package/dist/esm/Tabs/hooks/useTabScroll.js +9 -0
  57. package/dist/esm/Tabs/interface.d.ts +9 -0
  58. package/dist/esm/Tabs/style/index.less +5 -0
  59. package/dist/esm/Tabs/tab-header/index.d.ts +1 -0
  60. package/dist/esm/Tabs/tab-header/index.js +13 -2
  61. package/dist/esm/Tabs/tabs.js +4 -2
  62. package/dist/esm/TreeSelect/tree-select.js +1 -1
  63. package/dist/esm/Upload/demo/auto-upload.d.ts +3 -0
  64. package/dist/esm/Upload/demo/auto-upload.js +42 -0
  65. package/dist/esm/Upload/demo/basic.js +5 -11
  66. package/dist/esm/Upload/demo/controlled.js +8 -6
  67. package/dist/esm/Upload/demo/pictureWall.js +17 -14
  68. package/dist/esm/Upload/dragger.d.ts +2 -1
  69. package/dist/esm/Upload/dragger.js +10 -5
  70. package/dist/esm/Upload/index.d.ts +1 -1
  71. package/dist/esm/Upload/interface.d.ts +67 -120
  72. package/dist/esm/Upload/style/index.less +40 -13
  73. package/dist/esm/Upload/upload.d.ts +2 -2
  74. package/dist/esm/Upload/upload.js +573 -271
  75. package/dist/esm/Upload/uploaded-list/index.d.ts +2 -1
  76. package/dist/esm/Upload/uploaded-list/index.js +9 -4
  77. package/dist/esm/Upload/uploaded-list/uploaded-item.d.ts +6 -3
  78. package/dist/esm/Upload/uploaded-list/uploaded-item.js +145 -150
  79. package/dist/esm/style/size.css +1 -1
  80. package/dist/esm/style/themes.css +1 -1
  81. package/dist/esm/style/variables.css +2 -2
  82. package/dist/esm/utils/ax/core.d.ts +3 -1
  83. package/dist/esm/utils/ax/core.js +32 -40
  84. package/dist/esm/utils/ax/index.d.ts +3 -1
  85. package/dist/esm/utils/folder-scanner.d.ts +1 -1
  86. package/dist/esm/utils/folder-scanner.js +76 -75
  87. package/dist/esm/version.d.ts +1 -1
  88. package/dist/esm/version.js +1 -1
  89. package/dist/umd/yee-c.min.css +2 -2
  90. package/dist/umd/yee-c.min.js +1 -1
  91. package/package.json +1 -1
  92. package/src/Badge/badge.tsx +2 -1
  93. package/src/Badge/interface.ts +4 -0
  94. package/src/Input/style/index.less +1 -0
  95. package/src/Popconfirm/interface.ts +0 -4
  96. package/src/Select/select.tsx +2 -1
  97. package/src/TableSelect/table-select.tsx +1 -0
  98. package/src/Tabs/demo/overflow-center.tsx +35 -0
  99. package/src/Tabs/hooks/useNavListMove.ts +60 -18
  100. package/src/Tabs/hooks/useTabScroll.ts +7 -1
  101. package/src/Tabs/index.en-US.md +33 -31
  102. package/src/Tabs/index.zh-CN.md +33 -31
  103. package/src/Tabs/interface.ts +9 -0
  104. package/src/Tabs/style/index.less +5 -0
  105. package/src/Tabs/tab-header/index.tsx +12 -2
  106. package/src/Tabs/tabs.tsx +2 -0
  107. package/src/TreeSelect/tree-select.tsx +1 -1
  108. package/src/Upload/demo/auto-upload.tsx +35 -0
  109. package/src/Upload/demo/basic.tsx +7 -11
  110. package/src/Upload/demo/controlled.tsx +12 -8
  111. package/src/Upload/demo/directory.tsx +3 -4
  112. package/src/Upload/demo/drag.tsx +5 -12
  113. package/src/Upload/demo/multiple.tsx +3 -4
  114. package/src/Upload/demo/pictureWall.tsx +22 -21
  115. package/src/Upload/dragger.tsx +47 -34
  116. package/src/Upload/index.en-US.md +63 -43
  117. package/src/Upload/index.ts +8 -1
  118. package/src/Upload/index.zh-CN.md +62 -42
  119. package/src/Upload/interface.ts +68 -120
  120. package/src/Upload/style/index.less +40 -13
  121. package/src/Upload/upload.tsx +546 -215
  122. package/src/Upload/uploaded-list/index.tsx +9 -5
  123. package/src/Upload/uploaded-list/uploaded-item.tsx +199 -228
  124. package/src/style/size.css +1 -1
  125. package/src/utils/ax/core.ts +28 -41
  126. package/src/utils/folder-scanner.ts +51 -37
  127. package/src/version.ts +1 -1
@@ -35,11 +35,7 @@ var Ax = /*#__PURE__*/function () {
35
35
  }
36
36
  _createClass(Ax, [{
37
37
  key: "request",
38
- value:
39
- // eslint-disable-next-line @typescript-eslint/no-empty-function
40
- // constructor() {}
41
-
42
- function request(configOrUrl) {
38
+ value: function request(configOrUrl) {
43
39
  var config = getDefaultConfig();
44
40
  if (typeof configOrUrl === 'string') {
45
41
  config = config || {};
@@ -54,9 +50,10 @@ var Ax = /*#__PURE__*/function () {
54
50
  body: config.data
55
51
  }));
56
52
  }
57
- return new Promise(function (resolve, reject) {
53
+ var xhr;
54
+ var request = new Promise(function (resolve, reject) {
58
55
  var _config$method2;
59
- var xhr = new XMLHttpRequest();
56
+ xhr = new XMLHttpRequest();
60
57
  var _config = config,
61
58
  headers = _config.headers,
62
59
  timeout = _config.timeout,
@@ -72,7 +69,6 @@ var Ax = /*#__PURE__*/function () {
72
69
  _config$formDataWithB = _config.formDataWithBoundary,
73
70
  formDataWithBoundary = _config$formDataWithB === void 0 ? true : _config$formDataWithB;
74
71
  if ((!data || getType(data) === 'FormData') && headers) {
75
- // Delete to let browser auto-generate
76
72
  if (formDataWithBoundary) {
77
73
  delete headers['Content-Type'];
78
74
  }
@@ -85,33 +81,28 @@ var Ax = /*#__PURE__*/function () {
85
81
  xhr.timeout = timeout;
86
82
  }
87
83
  xhr.upload.onprogress = function (event) {
88
- if (onUploadProgress) {
89
- onUploadProgress(event, xhr);
90
- }
84
+ onUploadProgress === null || onUploadProgress === void 0 || onUploadProgress(event, xhr);
91
85
  };
92
86
  xhr.onreadystatechange = function () {
93
- if (xhr.readyState === XMLHttpRequest.DONE) {
87
+ var _xhr;
88
+ if (((_xhr = xhr) === null || _xhr === void 0 ? void 0 : _xhr.readyState) === XMLHttpRequest.DONE) {
94
89
  if (xhr.status >= 200 && xhr.status <= 299) {
95
90
  var type = this.getResponseHeader('content-type') || '';
96
91
  var isJsonType = type.indexOf('application/json') > -1;
97
- var _data;
92
+ var responseData;
98
93
  if (isJsonType) {
99
94
  try {
100
- _data = JSON.parse(xhr.response);
101
- } catch (err) {
102
- _data = xhr.response;
95
+ responseData = JSON.parse(xhr.response);
96
+ } catch (error) {
97
+ responseData = xhr.response;
103
98
  }
104
99
  } else {
105
- _data = xhr.response;
106
- }
107
- if (onSuccess) {
108
- onSuccess(_data, xhr);
100
+ responseData = xhr.response;
109
101
  }
110
- resolve(_data);
102
+ onSuccess === null || onSuccess === void 0 || onSuccess(responseData, xhr);
103
+ resolve(responseData);
111
104
  } else {
112
- if (onError) {
113
- onError(xhr.response, xhr);
114
- }
105
+ onError === null || onError === void 0 || onError(xhr.response, xhr);
115
106
  reject({
116
107
  status: 'error',
117
108
  error: xhr.response
@@ -120,38 +111,39 @@ var Ax = /*#__PURE__*/function () {
120
111
  }
121
112
  };
122
113
  xhr.onprogress = function (event) {
123
- if (onProgress) {
124
- onProgress(event, xhr);
125
- }
114
+ onProgress === null || onProgress === void 0 || onProgress(event, xhr);
126
115
  };
127
116
  xhr.onloadend = function (event) {
128
- if (onLoaded) {
129
- onLoaded(event, xhr);
130
- }
117
+ onLoaded === null || onLoaded === void 0 || onLoaded(event, xhr);
131
118
  xhr = null;
132
119
  };
133
- xhr.onerror = function (err) {
134
- if (onError) {
135
- onError(xhr.response, xhr);
136
- }
120
+ xhr.onerror = function (error) {
121
+ onError === null || onError === void 0 || onError(xhr.response, xhr);
137
122
  reject({
138
123
  status: 'error',
139
- error: err
124
+ error: error
125
+ });
126
+ };
127
+ xhr.onabort = function (event) {
128
+ reject({
129
+ status: 'abort',
130
+ error: event
140
131
  });
141
- xhr = null;
142
132
  };
143
133
  xhr.ontimeout = function (event) {
144
- if (onTimeout) {
145
- onTimeout(event, xhr);
146
- }
134
+ onTimeout === null || onTimeout === void 0 || onTimeout(event, xhr);
147
135
  reject({
148
136
  status: 'timeout',
149
137
  error: event
150
138
  });
151
- xhr = null;
152
139
  };
153
140
  xhr.send(data || null);
154
141
  });
142
+ request.abort = function () {
143
+ var _xhr2;
144
+ return (_xhr2 = xhr) === null || _xhr2 === void 0 ? void 0 : _xhr2.abort();
145
+ };
146
+ return request;
155
147
  }
156
148
  }]);
157
149
  return Ax;
@@ -1,2 +1,4 @@
1
- declare const ax: (configOrUrl: string | import("./interface").AxConfig) => Promise<unknown>;
1
+ declare const ax: (configOrUrl: string | import("./interface").AxConfig) => Promise<Response> | (Promise<any> & {
2
+ abort: () => void;
3
+ });
2
4
  export default ax;
@@ -1 +1 @@
1
- export default function folderScanner(entry: FileSystemFileEntry | FileSystemDirectoryEntry, filesList: any[]): Promise<unknown>;
1
+ export default function folderScanner(entry: FileSystemEntry, filesList?: File[]): Promise<File[]>;
@@ -2,88 +2,89 @@ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" ==
2
2
  function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator.return && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, catch: function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
3
3
  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); } }
4
4
  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); }); }; }
5
- export default function folderScanner(_x, _x2) {
5
+ function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
6
+ function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
7
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
8
+ function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
9
+ function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
10
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
11
+ var readAllEntries = function readAllEntries(reader) {
12
+ return new Promise(function (resolve, reject) {
13
+ var entries = [];
14
+ var readNextBatch = function readNextBatch() {
15
+ reader.readEntries(function (batch) {
16
+ if (batch.length === 0) {
17
+ resolve(entries);
18
+ return;
19
+ }
20
+ entries.push.apply(entries, _toConsumableArray(batch));
21
+ readNextBatch();
22
+ }, reject);
23
+ };
24
+ readNextBatch();
25
+ });
26
+ };
27
+ var readFile = function readFile(entry) {
28
+ return new Promise(function (resolve, reject) {
29
+ entry.file(function (file) {
30
+ var path = entry.fullPath.replace(/^\//, '');
31
+ Object.defineProperty(file, 'webkitRelativePath', {
32
+ configurable: true,
33
+ value: path
34
+ });
35
+ resolve(file);
36
+ }, reject);
37
+ });
38
+ };
39
+ export default function folderScanner(_x) {
6
40
  return _folderScanner.apply(this, arguments);
7
41
  }
8
42
  function _folderScanner() {
9
- _folderScanner = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(entry, filesList) {
10
- return _regeneratorRuntime().wrap(function _callee4$(_context4) {
11
- while (1) switch (_context4.prev = _context4.next) {
43
+ _folderScanner = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(entry) {
44
+ var filesList,
45
+ reader,
46
+ entries,
47
+ nestedFiles,
48
+ _args = arguments;
49
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
50
+ while (1) switch (_context.prev = _context.next) {
12
51
  case 0:
13
- return _context4.abrupt("return", new Promise(function (resolve, reject) {
14
- if (entry.isDirectory) {
15
- var directoryReader = entry.createReader();
16
- directoryReader.readEntries( /*#__PURE__*/function () {
17
- var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(entries) {
18
- return _regeneratorRuntime().wrap(function _callee2$(_context2) {
19
- while (1) switch (_context2.prev = _context2.next) {
20
- case 0:
21
- entries.forEach( /*#__PURE__*/function () {
22
- var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(entry, index) {
23
- return _regeneratorRuntime().wrap(function _callee$(_context) {
24
- while (1) switch (_context.prev = _context.next) {
25
- case 0:
26
- _context.next = 2;
27
- return folderScanner(entry, filesList);
28
- case 2:
29
- if (index === entries.length - 1) {
30
- resolve(filesList);
31
- }
32
- case 3:
33
- case "end":
34
- return _context.stop();
35
- }
36
- }, _callee);
37
- }));
38
- return function (_x4, _x5) {
39
- return _ref2.apply(this, arguments);
40
- };
41
- }());
42
- case 1:
43
- case "end":
44
- return _context2.stop();
45
- }
46
- }, _callee2);
47
- }));
48
- return function (_x3) {
49
- return _ref.apply(this, arguments);
50
- };
51
- }(), function (e) {
52
- reject(e);
53
- });
54
- } else if (entry.isFile) {
55
- entry.file( /*#__PURE__*/function () {
56
- var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(file) {
57
- var path, newFile;
58
- return _regeneratorRuntime().wrap(function _callee3$(_context3) {
59
- while (1) switch (_context3.prev = _context3.next) {
60
- case 0:
61
- path = entry.fullPath.substring(1);
62
- /** Modifying webkitRelativePath is the core operation, because in drag events webkitRelativePath is empty, and webkitRelativePath is read-only so normal assignment won't work. Currently the only way is to use this method to assign entry.fullPath to webkitRelativePath **/
63
- newFile = Object.defineProperty(file, 'webkitRelativePath', {
64
- value: path
65
- });
66
- filesList.push(newFile);
67
- resolve(filesList);
68
- case 4:
69
- case "end":
70
- return _context3.stop();
71
- }
72
- }, _callee3);
73
- }));
74
- return function (_x6) {
75
- return _ref3.apply(this, arguments);
76
- };
77
- }(), function (e) {
78
- reject(e);
79
- });
80
- }
52
+ filesList = _args.length > 1 && _args[1] !== undefined ? _args[1] : [];
53
+ if (!entry.isFile) {
54
+ _context.next = 8;
55
+ break;
56
+ }
57
+ _context.t0 = filesList;
58
+ _context.next = 5;
59
+ return readFile(entry);
60
+ case 5:
61
+ _context.t1 = _context.sent;
62
+ _context.t0.push.call(_context.t0, _context.t1);
63
+ return _context.abrupt("return", filesList);
64
+ case 8:
65
+ if (!entry.isDirectory) {
66
+ _context.next = 17;
67
+ break;
68
+ }
69
+ reader = entry.createReader();
70
+ _context.next = 12;
71
+ return readAllEntries(reader);
72
+ case 12:
73
+ entries = _context.sent;
74
+ _context.next = 15;
75
+ return Promise.all(entries.map(function (nestedEntry) {
76
+ return folderScanner(nestedEntry, []);
81
77
  }));
82
- case 1:
78
+ case 15:
79
+ nestedFiles = _context.sent;
80
+ filesList.push.apply(filesList, _toConsumableArray(nestedFiles.flat()));
81
+ case 17:
82
+ return _context.abrupt("return", filesList);
83
+ case 18:
83
84
  case "end":
84
- return _context4.stop();
85
+ return _context.stop();
85
86
  }
86
- }, _callee4);
87
+ }, _callee);
87
88
  }));
88
89
  return _folderScanner.apply(this, arguments);
89
90
  }
@@ -3,4 +3,4 @@ declare global {
3
3
  __yee_c_version__: string;
4
4
  }
5
5
  }
6
- export declare const version = "0.9.1";
6
+ export declare const version = "0.10.0";
@@ -1,4 +1,4 @@
1
- export var version = "0.9.1";
1
+ export var version = "0.10.0";
2
2
  if (typeof window !== 'undefined') {
3
3
  window.__yee_c_version__ = version;
4
4
  }