@emqx/shared-ui-utils 0.0.10 → 0.0.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/download.d.ts +7 -0
- package/dist/format.d.ts +28 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +607 -41
- package/dist/index.umd.cjs +15 -1
- package/dist/useBatchSettings.d.ts +21 -0
- package/package.json +8 -1
package/dist/download.d.ts
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Initiates a download of a file from a given URL with the specified filename.
|
|
3
|
+
*
|
|
4
|
+
* @param url - The URL of the file to be downloaded.
|
|
5
|
+
* @param filename - The name of the file to be downloaded.
|
|
6
|
+
*/
|
|
7
|
+
export declare const downloadFile: (url: string, filename: string) => void;
|
|
1
8
|
/**
|
|
2
9
|
* Creates a download link for a given Blob data with the specified filename.
|
|
3
10
|
* The link is automatically clicked to initiate the download, and then removed from the document body.
|
package/dist/format.d.ts
CHANGED
|
@@ -5,3 +5,31 @@
|
|
|
5
5
|
* @throws {Error} If the input is not a non-negative number.
|
|
6
6
|
*/
|
|
7
7
|
export declare const formatSizeUnit: (val: number) => string;
|
|
8
|
+
/**
|
|
9
|
+
* Converts a given value from one unit to its equivalent in the smallest unit of the same type.
|
|
10
|
+
*
|
|
11
|
+
* For example, it converts a value in kilobytes (KB) to bytes (B), or a value in hours (h) to milliseconds (ms).
|
|
12
|
+
* The smallest unit for time is millisecond (ms), and for size is byte (B).
|
|
13
|
+
*
|
|
14
|
+
* @param {number} value - The numeric value to be converted.
|
|
15
|
+
* @param {string} unit - The unit of the value, which is a key of the SizeOrTimeUnit enum.
|
|
16
|
+
* @returns {number} The input value converted to the smallest unit.
|
|
17
|
+
* @throws {Error} If the provided unit is not a key in the SizeOrTimeUnit enum.
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* // returns 1024, converts 1 kilobyte to bytes
|
|
21
|
+
* formatValueToMinUnit(1, 'KB');
|
|
22
|
+
*/
|
|
23
|
+
declare enum SizeOrTimeUnit {
|
|
24
|
+
ms = 1,
|
|
25
|
+
s = 1000,
|
|
26
|
+
m = 60000,
|
|
27
|
+
h = 3600000,
|
|
28
|
+
d = 86400000,
|
|
29
|
+
B = 1,
|
|
30
|
+
KB = 1024,
|
|
31
|
+
MB = 1048576,
|
|
32
|
+
GB = 1073741824
|
|
33
|
+
}
|
|
34
|
+
export declare const formatValueToMinUnit: (value: number, unit: keyof typeof SizeOrTimeUnit) => number;
|
|
35
|
+
export {};
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -1,60 +1,626 @@
|
|
|
1
|
-
const
|
|
2
|
-
if (typeof
|
|
3
|
-
for (const
|
|
4
|
-
i
|
|
1
|
+
const ke = (i, E = [], m = {}) => {
|
|
2
|
+
if (typeof i == "object" && !Array.isArray(i) && i !== null)
|
|
3
|
+
for (const c of Object.keys(i))
|
|
4
|
+
ke(i[c], E.concat(c), m);
|
|
5
5
|
else
|
|
6
|
-
|
|
7
|
-
return
|
|
8
|
-
},
|
|
9
|
-
if (Object(
|
|
10
|
-
return
|
|
11
|
-
const
|
|
6
|
+
m[E.join(".")] = i;
|
|
7
|
+
return m;
|
|
8
|
+
}, Ce = (i) => {
|
|
9
|
+
if (Object(i) !== i && !Array.isArray(i))
|
|
10
|
+
return i;
|
|
11
|
+
const E = /\.?([^.[\]]+)|\[(\d+)\]/g, m = {};
|
|
12
12
|
try {
|
|
13
|
-
for (const
|
|
14
|
-
let
|
|
15
|
-
for (;
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
}
|
|
19
|
-
} catch (
|
|
20
|
-
console.error(
|
|
13
|
+
for (const c in i) {
|
|
14
|
+
let z = m, G = "", J;
|
|
15
|
+
for (; J = E.exec(c); )
|
|
16
|
+
z = z[G] || (z[G] = J[2] ? [] : {}), G = J[2] || J[1];
|
|
17
|
+
z[G] = i[c];
|
|
18
|
+
}
|
|
19
|
+
} catch (c) {
|
|
20
|
+
console.error(c);
|
|
21
21
|
}
|
|
22
|
-
return
|
|
23
|
-
},
|
|
22
|
+
return m[""] || m;
|
|
23
|
+
}, Re = (i) => Object.keys(i).length === 0, xe = (i) => {
|
|
24
24
|
try {
|
|
25
|
-
return JSON.parse(
|
|
25
|
+
return JSON.parse(i);
|
|
26
26
|
} catch {
|
|
27
27
|
console.error("An error occurred while parsing the JSON string");
|
|
28
28
|
}
|
|
29
|
-
},
|
|
29
|
+
}, Oe = (i, E) => {
|
|
30
30
|
try {
|
|
31
|
-
return typeof
|
|
32
|
-
} catch (
|
|
33
|
-
return console.error(
|
|
31
|
+
return typeof i == "string" ? i : JSON.stringify(i, null, E);
|
|
32
|
+
} catch (m) {
|
|
33
|
+
return console.error(m), "stringify error";
|
|
34
34
|
}
|
|
35
|
-
},
|
|
36
|
-
if (typeof
|
|
35
|
+
}, Ae = (i) => {
|
|
36
|
+
if (typeof i != "string")
|
|
37
37
|
return !1;
|
|
38
38
|
try {
|
|
39
|
-
const
|
|
40
|
-
return typeof
|
|
39
|
+
const E = JSON.parse(i);
|
|
40
|
+
return typeof E == "object" && E !== null;
|
|
41
41
|
} catch {
|
|
42
42
|
return !1;
|
|
43
43
|
}
|
|
44
|
-
},
|
|
45
|
-
if (typeof
|
|
44
|
+
}, Ie = (i) => {
|
|
45
|
+
if (typeof i != "number" || isNaN(i) || i < 0)
|
|
46
46
|
throw new Error("Invalid input: input should be a non-negative number");
|
|
47
|
-
if (
|
|
47
|
+
if (i === 0)
|
|
48
48
|
return "0 Bytes";
|
|
49
|
-
const
|
|
50
|
-
return `${(
|
|
49
|
+
const E = ["Bytes", "KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"], m = Math.floor(Math.log(i) / Math.log(1024));
|
|
50
|
+
return `${(i / 1024 ** m).toFixed(1)} ${E[m]}`;
|
|
51
|
+
};
|
|
52
|
+
var ce = /* @__PURE__ */ ((i) => (i[i.ms = 1] = "ms", i[i.s = 1e3] = "s", i[i.m = 6e4] = "m", i[i.h = 36e5] = "h", i[i.d = 864e5] = "d", i[i.B = 1] = "B", i[i.KB = 1024] = "KB", i[i.MB = 1048576] = "MB", i[i.GB = 1073741824] = "GB", i))(ce || {});
|
|
53
|
+
const De = (i, E) => {
|
|
54
|
+
if (!(E in ce))
|
|
55
|
+
throw new Error(`Invalid unit: ${E}`);
|
|
56
|
+
return i * ce[E];
|
|
57
|
+
}, be = (i, E) => {
|
|
58
|
+
const m = document.createElement("a");
|
|
59
|
+
m.style.display = "none", m.href = i, m.download = E, document.body.appendChild(m), m.click(), document.body.removeChild(m);
|
|
60
|
+
}, Le = (i, E) => {
|
|
61
|
+
const m = window.URL.createObjectURL(new Blob([i]));
|
|
62
|
+
be(m, E), window.URL.revokeObjectURL(m);
|
|
51
63
|
};
|
|
64
|
+
var we = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {}, Ee = { exports: {} };
|
|
65
|
+
/* @license
|
|
66
|
+
Papa Parse
|
|
67
|
+
v5.4.1
|
|
68
|
+
https://github.com/mholt/PapaParse
|
|
69
|
+
License: MIT
|
|
70
|
+
*/
|
|
71
|
+
(function(i, E) {
|
|
72
|
+
(function(m, c) {
|
|
73
|
+
i.exports = c();
|
|
74
|
+
})(we, function m() {
|
|
75
|
+
var c = typeof self < "u" ? self : typeof window < "u" ? window : c !== void 0 ? c : {}, z = !c.document && !!c.postMessage, G = c.IS_PAPA_WORKER || !1, J = {}, me = 0, l = { parse: function(t, e) {
|
|
76
|
+
var r = (e = e || {}).dynamicTyping || !1;
|
|
77
|
+
if (_(r) && (e.dynamicTypingFunction = r, r = {}), e.dynamicTyping = r, e.transform = !!_(e.transform) && e.transform, e.worker && l.WORKERS_SUPPORTED) {
|
|
78
|
+
var n = function() {
|
|
79
|
+
if (!l.WORKERS_SUPPORTED)
|
|
80
|
+
return !1;
|
|
81
|
+
var f = (B = c.URL || c.webkitURL || null, C = m.toString(), l.BLOB_URL || (l.BLOB_URL = B.createObjectURL(new Blob(["var global = (function() { if (typeof self !== 'undefined') { return self; } if (typeof window !== 'undefined') { return window; } if (typeof global !== 'undefined') { return global; } return {}; })(); global.IS_PAPA_WORKER=true; ", "(", C, ")();"], { type: "text/javascript" })))), d = new c.Worker(f), B, C;
|
|
82
|
+
return d.onmessage = ve, d.id = me++, J[d.id] = d;
|
|
83
|
+
}();
|
|
84
|
+
return n.userStep = e.step, n.userChunk = e.chunk, n.userComplete = e.complete, n.userError = e.error, e.step = _(e.step), e.chunk = _(e.chunk), e.complete = _(e.complete), e.error = _(e.error), delete e.worker, void n.postMessage({ input: t, config: e, workerId: n.id });
|
|
85
|
+
}
|
|
86
|
+
var a = null;
|
|
87
|
+
return l.NODE_STREAM_INPUT, typeof t == "string" ? (t = function(f) {
|
|
88
|
+
return f.charCodeAt(0) === 65279 ? f.slice(1) : f;
|
|
89
|
+
}(t), a = e.download ? new ae(e) : new ie(e)) : t.readable === !0 && _(t.read) && _(t.on) ? a = new ue(e) : (c.File && t instanceof File || t instanceof Object) && (a = new oe(e)), a.stream(t);
|
|
90
|
+
}, unparse: function(t, e) {
|
|
91
|
+
var r = !1, n = !0, a = ",", f = `\r
|
|
92
|
+
`, d = '"', B = d + d, C = !1, o = null, x = !1;
|
|
93
|
+
(function() {
|
|
94
|
+
if (typeof e == "object") {
|
|
95
|
+
if (typeof e.delimiter != "string" || l.BAD_DELIMITERS.filter(function(s) {
|
|
96
|
+
return e.delimiter.indexOf(s) !== -1;
|
|
97
|
+
}).length || (a = e.delimiter), (typeof e.quotes == "boolean" || typeof e.quotes == "function" || Array.isArray(e.quotes)) && (r = e.quotes), typeof e.skipEmptyLines != "boolean" && typeof e.skipEmptyLines != "string" || (C = e.skipEmptyLines), typeof e.newline == "string" && (f = e.newline), typeof e.quoteChar == "string" && (d = e.quoteChar), typeof e.header == "boolean" && (n = e.header), Array.isArray(e.columns)) {
|
|
98
|
+
if (e.columns.length === 0)
|
|
99
|
+
throw new Error("Option columns is empty");
|
|
100
|
+
o = e.columns;
|
|
101
|
+
}
|
|
102
|
+
e.escapeChar !== void 0 && (B = e.escapeChar + d), (typeof e.escapeFormulae == "boolean" || e.escapeFormulae instanceof RegExp) && (x = e.escapeFormulae instanceof RegExp ? e.escapeFormulae : /^[=+\-@\t\r].*$/);
|
|
103
|
+
}
|
|
104
|
+
})();
|
|
105
|
+
var h = new RegExp(se(d), "g");
|
|
106
|
+
if (typeof t == "string" && (t = JSON.parse(t)), Array.isArray(t)) {
|
|
107
|
+
if (!t.length || Array.isArray(t[0]))
|
|
108
|
+
return j(null, t, C);
|
|
109
|
+
if (typeof t[0] == "object")
|
|
110
|
+
return j(o || Object.keys(t[0]), t, C);
|
|
111
|
+
} else if (typeof t == "object")
|
|
112
|
+
return typeof t.data == "string" && (t.data = JSON.parse(t.data)), Array.isArray(t.data) && (t.fields || (t.fields = t.meta && t.meta.fields || o), t.fields || (t.fields = Array.isArray(t.data[0]) ? t.fields : typeof t.data[0] == "object" ? Object.keys(t.data[0]) : []), Array.isArray(t.data[0]) || typeof t.data[0] == "object" || (t.data = [t.data])), j(t.fields || [], t.data || [], C);
|
|
113
|
+
throw new Error("Unable to serialize unrecognized input");
|
|
114
|
+
function j(s, k, M) {
|
|
115
|
+
var R = "";
|
|
116
|
+
typeof s == "string" && (s = JSON.parse(s)), typeof k == "string" && (k = JSON.parse(k));
|
|
117
|
+
var F = Array.isArray(s) && 0 < s.length, D = !Array.isArray(k[0]);
|
|
118
|
+
if (F && n) {
|
|
119
|
+
for (var L = 0; L < s.length; L++)
|
|
120
|
+
0 < L && (R += a), R += S(s[L], L);
|
|
121
|
+
0 < k.length && (R += f);
|
|
122
|
+
}
|
|
123
|
+
for (var u = 0; u < k.length; u++) {
|
|
124
|
+
var p = F ? s.length : k[u].length, b = !1, I = F ? Object.keys(k[u]).length === 0 : k[u].length === 0;
|
|
125
|
+
if (M && !F && (b = M === "greedy" ? k[u].join("").trim() === "" : k[u].length === 1 && k[u][0].length === 0), M === "greedy" && F) {
|
|
126
|
+
for (var y = [], T = 0; T < p; T++) {
|
|
127
|
+
var O = D ? s[T] : T;
|
|
128
|
+
y.push(k[u][O]);
|
|
129
|
+
}
|
|
130
|
+
b = y.join("").trim() === "";
|
|
131
|
+
}
|
|
132
|
+
if (!b) {
|
|
133
|
+
for (var v = 0; v < p; v++) {
|
|
134
|
+
0 < v && !I && (R += a);
|
|
135
|
+
var W = F && D ? s[v] : v;
|
|
136
|
+
R += S(k[u][W], v);
|
|
137
|
+
}
|
|
138
|
+
u < k.length - 1 && (!M || 0 < p && !I) && (R += f);
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
return R;
|
|
142
|
+
}
|
|
143
|
+
function S(s, k) {
|
|
144
|
+
if (s == null)
|
|
145
|
+
return "";
|
|
146
|
+
if (s.constructor === Date)
|
|
147
|
+
return JSON.stringify(s).slice(1, 25);
|
|
148
|
+
var M = !1;
|
|
149
|
+
x && typeof s == "string" && x.test(s) && (s = "'" + s, M = !0);
|
|
150
|
+
var R = s.toString().replace(h, B);
|
|
151
|
+
return (M = M || r === !0 || typeof r == "function" && r(s, k) || Array.isArray(r) && r[k] || function(F, D) {
|
|
152
|
+
for (var L = 0; L < D.length; L++)
|
|
153
|
+
if (-1 < F.indexOf(D[L]))
|
|
154
|
+
return !0;
|
|
155
|
+
return !1;
|
|
156
|
+
}(R, l.BAD_DELIMITERS) || -1 < R.indexOf(a) || R.charAt(0) === " " || R.charAt(R.length - 1) === " ") ? d + R + d : R;
|
|
157
|
+
}
|
|
158
|
+
} };
|
|
159
|
+
if (l.RECORD_SEP = String.fromCharCode(30), l.UNIT_SEP = String.fromCharCode(31), l.BYTE_ORDER_MARK = "\uFEFF", l.BAD_DELIMITERS = ["\r", `
|
|
160
|
+
`, '"', l.BYTE_ORDER_MARK], l.WORKERS_SUPPORTED = !z && !!c.Worker, l.NODE_STREAM_INPUT = 1, l.LocalChunkSize = 10485760, l.RemoteChunkSize = 5242880, l.DefaultDelimiter = ",", l.Parser = fe, l.ParserHandle = pe, l.NetworkStreamer = ae, l.FileStreamer = oe, l.StringStreamer = ie, l.ReadableStreamStreamer = ue, c.jQuery) {
|
|
161
|
+
var ne = c.jQuery;
|
|
162
|
+
ne.fn.parse = function(t) {
|
|
163
|
+
var e = t.config || {}, r = [];
|
|
164
|
+
return this.each(function(f) {
|
|
165
|
+
if (!(ne(this).prop("tagName").toUpperCase() === "INPUT" && ne(this).attr("type").toLowerCase() === "file" && c.FileReader) || !this.files || this.files.length === 0)
|
|
166
|
+
return !0;
|
|
167
|
+
for (var d = 0; d < this.files.length; d++)
|
|
168
|
+
r.push({ file: this.files[d], inputElem: this, instanceConfig: ne.extend({}, e) });
|
|
169
|
+
}), n(), this;
|
|
170
|
+
function n() {
|
|
171
|
+
if (r.length !== 0) {
|
|
172
|
+
var f, d, B, C, o = r[0];
|
|
173
|
+
if (_(t.before)) {
|
|
174
|
+
var x = t.before(o.file, o.inputElem);
|
|
175
|
+
if (typeof x == "object") {
|
|
176
|
+
if (x.action === "abort")
|
|
177
|
+
return f = "AbortError", d = o.file, B = o.inputElem, C = x.reason, void (_(t.error) && t.error({ name: f }, d, B, C));
|
|
178
|
+
if (x.action === "skip")
|
|
179
|
+
return void a();
|
|
180
|
+
typeof x.config == "object" && (o.instanceConfig = ne.extend(o.instanceConfig, x.config));
|
|
181
|
+
} else if (x === "skip")
|
|
182
|
+
return void a();
|
|
183
|
+
}
|
|
184
|
+
var h = o.instanceConfig.complete;
|
|
185
|
+
o.instanceConfig.complete = function(j) {
|
|
186
|
+
_(h) && h(j, o.file, o.inputElem), a();
|
|
187
|
+
}, l.parse(o.file, o.instanceConfig);
|
|
188
|
+
} else
|
|
189
|
+
_(t.complete) && t.complete();
|
|
190
|
+
}
|
|
191
|
+
function a() {
|
|
192
|
+
r.splice(0, 1), n();
|
|
193
|
+
}
|
|
194
|
+
};
|
|
195
|
+
}
|
|
196
|
+
function U(t) {
|
|
197
|
+
this._handle = null, this._finished = !1, this._completed = !1, this._halted = !1, this._input = null, this._baseIndex = 0, this._partialLine = "", this._rowCount = 0, this._start = 0, this._nextChunk = null, this.isFirstChunk = !0, this._completeResults = { data: [], errors: [], meta: {} }, (function(e) {
|
|
198
|
+
var r = le(e);
|
|
199
|
+
r.chunkSize = parseInt(r.chunkSize), e.step || e.chunk || (r.chunkSize = null), this._handle = new pe(r), (this._handle.streamer = this)._config = r;
|
|
200
|
+
}).call(this, t), this.parseChunk = function(e, r) {
|
|
201
|
+
if (this.isFirstChunk && _(this._config.beforeFirstChunk)) {
|
|
202
|
+
var n = this._config.beforeFirstChunk(e);
|
|
203
|
+
n !== void 0 && (e = n);
|
|
204
|
+
}
|
|
205
|
+
this.isFirstChunk = !1, this._halted = !1;
|
|
206
|
+
var a = this._partialLine + e;
|
|
207
|
+
this._partialLine = "";
|
|
208
|
+
var f = this._handle.parse(a, this._baseIndex, !this._finished);
|
|
209
|
+
if (!this._handle.paused() && !this._handle.aborted()) {
|
|
210
|
+
var d = f.meta.cursor;
|
|
211
|
+
this._finished || (this._partialLine = a.substring(d - this._baseIndex), this._baseIndex = d), f && f.data && (this._rowCount += f.data.length);
|
|
212
|
+
var B = this._finished || this._config.preview && this._rowCount >= this._config.preview;
|
|
213
|
+
if (G)
|
|
214
|
+
c.postMessage({ results: f, workerId: l.WORKER_ID, finished: B });
|
|
215
|
+
else if (_(this._config.chunk) && !r) {
|
|
216
|
+
if (this._config.chunk(f, this._handle), this._handle.paused() || this._handle.aborted())
|
|
217
|
+
return void (this._halted = !0);
|
|
218
|
+
f = void 0, this._completeResults = void 0;
|
|
219
|
+
}
|
|
220
|
+
return this._config.step || this._config.chunk || (this._completeResults.data = this._completeResults.data.concat(f.data), this._completeResults.errors = this._completeResults.errors.concat(f.errors), this._completeResults.meta = f.meta), this._completed || !B || !_(this._config.complete) || f && f.meta.aborted || (this._config.complete(this._completeResults, this._input), this._completed = !0), B || f && f.meta.paused || this._nextChunk(), f;
|
|
221
|
+
}
|
|
222
|
+
this._halted = !0;
|
|
223
|
+
}, this._sendError = function(e) {
|
|
224
|
+
_(this._config.error) ? this._config.error(e) : G && this._config.error && c.postMessage({ workerId: l.WORKER_ID, error: e, finished: !1 });
|
|
225
|
+
};
|
|
226
|
+
}
|
|
227
|
+
function ae(t) {
|
|
228
|
+
var e;
|
|
229
|
+
(t = t || {}).chunkSize || (t.chunkSize = l.RemoteChunkSize), U.call(this, t), this._nextChunk = z ? function() {
|
|
230
|
+
this._readChunk(), this._chunkLoaded();
|
|
231
|
+
} : function() {
|
|
232
|
+
this._readChunk();
|
|
233
|
+
}, this.stream = function(r) {
|
|
234
|
+
this._input = r, this._nextChunk();
|
|
235
|
+
}, this._readChunk = function() {
|
|
236
|
+
if (this._finished)
|
|
237
|
+
this._chunkLoaded();
|
|
238
|
+
else {
|
|
239
|
+
if (e = new XMLHttpRequest(), this._config.withCredentials && (e.withCredentials = this._config.withCredentials), z || (e.onload = Z(this._chunkLoaded, this), e.onerror = Z(this._chunkError, this)), e.open(this._config.downloadRequestBody ? "POST" : "GET", this._input, !z), this._config.downloadRequestHeaders) {
|
|
240
|
+
var r = this._config.downloadRequestHeaders;
|
|
241
|
+
for (var n in r)
|
|
242
|
+
e.setRequestHeader(n, r[n]);
|
|
243
|
+
}
|
|
244
|
+
if (this._config.chunkSize) {
|
|
245
|
+
var a = this._start + this._config.chunkSize - 1;
|
|
246
|
+
e.setRequestHeader("Range", "bytes=" + this._start + "-" + a);
|
|
247
|
+
}
|
|
248
|
+
try {
|
|
249
|
+
e.send(this._config.downloadRequestBody);
|
|
250
|
+
} catch (f) {
|
|
251
|
+
this._chunkError(f.message);
|
|
252
|
+
}
|
|
253
|
+
z && e.status === 0 && this._chunkError();
|
|
254
|
+
}
|
|
255
|
+
}, this._chunkLoaded = function() {
|
|
256
|
+
e.readyState === 4 && (e.status < 200 || 400 <= e.status ? this._chunkError() : (this._start += this._config.chunkSize ? this._config.chunkSize : e.responseText.length, this._finished = !this._config.chunkSize || this._start >= function(r) {
|
|
257
|
+
var n = r.getResponseHeader("Content-Range");
|
|
258
|
+
return n === null ? -1 : parseInt(n.substring(n.lastIndexOf("/") + 1));
|
|
259
|
+
}(e), this.parseChunk(e.responseText)));
|
|
260
|
+
}, this._chunkError = function(r) {
|
|
261
|
+
var n = e.statusText || r;
|
|
262
|
+
this._sendError(new Error(n));
|
|
263
|
+
};
|
|
264
|
+
}
|
|
265
|
+
function oe(t) {
|
|
266
|
+
var e, r;
|
|
267
|
+
(t = t || {}).chunkSize || (t.chunkSize = l.LocalChunkSize), U.call(this, t);
|
|
268
|
+
var n = typeof FileReader < "u";
|
|
269
|
+
this.stream = function(a) {
|
|
270
|
+
this._input = a, r = a.slice || a.webkitSlice || a.mozSlice, n ? ((e = new FileReader()).onload = Z(this._chunkLoaded, this), e.onerror = Z(this._chunkError, this)) : e = new FileReaderSync(), this._nextChunk();
|
|
271
|
+
}, this._nextChunk = function() {
|
|
272
|
+
this._finished || this._config.preview && !(this._rowCount < this._config.preview) || this._readChunk();
|
|
273
|
+
}, this._readChunk = function() {
|
|
274
|
+
var a = this._input;
|
|
275
|
+
if (this._config.chunkSize) {
|
|
276
|
+
var f = Math.min(this._start + this._config.chunkSize, this._input.size);
|
|
277
|
+
a = r.call(a, this._start, f);
|
|
278
|
+
}
|
|
279
|
+
var d = e.readAsText(a, this._config.encoding);
|
|
280
|
+
n || this._chunkLoaded({ target: { result: d } });
|
|
281
|
+
}, this._chunkLoaded = function(a) {
|
|
282
|
+
this._start += this._config.chunkSize, this._finished = !this._config.chunkSize || this._start >= this._input.size, this.parseChunk(a.target.result);
|
|
283
|
+
}, this._chunkError = function() {
|
|
284
|
+
this._sendError(e.error);
|
|
285
|
+
};
|
|
286
|
+
}
|
|
287
|
+
function ie(t) {
|
|
288
|
+
var e;
|
|
289
|
+
U.call(this, t = t || {}), this.stream = function(r) {
|
|
290
|
+
return e = r, this._nextChunk();
|
|
291
|
+
}, this._nextChunk = function() {
|
|
292
|
+
if (!this._finished) {
|
|
293
|
+
var r, n = this._config.chunkSize;
|
|
294
|
+
return n ? (r = e.substring(0, n), e = e.substring(n)) : (r = e, e = ""), this._finished = !e, this.parseChunk(r);
|
|
295
|
+
}
|
|
296
|
+
};
|
|
297
|
+
}
|
|
298
|
+
function ue(t) {
|
|
299
|
+
U.call(this, t = t || {});
|
|
300
|
+
var e = [], r = !0, n = !1;
|
|
301
|
+
this.pause = function() {
|
|
302
|
+
U.prototype.pause.apply(this, arguments), this._input.pause();
|
|
303
|
+
}, this.resume = function() {
|
|
304
|
+
U.prototype.resume.apply(this, arguments), this._input.resume();
|
|
305
|
+
}, this.stream = function(a) {
|
|
306
|
+
this._input = a, this._input.on("data", this._streamData), this._input.on("end", this._streamEnd), this._input.on("error", this._streamError);
|
|
307
|
+
}, this._checkIsFinished = function() {
|
|
308
|
+
n && e.length === 1 && (this._finished = !0);
|
|
309
|
+
}, this._nextChunk = function() {
|
|
310
|
+
this._checkIsFinished(), e.length ? this.parseChunk(e.shift()) : r = !0;
|
|
311
|
+
}, this._streamData = Z(function(a) {
|
|
312
|
+
try {
|
|
313
|
+
e.push(typeof a == "string" ? a : a.toString(this._config.encoding)), r && (r = !1, this._checkIsFinished(), this.parseChunk(e.shift()));
|
|
314
|
+
} catch (f) {
|
|
315
|
+
this._streamError(f);
|
|
316
|
+
}
|
|
317
|
+
}, this), this._streamError = Z(function(a) {
|
|
318
|
+
this._streamCleanUp(), this._sendError(a);
|
|
319
|
+
}, this), this._streamEnd = Z(function() {
|
|
320
|
+
this._streamCleanUp(), n = !0, this._streamData("");
|
|
321
|
+
}, this), this._streamCleanUp = Z(function() {
|
|
322
|
+
this._input.removeListener("data", this._streamData), this._input.removeListener("end", this._streamEnd), this._input.removeListener("error", this._streamError);
|
|
323
|
+
}, this);
|
|
324
|
+
}
|
|
325
|
+
function pe(t) {
|
|
326
|
+
var e, r, n, a = Math.pow(2, 53), f = -a, d = /^\s*-?(\d+\.?|\.\d+|\d+\.\d+)([eE][-+]?\d+)?\s*$/, B = /^((\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d:[0-5]\d\.\d+([+-][0-2]\d:[0-5]\d|Z))|(\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d:[0-5]\d([+-][0-2]\d:[0-5]\d|Z))|(\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d([+-][0-2]\d:[0-5]\d|Z)))$/, C = this, o = 0, x = 0, h = !1, j = !1, S = [], s = { data: [], errors: [], meta: {} };
|
|
327
|
+
if (_(t.step)) {
|
|
328
|
+
var k = t.step;
|
|
329
|
+
t.step = function(u) {
|
|
330
|
+
if (s = u, F())
|
|
331
|
+
R();
|
|
332
|
+
else {
|
|
333
|
+
if (R(), s.data.length === 0)
|
|
334
|
+
return;
|
|
335
|
+
o += u.data.length, t.preview && o > t.preview ? r.abort() : (s.data = s.data[0], k(s, C));
|
|
336
|
+
}
|
|
337
|
+
};
|
|
338
|
+
}
|
|
339
|
+
function M(u) {
|
|
340
|
+
return t.skipEmptyLines === "greedy" ? u.join("").trim() === "" : u.length === 1 && u[0].length === 0;
|
|
341
|
+
}
|
|
342
|
+
function R() {
|
|
343
|
+
return s && n && (L("Delimiter", "UndetectableDelimiter", "Unable to auto-detect delimiting character; defaulted to '" + l.DefaultDelimiter + "'"), n = !1), t.skipEmptyLines && (s.data = s.data.filter(function(u) {
|
|
344
|
+
return !M(u);
|
|
345
|
+
})), F() && function() {
|
|
346
|
+
if (!s)
|
|
347
|
+
return;
|
|
348
|
+
function u(b, I) {
|
|
349
|
+
_(t.transformHeader) && (b = t.transformHeader(b, I)), S.push(b);
|
|
350
|
+
}
|
|
351
|
+
if (Array.isArray(s.data[0])) {
|
|
352
|
+
for (var p = 0; F() && p < s.data.length; p++)
|
|
353
|
+
s.data[p].forEach(u);
|
|
354
|
+
s.data.splice(0, 1);
|
|
355
|
+
} else
|
|
356
|
+
s.data.forEach(u);
|
|
357
|
+
}(), function() {
|
|
358
|
+
if (!s || !t.header && !t.dynamicTyping && !t.transform)
|
|
359
|
+
return s;
|
|
360
|
+
function u(b, I) {
|
|
361
|
+
var y, T = t.header ? {} : [];
|
|
362
|
+
for (y = 0; y < b.length; y++) {
|
|
363
|
+
var O = y, v = b[y];
|
|
364
|
+
t.header && (O = y >= S.length ? "__parsed_extra" : S[y]), t.transform && (v = t.transform(v, O)), v = D(O, v), O === "__parsed_extra" ? (T[O] = T[O] || [], T[O].push(v)) : T[O] = v;
|
|
365
|
+
}
|
|
366
|
+
return t.header && (y > S.length ? L("FieldMismatch", "TooManyFields", "Too many fields: expected " + S.length + " fields but parsed " + y, x + I) : y < S.length && L("FieldMismatch", "TooFewFields", "Too few fields: expected " + S.length + " fields but parsed " + y, x + I)), T;
|
|
367
|
+
}
|
|
368
|
+
var p = 1;
|
|
369
|
+
return !s.data.length || Array.isArray(s.data[0]) ? (s.data = s.data.map(u), p = s.data.length) : s.data = u(s.data, 0), t.header && s.meta && (s.meta.fields = S), x += p, s;
|
|
370
|
+
}();
|
|
371
|
+
}
|
|
372
|
+
function F() {
|
|
373
|
+
return t.header && S.length === 0;
|
|
374
|
+
}
|
|
375
|
+
function D(u, p) {
|
|
376
|
+
return b = u, t.dynamicTypingFunction && t.dynamicTyping[b] === void 0 && (t.dynamicTyping[b] = t.dynamicTypingFunction(b)), (t.dynamicTyping[b] || t.dynamicTyping) === !0 ? p === "true" || p === "TRUE" || p !== "false" && p !== "FALSE" && (function(I) {
|
|
377
|
+
if (d.test(I)) {
|
|
378
|
+
var y = parseFloat(I);
|
|
379
|
+
if (f < y && y < a)
|
|
380
|
+
return !0;
|
|
381
|
+
}
|
|
382
|
+
return !1;
|
|
383
|
+
}(p) ? parseFloat(p) : B.test(p) ? new Date(p) : p === "" ? null : p) : p;
|
|
384
|
+
var b;
|
|
385
|
+
}
|
|
386
|
+
function L(u, p, b, I) {
|
|
387
|
+
var y = { type: u, code: p, message: b };
|
|
388
|
+
I !== void 0 && (y.row = I), s.errors.push(y);
|
|
389
|
+
}
|
|
390
|
+
this.parse = function(u, p, b) {
|
|
391
|
+
var I = t.quoteChar || '"';
|
|
392
|
+
if (t.newline || (t.newline = function(O, v) {
|
|
393
|
+
O = O.substring(0, 1048576);
|
|
394
|
+
var W = new RegExp(se(v) + "([^]*?)" + se(v), "gm"), N = (O = O.replace(W, "")).split("\r"), H = O.split(`
|
|
395
|
+
`), Q = 1 < H.length && H[0].length < N[0].length;
|
|
396
|
+
if (N.length === 1 || Q)
|
|
397
|
+
return `
|
|
398
|
+
`;
|
|
399
|
+
for (var P = 0, w = 0; w < N.length; w++)
|
|
400
|
+
N[w][0] === `
|
|
401
|
+
` && P++;
|
|
402
|
+
return P >= N.length / 2 ? `\r
|
|
403
|
+
` : "\r";
|
|
404
|
+
}(u, I)), n = !1, t.delimiter)
|
|
405
|
+
_(t.delimiter) && (t.delimiter = t.delimiter(u), s.meta.delimiter = t.delimiter);
|
|
406
|
+
else {
|
|
407
|
+
var y = function(O, v, W, N, H) {
|
|
408
|
+
var Q, P, w, A;
|
|
409
|
+
H = H || [",", " ", "|", ";", l.RECORD_SEP, l.UNIT_SEP];
|
|
410
|
+
for (var ee = 0; ee < H.length; ee++) {
|
|
411
|
+
var g = H[ee], re = 0, $ = 0, te = 0;
|
|
412
|
+
w = void 0;
|
|
413
|
+
for (var Y = new fe({ comments: N, delimiter: g, newline: v, preview: 10 }).parse(O), V = 0; V < Y.data.length; V++)
|
|
414
|
+
if (W && M(Y.data[V]))
|
|
415
|
+
te++;
|
|
416
|
+
else {
|
|
417
|
+
var X = Y.data[V].length;
|
|
418
|
+
$ += X, w !== void 0 ? 0 < X && (re += Math.abs(X - w), w = X) : w = X;
|
|
419
|
+
}
|
|
420
|
+
0 < Y.data.length && ($ /= Y.data.length - te), (P === void 0 || re <= P) && (A === void 0 || A < $) && 1.99 < $ && (P = re, Q = g, A = $);
|
|
421
|
+
}
|
|
422
|
+
return { successful: !!(t.delimiter = Q), bestDelimiter: Q };
|
|
423
|
+
}(u, t.newline, t.skipEmptyLines, t.comments, t.delimitersToGuess);
|
|
424
|
+
y.successful ? t.delimiter = y.bestDelimiter : (n = !0, t.delimiter = l.DefaultDelimiter), s.meta.delimiter = t.delimiter;
|
|
425
|
+
}
|
|
426
|
+
var T = le(t);
|
|
427
|
+
return t.preview && t.header && T.preview++, e = u, r = new fe(T), s = r.parse(e, p, b), R(), h ? { meta: { paused: !0 } } : s || { meta: { paused: !1 } };
|
|
428
|
+
}, this.paused = function() {
|
|
429
|
+
return h;
|
|
430
|
+
}, this.pause = function() {
|
|
431
|
+
h = !0, r.abort(), e = _(t.chunk) ? "" : e.substring(r.getCharIndex());
|
|
432
|
+
}, this.resume = function() {
|
|
433
|
+
C.streamer._halted ? (h = !1, C.streamer.parseChunk(e, !0)) : setTimeout(C.resume, 3);
|
|
434
|
+
}, this.aborted = function() {
|
|
435
|
+
return j;
|
|
436
|
+
}, this.abort = function() {
|
|
437
|
+
j = !0, r.abort(), s.meta.aborted = !0, _(t.complete) && t.complete(s), e = "";
|
|
438
|
+
};
|
|
439
|
+
}
|
|
440
|
+
function se(t) {
|
|
441
|
+
return t.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
442
|
+
}
|
|
443
|
+
function fe(t) {
|
|
444
|
+
var e, r = (t = t || {}).delimiter, n = t.newline, a = t.comments, f = t.step, d = t.preview, B = t.fastMode, C = e = t.quoteChar === void 0 || t.quoteChar === null ? '"' : t.quoteChar;
|
|
445
|
+
if (t.escapeChar !== void 0 && (C = t.escapeChar), (typeof r != "string" || -1 < l.BAD_DELIMITERS.indexOf(r)) && (r = ","), a === r)
|
|
446
|
+
throw new Error("Comment character same as delimiter");
|
|
447
|
+
a === !0 ? a = "#" : (typeof a != "string" || -1 < l.BAD_DELIMITERS.indexOf(a)) && (a = !1), n !== `
|
|
448
|
+
` && n !== "\r" && n !== `\r
|
|
449
|
+
` && (n = `
|
|
450
|
+
`);
|
|
451
|
+
var o = 0, x = !1;
|
|
452
|
+
this.parse = function(h, j, S) {
|
|
453
|
+
if (typeof h != "string")
|
|
454
|
+
throw new Error("Input must be a string");
|
|
455
|
+
var s = h.length, k = r.length, M = n.length, R = a.length, F = _(f), D = [], L = [], u = [], p = o = 0;
|
|
456
|
+
if (!h)
|
|
457
|
+
return q();
|
|
458
|
+
if (t.header && !j) {
|
|
459
|
+
var b = h.split(n)[0].split(r), I = [], y = {}, T = !1;
|
|
460
|
+
for (var O in b) {
|
|
461
|
+
var v = b[O];
|
|
462
|
+
_(t.transformHeader) && (v = t.transformHeader(v, O));
|
|
463
|
+
var W = v, N = y[v] || 0;
|
|
464
|
+
for (0 < N && (T = !0, W = v + "_" + N), y[v] = N + 1; I.includes(W); )
|
|
465
|
+
W = W + "_" + N;
|
|
466
|
+
I.push(W);
|
|
467
|
+
}
|
|
468
|
+
if (T) {
|
|
469
|
+
var H = h.split(n);
|
|
470
|
+
H[0] = I.join(r), h = H.join(n);
|
|
471
|
+
}
|
|
472
|
+
}
|
|
473
|
+
if (B || B !== !1 && h.indexOf(e) === -1) {
|
|
474
|
+
for (var Q = h.split(n), P = 0; P < Q.length; P++) {
|
|
475
|
+
if (u = Q[P], o += u.length, P !== Q.length - 1)
|
|
476
|
+
o += n.length;
|
|
477
|
+
else if (S)
|
|
478
|
+
return q();
|
|
479
|
+
if (!a || u.substring(0, R) !== a) {
|
|
480
|
+
if (F) {
|
|
481
|
+
if (D = [], te(u.split(r)), he(), x)
|
|
482
|
+
return q();
|
|
483
|
+
} else
|
|
484
|
+
te(u.split(r));
|
|
485
|
+
if (d && d <= P)
|
|
486
|
+
return D = D.slice(0, d), q(!0);
|
|
487
|
+
}
|
|
488
|
+
}
|
|
489
|
+
return q();
|
|
490
|
+
}
|
|
491
|
+
for (var w = h.indexOf(r, o), A = h.indexOf(n, o), ee = new RegExp(se(C) + se(e), "g"), g = h.indexOf(e, o); ; )
|
|
492
|
+
if (h[o] !== e)
|
|
493
|
+
if (a && u.length === 0 && h.substring(o, o + R) === a) {
|
|
494
|
+
if (A === -1)
|
|
495
|
+
return q();
|
|
496
|
+
o = A + M, A = h.indexOf(n, o), w = h.indexOf(r, o);
|
|
497
|
+
} else if (w !== -1 && (w < A || A === -1))
|
|
498
|
+
u.push(h.substring(o, w)), o = w + k, w = h.indexOf(r, o);
|
|
499
|
+
else {
|
|
500
|
+
if (A === -1)
|
|
501
|
+
break;
|
|
502
|
+
if (u.push(h.substring(o, A)), X(A + M), F && (he(), x))
|
|
503
|
+
return q();
|
|
504
|
+
if (d && D.length >= d)
|
|
505
|
+
return q(!0);
|
|
506
|
+
}
|
|
507
|
+
else
|
|
508
|
+
for (g = o, o++; ; ) {
|
|
509
|
+
if ((g = h.indexOf(e, g + 1)) === -1)
|
|
510
|
+
return S || L.push({ type: "Quotes", code: "MissingQuotes", message: "Quoted field unterminated", row: D.length, index: o }), V();
|
|
511
|
+
if (g === s - 1)
|
|
512
|
+
return V(h.substring(o, g).replace(ee, e));
|
|
513
|
+
if (e !== C || h[g + 1] !== C) {
|
|
514
|
+
if (e === C || g === 0 || h[g - 1] !== C) {
|
|
515
|
+
w !== -1 && w < g + 1 && (w = h.indexOf(r, g + 1)), A !== -1 && A < g + 1 && (A = h.indexOf(n, g + 1));
|
|
516
|
+
var re = Y(A === -1 ? w : Math.min(w, A));
|
|
517
|
+
if (h.substr(g + 1 + re, k) === r) {
|
|
518
|
+
u.push(h.substring(o, g).replace(ee, e)), h[o = g + 1 + re + k] !== e && (g = h.indexOf(e, o)), w = h.indexOf(r, o), A = h.indexOf(n, o);
|
|
519
|
+
break;
|
|
520
|
+
}
|
|
521
|
+
var $ = Y(A);
|
|
522
|
+
if (h.substring(g + 1 + $, g + 1 + $ + M) === n) {
|
|
523
|
+
if (u.push(h.substring(o, g).replace(ee, e)), X(g + 1 + $ + M), w = h.indexOf(r, o), g = h.indexOf(e, o), F && (he(), x))
|
|
524
|
+
return q();
|
|
525
|
+
if (d && D.length >= d)
|
|
526
|
+
return q(!0);
|
|
527
|
+
break;
|
|
528
|
+
}
|
|
529
|
+
L.push({ type: "Quotes", code: "InvalidQuotes", message: "Trailing quote on quoted field is malformed", row: D.length, index: o }), g++;
|
|
530
|
+
}
|
|
531
|
+
} else
|
|
532
|
+
g++;
|
|
533
|
+
}
|
|
534
|
+
return V();
|
|
535
|
+
function te(K) {
|
|
536
|
+
D.push(K), p = o;
|
|
537
|
+
}
|
|
538
|
+
function Y(K) {
|
|
539
|
+
var ye = 0;
|
|
540
|
+
if (K !== -1) {
|
|
541
|
+
var de = h.substring(g + 1, K);
|
|
542
|
+
de && de.trim() === "" && (ye = de.length);
|
|
543
|
+
}
|
|
544
|
+
return ye;
|
|
545
|
+
}
|
|
546
|
+
function V(K) {
|
|
547
|
+
return S || (K === void 0 && (K = h.substring(o)), u.push(K), o = s, te(u), F && he()), q();
|
|
548
|
+
}
|
|
549
|
+
function X(K) {
|
|
550
|
+
o = K, te(u), u = [], A = h.indexOf(n, o);
|
|
551
|
+
}
|
|
552
|
+
function q(K) {
|
|
553
|
+
return { data: D, errors: L, meta: { delimiter: r, linebreak: n, aborted: x, truncated: !!K, cursor: p + (j || 0) } };
|
|
554
|
+
}
|
|
555
|
+
function he() {
|
|
556
|
+
f(q()), D = [], L = [];
|
|
557
|
+
}
|
|
558
|
+
}, this.abort = function() {
|
|
559
|
+
x = !0;
|
|
560
|
+
}, this.getCharIndex = function() {
|
|
561
|
+
return o;
|
|
562
|
+
};
|
|
563
|
+
}
|
|
564
|
+
function ve(t) {
|
|
565
|
+
var e = t.data, r = J[e.workerId], n = !1;
|
|
566
|
+
if (e.error)
|
|
567
|
+
r.userError(e.error, e.file);
|
|
568
|
+
else if (e.results && e.results.data) {
|
|
569
|
+
var a = { abort: function() {
|
|
570
|
+
n = !0, ge(e.workerId, { data: [], errors: [], meta: { aborted: !0 } });
|
|
571
|
+
}, pause: _e, resume: _e };
|
|
572
|
+
if (_(r.userStep)) {
|
|
573
|
+
for (var f = 0; f < e.results.data.length && (r.userStep({ data: e.results.data[f], errors: e.results.errors, meta: e.results.meta }, a), !n); f++)
|
|
574
|
+
;
|
|
575
|
+
delete e.results;
|
|
576
|
+
} else
|
|
577
|
+
_(r.userChunk) && (r.userChunk(e.results, a, e.file), delete e.results);
|
|
578
|
+
}
|
|
579
|
+
e.finished && !n && ge(e.workerId, e.results);
|
|
580
|
+
}
|
|
581
|
+
function ge(t, e) {
|
|
582
|
+
var r = J[t];
|
|
583
|
+
_(r.userComplete) && r.userComplete(e), r.terminate(), delete J[t];
|
|
584
|
+
}
|
|
585
|
+
function _e() {
|
|
586
|
+
throw new Error("Not implemented.");
|
|
587
|
+
}
|
|
588
|
+
function le(t) {
|
|
589
|
+
if (typeof t != "object" || t === null)
|
|
590
|
+
return t;
|
|
591
|
+
var e = Array.isArray(t) ? [] : {};
|
|
592
|
+
for (var r in t)
|
|
593
|
+
e[r] = le(t[r]);
|
|
594
|
+
return e;
|
|
595
|
+
}
|
|
596
|
+
function Z(t, e) {
|
|
597
|
+
return function() {
|
|
598
|
+
t.apply(e, arguments);
|
|
599
|
+
};
|
|
600
|
+
}
|
|
601
|
+
function _(t) {
|
|
602
|
+
return typeof t == "function";
|
|
603
|
+
}
|
|
604
|
+
return G && (c.onmessage = function(t) {
|
|
605
|
+
var e = t.data;
|
|
606
|
+
if (l.WORKER_ID === void 0 && e && (l.WORKER_ID = e.workerId), typeof e.input == "string")
|
|
607
|
+
c.postMessage({ workerId: l.WORKER_ID, results: l.parse(e.input, e.config), finished: !0 });
|
|
608
|
+
else if (c.File && e.input instanceof File || e.input instanceof Object) {
|
|
609
|
+
var r = l.parse(e.input, e.config);
|
|
610
|
+
r && c.postMessage({ workerId: l.WORKER_ID, results: r, finished: !0 });
|
|
611
|
+
}
|
|
612
|
+
}), (ae.prototype = Object.create(U.prototype)).constructor = ae, (oe.prototype = Object.create(U.prototype)).constructor = oe, (ie.prototype = Object.create(ie.prototype)).constructor = ie, (ue.prototype = Object.create(U.prototype)).constructor = ue, l;
|
|
613
|
+
});
|
|
614
|
+
})(Ee);
|
|
52
615
|
export {
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
616
|
+
Le as createDownloadBlobLink,
|
|
617
|
+
be as downloadFile,
|
|
618
|
+
ke as flattenObject,
|
|
619
|
+
Ie as formatSizeUnit,
|
|
620
|
+
De as formatValueToMinUnit,
|
|
621
|
+
Re as isEmptyObj,
|
|
622
|
+
Ae as isJSONString,
|
|
623
|
+
xe as parseJSONSafely,
|
|
624
|
+
Oe as stringifyObjSafely,
|
|
625
|
+
Ce as unflattenObject
|
|
60
626
|
};
|
package/dist/index.umd.cjs
CHANGED
|
@@ -1 +1,15 @@
|
|
|
1
|
-
(function(
|
|
1
|
+
(function(N,ne){typeof exports=="object"&&typeof module<"u"?ne(exports):typeof define=="function"&&define.amd?define(["exports"],ne):(N=typeof globalThis<"u"?globalThis:N||self,ne(N["@emqx/shared-ui-utils"]={}))})(this,function(N){"use strict";const ne=(i,E=[],m={})=>{if(typeof i=="object"&&!Array.isArray(i)&&i!==null)for(const c of Object.keys(i))ne(i[c],E.concat(c),m);else m[E.join(".")]=i;return m},be=i=>{if(Object(i)!==i&&!Array.isArray(i))return i;const E=/\.?([^.[\]]+)|\[(\d+)\]/g,m={};try{for(const c in i){let W=m,Z="",H;for(;H=E.exec(c);)W=W[Z]||(W[Z]=H[2]?[]:{}),Z=H[2]||H[1];W[Z]=i[c]}}catch(c){console.error(c)}return m[""]||m},we=i=>Object.keys(i).length===0,Ee=i=>{try{return JSON.parse(i)}catch{console.error("An error occurred while parsing the JSON string")}},Ce=(i,E)=>{try{return typeof i=="string"?i:JSON.stringify(i,null,E)}catch(m){return console.error(m),"stringify error"}},Re=i=>{if(typeof i!="string")return!1;try{const E=JSON.parse(i);return typeof E=="object"&&E!==null}catch{return!1}},Oe=i=>{if(typeof i!="number"||isNaN(i)||i<0)throw new Error("Invalid input: input should be a non-negative number");if(i===0)return"0 Bytes";const E=["Bytes","KB","MB","GB","TB","PB","EB","ZB","YB"],m=Math.floor(Math.log(i)/Math.log(1024));return`${(i/1024**m).toFixed(1)} ${E[m]}`};var de=(i=>(i[i.ms=1]="ms",i[i.s=1e3]="s",i[i.m=6e4]="m",i[i.h=36e5]="h",i[i.d=864e5]="d",i[i.B=1]="B",i[i.KB=1024]="KB",i[i.MB=1048576]="MB",i[i.GB=1073741824]="GB",i))(de||{});const xe=(i,E)=>{if(!(E in de))throw new Error(`Invalid unit: ${E}`);return i*de[E]},_e=(i,E)=>{const m=document.createElement("a");m.style.display="none",m.href=i,m.download=E,document.body.appendChild(m),m.click(),document.body.removeChild(m)},Ae=(i,E)=>{const m=window.URL.createObjectURL(new Blob([i]));_e(m,E),window.URL.revokeObjectURL(m)};var Ie=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},De={exports:{}};/* @license
|
|
2
|
+
Papa Parse
|
|
3
|
+
v5.4.1
|
|
4
|
+
https://github.com/mholt/PapaParse
|
|
5
|
+
License: MIT
|
|
6
|
+
*/(function(i,E){(function(m,c){i.exports=c()})(Ie,function m(){var c=typeof self<"u"?self:typeof window<"u"?window:c!==void 0?c:{},W=!c.document&&!!c.postMessage,Z=c.IS_PAPA_WORKER||!1,H={},Le=0,l={parse:function(t,e){var r=(e=e||{}).dynamicTyping||!1;if(_(r)&&(e.dynamicTypingFunction=r,r={}),e.dynamicTyping=r,e.transform=!!_(e.transform)&&e.transform,e.worker&&l.WORKERS_SUPPORTED){var n=function(){if(!l.WORKERS_SUPPORTED)return!1;var f=(S=c.URL||c.webkitURL||null,C=m.toString(),l.BLOB_URL||(l.BLOB_URL=S.createObjectURL(new Blob(["var global = (function() { if (typeof self !== 'undefined') { return self; } if (typeof window !== 'undefined') { return window; } if (typeof global !== 'undefined') { return global; } return {}; })(); global.IS_PAPA_WORKER=true; ","(",C,")();"],{type:"text/javascript"})))),d=new c.Worker(f),S,C;return d.onmessage=Se,d.id=Le++,H[d.id]=d}();return n.userStep=e.step,n.userChunk=e.chunk,n.userComplete=e.complete,n.userError=e.error,e.step=_(e.step),e.chunk=_(e.chunk),e.complete=_(e.complete),e.error=_(e.error),delete e.worker,void n.postMessage({input:t,config:e,workerId:n.id})}var a=null;return l.NODE_STREAM_INPUT,typeof t=="string"?(t=function(f){return f.charCodeAt(0)===65279?f.slice(1):f}(t),a=e.download?new ue(e):new ae(e)):t.readable===!0&&_(t.read)&&_(t.on)?a=new fe(e):(c.File&&t instanceof File||t instanceof Object)&&(a=new he(e)),a.stream(t)},unparse:function(t,e){var r=!1,n=!0,a=",",f=`\r
|
|
7
|
+
`,d='"',S=d+d,C=!1,o=null,O=!1;(function(){if(typeof e=="object"){if(typeof e.delimiter!="string"||l.BAD_DELIMITERS.filter(function(s){return e.delimiter.indexOf(s)!==-1}).length||(a=e.delimiter),(typeof e.quotes=="boolean"||typeof e.quotes=="function"||Array.isArray(e.quotes))&&(r=e.quotes),typeof e.skipEmptyLines!="boolean"&&typeof e.skipEmptyLines!="string"||(C=e.skipEmptyLines),typeof e.newline=="string"&&(f=e.newline),typeof e.quoteChar=="string"&&(d=e.quoteChar),typeof e.header=="boolean"&&(n=e.header),Array.isArray(e.columns)){if(e.columns.length===0)throw new Error("Option columns is empty");o=e.columns}e.escapeChar!==void 0&&(S=e.escapeChar+d),(typeof e.escapeFormulae=="boolean"||e.escapeFormulae instanceof RegExp)&&(O=e.escapeFormulae instanceof RegExp?e.escapeFormulae:/^[=+\-@\t\r].*$/)}})();var h=new RegExp(oe(d),"g");if(typeof t=="string"&&(t=JSON.parse(t)),Array.isArray(t)){if(!t.length||Array.isArray(t[0]))return z(null,t,C);if(typeof t[0]=="object")return z(o||Object.keys(t[0]),t,C)}else if(typeof t=="object")return typeof t.data=="string"&&(t.data=JSON.parse(t.data)),Array.isArray(t.data)&&(t.fields||(t.fields=t.meta&&t.meta.fields||o),t.fields||(t.fields=Array.isArray(t.data[0])?t.fields:typeof t.data[0]=="object"?Object.keys(t.data[0]):[]),Array.isArray(t.data[0])||typeof t.data[0]=="object"||(t.data=[t.data])),z(t.fields||[],t.data||[],C);throw new Error("Unable to serialize unrecognized input");function z(s,k,T){var R="";typeof s=="string"&&(s=JSON.parse(s)),typeof k=="string"&&(k=JSON.parse(k));var B=Array.isArray(s)&&0<s.length,D=!Array.isArray(k[0]);if(B&&n){for(var L=0;L<s.length;L++)0<L&&(R+=a),R+=F(s[L],L);0<k.length&&(R+=f)}for(var u=0;u<k.length;u++){var p=B?s.length:k[u].length,b=!1,I=B?Object.keys(k[u]).length===0:k[u].length===0;if(T&&!B&&(b=T==="greedy"?k[u].join("").trim()==="":k[u].length===1&&k[u][0].length===0),T==="greedy"&&B){for(var y=[],M=0;M<p;M++){var x=D?s[M]:M;y.push(k[u][x])}b=y.join("").trim()===""}if(!b){for(var v=0;v<p;v++){0<v&&!I&&(R+=a);var J=B&&D?s[v]:v;R+=F(k[u][J],v)}u<k.length-1&&(!T||0<p&&!I)&&(R+=f)}}return R}function F(s,k){if(s==null)return"";if(s.constructor===Date)return JSON.stringify(s).slice(1,25);var T=!1;O&&typeof s=="string"&&O.test(s)&&(s="'"+s,T=!0);var R=s.toString().replace(h,S);return(T=T||r===!0||typeof r=="function"&&r(s,k)||Array.isArray(r)&&r[k]||function(B,D){for(var L=0;L<D.length;L++)if(-1<B.indexOf(D[L]))return!0;return!1}(R,l.BAD_DELIMITERS)||-1<R.indexOf(a)||R.charAt(0)===" "||R.charAt(R.length-1)===" ")?d+R+d:R}}};if(l.RECORD_SEP=String.fromCharCode(30),l.UNIT_SEP=String.fromCharCode(31),l.BYTE_ORDER_MARK="\uFEFF",l.BAD_DELIMITERS=["\r",`
|
|
8
|
+
`,'"',l.BYTE_ORDER_MARK],l.WORKERS_SUPPORTED=!W&&!!c.Worker,l.NODE_STREAM_INPUT=1,l.LocalChunkSize=10485760,l.RemoteChunkSize=5242880,l.DefaultDelimiter=",",l.Parser=ce,l.ParserHandle=ye,l.NetworkStreamer=ue,l.FileStreamer=he,l.StringStreamer=ae,l.ReadableStreamStreamer=fe,c.jQuery){var se=c.jQuery;se.fn.parse=function(t){var e=t.config||{},r=[];return this.each(function(f){if(!(se(this).prop("tagName").toUpperCase()==="INPUT"&&se(this).attr("type").toLowerCase()==="file"&&c.FileReader)||!this.files||this.files.length===0)return!0;for(var d=0;d<this.files.length;d++)r.push({file:this.files[d],inputElem:this,instanceConfig:se.extend({},e)})}),n(),this;function n(){if(r.length!==0){var f,d,S,C,o=r[0];if(_(t.before)){var O=t.before(o.file,o.inputElem);if(typeof O=="object"){if(O.action==="abort")return f="AbortError",d=o.file,S=o.inputElem,C=O.reason,void(_(t.error)&&t.error({name:f},d,S,C));if(O.action==="skip")return void a();typeof O.config=="object"&&(o.instanceConfig=se.extend(o.instanceConfig,O.config))}else if(O==="skip")return void a()}var h=o.instanceConfig.complete;o.instanceConfig.complete=function(z){_(h)&&h(z,o.file,o.inputElem),a()},l.parse(o.file,o.instanceConfig)}else _(t.complete)&&t.complete()}function a(){r.splice(0,1),n()}}}function Q(t){this._handle=null,this._finished=!1,this._completed=!1,this._halted=!1,this._input=null,this._baseIndex=0,this._partialLine="",this._rowCount=0,this._start=0,this._nextChunk=null,this.isFirstChunk=!0,this._completeResults={data:[],errors:[],meta:{}},(function(e){var r=pe(e);r.chunkSize=parseInt(r.chunkSize),e.step||e.chunk||(r.chunkSize=null),this._handle=new ye(r),(this._handle.streamer=this)._config=r}).call(this,t),this.parseChunk=function(e,r){if(this.isFirstChunk&&_(this._config.beforeFirstChunk)){var n=this._config.beforeFirstChunk(e);n!==void 0&&(e=n)}this.isFirstChunk=!1,this._halted=!1;var a=this._partialLine+e;this._partialLine="";var f=this._handle.parse(a,this._baseIndex,!this._finished);if(!this._handle.paused()&&!this._handle.aborted()){var d=f.meta.cursor;this._finished||(this._partialLine=a.substring(d-this._baseIndex),this._baseIndex=d),f&&f.data&&(this._rowCount+=f.data.length);var S=this._finished||this._config.preview&&this._rowCount>=this._config.preview;if(Z)c.postMessage({results:f,workerId:l.WORKER_ID,finished:S});else if(_(this._config.chunk)&&!r){if(this._config.chunk(f,this._handle),this._handle.paused()||this._handle.aborted())return void(this._halted=!0);f=void 0,this._completeResults=void 0}return this._config.step||this._config.chunk||(this._completeResults.data=this._completeResults.data.concat(f.data),this._completeResults.errors=this._completeResults.errors.concat(f.errors),this._completeResults.meta=f.meta),this._completed||!S||!_(this._config.complete)||f&&f.meta.aborted||(this._config.complete(this._completeResults,this._input),this._completed=!0),S||f&&f.meta.paused||this._nextChunk(),f}this._halted=!0},this._sendError=function(e){_(this._config.error)?this._config.error(e):Z&&this._config.error&&c.postMessage({workerId:l.WORKER_ID,error:e,finished:!1})}}function ue(t){var e;(t=t||{}).chunkSize||(t.chunkSize=l.RemoteChunkSize),Q.call(this,t),this._nextChunk=W?function(){this._readChunk(),this._chunkLoaded()}:function(){this._readChunk()},this.stream=function(r){this._input=r,this._nextChunk()},this._readChunk=function(){if(this._finished)this._chunkLoaded();else{if(e=new XMLHttpRequest,this._config.withCredentials&&(e.withCredentials=this._config.withCredentials),W||(e.onload=Y(this._chunkLoaded,this),e.onerror=Y(this._chunkError,this)),e.open(this._config.downloadRequestBody?"POST":"GET",this._input,!W),this._config.downloadRequestHeaders){var r=this._config.downloadRequestHeaders;for(var n in r)e.setRequestHeader(n,r[n])}if(this._config.chunkSize){var a=this._start+this._config.chunkSize-1;e.setRequestHeader("Range","bytes="+this._start+"-"+a)}try{e.send(this._config.downloadRequestBody)}catch(f){this._chunkError(f.message)}W&&e.status===0&&this._chunkError()}},this._chunkLoaded=function(){e.readyState===4&&(e.status<200||400<=e.status?this._chunkError():(this._start+=this._config.chunkSize?this._config.chunkSize:e.responseText.length,this._finished=!this._config.chunkSize||this._start>=function(r){var n=r.getResponseHeader("Content-Range");return n===null?-1:parseInt(n.substring(n.lastIndexOf("/")+1))}(e),this.parseChunk(e.responseText)))},this._chunkError=function(r){var n=e.statusText||r;this._sendError(new Error(n))}}function he(t){var e,r;(t=t||{}).chunkSize||(t.chunkSize=l.LocalChunkSize),Q.call(this,t);var n=typeof FileReader<"u";this.stream=function(a){this._input=a,r=a.slice||a.webkitSlice||a.mozSlice,n?((e=new FileReader).onload=Y(this._chunkLoaded,this),e.onerror=Y(this._chunkError,this)):e=new FileReaderSync,this._nextChunk()},this._nextChunk=function(){this._finished||this._config.preview&&!(this._rowCount<this._config.preview)||this._readChunk()},this._readChunk=function(){var a=this._input;if(this._config.chunkSize){var f=Math.min(this._start+this._config.chunkSize,this._input.size);a=r.call(a,this._start,f)}var d=e.readAsText(a,this._config.encoding);n||this._chunkLoaded({target:{result:d}})},this._chunkLoaded=function(a){this._start+=this._config.chunkSize,this._finished=!this._config.chunkSize||this._start>=this._input.size,this.parseChunk(a.target.result)},this._chunkError=function(){this._sendError(e.error)}}function ae(t){var e;Q.call(this,t=t||{}),this.stream=function(r){return e=r,this._nextChunk()},this._nextChunk=function(){if(!this._finished){var r,n=this._config.chunkSize;return n?(r=e.substring(0,n),e=e.substring(n)):(r=e,e=""),this._finished=!e,this.parseChunk(r)}}}function fe(t){Q.call(this,t=t||{});var e=[],r=!0,n=!1;this.pause=function(){Q.prototype.pause.apply(this,arguments),this._input.pause()},this.resume=function(){Q.prototype.resume.apply(this,arguments),this._input.resume()},this.stream=function(a){this._input=a,this._input.on("data",this._streamData),this._input.on("end",this._streamEnd),this._input.on("error",this._streamError)},this._checkIsFinished=function(){n&&e.length===1&&(this._finished=!0)},this._nextChunk=function(){this._checkIsFinished(),e.length?this.parseChunk(e.shift()):r=!0},this._streamData=Y(function(a){try{e.push(typeof a=="string"?a:a.toString(this._config.encoding)),r&&(r=!1,this._checkIsFinished(),this.parseChunk(e.shift()))}catch(f){this._streamError(f)}},this),this._streamError=Y(function(a){this._streamCleanUp(),this._sendError(a)},this),this._streamEnd=Y(function(){this._streamCleanUp(),n=!0,this._streamData("")},this),this._streamCleanUp=Y(function(){this._input.removeListener("data",this._streamData),this._input.removeListener("end",this._streamEnd),this._input.removeListener("error",this._streamError)},this)}function ye(t){var e,r,n,a=Math.pow(2,53),f=-a,d=/^\s*-?(\d+\.?|\.\d+|\d+\.\d+)([eE][-+]?\d+)?\s*$/,S=/^((\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d:[0-5]\d\.\d+([+-][0-2]\d:[0-5]\d|Z))|(\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d:[0-5]\d([+-][0-2]\d:[0-5]\d|Z))|(\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d([+-][0-2]\d:[0-5]\d|Z)))$/,C=this,o=0,O=0,h=!1,z=!1,F=[],s={data:[],errors:[],meta:{}};if(_(t.step)){var k=t.step;t.step=function(u){if(s=u,B())R();else{if(R(),s.data.length===0)return;o+=u.data.length,t.preview&&o>t.preview?r.abort():(s.data=s.data[0],k(s,C))}}}function T(u){return t.skipEmptyLines==="greedy"?u.join("").trim()==="":u.length===1&&u[0].length===0}function R(){return s&&n&&(L("Delimiter","UndetectableDelimiter","Unable to auto-detect delimiting character; defaulted to '"+l.DefaultDelimiter+"'"),n=!1),t.skipEmptyLines&&(s.data=s.data.filter(function(u){return!T(u)})),B()&&function(){if(!s)return;function u(b,I){_(t.transformHeader)&&(b=t.transformHeader(b,I)),F.push(b)}if(Array.isArray(s.data[0])){for(var p=0;B()&&p<s.data.length;p++)s.data[p].forEach(u);s.data.splice(0,1)}else s.data.forEach(u)}(),function(){if(!s||!t.header&&!t.dynamicTyping&&!t.transform)return s;function u(b,I){var y,M=t.header?{}:[];for(y=0;y<b.length;y++){var x=y,v=b[y];t.header&&(x=y>=F.length?"__parsed_extra":F[y]),t.transform&&(v=t.transform(v,x)),v=D(x,v),x==="__parsed_extra"?(M[x]=M[x]||[],M[x].push(v)):M[x]=v}return t.header&&(y>F.length?L("FieldMismatch","TooManyFields","Too many fields: expected "+F.length+" fields but parsed "+y,O+I):y<F.length&&L("FieldMismatch","TooFewFields","Too few fields: expected "+F.length+" fields but parsed "+y,O+I)),M}var p=1;return!s.data.length||Array.isArray(s.data[0])?(s.data=s.data.map(u),p=s.data.length):s.data=u(s.data,0),t.header&&s.meta&&(s.meta.fields=F),O+=p,s}()}function B(){return t.header&&F.length===0}function D(u,p){return b=u,t.dynamicTypingFunction&&t.dynamicTyping[b]===void 0&&(t.dynamicTyping[b]=t.dynamicTypingFunction(b)),(t.dynamicTyping[b]||t.dynamicTyping)===!0?p==="true"||p==="TRUE"||p!=="false"&&p!=="FALSE"&&(function(I){if(d.test(I)){var y=parseFloat(I);if(f<y&&y<a)return!0}return!1}(p)?parseFloat(p):S.test(p)?new Date(p):p===""?null:p):p;var b}function L(u,p,b,I){var y={type:u,code:p,message:b};I!==void 0&&(y.row=I),s.errors.push(y)}this.parse=function(u,p,b){var I=t.quoteChar||'"';if(t.newline||(t.newline=function(x,v){x=x.substring(0,1048576);var J=new RegExp(oe(v)+"([^]*?)"+oe(v),"gm"),P=(x=x.replace(J,"")).split("\r"),U=x.split(`
|
|
9
|
+
`),$=1<U.length&&U[0].length<P[0].length;if(P.length===1||$)return`
|
|
10
|
+
`;for(var q=0,w=0;w<P.length;w++)P[w][0]===`
|
|
11
|
+
`&&q++;return q>=P.length/2?`\r
|
|
12
|
+
`:"\r"}(u,I)),n=!1,t.delimiter)_(t.delimiter)&&(t.delimiter=t.delimiter(u),s.meta.delimiter=t.delimiter);else{var y=function(x,v,J,P,U){var $,q,w,A;U=U||[","," ","|",";",l.RECORD_SEP,l.UNIT_SEP];for(var te=0;te<U.length;te++){var g=U[te],ie=0,G=0,re=0;w=void 0;for(var V=new ce({comments:P,delimiter:g,newline:v,preview:10}).parse(x),X=0;X<V.data.length;X++)if(J&&T(V.data[X]))re++;else{var ee=V.data[X].length;G+=ee,w!==void 0?0<ee&&(ie+=Math.abs(ee-w),w=ee):w=ee}0<V.data.length&&(G/=V.data.length-re),(q===void 0||ie<=q)&&(A===void 0||A<G)&&1.99<G&&(q=ie,$=g,A=G)}return{successful:!!(t.delimiter=$),bestDelimiter:$}}(u,t.newline,t.skipEmptyLines,t.comments,t.delimitersToGuess);y.successful?t.delimiter=y.bestDelimiter:(n=!0,t.delimiter=l.DefaultDelimiter),s.meta.delimiter=t.delimiter}var M=pe(t);return t.preview&&t.header&&M.preview++,e=u,r=new ce(M),s=r.parse(e,p,b),R(),h?{meta:{paused:!0}}:s||{meta:{paused:!1}}},this.paused=function(){return h},this.pause=function(){h=!0,r.abort(),e=_(t.chunk)?"":e.substring(r.getCharIndex())},this.resume=function(){C.streamer._halted?(h=!1,C.streamer.parseChunk(e,!0)):setTimeout(C.resume,3)},this.aborted=function(){return z},this.abort=function(){z=!0,r.abort(),s.meta.aborted=!0,_(t.complete)&&t.complete(s),e=""}}function oe(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function ce(t){var e,r=(t=t||{}).delimiter,n=t.newline,a=t.comments,f=t.step,d=t.preview,S=t.fastMode,C=e=t.quoteChar===void 0||t.quoteChar===null?'"':t.quoteChar;if(t.escapeChar!==void 0&&(C=t.escapeChar),(typeof r!="string"||-1<l.BAD_DELIMITERS.indexOf(r))&&(r=","),a===r)throw new Error("Comment character same as delimiter");a===!0?a="#":(typeof a!="string"||-1<l.BAD_DELIMITERS.indexOf(a))&&(a=!1),n!==`
|
|
13
|
+
`&&n!=="\r"&&n!==`\r
|
|
14
|
+
`&&(n=`
|
|
15
|
+
`);var o=0,O=!1;this.parse=function(h,z,F){if(typeof h!="string")throw new Error("Input must be a string");var s=h.length,k=r.length,T=n.length,R=a.length,B=_(f),D=[],L=[],u=[],p=o=0;if(!h)return j();if(t.header&&!z){var b=h.split(n)[0].split(r),I=[],y={},M=!1;for(var x in b){var v=b[x];_(t.transformHeader)&&(v=t.transformHeader(v,x));var J=v,P=y[v]||0;for(0<P&&(M=!0,J=v+"_"+P),y[v]=P+1;I.includes(J);)J=J+"_"+P;I.push(J)}if(M){var U=h.split(n);U[0]=I.join(r),h=U.join(n)}}if(S||S!==!1&&h.indexOf(e)===-1){for(var $=h.split(n),q=0;q<$.length;q++){if(u=$[q],o+=u.length,q!==$.length-1)o+=n.length;else if(F)return j();if(!a||u.substring(0,R)!==a){if(B){if(D=[],re(u.split(r)),le(),O)return j()}else re(u.split(r));if(d&&d<=q)return D=D.slice(0,d),j(!0)}}return j()}for(var w=h.indexOf(r,o),A=h.indexOf(n,o),te=new RegExp(oe(C)+oe(e),"g"),g=h.indexOf(e,o);;)if(h[o]!==e)if(a&&u.length===0&&h.substring(o,o+R)===a){if(A===-1)return j();o=A+T,A=h.indexOf(n,o),w=h.indexOf(r,o)}else if(w!==-1&&(w<A||A===-1))u.push(h.substring(o,w)),o=w+k,w=h.indexOf(r,o);else{if(A===-1)break;if(u.push(h.substring(o,A)),ee(A+T),B&&(le(),O))return j();if(d&&D.length>=d)return j(!0)}else for(g=o,o++;;){if((g=h.indexOf(e,g+1))===-1)return F||L.push({type:"Quotes",code:"MissingQuotes",message:"Quoted field unterminated",row:D.length,index:o}),X();if(g===s-1)return X(h.substring(o,g).replace(te,e));if(e!==C||h[g+1]!==C){if(e===C||g===0||h[g-1]!==C){w!==-1&&w<g+1&&(w=h.indexOf(r,g+1)),A!==-1&&A<g+1&&(A=h.indexOf(n,g+1));var ie=V(A===-1?w:Math.min(w,A));if(h.substr(g+1+ie,k)===r){u.push(h.substring(o,g).replace(te,e)),h[o=g+1+ie+k]!==e&&(g=h.indexOf(e,o)),w=h.indexOf(r,o),A=h.indexOf(n,o);break}var G=V(A);if(h.substring(g+1+G,g+1+G+T)===n){if(u.push(h.substring(o,g).replace(te,e)),ee(g+1+G+T),w=h.indexOf(r,o),g=h.indexOf(e,o),B&&(le(),O))return j();if(d&&D.length>=d)return j(!0);break}L.push({type:"Quotes",code:"InvalidQuotes",message:"Trailing quote on quoted field is malformed",row:D.length,index:o}),g++}}else g++}return X();function re(K){D.push(K),p=o}function V(K){var ke=0;if(K!==-1){var ge=h.substring(g+1,K);ge&&ge.trim()===""&&(ke=ge.length)}return ke}function X(K){return F||(K===void 0&&(K=h.substring(o)),u.push(K),o=s,re(u),B&&le()),j()}function ee(K){o=K,re(u),u=[],A=h.indexOf(n,o)}function j(K){return{data:D,errors:L,meta:{delimiter:r,linebreak:n,aborted:O,truncated:!!K,cursor:p+(z||0)}}}function le(){f(j()),D=[],L=[]}},this.abort=function(){O=!0},this.getCharIndex=function(){return o}}function Se(t){var e=t.data,r=H[e.workerId],n=!1;if(e.error)r.userError(e.error,e.file);else if(e.results&&e.results.data){var a={abort:function(){n=!0,me(e.workerId,{data:[],errors:[],meta:{aborted:!0}})},pause:ve,resume:ve};if(_(r.userStep)){for(var f=0;f<e.results.data.length&&(r.userStep({data:e.results.data[f],errors:e.results.errors,meta:e.results.meta},a),!n);f++);delete e.results}else _(r.userChunk)&&(r.userChunk(e.results,a,e.file),delete e.results)}e.finished&&!n&&me(e.workerId,e.results)}function me(t,e){var r=H[t];_(r.userComplete)&&r.userComplete(e),r.terminate(),delete H[t]}function ve(){throw new Error("Not implemented.")}function pe(t){if(typeof t!="object"||t===null)return t;var e=Array.isArray(t)?[]:{};for(var r in t)e[r]=pe(t[r]);return e}function Y(t,e){return function(){t.apply(e,arguments)}}function _(t){return typeof t=="function"}return Z&&(c.onmessage=function(t){var e=t.data;if(l.WORKER_ID===void 0&&e&&(l.WORKER_ID=e.workerId),typeof e.input=="string")c.postMessage({workerId:l.WORKER_ID,results:l.parse(e.input,e.config),finished:!0});else if(c.File&&e.input instanceof File||e.input instanceof Object){var r=l.parse(e.input,e.config);r&&c.postMessage({workerId:l.WORKER_ID,results:r,finished:!0})}}),(ue.prototype=Object.create(Q.prototype)).constructor=ue,(he.prototype=Object.create(Q.prototype)).constructor=he,(ae.prototype=Object.create(ae.prototype)).constructor=ae,(fe.prototype=Object.create(Q.prototype)).constructor=fe,l})})(De),N.createDownloadBlobLink=Ae,N.downloadFile=_e,N.flattenObject=ne,N.formatSizeUnit=Oe,N.formatValueToMinUnit=xe,N.isEmptyObj=we,N.isJSONString=Re,N.parseJSONSafely=Ee,N.stringifyObjSafely=Ce,N.unflattenObject=be,Object.defineProperty(N,Symbol.toStringTag,{value:"Module"})});
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
declare const _default: (locale?: 'zh' | 'en') => {
|
|
2
|
+
filenameMap: {
|
|
3
|
+
influxdb: string;
|
|
4
|
+
tdengine: string;
|
|
5
|
+
iotdb: string;
|
|
6
|
+
};
|
|
7
|
+
templateContentMap: {
|
|
8
|
+
tdengine: string;
|
|
9
|
+
iotdb: string;
|
|
10
|
+
influxdb: string;
|
|
11
|
+
};
|
|
12
|
+
handleDownloadTemp: (template?: string, filename?: string) => void;
|
|
13
|
+
readFileAndParse: (file: File, maxRows: number) => Promise<string[][]>;
|
|
14
|
+
processIoTDBData: (data: string[][]) => Promise<Array<Record<string, any>>>;
|
|
15
|
+
processTDengineData: (data: string[][]) => Promise<string>;
|
|
16
|
+
processInfluxDBData: (data: string[][]) => Promise<{
|
|
17
|
+
key: string;
|
|
18
|
+
value: string;
|
|
19
|
+
}[]>;
|
|
20
|
+
};
|
|
21
|
+
export default _default;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@emqx/shared-ui-utils",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.12",
|
|
4
4
|
"homepage": "https://emqx.io",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"repository": {
|
|
@@ -24,6 +24,13 @@
|
|
|
24
24
|
"require": "./dist/index.umd.cjs"
|
|
25
25
|
}
|
|
26
26
|
},
|
|
27
|
+
"dependencies": {
|
|
28
|
+
"papaparse": "^5.4.1",
|
|
29
|
+
"vue-i18n": "^9.10.2"
|
|
30
|
+
},
|
|
31
|
+
"devDependencies": {
|
|
32
|
+
"@types/papaparse": "^5.3.14"
|
|
33
|
+
},
|
|
27
34
|
"scripts": {
|
|
28
35
|
"dev": "vite",
|
|
29
36
|
"build": "tsc && vite build",
|