mcdview 0.34.0__tar.gz → 0.34.2__tar.gz
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.
- {mcdview-0.34.0 → mcdview-0.34.2}/PKG-INFO +31 -1
- {mcdview-0.34.0 → mcdview-0.34.2}/README.md +30 -0
- {mcdview-0.34.0 → mcdview-0.34.2}/mcdview.py +72 -18
- {mcdview-0.34.0 → mcdview-0.34.2}/pyproject.toml +1 -1
- {mcdview-0.34.0 → mcdview-0.34.2}/templates/explorateur.html +102 -32
- {mcdview-0.34.0 → mcdview-0.34.2}/.gitignore +0 -0
- {mcdview-0.34.0 → mcdview-0.34.2}/LICENSE +0 -0
- {mcdview-0.34.0 → mcdview-0.34.2}/logo.svg +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: mcdview
|
|
3
|
-
Version: 0.34.
|
|
3
|
+
Version: 0.34.2
|
|
4
4
|
Summary: Turn a SQL data model into one self-contained, interactive HTML page
|
|
5
5
|
Project-URL: Homepage, https://github.com/Gheop/mcdview
|
|
6
6
|
Project-URL: Demo, https://gheop.github.io/mcdview/
|
|
@@ -356,6 +356,36 @@ file's header.
|
|
|
356
356
|
|
|
357
357
|
## Changelog
|
|
358
358
|
|
|
359
|
+
### v0.34.2 — Right SQL dialect on large MySQL and Prisma models (2026-09-23)
|
|
360
|
+
|
|
361
|
+
- `--dialect auto` now chooses the dialect on the whole file. On files over
|
|
362
|
+
25 KB it used to decide on the first 25 KB, cut mid-statement, and could pick
|
|
363
|
+
the wrong one: tables went missing (some MySQL dumps showed none at all) and
|
|
364
|
+
column types were rewritten (`VARCHAR(191)` shown as `text(191)`, `BOOLEAN`
|
|
365
|
+
as `integer`). Across the test corpus, 36 files regain 2,406 tables and none
|
|
366
|
+
loses any.
|
|
367
|
+
- A MySQL dump with a stray `[word] word` inside a comment is no longer taken
|
|
368
|
+
for SQL Server.
|
|
369
|
+
- A Prisma schema with a `mysql` or `sqlite` provider is parsed straight in that
|
|
370
|
+
dialect instead of trying up to seven in turn: about 100 ms less per run.
|
|
371
|
+
- Parsing non-PostgreSQL SQL is about twice as fast overall (median 92 ms to
|
|
372
|
+
21 ms per file on the corpus). If you already converted a Prisma schema to SQL
|
|
373
|
+
yourself, pass `--dialect mysql` (or `sqlite`) to skip the dialect trial.
|
|
374
|
+
- Some MySQL and SQLite models now render differently: more tables, and column
|
|
375
|
+
types as written in the DDL.
|
|
376
|
+
|
|
377
|
+
### v0.34.1 — Smoother pan, hover and drag on large models (2026-09-23)
|
|
378
|
+
|
|
379
|
+
- Panning and zooming no longer re-read every table to repaint the minimap: a
|
|
380
|
+
pan move on a 5000-table model drops from ~23-42 ms to ~0.1 ms.
|
|
381
|
+
- Hovering a table only restyles its own links instead of redrawing them all
|
|
382
|
+
(55 ms to under 1 ms on 5000 tables).
|
|
383
|
+
- Dragging a table only reroutes that table's links on each frame (53 ms to
|
|
384
|
+
~6 ms per frame on 5000 tables).
|
|
385
|
+
- A full link redraw is ~8-12% faster. Across the 186 models of 100+ tables in
|
|
386
|
+
the test corpus, no interaction got slower, and every generated page renders
|
|
387
|
+
exactly as before.
|
|
388
|
+
|
|
359
389
|
### v0.34.0 — Clickable foreign-key links (2026-09-10)
|
|
360
390
|
|
|
361
391
|
- Click a foreign-key link to see its detail in the right panel, the way a table
|
|
@@ -334,6 +334,36 @@ file's header.
|
|
|
334
334
|
|
|
335
335
|
## Changelog
|
|
336
336
|
|
|
337
|
+
### v0.34.2 — Right SQL dialect on large MySQL and Prisma models (2026-09-23)
|
|
338
|
+
|
|
339
|
+
- `--dialect auto` now chooses the dialect on the whole file. On files over
|
|
340
|
+
25 KB it used to decide on the first 25 KB, cut mid-statement, and could pick
|
|
341
|
+
the wrong one: tables went missing (some MySQL dumps showed none at all) and
|
|
342
|
+
column types were rewritten (`VARCHAR(191)` shown as `text(191)`, `BOOLEAN`
|
|
343
|
+
as `integer`). Across the test corpus, 36 files regain 2,406 tables and none
|
|
344
|
+
loses any.
|
|
345
|
+
- A MySQL dump with a stray `[word] word` inside a comment is no longer taken
|
|
346
|
+
for SQL Server.
|
|
347
|
+
- A Prisma schema with a `mysql` or `sqlite` provider is parsed straight in that
|
|
348
|
+
dialect instead of trying up to seven in turn: about 100 ms less per run.
|
|
349
|
+
- Parsing non-PostgreSQL SQL is about twice as fast overall (median 92 ms to
|
|
350
|
+
21 ms per file on the corpus). If you already converted a Prisma schema to SQL
|
|
351
|
+
yourself, pass `--dialect mysql` (or `sqlite`) to skip the dialect trial.
|
|
352
|
+
- Some MySQL and SQLite models now render differently: more tables, and column
|
|
353
|
+
types as written in the DDL.
|
|
354
|
+
|
|
355
|
+
### v0.34.1 — Smoother pan, hover and drag on large models (2026-09-23)
|
|
356
|
+
|
|
357
|
+
- Panning and zooming no longer re-read every table to repaint the minimap: a
|
|
358
|
+
pan move on a 5000-table model drops from ~23-42 ms to ~0.1 ms.
|
|
359
|
+
- Hovering a table only restyles its own links instead of redrawing them all
|
|
360
|
+
(55 ms to under 1 ms on 5000 tables).
|
|
361
|
+
- Dragging a table only reroutes that table's links on each frame (53 ms to
|
|
362
|
+
~6 ms per frame on 5000 tables).
|
|
363
|
+
- A full link redraw is ~8-12% faster. Across the 186 models of 100+ tables in
|
|
364
|
+
the test corpus, no interaction got slower, and every generated page renders
|
|
365
|
+
exactly as before.
|
|
366
|
+
|
|
337
367
|
### v0.34.0 — Clickable foreign-key links (2026-09-10)
|
|
338
368
|
|
|
339
369
|
- Click a foreign-key link to see its detail in the right panel, the way a table
|
|
@@ -466,7 +466,12 @@ def flairer_dialecte(chemin, src=None):
|
|
|
466
466
|
src = lire_texte(chemin, 300000)
|
|
467
467
|
if 'AUTOINCREMENT' in src:
|
|
468
468
|
return 'sqlite'
|
|
469
|
-
|
|
469
|
+
# `[name] type` points at SQL Server only when such bracket identifiers
|
|
470
|
+
# outnumber backquoted ones: a MySQL dump can carry a stray one inside a
|
|
471
|
+
# COMMENT string (glpi: one `CFG_GLPI[language] array` against ~10 000
|
|
472
|
+
# backquoted names). A wrong first guess costs a whole wasted parse.
|
|
473
|
+
crochets = len(re.findall(r'\[\w+\]\s+\w', src))
|
|
474
|
+
if crochets and crochets > src.count('`') // 2:
|
|
470
475
|
return 'tsql'
|
|
471
476
|
return 'mysql' # backticks or anything else: MySQL is the sensible default
|
|
472
477
|
|
|
@@ -474,9 +479,13 @@ def flairer_dialecte(chemin, src=None):
|
|
|
474
479
|
# auto tries these sqlglot dialects (after the sniffed guess) and keeps the
|
|
475
480
|
# one that yields the most tables — one file is often only valid in one of them
|
|
476
481
|
DIALECTES_ESSAI = ['mysql', 'sqlite', 'postgres', 'tsql', 'oracle', 'clickhouse', 'duckdb']
|
|
477
|
-
#
|
|
478
|
-
#
|
|
479
|
-
#
|
|
482
|
+
# How many tables a DDL text declares, for auto's early stop: deliberately
|
|
483
|
+
# generous (any words between CREATE and TABLE — UNLOGGED, TEMPORARY, OR
|
|
484
|
+
# REPLACE…; commented-out statements count too). Overcounting only costs the
|
|
485
|
+
# early stop; undercounting would stop on a dialect that misses tables.
|
|
486
|
+
RE_CREATE_TABLE = re.compile(r'\bCREATE\b[^;(]{0,80}?\bTABLE\b', re.I)
|
|
487
|
+
# up to this size, auto can afford a full sqlglot parse per candidate dialect;
|
|
488
|
+
# above it, a full parse per dialect reached ~27 s on the corpus tail
|
|
480
489
|
SEUIL_ECHANTILLON = 25000
|
|
481
490
|
|
|
482
491
|
|
|
@@ -526,10 +535,11 @@ def analyser(chemin, dialecte='auto'):
|
|
|
526
535
|
tables, fks = analyser_sql(chemin, src)
|
|
527
536
|
if tables:
|
|
528
537
|
return (*normaliser_casse(tables, fks), 'postgresql')
|
|
529
|
-
# otherwise try
|
|
530
|
-
#
|
|
531
|
-
#
|
|
538
|
+
# otherwise try the sqlglot dialects, keeping the first one with the most
|
|
539
|
+
# tables; a dialect that finds every table the text declares cannot be
|
|
540
|
+
# beaten, so the trial stops there.
|
|
532
541
|
candidats = list(dict.fromkeys([flairer_dialecte(chemin, apercu)] + DIALECTES_ESSAI))
|
|
542
|
+
attendu = len(RE_CREATE_TABLE.findall(src))
|
|
533
543
|
|
|
534
544
|
def essayer(d, texte):
|
|
535
545
|
# defense in depth: an unforeseen sqlglot AST shape must not crash
|
|
@@ -539,16 +549,33 @@ def analyser(chemin, dialecte='auto'):
|
|
|
539
549
|
except Exception:
|
|
540
550
|
return {}, []
|
|
541
551
|
|
|
542
|
-
if len(src)
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
+
if len(src) <= SEUIL_ECHANTILLON:
|
|
553
|
+
# small file: whole-file parse per dialect, exact
|
|
554
|
+
meilleur = ({}, [], candidats[0])
|
|
555
|
+
for d in candidats:
|
|
556
|
+
t, f = essayer(d, src)
|
|
557
|
+
if len(t) > len(meilleur[0]):
|
|
558
|
+
meilleur = (t, f, d)
|
|
559
|
+
if attendu and len(t) >= attendu:
|
|
560
|
+
break
|
|
561
|
+
return (*normaliser_casse(meilleur[0], meilleur[1]), meilleur[2])
|
|
562
|
+
# big file: parse the sniffed dialect in full; if it misses declared
|
|
563
|
+
# tables, rank the dialects on a prefix cut at a statement end, and parse
|
|
564
|
+
# the winner in full too, keeping the better of the two. (The prefix
|
|
565
|
+
# alone used to decide: cut mid-statement, it chose the wrong dialect on
|
|
566
|
+
# 99 of 775 big corpus files, losing tables or rewriting column types.)
|
|
567
|
+
t, f = essayer(candidats[0], src)
|
|
568
|
+
if attendu and len(t) >= attendu:
|
|
569
|
+
return (*normaliser_casse(t, f), candidats[0])
|
|
570
|
+
ech = src[:SEUIL_ECHANTILLON]
|
|
571
|
+
fin = ech.rfind(';')
|
|
572
|
+
ech = ech[:fin + 1] if fin > 0 else ech
|
|
573
|
+
gagnant = max(candidats, key=lambda d: len(essayer(d, ech)[0])) # ties: earliest
|
|
574
|
+
if gagnant != candidats[0]:
|
|
575
|
+
t2, f2 = essayer(gagnant, src)
|
|
576
|
+
if len(t2) > len(t):
|
|
577
|
+
return (*normaliser_casse(t2, f2), gagnant)
|
|
578
|
+
return (*normaliser_casse(t, f), candidats[0])
|
|
552
579
|
tables, fks = analyser_sqlglot(chemin, dialecte)
|
|
553
580
|
return (*normaliser_casse(tables, fks), dialecte)
|
|
554
581
|
|
|
@@ -824,6 +851,20 @@ def pretraiter_prisma(src):
|
|
|
824
851
|
return src
|
|
825
852
|
|
|
826
853
|
|
|
854
|
+
# The datasource provider names the SQL dialect `prisma migrate diff` emits. When
|
|
855
|
+
# that SQL is not PostgreSQL-looking (MySQL backticks, SQLite AUTOINCREMENT…),
|
|
856
|
+
# auto would try up to 7 sqlglot dialects in turn; parsing straight in the
|
|
857
|
+
# provider's dialect skips that trial. Only providers checked against the whole
|
|
858
|
+
# Prisma test corpus are mapped (sqlserver has no sample there).
|
|
859
|
+
DIALECTE_PRISMA = {'mysql': 'mysql', 'sqlite': 'sqlite'}
|
|
860
|
+
|
|
861
|
+
|
|
862
|
+
def dialecte_prisma(src):
|
|
863
|
+
"""The sqlglot dialect of a Prisma schema's datasource, or None."""
|
|
864
|
+
m = re.search(r'datasource\s+\w+\s*\{[^}]*?\bprovider\s*=\s*"(\w+)"', src)
|
|
865
|
+
return DIALECTE_PRISMA.get(m.group(1).lower()) if m else None
|
|
866
|
+
|
|
867
|
+
|
|
827
868
|
def sql_depuis_prisma(chemin):
|
|
828
869
|
"""Convert a Prisma schema to SQL through `prisma migrate diff` (writes to
|
|
829
870
|
stdout). A dummy DATABASE_URL is set so `url = env(...)` schemas resolve;
|
|
@@ -1524,7 +1565,20 @@ def charger(source, dialect='auto'):
|
|
|
1524
1565
|
tables, fks, _ = analyser(sql_depuis_dbml(source), 'postgres')
|
|
1525
1566
|
return tables, fks, 'postgres'
|
|
1526
1567
|
if source.endswith('.prisma'):
|
|
1527
|
-
|
|
1568
|
+
sql = sql_depuis_prisma(source)
|
|
1569
|
+
dial = dialecte_prisma(lire_texte(source))
|
|
1570
|
+
# only stands in for auto's sqlglot trial: SQL that the fast regex parser
|
|
1571
|
+
# takes (PostgreSQL-looking, as Prisma's SQLite output often is) stays
|
|
1572
|
+
# on auto. Same defensive call as that trial (non-strict, a sqlglot crash
|
|
1573
|
+
# counts as no table), and auto again if it finds nothing.
|
|
1574
|
+
if dial and not ressemble_postgres(sql):
|
|
1575
|
+
try:
|
|
1576
|
+
tables, fks = analyser_sqlglot(sql, dial, False)
|
|
1577
|
+
except Exception:
|
|
1578
|
+
tables, fks = {}, []
|
|
1579
|
+
if tables:
|
|
1580
|
+
return (*normaliser_casse(tables, fks), dial)
|
|
1581
|
+
return analyser(sql, 'auto')
|
|
1528
1582
|
if source.endswith('.mwb'):
|
|
1529
1583
|
return (*normaliser_casse(*analyser_mwb(source)), 'mysql')
|
|
1530
1584
|
if source.endswith('.rb'):
|
|
@@ -386,6 +386,9 @@ const svgClic = document.createElementNS("http://www.w3.org/2000/svg", "svg");
|
|
|
386
386
|
svgClic.id = "liensClic";
|
|
387
387
|
plan.insertBefore(svgClic, plan.children[1]);
|
|
388
388
|
let liensVus = []; // index (data-fk on a hit path) -> the FK it draws
|
|
389
|
+
let liensEls = null; // index -> its visible path, built lazily (hover, drag)
|
|
390
|
+
let liensClics = null; // index -> its hit path, built with liensEls
|
|
391
|
+
let miniCouche = null; // cached table layer of the minimap (see dessinerMinimap)
|
|
389
392
|
let focusLien = null; // the FK whose detail is shown in the panel
|
|
390
393
|
// all table names first, then all column names: a table-name query (e.g. a
|
|
391
394
|
// name shared by several tables) then lists the matching TABLES before any of
|
|
@@ -476,9 +479,10 @@ function centre(cle) {
|
|
|
476
479
|
// left/right when the boxes sit side by side, top/bottom when stacked. Keeps the
|
|
477
480
|
// visible line off the box bodies and off the old center-to-center diagonals.
|
|
478
481
|
function boite(cle) {
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
+
// each offset read goes through the layout engine: read every dimension once
|
|
483
|
+
// (a full redraw calls this for every visible table)
|
|
484
|
+
const e = elems[cle], l = e.offsetLeft, t = e.offsetTop, w = e.offsetWidth, h = e.offsetHeight;
|
|
485
|
+
return { l, t, w, h, cx: l + w / 2, cy: t + h / 2 };
|
|
482
486
|
}
|
|
483
487
|
function ancres(a, b) {
|
|
484
488
|
const dx = b.cx - a.cx, dy = b.cy - a.cy;
|
|
@@ -527,6 +531,13 @@ function marqueCardin(p, nn, vif, pourExport) {
|
|
|
527
531
|
`<text class="cardtxt" x="${bx + vx * pin + vx * 4 + px * 10}" y="${by + vy * pin + vy * 4 + py * 10}">${nn ? "1" : "0..1"}</text>`;
|
|
528
532
|
return { da: { x: ax + ux * L, y: ay + uy * L }, db: { x: bx + vx * pin, y: by + vy * pin }, s };
|
|
529
533
|
}
|
|
534
|
+
// whether a link is highlighted (drawn blue in the overlay above the tables)
|
|
535
|
+
function estVifLien(f) {
|
|
536
|
+
return f === focusLien ||
|
|
537
|
+
(focusCle && (f.de === focusCle || f.vers === focusCle)) ||
|
|
538
|
+
(survolCle && (f.de === survolCle || f.vers === survolCle)) ||
|
|
539
|
+
(mev && mev.liens.has(f.de + " " + f.vers));
|
|
540
|
+
}
|
|
530
541
|
function dessinerLiens() {
|
|
531
542
|
// two markup strings in one DOM write each: normal edges under the tables
|
|
532
543
|
// (#liens), highlighted ones over them (#liensVif) so a focused/hovered link
|
|
@@ -539,10 +550,8 @@ function dessinerLiens() {
|
|
|
539
550
|
liensVus = [];
|
|
540
551
|
fksVisibles().forEach(f => {
|
|
541
552
|
if (!vus.has(f.de) || !vus.has(f.vers)) return;
|
|
542
|
-
const estVif = f
|
|
543
|
-
|
|
544
|
-
(survolCle && (f.de === survolCle || f.vers === survolCle)) ||
|
|
545
|
-
(mev && mev.liens.has(f.de + " " + f.vers));
|
|
553
|
+
const estVif = estVifLien(f);
|
|
554
|
+
const i = liensVus.push(f) - 1;
|
|
546
555
|
const dcls = f.diff ? " " + DCLS[f.diff] : "";
|
|
547
556
|
let d, extra = "";
|
|
548
557
|
if (f.de === f.vers) {
|
|
@@ -556,24 +565,50 @@ function dessinerLiens() {
|
|
|
556
565
|
} else {
|
|
557
566
|
d = trace(f, boites);
|
|
558
567
|
}
|
|
559
|
-
(estVif ? vif : norm).push(`<path class="lien${estVif ? " vif" : ""}${dcls}" d="${d}"/>` + extra);
|
|
560
|
-
|
|
561
|
-
clic.push(`<path data-fk="${i}" d="${d}"/>`);
|
|
568
|
+
(estVif ? vif : norm).push(`<path data-fk="${i}" class="lien${estVif ? " vif" : ""}${dcls}" d="${d}"/>` + extra);
|
|
569
|
+
clic.push(`<path data-fk="${i}" d="${d}"/>`); // a fat transparent hit path per link
|
|
562
570
|
});
|
|
563
571
|
svg.innerHTML = norm.join("");
|
|
564
572
|
svgVif.innerHTML = vif.join("");
|
|
565
573
|
svgClic.innerHTML = clic.join("");
|
|
574
|
+
liensEls = liensClics = null;
|
|
575
|
+
miniCouche = null; // boxes may have moved: the minimap table layer is stale
|
|
576
|
+
}
|
|
577
|
+
// index -> path elements, for the incremental updates below. Without markers
|
|
578
|
+
// (cardinalities off) each layer child is exactly one link path.
|
|
579
|
+
function indexerLiens() {
|
|
580
|
+
liensEls = []; liensClics = [];
|
|
581
|
+
for (const el of svg.children) liensEls[+el.dataset.fk] = el;
|
|
582
|
+
for (const el of svgVif.children) liensEls[+el.dataset.fk] = el;
|
|
583
|
+
for (const el of svgClic.children) liensClics[+el.dataset.fk] = el;
|
|
584
|
+
}
|
|
585
|
+
// A hover only changes which links are highlighted, never where they run: move
|
|
586
|
+
// the few paths of the old and new hovered tables between the two layers
|
|
587
|
+
// instead of a full redraw (which re-reads every box and rewrites every path,
|
|
588
|
+
// ~100 ms on a 5000-table model). Crow's-foot markers carry state-dependent
|
|
589
|
+
// labels, so with cardinalities shown the full redraw still runs.
|
|
590
|
+
function survoler(cle) {
|
|
591
|
+
if (cle === survolCle) return;
|
|
592
|
+
const avant = survolCle;
|
|
593
|
+
survolCle = cle;
|
|
594
|
+
if (cardOn) { dessinerLiens(); return; }
|
|
595
|
+
if (!liensEls) indexerLiens();
|
|
596
|
+
liensVus.forEach((f, i) => {
|
|
597
|
+
if (f.de !== avant && f.vers !== avant && f.de !== cle && f.vers !== cle) return;
|
|
598
|
+
const vif = estVifLien(f), el = liensEls[i];
|
|
599
|
+
if (!el || (el.parentNode === svgVif) === vif) return;
|
|
600
|
+
el.classList.toggle("vif", vif);
|
|
601
|
+
(vif ? svgVif : svg).appendChild(el);
|
|
602
|
+
});
|
|
566
603
|
}
|
|
567
604
|
|
|
568
605
|
// --- hover: light up the links of the table under the pointer ---
|
|
569
606
|
plan.addEventListener("mouseover", e => {
|
|
570
607
|
const t = e.target.closest(".table");
|
|
571
608
|
const cle = t ? t.dataset.cle : null;
|
|
572
|
-
|
|
573
|
-
});
|
|
574
|
-
plan.addEventListener("mouseleave", () => {
|
|
575
|
-
if (survolCle) { survolCle = null; dessinerLiens(); }
|
|
609
|
+
survoler(cle);
|
|
576
610
|
});
|
|
611
|
+
plan.addEventListener("mouseleave", () => survoler(null));
|
|
577
612
|
|
|
578
613
|
// --- pan / zoom ---
|
|
579
614
|
let estCompact = false;
|
|
@@ -596,24 +631,40 @@ const miniCanvas = document.getElementById("minimap");
|
|
|
596
631
|
const miniCtx = miniCanvas.getContext("2d");
|
|
597
632
|
const MINI_ACTIVE = D.tables.length >= 25;
|
|
598
633
|
if (MINI_ACTIVE) miniCanvas.classList.add("on");
|
|
634
|
+
// The table layer of the minimap only changes when boxes move or resize; a pan
|
|
635
|
+
// or zoom only moves the viewport rectangle. Keep that layer in an offscreen
|
|
636
|
+
// canvas and redraw it only after a geometry change: every such change already
|
|
637
|
+
// goes through dessinerLiens()/majLiensDe() (links must follow the boxes) or
|
|
638
|
+
// cadrer(), and each of them drops this cache. Rebuilding it re-reads every
|
|
639
|
+
// box (~50 000 offset reads on a 5000-table model), once per pan frame before.
|
|
640
|
+
// (miniCouche is declared with the link indexes, near the top.)
|
|
599
641
|
function dessinerMinimap() {
|
|
600
642
|
if (!MINI_ACTIVE) return;
|
|
601
643
|
const W = miniCanvas.width, H = miniCanvas.height, pad = 6;
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
644
|
+
if (!miniCouche) {
|
|
645
|
+
let bx0 = 1e9, by0 = 1e9, bx1 = -1e9, by1 = -1e9;
|
|
646
|
+
const g = {};
|
|
647
|
+
Object.entries(elems).forEach(([cle, e]) => {
|
|
648
|
+
const b = g[cle] = { l: e.offsetLeft, t: e.offsetTop, w: e.offsetWidth, h: e.offsetHeight };
|
|
649
|
+
bx0 = Math.min(bx0, b.l); by0 = Math.min(by0, b.t);
|
|
650
|
+
bx1 = Math.max(bx1, b.l + b.w); by1 = Math.max(by1, b.t + b.h);
|
|
651
|
+
});
|
|
652
|
+
const s = Math.min((W - 2 * pad) / (bx1 - bx0 || 1), (H - 2 * pad) / (by1 - by0 || 1));
|
|
653
|
+
const ox = pad - bx0 * s, oy = pad - by0 * s;
|
|
654
|
+
const c = document.createElement("canvas");
|
|
655
|
+
c.width = W; c.height = H;
|
|
656
|
+
const cx = c.getContext("2d");
|
|
657
|
+
Object.entries(elems).forEach(([cle, e]) => {
|
|
658
|
+
if (e.classList.contains("efface")) return;
|
|
659
|
+
const b = g[cle];
|
|
660
|
+
cx.fillStyle = D.schemas[parCle[cle].schema] || "#9aa3ad";
|
|
661
|
+
cx.fillRect(b.l * s + ox, b.t * s + oy, Math.max(1, b.w * s), Math.max(1, b.h * s));
|
|
662
|
+
});
|
|
663
|
+
miniCouche = { c, s, ox, oy };
|
|
664
|
+
}
|
|
665
|
+
const { s, ox, oy } = miniCouche;
|
|
610
666
|
miniCtx.clearRect(0, 0, W, H);
|
|
611
|
-
|
|
612
|
-
if (e.classList.contains("efface")) return;
|
|
613
|
-
miniCtx.fillStyle = D.schemas[parCle[cle].schema] || "#9aa3ad";
|
|
614
|
-
miniCtx.fillRect(e.offsetLeft * s + ox, e.offsetTop * s + oy,
|
|
615
|
-
Math.max(1, e.offsetWidth * s), Math.max(1, e.offsetHeight * s));
|
|
616
|
-
});
|
|
667
|
+
miniCtx.drawImage(miniCouche.c, 0, 0);
|
|
617
668
|
const vx0 = -x / k, vy0 = -y / k;
|
|
618
669
|
miniCtx.strokeStyle = getComputedStyle(document.documentElement)
|
|
619
670
|
.getPropertyValue("--ligne-vive") || "#0b74c4";
|
|
@@ -630,6 +681,7 @@ miniCanvas.addEventListener("click", e => {
|
|
|
630
681
|
rendre();
|
|
631
682
|
});
|
|
632
683
|
function cadrer(cles) {
|
|
684
|
+
miniCouche = null; // framing follows a layout change (isolate, overview, fonts settled)
|
|
633
685
|
let x0 = 1e9, y0 = 1e9, x1 = -1e9, y1 = -1e9;
|
|
634
686
|
cles.forEach(c => {
|
|
635
687
|
const e = elems[c];
|
|
@@ -690,11 +742,29 @@ function annulerDispo() {
|
|
|
690
742
|
majBoutonAnnuler();
|
|
691
743
|
}
|
|
692
744
|
btnAnnuler.addEventListener("click", annulerDispo);
|
|
693
|
-
function liensAuProchainRendu() {
|
|
694
|
-
// one link
|
|
745
|
+
function liensAuProchainRendu(cle) {
|
|
746
|
+
// one link update per frame while a table is being dragged
|
|
695
747
|
if (lienPrevus) return;
|
|
696
748
|
lienPrevus = true;
|
|
697
|
-
requestAnimationFrame(() => { lienPrevus = false;
|
|
749
|
+
requestAnimationFrame(() => { lienPrevus = false; majLiensDe(cle); });
|
|
750
|
+
}
|
|
751
|
+
// A dragged table is the only box that moves, so only its own links change
|
|
752
|
+
// shape: reroute those (visible + hit path) instead of redrawing every link each
|
|
753
|
+
// frame (~100 ms per frame on a 5000-table model). Markers follow the geometry,
|
|
754
|
+
// so with cardinalities shown the full redraw still runs.
|
|
755
|
+
function majLiensDe(cle) {
|
|
756
|
+
miniCouche = null; // the dragged box moved
|
|
757
|
+
if (cardOn) { dessinerLiens(); return; }
|
|
758
|
+
if (!liensEls) indexerLiens();
|
|
759
|
+
const boites = {};
|
|
760
|
+
liensVus.forEach((f, i) => {
|
|
761
|
+
if (f.de !== cle && f.vers !== cle) return;
|
|
762
|
+
boites[f.de] = boites[f.de] || boite(f.de);
|
|
763
|
+
boites[f.vers] = boites[f.vers] || boite(f.vers);
|
|
764
|
+
const d = trace(f, boites);
|
|
765
|
+
if (liensEls[i]) liensEls[i].setAttribute("d", d);
|
|
766
|
+
if (liensClics[i]) liensClics[i].setAttribute("d", d);
|
|
767
|
+
});
|
|
698
768
|
}
|
|
699
769
|
vp.addEventListener("pointerdown", e => {
|
|
700
770
|
const table = e.target.closest(".table");
|
|
@@ -714,7 +784,7 @@ vp.addEventListener("pointermove", e => {
|
|
|
714
784
|
// pointer deltas are in screen pixels, the plan is scaled by k
|
|
715
785
|
drag.table.style.left = Math.round(drag.tx + (e.clientX - drag.px) / k) + "px";
|
|
716
786
|
drag.table.style.top = Math.round(drag.ty + (e.clientY - drag.py) / k) + "px";
|
|
717
|
-
liensAuProchainRendu();
|
|
787
|
+
liensAuProchainRendu(drag.table.dataset.cle);
|
|
718
788
|
} else {
|
|
719
789
|
vuePrise = true; // the viewer is panning
|
|
720
790
|
x = drag.ox + e.clientX - drag.px;
|
|
File without changes
|
|
File without changes
|
|
File without changes
|