@cardenelabs/dragon 0.45.0 → 0.45.3
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/cli.cjs +71 -30
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.js +71 -30
- package/dist/cli.js.map +1 -1
- package/dist/export.cjs +71 -30
- package/dist/export.cjs.map +1 -1
- package/dist/export.js +71 -30
- package/dist/export.js.map +1 -1
- package/dist/index.cjs +71 -30
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +71 -30
- package/dist/index.js.map +1 -1
- package/dist/light/{chunk-VRAW7VAQ.cjs → chunk-5OQV42W3.cjs} +50 -19
- package/dist/light/chunk-5OQV42W3.cjs.map +1 -0
- package/dist/light/chunk-CLS6JVKK.cjs.map +1 -1
- package/dist/light/{chunk-JNSHZTPF.js → chunk-EHTQUCW4.js} +49 -18
- package/dist/light/chunk-EHTQUCW4.js.map +1 -0
- package/dist/light/{chunk-OUQ44P45.cjs → chunk-JCEKXALJ.cjs} +81 -81
- package/dist/light/{chunk-OUQ44P45.cjs.map → chunk-JCEKXALJ.cjs.map} +1 -1
- package/dist/light/{chunk-6ZUKJ3VO.js → chunk-YEQSLVIN.js} +2 -2
- package/dist/light/{git-C4RVNFT6.js → git-GESUYKGR.js} +3 -3
- package/dist/light/{git-I7D7RIW2.cjs → git-K3KAAAWW.cjs} +59 -59
- package/dist/light/{git-I7D7RIW2.cjs.map → git-K3KAAAWW.cjs.map} +1 -1
- package/dist/light/index.cjs +232 -220
- package/dist/light/index.cjs.map +1 -1
- package/dist/light/index.js +32 -20
- package/dist/light/index.js.map +1 -1
- package/dist/light/{lineup-YEG4HHEI.js → lineup-2V2U7HZH.js} +3 -3
- package/dist/light/{lineup-FAIKTH3Y.cjs → lineup-623J25LU.cjs} +40 -40
- package/dist/light/{lineup-FAIKTH3Y.cjs.map → lineup-623J25LU.cjs.map} +1 -1
- package/dist/light/{state-ZZUK6AQT.cjs → state-OZVCHX7H.cjs} +41 -41
- package/dist/light/{state-ZZUK6AQT.cjs.map → state-OZVCHX7H.cjs.map} +1 -1
- package/dist/light/{state-P3LIVI3K.js → state-T4OTVING.js} +2 -2
- package/dist/light/{time-B5WUQOFP.js → time-6WEMD4FQ.js} +3 -3
- package/dist/light/{time-64DJKYAL.cjs → time-PQCPVQOE.cjs} +84 -84
- package/dist/light/{time-64DJKYAL.cjs.map → time-PQCPVQOE.cjs.map} +1 -1
- package/dist/light/{tree-66EH4QVI.cjs → tree-6D7KI57H.cjs} +62 -62
- package/dist/light/{tree-66EH4QVI.cjs.map → tree-6D7KI57H.cjs.map} +1 -1
- package/dist/light/{tree-5HPREYW2.js → tree-ZJZQI5QT.js} +3 -3
- package/dist/player.global.js +3 -3
- package/package.json +1 -1
- package/src/layout/scene.ts +58 -16
- package/src/look/values.ts +1 -1
- package/src/render/draw.ts +39 -17
- package/dist/light/chunk-JNSHZTPF.js.map +0 -1
- package/dist/light/chunk-VRAW7VAQ.cjs.map +0 -1
- /package/dist/light/{chunk-6ZUKJ3VO.js.map → chunk-YEQSLVIN.js.map} +0 -0
- /package/dist/light/{git-C4RVNFT6.js.map → git-GESUYKGR.js.map} +0 -0
- /package/dist/light/{lineup-YEG4HHEI.js.map → lineup-2V2U7HZH.js.map} +0 -0
- /package/dist/light/{state-P3LIVI3K.js.map → state-T4OTVING.js.map} +0 -0
- /package/dist/light/{time-B5WUQOFP.js.map → time-6WEMD4FQ.js.map} +0 -0
- /package/dist/light/{tree-5HPREYW2.js.map → tree-ZJZQI5QT.js.map} +0 -0
package/dist/cli.js
CHANGED
|
@@ -512,7 +512,7 @@ var LOOK = {
|
|
|
512
512
|
/**
|
|
513
513
|
* `trail` は状態遷移図の帯の最後の、通った状態の点 (#3171)。`r` は点の半径、`step` は点の中心どうしの間、`now` は変わった値の欄の名前の横の点の半径と、名前からの離れ
|
|
514
514
|
*/
|
|
515
|
-
strip: { h: 72, line: 44, pad: 12, icon: 24, titleX: 44, fieldGap: 22, sepInset: 14, tagGap: 6, tagH: 15, tagPadX: 7, nameY: 22, valueY: 43, trail: { r: 5.4, step: 16 }, now: { r: 3, gap: 7 } },
|
|
515
|
+
strip: { h: 72, line: 44, titleRow: 40, pad: 12, icon: 24, titleX: 44, fieldGap: 22, sepInset: 14, tagGap: 6, tagH: 15, tagPadX: 7, nameY: 22, valueY: 43, trail: { r: 5.4, step: 16 }, now: { r: 3, gap: 7 } },
|
|
516
516
|
/** `time` から始まる値は時間軸の図 (#3165) の、目盛りの印の枠、拡大の枠、時刻の線、範囲の括弧と囲み、節目へ下ろす点線、節目の丸、針、物差しの線の印 */
|
|
517
517
|
stroke: {
|
|
518
518
|
git: 2.25,
|
|
@@ -993,26 +993,40 @@ function fieldWidth(diagram, name) {
|
|
|
993
993
|
var trailWidth = (trail) => Math.max(textWidth(trail.title, TYPE.fieldName), trail.states.length * LOOK.strip.trail.step);
|
|
994
994
|
function stripNeed(diagram, trail) {
|
|
995
995
|
if (!diagram.strip) return 0;
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
996
|
+
return rowNeed(diagram.strip.title, [...diagram.strip.fields.map((name) => fieldWidth(diagram, name)), ...trail ? [trailWidth(trail)] : []]);
|
|
997
|
+
}
|
|
998
|
+
function rowNeed(title, widths) {
|
|
999
|
+
const { fieldGap, pad: pad2 } = LOOK.strip;
|
|
1000
|
+
return stripStart(title) + widths.reduce((sum, w) => sum + w + fieldGap, 0) - fieldGap + pad2;
|
|
1001
|
+
}
|
|
1002
|
+
function stripStart(title) {
|
|
1003
|
+
return LOOK.strip.titleX + textWidth(title, TYPE.stripTitle) + LOOK.strip.fieldGap;
|
|
1004
|
+
}
|
|
1005
|
+
function fieldPlacer(start, width) {
|
|
1006
|
+
const { fieldGap, pad: pad2 } = LOOK.strip;
|
|
1007
|
+
let cx = start;
|
|
1008
|
+
let row = 0;
|
|
1009
|
+
return {
|
|
1010
|
+
place(w) {
|
|
1011
|
+
if (cx > start && cx + w > width - pad2) {
|
|
1012
|
+
cx = start;
|
|
1013
|
+
row++;
|
|
1014
|
+
}
|
|
1015
|
+
const at2 = { x: cx, row };
|
|
1016
|
+
cx += w + fieldGap;
|
|
1017
|
+
return at2;
|
|
1018
|
+
},
|
|
1019
|
+
rows: () => row
|
|
1020
|
+
};
|
|
1000
1021
|
}
|
|
1001
1022
|
function layoutStrip(diagram, x, y, width, trail) {
|
|
1002
1023
|
if (!diagram.strip) return void 0;
|
|
1003
|
-
const {
|
|
1004
|
-
const start = titleX + textWidth(diagram.strip.title, TYPE.stripTitle) + fieldGap;
|
|
1024
|
+
const { line, h } = LOOK.strip;
|
|
1005
1025
|
const fields = [];
|
|
1006
|
-
|
|
1007
|
-
let row = 0;
|
|
1026
|
+
const placer = fieldPlacer(stripStart(diagram.strip.title), width);
|
|
1008
1027
|
const place2 = (w) => {
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
row++;
|
|
1012
|
-
}
|
|
1013
|
-
const at2 = { x: x + cx, y: y + row * line };
|
|
1014
|
-
cx += w + fieldGap;
|
|
1015
|
-
return at2;
|
|
1028
|
+
const at2 = placer.place(w);
|
|
1029
|
+
return { x: x + at2.x, y: y + at2.row * line };
|
|
1016
1030
|
};
|
|
1017
1031
|
for (const name of diagram.strip.fields) {
|
|
1018
1032
|
const w = fieldWidth(diagram, name);
|
|
@@ -1022,7 +1036,23 @@ function layoutStrip(diagram, x, y, width, trail) {
|
|
|
1022
1036
|
fields.push({ name, ...at2, w, ...meter && line2 !== void 0 ? { meter: { line: line2, text: meter.line, x: at2.x, w: LOOK.time.meter.w } } : {} });
|
|
1023
1037
|
}
|
|
1024
1038
|
const laidTrail = trail ? { ...trail, ...place2(trailWidth(trail)), w: trailWidth(trail) } : void 0;
|
|
1025
|
-
return { x, y, w: width, h: h +
|
|
1039
|
+
return { x, y, w: width, h: h + placer.rows() * line, title: diagram.strip.title, fields, ...laidTrail ? { trail: laidTrail } : {} };
|
|
1040
|
+
}
|
|
1041
|
+
function rewrapStrip(s, x, y, width) {
|
|
1042
|
+
const { line, h, pad: pad2, titleRow } = LOOK.strip;
|
|
1043
|
+
const stacked = rowNeed(s.title, [...s.fields.map((f) => f.w), ...s.trail ? [s.trail.w] : []]) > width;
|
|
1044
|
+
const top = stacked ? titleRow : 0;
|
|
1045
|
+
const placer = fieldPlacer(stacked ? pad2 : stripStart(s.title), width);
|
|
1046
|
+
const place2 = (w) => {
|
|
1047
|
+
const at2 = placer.place(w);
|
|
1048
|
+
return { x: x + at2.x, y: y + top + at2.row * line };
|
|
1049
|
+
};
|
|
1050
|
+
const fields = s.fields.map((field) => {
|
|
1051
|
+
const at2 = place2(field.w);
|
|
1052
|
+
return { ...field, ...at2, ...field.meter ? { meter: { ...field.meter, x: at2.x } } : {} };
|
|
1053
|
+
});
|
|
1054
|
+
const trail = s.trail ? { ...s.trail, ...place2(s.trail.w) } : void 0;
|
|
1055
|
+
return { ...s, x, y, w: width, h: h + placer.rows() * line + top, fields, ...trail ? { trail } : {} };
|
|
1026
1056
|
}
|
|
1027
1057
|
function shiftContent(layout, dx, dy) {
|
|
1028
1058
|
const move = (rect) => {
|
|
@@ -9241,7 +9271,8 @@ function drawSvg(diagram, layout, timeline, palette, theme, follow, ink = [], tr
|
|
|
9241
9271
|
const arrivals = new Map((timeline.states ?? []).flatMap((s) => s.lit[0] ? [[s.box, s.lit[0].start]] : []));
|
|
9242
9272
|
const meters = new Map((timeline.meters ?? []).map((meter) => [meter.field, meter.keys]));
|
|
9243
9273
|
const gauge = (field) => field.meter ? kindParts("time").meterField({ ...field, meter: field.meter }, meters.get(field.name) ?? [[0, 0]], ctx) : void 0;
|
|
9244
|
-
|
|
9274
|
+
const drawStrip = (s) => strip(s, fieldChanges(diagram, timeline, layout), ctx, isState, arrivals, gauge);
|
|
9275
|
+
if (layout.strip && !follow) L.band.push(drawStrip(layout.strip));
|
|
9245
9276
|
for (const line of layout.lifelines) L.base.push(lifeline(line.x, line.y1, line.y2));
|
|
9246
9277
|
if (isGitLayout(layout)) {
|
|
9247
9278
|
const git = kindParts("git").drawGit(layout, diagram, timeline, ctx);
|
|
@@ -9293,7 +9324,7 @@ function drawSvg(diagram, layout, timeline, palette, theme, follow, ink = [], tr
|
|
|
9293
9324
|
L.node.push(linked(box.id, card(box, ctx, on.get(box.id) ?? [], subs.get(box.id) ?? [], isState ? state?.lit ?? [] : void 0)));
|
|
9294
9325
|
if (state?.done !== void 0) L.node.push(doneMark(box, state.done, ctx));
|
|
9295
9326
|
}
|
|
9296
|
-
for (const b of layout.badges) L.badge.push(badge(b, ctx, isState));
|
|
9327
|
+
for (const b of layout.badges) if (!(follow && onStrip(layout, b))) L.badge.push(badge(b, ctx, isState));
|
|
9297
9328
|
for (const l of layout.labels) {
|
|
9298
9329
|
const time = timeline.labels.find((t) => t.step === l.step && t.event === l.event);
|
|
9299
9330
|
if (time) L.top.push(label(l, fadeBefore(l, time, timeline.steps), ctx));
|
|
@@ -9313,7 +9344,8 @@ function drawSvg(diagram, layout, timeline, palette, theme, follow, ink = [], tr
|
|
|
9313
9344
|
const { near, far, nearY, farY } = LOOK.shadow;
|
|
9314
9345
|
const shadow = `<filter id="dg-sh-${id}" x="-20%" y="-30%" width="140%" height="180%"><feDropShadow dx="0" dy="${nearY}" stdDeviation="${near}" style="flood-color:var(--sh);flood-opacity:var(--shA)"/><feDropShadow dx="0" dy="${farY}" stdDeviation="${far}" style="flood-color:var(--sh);flood-opacity:var(--shB)"/></filter>`;
|
|
9315
9346
|
const heads = follow && layout.kind === "sequence" ? layout.boxes.map((box) => linked(box.id, headCard(box, ctx, on.get(box.id) ?? [], subs.get(box.id) ?? []))).join("") : "";
|
|
9316
|
-
const
|
|
9347
|
+
const drawTable = (s, from) => drawStrip(s) + layout.badges.filter((b) => onStrip(layout, b)).map((b) => badge({ ...b, x: b.x - from.x + s.x + LOOK.badge.r, y: b.y - from.y + s.y }, ctx, isState)).join("");
|
|
9348
|
+
const view = follow ? followView(layout, timeline, diagram, m, id, content, follow, heads, drawTable) : { body: `<rect class="dg-bg" width="${layout.width}" height="${layout.height}" rx="${LOOK.region.radius}"/>${content}`, w: layout.width, h: layout.height };
|
|
9317
9349
|
const css = `.dg-${id}{${FONT_VARS};--T:${timeline.total}s;${vars}}${PART_CSS}${m.frames.join("")}`;
|
|
9318
9350
|
return `<svg xmlns="http://www.w3.org/2000/svg" class="dg dg-${id}" viewBox="0 0 ${Math.ceil(view.w)} ${Math.ceil(view.h)}" width="${Math.ceil(view.w)}" height="${Math.ceil(view.h)}" role="img" aria-label="${esc(diagram.title)}" data-dragon="figure" data-view="${follow ? "follow" : "fixed"}"><style>${css}</style><defs>${shadow}</defs>${view.body}</svg>`;
|
|
9319
9351
|
}
|
|
@@ -9322,6 +9354,9 @@ function union(rects) {
|
|
|
9322
9354
|
const y = Math.min(...rects.map((r) => r.y));
|
|
9323
9355
|
return { x, y, w: Math.max(...rects.map((r) => r.x + r.w)) - x, h: Math.max(...rects.map((r) => r.y + r.h)) - y };
|
|
9324
9356
|
}
|
|
9357
|
+
function onStrip(layout, badge2) {
|
|
9358
|
+
return layout.strip !== void 0 && badge2.y >= layout.strip.y;
|
|
9359
|
+
}
|
|
9325
9360
|
function focusOf(layout, diagram, step) {
|
|
9326
9361
|
const rects = focusParts(layout, diagram, step);
|
|
9327
9362
|
return rects.length === 0 ? void 0 : union(rects);
|
|
@@ -9367,31 +9402,33 @@ function focusParts(layout, diagram, step) {
|
|
|
9367
9402
|
}
|
|
9368
9403
|
return rects;
|
|
9369
9404
|
}
|
|
9370
|
-
function followView(layout, timeline, diagram, m, id, content, follow, heads) {
|
|
9405
|
+
function followView(layout, timeline, diagram, m, id, content, follow, heads, drawTable) {
|
|
9371
9406
|
const F = LOOK.follow;
|
|
9372
9407
|
const M = LOOK.mini;
|
|
9373
9408
|
const frameWidth = Math.max(1, follow.width);
|
|
9374
9409
|
const full = Math.min(layout.width, frameWidth);
|
|
9410
|
+
const worldH = layout.strip ? layout.strip.y : layout.height;
|
|
9375
9411
|
const title = FIGURE_TEXT[follow.lang].overview;
|
|
9376
9412
|
const sized = (vh2) => {
|
|
9377
9413
|
const mw2 = Math.min(M.w, full * 0.4, vh2 * 0.4 / layout.height * layout.width);
|
|
9378
9414
|
const k2 = mw2 / layout.width;
|
|
9379
|
-
const mh2 =
|
|
9415
|
+
const mh2 = worldH * k2;
|
|
9380
9416
|
const bw2 = Math.max(mw2, Math.ceil(textWidth(title, TYPE.miniTitle)));
|
|
9381
9417
|
return { vh: vh2, mw: mw2, k: k2, mh: mh2, bw: bw2, bgW: bw2 + M.pad * 2, bgH: mh2 + M.pad * 2 + M.title, beside: mh2 > mw2 };
|
|
9382
9418
|
};
|
|
9383
|
-
const natural = sized(Math.min(
|
|
9384
|
-
const bare = natural.beside
|
|
9385
|
-
const
|
|
9386
|
-
const
|
|
9419
|
+
const natural = sized(Math.min(worldH, Math.max(F.minH, full * F.aspect)));
|
|
9420
|
+
const bare = frameWidth < F.narrow && (natural.beside || layout.strip !== void 0);
|
|
9421
|
+
const tableH = layout.strip ? rewrapStrip(layout.strip, 0, 0, full).h + M.inset : 0;
|
|
9422
|
+
const room = follow.height === void 0 ? Number.POSITIVE_INFINITY : (natural.beside || bare ? follow.height : follow.height - natural.bgH - M.inset) - tableH;
|
|
9423
|
+
const { vh, mw, k, mh, bw, bgW, bgH, beside } = room < natural.vh ? sized(Math.max(F.fitMinH, room)) : { ...natural, vh: Number.isFinite(room) ? Math.min(worldH, room) : natural.vh };
|
|
9387
9424
|
const vw = beside && !bare ? Math.min(layout.width, frameWidth - bgW - M.inset) : full;
|
|
9388
9425
|
const clampX = (x) => Math.min(layout.width - vw / 2, Math.max(vw / 2, x));
|
|
9389
9426
|
const top = heads === "" ? 0 : Math.max(...layout.boxes.map((b) => b.y + b.h)) + F.headRoom;
|
|
9390
9427
|
const strip2 = heads === "" ? 0 : F.head.pad * 2 + F.head.h;
|
|
9391
9428
|
const below = vh - strip2;
|
|
9392
|
-
const clampY = (y) => Math.min(
|
|
9429
|
+
const clampY = (y) => Math.min(worldH - below / 2, Math.max(top + below / 2, y));
|
|
9393
9430
|
const r = LOOK.badge.r;
|
|
9394
|
-
let prev = [layout.width / 2,
|
|
9431
|
+
let prev = [layout.width / 2, worldH / 2];
|
|
9395
9432
|
const middles = timeline.steps.map((_, s) => {
|
|
9396
9433
|
if (isTimeLayout(layout)) {
|
|
9397
9434
|
const f2 = kindParts("time").timeFocus(layout, timeline, s, focusParts(layout, diagram, s), vw, below);
|
|
@@ -9402,7 +9439,7 @@ function followView(layout, timeline, diagram, m, id, content, follow, heads) {
|
|
|
9402
9439
|
prev = f ? [f.x + f.w / 2, f.y + f.h / 2] : prev;
|
|
9403
9440
|
const at2 = [clampX(prev[0]), clampY(prev[1])];
|
|
9404
9441
|
const b = layout.badges.find((x) => x.step === s);
|
|
9405
|
-
if (!b || Math.abs(b.x - at2[0]) <= vw / 2 - r && Math.abs(b.y - at2[1]) <= below / 2 - r) return at2;
|
|
9442
|
+
if (!b || onStrip(layout, b) || Math.abs(b.x - at2[0]) <= vw / 2 - r && Math.abs(b.y - at2[1]) <= below / 2 - r) return at2;
|
|
9406
9443
|
const near = badgeFocus(b, focusParts(layout, diagram, s), vw, below);
|
|
9407
9444
|
prev = [near.x + near.w / 2, near.y + near.h / 2];
|
|
9408
9445
|
return [clampX(prev[0]), clampY(prev[1])];
|
|
@@ -9442,7 +9479,11 @@ function followView(layout, timeline, diagram, m, id, content, follow, heads) {
|
|
|
9442
9479
|
const mini = bare ? { clip: "", body: "" } : overview();
|
|
9443
9480
|
const head = strip2 === 0 ? "" : `<g class="dg-hd"><rect class="dg-hd-bg" width="${vw}" height="${strip2}"/><line class="dg-sep" x1="0" y1="${strip2}" x2="${vw}" y2="${strip2}"/><g class="dg-a" style="${m.move(cam.map(([t, cx, , s, e]) => [t, vw / 2 - cx, 0, s, e]))}">${heads}</g></g>`;
|
|
9444
9481
|
const body = `<defs><clipPath id="dg-vp-${id}"><rect width="${vw}" height="${vh}" rx="${LOOK.region.radius}"/></clipPath>${mini.clip}</defs><g clip-path="url(#dg-vp-${id})"><rect class="dg-vp-bg" width="${vw}" height="${vh}"/><g class="dg-a" style="${camKf}">${content}</g>${head}</g><rect class="dg-vp-frame" x="0.5" y="0.5" width="${vw - 1}" height="${vh - 1}" rx="${LOOK.region.radius}"/>${mini.body}`;
|
|
9445
|
-
|
|
9482
|
+
const w = beside && !bare ? vw + M.inset + bgW : full;
|
|
9483
|
+
const bottom = beside || bare ? vh : bgY + bgH;
|
|
9484
|
+
if (!layout.strip) return { body, w, h: bottom };
|
|
9485
|
+
const table = rewrapStrip(layout.strip, 0, bottom + M.inset, full);
|
|
9486
|
+
return { body: body + drawTable(table, layout.strip), w, h: table.y + table.h };
|
|
9446
9487
|
}
|
|
9447
9488
|
function paletteOf(options, theme) {
|
|
9448
9489
|
const palette = resolvePalette(options.palette);
|