mario-core 2.10.5-release → 2.10.6-release

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.
@@ -22207,6 +22207,93 @@ const _iteratorSymbol = /*#__PURE__*/ typeof Symbol !== "undefined" ? (Symbol.it
22207
22207
 
22208
22208
  const _asyncIteratorSymbol = /*#__PURE__*/ typeof Symbol !== "undefined" ? (Symbol.asyncIterator || (Symbol.asyncIterator = Symbol("Symbol.asyncIterator"))) : "@@asyncIterator";
22209
22209
 
22210
+ // Asynchronously implement a generic for loop
22211
+ function _for(test, update, body) {
22212
+ var stage;
22213
+ for (;;) {
22214
+ var shouldContinue = test();
22215
+ if (_isSettledPact(shouldContinue)) {
22216
+ shouldContinue = shouldContinue.v;
22217
+ }
22218
+ if (!shouldContinue) {
22219
+ return result;
22220
+ }
22221
+ if (shouldContinue.then) {
22222
+ stage = 0;
22223
+ break;
22224
+ }
22225
+ var result = body();
22226
+ if (result && result.then) {
22227
+ if (_isSettledPact(result)) {
22228
+ result = result.s;
22229
+ } else {
22230
+ stage = 1;
22231
+ break;
22232
+ }
22233
+ }
22234
+ if (update) {
22235
+ var updateValue = update();
22236
+ if (updateValue && updateValue.then && !_isSettledPact(updateValue)) {
22237
+ stage = 2;
22238
+ break;
22239
+ }
22240
+ }
22241
+ }
22242
+ var pact = new _Pact();
22243
+ var reject = _settle.bind(null, pact, 2);
22244
+ (stage === 0 ? shouldContinue.then(_resumeAfterTest) : stage === 1 ? result.then(_resumeAfterBody) : updateValue.then(_resumeAfterUpdate)).then(void 0, reject);
22245
+ return pact;
22246
+ function _resumeAfterBody(value) {
22247
+ result = value;
22248
+ do {
22249
+ if (update) {
22250
+ updateValue = update();
22251
+ if (updateValue && updateValue.then && !_isSettledPact(updateValue)) {
22252
+ updateValue.then(_resumeAfterUpdate).then(void 0, reject);
22253
+ return;
22254
+ }
22255
+ }
22256
+ shouldContinue = test();
22257
+ if (!shouldContinue || (_isSettledPact(shouldContinue) && !shouldContinue.v)) {
22258
+ _settle(pact, 1, result);
22259
+ return;
22260
+ }
22261
+ if (shouldContinue.then) {
22262
+ shouldContinue.then(_resumeAfterTest).then(void 0, reject);
22263
+ return;
22264
+ }
22265
+ result = body();
22266
+ if (_isSettledPact(result)) {
22267
+ result = result.v;
22268
+ }
22269
+ } while (!result || !result.then);
22270
+ result.then(_resumeAfterBody).then(void 0, reject);
22271
+ }
22272
+ function _resumeAfterTest(shouldContinue) {
22273
+ if (shouldContinue) {
22274
+ result = body();
22275
+ if (result && result.then) {
22276
+ result.then(_resumeAfterBody).then(void 0, reject);
22277
+ } else {
22278
+ _resumeAfterBody(result);
22279
+ }
22280
+ } else {
22281
+ _settle(pact, 1, result);
22282
+ }
22283
+ }
22284
+ function _resumeAfterUpdate() {
22285
+ if (shouldContinue = test()) {
22286
+ if (shouldContinue.then) {
22287
+ shouldContinue.then(_resumeAfterTest).then(void 0, reject);
22288
+ } else {
22289
+ _resumeAfterTest(shouldContinue);
22290
+ }
22291
+ } else {
22292
+ _settle(pact, 1, result);
22293
+ }
22294
+ }
22295
+ }
22296
+
22210
22297
  // Asynchronously call a function and send errors to recovery continuation
22211
22298
  function _catch(body, recover) {
22212
22299
  try {
@@ -49699,12 +49786,56 @@ var useCSVImportTab = function useCSVImportTab() {
49699
49786
  }
49700
49787
  };
49701
49788
 
49789
+ var safeImport = function safeImport(importUsersCSV, formData, chunkIndex) {
49790
+ try {
49791
+ var _exit3 = false;
49792
+ var _retry = 0;
49793
+ return Promise.resolve(_for(function () {
49794
+ return !_exit3 && _retry < 2;
49795
+ }, function () {
49796
+ return _retry++;
49797
+ }, function () {
49798
+ return _catch(function () {
49799
+ _exit3 = true;
49800
+ return Promise.resolve(importUsersCSV(formData));
49801
+ }, function (err) {
49802
+ var _exit2 = false;
49803
+
49804
+ function _temp6(_result) {
49805
+ if (_exit2) return _result;
49806
+ throw err;
49807
+ }
49808
+
49809
+ if (err.response) {
49810
+ throw err;
49811
+ }
49812
+
49813
+ console.warn("\u26A0\uFE0F Chunk " + chunkIndex + " network error, retry " + (_retry + 1) + "/2...");
49814
+
49815
+ var _temp5 = function () {
49816
+ if (_retry < 1) {
49817
+ return Promise.resolve(new Promise(function (res) {
49818
+ return setTimeout(res, 500);
49819
+ })).then(function () {});
49820
+ } else {
49821
+ throw err;
49822
+ }
49823
+ }();
49824
+
49825
+ return _temp5 && _temp5.then ? _temp5.then(_temp6) : _temp6(_temp5);
49826
+ });
49827
+ }));
49828
+ } catch (e) {
49829
+ return Promise.reject(e);
49830
+ }
49831
+ };
49832
+
49702
49833
  var upload = useCallback(function (file) {
49703
49834
  try {
49704
- var _exit2 = false;
49835
+ var _exit5 = false;
49705
49836
 
49706
- var _temp12 = function _temp12(_result2) {
49707
- if (_exit2) return _result2;
49837
+ var _temp14 = function _temp14(_result4) {
49838
+ if (_exit5) return _result4;
49708
49839
  dispatch(setLoading(false));
49709
49840
  var inputId = document.getElementById(id$1);
49710
49841
  var input = document.getElementById('import-student');
@@ -49717,9 +49848,9 @@ var useCSVImportTab = function useCSVImportTab() {
49717
49848
  if (!type || !file) return Promise.resolve();
49718
49849
  dispatch(setLoading(true));
49719
49850
 
49720
- var _temp13 = _catch(function () {
49721
- function _temp9(_result) {
49722
- if (_exit2) return _result;
49851
+ var _temp15 = _catch(function () {
49852
+ function _temp11(_result3) {
49853
+ if (_exit5) return _result3;
49723
49854
  dispatch(setAlert({
49724
49855
  type: "success",
49725
49856
  message: "Import CSV successfully"
@@ -49729,7 +49860,7 @@ var useCSVImportTab = function useCSVImportTab() {
49729
49860
  var formData = new FormData();
49730
49861
  formData.append("file", file, file.name);
49731
49862
 
49732
- var _temp8 = function () {
49863
+ var _temp10 = function () {
49733
49864
  if (type == CSVType$1.AllUser) {
49734
49865
  return Promise.resolve(file.text()).then(function (fileTextRaw) {
49735
49866
  var fileText = fileTextRaw.trim();
@@ -49751,7 +49882,7 @@ var useCSVImportTab = function useCSVImportTab() {
49751
49882
  });
49752
49883
  var header = parsedData.meta.fields;
49753
49884
  var dataRows = parsedData.data;
49754
- var chunkSize = 20;
49885
+ var chunkSize = 30;
49755
49886
  var chunks = [];
49756
49887
 
49757
49888
  for (var _i = 0; _i < dataRows.length; _i += chunkSize) {
@@ -49763,47 +49894,52 @@ var useCSVImportTab = function useCSVImportTab() {
49763
49894
  chunks.push(csvChunk);
49764
49895
  }
49765
49896
 
49766
- var _temp5 = _forTo(chunks, function (i) {
49897
+ var _temp7 = _forTo(chunks, function (i) {
49767
49898
  var blob = new Blob([chunks[i]], {
49768
49899
  type: "text/csv"
49769
49900
  });
49770
49901
  var formData = new FormData();
49771
49902
  formData.append("file", blob, "students_chunk" + (i + 1) + ".csv");
49772
- return Promise.resolve(importUsersCSV$1(formData)).then(function () {});
49903
+ return Promise.resolve(safeImport(importUsersCSV$1, formData, i + 1)).then(function () {
49904
+ return Promise.resolve(new Promise(function (res) {
49905
+ return setTimeout(res, 500);
49906
+ })).then(function () {});
49907
+ });
49773
49908
  });
49774
49909
 
49775
- if (_temp5 && _temp5.then) return _temp5.then(function () {});
49910
+ if (_temp7 && _temp7.then) return _temp7.then(function () {});
49776
49911
  });
49777
49912
  } else {
49778
- var _temp14 = function () {
49913
+ var _temp16 = function () {
49779
49914
  if (isCheckDomainIBS) {
49780
- var _temp15 = function () {
49915
+ var _temp17 = function () {
49781
49916
  if (type == CSVType$1.ClassReflection) {
49782
49917
  return Promise.resolve(importClassReflectionCSV$1(formData)).then(function () {});
49783
49918
  }
49784
49919
  }();
49785
49920
 
49786
- if (_temp15 && _temp15.then) return _temp15.then(function () {});
49921
+ if (_temp17 && _temp17.then) return _temp17.then(function () {});
49787
49922
  } else {
49788
49923
  return Promise.resolve(importCSV$1(formData, type.toString())).then(function () {});
49789
49924
  }
49790
49925
  }();
49791
49926
 
49792
- if (_temp14 && _temp14.then) return _temp14.then(function () {});
49927
+ if (_temp16 && _temp16.then) return _temp16.then(function () {});
49793
49928
  }
49794
49929
  }();
49795
49930
 
49796
- return _temp8 && _temp8.then ? _temp8.then(_temp9) : _temp9(_temp8);
49931
+ return _temp10 && _temp10.then ? _temp10.then(_temp11) : _temp11(_temp10);
49797
49932
  }, function (err) {
49798
49933
  var _err$response, _err$response$data;
49799
49934
 
49935
+ console.error("❌ Upload failed", err);
49800
49936
  dispatch(setAlert({
49801
49937
  type: "danger",
49802
49938
  message: ((_err$response = err.response) === null || _err$response === void 0 ? void 0 : (_err$response$data = _err$response.data) === null || _err$response$data === void 0 ? void 0 : _err$response$data.title) || err.message
49803
49939
  }));
49804
49940
  });
49805
49941
 
49806
- return Promise.resolve(_temp13 && _temp13.then ? _temp13.then(_temp12) : _temp12(_temp13));
49942
+ return Promise.resolve(_temp15 && _temp15.then ? _temp15.then(_temp14) : _temp14(_temp15));
49807
49943
  } catch (e) {
49808
49944
  return Promise.reject(e);
49809
49945
  }
@@ -49811,7 +49947,7 @@ var useCSVImportTab = function useCSVImportTab() {
49811
49947
 
49812
49948
  var uploadByTeacherId = function uploadByTeacherId(file) {
49813
49949
  try {
49814
- var _temp18 = function _temp18() {
49950
+ var _temp20 = function _temp20() {
49815
49951
  dispatch(setLoading(false));
49816
49952
  var input = document.getElementById('teacherSelector');
49817
49953
  input && (input.value = "");
@@ -49828,7 +49964,7 @@ var useCSVImportTab = function useCSVImportTab() {
49828
49964
  if (!type || !file) return Promise.resolve();
49829
49965
  dispatch(setLoading(true));
49830
49966
 
49831
- var _temp19 = _catch(function () {
49967
+ var _temp21 = _catch(function () {
49832
49968
  var formData = new FormData();
49833
49969
  formData.append("file", file, file.name);
49834
49970
  return Promise.resolve(importStudentByTeacher$1(defaultTeacher, formData)).then(function () {
@@ -49846,7 +49982,7 @@ var useCSVImportTab = function useCSVImportTab() {
49846
49982
  }));
49847
49983
  });
49848
49984
 
49849
- return Promise.resolve(_temp19 && _temp19.then ? _temp19.then(_temp18) : _temp18(_temp19));
49985
+ return Promise.resolve(_temp21 && _temp21.then ? _temp21.then(_temp20) : _temp20(_temp21));
49850
49986
  } catch (e) {
49851
49987
  return Promise.reject(e);
49852
49988
  }
@@ -49854,7 +49990,7 @@ var useCSVImportTab = function useCSVImportTab() {
49854
49990
 
49855
49991
  var onConfirm = function onConfirm(values) {
49856
49992
  try {
49857
- var _temp22 = function _temp22() {
49993
+ var _temp24 = function _temp24() {
49858
49994
  dispatch(setLoading(false));
49859
49995
  var input = document.getElementById(id$1);
49860
49996
  input && (input.value = "");
@@ -49863,7 +49999,7 @@ var useCSVImportTab = function useCSVImportTab() {
49863
49999
  if (!dataFile || !dataFile) return Promise.resolve();
49864
50000
  dispatch(setLoading(true));
49865
50001
 
49866
- var _temp23 = _catch(function () {
50002
+ var _temp25 = _catch(function () {
49867
50003
  var formData = new FormData();
49868
50004
  formData.append("file", dataFile, dataFile.name);
49869
50005
  formData.append("teacherName", values.teacherName);
@@ -49887,7 +50023,7 @@ var useCSVImportTab = function useCSVImportTab() {
49887
50023
  }));
49888
50024
  });
49889
50025
 
49890
- return Promise.resolve(_temp23 && _temp23.then ? _temp23.then(_temp22) : _temp22(_temp23));
50026
+ return Promise.resolve(_temp25 && _temp25.then ? _temp25.then(_temp24) : _temp24(_temp25));
49891
50027
  } catch (e) {
49892
50028
  return Promise.reject(e);
49893
50029
  }