@langeditor/plugin-spreadsheet 0.0.0-stage → 1.1.4
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/LICENSE +21 -0
- package/PRD.md +72 -0
- package/README.md +82 -2
- package/dist/chunks/SpreadsheetSurface-C5IFZ3LB.js +1762 -0
- package/dist/chunks/csv-DF3_VfSt.js +506 -0
- package/dist/chunks/exceljs.min-DrDLmZv4.js +32079 -0
- package/dist/chunks/source-BxpnMm0o.js +37 -0
- package/dist/chunks/workbook-CY5eURLn.js +351 -0
- package/dist/chunks/xlsx-DGiNLc4q.js +17499 -0
- package/dist/components/SpreadsheetStatus.vue.d.ts +7 -0
- package/dist/components/SpreadsheetSurface.vue.d.ts +37 -0
- package/dist/components/SpreadsheetToolbar.vue.d.ts +7 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.es.js +647 -0
- package/dist/locales/en.d.ts +57 -0
- package/dist/locales/zh.d.ts +57 -0
- package/dist/manifest.d.ts +10 -0
- package/dist/model/workbook.d.ts +55 -0
- package/dist/plugin.d.ts +1 -0
- package/dist/serializers/csv.d.ts +7 -0
- package/dist/serializers/index.d.ts +7 -0
- package/dist/serializers/source.d.ts +6 -0
- package/dist/serializers/xlsx.d.ts +6 -0
- package/dist/style.css +3 -0
- package/dist/types.d.ts +176 -0
- package/package.json +68 -3
|
@@ -0,0 +1,506 @@
|
|
|
1
|
+
import { f as e, g as t, m as n, n as r, p as i, s as a } from "./workbook-CY5eURLn.js";
|
|
2
|
+
//#region ../../node_modules/.pnpm/papaparse@5.7.0/node_modules/papaparse/papaparse.min.js
|
|
3
|
+
var o = /* @__PURE__ */ i(((e, t) => {
|
|
4
|
+
((n, r) => {
|
|
5
|
+
typeof define == "function" && define.amd ? define([], r) : typeof t == "object" && e !== void 0 ? t.exports = r() : n.Papa = r();
|
|
6
|
+
})(e, function e() {
|
|
7
|
+
var t = typeof self < "u" ? self : typeof window < "u" ? window : t === void 0 ? {} : t, n = !t.document && !!t.postMessage, r = t.IS_PAPA_WORKER || !1, i = {}, a = 0, o = {};
|
|
8
|
+
function s(e) {
|
|
9
|
+
return e.charCodeAt(0) === 65279 ? e.slice(1) : e;
|
|
10
|
+
}
|
|
11
|
+
function c(e) {
|
|
12
|
+
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 = {
|
|
13
|
+
data: [],
|
|
14
|
+
errors: [],
|
|
15
|
+
meta: {}
|
|
16
|
+
}, function(e) {
|
|
17
|
+
var t = y(e);
|
|
18
|
+
t.chunkSize = parseInt(t.chunkSize), e.step || e.chunk || (t.chunkSize = null), this._handle = new p(t), (this._handle.streamer = this)._config = t;
|
|
19
|
+
}.call(this, e), this.parseChunk = function(e, n) {
|
|
20
|
+
var i = parseInt(this._config.skipFirstNLines) || 0;
|
|
21
|
+
if (this.isFirstChunk && 0 < i) {
|
|
22
|
+
let t = this._config.newline;
|
|
23
|
+
t ||= (a = this._config.quoteChar || "\"", this._handle.guessLineEndings(e, a)), e = [...e.split(t).slice(i)].join(t);
|
|
24
|
+
}
|
|
25
|
+
this.isFirstChunk && x(this._config.beforeFirstChunk) && (a = this._config.beforeFirstChunk(e)) !== void 0 && (e = a), this.isFirstChunk = !1, this._halted = !1;
|
|
26
|
+
var i = this._partialLine + e, a = (this._partialLine = "", this._handle.parse(i, this._baseIndex, !this._finished));
|
|
27
|
+
if (!this._handle.paused() && !this._handle.aborted()) {
|
|
28
|
+
if (e = a.meta.cursor, i = (this._finished || (this._partialLine = i.substring(e - this._baseIndex), this._baseIndex = e), a && a.data && (this._rowCount += a.data.length), this._finished || this._config.preview && this._rowCount >= this._config.preview), r) t.postMessage({
|
|
29
|
+
results: a,
|
|
30
|
+
workerId: o.WORKER_ID,
|
|
31
|
+
finished: i
|
|
32
|
+
});
|
|
33
|
+
else if (x(this._config.chunk) && !n) {
|
|
34
|
+
if (this._config.chunk(a, this._handle), this._handle.paused() || this._handle.aborted()) return void (this._halted = !0);
|
|
35
|
+
this._completeResults = a = void 0;
|
|
36
|
+
}
|
|
37
|
+
return this._config.step || this._config.chunk || (this._completeResults.data = this._completeResults.data.concat(a.data), this._completeResults.errors = this._completeResults.errors.concat(a.errors), this._completeResults.meta = a.meta), this._completed || !i || !x(this._config.complete) || a && a.meta.aborted || (this._config.complete(this._completeResults, this._input), this._completed = !0), i || a && a.meta.paused || this._nextChunk(), a;
|
|
38
|
+
}
|
|
39
|
+
this._halted = !0;
|
|
40
|
+
}, this._sendError = function(e) {
|
|
41
|
+
x(this._config.error) ? this._config.error(e) : r && this._config.error && t.postMessage({
|
|
42
|
+
workerId: o.WORKER_ID,
|
|
43
|
+
error: e,
|
|
44
|
+
finished: !1
|
|
45
|
+
});
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
function l(e) {
|
|
49
|
+
var t;
|
|
50
|
+
(e ||= {}).chunkSize || (e.chunkSize = o.RemoteChunkSize), c.call(this, e), this._nextChunk = n ? function() {
|
|
51
|
+
this._readChunk(), this._chunkLoaded();
|
|
52
|
+
} : function() {
|
|
53
|
+
this._readChunk();
|
|
54
|
+
}, this.stream = function(e) {
|
|
55
|
+
this._input = e, this._nextChunk();
|
|
56
|
+
}, this._readChunk = function() {
|
|
57
|
+
if (this._finished) this._chunkLoaded();
|
|
58
|
+
else {
|
|
59
|
+
if (t = new XMLHttpRequest(), this._config.withCredentials && (t.withCredentials = this._config.withCredentials), n || (t.onload = b(this._chunkLoaded, this), t.onerror = b(this._chunkError, this)), t.ontimeout = b(this._chunkTimeout, this), t.open(this._config.downloadRequestBody ? "POST" : "GET", this._input, !n), this._config.downloadTimeout && !n && (t.timeout = this._config.downloadTimeout), this._config.downloadRequestHeaders) {
|
|
60
|
+
var e, r = this._config.downloadRequestHeaders;
|
|
61
|
+
for (e in r) t.setRequestHeader(e, r[e]);
|
|
62
|
+
}
|
|
63
|
+
var i;
|
|
64
|
+
this._config.chunkSize && (i = this._start + this._config.chunkSize - 1, t.setRequestHeader("Range", "bytes=" + this._start + "-" + i));
|
|
65
|
+
try {
|
|
66
|
+
t.send(this._config.downloadRequestBody);
|
|
67
|
+
} catch (e) {
|
|
68
|
+
this._chunkError(e.message);
|
|
69
|
+
}
|
|
70
|
+
n && t.status === 0 && this._chunkError();
|
|
71
|
+
}
|
|
72
|
+
}, this._chunkLoaded = function() {
|
|
73
|
+
t.readyState === 4 && (t.status < 200 || 400 <= t.status ? this._chunkError() : (this._start += this._config.chunkSize || t.responseText.length, this._finished = !this._config.chunkSize || this._start >= ((e) => (e = e.getResponseHeader("Content-Range")) === null ? -1 : parseInt(e.substring(e.lastIndexOf("/") + 1)))(t), this.parseChunk(t.responseText)));
|
|
74
|
+
}, this._chunkError = function(e) {
|
|
75
|
+
e = t.statusText || e, this._sendError(Error(e));
|
|
76
|
+
}, this._chunkTimeout = function() {
|
|
77
|
+
this._chunkError("Request timed out after " + this._config.downloadTimeout + "ms");
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
function u(e) {
|
|
81
|
+
(e ||= {}).chunkSize || (e.chunkSize = o.LocalChunkSize), c.call(this, e);
|
|
82
|
+
var t, n, r = typeof FileReader < "u";
|
|
83
|
+
this.stream = function(e) {
|
|
84
|
+
this._input = e, n = e.slice || e.webkitSlice || e.mozSlice, r ? ((t = new FileReader()).onload = b(this._chunkLoaded, this), t.onerror = b(this._chunkError, this)) : t = new FileReaderSync(), this._nextChunk();
|
|
85
|
+
}, this._nextChunk = function() {
|
|
86
|
+
this._finished || this._config.preview && !(this._rowCount < this._config.preview) || this._readChunk();
|
|
87
|
+
}, this._readChunk = function() {
|
|
88
|
+
var e = this._input, i = (this._config.chunkSize && (i = Math.min(this._start + this._config.chunkSize, this._input.size), e = n.call(e, this._start, i)), t.readAsText(e, this._config.encoding));
|
|
89
|
+
r || this._chunkLoaded({ target: { result: i } });
|
|
90
|
+
}, this._chunkLoaded = function(e) {
|
|
91
|
+
this._start += this._config.chunkSize, this._finished = !this._config.chunkSize || this._start >= this._input.size, this.parseChunk(e.target.result);
|
|
92
|
+
}, this._chunkError = function() {
|
|
93
|
+
this._sendError(t.error);
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
function d(e) {
|
|
97
|
+
var t;
|
|
98
|
+
c.call(this, e ||= {}), this.stream = function(e) {
|
|
99
|
+
return t = e, this._nextChunk();
|
|
100
|
+
}, this._nextChunk = function() {
|
|
101
|
+
var e, n;
|
|
102
|
+
if (!this._finished) return e = this._config.chunkSize, t = e ? (n = t.substring(0, e), t.substring(e)) : (n = t, ""), this._finished = !t, this.parseChunk(n);
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
function f(e) {
|
|
106
|
+
c.call(this, e ||= {});
|
|
107
|
+
var t = [], n = !0, r = !1;
|
|
108
|
+
this.pause = function() {
|
|
109
|
+
c.prototype.pause.apply(this, arguments), this._input.pause();
|
|
110
|
+
}, this.resume = function() {
|
|
111
|
+
c.prototype.resume.apply(this, arguments), this._input.resume();
|
|
112
|
+
}, this.stream = function(e) {
|
|
113
|
+
this._input = e, this._input.on("data", this._streamData), this._input.on("end", this._streamEnd), this._input.on("error", this._streamError);
|
|
114
|
+
}, this._checkIsFinished = function() {
|
|
115
|
+
r && t.length === 1 && (this._finished = !0);
|
|
116
|
+
}, this._nextChunk = function() {
|
|
117
|
+
this._checkIsFinished(), t.length ? this.parseChunk(t.shift()) : n = !0;
|
|
118
|
+
}, this._streamData = b(function(e) {
|
|
119
|
+
try {
|
|
120
|
+
t.push(typeof e == "string" ? e : e.toString(this._config.encoding)), n && (n = !1, this._checkIsFinished(), this.parseChunk(t.shift()));
|
|
121
|
+
} catch (e) {
|
|
122
|
+
this._streamError(e);
|
|
123
|
+
}
|
|
124
|
+
}, this), this._streamError = b(function(e) {
|
|
125
|
+
this._streamCleanUp(), this._sendError(e);
|
|
126
|
+
}, this), this._streamEnd = b(function() {
|
|
127
|
+
this._streamCleanUp(), r = !0, this._streamData("");
|
|
128
|
+
}, this), this._streamCleanUp = b(function() {
|
|
129
|
+
this._input.removeListener("data", this._streamData), this._input.removeListener("end", this._streamEnd), this._input.removeListener("error", this._streamError);
|
|
130
|
+
}, this);
|
|
131
|
+
}
|
|
132
|
+
function p(e) {
|
|
133
|
+
var t, n, r, i, a = 2 ** 53, s = -a, c = /^\s*-?(\d+\.?|\.\d+|\d+\.\d+)([eE][-+]?\d+)?\s*$/, l = /^((\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)))$/, u = this, d = 0, f = 0, p = !1, g = !1, _ = [], v = {
|
|
134
|
+
data: [],
|
|
135
|
+
errors: [],
|
|
136
|
+
meta: {}
|
|
137
|
+
};
|
|
138
|
+
function b(t) {
|
|
139
|
+
return e.skipEmptyLines === "greedy" ? t.join("").trim() === "" : t.length === 1 && t[0].length === 0;
|
|
140
|
+
}
|
|
141
|
+
function S() {
|
|
142
|
+
if (v && r && (w("Delimiter", "UndetectableDelimiter", "Unable to auto-detect delimiting character; defaulted to '" + o.DefaultDelimiter + "'"), r = !1), e.skipEmptyLines && (v.data = v.data.filter(function(e) {
|
|
143
|
+
return !b(e);
|
|
144
|
+
})), C()) {
|
|
145
|
+
if (v) {
|
|
146
|
+
if (Array.isArray(v.data[0])) {
|
|
147
|
+
for (var t = 0; C() && t < v.data.length; t++) v.data[t].forEach(e);
|
|
148
|
+
v.data.splice(0, 1);
|
|
149
|
+
} else v.data.forEach(e);
|
|
150
|
+
}
|
|
151
|
+
function e(e) {
|
|
152
|
+
_.push(e);
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
function n(t, n) {
|
|
156
|
+
for (var r = e.header ? {} : [], i = 0; i < t.length; i++) {
|
|
157
|
+
var o = i, u = t[i], u = ((t, n) => ((t) => (e.dynamicTypingFunction && e.dynamicTyping[t] === void 0 && (e.dynamicTyping[t] = e.dynamicTypingFunction(t)), !0 === (e.dynamicTyping[t] || e.dynamicTyping)))(t) ? n === "true" || n === "TRUE" || n !== "false" && n !== "FALSE" && (((e) => {
|
|
158
|
+
if (c.test(e) && (e = parseFloat(e), s < e && e < a)) return 1;
|
|
159
|
+
})(n) ? parseFloat(n) : l.test(n) ? new Date(n) : n === "" ? null : n) : n)(o = e.header ? i >= _.length ? "__parsed_extra" : _[i] : o, u = e.transform ? e.transform(u, o) : u);
|
|
160
|
+
o === "__parsed_extra" ? (r[o] = r[o] || [], r[o].push(u)) : r[o] = u;
|
|
161
|
+
}
|
|
162
|
+
return e.header && (i > _.length ? w("FieldMismatch", "TooManyFields", "Too many fields: expected " + _.length + " fields but parsed " + i, f + n) : i < _.length && w("FieldMismatch", "TooFewFields", "Too few fields: expected " + _.length + " fields but parsed " + i, f + n)), r;
|
|
163
|
+
}
|
|
164
|
+
var i;
|
|
165
|
+
v && (e.header || e.dynamicTyping || e.transform) && (i = 1, !v.data.length || Array.isArray(v.data[0]) ? (v.data = v.data.map(n), i = v.data.length) : v.data = n(v.data, 0), e.header && v.meta && (v.meta.fields = _), f += i);
|
|
166
|
+
}
|
|
167
|
+
function C() {
|
|
168
|
+
return e.header && _.length === 0;
|
|
169
|
+
}
|
|
170
|
+
function w(e, t, n, r) {
|
|
171
|
+
e = {
|
|
172
|
+
type: e,
|
|
173
|
+
code: t,
|
|
174
|
+
message: n
|
|
175
|
+
}, r !== void 0 && (e.row = r), v.errors.push(e);
|
|
176
|
+
}
|
|
177
|
+
x(e.step) && (i = e.step, e.step = function(t) {
|
|
178
|
+
v = t, C() ? S() : (S(), v.data.length !== 0 && (d += t.data.length, e.preview && d > e.preview ? n.abort() : (v.data = v.data[0], i(v, u))));
|
|
179
|
+
}), this.parse = function(i, a, s) {
|
|
180
|
+
var c = e.quoteChar || "\"", c = (e.newline ||= this.guessLineEndings(i, c), r = !1, e.delimiter ? x(e.delimiter) && (e.delimiter = e.delimiter(i), v.meta.delimiter = e.delimiter) : ((c = ((t, n, r, i, a) => {
|
|
181
|
+
var s, c, l, u;
|
|
182
|
+
a ||= [
|
|
183
|
+
",",
|
|
184
|
+
" ",
|
|
185
|
+
"|",
|
|
186
|
+
";",
|
|
187
|
+
o.RECORD_SEP,
|
|
188
|
+
o.UNIT_SEP
|
|
189
|
+
];
|
|
190
|
+
for (var d = 0; d < a.length; d++) {
|
|
191
|
+
for (var f, p = a[d], m = 0, g = 0, _ = 0, v = (l = void 0, new h({
|
|
192
|
+
comments: i,
|
|
193
|
+
delimiter: p,
|
|
194
|
+
newline: n,
|
|
195
|
+
preview: 10
|
|
196
|
+
}).parse(t)), y = 0; y < v.data.length; y++) r && b(v.data[y]) ? _++ : (f = v.data[y].length, g += f, l === void 0 ? l = f : 0 < f && (m += Math.abs(f - l), l = f));
|
|
197
|
+
0 < v.data.length && (g /= v.data.length - _), 1.99 < g && (c === void 0 || m < c || m === c && u < g) && (c = m, s = p, u = g);
|
|
198
|
+
}
|
|
199
|
+
return {
|
|
200
|
+
successful: !!(e.delimiter = s),
|
|
201
|
+
bestDelimiter: s
|
|
202
|
+
};
|
|
203
|
+
})(i, e.newline, e.skipEmptyLines, e.comments, e.delimitersToGuess)).successful ? e.delimiter = c.bestDelimiter : (r = !0, e.delimiter = o.DefaultDelimiter), v.meta.delimiter = e.delimiter), y(e));
|
|
204
|
+
return c.header = C(), e.preview && e.header && c.preview++, t = i, n = new h(c), v = n.parse(t, a, s), S(), p ? { meta: { paused: !0 } } : v || { meta: { paused: !1 } };
|
|
205
|
+
}, this.paused = function() {
|
|
206
|
+
return p;
|
|
207
|
+
}, this.pause = function() {
|
|
208
|
+
p = !0, n.abort(), t = x(e.chunk) ? "" : t.substring(n.getCharIndex());
|
|
209
|
+
}, this.resume = function() {
|
|
210
|
+
u.streamer._halted ? (p = !1, u.streamer.parseChunk(t, !0)) : setTimeout(u.resume, 3);
|
|
211
|
+
}, this.aborted = function() {
|
|
212
|
+
return g;
|
|
213
|
+
}, this.abort = function() {
|
|
214
|
+
g = !0, n.abort(), v.meta.aborted = !0, x(e.complete) && e.complete(v), t = "";
|
|
215
|
+
}, this.guessLineEndings = function(e, t) {
|
|
216
|
+
e = e.substring(0, 1048576);
|
|
217
|
+
var t = RegExp(m(t) + "([^]*?)" + m(t), "gm"), n = (e = e.replace(t, "")).split("\r"), t = e.split("\n"), e = 1 < t.length && t[0].length < n[0].length;
|
|
218
|
+
if (n.length === 1 || e) return "\n";
|
|
219
|
+
for (var r = 0, i = 0; i < n.length; i++) n[i][0] === "\n" && r++;
|
|
220
|
+
return r >= n.length / 2 ? "\r\n" : "\r";
|
|
221
|
+
};
|
|
222
|
+
}
|
|
223
|
+
function m(e) {
|
|
224
|
+
return e.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
225
|
+
}
|
|
226
|
+
function h(e) {
|
|
227
|
+
var t = (e ||= {}).delimiter, n = e.newline, r = e.comments, i = e.step, a = e.preview, c = e.fastMode, l = null, u = !1, d = e.quoteChar == null ? "\"" : e.quoteChar, f = d;
|
|
228
|
+
if (e.escapeChar !== void 0 && (f = e.escapeChar), (typeof t != "string" || -1 < o.BAD_DELIMITERS.indexOf(t)) && (t = ","), r === t) throw Error("Comment character same as delimiter");
|
|
229
|
+
!0 === r ? r = "#" : (typeof r != "string" || -1 < o.BAD_DELIMITERS.indexOf(r)) && (r = !1), n !== "\n" && n !== "\r" && n !== "\r\n" && (n = "\n");
|
|
230
|
+
var p = 0, h = !1;
|
|
231
|
+
this.parse = function(o, g, _) {
|
|
232
|
+
if (typeof o != "string") throw Error("Input must be a string");
|
|
233
|
+
var v = o.length, y = t.length, b = n.length, S = r.length, C = x(i), w = [], T = [], E = [], D = p = 0;
|
|
234
|
+
if (!o) return z();
|
|
235
|
+
if (c || !1 !== c && o.indexOf(d) === -1) {
|
|
236
|
+
for (var O = o.split(n), k = 0; k < O.length; k++) {
|
|
237
|
+
if (E = O[k], p += E.length, k !== O.length - 1) p += n.length;
|
|
238
|
+
else if (_) return z();
|
|
239
|
+
if (!r || E.substring(0, S) !== r) {
|
|
240
|
+
if (C) {
|
|
241
|
+
if (w = [], F(E.split(t)), B(), h) return z();
|
|
242
|
+
} else F(E.split(t));
|
|
243
|
+
if (a && a <= k) return w = w.slice(0, a), z(!0);
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
return z();
|
|
247
|
+
}
|
|
248
|
+
for (var A = o.indexOf(t, p), j = o.indexOf(n, p), M = new RegExp(m(f) + m(d), "g"), N = o.indexOf(d, p);;) if (o[p] === d) for (N = p, p++;;) {
|
|
249
|
+
if ((N = o.indexOf(d, N + 1)) === -1) return _ || T.push({
|
|
250
|
+
type: "Quotes",
|
|
251
|
+
code: "MissingQuotes",
|
|
252
|
+
message: "Quoted field unterminated",
|
|
253
|
+
row: w.length,
|
|
254
|
+
index: p
|
|
255
|
+
}), L();
|
|
256
|
+
if (N === v - 1) return L(o.substring(p, N).replace(M, d));
|
|
257
|
+
if (d === f && o[N + 1] === f) N++;
|
|
258
|
+
else if (d === f || N === 0 || o[N - 1] !== f) {
|
|
259
|
+
A !== -1 && A < N + 1 && (A = o.indexOf(t, N + 1));
|
|
260
|
+
var P = I((j = j !== -1 && j < N + 1 ? o.indexOf(n, N + 1) : j) === -1 ? A : Math.min(A, j));
|
|
261
|
+
if (o.substr(N + 1 + P, y) === t) {
|
|
262
|
+
E.push(o.substring(p, N).replace(M, d)), o[p = N + 1 + P + y] !== d && (N = o.indexOf(d, p)), A = o.indexOf(t, p), j = o.indexOf(n, p);
|
|
263
|
+
break;
|
|
264
|
+
}
|
|
265
|
+
if (P = I(j), o.substring(N + 1 + P, N + 1 + P + b) === n) {
|
|
266
|
+
if (E.push(o.substring(p, N).replace(M, d)), R(N + 1 + P + b), A = o.indexOf(t, p), N = o.indexOf(d, p), C && (B(), h)) return z();
|
|
267
|
+
if (a && w.length >= a) return z(!0);
|
|
268
|
+
break;
|
|
269
|
+
}
|
|
270
|
+
T.push({
|
|
271
|
+
type: "Quotes",
|
|
272
|
+
code: "InvalidQuotes",
|
|
273
|
+
message: "Trailing quote on quoted field is malformed",
|
|
274
|
+
row: w.length,
|
|
275
|
+
index: p
|
|
276
|
+
}), N++;
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
else if (r && E.length === 0 && o.substring(p, p + S) === r) {
|
|
280
|
+
if (j === -1) return z();
|
|
281
|
+
p = j + b, j = o.indexOf(n, p), A = o.indexOf(t, p);
|
|
282
|
+
} else if (A !== -1 && (A < j || j === -1)) E.push(o.substring(p, A)), p = A + y, A = o.indexOf(t, p);
|
|
283
|
+
else {
|
|
284
|
+
if (j === -1) break;
|
|
285
|
+
if (E.push(o.substring(p, j)), R(j + b), C && (B(), h)) return z();
|
|
286
|
+
if (a && w.length >= a) return z(!0);
|
|
287
|
+
}
|
|
288
|
+
return L();
|
|
289
|
+
function F(e) {
|
|
290
|
+
w.push(e), D = p;
|
|
291
|
+
}
|
|
292
|
+
function I(e) {
|
|
293
|
+
var t = 0;
|
|
294
|
+
return t = e !== -1 && (e = o.substring(N + 1, e)) && e.trim() === "" ? e.length : t;
|
|
295
|
+
}
|
|
296
|
+
function L(e) {
|
|
297
|
+
return _ || (e === void 0 && (e = o.substring(p)), E.push(e), p = v, F(E), C && B()), z();
|
|
298
|
+
}
|
|
299
|
+
function R(e) {
|
|
300
|
+
p = e, F(E), E = [], j = o.indexOf(n, p);
|
|
301
|
+
}
|
|
302
|
+
function z(r) {
|
|
303
|
+
if (e.header && !g && w.length && !u) {
|
|
304
|
+
var i = w[0], a = Object.create(null), o = new Set(i);
|
|
305
|
+
let t = !1;
|
|
306
|
+
for (let n = 0; n < i.length; n++) {
|
|
307
|
+
let r = s(i[n]);
|
|
308
|
+
if (a[r = x(e.transformHeader) ? e.transformHeader(r, n) : r]) {
|
|
309
|
+
let e, s = a[r];
|
|
310
|
+
for (; e = r + "_" + s, s++, o.has(e););
|
|
311
|
+
o.add(e), i[n] = e, a[r]++, t = !0, (l = l === null ? {} : l)[e] = r;
|
|
312
|
+
} else a[r] = 1, i[n] = r;
|
|
313
|
+
o.add(r);
|
|
314
|
+
}
|
|
315
|
+
t && console.warn("Duplicate headers found and renamed."), u = !0;
|
|
316
|
+
}
|
|
317
|
+
return {
|
|
318
|
+
data: w,
|
|
319
|
+
errors: T,
|
|
320
|
+
meta: {
|
|
321
|
+
delimiter: t,
|
|
322
|
+
linebreak: n,
|
|
323
|
+
aborted: h,
|
|
324
|
+
truncated: !!r,
|
|
325
|
+
cursor: D + (g || 0),
|
|
326
|
+
renamedHeaders: l
|
|
327
|
+
}
|
|
328
|
+
};
|
|
329
|
+
}
|
|
330
|
+
function B() {
|
|
331
|
+
i(z()), w = [], T = [];
|
|
332
|
+
}
|
|
333
|
+
}, this.abort = function() {
|
|
334
|
+
h = !0;
|
|
335
|
+
}, this.getCharIndex = function() {
|
|
336
|
+
return p;
|
|
337
|
+
};
|
|
338
|
+
}
|
|
339
|
+
function g(e) {
|
|
340
|
+
var t = e.data, n = i[t.workerId], r = !1;
|
|
341
|
+
if (t.error) n.userError(t.error, t.file);
|
|
342
|
+
else if (t.results && t.results.data) {
|
|
343
|
+
var a = {
|
|
344
|
+
abort: function() {
|
|
345
|
+
r = !0, _(t.workerId, {
|
|
346
|
+
data: [],
|
|
347
|
+
errors: [],
|
|
348
|
+
meta: { aborted: !0 }
|
|
349
|
+
});
|
|
350
|
+
},
|
|
351
|
+
pause: v,
|
|
352
|
+
resume: v
|
|
353
|
+
};
|
|
354
|
+
if (x(n.userStep)) {
|
|
355
|
+
for (var o = 0; o < t.results.data.length && (n.userStep({
|
|
356
|
+
data: t.results.data[o],
|
|
357
|
+
errors: t.results.errors,
|
|
358
|
+
meta: t.results.meta
|
|
359
|
+
}, a), !r); o++);
|
|
360
|
+
delete t.results;
|
|
361
|
+
} else x(n.userChunk) && (n.userChunk(t.results, a, t.file), delete t.results);
|
|
362
|
+
}
|
|
363
|
+
t.finished && !r && _(t.workerId, t.results);
|
|
364
|
+
}
|
|
365
|
+
function _(e, t) {
|
|
366
|
+
var n = i[e];
|
|
367
|
+
x(n.userComplete) && n.userComplete(t), n.terminate(), delete i[e];
|
|
368
|
+
}
|
|
369
|
+
function v() {
|
|
370
|
+
throw Error("Not implemented.");
|
|
371
|
+
}
|
|
372
|
+
function y(e) {
|
|
373
|
+
if (typeof e != "object" || !e) return e;
|
|
374
|
+
var t, n = Array.isArray(e) ? [] : {};
|
|
375
|
+
for (t in e) n[t] = y(e[t]);
|
|
376
|
+
return n;
|
|
377
|
+
}
|
|
378
|
+
function b(e, t) {
|
|
379
|
+
return function() {
|
|
380
|
+
e.apply(t, arguments);
|
|
381
|
+
};
|
|
382
|
+
}
|
|
383
|
+
function x(e) {
|
|
384
|
+
return typeof e == "function";
|
|
385
|
+
}
|
|
386
|
+
return o.parse = function(n, r) {
|
|
387
|
+
var c = (r ||= {}).dynamicTyping || !1;
|
|
388
|
+
if (x(c) && (r.dynamicTypingFunction = c, c = {}), r.dynamicTyping = c, r.transform = !!x(r.transform) && r.transform, r.downloadTimeout !== void 0) {
|
|
389
|
+
var c = parseInt(r.downloadTimeout);
|
|
390
|
+
if (isNaN(c)) throw Error("Config downloadTimeout value (" + r.downloadTimeout + ") not parsable by parseInt(val).");
|
|
391
|
+
r.downloadTimeout = c;
|
|
392
|
+
}
|
|
393
|
+
if (!r.worker || !o.WORKERS_SUPPORTED) return c = null, o.NODE_STREAM_INPUT, typeof n == "string" ? (n = s(n), c = new (r.download ? l : d)(r)) : !0 === n.readable && x(n.read) && x(n.on) ? c = new f(r) : (t.File && n instanceof File || n instanceof Object) && (c = new u(r)), c.stream(n);
|
|
394
|
+
(c = (() => {
|
|
395
|
+
var n;
|
|
396
|
+
return !!o.WORKERS_SUPPORTED && (n = (() => {
|
|
397
|
+
var n = t.URL || t.webkitURL || null, r = e.toString();
|
|
398
|
+
return o.BLOB_URL ||= n.createObjectURL(new Blob([
|
|
399
|
+
"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; ",
|
|
400
|
+
"(",
|
|
401
|
+
r,
|
|
402
|
+
")();"
|
|
403
|
+
], { type: "text/javascript" }));
|
|
404
|
+
})(), (n = new t.Worker(n)).onmessage = g, n.id = a++, i[n.id] = n);
|
|
405
|
+
})()).userStep = r.step, c.userChunk = r.chunk, c.userComplete = r.complete, c.userError = r.error, r.step = x(r.step), r.chunk = x(r.chunk), r.complete = x(r.complete), r.error = x(r.error), delete r.worker, c.postMessage({
|
|
406
|
+
input: n,
|
|
407
|
+
config: r,
|
|
408
|
+
workerId: c.id
|
|
409
|
+
});
|
|
410
|
+
}, o.unparse = function(e, t) {
|
|
411
|
+
var n = !1, r = !0, i = ",", a = "\r\n", s = "\"", c = s + s, l = !1, u = null, d = !1, f = ((() => {
|
|
412
|
+
if (typeof t == "object") {
|
|
413
|
+
if (typeof t.delimiter != "string" || o.BAD_DELIMITERS.filter(function(e) {
|
|
414
|
+
return t.delimiter.indexOf(e) !== -1;
|
|
415
|
+
}).length || (i = t.delimiter), typeof t.quotes != "boolean" && typeof t.quotes != "function" && !Array.isArray(t.quotes) || (n = t.quotes), typeof t.skipEmptyLines != "boolean" && typeof t.skipEmptyLines != "string" || (l = t.skipEmptyLines), typeof t.newline == "string" && (a = t.newline), typeof t.quoteChar == "string" && (s = t.quoteChar, c = s + s), typeof t.header == "boolean" && (r = t.header), Array.isArray(t.columns)) {
|
|
416
|
+
if (t.columns.length === 0) throw Error("Option columns is empty");
|
|
417
|
+
u = t.columns;
|
|
418
|
+
}
|
|
419
|
+
t.escapeChar !== void 0 && (c = t.escapeChar + s), t.escapeFormulae instanceof RegExp ? d = t.escapeFormulae : typeof t.escapeFormulae == "boolean" && t.escapeFormulae && (d = /^[=+\-@\t\r].*$/);
|
|
420
|
+
}
|
|
421
|
+
})(), new RegExp(m(s), "g"));
|
|
422
|
+
if (typeof e == "string" && (e = JSON.parse(e)), Array.isArray(e)) {
|
|
423
|
+
if (!e.length || Array.isArray(e[0])) return p(null, e, l);
|
|
424
|
+
if (typeof e[0] == "object") return p(u || Object.keys(e[0]), e, l);
|
|
425
|
+
} else if (typeof e == "object") return typeof e.data == "string" && (e.data = JSON.parse(e.data)), Array.isArray(e.data) && (e.fields || (e.fields = e.meta && e.meta.fields || u), e.fields || (e.fields = Array.isArray(e.data[0]) ? e.fields : typeof e.data[0] == "object" ? Object.keys(e.data[0]) : []), Array.isArray(e.data[0]) || typeof e.data[0] == "object" || (e.data = [e.data])), p(e.fields || [], e.data || [], l);
|
|
426
|
+
throw Error("Unable to serialize unrecognized input");
|
|
427
|
+
function p(e, t, n) {
|
|
428
|
+
var o = "", s = (typeof e == "string" && (e = JSON.parse(e)), typeof t == "string" && (t = JSON.parse(t)), Array.isArray(e) && 0 < e.length), c = !Array.isArray(t[0]);
|
|
429
|
+
if (s && r) {
|
|
430
|
+
for (var l = 0; l < e.length; l++) 0 < l && (o += i), o += h(e[l], l);
|
|
431
|
+
0 < t.length && (o += a);
|
|
432
|
+
}
|
|
433
|
+
for (var u = 0; u < t.length; u++) {
|
|
434
|
+
var d = (s ? e : t[u]).length, f = !1, p = s ? Object.keys(t[u]).length === 0 : t[u].length === 0;
|
|
435
|
+
if (n && !s && (f = n === "greedy" ? t[u].join("").trim() === "" : t[u].length === 1 && t[u][0].length === 0), n === "greedy" && s) {
|
|
436
|
+
for (var m = [], g = 0; g < d; g++) {
|
|
437
|
+
var _ = c ? e[g] : g;
|
|
438
|
+
m.push(t[u][_]);
|
|
439
|
+
}
|
|
440
|
+
f = m.join("").trim() === "";
|
|
441
|
+
}
|
|
442
|
+
if (!f) {
|
|
443
|
+
for (var v = 0; v < d; v++) {
|
|
444
|
+
0 < v && !p && (o += i);
|
|
445
|
+
var y = s && c ? e[v] : v;
|
|
446
|
+
o += h(t[u][y], v);
|
|
447
|
+
}
|
|
448
|
+
u < t.length - 1 && (!n || 0 < d && !p) && (o += a);
|
|
449
|
+
}
|
|
450
|
+
}
|
|
451
|
+
return o;
|
|
452
|
+
}
|
|
453
|
+
function h(e, t) {
|
|
454
|
+
var r, a, l;
|
|
455
|
+
return e == null ? "" : e.constructor === Date ? isNaN(e.getTime()) ? "" : e.toISOString() : (l = !1, d && typeof e == "string" && d.test(e) && (e = "'" + e, l = !0), a = (r = e.toString()).replace(f, c), (l = l || !0 === n || typeof n == "function" && n(e, t) || Array.isArray(n) && n[t] || ((e, t) => {
|
|
456
|
+
for (var n = 0; n < t.length; n++) if (-1 < e.indexOf(t[n])) return !0;
|
|
457
|
+
return !1;
|
|
458
|
+
})(a, o.BAD_DELIMITERS) || -1 < a.indexOf(i) || -1 < r.indexOf(s) || a.charAt(0) === " " || a.charAt(a.length - 1) === " ") ? s + a + s : a);
|
|
459
|
+
}
|
|
460
|
+
}, o.RECORD_SEP = "", o.UNIT_SEP = "", o.BYTE_ORDER_MARK = "", o.BAD_DELIMITERS = [
|
|
461
|
+
"\r",
|
|
462
|
+
"\n",
|
|
463
|
+
"\"",
|
|
464
|
+
o.BYTE_ORDER_MARK
|
|
465
|
+
], o.WORKERS_SUPPORTED = !n && !!t.Worker, o.NODE_STREAM_INPUT = 1, o.LocalChunkSize = 10485760, o.RemoteChunkSize = 5242880, o.DefaultDelimiter = ",", o.Parser = h, o.ParserHandle = p, o.NetworkStreamer = l, o.FileStreamer = u, o.StringStreamer = d, o.ReadableStreamStreamer = f, r && (t.onmessage = function(e) {
|
|
466
|
+
e = e.data, o.WORKER_ID === void 0 && e && (o.WORKER_ID = e.workerId), typeof e.input == "string" ? t.postMessage({
|
|
467
|
+
workerId: o.WORKER_ID,
|
|
468
|
+
results: o.parse(e.input, e.config),
|
|
469
|
+
finished: !0
|
|
470
|
+
}) : (t.File && e.input instanceof File || e.input instanceof Object) && (e = o.parse(e.input, e.config)) && t.postMessage({
|
|
471
|
+
workerId: o.WORKER_ID,
|
|
472
|
+
results: e,
|
|
473
|
+
finished: !0
|
|
474
|
+
});
|
|
475
|
+
}), (l.prototype = Object.create(c.prototype)).constructor = l, (u.prototype = Object.create(c.prototype)).constructor = u, (d.prototype = Object.create(d.prototype)).constructor = d, (f.prototype = Object.create(c.prototype)).constructor = f, o;
|
|
476
|
+
});
|
|
477
|
+
})), s = /* @__PURE__ */ n({
|
|
478
|
+
exportCsv: () => u,
|
|
479
|
+
importCsv: () => l,
|
|
480
|
+
selectedSheet: () => d
|
|
481
|
+
}), c = /* @__PURE__ */ t(o(), 1);
|
|
482
|
+
function l(e, t = "Workbook", n) {
|
|
483
|
+
let i = c.default.parse(e, {
|
|
484
|
+
delimiter: n,
|
|
485
|
+
skipEmptyLines: !1
|
|
486
|
+
});
|
|
487
|
+
if (i.errors.length && !i.data.length) throw Error(i.errors[0].message);
|
|
488
|
+
let o = a({ workbookName: t.replace(/\.[^.]+$/, "") }), s = o.sheets[0];
|
|
489
|
+
return s.name = "Sheet1", i.data.forEach((e, t) => {
|
|
490
|
+
e.forEach((e, n) => {
|
|
491
|
+
e !== "" && (s.cells[r(t + 1, n + 1)] = { input: e });
|
|
492
|
+
});
|
|
493
|
+
}), {
|
|
494
|
+
value: o,
|
|
495
|
+
diagnostics: []
|
|
496
|
+
};
|
|
497
|
+
}
|
|
498
|
+
function u(t) {
|
|
499
|
+
let { maxRow: n, maxColumn: i } = e(t), a = Array.from({ length: n }, (e, n) => Array.from({ length: i }, (e, i) => t.cells[r(n + 1, i + 1)]?.input ?? ""));
|
|
500
|
+
return c.default.unparse(a);
|
|
501
|
+
}
|
|
502
|
+
function d(e) {
|
|
503
|
+
return e.sheets.find((t) => t.id === e.selectedSheetId) ?? e.sheets[0];
|
|
504
|
+
}
|
|
505
|
+
//#endregion
|
|
506
|
+
export { d as i, u as n, l as r, s as t };
|