@sheetxl/query 0.8.0-beta.12 → 0.8.0-beta.14
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/browser/esm/index.mjs +1154 -1131
- package/node/esm/index.mjs +121 -98
- package/package.json +3 -3
- package/types/src/grep/GrepTypes.d.ts +13 -7
- package/types/src/grep/grep.d.ts +3 -2
package/node/esm/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @license @sheetxl/query - SheetXL - Workbook read surface and renderers (grep, reports) — capabilities declared once, adapted by any host surface - v0.8.0-beta.
|
|
2
|
+
* @license @sheetxl/query - SheetXL - Workbook read surface and renderers (grep, reports) — capabilities declared once, adapted by any host surface - v0.8.0-beta.14
|
|
3
3
|
*
|
|
4
4
|
* (C) 2026-present SheetXL Inc. & Michael T. Ford
|
|
5
5
|
* License: The license can be found at https://www.sheetxl.com/license.
|
|
@@ -88,7 +88,7 @@ function j(e) {
|
|
|
88
88
|
display: t
|
|
89
89
|
};
|
|
90
90
|
}
|
|
91
|
-
var M = (e) => "object" == typeof e && null !== e && !n.isError(e) && e.getKind().getName() === t.Type, I = (e) => {
|
|
91
|
+
var M = (e) => "object" == typeof e && null !== e && !n.isError(e) && "function" == typeof e.getKind && e.getKind().getName() === t.Type, I = (e) => {
|
|
92
92
|
const t = e.getAltText();
|
|
93
93
|
return t ? `[image: ${e.getSource()} "${t}"]` : `[image: ${e.getSource()}]`;
|
|
94
94
|
}, F = {
|
|
@@ -147,9 +147,9 @@ function D(e, t) {
|
|
|
147
147
|
const n = t.getCoords(), o = e.evidence, r = (s = e.check, P.get(s) ?? s);
|
|
148
148
|
var s;
|
|
149
149
|
switch (e.check) {
|
|
150
|
-
case O.InconsistentFormula: return `${r} · the cells ${
|
|
151
|
-
case O.HardcodeInRun: return `${r} · the cells ${
|
|
152
|
-
case O.StyleBreak: return `${o.layer} ${r} · ${o.actual} here, ${o.expected} ${
|
|
150
|
+
case O.InconsistentFormula: return `${r} · the cells ${V(o)} have ${J(String(o.expected ?? ""), n)}${B(o)}`;
|
|
151
|
+
case O.HardcodeInRun: return `${r} · the cells ${V(o)} are formulas${B(o)}`;
|
|
152
|
+
case O.StyleBreak: return `${o.layer} ${r} · ${o.actual} here, ${o.expected} ${V(o)}${B(o)}`;
|
|
153
153
|
case O.StyleRole: return `${o.part} ${r} · ${o.actual} on a ${o.role}, ${o.majority} of the sheet's ${o.of} are ${o.expected}`;
|
|
154
154
|
case O.OmittedCells: return `${r} · ${J(String(o.reference ?? ""), n)} stops before the number in ${J(String(o.omitted ?? ""), n)}`;
|
|
155
155
|
case O.EmptyCellReference: return `${r} · reads ${J(String(o.reference ?? ""), n)}`;
|
|
@@ -164,7 +164,7 @@ function D(e, t) {
|
|
|
164
164
|
}
|
|
165
165
|
case O.MisalignedReference: {
|
|
166
166
|
const e = void 0 !== o.landsAt && o.landsAt !== o.term ? ` in ${J(String(o.landsAt), n)}` : "";
|
|
167
|
-
return `${r} · ${J(String(o.term ?? ""), n)}, ${
|
|
167
|
+
return `${r} · ${J(String(o.term ?? ""), n)}, ${H[String(o.targetRole)] ?? o.targetRole}${e}, beside the block ${J(String(o.block ?? ""), n)}`;
|
|
168
168
|
}
|
|
169
169
|
case O.ApproximateMatch: return `${r} · ${o.function} match type ${o.matchType}`;
|
|
170
170
|
case O.LookupShape: return `${r} · reads ${J(String(o.array ?? ""), n)} at a position found in ${J(String(o.vector ?? ""), n)}`;
|
|
@@ -203,12 +203,12 @@ function D(e, t) {
|
|
|
203
203
|
default: return r;
|
|
204
204
|
}
|
|
205
205
|
}
|
|
206
|
-
var
|
|
206
|
+
var H = {
|
|
207
207
|
lineItem: "a line of another block",
|
|
208
208
|
closingRow: "another block's total",
|
|
209
209
|
outsideBlocks: "a cell in no block",
|
|
210
210
|
absolute: "an absolute reference"
|
|
211
|
-
},
|
|
211
|
+
}, V = (e) => "row" === e.axis ? "left and right" : "above and below";
|
|
212
212
|
function B(e) {
|
|
213
213
|
const t = [], n = Number(e.thickness ?? 1);
|
|
214
214
|
n > 1 && t.push(`${n} ${"row" === e.axis ? "columns" : "rows"} wide`), 1 === Number(e.flanks) && t.push("one cell each side");
|
|
@@ -679,10 +679,10 @@ var Le = [
|
|
|
679
679
|
}, Pe = {
|
|
680
680
|
name: "format",
|
|
681
681
|
project: (e) => ne(e)
|
|
682
|
-
}, De = [Oe, Pe],
|
|
682
|
+
}, De = [Oe, Pe], He = [{
|
|
683
683
|
name: "color",
|
|
684
684
|
project: (e) => Y(e)
|
|
685
|
-
}],
|
|
685
|
+
}], Ve = [{
|
|
686
686
|
name: "edges",
|
|
687
687
|
project: (e) => Q(e)
|
|
688
688
|
}], Be = [
|
|
@@ -722,8 +722,8 @@ function _e(e) {
|
|
|
722
722
|
var Ue = {
|
|
723
723
|
[Re.Font]: Le,
|
|
724
724
|
[Re.NumberFormat]: De,
|
|
725
|
-
[Re.Fill]:
|
|
726
|
-
[Re.Borders]:
|
|
725
|
+
[Re.Fill]: He,
|
|
726
|
+
[Re.Borders]: Ve,
|
|
727
727
|
[Re.Alignment]: Be
|
|
728
728
|
}, Je = (e) => e in Ue;
|
|
729
729
|
function qe(e, t, n, o) {
|
|
@@ -1059,7 +1059,10 @@ function ft(e, t) {
|
|
|
1059
1059
|
const n = t.replace(/\s+/g, " ").trim();
|
|
1060
1060
|
return n ? n.length > 60 ? `${n.slice(0, 59)}…` : n : null;
|
|
1061
1061
|
};
|
|
1062
|
-
case gt.Spills: return (e) =>
|
|
1062
|
+
case gt.Spills: return (e) => {
|
|
1063
|
+
const t = e.getCell();
|
|
1064
|
+
return "error" === t.getSpillKind() ? null : t.getSpill()?.getValuesRange().toString() ?? null;
|
|
1065
|
+
};
|
|
1063
1066
|
case gt.Hyperlink: return (e) => e.getCell().getHyperlink()?.getAddress() ?? null;
|
|
1064
1067
|
case gt.Table: return (e) => e.getCell().getTable()?.getName() ?? null;
|
|
1065
1068
|
case gt.Fill: return (e) => Y(dt(e));
|
|
@@ -1318,7 +1321,7 @@ var Dt = [
|
|
|
1318
1321
|
s.Role.Computed,
|
|
1319
1322
|
s.Role.Output
|
|
1320
1323
|
];
|
|
1321
|
-
function
|
|
1324
|
+
function Ht(e, t) {
|
|
1322
1325
|
const n = [...t.getRegions([Rt.Role, Rt.Font])];
|
|
1323
1326
|
if (0 === n.length) return;
|
|
1324
1327
|
const o = t.getWorksheet().getWorkbook()?.getStyles() ?? null, r = (e) => {
|
|
@@ -1348,7 +1351,7 @@ function Vt(e, t) {
|
|
|
1348
1351
|
e.blank();
|
|
1349
1352
|
}
|
|
1350
1353
|
}
|
|
1351
|
-
function
|
|
1354
|
+
function Vt(e, t, n) {
|
|
1352
1355
|
const o = t.getWorksheet().getWorkbook()?.getStyles().getNormal() ?? null, r = void 0 === n?.features ? null : new Set("string" == typeof n.features ? [n.features] : n.features), s = Nt.filter((e) => !r || r.has(e));
|
|
1353
1356
|
if (0 === s.length) return;
|
|
1354
1357
|
const l = t.getCounts(s);
|
|
@@ -1936,12 +1939,12 @@ function Pn(e, t) {
|
|
|
1936
1939
|
var Dn = (e) => {
|
|
1937
1940
|
const t = e.getContent();
|
|
1938
1941
|
return !0 === t?.isIGroup ? t : null;
|
|
1939
|
-
},
|
|
1940
|
-
const t =
|
|
1942
|
+
}, Hn = (e) => {
|
|
1943
|
+
const t = Vn(e);
|
|
1941
1944
|
return !0 === t?.isIShape ? In(t.toJSON() ?? {}) : e.getContent().getType();
|
|
1942
|
-
},
|
|
1945
|
+
}, Vn = (e) => e.getContent(), Bn = (e, t, n) => {
|
|
1943
1946
|
for (const o of t.getItems()) {
|
|
1944
|
-
const t =
|
|
1947
|
+
const t = Vn(o), r = [Hn(o), t.getName?.() || "(unnamed)"];
|
|
1945
1948
|
!0 === t.isIPicture && r.push(t.getResource()?.getName?.() || "(no image)");
|
|
1946
1949
|
const s = t.getTextFrame?.()?.getText();
|
|
1947
1950
|
s && r.push(Mn(s, 120, "")), o.isHidden() && r.push("(hidden)"), e.text(`${" ".repeat(n + 2)}${r.join(" · ")}`);
|
|
@@ -2156,7 +2159,7 @@ var io = (e) => "visible" === e.getVisibility(), co = (e, t, n) => {
|
|
|
2156
2159
|
}
|
|
2157
2160
|
default: return null;
|
|
2158
2161
|
}
|
|
2159
|
-
}, go = ["hyperlink", "numberFormat"], ho = (e, t) => t && "" !== t.trim() ? [{
|
|
2162
|
+
}, go = /* @__PURE__ */ new Map([["hyperlink", l.Feature.Hyperlink], ["numberFormat", l.Feature.NumberFormat]]), ho = (e, t) => t && "" !== t.trim() ? [{
|
|
2160
2163
|
field: e,
|
|
2161
2164
|
text: {
|
|
2162
2165
|
match: t,
|
|
@@ -2242,14 +2245,14 @@ async function So(t, n) {
|
|
|
2242
2245
|
throw new Error(`Invalid regex ${JSON.stringify(e.pattern)}: ${t instanceof Error ? t.message : String(t)}. Use fixedStrings (-F) to search for the literal text.`);
|
|
2243
2246
|
}
|
|
2244
2247
|
}
|
|
2245
|
-
})(n), u = co(t, n.scope, a), g =
|
|
2246
|
-
let
|
|
2247
|
-
const
|
|
2248
|
+
})(n), u = co(t, n.scope, a), g = o.filter((e) => !go.has(e)), d = o.filter((e) => go.has(e)), h = o.includes("display") && o.includes("value"), f = "content" === r || "addresses" === r, m = [], p = [];
|
|
2249
|
+
let $ = 0, w = 0, y = 0, b = 0, S = !1;
|
|
2250
|
+
const x = (e) => {
|
|
2248
2251
|
const t = e.filter((t, n) => c.test(t.text.match) && e.findIndex((e) => e.field === t.field && e.text.display === t.text.display && c.test(e.text.match)) === n);
|
|
2249
2252
|
return l ? 0 === t.length && e.length > 0 ? [e[0]] : null : 0 === t.length ? null : "addresses" === r ? t.slice(0, 1) : t;
|
|
2250
|
-
},
|
|
2251
|
-
if (s > 0 &&
|
|
2252
|
-
if ("cell" === e ?
|
|
2253
|
+
}, k = (e, t, n, o, r, l = 1) => {
|
|
2254
|
+
if (s > 0 && y >= s) return S = !0, !1;
|
|
2255
|
+
if (y++, "cell" === e ? $ += l : w++, f) for (const e of o) m.push({
|
|
2253
2256
|
sheet: t,
|
|
2254
2257
|
address: n,
|
|
2255
2258
|
field: e.field,
|
|
@@ -2259,93 +2262,113 @@ async function So(t, n) {
|
|
|
2259
2262
|
return !0;
|
|
2260
2263
|
};
|
|
2261
2264
|
for (const { sheet: t, address: n } of u) {
|
|
2262
|
-
if (
|
|
2265
|
+
if (S) continue;
|
|
2263
2266
|
const s = t.getName();
|
|
2264
|
-
|
|
2267
|
+
b++, await t.getCalculation().ready();
|
|
2265
2268
|
const l = null !== n ? t.getRange(n) : t.getUsedRange(), c = l && i && "content" === r ? bo(i, s, l) : null, u = {
|
|
2266
2269
|
...null !== n ? { address: n } : {},
|
|
2267
2270
|
...a ? {} : { ignoreHidden: !0 }
|
|
2268
|
-
},
|
|
2271
|
+
}, f = /* @__PURE__ */ new Map();
|
|
2269
2272
|
if (o.includes("comment")) for (const e of t.getComments().getItems(u)) {
|
|
2270
2273
|
const t = e.getRange().getCoords();
|
|
2271
|
-
|
|
2274
|
+
f.set(`${t.rowStart}:${t.colStart}`, e);
|
|
2272
2275
|
}
|
|
2273
|
-
let
|
|
2274
|
-
l?.forEach((e, t) => {
|
|
2275
|
-
if (
|
|
2276
|
-
const n = t.getCell(),
|
|
2277
|
-
let
|
|
2278
|
-
for (const e of
|
|
2276
|
+
let m = 0;
|
|
2277
|
+
g.length > 0 && l?.forEach((e, t) => {
|
|
2278
|
+
if (null == e) return;
|
|
2279
|
+
const n = t.getCell(), o = t.getCoords(), r = [];
|
|
2280
|
+
let l;
|
|
2281
|
+
for (const e of g) {
|
|
2279
2282
|
if ("comment" === e) {
|
|
2280
|
-
const e = `${
|
|
2281
|
-
t && (
|
|
2283
|
+
const e = `${o.rowIndex}:${o.colIndex}`, t = f.get(e);
|
|
2284
|
+
t && (r.push(...fo(t)), f.delete(e));
|
|
2282
2285
|
continue;
|
|
2283
2286
|
}
|
|
2284
2287
|
const t = uo(n, e);
|
|
2285
|
-
"display" === e && (
|
|
2288
|
+
"display" === e && (l = t?.match ?? null), null !== t && ("value" === e && h && (void 0 === l && (l = uo(n, "display")?.match ?? null), t.match === l) || r.push({
|
|
2286
2289
|
field: e,
|
|
2287
2290
|
text: t
|
|
2288
2291
|
}));
|
|
2289
2292
|
}
|
|
2290
|
-
const
|
|
2291
|
-
if (!
|
|
2292
|
-
const
|
|
2293
|
-
if (!
|
|
2294
|
-
|
|
2295
|
-
},
|
|
2296
|
-
const
|
|
2293
|
+
const a = x(r);
|
|
2294
|
+
if (!a) return;
|
|
2295
|
+
const i = c?.resolve(n, o);
|
|
2296
|
+
if (!k("cell", s, t.getAddress(), a, i)) return { break: !0 };
|
|
2297
|
+
m++;
|
|
2298
|
+
}, { ignoreHidden: !a });
|
|
2299
|
+
const $ = [...f.values()].map((e) => ({
|
|
2297
2300
|
comment: e,
|
|
2298
2301
|
at: e.getRange().getCoords()
|
|
2299
2302
|
})).sort((e, t) => yo(e.at, t.at));
|
|
2300
|
-
for (const { comment: t, at: n } of
|
|
2301
|
-
if (
|
|
2302
|
-
const o =
|
|
2303
|
+
for (const { comment: t, at: n } of $) {
|
|
2304
|
+
if (S) break;
|
|
2305
|
+
const o = x(fo(t));
|
|
2303
2306
|
if (!o) continue;
|
|
2304
2307
|
const r = c?.resolve(t.getRange().getCell(), {
|
|
2305
2308
|
rowIndex: n.rowStart,
|
|
2306
2309
|
colIndex: n.colStart
|
|
2307
2310
|
});
|
|
2308
|
-
|
|
2311
|
+
k("cell", s, e.rangeToString(n) ?? t.getRange().toString(), o, r) && m++;
|
|
2312
|
+
}
|
|
2313
|
+
for (const e of d) {
|
|
2314
|
+
if (S || !l) break;
|
|
2315
|
+
const t = [...l.getRegions(go.get(e), { ignoreHidden: !a })].map((e) => ({
|
|
2316
|
+
region: e,
|
|
2317
|
+
at: e.getCoords()
|
|
2318
|
+
})).sort((e, t) => yo(e.at, t.at));
|
|
2319
|
+
for (const { region: n, at: o } of t) {
|
|
2320
|
+
const t = n.getCell(), r = uo(t, e), l = x(r ? [{
|
|
2321
|
+
field: e,
|
|
2322
|
+
text: r
|
|
2323
|
+
}] : []);
|
|
2324
|
+
if (!l) continue;
|
|
2325
|
+
const a = c?.resolve(t, {
|
|
2326
|
+
rowIndex: o.rowStart,
|
|
2327
|
+
colIndex: o.colStart
|
|
2328
|
+
}), i = (o.rowEnd - o.rowStart + 1) * (o.colEnd - o.colStart + 1);
|
|
2329
|
+
if (!k("cell", s, n.toString(), l, a, i)) break;
|
|
2330
|
+
m += i;
|
|
2331
|
+
}
|
|
2309
2332
|
}
|
|
2310
|
-
let
|
|
2311
|
-
if (!
|
|
2333
|
+
let w = 0;
|
|
2334
|
+
if (!S && (o.includes("shape") || o.includes("chart"))) {
|
|
2312
2335
|
const n = t.getMovables().getItems(u).filter((e) => "note" !== e.getContent().getType()).filter((e) => a || !e.isHidden()).map((e) => ({
|
|
2313
2336
|
movable: e,
|
|
2314
2337
|
at: e.getRange().getCoords()
|
|
2315
2338
|
})).sort((e, t) => yo(e.at, t.at));
|
|
2316
2339
|
for (const { movable: t, at: r } of n) {
|
|
2317
|
-
const n =
|
|
2340
|
+
const n = x(mo(t, o));
|
|
2318
2341
|
if (n) {
|
|
2319
|
-
if (!
|
|
2320
|
-
|
|
2342
|
+
if (!k("object", s, e.rangeToString(r) ?? t.getRange().toString(), n)) break;
|
|
2343
|
+
w++;
|
|
2321
2344
|
}
|
|
2322
2345
|
}
|
|
2323
2346
|
}
|
|
2324
|
-
(
|
|
2347
|
+
(m > 0 || w > 0) && p.push({
|
|
2325
2348
|
sheet: s,
|
|
2326
|
-
cells:
|
|
2327
|
-
objects:
|
|
2349
|
+
cells: m,
|
|
2350
|
+
objects: w
|
|
2328
2351
|
});
|
|
2329
2352
|
}
|
|
2330
|
-
if (!
|
|
2353
|
+
if (!S && o.includes("name")) {
|
|
2331
2354
|
const e = Boolean(n.scope?.trim()), o = t.getNames().getItems(a ? { includeHidden: !0 } : void 0) ?? [];
|
|
2332
2355
|
for (const t of o) {
|
|
2333
2356
|
if (e && !wo(t, u)) continue;
|
|
2334
|
-
const n =
|
|
2335
|
-
if (n && !
|
|
2357
|
+
const n = x(po(t));
|
|
2358
|
+
if (n && !k("object", t.getScope() ?? "", t.getName(), n)) break;
|
|
2336
2359
|
}
|
|
2337
2360
|
}
|
|
2338
2361
|
return {
|
|
2339
2362
|
pattern: n.pattern,
|
|
2340
2363
|
fields: o,
|
|
2341
2364
|
scope: n.scope?.trim() || "workbook",
|
|
2342
|
-
matches:
|
|
2343
|
-
cellCount:
|
|
2344
|
-
objectCount:
|
|
2345
|
-
sheets:
|
|
2346
|
-
sheetsSearched:
|
|
2347
|
-
sheetsMatched:
|
|
2348
|
-
truncated:
|
|
2365
|
+
matches: m,
|
|
2366
|
+
cellCount: $,
|
|
2367
|
+
objectCount: w,
|
|
2368
|
+
sheets: p,
|
|
2369
|
+
sheetsSearched: b,
|
|
2370
|
+
sheetsMatched: p.length,
|
|
2371
|
+
truncated: S,
|
|
2349
2372
|
output: r
|
|
2350
2373
|
};
|
|
2351
2374
|
}
|
|
@@ -2612,19 +2635,19 @@ function Do(e, t) {
|
|
|
2612
2635
|
}).filter((e) => null !== e.score).map((t) => ({
|
|
2613
2636
|
...t,
|
|
2614
2637
|
hasMember: _o(e, t.key).some((e) => e.name.toLowerCase() === r)
|
|
2615
|
-
})).sort((e, t) => Number(t.hasMember) - Number(e.hasMember) || e.score - t.score).slice(0,
|
|
2638
|
+
})).sort((e, t) => Number(t.hasMember) - Number(e.hasMember) || e.score - t.score).slice(0, Ho).map(({ key: e, hasMember: t }) => ({
|
|
2616
2639
|
key: e,
|
|
2617
2640
|
hasMember: t
|
|
2618
2641
|
}));
|
|
2619
2642
|
}(e, t, o), i = n ? function(e, t, n) {
|
|
2620
|
-
const o =
|
|
2643
|
+
const o = Vo(n)?.toLowerCase();
|
|
2621
2644
|
return _o(e, t).map((e) => {
|
|
2622
2645
|
const t = Uo(n, e.name), r = o && o.length >= 3 && e.name.toLowerCase().includes(o);
|
|
2623
2646
|
return {
|
|
2624
2647
|
member: e,
|
|
2625
2648
|
score: t ?? (r ? 10 : null)
|
|
2626
2649
|
};
|
|
2627
|
-
}).filter((e) => null !== e.score).sort((e, t) => e.score - t.score).slice(0,
|
|
2650
|
+
}).filter((e) => null !== e.score).sort((e, t) => e.score - t.score).slice(0, Ho).map((e) => e.member);
|
|
2628
2651
|
}(e, n, o) : [];
|
|
2629
2652
|
return a.length + i.length + l.length + s.length === 0 ? null : {
|
|
2630
2653
|
kind: "miss",
|
|
@@ -2636,8 +2659,8 @@ function Do(e, t) {
|
|
|
2636
2659
|
nearestTypes: a,
|
|
2637
2660
|
nearest: i,
|
|
2638
2661
|
hints: l,
|
|
2639
|
-
elsewhere: s.slice(0,
|
|
2640
|
-
elsewhereOmitted: Math.max(0, s.length -
|
|
2662
|
+
elsewhere: s.slice(0, Ho),
|
|
2663
|
+
elsewhereOmitted: Math.max(0, s.length - Ho)
|
|
2641
2664
|
};
|
|
2642
2665
|
}(e, t, o, s);
|
|
2643
2666
|
if (n) return n;
|
|
@@ -2662,7 +2685,7 @@ function Do(e, t) {
|
|
|
2662
2685
|
};
|
|
2663
2686
|
}(e, r > 0 ? n.slice(r + 1) : n);
|
|
2664
2687
|
}
|
|
2665
|
-
var
|
|
2688
|
+
var Ho = 5, Vo = (e) => /([A-Z][a-z0-9]+|^[a-z0-9]+)$/.exec(e)?.[1] ?? null;
|
|
2666
2689
|
function Bo(e, t) {
|
|
2667
2690
|
if (!t || "object" != typeof t && "function" != typeof t) return null;
|
|
2668
2691
|
const n = [], o = /* @__PURE__ */ new Set();
|
|
@@ -3308,13 +3331,13 @@ function Dr(e) {
|
|
|
3308
3331
|
}
|
|
3309
3332
|
return t.toLines().join("\n").trimEnd();
|
|
3310
3333
|
}
|
|
3311
|
-
function
|
|
3334
|
+
function Hr(e) {
|
|
3312
3335
|
const t = new pt(), n = e.getRanges();
|
|
3313
3336
|
t.h1(`Unlocked Range — ${e.getName()}`), t.blank(), t.fact(`Ranges: ${Wt(n)}`), t.fact(`Cells: ${n.size}`), t.fact("Password: " + (e.hasPassword() ? e.isUnlocked() ? "set · unlocked for this session" : "set · unlock(password) grants access" : "none"));
|
|
3314
3337
|
const o = n.getWorksheet().getProtection().isLocked();
|
|
3315
3338
|
return t.fact("In force: " + (o ? "true — the sheet is protected" : "false — the sheet is not protected, so every cell is editable")), e.getSecurityDescriptor() && t.fact("Security Descriptor: present · not evaluated"), t.toLines().join("\n").trimEnd();
|
|
3316
3339
|
}
|
|
3317
|
-
var
|
|
3340
|
+
var Vr = l.Feature;
|
|
3318
3341
|
async function Br(e, t) {
|
|
3319
3342
|
const n = e.getWorksheet().getRange(e.getCoords());
|
|
3320
3343
|
e = n.getCell();
|
|
@@ -3345,7 +3368,7 @@ async function Br(e, t) {
|
|
|
3345
3368
|
e.fact(`Merge: ${n} · ${a.height}×${a.width}`), i && e.fact("Merge Anchor: false — this cell is covered; the value lives at the top-left");
|
|
3346
3369
|
}
|
|
3347
3370
|
const c = t.getSpill();
|
|
3348
|
-
c && e.fact(`Spill: ${c.toString()}`);
|
|
3371
|
+
c && e.fact(`Spill: ${c.toString()}${"error" === t.getSpillKind() ? " (blocked)" : ""}`);
|
|
3349
3372
|
t.isSpillOverflow() && e.fact("Spill Overflow: true — the anchor formula is elsewhere");
|
|
3350
3373
|
const u = t.getTable();
|
|
3351
3374
|
u && e.fact(`Table: ${function(e, t) {
|
|
@@ -3478,7 +3501,7 @@ var zr = 8, _r = (e) => ({
|
|
|
3478
3501
|
function Ur(e, t, n) {
|
|
3479
3502
|
if (e.isSingleCell()) return null;
|
|
3480
3503
|
const o = [];
|
|
3481
|
-
for (const n of e.getRegions(
|
|
3504
|
+
for (const n of e.getRegions(Vr.Formula)) {
|
|
3482
3505
|
const e = n.getCoords();
|
|
3483
3506
|
o.push({
|
|
3484
3507
|
start: "row" === t ? e.colStart : e.rowStart,
|
|
@@ -3556,7 +3579,7 @@ async function qr(e, t) {
|
|
|
3556
3579
|
const a = {
|
|
3557
3580
|
text: (s?.display ?? "").replace(/\|/g, "\\|").replace(/[\r\n]+/g, " "),
|
|
3558
3581
|
alignment: n.getRenderHorizontalAlignment()
|
|
3559
|
-
}, i = n.getSpill();
|
|
3582
|
+
}, i = "error" === n.getSpillKind() ? null : n.getSpill();
|
|
3560
3583
|
i && d.push({
|
|
3561
3584
|
address: n.getAddress(),
|
|
3562
3585
|
valuesRange: i.getValuesRange().toString()
|
|
@@ -4075,11 +4098,11 @@ function Os(e, t) {
|
|
|
4075
4098
|
var Ps = (e, t) => {
|
|
4076
4099
|
if (null == e) return { text: "" };
|
|
4077
4100
|
if ("function" == typeof e) return { text: "[Function]" };
|
|
4078
|
-
if ("bigint" == typeof e || "symbol" == typeof e) return { text:
|
|
4101
|
+
if ("bigint" == typeof e || "symbol" == typeof e) return { text: Vs(String(e)) };
|
|
4079
4102
|
if ("object" == typeof e) {
|
|
4080
4103
|
if (e instanceof Date) return { text: e.toISOString() };
|
|
4081
4104
|
const n = e;
|
|
4082
|
-
if (!0 === n.isFormulaError || !0 === n.isIRichData) return { text: Hs(
|
|
4105
|
+
if (!0 === n.isFormulaError || !0 === n.isIRichData) return { text: Vs(Hs(e)) };
|
|
4083
4106
|
if (Ws(e) || Array.isArray(e)) {
|
|
4084
4107
|
let t;
|
|
4085
4108
|
try {
|
|
@@ -4087,11 +4110,11 @@ var Ps = (e, t) => {
|
|
|
4087
4110
|
} catch {
|
|
4088
4111
|
t = "[circular]";
|
|
4089
4112
|
}
|
|
4090
|
-
return { text:
|
|
4113
|
+
return { text: Vs(t) };
|
|
4091
4114
|
}
|
|
4092
|
-
return { text:
|
|
4115
|
+
return { text: Vs(t?.(e) ?? Ds(e)) };
|
|
4093
4116
|
}
|
|
4094
|
-
const n = Hs(
|
|
4117
|
+
const n = Vs(Hs(e).replace(/[\r\n]+/g, " "));
|
|
4095
4118
|
return "number" == typeof e ? {
|
|
4096
4119
|
text: n,
|
|
4097
4120
|
alignment: "right"
|
|
@@ -4105,13 +4128,13 @@ var Ps = (e, t) => {
|
|
|
4105
4128
|
}
|
|
4106
4129
|
const n = /^\[object (.+)\]$/.exec(t)?.[1];
|
|
4107
4130
|
return n && "Object" !== n ? n : t;
|
|
4108
|
-
},
|
|
4131
|
+
}, Hs = (e) => {
|
|
4109
4132
|
try {
|
|
4110
4133
|
return j(e)?.match ?? String(e);
|
|
4111
4134
|
} catch {
|
|
4112
4135
|
return String(e);
|
|
4113
4136
|
}
|
|
4114
|
-
},
|
|
4137
|
+
}, Vs = (e) => e.length > 80 ? `${e.slice(0, 79)}…` : e;
|
|
4115
4138
|
function Bs(e, t) {
|
|
4116
4139
|
const n = e.length, o = L(n, t?.maxRanges ?? 100), r = Math.min(n, o), s = [];
|
|
4117
4140
|
for (let t = 0; t < r; t++) {
|
|
@@ -4194,7 +4217,7 @@ async function Ks(e, t) {
|
|
|
4194
4217
|
const l = As(e);
|
|
4195
4218
|
l && n.text(`Print: ${l}`), n.blank();
|
|
4196
4219
|
const a = r ?? o;
|
|
4197
|
-
Pt(n, a),
|
|
4220
|
+
Pt(n, a), Ht(n, a), Vt(n, a, {
|
|
4198
4221
|
profile: !0,
|
|
4199
4222
|
...t
|
|
4200
4223
|
});
|
|
@@ -4661,7 +4684,7 @@ var wl = (e, t) => !!e && "object" == typeof e && !0 === e[t], yl = {
|
|
|
4661
4684
|
is: (e) => wl(e, "isIProtectedRangeCollection"),
|
|
4662
4685
|
render: (e) => {
|
|
4663
4686
|
const t = e.getItems();
|
|
4664
|
-
return 0 === t.length ? "# Unlocked Ranges (0)\nNone" : t.slice(0, xl).map(
|
|
4687
|
+
return 0 === t.length ? "# Unlocked Ranges (0)\nNone" : t.slice(0, xl).map(Hr).concat(t.length > xl ? [`…and ${t.length - xl} more · render one at a time to see them`] : []).join("\n\n");
|
|
4665
4688
|
}
|
|
4666
4689
|
}, bl = 2;
|
|
4667
4690
|
function Sl(e) {
|
|
@@ -4749,7 +4772,7 @@ var xl = 20, kl = [
|
|
|
4749
4772
|
{
|
|
4750
4773
|
kind: "protectedRange",
|
|
4751
4774
|
is: (e) => wl(e, "isIProtectedRange"),
|
|
4752
|
-
render: (e) =>
|
|
4775
|
+
render: (e) => Hr(e)
|
|
4753
4776
|
},
|
|
4754
4777
|
{
|
|
4755
4778
|
kind: "pageLayout",
|
|
@@ -5106,25 +5129,25 @@ function Pl(e, t) {
|
|
|
5106
5129
|
charts: Array.from(s.values(), jn)
|
|
5107
5130
|
};
|
|
5108
5131
|
}
|
|
5109
|
-
var Dl = (e, t, n = `${t}s`) => `${e} ${1 === e ? t : n}`,
|
|
5110
|
-
function
|
|
5132
|
+
var Dl = (e, t, n = `${t}s`) => `${e} ${1 === e ? t : n}`, Hl = (e, t) => `${`${e}:`.padEnd(14)}${t}`;
|
|
5133
|
+
function Vl(e) {
|
|
5111
5134
|
const t = [];
|
|
5112
5135
|
for (const n of e.sheets) {
|
|
5113
5136
|
if (n.written) {
|
|
5114
|
-
t.push(
|
|
5137
|
+
t.push(Hl("Changed", `${n.written} — ${Bl(n)}`));
|
|
5115
5138
|
for (const e of n.blocks) t.push(` ${_l(e)}`);
|
|
5116
5139
|
n.blocksMore > 0 && t.push(` +${Dl(n.blocksMore, "more formula block")}`);
|
|
5117
5140
|
}
|
|
5118
|
-
n.shifts.length > 0 && t.push(
|
|
5141
|
+
n.shifts.length > 0 && t.push(Hl("Structure", n.shifts.map((e) => zl(n.sheet, e)).join(" · "))), n.styles && t.push(Hl("Formatting", n.styles));
|
|
5119
5142
|
}
|
|
5120
5143
|
const n = e.dependents;
|
|
5121
5144
|
if (n) {
|
|
5122
5145
|
const e = n.sheets.length > 1 ? ` on ${Dl(n.sheets.length, "sheet")}` : "";
|
|
5123
|
-
t.push(
|
|
5146
|
+
t.push(Hl("Dependents", `${Dl(n.cells, "cell")}${e} — ${n.areas.join(", ")}${((e) => e > 0 ? ` · +${e} more` : "")(n.areasMore)}`));
|
|
5124
5147
|
}
|
|
5125
5148
|
if (e.errors.length > 0 || e.errorsCleared > 0) {
|
|
5126
5149
|
const n = e.errors.map((e) => `${e.address} ${e.error} (${e.cells})`);
|
|
5127
|
-
e.errorsMore > 0 && n.push(`+${e.errorsMore} more`), e.errorsCleared > 0 && n.push(`${Dl(e.errorsCleared, "error")} cleared`), t.push(
|
|
5150
|
+
e.errorsMore > 0 && n.push(`+${e.errorsMore} more`), e.errorsCleared > 0 && n.push(`${Dl(e.errorsCleared, "error")} cleared`), t.push(Hl("Errors", n.join(" · ")));
|
|
5128
5151
|
}
|
|
5129
5152
|
const o = function(e) {
|
|
5130
5153
|
const t = [], n = (e, n, o) => {
|
|
@@ -5132,7 +5155,7 @@ function Hl(e) {
|
|
|
5132
5155
|
};
|
|
5133
5156
|
return n(e.names, "name"), n(e.conditionalFormats, "conditional format"), n(e.dataValidations, "data validation"), n(e.charts, "chart"), t.length > 0 ? t.join(" · ") : null;
|
|
5134
5157
|
}(e.touches);
|
|
5135
|
-
return o && t.push(
|
|
5158
|
+
return o && t.push(Hl("Also touches", o)), t.join("\n");
|
|
5136
5159
|
}
|
|
5137
5160
|
function Bl(e) {
|
|
5138
5161
|
const t = [];
|
|
@@ -5158,11 +5181,11 @@ async function Ul(e, t, n) {
|
|
|
5158
5181
|
const o = await Il(e, t, n);
|
|
5159
5182
|
return o ? {
|
|
5160
5183
|
delta: o,
|
|
5161
|
-
markdown:
|
|
5184
|
+
markdown: Vl(o)
|
|
5162
5185
|
} : {};
|
|
5163
5186
|
} catch (e) {
|
|
5164
5187
|
return { markdown: `Changes could not be read: ${e?.message ?? String(e)}` };
|
|
5165
5188
|
}
|
|
5166
5189
|
}
|
|
5167
5190
|
var Jl = [No], ql = [Qo];
|
|
5168
|
-
export { Fo as API_ENTRY_POINTS, v as CellEncoding, T as GREP_FIELDS, A as GREP_FIELDS_DEFAULT, F as GrepField, pt as MarkdownBuilder, $t as MarkdownFrameSection, vl as NoRendererError, ql as REFERENCES, Cl as RENDERABLE_KINDS, kl as RENDERERS, pr as RENDER_OPTION_KEYS, Nt as REPORTED_FEATURES, Jl as TOOLS, xt as anomalyRegionKey, zo as apiPointerFor, Ko as apiSuggestionsFor, Qo as apiTool, Bo as apiTypeOf, tr as appendDependencies, zn as appendGroupFacts, Bn as appendGroupMembers, Pt as appendKinds, ps as appendModules, no as appendMovables, on as appendNames, yt as appendRegionList,
|
|
5191
|
+
export { Fo as API_ENTRY_POINTS, v as CellEncoding, T as GREP_FIELDS, A as GREP_FIELDS_DEFAULT, F as GrepField, pt as MarkdownBuilder, $t as MarkdownFrameSection, vl as NoRendererError, ql as REFERENCES, Cl as RENDERABLE_KINDS, kl as RENDERERS, pr as RENDER_OPTION_KEYS, Nt as REPORTED_FEATURES, Jl as TOOLS, xt as anomalyRegionKey, zo as apiPointerFor, Ko as apiSuggestionsFor, Qo as apiTool, Bo as apiTypeOf, tr as appendDependencies, zn as appendGroupFacts, Bn as appendGroupMembers, Pt as appendKinds, ps as appendModules, no as appendMovables, on as appendNames, yt as appendRegionList, Vt as appendRegions, Ht as appendRoles, ln as appendRules, Pn as appendShapeFacts, cn as appendSheetObjects, Lr as appendSheetProtection, vt as appendTables, ms as collectModules, Xn as collectShapeText, Ut as contentfulBlocks, xe as countDates, oe as describeAlignment, ct as describeAllowedValues, Jn as describeAnchor, Yo as describeApi, Q as describeBorder, te as describeBorderParts, Or as describeCellProtection, Z as describeColor, at as describeConditionalFormat, it as describeDataValidation, Il as describeDelta, Ft as describeExtent, Y as describeFill, re as describeFont, Er as describeLock, Zn as describeMovableSummary, fr as describeNode, hr as describeNodeLabel, gr as describeNodeLabels, ne as describeNumberFormat, sn as describeOutline, As as describePageLayout, Ot as describeQualifiedExtent, Xt as describeQualifiedName, Wt as describeQualifiedRanges, Wr as describeRangeProtection, Lt as describeRanges, ot as describeRuleStyle, ut as describeRules, st as describeScale, qn as describeShapeText, At as describeSheetCall, Tt as describeSheetName, me as describeSums, eo as describeTypeHeading, jr as describeWorkbookProtection, de as detectTotals, N as encodeCell, R as encodeFormattedNumber, E as encodeNumber, j as encodeScalar, an as findNames, So as grep, No as grepTool, to as groupMovables, Dn as groupOf, Ws as isPlainRecord, Do as lookupApi, It as parseFeatures, $r as parseRenderOptions, Se as profileKinds, ce as profileRegion, Pr as protectionPointerFor, Mn as quoteShapeText, Ul as readRunDelta, Kn as readShapeText, ft as regionPayload, mt as regionPayloads, Zo as renderApi, Br as renderCell, qr as renderCellRange, Zr as renderConditionalFormat, Yr as renderCounts, Qr as renderDataValidation, Vl as renderDelta, cs as renderFormula, Ro as renderGrep, Rl as renderMarkdown, ws as renderModule, ys as renderModules, ro as renderMovable, Ss as renderNames, Ls as renderPageLayout, Hr as renderProtectedRange, Dr as renderProtection, Bs as renderRanges, Os as renderRecords, kt as renderRegions, jl as renderResult, so as renderShape, Zs as renderStats, Qs as renderStyle, Et as renderTable, el as renderValues, sl as renderWorkbook, Ks as renderWorksheet, El as resolveRenderer, Ar as summarizeSheetProtection, Jo as withoutHiddenSuggestion };
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sheetxl/query",
|
|
3
3
|
"description": "SheetXL - Workbook read surface and renderers (grep, reports) — capabilities declared once, adapted by any host surface",
|
|
4
|
-
"version": "0.8.0-beta.
|
|
4
|
+
"version": "0.8.0-beta.14",
|
|
5
5
|
"license": "SEE LICENSE IN <LICENSE>",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"exports": {
|
|
@@ -42,8 +42,8 @@
|
|
|
42
42
|
"query"
|
|
43
43
|
],
|
|
44
44
|
"dependencies": {
|
|
45
|
-
"@sheetxl/primitives": "^0.8.0-beta.
|
|
46
|
-
"@sheetxl/sdk": "^0.8.0-beta.
|
|
45
|
+
"@sheetxl/primitives": "^0.8.0-beta.14",
|
|
46
|
+
"@sheetxl/sdk": "^0.8.0-beta.14"
|
|
47
47
|
},
|
|
48
48
|
"devDependencies": {
|
|
49
49
|
"@types/node": "^26.6.4"
|
|
@@ -61,8 +61,9 @@ export type GrepField =
|
|
|
61
61
|
*
|
|
62
62
|
* Authored text (it is literally what was typed into Format Cells), canonical, and regex
|
|
63
63
|
* is its native matcher. `--fields numberFormat "%"` is the well-posed form of "which
|
|
64
|
-
* cells are percentages" — the rendered `40%` is not. Matches
|
|
65
|
-
*
|
|
64
|
+
* cells are percentages" — the rendered `40%` is not. Matches blocks given a format,
|
|
65
|
+
* directly or by a named style, including value-less ones (a formatted-but-empty column is
|
|
66
|
+
* a real finding).
|
|
66
67
|
*/
|
|
67
68
|
| 'numberFormat'
|
|
68
69
|
/**
|
|
@@ -238,7 +239,8 @@ export interface GrepArgs {
|
|
|
238
239
|
*
|
|
239
240
|
* @remarks
|
|
240
241
|
* Counts **cells and objects**, not match rows — a cell matching in two fields is one unit of
|
|
241
|
-
* budget, and so is a chart matching in its title and an axis
|
|
242
|
+
* budget, and so is a chart matching in its title and an axis, and a block matching in its
|
|
243
|
+
* hyperlink or number format.
|
|
242
244
|
* The search looks one match past the cap, so a result that ends exactly at `maxCount` is
|
|
243
245
|
* only reported truncated when a further match actually exists.
|
|
244
246
|
*/
|
|
@@ -290,8 +292,9 @@ export interface GrepMatch {
|
|
|
290
292
|
*/
|
|
291
293
|
sheet: string;
|
|
292
294
|
/**
|
|
293
|
-
* A1 cell address within the sheet; the
|
|
294
|
-
*
|
|
295
|
+
* A1 cell address within the sheet; the block (`A:J`) for a hyperlink or number format; the
|
|
296
|
+
* anchor range (`F2:H6`) for a shape or chart; the name itself for a defined name. Qualified
|
|
297
|
+
* with `sheet`, each is something a follow-up call takes.
|
|
295
298
|
*/
|
|
296
299
|
address: string;
|
|
297
300
|
/**
|
|
@@ -312,7 +315,7 @@ export interface GrepMatch {
|
|
|
312
315
|
export interface GrepSheetMatches {
|
|
313
316
|
/** Sheet name. */
|
|
314
317
|
sheet: string;
|
|
315
|
-
/**
|
|
318
|
+
/** Cells that produced a match in this sheet, counted as {@link GrepResult.cellCount} is. */
|
|
316
319
|
cells: number;
|
|
317
320
|
/** Shapes and charts on this sheet that produced at least one match. */
|
|
318
321
|
objects: number;
|
|
@@ -325,7 +328,10 @@ export interface GrepResult {
|
|
|
325
328
|
/** Resolved human-readable scope, e.g. `Sheet1!A1:D847` or `workbook`. */
|
|
326
329
|
scope: string;
|
|
327
330
|
matches: readonly GrepMatch[];
|
|
328
|
-
/**
|
|
331
|
+
/**
|
|
332
|
+
* Cells that produced a match. A hyperlink or number format block counts all of its cells, and
|
|
333
|
+
* a cell also matching in another field is counted again.
|
|
334
|
+
*/
|
|
329
335
|
cellCount: number;
|
|
330
336
|
/** Shapes, charts and names that produced at least one match. */
|
|
331
337
|
objectCount: number;
|
package/types/src/grep/grep.d.ts
CHANGED
|
@@ -4,8 +4,9 @@ import { GrepArgs, GrepResult } from './GrepTypes';
|
|
|
4
4
|
* Searches a workbook's text by pattern — its cells, and what is written off the grid.
|
|
5
5
|
*
|
|
6
6
|
* @remarks
|
|
7
|
-
* Per sheet: the cells in reading order (a comment rides its cell), then the
|
|
8
|
-
*
|
|
7
|
+
* Per sheet: the cells in reading order (a comment rides its cell), then the blocks a hyperlink or
|
|
8
|
+
* number format is stated over, then the shapes and charts in reading order of their anchors.
|
|
9
|
+
* Defined names follow every sheet, since they belong to none.
|
|
9
10
|
*
|
|
10
11
|
* Deliberately shaped after ripgrep — args, defaults and vocabulary are pretrained, and every
|
|
11
12
|
* novel idiom is paid for in error loops.
|