open-grid 1.7.0 → 1.7.1
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/CHANGELOG.md +34 -0
- package/dist/ExportProgressView-BYPw8osg.cjs +2 -0
- package/dist/ExportProgressView-Bt5-z7rE.js +2 -0
- package/dist/LcpMergeOrderer-CeP6C6G1.cjs +2 -0
- package/dist/LcpMergeOrderer-Ebwuir-r.js +2 -0
- package/dist/OpenGrid-Bh1NMOcm.cjs +98 -0
- package/dist/OpenGrid-CeXt04ho.js +98 -0
- package/dist/Registry-CrT46EAO.js +2 -0
- package/dist/Registry-DpHOpU5V.cjs +2 -0
- package/dist/XlsxChannel-CuOZ3LQz.js +2 -0
- package/dist/XlsxChannel-DQHLGend.cjs +2 -0
- package/dist/XlsxWorkbookWriter-DixuNGtw.cjs +3 -0
- package/dist/XlsxWorkbookWriter-VgbibI0Z.js +3 -0
- package/dist/fflate-Cs3txMgg.js +2 -0
- package/dist/fflate-G9RAFEgF.cjs +2 -0
- package/dist/index-1OXjJmct.js +2 -0
- package/dist/index-B5V7e4Xc.js +2 -0
- package/dist/index-DbKDox8y.cjs +2 -0
- package/dist/index-HaDoF1HM.cjs +2 -0
- package/dist/open-grid-react.cjs +1 -27
- package/dist/open-grid-react.js +1 -30
- package/dist/open-grid-vue.cjs +1 -31
- package/dist/open-grid-vue.js +1 -33
- package/dist/open-grid.cjs +6 -275
- package/dist/open-grid.js +6 -293
- package/dist/sinks-BCZFMGQJ.cjs +2 -0
- package/dist/sinks-qkBJ5bKn.js +2 -0
- package/dist/types/core/ExportManager.d.ts +1 -0
- package/dist/types/core/export/channels/XlsxChannel.d.ts +9 -1
- package/dist/types/core/export/channels/XlsxRichTextRun.d.ts +14 -0
- package/dist/types/core/export/channels/XlsxSheetXml.d.ts +19 -0
- package/dist/types/core/export/channels/XlsxStyleEntries.d.ts +80 -0
- package/dist/types/core/export/channels/XlsxStylesRegistry.d.ts +20 -0
- package/dist/types/core/export/channels/XlsxWorkbookWriter.d.ts +7 -4
- package/dist/types/core/export/channels/XlsxXml.d.ts +6 -0
- package/dist/types/core/export/types.d.ts +63 -0
- package/dist/types/core/types.d.ts +24 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/xlsx.min-CMvrM6b4.cjs +138 -0
- package/dist/xlsx.min-i_b-4PvU.js +138 -0
- package/package.json +2 -1
- package/dist/ExportProgressView-9Kt1SQxv.js +0 -48
- package/dist/ExportProgressView-B59uHIwt.cjs +0 -48
- package/dist/LcpMergeOrderer-BdUtV67j.js +0 -114
- package/dist/LcpMergeOrderer-C_ANVkGk.cjs +0 -113
- package/dist/OpenGrid-BUYQs1_w.cjs +0 -9806
- package/dist/OpenGrid-BmagF0yo.js +0 -9819
- package/dist/Registry-CPJYOqCn.js +0 -74
- package/dist/Registry-D74ZmdDz.cjs +0 -71
- package/dist/XlsxChannel-DOeHeP7h.cjs +0 -95
- package/dist/XlsxChannel-DdaiytFR.js +0 -95
- package/dist/XlsxWorkbookWriter-BTNtZ80J.js +0 -199
- package/dist/XlsxWorkbookWriter-_u5stfg4.cjs +0 -198
- package/dist/index-B9_g5Eg3.js +0 -481
- package/dist/index-CeJ-0-80.cjs +0 -260
- package/dist/index-CnyumyPV.cjs +0 -452
- package/dist/index-DnarQ4eR.js +0 -266
- package/dist/sinks-BWkWQexV.js +0 -149
- package/dist/sinks-DPK0VxYG.cjs +0 -143
- package/dist/xlsx.min-BQ1o3sB6.cjs +0 -11793
- package/dist/xlsx.min-Bbz2ZypC.js +0 -11794
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "open-grid",
|
|
3
|
-
"version": "1.7.
|
|
3
|
+
"version": "1.7.1",
|
|
4
4
|
"description": "초경량·제로 의존성 데이터 그리드 — React·Vue·Angular·jQuery·Vanilla 어디서나. 가상 스크롤·인라인 편집·다국어(i18n), MIT 라이선스, AI 친화 override 가이드. / Ultra-light data grid with a zero-dependency core — works with React, Vue, Angular, jQuery, or vanilla JS. Virtual scroll, inline editing, i18n. MIT-licensed, endlessly customizable, with an AI-friendly override guide.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/open-grid.cjs",
|
|
@@ -127,6 +127,7 @@
|
|
|
127
127
|
"vite-plugin-dts": "^4.5.4",
|
|
128
128
|
"vitest": "^1.6.0",
|
|
129
129
|
"vue": "^3.4.0",
|
|
130
|
+
"fflate": "^0.8.3",
|
|
130
131
|
"xlsx": "^0.18.5",
|
|
131
132
|
"xlsx-js-style": "^1.2.0"
|
|
132
133
|
},
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
const l = { "export.preparing": "Preparing export…", "export.exporting": "Exporting {done} / {total} rows ({percent}%)", "export.cancel": "Cancel", "export.cancelled": "Export cancelled", "export.done": "Export complete", "export.exportError": "Export failed" };
|
|
2
|
-
class c {
|
|
3
|
-
constructor(e = {}) {
|
|
4
|
-
if (this.opts = e, this._root = null, this._bar = null, this._text = null, this._btn = null, this._closed = false, this._failed = false, this._prevFocus = null, typeof document > "u" || !document.body) return;
|
|
5
|
-
const t = document.createElement("div");
|
|
6
|
-
t.className = "og-export-progress", t.setAttribute("role", "dialog"), t.setAttribute("aria-modal", "true"), t.setAttribute("aria-label", this._t("export.preparing")), t.style.cssText = "position:fixed;inset:0;background:rgba(0,0,0,0.4);z-index:1100;display:flex;align-items:center;justify-content:center;font:14px/1.4 sans-serif;";
|
|
7
|
-
const r = document.createElement("div");
|
|
8
|
-
r.className = "og-export-progress__panel", r.style.cssText = "box-sizing:border-box;width:min(360px,90vw);padding:16px;background:#fff;color:#212121;border-radius:6px;box-shadow:0 8px 30px rgba(0,0,0,0.3);";
|
|
9
|
-
const i = document.createElement("div");
|
|
10
|
-
i.className = "og-export-progress__text", i.setAttribute("aria-live", "polite"), i.textContent = this._t("export.preparing");
|
|
11
|
-
const o = document.createElement("div");
|
|
12
|
-
o.className = "og-export-progress__track", o.setAttribute("role", "progressbar"), o.setAttribute("aria-valuemin", "0"), o.setAttribute("aria-valuemax", "100"), o.setAttribute("aria-valuenow", "0"), o.style.cssText = "height:8px;margin:12px 0;background:#e0e0e0;border-radius:4px;overflow:hidden;";
|
|
13
|
-
const n = document.createElement("div");
|
|
14
|
-
n.className = "og-export-progress__bar", n.style.cssText = "height:100%;width:0%;background:#1565c0;", o.appendChild(n);
|
|
15
|
-
const s = document.createElement("button");
|
|
16
|
-
s.type = "button", s.className = "og-export-progress__cancel", s.textContent = this._t("export.cancel"), s.addEventListener("click", () => {
|
|
17
|
-
var _a, _b;
|
|
18
|
-
return (_b = (_a = this.opts).onCancel) == null ? void 0 : _b.call(_a);
|
|
19
|
-
}), r.append(i, o, s), t.appendChild(r), t.addEventListener("keydown", (a) => {
|
|
20
|
-
var _a, _b, _c2;
|
|
21
|
-
a.key === "Escape" ? (a.preventDefault(), this._failed ? this.close() : (_b = (_a = this.opts).onCancel) == null ? void 0 : _b.call(_a)) : a.key === "Tab" && (a.preventDefault(), (_c2 = this._btn) == null ? void 0 : _c2.focus());
|
|
22
|
-
}), this._prevFocus = document.activeElement, document.body.appendChild(t), s.focus(), this._root = t, this._bar = n, this._text = i, this._btn = s;
|
|
23
|
-
}
|
|
24
|
-
_t(e, t) {
|
|
25
|
-
var _a, _b;
|
|
26
|
-
const r = (_b = (_a = this.opts).t) == null ? void 0 : _b.call(_a, e, t);
|
|
27
|
-
return r && r !== e ? r : (l[e] ?? e).replace(/\{(\w+)\}/g, (i, o) => String((t == null ? void 0 : t[o]) ?? ""));
|
|
28
|
-
}
|
|
29
|
-
update(e, t) {
|
|
30
|
-
if (this._closed || !this._root) return;
|
|
31
|
-
const r = t > 0 ? Math.min(100, Math.floor(e / t * 100)) : 0;
|
|
32
|
-
this._bar.style.width = `${r}%`, this._bar.parentElement.setAttribute("aria-valuenow", String(r)), this._text.textContent = this._t("export.exporting", { done: e, total: t, percent: r });
|
|
33
|
-
}
|
|
34
|
-
fail(e) {
|
|
35
|
-
this._closed || !this._root || (this._text.textContent = e ? `${this._t("export.exportError")}: ${e}` : this._t("export.exportError"), this._failed = true, this._root.setAttribute("role", "alertdialog"), this._btn.textContent = "OK", this._btn.onclick = () => this.close());
|
|
36
|
-
}
|
|
37
|
-
close() {
|
|
38
|
-
var _a, _b, _c2;
|
|
39
|
-
this._closed || (this._closed = true, (_a = this._root) == null ? void 0 : _a.remove(), (_c2 = (_b = this._prevFocus) == null ? void 0 : _b.focus) == null ? void 0 : _c2.call(_b), this._prevFocus = null, this._root = this._bar = this._text = this._btn = null);
|
|
40
|
-
}
|
|
41
|
-
get isOpen() {
|
|
42
|
-
return !this._closed && !!this._root;
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
export {
|
|
46
|
-
c as ExportProgressView
|
|
47
|
-
};
|
|
48
|
-
//# sourceMappingURL=ExportProgressView-9Kt1SQxv.js.map
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
const FALLBACK = { "export.preparing": "Preparing export…", "export.exporting": "Exporting {done} / {total} rows ({percent}%)", "export.cancel": "Cancel", "export.cancelled": "Export cancelled", "export.done": "Export complete", "export.exportError": "Export failed" };
|
|
4
|
-
class ExportProgressView {
|
|
5
|
-
constructor(e = {}) {
|
|
6
|
-
if (this.opts = e, this._root = null, this._bar = null, this._text = null, this._btn = null, this._closed = false, this._failed = false, this._prevFocus = null, typeof document > "u" || !document.body) return;
|
|
7
|
-
const t = document.createElement("div");
|
|
8
|
-
t.className = "og-export-progress", t.setAttribute("role", "dialog"), t.setAttribute("aria-modal", "true"), t.setAttribute("aria-label", this._t("export.preparing")), t.style.cssText = "position:fixed;inset:0;background:rgba(0,0,0,0.4);z-index:1100;display:flex;align-items:center;justify-content:center;font:14px/1.4 sans-serif;";
|
|
9
|
-
const r = document.createElement("div");
|
|
10
|
-
r.className = "og-export-progress__panel", r.style.cssText = "box-sizing:border-box;width:min(360px,90vw);padding:16px;background:#fff;color:#212121;border-radius:6px;box-shadow:0 8px 30px rgba(0,0,0,0.3);";
|
|
11
|
-
const i = document.createElement("div");
|
|
12
|
-
i.className = "og-export-progress__text", i.setAttribute("aria-live", "polite"), i.textContent = this._t("export.preparing");
|
|
13
|
-
const o = document.createElement("div");
|
|
14
|
-
o.className = "og-export-progress__track", o.setAttribute("role", "progressbar"), o.setAttribute("aria-valuemin", "0"), o.setAttribute("aria-valuemax", "100"), o.setAttribute("aria-valuenow", "0"), o.style.cssText = "height:8px;margin:12px 0;background:#e0e0e0;border-radius:4px;overflow:hidden;";
|
|
15
|
-
const n = document.createElement("div");
|
|
16
|
-
n.className = "og-export-progress__bar", n.style.cssText = "height:100%;width:0%;background:#1565c0;", o.appendChild(n);
|
|
17
|
-
const s = document.createElement("button");
|
|
18
|
-
s.type = "button", s.className = "og-export-progress__cancel", s.textContent = this._t("export.cancel"), s.addEventListener("click", () => {
|
|
19
|
-
var _a, _b;
|
|
20
|
-
return (_b = (_a = this.opts).onCancel) == null ? void 0 : _b.call(_a);
|
|
21
|
-
}), r.append(i, o, s), t.appendChild(r), t.addEventListener("keydown", (a) => {
|
|
22
|
-
var _a, _b, _c;
|
|
23
|
-
a.key === "Escape" ? (a.preventDefault(), this._failed ? this.close() : (_b = (_a = this.opts).onCancel) == null ? void 0 : _b.call(_a)) : a.key === "Tab" && (a.preventDefault(), (_c = this._btn) == null ? void 0 : _c.focus());
|
|
24
|
-
}), this._prevFocus = document.activeElement, document.body.appendChild(t), s.focus(), this._root = t, this._bar = n, this._text = i, this._btn = s;
|
|
25
|
-
}
|
|
26
|
-
_t(e, t) {
|
|
27
|
-
var _a, _b;
|
|
28
|
-
const r = (_b = (_a = this.opts).t) == null ? void 0 : _b.call(_a, e, t);
|
|
29
|
-
return r && r !== e ? r : (FALLBACK[e] ?? e).replace(/\{(\w+)\}/g, (i, o) => String((t == null ? void 0 : t[o]) ?? ""));
|
|
30
|
-
}
|
|
31
|
-
update(e, t) {
|
|
32
|
-
if (this._closed || !this._root) return;
|
|
33
|
-
const r = t > 0 ? Math.min(100, Math.floor(e / t * 100)) : 0;
|
|
34
|
-
this._bar.style.width = `${r}%`, this._bar.parentElement.setAttribute("aria-valuenow", String(r)), this._text.textContent = this._t("export.exporting", { done: e, total: t, percent: r });
|
|
35
|
-
}
|
|
36
|
-
fail(e) {
|
|
37
|
-
this._closed || !this._root || (this._text.textContent = e ? `${this._t("export.exportError")}: ${e}` : this._t("export.exportError"), this._failed = true, this._root.setAttribute("role", "alertdialog"), this._btn.textContent = "OK", this._btn.onclick = () => this.close());
|
|
38
|
-
}
|
|
39
|
-
close() {
|
|
40
|
-
var _a, _b, _c;
|
|
41
|
-
this._closed || (this._closed = true, (_a = this._root) == null ? void 0 : _a.remove(), (_c = (_b = this._prevFocus) == null ? void 0 : _b.focus) == null ? void 0 : _c.call(_b), this._prevFocus = null, this._root = this._bar = this._text = this._btn = null);
|
|
42
|
-
}
|
|
43
|
-
get isOpen() {
|
|
44
|
-
return !this._closed && !!this._root;
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
exports.ExportProgressView = ExportProgressView;
|
|
48
|
-
//# sourceMappingURL=ExportProgressView-B59uHIwt.cjs.map
|
|
@@ -1,114 +0,0 @@
|
|
|
1
|
-
const B = 256;
|
|
2
|
-
function k(d, r, i) {
|
|
3
|
-
const n = d.length < r.length ? d.length : r.length;
|
|
4
|
-
let t = i;
|
|
5
|
-
if (n - t > 64) for (; t + 256 <= n && d.substring(t, t + 256) === r.substring(t, t + 256); ) t += 256;
|
|
6
|
-
for (; t < n && d.charCodeAt(t) === r.charCodeAt(t); ) t++;
|
|
7
|
-
return t;
|
|
8
|
-
}
|
|
9
|
-
const H = "lcpMerge", L = 1024, O = 64, R = 12e-6, T = 3e-5, C = 2e-5, S = 1e-7, y = 64, G = 100;
|
|
10
|
-
function K(d, r) {
|
|
11
|
-
const i = Math.min(y, r);
|
|
12
|
-
if (i === 0) return 0;
|
|
13
|
-
const n = r / i;
|
|
14
|
-
let t = 0;
|
|
15
|
-
for (let e = 0; e < i; e++) {
|
|
16
|
-
const s = d.stringKeyAt(Math.floor(e * n));
|
|
17
|
-
s !== null && (t += s.length);
|
|
18
|
-
}
|
|
19
|
-
return t / i;
|
|
20
|
-
}
|
|
21
|
-
const P = { number: () => R, ranked: () => R, general: () => T, string: (d, r) => C + S * K(d, r) };
|
|
22
|
-
class _ {
|
|
23
|
-
constructor(r) {
|
|
24
|
-
this.expectedMs = r;
|
|
25
|
-
}
|
|
26
|
-
static of(r, i, n) {
|
|
27
|
-
const t = Math.max(0, Math.floor(r));
|
|
28
|
-
if (t < 2 || i.length === 0) return new _(0);
|
|
29
|
-
let e = 0;
|
|
30
|
-
for (const s of i) e += n ? R : P[s.kind](s, t);
|
|
31
|
-
return new _(t * Math.log2(t) * e);
|
|
32
|
-
}
|
|
33
|
-
prefersSlicing(r = G) {
|
|
34
|
-
return this.expectedMs > r;
|
|
35
|
-
}
|
|
36
|
-
static meanCommonPrefix(r, i) {
|
|
37
|
-
const n = i.length, t = n < L ? n : L, e = [];
|
|
38
|
-
let s = 2654435769;
|
|
39
|
-
for (let u = 0; u < t; u++) {
|
|
40
|
-
s = Math.imul(s, 1103515245) + 12345 >>> 0;
|
|
41
|
-
const E = Math.floor(u * n / t), M = Math.floor((u + 1) * n / t), l = E + Math.floor(s / 4294967296 * (M - E)), a = r.stringKeyAt(i[l]);
|
|
42
|
-
a !== null && e.push(a);
|
|
43
|
-
}
|
|
44
|
-
if (e.length < 2) return 0;
|
|
45
|
-
e.sort();
|
|
46
|
-
let f = 0;
|
|
47
|
-
for (let u = 1; u < e.length; u++) f += k(e[u - 1], e[u], 0);
|
|
48
|
-
return f / (e.length - 1);
|
|
49
|
-
}
|
|
50
|
-
static pickOrderer(r, i, n) {
|
|
51
|
-
let t = null, e = null;
|
|
52
|
-
for (const s of r) s.accepts(i, n.length) && (s.id === H ? t ?? (t = s) : e ?? (e = s));
|
|
53
|
-
if (t && (!e || n.length >= L && _.meanCommonPrefix(i[0], n) > O)) return t;
|
|
54
|
-
if (!e) throw new Error("Sorter: no orderer accepts these keys");
|
|
55
|
-
return e;
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
class x {
|
|
59
|
-
constructor() {
|
|
60
|
-
this.id = "lcpMerge";
|
|
61
|
-
}
|
|
62
|
-
accepts(r, i) {
|
|
63
|
-
return r.length === 1 && r[0].kind === "string";
|
|
64
|
-
}
|
|
65
|
-
order(r, i, n) {
|
|
66
|
-
const t = i[0], e = n[0] !== "asc", s = r.length, f = [], u = [], E = [];
|
|
67
|
-
for (let o = 0; o < s; o++) {
|
|
68
|
-
const h = r[o], m = t.stringKeyAt(h);
|
|
69
|
-
m === null ? f.push(h) : (u.push(h), E.push(m));
|
|
70
|
-
}
|
|
71
|
-
const M = this._sort(E, e), l = new Int32Array(s);
|
|
72
|
-
let a = 0;
|
|
73
|
-
if (!e) for (let o = 0; o < f.length; o++) l[a++] = f[o];
|
|
74
|
-
for (let o = 0; o < M.length; o++) l[a++] = u[M[o]];
|
|
75
|
-
if (e) for (let o = 0; o < f.length; o++) l[a++] = f[o];
|
|
76
|
-
return l;
|
|
77
|
-
}
|
|
78
|
-
_sort(r, i) {
|
|
79
|
-
const n = r.length;
|
|
80
|
-
let t = new Int32Array(n), e = new Int32Array(n), s = new Int32Array(n), f = new Int32Array(n);
|
|
81
|
-
for (let l = 0; l < n; l++) t[l] = l;
|
|
82
|
-
const u = i ? -1 : 1;
|
|
83
|
-
let E = 0;
|
|
84
|
-
const M = (l, a, o) => {
|
|
85
|
-
const h = k(l, a, o);
|
|
86
|
-
return E = h, h === l.length ? h === a.length ? 0 : -u : h === a.length ? u : (l.charCodeAt(h) - a.charCodeAt(h)) * u;
|
|
87
|
-
};
|
|
88
|
-
for (let l = 1; l < n; l *= 2) {
|
|
89
|
-
for (let o = 0; o < n; o += 2 * l) {
|
|
90
|
-
const h = o + l < n ? o + l : n, m = o + 2 * l < n ? o + 2 * l : n;
|
|
91
|
-
let g = o, p = h, c = o;
|
|
92
|
-
if (h >= m) {
|
|
93
|
-
for (; g < m; g++, c++) e[c] = t[g], f[c] = s[g];
|
|
94
|
-
continue;
|
|
95
|
-
}
|
|
96
|
-
let A = 0, I = 0;
|
|
97
|
-
for (; g < h && p < m; ) {
|
|
98
|
-
let w;
|
|
99
|
-
A > I ? w = true : A < I ? w = false : (w = M(r[t[g]], r[t[p]], A) <= 0, w ? I = E : A = E), w ? (e[c] = t[g], f[c] = c === o ? 0 : A, c++, g++, A = g < h ? s[g] : 0) : (e[c] = t[p], f[c] = c === o ? 0 : I, c++, p++, I = p < m ? s[p] : 0);
|
|
100
|
-
}
|
|
101
|
-
if (g < h) for (e[c] = t[g], f[c] = A, c++, g++; g < h; g++, c++) e[c] = t[g], f[c] = s[g];
|
|
102
|
-
if (p < m) for (e[c] = t[p], f[c] = I, c++, p++; p < m; p++, c++) e[c] = t[p], f[c] = s[p];
|
|
103
|
-
}
|
|
104
|
-
let a = t;
|
|
105
|
-
t = e, e = a, a = s, s = f, f = a;
|
|
106
|
-
}
|
|
107
|
-
return t;
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
export {
|
|
111
|
-
x as LcpMergeOrderer,
|
|
112
|
-
_ as SortCostEstimate
|
|
113
|
-
};
|
|
114
|
-
//# sourceMappingURL=LcpMergeOrderer-BdUtV67j.js.map
|
|
@@ -1,113 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
const BLOCK = 256;
|
|
4
|
-
function commonPrefix(d, r, i) {
|
|
5
|
-
const n = d.length < r.length ? d.length : r.length;
|
|
6
|
-
let t = i;
|
|
7
|
-
if (n - t > 64) for (; t + BLOCK <= n && d.substring(t, t + BLOCK) === r.substring(t, t + BLOCK); ) t += BLOCK;
|
|
8
|
-
for (; t < n && d.charCodeAt(t) === r.charCodeAt(t); ) t++;
|
|
9
|
-
return t;
|
|
10
|
-
}
|
|
11
|
-
const PREFIX_ORDERER_ID = "lcpMerge", PREFIX_SAMPLES = 1024, PREFIX_THRESHOLD = 64, NUMBER_WEIGHT = 12e-6, GENERAL_WEIGHT = 3e-5, STRING_BASE_WEIGHT = 2e-5, STRING_PER_CHAR_WEIGHT = 1e-7, LENGTH_SAMPLES = 64, DEFAULT_THRESHOLD_MS = 100;
|
|
12
|
-
function meanKeyLength(d, r) {
|
|
13
|
-
const i = Math.min(LENGTH_SAMPLES, r);
|
|
14
|
-
if (i === 0) return 0;
|
|
15
|
-
const n = r / i;
|
|
16
|
-
let t = 0;
|
|
17
|
-
for (let e = 0; e < i; e++) {
|
|
18
|
-
const s = d.stringKeyAt(Math.floor(e * n));
|
|
19
|
-
s !== null && (t += s.length);
|
|
20
|
-
}
|
|
21
|
-
return t / i;
|
|
22
|
-
}
|
|
23
|
-
const WEIGHT_OF = { number: () => NUMBER_WEIGHT, ranked: () => NUMBER_WEIGHT, general: () => GENERAL_WEIGHT, string: (d, r) => STRING_BASE_WEIGHT + STRING_PER_CHAR_WEIGHT * meanKeyLength(d, r) };
|
|
24
|
-
class SortCostEstimate {
|
|
25
|
-
constructor(r) {
|
|
26
|
-
this.expectedMs = r;
|
|
27
|
-
}
|
|
28
|
-
static of(r, i, n) {
|
|
29
|
-
const t = Math.max(0, Math.floor(r));
|
|
30
|
-
if (t < 2 || i.length === 0) return new SortCostEstimate(0);
|
|
31
|
-
let e = 0;
|
|
32
|
-
for (const s of i) e += n ? NUMBER_WEIGHT : WEIGHT_OF[s.kind](s, t);
|
|
33
|
-
return new SortCostEstimate(t * Math.log2(t) * e);
|
|
34
|
-
}
|
|
35
|
-
prefersSlicing(r = DEFAULT_THRESHOLD_MS) {
|
|
36
|
-
return this.expectedMs > r;
|
|
37
|
-
}
|
|
38
|
-
static meanCommonPrefix(r, i) {
|
|
39
|
-
const n = i.length, t = n < PREFIX_SAMPLES ? n : PREFIX_SAMPLES, e = [];
|
|
40
|
-
let s = 2654435769;
|
|
41
|
-
for (let u = 0; u < t; u++) {
|
|
42
|
-
s = Math.imul(s, 1103515245) + 12345 >>> 0;
|
|
43
|
-
const m = Math.floor(u * n / t), A = Math.floor((u + 1) * n / t), l = m + Math.floor(s / 4294967296 * (A - m)), a = r.stringKeyAt(i[l]);
|
|
44
|
-
a !== null && e.push(a);
|
|
45
|
-
}
|
|
46
|
-
if (e.length < 2) return 0;
|
|
47
|
-
e.sort();
|
|
48
|
-
let f = 0;
|
|
49
|
-
for (let u = 1; u < e.length; u++) f += commonPrefix(e[u - 1], e[u], 0);
|
|
50
|
-
return f / (e.length - 1);
|
|
51
|
-
}
|
|
52
|
-
static pickOrderer(r, i, n) {
|
|
53
|
-
let t = null, e = null;
|
|
54
|
-
for (const s of r) s.accepts(i, n.length) && (s.id === PREFIX_ORDERER_ID ? t ?? (t = s) : e ?? (e = s));
|
|
55
|
-
if (t && (!e || n.length >= PREFIX_SAMPLES && SortCostEstimate.meanCommonPrefix(i[0], n) > PREFIX_THRESHOLD)) return t;
|
|
56
|
-
if (!e) throw new Error("Sorter: no orderer accepts these keys");
|
|
57
|
-
return e;
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
class LcpMergeOrderer {
|
|
61
|
-
constructor() {
|
|
62
|
-
this.id = "lcpMerge";
|
|
63
|
-
}
|
|
64
|
-
accepts(r, i) {
|
|
65
|
-
return r.length === 1 && r[0].kind === "string";
|
|
66
|
-
}
|
|
67
|
-
order(r, i, n) {
|
|
68
|
-
const t = i[0], e = n[0] !== "asc", s = r.length, f = [], u = [], m = [];
|
|
69
|
-
for (let o = 0; o < s; o++) {
|
|
70
|
-
const h = r[o], E = t.stringKeyAt(h);
|
|
71
|
-
E === null ? f.push(h) : (u.push(h), m.push(E));
|
|
72
|
-
}
|
|
73
|
-
const A = this._sort(m, e), l = new Int32Array(s);
|
|
74
|
-
let a = 0;
|
|
75
|
-
if (!e) for (let o = 0; o < f.length; o++) l[a++] = f[o];
|
|
76
|
-
for (let o = 0; o < A.length; o++) l[a++] = u[A[o]];
|
|
77
|
-
if (e) for (let o = 0; o < f.length; o++) l[a++] = f[o];
|
|
78
|
-
return l;
|
|
79
|
-
}
|
|
80
|
-
_sort(r, i) {
|
|
81
|
-
const n = r.length;
|
|
82
|
-
let t = new Int32Array(n), e = new Int32Array(n), s = new Int32Array(n), f = new Int32Array(n);
|
|
83
|
-
for (let l = 0; l < n; l++) t[l] = l;
|
|
84
|
-
const u = i ? -1 : 1;
|
|
85
|
-
let m = 0;
|
|
86
|
-
const A = (l, a, o) => {
|
|
87
|
-
const h = commonPrefix(l, a, o);
|
|
88
|
-
return m = h, h === l.length ? h === a.length ? 0 : -u : h === a.length ? u : (l.charCodeAt(h) - a.charCodeAt(h)) * u;
|
|
89
|
-
};
|
|
90
|
-
for (let l = 1; l < n; l *= 2) {
|
|
91
|
-
for (let o = 0; o < n; o += 2 * l) {
|
|
92
|
-
const h = o + l < n ? o + l : n, E = o + 2 * l < n ? o + 2 * l : n;
|
|
93
|
-
let g = o, p = h, c = o;
|
|
94
|
-
if (h >= E) {
|
|
95
|
-
for (; g < E; g++, c++) e[c] = t[g], f[c] = s[g];
|
|
96
|
-
continue;
|
|
97
|
-
}
|
|
98
|
-
let M = 0, I = 0;
|
|
99
|
-
for (; g < h && p < E; ) {
|
|
100
|
-
let w;
|
|
101
|
-
M > I ? w = true : M < I ? w = false : (w = A(r[t[g]], r[t[p]], M) <= 0, w ? I = m : M = m), w ? (e[c] = t[g], f[c] = c === o ? 0 : M, c++, g++, M = g < h ? s[g] : 0) : (e[c] = t[p], f[c] = c === o ? 0 : I, c++, p++, I = p < E ? s[p] : 0);
|
|
102
|
-
}
|
|
103
|
-
if (g < h) for (e[c] = t[g], f[c] = M, c++, g++; g < h; g++, c++) e[c] = t[g], f[c] = s[g];
|
|
104
|
-
if (p < E) for (e[c] = t[p], f[c] = I, c++, p++; p < E; p++, c++) e[c] = t[p], f[c] = s[p];
|
|
105
|
-
}
|
|
106
|
-
let a = t;
|
|
107
|
-
t = e, e = a, a = s, s = f, f = a;
|
|
108
|
-
}
|
|
109
|
-
return t;
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
exports.LcpMergeOrderer = LcpMergeOrderer, exports.SortCostEstimate = SortCostEstimate;
|
|
113
|
-
//# sourceMappingURL=LcpMergeOrderer-C_ANVkGk.cjs.map
|