@lotics/cli 0.211.0 → 0.213.0
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/probe_page.js +48 -11
- package/dist/src/cli.js +535 -220
- package/package.json +1 -1
package/dist/probe_page.js
CHANGED
|
@@ -736,6 +736,26 @@ var __loticsProbe = (() => {
|
|
|
736
736
|
const money = /^[-+−]?\s?(?:(?:[$€]|USD|EUR|VND)\s?[\d.,]+\s?(?:[KMB]|tr|tỷ)?|[\d.,]+\s?(?:tr|tỷ)?\s?(?:₫|đ|VND|USD|EUR|[$€]))$/i;
|
|
737
737
|
const dated = /^\d{1,4}[/.-]\d{1,2}(?:[/.-]\d{1,4})?$/;
|
|
738
738
|
const coded = /^(?=[^0-9]*[0-9])(?=[^A-Z]*[A-Z])[A-Z0-9][A-Z0-9/_.-]{4,}$/;
|
|
739
|
+
const trim = /^[\s·•|,:;–—-]+|[\s·•|,:;–—-]+$/g;
|
|
740
|
+
const beside = (el, value) => {
|
|
741
|
+
const said = [];
|
|
742
|
+
const walk = (node) => {
|
|
743
|
+
if (node === value) return;
|
|
744
|
+
if (node.nodeType === Node.TEXT_NODE) said.push(node.textContent || "");
|
|
745
|
+
else node.childNodes.forEach(walk);
|
|
746
|
+
};
|
|
747
|
+
walk(el);
|
|
748
|
+
return said.join(" ").replace(/\s+/g, " ").replace(trim, "");
|
|
749
|
+
};
|
|
750
|
+
const named = (value, surface) => {
|
|
751
|
+
for (let up = value; up !== null && up !== surface; up = up.parentElement) {
|
|
752
|
+
const said = stated(up);
|
|
753
|
+
if (said !== "") return said.replace(trim, "");
|
|
754
|
+
const words4 = beside(up, value);
|
|
755
|
+
if (words4 !== "") return words4.slice(0, 40);
|
|
756
|
+
}
|
|
757
|
+
return "";
|
|
758
|
+
};
|
|
739
759
|
const places = /* @__PURE__ */ new Map();
|
|
740
760
|
const shown = /* @__PURE__ */ new Map();
|
|
741
761
|
for (let index = 0; index < surfaces.length; index++) {
|
|
@@ -746,8 +766,9 @@ var __loticsProbe = (() => {
|
|
|
746
766
|
if (text === "" || parent === null || skipTag.test(parent.tagName)) return;
|
|
747
767
|
if (!onScreen(parent)) return;
|
|
748
768
|
if (!money.test(text) && !dated.test(text) && !coded.test(text)) return;
|
|
749
|
-
const
|
|
750
|
-
|
|
769
|
+
const label = named(parent, surfaces[index]);
|
|
770
|
+
const key = `${index}\0${label.toLowerCase()}\0${text}`;
|
|
771
|
+
shown.set(key, { label, text });
|
|
751
772
|
const edges = places.get(key);
|
|
752
773
|
const left = Math.round(parent.getBoundingClientRect().left);
|
|
753
774
|
if (edges === void 0) places.set(key, [left]);
|
|
@@ -765,7 +786,12 @@ var __loticsProbe = (() => {
|
|
|
765
786
|
for (const left of edges) if (!columns.some((edge) => Math.abs(edge - left) <= sameEdge)) columns.push(left);
|
|
766
787
|
if (columns.length < 2) continue;
|
|
767
788
|
twice += 1;
|
|
768
|
-
|
|
789
|
+
const fact = shown.get(key);
|
|
790
|
+
if (fact !== void 0 && repeated.length < 3) {
|
|
791
|
+
repeated.push(
|
|
792
|
+
`${fact.label === "" ? "" : `"${fact.label}" \u2014 `}"${fact.text}" drawn in ${columns.length} places`
|
|
793
|
+
);
|
|
794
|
+
}
|
|
769
795
|
}
|
|
770
796
|
rules.push({
|
|
771
797
|
law: "hierarchy.md",
|
|
@@ -811,8 +837,8 @@ var __loticsProbe = (() => {
|
|
|
811
837
|
if (lines <= noteFloor || written > 1) continue;
|
|
812
838
|
overReserved += 1;
|
|
813
839
|
if (reserved.length < 3) {
|
|
814
|
-
const
|
|
815
|
-
reserved.push(`"${
|
|
840
|
+
const named2 = nameOf(box).slice(0, 40);
|
|
841
|
+
reserved.push(`"${named2 === "" ? "(unnamed)" : named2}": ${lines} lines reserved for 1`);
|
|
816
842
|
}
|
|
817
843
|
}
|
|
818
844
|
for (const surface of within(root, overlaySurface).filter(onScreen)) {
|
|
@@ -1301,8 +1327,7 @@ var __loticsProbe = (() => {
|
|
|
1301
1327
|
if (dayRuns) break;
|
|
1302
1328
|
}
|
|
1303
1329
|
const dated = /^\d{1,4}[/.-]\d{1,2}(?:[/.-]\d{1,4})?$/;
|
|
1304
|
-
const
|
|
1305
|
-
const headings = [];
|
|
1330
|
+
const leaves = [];
|
|
1306
1331
|
if (dayRuns) {
|
|
1307
1332
|
const walk = (node) => {
|
|
1308
1333
|
if (node.nodeType === Node.TEXT_NODE) {
|
|
@@ -1311,15 +1336,25 @@ var __loticsProbe = (() => {
|
|
|
1311
1336
|
if (text === "" || parent === null || skipTag.test(parent.tagName)) return;
|
|
1312
1337
|
if (!onScreen(parent)) return;
|
|
1313
1338
|
const box = parent.getBoundingClientRect();
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1339
|
+
leaves.push({
|
|
1340
|
+
text,
|
|
1341
|
+
left: Math.round(box.left),
|
|
1342
|
+
right: Math.round(box.right),
|
|
1343
|
+
top: Math.round(box.top),
|
|
1344
|
+
bottom: Math.round(box.bottom),
|
|
1345
|
+
date: dated.test(text)
|
|
1346
|
+
});
|
|
1317
1347
|
return;
|
|
1318
1348
|
}
|
|
1319
1349
|
node.childNodes.forEach(walk);
|
|
1320
1350
|
};
|
|
1321
1351
|
walk(root);
|
|
1322
1352
|
}
|
|
1353
|
+
const dates = leaves.filter((leaf) => leaf.date);
|
|
1354
|
+
const headings = leaves.filter((leaf) => !leaf.date);
|
|
1355
|
+
const leads = (leaf) => !leaves.some(
|
|
1356
|
+
(other) => other.left < leaf.left && other.top < leaf.bottom && other.bottom > leaf.top
|
|
1357
|
+
);
|
|
1323
1358
|
const stacks = [];
|
|
1324
1359
|
for (const leaf of [...dates].sort((a, b) => a.left - b.left || a.top - b.top)) {
|
|
1325
1360
|
const stack = stacks.find((column) => leaf.left < column.right && leaf.right > column.left);
|
|
@@ -1331,7 +1366,9 @@ var __loticsProbe = (() => {
|
|
|
1331
1366
|
stacks.push({ left: leaf.left, right: leaf.right, items: [leaf] });
|
|
1332
1367
|
}
|
|
1333
1368
|
}
|
|
1334
|
-
const columns = stacks.filter(
|
|
1369
|
+
const columns = stacks.filter(
|
|
1370
|
+
(stack) => stack.items.length >= columnFloor && stack.items.every(leads)
|
|
1371
|
+
);
|
|
1335
1372
|
let grouped = 0;
|
|
1336
1373
|
const runs = [];
|
|
1337
1374
|
for (const column of columns) {
|