fastdraw 0.2.2 → 0.4.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/cli.js CHANGED
@@ -10312,8 +10312,8 @@ import { dirname as dirname5, join as join5, resolve as resolve4, basename as ba
10312
10312
  import { fileURLToPath as fileURLToPath2 } from "node:url";
10313
10313
 
10314
10314
  // src/node.ts
10315
- import { readFileSync, readdirSync, existsSync, mkdtempSync, writeFileSync, rmSync } from "node:fs";
10316
- import { tmpdir } from "node:os";
10315
+ import { readFileSync, readdirSync, existsSync, mkdtempSync, mkdirSync, writeFileSync, rmSync } from "node:fs";
10316
+ import { tmpdir, homedir } from "node:os";
10317
10317
  import { fileURLToPath } from "node:url";
10318
10318
 
10319
10319
  // src/fontmeta.ts
@@ -10457,7 +10457,7 @@ function parseStatements(src) {
10457
10457
  // src/defaultLook.ts
10458
10458
  var DEFAULT_LOOK = `// FastDraw default look. Copy it with "fastdraw init-look" and change anything.
10459
10459
  // A light neutral page, white cards with rounded corners and a two-tone icon, softly tinted zones,
10460
- // neutral greys for everything else and one tomato red for the subject and the main path. Geist for names and details, Geist Mono for small technical labels.
10460
+ // neutral greys for everything else and one tomato red for the subject and the main path. Libre Caslon Display for the title, Geist for names and details, Geist Mono for small technical labels.
10461
10461
 
10462
10462
  canvas paper=paper dots=ink/0.07 dotgap=24
10463
10463
 
@@ -10479,7 +10479,7 @@ color violet #7c3aed
10479
10479
 
10480
10480
  font sans "Geist"
10481
10481
  font mono "Geist Mono"
10482
- font serif "Newsreader"
10482
+ font serif "Libre Caslon Display"
10483
10483
 
10484
10484
  // ---- boxes ----------------------------------------------------------------
10485
10485
  style node shape=rect radius=10 size=144x64 fill=#ffffff stroke=ink/0.14 sw=1 sub.font=sans sub.color=muted
@@ -10538,7 +10538,7 @@ style lifeline line head=none stroke=ink/0.20 sw=1 dash=4,4 route=straight use="
10538
10538
  style rule line head=none stroke=ink/0.10 sw=1 route=straight use="thin separator, e.g. above a legend"
10539
10539
 
10540
10540
  // ---- text -----------------------------------------------------------------
10541
- style h1 text font=sans size=26 weight=700 spacing=-0.03 color=ink use="diagram title"
10541
+ style h1 text font=serif size=30 weight=400 spacing=-0.01 dy=4 color=ink use="diagram title"
10542
10542
  style kicker text font=mono size=10 weight=500 color=accent spacing=0.12 caps=1 use="optional: a short category above the title, e.g. PROCESS"
10543
10543
  style dek text font=sans size=14 color=muted use="optional: one line under the title saying what the diagram shows"
10544
10544
  style eyebrow text font=mono size=8 color=muted spacing=0.14 caps=1 use="small caps label, e.g. LEGEND"
@@ -11344,14 +11344,14 @@ var DUOTONE_TINT = {
11344
11344
  // src/icons.ts
11345
11345
  var ICONS = ICON_WEIGHTS.regular;
11346
11346
  var ICON_WORDS = {
11347
- "active-directory": "ad identity directory ldap",
11347
+ "active-directory": "ad identity directory ldap entra aad",
11348
11348
  admin: "administrator superuser",
11349
11349
  alert: "warning danger",
11350
11350
  api: "endpoint rest interface",
11351
11351
  backup: "save snapshot",
11352
- bucket: "object storage blob s3",
11352
+ bucket: "object storage blob s3 account",
11353
11353
  cache: "fast redis memcached",
11354
- cdn: "edge",
11354
+ cdn: "edge front door",
11355
11355
  cloud: "saas hosted",
11356
11356
  container: "docker image",
11357
11357
  database: "db store table postgres mysql",
@@ -11367,12 +11367,12 @@ var ICON_WORDS = {
11367
11367
  "load-balancer": "lb balancer traffic",
11368
11368
  lock: "secure private auth",
11369
11369
  log: "logs logging audit",
11370
- monitoring: "metrics observability graph",
11370
+ monitoring: "metrics observability graph insights telemetry",
11371
11371
  node: "cluster graph mesh",
11372
11372
  phone: "mobile smartphone device",
11373
11373
  pipeline: "ci cd build workflow",
11374
11374
  pod: "kubernetes k8s",
11375
- queue: "messages broker kafka rabbitmq sqs topic",
11375
+ queue: "messages broker kafka rabbitmq sqs topic bus",
11376
11376
  request: "send outbound",
11377
11377
  response: "reply return",
11378
11378
  robot: "bot agent automation",
@@ -11387,7 +11387,7 @@ var ICON_WORDS = {
11387
11387
  vm: "virtual machine instance compute",
11388
11388
  volume: "disk storage ssd",
11389
11389
  vpn: "tunnel private network",
11390
- mail: "email inbox smtp",
11390
+ mail: "email inbox smtp letter envelope",
11391
11391
  message: "sms notification",
11392
11392
  chat: "conversation messages talk",
11393
11393
  bell: "notification alert alarm",
@@ -11411,7 +11411,7 @@ var ICON_WORDS = {
11411
11411
  fingerprint: "biometric identity",
11412
11412
  id: "identity badge card",
11413
11413
  password: "credential login secret",
11414
- cart: "shop checkout ecommerce",
11414
+ cart: "shop checkout ecommerce basket",
11415
11415
  payment: "card billing checkout",
11416
11416
  money: "cost price coin finance",
11417
11417
  building: "office company",
@@ -11432,7 +11432,7 @@ var ICON_WORDS = {
11432
11432
  sparkles: "magic ai new",
11433
11433
  package: "artifact npm library",
11434
11434
  box: "product",
11435
- truck: "delivery shipping logistics",
11435
+ truck: "delivery shipping logistics van lorry",
11436
11436
  broadcast: "stream publish pubsub event",
11437
11437
  "git-merge": "merge",
11438
11438
  "git-commit": "commit version",
@@ -11472,341 +11472,35 @@ function iconMatches(name2, word) {
11472
11472
  const words = ICON_WORDS[name2];
11473
11473
  return !!words && words.split(" ").some((x) => x.startsWith(w) || x === w.replace(/-/g, ""));
11474
11474
  }
11475
+ var FIRST = Object.keys(ICONS);
11476
+ var VAGUE = /* @__PURE__ */ new Set(["app", "apps", "application", "applications", "data", "web", "manager", "management"]);
11477
+ var VENDOR_WORDS = /* @__PURE__ */ new Set(["icon", "icons", "service", "services", "azure", "aws", "amazon", "gcp", "google", "microsoft", "ms", "the", "and", "for", "of"]);
11478
+ function standInIcon(name2) {
11479
+ if (FIRST.includes(name2)) return name2;
11480
+ const words = name2.split("-").filter((w) => w.length > 1 && !VENDOR_WORDS.has(w) && !/^\d+$/.test(w));
11481
+ const hit = (n, w) => w.length > 2 ? iconMatches(n, w) ? 1 : w.length > 3 && w.endsWith("s") && iconMatches(n, w.slice(0, -1)) ? 0.75 : 0 : ICON_WORDS[n]?.split(" ").includes(w) ? 1 : 0;
11482
+ let best = "box", score = 0;
11483
+ for (const n of FIRST) {
11484
+ let s = iconMatches(n, name2) && name2.length > 2 ? 4 : 0;
11485
+ for (const w of words) s += (n === w ? 3 : n + "s" === w ? 2.5 : hit(n, w)) * (VAGUE.has(w) ? 0.25 : 1);
11486
+ if (s > score) {
11487
+ best = n;
11488
+ score = s;
11489
+ }
11490
+ }
11491
+ return best;
11492
+ }
11475
11493
 
11476
11494
  // src/bundledLooks.ts
11477
11495
  var BUNDLED_LOOKS = {
11478
- engraved: `// Engraved: a plate from an old technical book. Double rules round every box, shadows cut in fine lines,
11479
- // a tall serif title and italic notes on the lines, a black plate for the subject and a red double line
11480
- // for the main path. Same style names as the built-in look.
11481
-
11482
- canvas paper=paper
11483
-
11484
- color paper #f3eee2
11485
- color card #fbf8f0
11486
- color block #e7dfcd
11487
- color ink #1c1814
11488
- color muted #5d554a
11489
- color soft #9a8f7f
11490
- color accent #b3261a
11491
- color link #1c1814
11492
- color teal #2f6f62
11493
- color amber #a8742a
11494
- color rose #b3261a
11495
- color violet #5b4a8a
11496
-
11497
- font sans "Newsreader"
11498
- font mono "Geist Mono"
11499
- font serif "Instrument Serif"
11500
-
11501
- // ---- boxes -----------------------------------------------------------------
11502
- style node shape=rect radius=0 size=144x64 fill=card stroke=ink sw=1.2 inner=ink inner.gap=3.5 inner.sw=0.5 shade=ink shade.gap=3 shade.sw=0.7
11503
- title.size=12.5 sub.font=serif sub.italic=1 sub.size=11.5 sub.color=ink/0.8 tag.color=ink tag.border=ink/0.5 tag.font=mono icon.color=ink use="default box: a backend, service, component or step"
11504
- style focal extends node fill=ink inner=paper shade.gap=2.2 shade.sw=0.9 title.color=paper sub.color=paper/0.85
11505
- tag.color=paper tag.border=paper/0.6 icon.color=paper ghost.color=paper/0.14 use="the one or two elements the diagram is about"
11506
- style store extends node shape=path path="M0,0.1 C0,-0.035 1,-0.035 1,0.1 L1,0.9 C1,1.035 0,1.035 0,0.9 Z M0,0.1 C0,0.235 1,0.235 1,0.1 C1,0.235 0,0.235 0,0.1" inner=none use="something that holds data or state"
11507
- style cloud extends node fill=block use="a hosted or third-party platform"
11508
- style external extends node fill=paper sw=0.9 dash=1.2,3 inner=none shade=none use="a person or system outside what you own"
11509
- style optional extends node fill=paper sw=0.9 dash=4,3 inner=none shade=none use="optional or asynchronous participant"
11510
- style sticky extends node size=120x120 fill=#ead9a0 title.font=serif title.italic=1 title.size=15 title.weight=400 use="a yellow sticky note: an idea, comment or open question"
11511
- style sticky-orange extends sticky fill=#e9c4b0 use="an orange sticky note: a risk or issue"
11512
- style sticky-violet extends sticky fill=#d9d0e6 use="a violet sticky note: a decision or note"
11513
-
11514
- // ---- flowchart shapes ------------------------------------------------------
11515
- style step extends node size=160x48 use="flowchart action"
11516
- style terminal extends node radius=24 size=160x48 use="flowchart start or end"
11517
- style terminal-focal extends terminal fill=ink inner=paper title.color=paper sub.color=paper/0.85 use="the flowchart outcome that matters most"
11518
- style decision shape=diamond size=200x96 fill=card stroke=ink sw=1.2 shade=ink shade.gap=3 shade.sw=0.7 title.size=12.5 use="flowchart yes/no question; put the text on two short lines"
11519
-
11520
- // ---- regions and markers ---------------------------------------------------
11521
- style zone shape=rect radius=0 fill=none hatch=ink/0.4 hatch.gap=5 hatch.sw=0.45 stroke=ink sw=0.8 corners=square layer=back
11522
- title.pos=top title.dy=-11 title.font=sans title.size=11 title.weight=500 title.color=ink title.spacing=0.2 title.caps=1 use="a labelled region drawn behind a group of boxes; always give WxH"
11523
- style bar shape=rect radius=0 size=8x80 fill=ink stroke=ink sw=1 use="sequence diagram activation bar, centred on a lifeline; always give WxH"
11524
- style table shape=table radius=0 fill=card stroke=ink sw=1.2 shade=ink shade.gap=3 shade.sw=0.7 head.fill=block rule=ink/0.18
11525
- title.size=12.5 cell.font=mono cell.size=10 detail.color=muted use="an entity, class or database table: a header and rows. One line per row: | id \\"name\\" \\"type\\" \\"key\\". Arrows can end on a row: orders.user_id -> users.id"
11526
- style matrix extends table align=center grid=1 cell.font=sans use="a grid of values: first row with |= for the column headings, first cell of each row is its name"
11527
- style chart shape=chart fill=none stroke=ink sw=1 mask=0 bar.radius=0 grid.color=ink/0.12
11528
- tick.font=mono tick.size=9 tick.color=muted use="axes with your numbers drawn for you: chart at x,y WxH x=\\"Q1,Q2,Q3\\" y=0..100, then a line per series: | bars \\"Revenue\\" 42 61 75"
11529
-
11530
- // ---- lines -----------------------------------------------------------------
11531
- style arrow line stroke=ink sw=0.95 route=ortho radius=0 head.size=1.15 label.font=sans label.italic=1 label.size=10 label.color=ink label.spacing=0 label.caps=0 use="default arrow"
11532
- style primary extends arrow stroke=accent sw=4.2 double=paper double.sw=1.8 head.size=1.5 label.color=accent use="the main path; at most two per diagram"
11533
- style link extends arrow use="an HTTP or API request crossing a boundary"
11534
- style return extends arrow dash=1.2,3.2 use="a response, or something optional or asynchronous"
11535
- style relation extends relation stroke=ink label.font=sans label.italic=1 label.size=10 label.spacing=0 label.caps=0
11536
- style lifeline line head=none stroke=ink/0.5 sw=0.8 dash=1.2,3 route=straight use="sequence diagram lifeline"
11537
- style rule line head=none stroke=ink/0.45 sw=0.7 route=straight use="thin separator, e.g. above a legend"
11538
-
11539
- // ---- text ------------------------------------------------------------------
11540
- style h1 text font=serif size=36 weight=400 color=ink use="diagram title"
11541
- style kicker text font=sans size=10 weight=500 color=accent spacing=0.2 caps=1 use="optional: a short category above the title, e.g. PROCESS"
11542
- style dek text font=serif italic=1 size=16 color=ink use="optional: one line under the title saying what the diagram shows"
11543
- style eyebrow text font=sans size=9 weight=500 color=ink spacing=0.18 caps=1 use="small caps label, e.g. LEGEND"
11544
- style caption text font=sans size=10 color=muted use="small explanatory text"
11545
- style legend extends legend rule=ink/0.4 title.font=sans title.size=9 item.font=sans item.size=10.5 item.color=ink
11546
- style note text font=serif italic=1 size=15 color=ink use="a short aside; at most two"
11547
- style small text font=mono size=9 color=muted use="technical detail: a port, path or command"
11548
-
11549
- guidance "focal, terminal-focal and primary are the accent. Use the accent on at most two things in one diagram."
11550
- guidance "Never fill a shape with ink to make it stand out; use focal."
11551
- guidance "tag= is a 3 or 4 letter type marker in the corner of a box (EXT, EDGE, API, DB). Use it on architecture boxes, not flowchart shapes."
11552
- guidance "sub= is a short second line of detail: a product name, path, port or protocol. Names of things go in the main text."
11553
- guidance "kicker and dek are optional. Add a kicker only when the diagram belongs to a named category, and a dek only when there is one clear message; most diagrams need neither."
11554
- guidance "Finish with a legend: one statement, 'legend at x,y' followed by style=\\"what it means\\" for each style you used."
11555
- `,
11556
- headline: `// Headline. A named alternative to the built-in look: serif headline over flat newspaper-graphics blocks.
11557
- // Drawn like a newspaper graphics desk: a serif headline over flat, square, pale-grey blocks set in
11558
- // one grotesque, grey for context and one muted crimson for the subject. No shadows, no black fills.
11559
-
11560
- canvas paper=paper
11561
-
11562
- color paper #ffffff
11563
- color ink #1f2328
11564
- color muted #5f6670
11565
- color soft #a3a9b1
11566
- color block #e4e7eb
11567
- color hair #cfd4da
11568
- color accent #b3354d
11569
- color link #45607e
11570
-
11571
- font sans "Libre Franklin"
11572
- font mono "Geist Mono"
11573
- font serif "Newsreader"
11574
-
11575
- // ---- boxes ----------------------------------------------------------------
11576
- style node shape=rect radius=2 size=144x64 fill=block stroke=none sw=0
11577
- title.weight=700 title.size=12 title.color=ink sub.font=sans sub.size=10 sub.color=muted
11578
- tag.font=sans tag.size=8 tag.weight=700 tag.color=muted tag.border=none
11579
- use="default box: a service, component or step"
11580
- style focal extends node fill=accent title.color=#ffffff sub.color=#ffffff/0.85
11581
- tag.color=#ffffff/0.85 ghost.color=#ffffff/0.15
11582
- use="the one or two elements the diagram is about"
11583
- style store extends node size=144x72
11584
- path="M0,0.1 C0,-0.035 1,-0.035 1,0.1 L1,0.9 C1,1.035 0,1.035 0,0.9 Z M0,0.1 C0,0.235 1,0.235 1,0.1 C1,0.235 0,0.235 0,0.1"
11585
- shape=path stroke=#ffffff sw=1.5
11586
- use="something that holds data or state"
11587
- style cloud extends node fill=link/0.12 title.color=link sub.color=link/0.8
11588
- use="a hosted or third-party platform"
11589
- style external extends node fill=paper stroke=soft sw=1 dash=3,3
11590
- use="a person or system outside what you own"
11591
- style optional extends node fill=paper stroke=hair sw=1 dash=2,3
11592
- use="optional or asynchronous participant"
11593
- style sticky extends node size=120x120 fill=#efe3a2 title.weight=500
11594
- use="a yellow sticky note: an idea, comment or open question"
11595
- style sticky-orange extends sticky fill=#efd2bb use="an orange sticky note: a risk or issue"
11596
- style sticky-violet extends sticky fill=#ddd8ec use="a violet sticky note: a decision or note"
11597
-
11598
- // ---- flowchart shapes -----------------------------------------------------
11599
- style step extends node size=160x48 use="flowchart action"
11600
- style terminal shape=rect radius=24 size=160x48 fill=paper stroke=ink sw=1 title.weight=700 title.size=12 title.color=ink sub.font=sans sub.size=10 sub.color=muted
11601
- use="flowchart start or end"
11602
- style terminal-focal extends terminal fill=accent stroke=accent title.color=#ffffff sub.color=#ffffff/0.85
11603
- use="the flowchart outcome that matters most"
11604
- style decision shape=diamond size=200x96 fill=block stroke=none title.weight=700 title.size=12
11605
- use="flowchart yes/no question; put the text on two short lines"
11606
-
11607
- // ---- other shapes ---------------------------------------------------------
11608
- style zone shape=rect radius=0 fill=none stroke=hair sw=1 dash=1,3 layer=back
11609
- title.pos=top title.align=left title.font=sans title.size=10 title.weight=700 title.caps=1 title.spacing=0.06 title.color=muted
11610
- use="a labelled region drawn behind a group of boxes; always give WxH"
11611
- style bar shape=rect size=8x80 fill=block stroke=none
11612
- use="sequence diagram activation bar, centred on a lifeline; always give WxH"
11613
-
11614
- style table shape=table radius=0 fill=paper stroke=hair sw=1 head.fill=block rule=hair
11615
- cell.font=sans cell.size=10 detail.color=muted
11616
- use="an entity, class or database table: a header and rows. One line per row: | id \\"name\\" \\"type\\" \\"key\\". Arrows can end on a row: orders.user_id -> users.id"
11617
- style matrix extends table align=center grid=1
11618
- use="a grid of values: first row with |= for the column headings, first cell of each row is its name"
11619
- style chart shape=chart fill=none stroke=ink/0.6 sw=1 mask=0 bar.radius=0 grid.color=ink/0.08
11620
- use="axes with your numbers drawn for you: chart at x,y WxH x=\\"Q1,Q2,Q3\\" y=0..100, then a line per series: | bars \\"Revenue\\" 42 61 75"
11621
-
11622
- // ---- lines ----------------------------------------------------------------
11623
- style arrow line stroke=#80868f sw=1.25 route=ortho radius=4 label.font=sans label.size=10 label.caps=0 label.spacing=0 label.color=muted
11624
- use="default arrow"
11625
- style primary extends arrow stroke=accent sw=2.25 label.color=accent label.weight=700 use="the main path; at most two per diagram"
11626
- style link extends arrow stroke=link label.color=link use="a request crossing a boundary"
11627
- style return extends arrow stroke=soft dash=3,3 use="a response, or something optional or asynchronous"
11628
- style relation extends relation stroke=#80868f label.font=sans label.size=10 label.caps=0 label.spacing=0 label.color=muted
11629
- style lifeline line head=none stroke=hair sw=1 dash=1,3 route=straight use="sequence diagram lifeline"
11630
- style rule line head=none stroke=hair sw=1 route=straight use="thin separator"
11631
-
11632
- // ---- text -----------------------------------------------------------------
11633
- style h1 text font=serif size=28 weight=500 color=ink use="diagram title, a serif headline"
11634
- style kicker text font=sans size=10 weight=700 color=accent caps=1 spacing=0.08 use="optional: a short category above the title, e.g. PROCESS"
11635
- style dek text font=sans size=15 color=muted use="one line under the title that says what the diagram shows"
11636
- style eyebrow text font=sans size=10 weight=700 color=muted caps=1 spacing=0.06 use="small heading"
11637
- style caption text font=sans size=10 color=muted use="small explanatory text"
11638
- style legend extends legend rule=hair title.font=sans title.size=9 title.weight=700 title.spacing=0.06 item.font=sans item.size=10
11639
- style note text font=serif italic=1 size=15 color=muted use="a short aside; at most two"
11640
- style small text font=sans size=10 color=soft use="source line, or technical detail: a port, path or command"
11641
-
11642
- guidance "focal, terminal-focal and primary are the accent. Use the accent on at most two things in one diagram."
11643
- guidance "Never fill a shape with ink to make it stand out; use the accent, or a tint such as accent/0.14 or block."
11644
- guidance "tag= is a 3 or 4 letter type marker in the corner of a box. sub= is a short second line of detail."
11645
- guidance "A title reads best with a dek under it: one plain sentence saying what the diagram shows."
11646
- guidance "Finish with a legend: one statement, 'legend at x,y' followed by style=\\"what it means\\" for each style you used."
11647
- `,
11648
- keys: `// Keys: every box is a solid key you could press, with a face and a coloured side for its depth. Lines
11649
- // are thick cables and their labels are tags clipped onto them. Same style names as the built-in look.
11650
-
11651
- canvas paper=paper
11652
-
11653
- color paper #f4f5fa
11654
- color card #ffffff
11655
- color side #c3c8d8
11656
- color ink #1c1a2e
11657
- color muted #6b6f86
11658
- color soft #a3a7bb
11659
- color accent #6d4aff
11660
- color accentside #4326c9
11661
- color link #2f7de1
11662
- color teal #0f9d83
11663
- color amber #d18a00
11664
- color rose #e5484d
11665
- color violet #6d4aff
11666
-
11667
- font sans "Geist"
11668
- font mono "Geist Mono"
11669
- font serif "Newsreader"
11670
-
11671
- // ---- boxes -----------------------------------------------------------------
11672
- style node shape=rect radius=12 size=144x64 fill=card stroke=ink sw=2 depth=7 depth.fill=side title.size=12.5 sub.font=sans sub.size=9.5 sub.color=muted
11673
- tag.color=muted tag.border=ink/0.3 tag.font=mono icon.color=ink use="default box: a backend, service, component or step"
11674
- style focal extends node fill=accent depth.fill=accentside title.color=#ffffff sub.color=#ffffff/0.85
11675
- tag.color=#ffffff tag.border=#ffffff/0.6 icon.color=#ffffff ghost.color=#ffffff/0.16 use="the one or two elements the diagram is about"
11676
- style store extends node radius=32 fill=#bff0df depth.fill=#6fcab0 use="something that holds data or state"
11677
- style cloud extends node fill=#cfe3ff depth.fill=#8db5ee use="a hosted or third-party platform"
11678
- style external extends node fill=none dash=2,6 cap=round depth=0 icon.color=muted use="a person or system outside what you own"
11679
- style optional extends node fill=none stroke=ink/0.6 dash=2,6 cap=round depth=0 use="optional or asynchronous participant"
11680
- style sticky extends node radius=10 size=120x120 fill=#ffe27a depth.fill=#e0b93a use="a yellow sticky note: an idea, comment or open question"
11681
- style sticky-orange extends sticky fill=#ffc2ad depth.fill=#e58a6c use="an orange sticky note: a risk or issue"
11682
- style sticky-violet extends sticky fill=#ddd3ff depth.fill=#a996ee use="a violet sticky note: a decision or note"
11683
-
11684
- // ---- flowchart shapes ------------------------------------------------------
11685
- style step extends node size=160x48 use="flowchart action"
11686
- style terminal extends node radius=24 size=160x48 fill=#e9ebf3 use="flowchart start or end"
11687
- style terminal-focal extends terminal fill=accent depth.fill=accentside title.color=#ffffff sub.color=#ffffff/0.85 use="the flowchart outcome that matters most"
11688
- style decision shape=diamond size=200x96 fill=card stroke=ink sw=2 depth=7 depth.fill=side title.size=12.5 use="flowchart yes/no question; put the text on two short lines"
11689
-
11690
- // ---- regions and markers ---------------------------------------------------
11691
- style zone shape=rect radius=18 fill=#e9ebf3 stroke=none sw=0 layer=back
11692
- title.pos=top title.dy=4 title.fill=none title.align=left title.font=sans title.size=12 title.weight=600 title.color=muted title.spacing=0 title.caps=0 use="a labelled region drawn behind a group of boxes; always give WxH"
11693
- style bar shape=rect radius=4 size=8x80 fill=accent stroke=ink sw=1.5 use="sequence diagram activation bar, centred on a lifeline; always give WxH"
11694
- style table shape=table radius=10 fill=card stroke=ink sw=2 depth=7 depth.fill=side head.fill=accent/0.12 rule=ink/0.1
11695
- cell.font=mono cell.size=10 detail.color=muted use="an entity, class or database table: a header and rows. One line per row: | id \\"name\\" \\"type\\" \\"key\\". Arrows can end on a row: orders.user_id -> users.id"
11696
- style matrix extends table align=center grid=1 cell.font=sans use="a grid of values: first row with |= for the column headings, first cell of each row is its name"
11697
- style chart shape=chart fill=none stroke=ink sw=2 mask=0 bar.radius=4 grid.color=ink/0.08
11698
- tick.font=mono tick.size=9 tick.color=muted use="axes with your numbers drawn for you: chart at x,y WxH x=\\"Q1,Q2,Q3\\" y=0..100, then a line per series: | bars \\"Revenue\\" 42 61 75"
11699
-
11700
- // ---- lines -----------------------------------------------------------------
11701
- style arrow line stroke=ink sw=3 cap=round route=ortho radius=10 head.size=1.5 label.font=sans label.size=9.5 label.weight=600 label.color=ink
11702
- label.fill=card label.border=ink label.sw=1.5 label.radius=12 label.pad=4 label.spacing=0 label.caps=0 use="default arrow"
11703
- style primary extends arrow stroke=accent sw=5 label.color=accent label.border=accent use="the main path; at most two per diagram"
11704
- style link extends arrow stroke=link label.color=link label.border=link use="an HTTP or API request crossing a boundary"
11705
- style return extends arrow dash=1,8 use="a response, or something optional or asynchronous"
11706
- style relation extends relation stroke=ink sw=2 label.font=sans label.size=10 label.spacing=0 label.caps=0
11707
- style lifeline line head=none stroke=ink/0.35 sw=2 dash=1,7 cap=round route=straight use="sequence diagram lifeline"
11708
- style rule line head=none stroke=ink/0.18 sw=1.5 route=straight use="thin separator, e.g. above a legend"
11709
-
11710
- // ---- text ------------------------------------------------------------------
11711
- style h1 text font=sans size=30 weight=600 color=ink spacing=-0.02 use="diagram title"
11712
- style kicker text font=sans size=11 weight=600 color=accent use="optional: a short category above the title, e.g. PROCESS"
11713
- style dek text font=sans size=14 color=muted use="optional: one line under the title saying what the diagram shows"
11714
- style eyebrow text font=sans size=10 weight=600 color=muted use="small caps label, e.g. LEGEND"
11715
- style caption text font=sans size=10 color=muted use="small explanatory text"
11716
- style legend extends legend rule=ink/0.14 title.font=sans title.caps=0 title.size=10 item.size=10
11717
- style note text font=sans size=13 color=muted use="a short aside; at most two"
11718
- style small text font=mono size=9 color=muted use="technical detail: a port, path or command"
11719
-
11720
- guidance "focal, terminal-focal and primary are the accent. Use the accent on at most two things in one diagram."
11721
- guidance "Never fill a shape with ink to make it stand out; use focal."
11722
- guidance "tag= is a 3 or 4 letter type marker in the corner of a box (EXT, EDGE, API, DB). Use it on architecture boxes, not flowchart shapes."
11723
- guidance "sub= is a short second line of detail: a product name, path, port or protocol. Names of things go in the main text."
11724
- guidance "kicker and dek are optional. Add a kicker only when the diagram belongs to a named category, and a dek only when there is one clear message; most diagrams need neither."
11725
- guidance "Finish with a legend: one statement, 'legend at x,y' followed by style=\\"what it means\\" for each style you used."
11726
- `,
11727
- listing: `// Listing: the diagram as a line printer would put it on green-bar paper, sprocket holes and all.
11728
- // One typewriter face, names in capitals, plus signs on the corners, the subject printed in reverse.
11729
- // A FastDraw diagram is a text file; in this look the picture says so. Same style names as the built-in look.
11730
-
11731
- canvas paper=paper bars=#e3f1e4 bargap=32 feed=#b9cdbb
11732
-
11733
- color paper #f6fbf6
11734
- color card #f6fbf6
11735
- color ink #1d2b24
11736
- color muted #4a5d52
11737
- color soft #8fa697
11738
- color accent #2f8f5f
11739
- color link #1d2b24
11740
- color teal #1d6b4f
11741
- color amber #8a6d00
11742
- color rose #a33a2a
11743
- color violet #4a3f8a
11744
-
11745
- font sans "Geist Mono"
11746
- font mono "Geist Mono"
11747
- font serif "Geist Mono"
11748
-
11749
- // ---- boxes -----------------------------------------------------------------
11750
- style node shape=rect radius=0 size=144x64 fill=card stroke=ink sw=1.4 corners=plus shade=ink/0.55 shade.size=6 shade.gap=2 shade.sw=0.8
11751
- title.size=11 title.weight=500 title.caps=1 sub.font=mono sub.size=9 sub.color=ink tag.color=ink tag.border=ink/0.5 tag.font=mono icon.color=ink use="default box: a backend, service, component or step"
11752
- style focal extends node fill=ink inner=paper inner.sw=1.2 title.color=paper sub.color=paper tag.color=paper tag.border=paper/0.6 icon.color=paper ghost.color=paper/0.14 use="the one or two elements the diagram is about"
11753
- style store extends node inner=ink inner.gap=3.5 inner.sw=1.2 use="something that holds data or state"
11754
- style cloud extends node dash=1,3 use="a hosted or third-party platform"
11755
- style external extends node dash=6,5 shade=none use="a person or system outside what you own"
11756
- style optional extends node dash=2,4 shade=none use="optional or asynchronous participant"
11757
- style sticky extends node size=120x120 fill=#fff6c9 title.caps=0 use="a yellow sticky note: an idea, comment or open question"
11758
- style sticky-orange extends sticky fill=#ffe3d6 use="an orange sticky note: a risk or issue"
11759
- style sticky-violet extends sticky fill=#e8e4fb use="a violet sticky note: a decision or note"
11760
-
11761
- // ---- flowchart shapes ------------------------------------------------------
11762
- style step extends node size=160x48 use="flowchart action"
11763
- style terminal extends node size=160x48 inner=ink inner.gap=3.5 inner.sw=0.8 use="flowchart start or end"
11764
- style terminal-focal extends terminal fill=ink inner=paper title.color=paper sub.color=paper use="the flowchart outcome that matters most"
11765
- style decision shape=diamond size=200x96 fill=card stroke=ink sw=1.4 title.size=11 title.weight=500 title.caps=1 use="flowchart yes/no question; put the text on two short lines"
11766
-
11767
- // ---- regions and markers ---------------------------------------------------
11768
- style zone shape=rect radius=0 fill=none halftone=#9fc2a4 halftone.gap=4 halftone.r=0.7 stroke=none sw=0 layer=back
11769
- title.pos=top title.dy=-11 title.fill=ink title.align=left title.font=mono title.size=10 title.weight=500 title.color=paper title.spacing=0.06 title.caps=1 use="a labelled region drawn behind a group of boxes; always give WxH"
11770
- style bar shape=rect radius=0 size=8x80 fill=ink stroke=ink sw=1 use="sequence diagram activation bar, centred on a lifeline; always give WxH"
11771
- style table shape=table radius=0 fill=card stroke=ink sw=1.4 corners=plus head.fill=ink/0.1 rule=ink/0.25
11772
- title.size=11 title.weight=500 title.caps=1 cell.font=mono cell.size=10 detail.color=ink use="an entity, class or database table: a header and rows. One line per row: | id \\"name\\" \\"type\\" \\"key\\". Arrows can end on a row: orders.user_id -> users.id"
11773
- style matrix extends table align=center grid=1 use="a grid of values: first row with |= for the column headings, first cell of each row is its name"
11774
- style chart shape=chart fill=none stroke=ink sw=1.4 mask=0 bar.radius=0 grid.color=ink/0.15
11775
- tick.font=mono tick.size=9 tick.color=ink use="axes with your numbers drawn for you: chart at x,y WxH x=\\"Q1,Q2,Q3\\" y=0..100, then a line per series: | bars \\"Revenue\\" 42 61 75"
11776
-
11777
- // ---- lines -----------------------------------------------------------------
11778
- style arrow line stroke=ink sw=1.4 route=ortho radius=0 label.font=mono label.size=9 label.color=ink label.spacing=0.02 use="default arrow"
11779
- style primary extends arrow sw=3.4 double=paper double.sw=1 head.size=1.3 use="the main path; at most two per diagram"
11780
- style link extends arrow use="an HTTP or API request crossing a boundary"
11781
- style return extends arrow dash=6,5 use="a response, or something optional or asynchronous"
11782
- style relation extends relation stroke=ink sw=1.4 label.font=mono label.size=9
11783
- style lifeline line head=none stroke=ink/0.6 sw=1 dash=1,4 route=straight use="sequence diagram lifeline"
11784
- style rule line head=none stroke=ink/0.5 sw=1 dash=1,4 route=straight use="thin separator, e.g. above a legend"
11785
-
11786
- // ---- text ------------------------------------------------------------------
11787
- style h1 text font=mono size=22 weight=500 color=ink spacing=0.05 caps=1 use="diagram title"
11788
- style kicker text font=mono size=10 weight=500 color=ink spacing=0.1 caps=1 use="optional: a short category above the title, e.g. PROCESS"
11789
- style dek text font=mono size=11 color=ink use="optional: one line under the title saying what the diagram shows"
11790
- style eyebrow text font=mono size=9 color=ink spacing=0.1 caps=1 use="small caps label, e.g. LEGEND"
11791
- style caption text font=mono size=9.5 color=ink use="small explanatory text"
11792
- style legend extends legend rule=ink/0.5 title.font=mono title.color=ink item.font=mono item.size=9 item.color=ink
11793
- style note text font=mono size=11 color=ink use="a short aside; at most two"
11794
- style small text font=mono size=9 color=ink use="technical detail: a port, path or command"
11795
-
11796
- guidance "focal, terminal-focal and primary are the accent. Use the accent on at most two things in one diagram."
11797
- guidance "Never fill a shape with ink to make it stand out; use focal."
11798
- guidance "tag= is a 3 or 4 letter type marker in the corner of a box (EXT, EDGE, API, DB). Use it on architecture boxes, not flowchart shapes."
11799
- guidance "sub= is a short second line of detail: a product name, path, port or protocol. Names of things go in the main text."
11800
- guidance "kicker and dek are optional. Add a kicker only when the diagram belongs to a named category, and a dek only when there is one clear message; most diagrams need neither."
11801
- guidance "Finish with a legend: one statement, 'legend at x,y' followed by style=\\"what it means\\" for each style you used."
11802
- `,
11803
- night: `// Night: the built-in look after dark. A deep navy page, raised navy cards with a two-tone icon,
11496
+ night: `// Night: the built-in look in the dark theme. A deep navy page, raised navy cards with a two-tone icon,
11804
11497
  // softly tinted zones, cool greys for everything else and one bright tomato red for the subject and the
11805
- // main path. Same styles as the built-in look, so a diagram moves between them without changes.
11498
+ // main path. Same styles as the built-in look, so a diagram moves between them without changes. It is not
11499
+ // offered as a look of its own: a diagram with no look line is drawn in it whenever the theme is dark.
11806
11500
 
11807
11501
  canvas paper=paper dots=ink/0.08 dotgap=24
11808
11502
 
11809
- // already dark, so "fastdraw render --dark" draws the dark image with this look too
11503
+ // already dark, so "fastdraw render --dark" and the dark theme draw this look too
11810
11504
  dark night
11811
11505
 
11812
11506
  color paper #0b1226
@@ -11823,7 +11517,7 @@ color violet #a78bfa
11823
11517
 
11824
11518
  font sans "Geist"
11825
11519
  font mono "Geist Mono"
11826
- font serif "Newsreader"
11520
+ font serif "Libre Caslon Display"
11827
11521
 
11828
11522
  // ---- boxes ----------------------------------------------------------------
11829
11523
  style node shape=rect radius=10 size=144x64 fill=#131c38 stroke=ink/0.14 sw=1 sub.font=sans sub.color=muted
@@ -11882,7 +11576,7 @@ style lifeline line head=none stroke=ink/0.20 sw=1 dash=4,4 route=straight use="
11882
11576
  style rule line head=none stroke=ink/0.10 sw=1 route=straight use="thin separator, e.g. above a legend"
11883
11577
 
11884
11578
  // ---- text -----------------------------------------------------------------
11885
- style h1 text font=sans size=26 weight=700 spacing=-0.03 color=ink use="diagram title"
11579
+ style h1 text font=serif size=30 weight=400 spacing=-0.01 dy=4 color=ink use="diagram title"
11886
11580
  style kicker text font=mono size=10 weight=500 color=accent spacing=0.12 caps=1 use="optional: a short category above the title, e.g. PROCESS"
11887
11581
  style dek text font=sans size=14 color=muted use="optional: one line under the title saying what the diagram shows"
11888
11582
  style eyebrow text font=mono size=8 color=muted spacing=0.14 caps=1 use="small caps label, e.g. LEGEND"
@@ -11897,82 +11591,6 @@ guidance "tag= is a 3 or 4 letter type marker in the corner of a box (EXT, EDGE,
11897
11591
  guidance "sub= is a short second line of detail: a product name, path, port or protocol. Names of things go in the main text."
11898
11592
  guidance "kicker and dek are optional. Add a kicker only when the diagram belongs to a named category, and a dek only when there is one clear message; most diagrams need neither."
11899
11593
  guidance "Finish with a legend: one statement, 'legend at x,y' followed by style=\\"what it means\\" for each style you used."
11900
- `,
11901
- offset: `// Offset: printed in two spot inks, a little out of register, the way a small press prints a poster.
11902
- // There is no black: blue is the ink, red is the subject, and tints are fields of dots.
11903
- // Same style names as the built-in look.
11904
-
11905
- canvas paper=paper grain=0.5
11906
-
11907
- color paper #f6f2e9
11908
- color card #f6f2e9
11909
- color ink #2a3fd0
11910
- color muted #2a3fd0
11911
- color soft #7d8be0
11912
- color accent #ff5a4f
11913
- color link #2a3fd0
11914
- color teal #2a3fd0
11915
- color amber #ffcf33
11916
- color rose #ff5a4f
11917
- color violet #2a3fd0
11918
-
11919
- font sans "Libre Franklin"
11920
- font mono "Geist Mono"
11921
- font serif "Newsreader"
11922
-
11923
- // ---- boxes -----------------------------------------------------------------
11924
- style node shape=rect radius=0 size=144x64 fill=card stroke=ink sw=2 title.size=12.5 title.weight=700 sub.font=sans sub.size=9.5 sub.color=ink
11925
- tag.color=ink tag.border=ink/0.6 tag.font=mono icon.color=ink use="default box: a backend, service, component or step"
11926
- style focal extends node fill=accent offset=5,5 blend=multiply title.color=paper sub.color=paper tag.color=paper tag.border=paper/0.7 icon.color=paper ghost.color=paper/0.2 use="the one or two elements the diagram is about"
11927
- style store extends node radius=32 fill=amber offset=5,5 blend=multiply use="something that holds data or state"
11928
- style cloud extends node halftone=ink/0.4 halftone.gap=5 offset=5,5 use="a hosted or third-party platform"
11929
- style external extends node fill=none dash=7,5 use="a person or system outside what you own"
11930
- style optional extends node fill=none dash=2,4 use="optional or asynchronous participant"
11931
- style sticky extends node size=120x120 halftone=accent/0.55 halftone.gap=5 halftone.r=1 offset=5,5 use="a yellow sticky note: an idea, comment or open question"
11932
- style sticky-orange extends sticky halftone=accent/0.85 use="an orange sticky note: a risk or issue"
11933
- style sticky-violet extends sticky halftone=ink/0.4 use="a violet sticky note: a decision or note"
11934
-
11935
- // ---- flowchart shapes ------------------------------------------------------
11936
- style step extends node size=160x48 use="flowchart action"
11937
- style terminal extends node radius=24 size=160x48 use="flowchart start or end"
11938
- style terminal-focal extends terminal fill=accent offset=5,5 blend=multiply title.color=paper sub.color=paper use="the flowchart outcome that matters most"
11939
- style decision shape=diamond size=200x96 fill=card stroke=ink sw=2 title.size=12.5 title.weight=700 use="flowchart yes/no question; put the text on two short lines"
11940
-
11941
- // ---- regions and markers ---------------------------------------------------
11942
- style zone shape=rect radius=0 fill=none halftone=ink/0.3 halftone.gap=6 offset=5,5 stroke=none sw=0 layer=back
11943
- title.pos=top title.dy=8 title.fill=none title.align=left title.font=sans title.size=11 title.weight=700 title.color=ink title.spacing=0.14 title.caps=1 use="a labelled region drawn behind a group of boxes; always give WxH"
11944
- style bar shape=rect radius=0 size=8x80 fill=accent stroke=ink sw=1.5 use="sequence diagram activation bar, centred on a lifeline; always give WxH"
11945
- style table shape=table radius=0 fill=card stroke=ink sw=2 head.fill=amber rule=ink/0.25
11946
- title.weight=700 cell.font=mono cell.size=10 cell.color=ink detail.color=ink use="an entity, class or database table: a header and rows. One line per row: | id \\"name\\" \\"type\\" \\"key\\". Arrows can end on a row: orders.user_id -> users.id"
11947
- style matrix extends table align=center grid=1 cell.font=sans use="a grid of values: first row with |= for the column headings, first cell of each row is its name"
11948
- style chart shape=chart fill=none stroke=ink sw=2 mask=0 bar.radius=0 grid.color=ink/0.15
11949
- tick.font=mono tick.size=9 tick.color=ink use="axes with your numbers drawn for you: chart at x,y WxH x=\\"Q1,Q2,Q3\\" y=0..100, then a line per series: | bars \\"Revenue\\" 42 61 75"
11950
-
11951
- // ---- lines -----------------------------------------------------------------
11952
- style arrow line stroke=ink sw=1.8 route=ortho radius=0 blend=multiply label.font=sans label.size=8.5 label.weight=700 label.spacing=0.09 label.color=ink use="default arrow"
11953
- style primary extends arrow stroke=accent sw=4.5 head.size=1.4 label.color=accent use="the main path; at most two per diagram"
11954
- style link extends arrow use="an HTTP or API request crossing a boundary"
11955
- style return extends arrow dash=5,4 use="a response, or something optional or asynchronous"
11956
- style relation extends relation stroke=ink sw=1.8 label.font=sans label.size=9 label.spacing=0 label.caps=0
11957
- style lifeline line head=none stroke=ink/0.6 sw=1.2 dash=2,4 route=straight use="sequence diagram lifeline"
11958
- style rule line head=none stroke=ink/0.5 sw=1 route=straight use="thin separator, e.g. above a legend"
11959
-
11960
- // ---- text ------------------------------------------------------------------
11961
- style h1 text font=sans size=34 weight=700 color=ink spacing=-0.03 echo=accent blend=multiply use="diagram title"
11962
- style kicker text font=sans size=10 weight=700 color=accent spacing=0.14 caps=1 use="optional: a short category above the title, e.g. PROCESS"
11963
- style dek text font=sans size=14 weight=600 color=ink use="optional: one line under the title saying what the diagram shows"
11964
- style eyebrow text font=sans size=9 weight=700 color=ink spacing=0.14 caps=1 use="small caps label, e.g. LEGEND"
11965
- style caption text font=sans size=10 color=ink use="small explanatory text"
11966
- style legend extends legend rule=ink/0.5 title.font=sans title.color=ink item.color=ink item.size=10
11967
- style note text font=sans size=13 weight=600 color=ink use="a short aside; at most two"
11968
- style small text font=mono size=9 color=ink use="technical detail: a port, path or command"
11969
-
11970
- guidance "focal, terminal-focal and primary are the accent. Use the accent on at most two things in one diagram."
11971
- guidance "Never fill a shape with ink to make it stand out; use focal."
11972
- guidance "tag= is a 3 or 4 letter type marker in the corner of a box (EXT, EDGE, API, DB). Use it on architecture boxes, not flowchart shapes."
11973
- guidance "sub= is a short second line of detail: a product name, path, port or protocol. Names of things go in the main text."
11974
- guidance "kicker and dek are optional. Add a kicker only when the diagram belongs to a named category, and a dek only when there is one clear message; most diagrams need neither."
11975
- guidance "Finish with a legend: one statement, 'legend at x,y' followed by style=\\"what it means\\" for each style you used."
11976
11594
  `,
11977
11595
  reference: `// Reference look for the quality comparison.
11978
11596
  // It mirrors the palette and type of diagram-design's default skin so the two can be
@@ -11980,6 +11598,9 @@ guidance "Finish with a legend: one statement, 'legend at x,y' followed by style
11980
11598
 
11981
11599
  canvas paper=paper dots=ink/0.055 dotgap=22
11982
11600
 
11601
+ // the look the dark theme and "fastdraw render --dark" draw this look with
11602
+ dark reference-dark
11603
+
11983
11604
  color paper #f5f5f5
11984
11605
  color ink #2d3142
11985
11606
  color muted #4f5d75
@@ -12056,6 +11677,95 @@ style legend extends legend title.size=7.5 item.font=sans item.size=8.5
12056
11677
  style note text font=serif italic=1 size=14 color=muted use="a short editorial aside; at most two"
12057
11678
  style small text font=mono size=9 color=muted use="technical detail: a port, path or command"
12058
11679
 
11680
+ guidance "focal, terminal-focal and primary are the accent. Use the accent on at most two things in one diagram."
11681
+ guidance "tag= is a 3 or 4 letter type marker in the corner of a box (EXT, EDGE, API, DB). Use it on architecture boxes, not flowchart shapes."
11682
+ guidance "sub= is for technical detail in mono type: a product name, path, port or protocol. Names of things go in the main text."
11683
+ guidance "Finish with a legend: one statement, 'legend at x,y' followed by style=\\"what it means\\" for each style you used."
11684
+ `,
11685
+ "reference-dark": `// Reference dark: the reference look on a dark page, for the quality comparison in the dark theme.
11686
+ // It is a test fixture, not the look FastDraw will ship with.
11687
+
11688
+ canvas paper=paper dots=ink/0.055 dotgap=22
11689
+
11690
+ // already dark, so "fastdraw render --dark" and the dark theme draw this look too
11691
+ dark reference-dark
11692
+
11693
+ color paper #17181d
11694
+ color ink #e2e4ea
11695
+ color muted #a6adbf
11696
+ color soft #737b90
11697
+ color accent #f08a5d
11698
+ color link #7ea6ec
11699
+
11700
+ font sans "Geist"
11701
+ font mono "Geist Mono"
11702
+ font serif "Instrument Serif"
11703
+
11704
+ // ---- boxes ----------------------------------------------------------------
11705
+ style node shape=rect radius=6 size=144x64 fill=#20222a stroke=ink sw=1
11706
+ tag.color=ink tag.border=ink/0.4
11707
+ use="default box: a backend, service, component or step"
11708
+ style focal extends node fill=accent/0.08 stroke=accent
11709
+ tag.color=accent tag.border=accent/0.5 ghost.color=accent/0.10
11710
+ use="the one or two elements the diagram is about"
11711
+ style store extends node fill=ink/0.05 stroke=muted tag.color=muted tag.border=muted/0.5
11712
+ use="something that holds data or state"
11713
+ style cloud extends node fill=ink/0.03 stroke=ink/0.30 tag.color=soft tag.border=ink/0.22
11714
+ use="a hosted or third-party platform"
11715
+ style external extends node fill=muted/0.10 stroke=soft tag.color=soft tag.border=soft/0.4
11716
+ use="a person or system outside what you own"
11717
+ style optional extends node fill=ink/0.02 stroke=ink/0.22 dash=4,3 tag.color=soft tag.border=ink/0.22
11718
+ use="optional or asynchronous participant"
11719
+ style sticky extends node size=120x120 fill=#3d3719 stroke=ink/0.25 tag.color=ink tag.border=ink/0.3
11720
+ use="a yellow sticky note: an idea, comment or open question"
11721
+ style sticky-orange extends sticky fill=#43301f use="an orange sticky note: a risk or issue"
11722
+ style sticky-violet extends sticky fill=#2c2748 use="a violet sticky note: a decision or note"
11723
+
11724
+ // ---- flowchart shapes -----------------------------------------------------
11725
+ style step extends node size=160x48 use="flowchart action"
11726
+ style terminal shape=rect radius=24 size=160x48 fill=ink/0.03 stroke=ink/0.30 sw=1
11727
+ use="flowchart start or end"
11728
+ style terminal-focal extends terminal fill=accent/0.08 stroke=accent
11729
+ use="the flowchart outcome that matters most"
11730
+ style decision shape=diamond size=200x96 fill=#20222a stroke=ink sw=1
11731
+ use="flowchart yes/no question; put the text on two short lines"
11732
+
11733
+ // ---- other shapes ---------------------------------------------------------
11734
+ style zone shape=rect radius=8 fill=ink/0.02 stroke=ink/0.10 sw=0.8 layer=back
11735
+ title.pos=top title.font=mono title.size=7 title.weight=400 title.color=ink/0.40 title.spacing=0.14 title.caps=1
11736
+ use="a labelled region drawn behind a group of boxes; always give WxH"
11737
+ style bar shape=rect size=8x80 fill=ink/0.06 stroke=muted sw=0.8
11738
+ use="sequence diagram activation bar, centred on a lifeline; always give WxH"
11739
+
11740
+ style table shape=table radius=6 fill=#20222a stroke=ink sw=1 head.fill=ink/0.06 rule=ink/0.1
11741
+ cell.font=mono cell.size=9.5 detail.color=muted
11742
+ use="an entity, class or database table: a header and rows. One line per row: | id \\"name\\" \\"type\\" \\"key\\". Arrows can end on a row: orders.user_id -> users.id"
11743
+ style matrix extends table align=center grid=1 cell.font=sans
11744
+ use="a grid of values: first row with |= for the column headings, first cell of each row is its name"
11745
+ style chart shape=chart fill=none stroke=ink/0.5 sw=1 mask=0 bar.radius=2 grid.color=ink/0.07
11746
+ tick.font=mono tick.size=8 tick.color=muted
11747
+ use="axes with your numbers drawn for you: chart at x,y WxH x=\\"Q1,Q2,Q3\\" y=0..100, then a line per series: | bars \\"Revenue\\" 42 61 75"
11748
+
11749
+ // ---- lines ----------------------------------------------------------------
11750
+ style arrow line stroke=muted sw=1.2 route=ortho radius=8 label.font=mono label.size=8 label.spacing=0.08
11751
+ use="default arrow"
11752
+ style primary extends arrow stroke=accent sw=1.4 use="the main path; at most two per diagram"
11753
+ style link extends arrow stroke=link use="an HTTP or API request crossing a boundary"
11754
+ style return extends arrow dash=5,4 use="a response, or something optional or asynchronous"
11755
+ style relation extends relation label.font=mono label.size=8 label.spacing=0.08
11756
+ style lifeline line head=none stroke=ink/0.22 sw=1 dash=3,3 route=straight use="sequence diagram lifeline"
11757
+ style rule line head=none stroke=ink/0.10 sw=0.8 route=straight use="thin separator, e.g. above a legend"
11758
+
11759
+ // ---- text -----------------------------------------------------------------
11760
+ style h1 text font=serif size=28 color=ink use="diagram title"
11761
+ style kicker text font=mono size=9 color=accent spacing=0.18 caps=1 use="optional: a short category above the title, e.g. PROCESS"
11762
+ style dek text font=sans size=14 color=muted use="optional: one line under the title saying what the diagram shows"
11763
+ style eyebrow text font=mono size=8 color=muted spacing=0.18 caps=1 use="small caps label, e.g. LEGEND"
11764
+ style caption text font=sans size=8.5 color=muted use="legend entry"
11765
+ style legend extends legend title.size=7.5 item.font=sans item.size=8.5
11766
+ style note text font=serif italic=1 size=14 color=muted use="a short editorial aside; at most two"
11767
+ style small text font=mono size=9 color=muted use="technical detail: a port, path or command"
11768
+
12059
11769
  guidance "focal, terminal-focal and primary are the accent. Use the accent on at most two things in one diagram."
12060
11770
  guidance "tag= is a 3 or 4 letter type marker in the corner of a box (EXT, EDGE, API, DB). Use it on architecture boxes, not flowchart shapes."
12061
11771
  guidance "sub= is for technical detail in mono type: a product name, path, port or protocol. Names of things go in the main text."
@@ -12067,6 +11777,9 @@ guidance "Finish with a legend: one statement, 'legend at x,y' followed by style
12067
11777
 
12068
11778
  canvas paper=paper
12069
11779
 
11780
+ // the look the dark theme and "fastdraw render --dark" draw this look with
11781
+ dark shade-dark
11782
+
12070
11783
  color paper #f5f5f5
12071
11784
  color card #ffffff
12072
11785
  color ink #2d3142
@@ -12132,6 +11845,87 @@ style legend extends legend rule=ink/0.12 title.font=mono item.size=9.5
12132
11845
  style note text font=serif italic=1 size=16 color=ink use="a short aside; at most two"
12133
11846
  style small text font=mono size=9 color=muted use="technical detail: a port, path or command"
12134
11847
 
11848
+ guidance "focal, terminal-focal and primary are the accent. Use the accent on at most two things in one diagram."
11849
+ guidance "Never fill a shape with ink to make it stand out; use focal."
11850
+ guidance "tag= is a 3 or 4 letter type marker in the corner of a box (EXT, EDGE, API, DB). Use it on architecture boxes, not flowchart shapes."
11851
+ guidance "sub= is a short second line of detail: a product name, path, port or protocol. Names of things go in the main text."
11852
+ guidance "kicker and dek are optional. Add a kicker only when the diagram belongs to a named category, and a dek only when there is one clear message; most diagrams need neither."
11853
+ guidance "Finish with a legend: one statement, 'legend at x,y' followed by style=\\"what it means\\" for each style you used."
11854
+ `,
11855
+ "shade-dark": `// Shade dark: Shade on a dark page. Hairline cards on charcoal, each casting a shadow of fine drawn lines,
11856
+ // the tall serif title, typewriter capitals for technical labels, one bright indigo for the subject.
11857
+ // Same styles and sizes as Shade, so a diagram moves between them without changes.
11858
+
11859
+ canvas paper=paper
11860
+
11861
+ // already dark, so "fastdraw render --dark" and the dark theme draw this look too
11862
+ dark shade-dark
11863
+
11864
+ color paper #16171c
11865
+ color card #1f2129
11866
+ color ink #e3e5ec
11867
+ color muted #a4abbd
11868
+ color soft #6f768a
11869
+ color accent #8f88ff
11870
+ color tint #29274f
11871
+ color link #7ea6ec
11872
+ color teal #2dd4bf
11873
+ color amber #f0b45a
11874
+ color rose #fb8c5c
11875
+ color violet #a78bfa
11876
+
11877
+ font sans "Geist"
11878
+ font mono "Geist Mono"
11879
+ font serif "Instrument Serif"
11880
+
11881
+ // ---- boxes -----------------------------------------------------------------
11882
+ style node shape=rect radius=2 size=144x64 fill=card stroke=ink sw=1 shade=ink/0.7 sub.font=mono sub.color=muted
11883
+ tag.color=muted tag.border=ink/0.3 tag.font=mono icon.color=ink use="default box: a backend, service, component or step"
11884
+ style focal extends node fill=tint stroke=accent shade=accent shade.sw=0.8 sub.color=accent
11885
+ tag.color=accent tag.border=accent/0.5 icon.color=accent ghost.color=accent/0.12 use="the one or two elements the diagram is about"
11886
+ style store extends node shape=path path="M0,0.1 C0,-0.035 1,-0.035 1,0.1 L1,0.9 C1,1.035 0,1.035 0,0.9 Z M0,0.1 C0,0.235 1,0.235 1,0.1 C1,0.235 0,0.235 0,0.1" use="something that holds data or state"
11887
+ style cloud extends node stroke=link shade=link/0.8 icon.color=link tag.color=link tag.border=link/0.5 use="a hosted or third-party platform"
11888
+ style external extends node fill=paper stroke=ink/0.5 dash=4,3 shade=none icon.color=muted use="a person or system outside what you own"
11889
+ style optional extends node fill=paper stroke=ink/0.4 dash=2,3 shade=none tag.color=soft tag.border=ink/0.2 use="optional or asynchronous participant"
11890
+ style sticky extends node radius=0 size=120x120 fill=#3b3418 stroke=ink/0.35 shade=ink/0.45 tag.color=ink tag.border=ink/0.3 use="a yellow sticky note: an idea, comment or open question"
11891
+ style sticky-orange extends sticky fill=#40261e use="an orange sticky note: a risk or issue"
11892
+ style sticky-violet extends sticky fill=#2a2547 use="a violet sticky note: a decision or note"
11893
+
11894
+ // ---- flowchart shapes ------------------------------------------------------
11895
+ style step extends node size=160x48 use="flowchart action"
11896
+ style terminal extends node radius=24 size=160x48 use="flowchart start or end"
11897
+ style terminal-focal extends terminal fill=tint stroke=accent shade=accent shade.sw=0.8 use="the flowchart outcome that matters most"
11898
+ style decision shape=diamond size=200x96 fill=card stroke=ink sw=1 shade=ink/0.7 use="flowchart yes/no question; put the text on two short lines"
11899
+
11900
+ // ---- regions and markers ---------------------------------------------------
11901
+ style zone shape=rect radius=0 fill=none hatch=ink/0.1 hatch.gap=6 hatch.sw=0.4 stroke=#3c3f48 sw=1 layer=back
11902
+ title.pos=top title.dy=-10 title.align=left title.font=mono title.size=8 title.weight=500 title.color=soft title.spacing=0.18 title.caps=1 use="a labelled region drawn behind a group of boxes; always give WxH"
11903
+ style bar shape=rect radius=0 size=8x80 fill=tint stroke=accent sw=1 use="sequence diagram activation bar, centred on a lifeline; always give WxH"
11904
+ style table shape=table radius=2 fill=card stroke=ink sw=1 shade=ink/0.7 head.fill=ink/0.06 rule=ink/0.1
11905
+ cell.font=mono cell.size=10 detail.color=muted use="an entity, class or database table: a header and rows. One line per row: | id \\"name\\" \\"type\\" \\"key\\". Arrows can end on a row: orders.user_id -> users.id"
11906
+ style matrix extends table align=center grid=1 cell.font=sans use="a grid of values: first row with |= for the column headings, first cell of each row is its name"
11907
+ style chart shape=chart fill=none stroke=ink/0.6 sw=1 mask=0 bar.radius=0 grid.color=ink/0.08
11908
+ tick.font=mono tick.size=9 tick.color=muted use="axes with your numbers drawn for you: chart at x,y WxH x=\\"Q1,Q2,Q3\\" y=0..100, then a line per series: | bars \\"Revenue\\" 42 61 75"
11909
+
11910
+ // ---- lines -----------------------------------------------------------------
11911
+ style arrow line stroke=muted sw=1 route=ortho radius=8 label.font=mono label.size=8 label.color=muted label.spacing=0.06 use="default arrow"
11912
+ style primary extends arrow stroke=accent sw=1.6 label.color=accent use="the main path; at most two per diagram"
11913
+ style link extends arrow stroke=link label.color=link use="an HTTP or API request crossing a boundary"
11914
+ style return extends arrow dash=5,4 use="a response, or something optional or asynchronous"
11915
+ style relation extends relation stroke=ink/0.7 label.font=mono label.size=8
11916
+ style lifeline line head=none stroke=ink/0.3 sw=1 dash=4,4 route=straight use="sequence diagram lifeline"
11917
+ style rule line head=none stroke=#3c3f48 sw=1 route=straight use="thin separator, e.g. above a legend"
11918
+
11919
+ // ---- text ------------------------------------------------------------------
11920
+ style h1 text font=serif size=36 weight=400 color=ink use="diagram title"
11921
+ style kicker text font=mono size=9 weight=500 color=accent spacing=0.14 caps=1 use="optional: a short category above the title, e.g. PROCESS"
11922
+ style dek text font=sans size=13 color=muted use="optional: one line under the title saying what the diagram shows"
11923
+ style eyebrow text font=mono size=8 color=soft spacing=0.16 caps=1 use="small caps label, e.g. LEGEND"
11924
+ style caption text font=sans size=9.5 color=muted use="small explanatory text"
11925
+ style legend extends legend rule=ink/0.12 title.font=mono item.size=9.5
11926
+ style note text font=serif italic=1 size=16 color=ink use="a short aside; at most two"
11927
+ style small text font=mono size=9 color=muted use="technical detail: a port, path or command"
11928
+
12135
11929
  guidance "focal, terminal-focal and primary are the accent. Use the accent on at most two things in one diagram."
12136
11930
  guidance "Never fill a shape with ink to make it stand out; use focal."
12137
11931
  guidance "tag= is a 3 or 4 letter type marker in the corner of a box (EXT, EDGE, API, DB). Use it on architecture boxes, not flowchart shapes."
@@ -12144,6 +11938,9 @@ guidance "Finish with a legend: one statement, 'legend at x,y' followed by style
12144
11938
  // hatching for the subject. White page, near-black ink, one blue for what the diagram is about.
12145
11939
 
12146
11940
  canvas paper=paper sketch=1
11941
+
11942
+ // the look the dark theme and "fastdraw render --dark" draw this look with
11943
+ dark sketch-dark
12147
11944
  fontdir "./fonts"
12148
11945
 
12149
11946
  color paper #ffffff
@@ -12237,80 +12034,105 @@ guidance "Colour by meaning with the pastel fills: fill=sky/0.5, fill=mint/0.7,
12237
12034
  guidance "hatch=colour fills a shape with pencil hatching; hatch.gap spaces the lines."
12238
12035
  guidance "Finish with a legend: one statement, 'legend at x,y' followed by style=\\"what it means\\" for each style you used."
12239
12036
  `,
12240
- transit: `// Transit: a transit map. The lines are the picture: thick coloured routes with sweeping bends and a ring
12241
- // where each one starts; the boxes are stations along them. Same style names as the built-in look.
12037
+ "sketch-dark": `// Sketch dark: Sketch on a dark page, like a whiteboard tool's dark mode. Marker-weight outlines that
12038
+ // wobble, the handwritten font, deep pastel fills and pencil hatching for the subject. Near-black page,
12039
+ // near-white ink, one bright blue for what the diagram is about. Same styles and sizes as Sketch.
12242
12040
 
12243
- canvas paper=paper
12041
+ canvas paper=paper sketch=1
12244
12042
 
12245
- color paper #ffffff
12246
- color card #ffffff
12247
- color ink #14213d
12248
- color muted #5c677d
12249
- color soft #8a94a8
12250
- color accent #e4002b
12251
- color link #0072ce
12252
- color teal #00857c
12253
- color amber #f2a900
12254
- color rose #e4002b
12255
- color violet #6a3fa0
12043
+ // already dark, so "fastdraw render --dark" and the dark theme draw this look too
12044
+ dark sketch-dark
12045
+ fontdir "./fonts"
12256
12046
 
12257
- font sans "Geist"
12047
+ color paper #121316
12048
+ color ink #e6e6ea
12049
+ color muted #b0b4bb
12050
+ color soft #7c828b
12051
+ color accent #4dabf7
12052
+ color sky #1f4f78
12053
+ color mint #2c5c38
12054
+ color leaf #69db7c
12055
+ color butter #5a4c17
12056
+ color amber #ffa94d
12057
+ color rose #6e2f35
12058
+ color link #9775fa
12059
+
12060
+ font sans "Sketch Hand"
12061
+ font serif "Sketch Hand"
12258
12062
  font mono "Geist Mono"
12259
- font serif "Newsreader"
12260
12063
 
12261
- // ---- boxes -----------------------------------------------------------------
12262
- style node shape=rect radius=32 size=144x64 fill=card stroke=ink sw=3.5 title.size=12.5 sub.font=sans sub.size=9.5 sub.color=muted
12263
- tag.color=muted tag.border=ink/0.35 tag.font=mono icon.color=ink use="default box: a backend, service, component or step"
12264
- style focal extends node fill=ink title.color=#ffffff sub.color=#ffffff/0.8 tag.color=#ffffff tag.border=#ffffff/0.6 icon.color=#ffffff ghost.color=#ffffff/0.14 use="the one or two elements the diagram is about"
12265
- style store extends node inner=ink inner.gap=5.5 inner.sw=1.2 use="something that holds data or state"
12266
- style cloud extends node stroke=link icon.color=link use="a hosted or third-party platform"
12267
- style external extends node sw=2 dash=6,5 icon.color=muted use="a person or system outside what you own"
12268
- style optional extends node sw=2 stroke=ink/0.6 dash=2,5 use="optional or asynchronous participant"
12269
- style sticky extends node radius=4 size=120x120 fill=#ffe9a8 stroke=none sw=0 use="a yellow sticky note: an idea, comment or open question"
12270
- style sticky-orange extends sticky fill=#ffd2c2 use="an orange sticky note: a risk or issue"
12271
- style sticky-violet extends sticky fill=#e6dcf7 use="a violet sticky note: a decision or note"
12064
+ // ---- boxes ----------------------------------------------------------------
12065
+ style node shape=rect radius=10 size=144x64 fill=paper stroke=ink sw=2
12066
+ title.font=sans title.size=14 title.weight=400 title.color=ink sub.font=sans sub.size=10.5 sub.color=muted
12067
+ tag.font=sans tag.size=9 tag.color=muted tag.border=ink/0.35
12068
+ use="default box: a backend, service, component or step"
12069
+ style focal extends node fill=sky/0.35 hatch=accent/0.5 hatch.gap=8 hatch.sw=1.2 stroke=accent
12070
+ title.color=ink tag.color=accent tag.border=accent/0.6 ghost.color=accent/0.12
12071
+ use="the one or two elements the diagram is about"
12072
+ style store extends node size=144x72
12073
+ path="M0,0.1 C0,-0.035 1,-0.035 1,0.1 L1,0.9 C1,1.035 0,1.035 0,0.9 Z M0,0.1 C0,0.235 1,0.235 1,0.1 C1,0.235 0,0.235 0,0.1"
12074
+ shape=path fill=butter stroke=ink
12075
+ use="something that holds data or state"
12076
+ style cloud extends node fill=mint/0.7 stroke=leaf tag.color=leaf tag.border=leaf/0.5
12077
+ use="a hosted or third-party platform"
12078
+ style external extends node fill=paper stroke=muted dash=8,7 tag.color=soft
12079
+ use="a person or system outside what you own"
12080
+ style optional extends node fill=paper stroke=soft dash=2,6 tag.color=soft
12081
+ use="optional or asynchronous participant"
12082
+ style sticky extends node size=128x128 radius=4 fill=butter stroke=ink sw=1.5
12083
+ use="a yellow sticky note: an idea, comment or open question"
12084
+ style sticky-orange extends sticky fill=#5c3a17 use="an orange sticky note: a risk or issue"
12085
+ style sticky-violet extends sticky fill=#3c3166 use="a violet sticky note: a decision or note"
12272
12086
 
12273
- // ---- flowchart shapes ------------------------------------------------------
12274
- style step extends node size=160x48 use="flowchart action"
12275
- style terminal extends node size=160x48 fill=#eef2f7 use="flowchart start or end"
12276
- style terminal-focal extends terminal fill=ink title.color=#ffffff sub.color=#ffffff/0.8 use="the flowchart outcome that matters most"
12277
- style decision shape=diamond size=200x96 fill=card stroke=ink sw=3.5 title.size=12.5 use="flowchart yes/no question; put the text on two short lines"
12087
+ // ---- flowchart shapes -----------------------------------------------------
12088
+ style step extends node size=160x56 use="flowchart action"
12089
+ style terminal extends node shape=ellipse size=168x60 fill=rose/0.6
12090
+ use="flowchart start or end"
12091
+ style terminal-focal extends terminal fill=sky/0.35 hatch=accent/0.5 hatch.gap=8 hatch.sw=1.2 stroke=accent
12092
+ use="the flowchart outcome that matters most"
12093
+ style decision extends node shape=diamond size=208x104 fill=butter/0.8
12094
+ use="flowchart yes/no question; put the text on two short lines"
12278
12095
 
12279
- // ---- regions and markers ---------------------------------------------------
12280
- style zone shape=rect radius=26 fill=#eef2f7 stroke=none sw=0 layer=back
12281
- title.pos=top title.dy=6 title.fill=none title.align=left title.font=sans title.size=11 title.weight=600 title.color=soft title.spacing=0.1 title.caps=1 use="a labelled region drawn behind a group of boxes; always give WxH"
12282
- style bar shape=rect radius=4 size=8x80 fill=ink stroke=ink sw=1 use="sequence diagram activation bar, centred on a lifeline; always give WxH"
12283
- style table shape=table radius=10 fill=card stroke=ink sw=3 head.fill=ink/0.07 rule=ink/0.12
12284
- cell.font=mono cell.size=10 detail.color=muted use="an entity, class or database table: a header and rows. One line per row: | id \\"name\\" \\"type\\" \\"key\\". Arrows can end on a row: orders.user_id -> users.id"
12285
- style matrix extends table align=center grid=1 cell.font=sans use="a grid of values: first row with |= for the column headings, first cell of each row is its name"
12286
- style chart shape=chart fill=none stroke=ink sw=2 mask=0 bar.radius=3 grid.color=ink/0.08
12287
- tick.font=mono tick.size=9 tick.color=muted use="axes with your numbers drawn for you: chart at x,y WxH x=\\"Q1,Q2,Q3\\" y=0..100, then a line per series: | bars \\"Revenue\\" 42 61 75"
12096
+ // ---- other shapes ---------------------------------------------------------
12097
+ style zone shape=rect radius=12 fill=none stroke=soft sw=1.5 dash=10,8 layer=back
12098
+ title.pos=top title.font=sans title.size=13 title.weight=400 title.color=muted
12099
+ use="a labelled region drawn behind a group of boxes; always give WxH"
12100
+ style bar shape=rect size=10x80 fill=sky/0.5 stroke=ink sw=1.5
12101
+ use="sequence diagram activation bar, centred on a lifeline; always give WxH"
12288
12102
 
12289
- // ---- lines -----------------------------------------------------------------
12290
- style arrow line stroke=ink sw=6 cap=round route=ortho radius=22 casing=paper casing.width=2.5 tail=stop stop.color=ink head.size=1.7
12291
- label.font=sans label.size=9 label.weight=600 label.spacing=0.05 label.color=#ffffff label.fill=ink label.radius=3 label.pad=4 use="default arrow"
12292
- style primary extends arrow stroke=accent sw=9 label.fill=accent use="the main path; at most two per diagram"
12293
- style link extends arrow stroke=link label.fill=link use="an HTTP or API request crossing a boundary"
12294
- style return extends arrow stroke=#8a94a6 dash=1,11 label.fill=#8a94a6 use="a response, or something optional or asynchronous"
12295
- style relation extends relation stroke=ink sw=3 label.font=sans label.size=10 label.spacing=0 label.caps=0
12296
- style lifeline line head=none stroke=ink/0.3 sw=2 dash=1,7 cap=round route=straight use="sequence diagram lifeline"
12297
- style rule line head=none stroke=#c9ced8 sw=1.5 route=straight use="thin separator, e.g. above a legend"
12103
+ style table shape=table radius=6 fill=paper stroke=ink sw=2 head.fill=sky/0.45 rule=ink/0.2
12104
+ title.font=sans title.size=14 title.weight=400 cell.font=sans cell.size=12 detail.color=muted
12105
+ use="an entity, class or database table: a header and rows. One line per row: | id \\"name\\" \\"type\\" \\"key\\". Arrows can end on a row: orders.user_id -> users.id"
12106
+ style matrix extends table align=center grid=1
12107
+ use="a grid of values: first row with |= for the column headings, first cell of each row is its name"
12108
+ style chart shape=chart fill=none stroke=ink sw=1.5 mask=0 bar.radius=3 grid.color=ink/0.1
12109
+ tick.font=sans tick.size=11 tick.color=muted
12110
+ use="axes with your numbers drawn for you: chart at x,y WxH x=\\"Q1,Q2,Q3\\" y=0..100, then a line per series: | bars \\"Revenue\\" 42 61 75"
12298
12111
 
12299
- // ---- text ------------------------------------------------------------------
12300
- style h1 text font=sans size=32 weight=600 color=ink spacing=-0.025 use="diagram title"
12301
- style kicker text font=sans size=10 weight=600 color=accent spacing=0.1 caps=1 use="optional: a short category above the title, e.g. PROCESS"
12302
- style dek text font=sans size=14 color=muted use="optional: one line under the title saying what the diagram shows"
12303
- style eyebrow text font=sans size=9 weight=600 color=muted spacing=0.1 caps=1 use="small caps label, e.g. LEGEND"
12304
- style caption text font=sans size=10 color=muted use="small explanatory text"
12305
- style legend extends legend rule=ink/0.14 title.font=sans title.size=9 item.size=10
12306
- style note text font=sans size=13 color=muted use="a short aside; at most two"
12307
- style small text font=mono size=9 color=muted use="technical detail: a port, path or command"
12112
+ // ---- lines ----------------------------------------------------------------
12113
+ style arrow line stroke=ink sw=2 route=ortho radius=14 label.font=sans label.size=12 label.spacing=0 label.caps=0 label.color=muted
12114
+ use="default arrow"
12115
+ style primary extends arrow stroke=accent sw=2.5 label.color=accent use="the main path; at most two per diagram"
12116
+ style link extends arrow stroke=link label.color=link use="an HTTP or API request crossing a boundary"
12117
+ style return extends arrow stroke=muted dash=8,7 use="a response, or something optional or asynchronous"
12118
+ style relation extends relation sw=1.8 label.font=sans label.size=12 label.spacing=0 label.caps=0
12119
+ style lifeline line head=none stroke=soft sw=1.5 dash=6,6 route=straight use="sequence diagram lifeline"
12120
+ style rule line head=none stroke=ink/0.25 sw=1.5 route=straight use="thin separator, e.g. above a legend"
12308
12121
 
12309
- guidance "focal, terminal-focal and primary are the accent. Use the accent on at most two things in one diagram."
12310
- guidance "Never fill a shape with ink to make it stand out; use focal."
12311
- guidance "tag= is a 3 or 4 letter type marker in the corner of a box (EXT, EDGE, API, DB). Use it on architecture boxes, not flowchart shapes."
12312
- guidance "sub= is a short second line of detail: a product name, path, port or protocol. Names of things go in the main text."
12313
- guidance "kicker and dek are optional. Add a kicker only when the diagram belongs to a named category, and a dek only when there is one clear message; most diagrams need neither."
12122
+ // ---- text -----------------------------------------------------------------
12123
+ style h1 text font=sans size=30 weight=400 color=ink use="diagram title"
12124
+ style kicker text font=sans size=13 color=accent use="optional: a short category above the title"
12125
+ style dek text font=sans size=16 color=muted use="optional: one line under the title saying what the diagram shows"
12126
+ style eyebrow text font=sans size=12 color=muted use="small heading, e.g. Legend"
12127
+ style caption text font=sans size=11 color=muted use="small explanatory text"
12128
+ style legend extends legend title.font=sans title.size=13 title.caps=0 title.spacing=0 item.font=sans item.size=12
12129
+ style note text font=sans size=16 color=accent use="a short handwritten aside; at most two"
12130
+ style small text font=mono size=10 color=muted use="technical detail: a port, path or command"
12131
+
12132
+ guidance "Everything is drawn by hand (canvas sketch=1). Keep diagrams loose and roomy: the handwriting is wider than a normal sans, so give boxes a little more width."
12133
+ guidance "focal, terminal-focal and primary are the accent blue. Use the accent on at most two things in one diagram."
12134
+ guidance "Colour by meaning with the pastel fills: fill=sky/0.5, fill=mint/0.7, fill=butter, fill=rose/0.6. Never fill a shape with ink."
12135
+ guidance "hatch=colour fills a shape with pencil hatching; hatch.gap spaces the lines."
12314
12136
  guidance "Finish with a legend: one statement, 'legend at x,y' followed by style=\\"what it means\\" for each style you used."
12315
12137
  `,
12316
12138
  whiteboard: `// Whiteboard: an online-whiteboard look. A white board with a light dot grid, white rounded
@@ -12319,6 +12141,9 @@ guidance "Finish with a legend: one statement, 'legend at x,y' followed by style
12319
12141
 
12320
12142
  canvas paper=paper dots=ink/0.14 dotgap=24
12321
12143
 
12144
+ // the look the dark theme and "fastdraw render --dark" draw this look with
12145
+ dark whiteboard-dark
12146
+
12322
12147
  color paper #fafafb
12323
12148
  color ink #1a1b25
12324
12149
  color muted #4b4d5c
@@ -12364,7 +12189,113 @@ style sticky-violet extends sticky fill=violet use="a violet sticky note: a deci
12364
12189
 
12365
12190
  // ---- flowchart shapes -----------------------------------------------------
12366
12191
  style step extends node size=160x48 use="flowchart action"
12367
- style terminal shape=rect radius=24 size=160x48 fill=#ffffff stroke=ink sw=1.6 title.weight=500
12192
+ style terminal shape=rect radius=24 size=160x48 fill=#ffffff stroke=ink sw=1.6 title.weight=500
12193
+ sub.font=sans sub.color=muted tag.color=ink tag.border=ink/0.35
12194
+ use="flowchart start or end"
12195
+ style terminal-focal extends terminal fill=accent stroke=accent title.color=#ffffff
12196
+ sub.color=#ffffff/0.85 tag.color=#ffffff tag.border=#ffffff/0.6
12197
+ use="the flowchart outcome that matters most"
12198
+ style decision shape=diamond size=200x96 fill=yellow stroke=ink sw=1.6 title.weight=500
12199
+ use="flowchart yes/no question; put the text on two short lines"
12200
+
12201
+ // ---- other shapes ---------------------------------------------------------
12202
+ // a zone is a board frame: white sheet, light outline, plain sans name
12203
+ style zone shape=rect radius=6 fill=#ffffff/0.7 stroke=ink/0.16 sw=1 layer=back
12204
+ title.pos=top title.font=sans title.size=11 title.weight=500 title.color=muted title.spacing=0 title.caps=0
12205
+ use="a labelled region drawn behind a group of boxes; always give WxH"
12206
+ style bar shape=rect radius=2 size=8x80 fill=accent/0.14 stroke=accent sw=1
12207
+ use="sequence diagram activation bar, centred on a lifeline; always give WxH"
12208
+
12209
+ style table shape=table radius=8 fill=#ffffff stroke=ink sw=1.4 head.fill=blue rule=ink/0.1
12210
+ cell.font=sans cell.size=10.5 detail.color=muted
12211
+ use="an entity, class or database table: a header and rows. One line per row: | id \\"name\\" \\"type\\" \\"key\\". Arrows can end on a row: orders.user_id -> users.id"
12212
+ style matrix extends table align=center grid=1 cell.font=sans
12213
+ use="a grid of values: first row with |= for the column headings, first cell of each row is its name"
12214
+ style chart shape=chart fill=none stroke=ink/0.6 sw=1.2 mask=0 bar.radius=3 grid.color=ink/0.08
12215
+ tick.font=sans tick.size=10 tick.color=muted
12216
+ use="axes with your numbers drawn for you: chart at x,y WxH x=\\"Q1,Q2,Q3\\" y=0..100, then a line per series: | bars \\"Revenue\\" 42 61 75"
12217
+
12218
+ // ---- lines ----------------------------------------------------------------
12219
+ style arrow line stroke=ink sw=1.6 route=curve radius=10 label.font=sans label.size=10.5 label.color=muted label.spacing=0 label.caps=0
12220
+ use="default connector"
12221
+ style primary extends arrow stroke=accent sw=2.2 use="the main path; at most two per diagram"
12222
+ style link extends arrow stroke=link use="an HTTP or API request crossing a boundary"
12223
+ style return extends arrow stroke=muted dash=6,4 use="a response, or something optional or asynchronous"
12224
+ style relation extends relation label.font=sans label.size=10.5 label.spacing=0 label.caps=0
12225
+ style lifeline line head=none stroke=ink/0.25 sw=1.2 dash=4,4 route=straight use="sequence diagram lifeline"
12226
+ style rule line head=none stroke=ink/0.12 sw=1 route=straight use="thin separator, e.g. above a legend"
12227
+
12228
+ // ---- text -----------------------------------------------------------------
12229
+ style h1 text font=sans size=28 weight=600 color=ink use="diagram title"
12230
+ style kicker text font=sans size=11 weight=600 color=accent spacing=0.06 caps=1 use="optional: a short category above the title, e.g. PROCESS"
12231
+ style dek text font=sans size=14 color=muted use="optional: one line under the title saying what the diagram shows"
12232
+ style eyebrow text font=sans size=9 weight=600 color=muted spacing=0.08 caps=1 use="small caps label, e.g. LEGEND"
12233
+ style caption text font=sans size=10 color=muted use="small explanatory text"
12234
+ style legend extends legend title.font=sans item.font=sans item.size=10
12235
+ style note text font=sans size=13 color=muted use="a short aside; at most two"
12236
+ style small text font=mono size=9.5 color=muted use="technical detail: a port, path or command"
12237
+
12238
+ guidance "focal, terminal-focal and primary are the blue accent. Use the accent on at most two things in one diagram."
12239
+ guidance "store, cloud and external are sticky notes (blue, green, pink). sticky, sticky-orange and sticky-violet are free notes for ideas, risks and decisions; keep their text short."
12240
+ guidance "Never fill a shape with ink to make it stand out; use the accent."
12241
+ guidance "tag= is a 3 or 4 letter type marker in the corner of a box (EXT, EDGE, API, DB). Use it on architecture boxes, not flowchart shapes."
12242
+ guidance "Finish with a legend: one statement, 'legend at x,y' followed by style=\\"what it means\\" for each style you used."
12243
+ `,
12244
+ "whiteboard-dark": `// Whiteboard dark: Whiteboard on a dark board. A charcoal board with a faint dot grid, raised dark shapes
12245
+ // with a light outline, deep sticky notes for the kinds of thing, curved light connectors, one bright blue
12246
+ // for the subject and the main path, and sans type throughout. Same styles and sizes as Whiteboard.
12247
+
12248
+ canvas paper=paper dots=ink/0.14 dotgap=24
12249
+
12250
+ // already dark, so "fastdraw render --dark" and the dark theme draw this look too
12251
+ dark whiteboard-dark
12252
+
12253
+ color paper #1b1c23
12254
+ color ink #ececf1
12255
+ color muted #b1b3c0
12256
+ color soft #7e808d
12257
+ color accent #6b84ff
12258
+ color link #4fb8b2
12259
+
12260
+ // sticky-note pastels
12261
+ color yellow #57501f
12262
+ color blue #1f3d5e
12263
+ color green #2d4b22
12264
+ color pink #582a40
12265
+ color orange #5b3a1d
12266
+ color violet #3a305f
12267
+
12268
+ font sans "Geist"
12269
+ font mono "Geist Mono"
12270
+ font serif "Newsreader"
12271
+
12272
+ // ---- boxes ----------------------------------------------------------------
12273
+ // plain boards shapes are white with a dark outline; stickies have no outline
12274
+ style node shape=rect radius=10 size=144x64 fill=#262832 stroke=ink sw=1.6
12275
+ title.font=sans title.weight=500 title.color=ink sub.font=sans sub.color=muted
12276
+ tag.color=ink tag.border=ink/0.35
12277
+ use="default box: a backend, service, component or step"
12278
+ style focal extends node fill=accent/0.10 stroke=accent sw=2.2
12279
+ title.color=accent tag.color=accent tag.border=accent/0.5 ghost.color=accent/0.12
12280
+ use="the one or two elements the diagram is about"
12281
+ style store extends node radius=3 fill=blue stroke=none sw=0 tag.color=ink tag.border=ink/0.3
12282
+ use="something that holds data or state (blue sticky)"
12283
+ style cloud extends node radius=3 fill=green stroke=none sw=0 tag.color=ink tag.border=ink/0.3
12284
+ use="a hosted or third-party platform (green sticky)"
12285
+ style external extends node radius=3 fill=pink stroke=none sw=0 tag.color=ink tag.border=ink/0.3
12286
+ use="a person or system outside what you own (pink sticky)"
12287
+ style optional extends node fill=#262832 stroke=soft sw=1.4 dash=6,4 tag.color=soft tag.border=soft/0.5
12288
+ title.color=muted
12289
+ use="optional or asynchronous participant"
12290
+ style sticky extends node radius=3 size=120x120 fill=yellow stroke=none sw=0 title.weight=400
12291
+ tag.color=ink tag.border=ink/0.3
12292
+ use="a yellow sticky note: an idea, comment or open question"
12293
+ style sticky-orange extends sticky fill=orange use="an orange sticky note: a risk or issue"
12294
+ style sticky-violet extends sticky fill=violet use="a violet sticky note: a decision or note"
12295
+
12296
+ // ---- flowchart shapes -----------------------------------------------------
12297
+ style step extends node size=160x48 use="flowchart action"
12298
+ style terminal shape=rect radius=24 size=160x48 fill=#262832 stroke=ink sw=1.6 title.weight=500
12368
12299
  sub.font=sans sub.color=muted tag.color=ink tag.border=ink/0.35
12369
12300
  use="flowchart start or end"
12370
12301
  style terminal-focal extends terminal fill=accent stroke=accent title.color=#ffffff
@@ -12375,13 +12306,13 @@ style decision shape=diamond size=200x96 fill=yellow stroke=ink sw=1.6 title.wei
12375
12306
 
12376
12307
  // ---- other shapes ---------------------------------------------------------
12377
12308
  // a zone is a board frame: white sheet, light outline, plain sans name
12378
- style zone shape=rect radius=6 fill=#ffffff/0.7 stroke=ink/0.16 sw=1 layer=back
12309
+ style zone shape=rect radius=6 fill=#262832/0.7 stroke=ink/0.16 sw=1 layer=back
12379
12310
  title.pos=top title.font=sans title.size=11 title.weight=500 title.color=muted title.spacing=0 title.caps=0
12380
12311
  use="a labelled region drawn behind a group of boxes; always give WxH"
12381
12312
  style bar shape=rect radius=2 size=8x80 fill=accent/0.14 stroke=accent sw=1
12382
12313
  use="sequence diagram activation bar, centred on a lifeline; always give WxH"
12383
12314
 
12384
- style table shape=table radius=8 fill=#ffffff stroke=ink sw=1.4 head.fill=blue rule=ink/0.1
12315
+ style table shape=table radius=8 fill=#262832 stroke=ink sw=1.4 head.fill=blue rule=ink/0.1
12385
12316
  cell.font=sans cell.size=10.5 detail.color=muted
12386
12317
  use="an entity, class or database table: a header and rows. One line per row: | id \\"name\\" \\"type\\" \\"key\\". Arrows can end on a row: orders.user_id -> users.id"
12387
12318
  style matrix extends table align=center grid=1 cell.font=sans
@@ -12487,20 +12418,27 @@ function emptyLook() {
12487
12418
  styles: /* @__PURE__ */ new Map(),
12488
12419
  icons: new Map(Object.entries(ICONS)),
12489
12420
  iconDirs: [],
12421
+ iconUrls: /* @__PURE__ */ new Map(),
12422
+ hideBuiltIns: false,
12423
+ iconSetNames: /* @__PURE__ */ new Map(),
12424
+ fontUrls: /* @__PURE__ */ new Map(),
12490
12425
  images: /* @__PURE__ */ new Map(),
12426
+ iconFolderRead: false,
12491
12427
  guidance: [],
12492
12428
  issues: []
12493
12429
  };
12494
12430
  for (const s of BUILTIN) look.styles.set(s.name, { ...s, props: { ...s.props } });
12495
12431
  return look;
12496
12432
  }
12433
+ var isWebUrl = (s) => /^https:\/\/[^\s\x00-\x1f\x7f"'<>\\`]+$/i.test(s) && s.length <= 500;
12434
+ var hasScheme = (s) => /^[a-z][a-z0-9+.-]*:/i.test(s);
12497
12435
  function parseLook(src, path = "look") {
12498
12436
  const look = emptyLook();
12499
12437
  for (const st of parseStatements(src)) {
12500
12438
  const [head, ...rest] = st.toks;
12501
12439
  const err = (msg) => look.issues.push({ line: st.line, level: "error", msg, file: path });
12502
12440
  if (head.t !== "word") {
12503
- err("a look statement must start with canvas, color, font, fontdir, style, icon, icondir, guidance or dark");
12441
+ err("a look statement must start with canvas, color, font, fontdir, style, icon, icons, icondir, guidance or dark");
12504
12442
  continue;
12505
12443
  }
12506
12444
  if (head.v === "dark") {
@@ -12511,16 +12449,35 @@ function parseLook(src, path = "look") {
12511
12449
  }
12512
12450
  if (head.v === "icondir") {
12513
12451
  if (!rest[0]) err('icondir needs a folder of SVG files, e.g. icondir "./icons"');
12514
- else look.iconDirs.push(rest[0].v);
12452
+ else if (hasScheme(rest[0].v) && !isWebUrl(rest[0].v)) err(`icondir takes a folder next to the look or an https:// address, e.g. icondir "https://cdn.jsdelivr.net/npm/simple-icons@16.38.0/icons/{name}.svg"; "${rest[0].v}" is neither`);
12453
+ else {
12454
+ look.iconDirs.push(rest[0].v);
12455
+ const names = rest.slice(1).find((t) => t.t === "prop" && t.k === "names")?.v;
12456
+ if (names !== void 0) {
12457
+ const list2 = names.split(/\s+/).filter(Boolean);
12458
+ if (!isWebUrl(rest[0].v)) err(`names= lists the icons of an icondir address; a folder's icons are its files ("${rest[0].v}")`);
12459
+ else if (!list2.length || list2.some((n) => !/^[a-z0-9-]{1,80}$/.test(n)) || list2.length > 3e3) err('icondir names= lists icon names in small letters separated by spaces, e.g. names="pod deploy svc"');
12460
+ else look.iconSetNames.set(rest[0].v, list2);
12461
+ }
12462
+ }
12515
12463
  continue;
12516
12464
  }
12517
12465
  if (head.v === "icon") {
12518
12466
  const name2 = rest[0]?.t === "word" ? rest[0].v : void 0, paths = rest.slice(1).filter((t) => t.t === "str").map((t) => t.v);
12519
12467
  if (!name2 || !/^[a-z][a-z0-9-]*$/.test(name2)) err('icon needs a name in small letters, e.g. icon queue "M4 6h16 M4 12h16 M4 18h16"');
12520
- else if (!paths.length || paths.some((d) => !/^[MmLlHhVvCcSsQqTtAaZz0-9eE\s,.+-]+$/.test(d) || d.length > 4e3) || paths.length > 12) err(`icon ${name2} needs its outline as SVG path data in quotes, drawn in a 24x24 box, e.g. "M4 6h16 M4 12h16"`);
12468
+ else if (paths.length === 1 && hasScheme(paths[0])) {
12469
+ if (isWebUrl(paths[0])) look.iconUrls.set(name2, paths[0]);
12470
+ else err(`icon ${name2} takes the https:// address of an SVG file, e.g. icon ${name2} "https://cdn.jsdelivr.net/npm/aws-icons@3.3.0/icons/architecture-service/AWSLambda.svg"`);
12471
+ } else if (!paths.length || paths.some((d) => !/^[MmLlHhVvCcSsQqTtAaZz0-9eE\s,.+-]+$/.test(d) || d.length > 4e3) || paths.length > 12) err(`icon ${name2} needs its outline as SVG path data in quotes, drawn in a 24x24 box, e.g. "M4 6h16 M4 12h16"`);
12521
12472
  else look.icons.set(name2, paths);
12522
12473
  continue;
12523
12474
  }
12475
+ if (head.v === "icons") {
12476
+ const v = rest.length === 1 && rest[0].t === "prop" && rest[0].k === "builtin" ? rest[0].v : void 0;
12477
+ if (v === "hidden" || v === "shown") look.hideBuiltIns = v === "hidden";
12478
+ else err("icons takes builtin=hidden (the built-in icons are not offered in the icon picker, the preview or the icon lists; diagrams that use one still draw) or builtin=shown");
12479
+ continue;
12480
+ }
12524
12481
  if (head.v === "fontdir") {
12525
12482
  if (!rest[0]) err('fontdir needs a folder, e.g. fontdir "./fonts"');
12526
12483
  else look.fontDirs.push(rest[0].v);
@@ -12534,6 +12491,11 @@ function parseLook(src, path = "look") {
12534
12491
  continue;
12535
12492
  }
12536
12493
  (head.v === "color" ? look.colors : look.fonts).set(rest[0].v, rest[1].v);
12494
+ const at = head.v === "font" ? rest[2]?.v : void 0;
12495
+ if (at !== void 0) {
12496
+ if (isWebUrl(at)) look.fontUrls.set(rest[1].v, at);
12497
+ else err(`font ${rest[0].v} "${rest[1].v}" takes the https:// address of its files as the third value, with {weight} and {style} where they differ, e.g. "https://cdn.jsdelivr.net/fontsource/fonts/inter@5.3.0/latin-{weight}-{style}.ttf"`);
12498
+ }
12537
12499
  } else if (head.v === "guidance") {
12538
12500
  for (const t of rest) if (t.t === "str") look.guidance.push(t.v);
12539
12501
  } else if (head.v === "style") {
@@ -12654,15 +12616,23 @@ function backdrop(look, v) {
12654
12616
  if (!top || !page) return top;
12655
12617
  return [0, 1, 2].map((i) => top[i] * a + page[i] * (1 - a));
12656
12618
  }
12619
+ var SHIPPED_FAMILIES = ["Geist", "Geist Mono", "Newsreader", "Libre Franklin", "Instrument Serif", "Libre Caslon Display", "Sketch Hand"];
12620
+ var SYSTEM_FAMILIES = ["sans-serif", "serif", "monospace", "helvetica"];
12621
+ var isShippedFamily = (fam2) => [...SHIPPED_FAMILIES, ...SYSTEM_FAMILIES].some((f) => f.toLowerCase() === fam2.toLowerCase());
12622
+ var fallbackFamily = (role, fam2) => role === "mono" || /mono/i.test(fam2) ? "Geist Mono" : role === "serif" ? "Newsreader" : "Geist";
12657
12623
  function fontFamily(look, v) {
12658
12624
  const name2 = v ?? "sans";
12659
12625
  const fam2 = look.fonts.get(name2) ?? name2;
12660
12626
  const generic = name2 === "mono" ? "monospace" : name2 === "serif" ? "serif" : "sans-serif";
12661
- return `'${fam2}', ${generic}`;
12627
+ return isShippedFamily(fam2) ? `'${fam2}', ${generic}` : `'${fam2}', '${fallbackFamily(name2, fam2)}', ${generic}`;
12662
12628
  }
12663
12629
  var cachedDefault;
12664
12630
  var BUNDLED_LOOK_NAMES = Object.keys(BUNDLED_LOOKS);
12665
12631
  var isBundledLook = (p) => !!p && Object.hasOwn(BUNDLED_LOOKS, p);
12632
+ var LOOKS_REPO = "coccor/fastdraw-looks";
12633
+ var MOVED_LOOKS = ["engraved", "headline", "keys", "listing", "offset", "transit"];
12634
+ var movedLookUrl = (name2) => MOVED_LOOKS.includes(name2) ? `https://raw.githubusercontent.com/${LOOKS_REPO}/main/${name2}.look` : void 0;
12635
+ var isWebLook = (p) => !!p && isWebUrl(p) && /^[^?#]*\.look(?:[?#]|$)/i.test(p);
12666
12636
  var bundledCache = /* @__PURE__ */ new Map();
12667
12637
  function bundledLook(name2) {
12668
12638
  if (!isBundledLook(name2)) return null;
@@ -12679,6 +12649,65 @@ function resetLookCaches() {
12679
12649
  bundledCache.clear();
12680
12650
  }
12681
12651
 
12652
+ // src/order.ts
12653
+ var byNumber = (a, b) => Number.isNaN(a) ? Number.isNaN(b) ? 0 : 1 : Number.isNaN(b) ? -1 : a < b ? -1 : a > b ? 1 : 0;
12654
+
12655
+ // src/extendedIcons.ts
12656
+ var loading;
12657
+ var loaded = false;
12658
+ var listeners = /* @__PURE__ */ new Set();
12659
+ var extendedIconsLoaded = () => loaded;
12660
+ function loadExtendedIcons() {
12661
+ loading ??= Promise.resolve().then(() => (init_iconSetAll(), iconSetAll_exports)).then((m) => {
12662
+ for (const w of Object.keys(m.EXTRA_WEIGHTS)) Object.assign(ICON_WEIGHTS[w], m.EXTRA_WEIGHTS[w]);
12663
+ Object.assign(DUOTONE_TINT, m.EXTRA_TINT);
12664
+ Object.assign(ICON_WORDS, m.EXTRA_WORDS);
12665
+ loaded = true;
12666
+ resetLookCaches();
12667
+ listeners.forEach((fn) => fn());
12668
+ });
12669
+ return loading;
12670
+ }
12671
+
12672
+ // src/iconfiles.ts
12673
+ var MAX_ICON_BYTES = 3e5;
12674
+ var MAX_ICON_FILES = 3e3;
12675
+ var URI = /^data:image\/svg\+xml;base64,[A-Za-z0-9+/]+=*$/;
12676
+ var isIconUri = (v) => typeof v === "string" && v.length < MAX_ICON_BYTES * 1.4 && URI.test(v);
12677
+ function iconName(file) {
12678
+ return file.replace(/\.svg$/i, "").toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^\d+-icon-service-/, "").replace(/^-+|-+$/g, "");
12679
+ }
12680
+ function svgDataUri(bytes) {
12681
+ if (bytes.length === 0 || bytes.length > MAX_ICON_BYTES) return null;
12682
+ const head = new TextDecoder().decode(bytes.subarray(0, 2e3));
12683
+ if (!/<svg[\s>]/i.test(head)) return null;
12684
+ let bin = "";
12685
+ for (let i = 0; i < bytes.length; i += 32768) bin += String.fromCharCode(...bytes.subarray(i, i + 32768));
12686
+ return "data:image/svg+xml;base64," + btoa(bin);
12687
+ }
12688
+ function withIconImages(look, files, uris = {}, folderRead = files.length > 0) {
12689
+ const images = new Map(look.images);
12690
+ for (const [k, v] of Object.entries(uris)) if (images.size < MAX_ICON_FILES && /^[a-z0-9-]{1,80}$/.test(k) && isIconUri(v)) images.set(k, v);
12691
+ for (const f of [...files].sort((a, b) => a.name.localeCompare(b.name))) {
12692
+ const name2 = iconName(f.name), uri = name2 && name2.length <= 80 ? svgDataUri(f.bytes) : null;
12693
+ if (uri && images.size < MAX_ICON_FILES && !images.has(name2)) images.set(name2, uri);
12694
+ }
12695
+ return { ...look, images, iconFolderRead: look.iconFolderRead || folderRead };
12696
+ }
12697
+ function usedIconImages(look, names) {
12698
+ const out = {};
12699
+ for (const n of names) {
12700
+ const u = look.images.get(n);
12701
+ if (u) out[n] = u;
12702
+ }
12703
+ return out;
12704
+ }
12705
+ function iconStandIn(look, name2) {
12706
+ if (!name2 || name2 === "none" || look.images.has(name2) || look.icons.has(name2)) return null;
12707
+ return (look.iconDirs.length || look.iconUrls.size) && !look.iconFolderRead && extendedIconsLoaded() ? standInIcon(name2) : null;
12708
+ }
12709
+ var iconSources = (look, name2) => look.iconUrls.get(name2) ?? look.iconDirs.join(", ");
12710
+
12682
12711
  // src/iconStyle.ts
12683
12712
  var isBuiltIn = (look, name2) => !look.images.has(name2) && !!ICONS[name2] && look.icons.get(name2) === ICONS[name2];
12684
12713
  function weightFor(width) {
@@ -12735,7 +12764,7 @@ var LANES = [CLEAR, CLEAR + 12, CLEAR + 24];
12735
12764
  function routeAround(P0, d0, P1, d1, obstacles, taken = []) {
12736
12765
  const S = d0 ? { x: P0.x + d0.x * STUB, y: P0.y + d0.y * STUB } : P0;
12737
12766
  const E = d1 ? { x: P1.x + d1.x * STUB, y: P1.y + d1.y * STUB } : P1;
12738
- const uniq = (v) => [...new Set(v.map((n) => Math.round(n)))].sort((a, b) => a - b);
12767
+ const uniq = (v) => [...new Set(v.map((n) => Math.round(n)))].sort(byNumber);
12739
12768
  const xs = uniq([S.x, E.x, ...obstacles.flatMap((o) => LANES.flatMap((l) => [o.x - l, o.x + o.w + l]))]);
12740
12769
  const ys = uniq([S.y, E.y, ...obstacles.flatMap((o) => LANES.flatMap((l) => [o.y - l, o.y + o.h + l]))]);
12741
12770
  const W = xs.length, H = ys.length;
@@ -12841,15 +12870,35 @@ var FONT_WIDTHS = {
12841
12870
  "instrument serif": {
12842
12871
  400: [17, 24, 37, 64, 42, 59, 58, 23, 34, 34, 44, 53, 22, 43, 21, 26, 46, 25, 40, 37, 39, 38, 40, 36, 43, 40, 21, 22, 53, 53, 53, 32, 66, 46, 48, 48, 53, 45, 41, 52, 55, 25, 25, 50, 41, 67, 54, 54, 47, 54, 51, 41, 46, 54, 46, 65, 55, 48, 43, 33, 26, 33, 43, 38, 35, 40, 44, 34, 46, 36, 29, 40, 47, 22, 22, 45, 22, 70, 47, 41, 44, 44, 32, 31, 26, 45, 39, 60, 39, 40, 35, 32, 25, 32, 53, 11, 51, 72, 53, -1, -1, -1, -1, 30, 53, 17, 17, 32, 32]
12843
12872
  },
12873
+ "libre caslon display": {
12874
+ 400: [24, 24, 26, 60, 52, 58, 83, 17, 27, 27, 41, 45, 23, 36, 23, 33, 62, 34, 51, 52, 51, 50, 51, 43, 53, 51, 23, 25, 42, 48, 42, 36, 75, 66, 62, 68, 70, 61, 55, 70, 73, 32, 33, 66, 58, 87, 73, 73, 57, 73, 61, 55, 67, 67, 66, 95, 72, 61, 59, 31, 33, 31, 36, 40, 19, 39, 47, 41, 47, 42, 26, 40, 45, 23, 22, 46, 22, 65, 46, 48, 47, 47, 32, 34, 27, 44, 45, 62, 46, 45, 39, 31, 21, 31, 44, 23, 50, 68, 66, -1, -1, -1, -1, 32, 47, 19, 19, 30, 30]
12875
+ },
12844
12876
  "sketch hand": {
12845
12877
  400: [50, 30, 33, 80, 80, 94, 72, 27, 42, 34, 52, 63, 26, 41, 27, 50, 69, 27, 71, 68, 64, 62, 64, 54, 77, 61, 24, 26, 61, 62, 49, 47, 81, 66, 73, 64, 78, 67, 57, 79, 55, 55, 63, 61, 60, 77, 64, 73, 66, 71, 68, 61, 80, 71, 52, 75, 60, 52, 80, 49, 50, 50, 54, 83, 44, 67, 51, 50, 57, 55, 49, 50, 49, 22, 33, 49, 26, 63, 47, 55, 49, 55, 43, 54, 56, 57, 52, 61, 56, 47, 57, 57, 17, 50, 84, 31, 69, 91, 68, 87, 92, -1, -1, 32, 45, 41, 49, 49, 51]
12846
12878
  }
12847
12879
  };
12848
12880
 
12849
12881
  // src/scene.ts
12882
+ function wrapLines(text, w, measure) {
12883
+ const out = [];
12884
+ for (const line of text.split("\n")) {
12885
+ const words = line.split(" ");
12886
+ let cur = words[0];
12887
+ for (const word of words.slice(1)) {
12888
+ const next = cur + " " + word;
12889
+ if (measure(next) <= w) cur = next;
12890
+ else {
12891
+ out.push(cur);
12892
+ cur = word;
12893
+ }
12894
+ }
12895
+ out.push(cur);
12896
+ }
12897
+ return out;
12898
+ }
12850
12899
  var SERIES = ["bars", "line", "area", "dots"];
12851
- var CANVAS_KEYS = ["paper", "dots", "dotgap"];
12852
- var MARKERS = ["none", "arrow", "open", "triangle", "diamond", "diamond-solid", "dot", "circle", "stop", "one", "only-one", "many", "one-many", "zero-one", "zero-many"];
12900
+ var CANVAS_KEYS = ["paper", "dots", "dotgap", "grid", "gridgap", "lines", "linegap", "cross", "crossgap", "iso", "isogap", "bars", "bargap", "diag", "diaggap", "graph", "graphgap", "hex", "hexgap"];
12901
+ var MARKERS = ["none", "arrow", "open", "stealth", "double", "half", "triangle", "diamond", "diamond-solid", "square", "square-solid", "dot", "circle", "bar", "cross", "stop", "one", "only-one", "many", "one-many", "zero-one", "zero-many"];
12853
12902
  var DIRS = { top: { x: 0, y: -1 }, bottom: { x: 0, y: 1 }, left: { x: -1, y: 0 }, right: { x: 1, y: 0 } };
12854
12903
  var num = (v, d) => v === void 0 || v === "" || isNaN(+v) ? d : +v;
12855
12904
  function textWidth(text, size, font, weight, spacing) {
@@ -12876,6 +12925,29 @@ function measureText(look, text, size, role, weight, spacing) {
12876
12925
  var cx = (b) => b.x + b.w / 2;
12877
12926
  var cy = (b) => b.y + b.h / 2;
12878
12927
  var within = (v, lo, hi) => v >= lo && v <= hi;
12928
+ function turnOf(p) {
12929
+ const r = num(p.rotate, 0) % 360;
12930
+ return Number.isFinite(r) && r !== 0 ? r : 0;
12931
+ }
12932
+ function cosSin(deg) {
12933
+ if (deg % 90 === 0) return [[1, 0], [0, 1], [-1, 0], [0, -1]][(deg / 90 % 4 + 4) % 4];
12934
+ const a = deg * Math.PI / 180;
12935
+ return [Math.cos(a), Math.sin(a)];
12936
+ }
12937
+ function turnPt(p, c, deg) {
12938
+ const [co, si] = cosSin(deg), dx = p.x - c.x, dy = p.y - c.y;
12939
+ return { x: c.x + dx * co - dy * si, y: c.y + dx * si + dy * co };
12940
+ }
12941
+ function turnedBox(b, c, deg) {
12942
+ const q = [{ x: b.x, y: b.y }, { x: b.x + b.w, y: b.y }, { x: b.x, y: b.y + b.h }, { x: b.x + b.w, y: b.y + b.h }].map((p) => turnPt(p, c, deg));
12943
+ const x0 = Math.min(...q.map((p) => p.x)), y0 = Math.min(...q.map((p) => p.y));
12944
+ return { x: x0, y: y0, w: Math.max(...q.map((p) => p.x)) - x0, h: Math.max(...q.map((p) => p.y)) - y0 };
12945
+ }
12946
+ var mid = (b) => ({ x: cx(b), y: cy(b) });
12947
+ function footprint(s) {
12948
+ const t = turnOf(s.p);
12949
+ return t ? turnedBox(s, mid(s), t) : s;
12950
+ }
12879
12951
  function autoSides(A, B) {
12880
12952
  if (within(cx(A), B.x, B.x + B.w) || within(cx(B), A.x, A.x + A.w)) return cy(A) <= cy(B) ? ["bottom", "top"] : ["top", "bottom"];
12881
12953
  if (within(cy(A), B.y, B.y + B.h) || within(cy(B), A.y, A.y + A.h)) return cx(A) <= cx(B) ? ["right", "left"] : ["left", "right"];
@@ -13128,19 +13200,19 @@ function withLook(src, look) {
13128
13200
  });
13129
13201
  return lines.join("\n");
13130
13202
  }
13131
- function buildScene(src, lookIn, file = "") {
13203
+ function buildScene(src, lookIn, file = "", drawIn) {
13132
13204
  const issues = [];
13133
13205
  const err = (line, msg) => issues.push({ line, level: "error", msg });
13134
13206
  const warn = (line, msg) => issues.push({ line, level: "warn", msg });
13135
13207
  const stmts = parseStatements(src);
13136
13208
  const lookStmt = stmts.find((s) => s.toks[0]?.v === "look" && s.toks[0].t === "word");
13137
13209
  const named = bundledLook(lookStmt?.toks[1]?.v ?? "");
13138
- let look = named ?? lookIn ?? (lookStmt ? emptyLook() : defaultLook());
13210
+ let look = drawIn ?? named ?? lookIn ?? (lookStmt ? emptyLook() : defaultLook());
13139
13211
  const baseCanvas = look.canvas;
13140
- if (lookStmt) {
13212
+ if (lookStmt && !drawIn) {
13141
13213
  const p = lookStmt.toks[1]?.v;
13142
13214
  if (!p) err(lookStmt.line, `look needs a name or a path, e.g. look sketch or look "./team.look" (named looks: ${BUNDLED_LOOK_NAMES.join(", ")})`);
13143
- else if (!named && !lookIn) err(lookStmt.line, /[\\/]|\.look$/i.test(p) ? `look file not found: ${p}` : `no look named ${p}; named looks: ${BUNDLED_LOOK_NAMES.join(", ")}, or give a path to a .look file`);
13215
+ else if (!named && !lookIn) err(lookStmt.line, isWebLook(p) ? `the look at ${p} could not be fetched` : movedLookUrl(p) ? `the ${p} look no longer ships with FastDraw; it is in ${LOOKS_REPO} on GitHub: look "${movedLookUrl(p)}"` : /[\\/]|\.look$/i.test(p) ? `look file not found: ${p}` : `no look named ${p}; named looks: ${BUNDLED_LOOK_NAMES.join(", ")}, or give a path to a .look file`);
13144
13216
  else for (const i of look.issues) issues.push({ ...i, line: lookStmt.line, msg: `${i.msg} (in look, line ${i.line})` });
13145
13217
  }
13146
13218
  const shapes = [], texts = [], conns = [];
@@ -13204,6 +13276,7 @@ function buildScene(src, lookIn, file = "") {
13204
13276
  }
13205
13277
  const p2 = { ...style2.props, ...over3 };
13206
13278
  if (p2.route && !["ortho", "straight", "curve"].includes(p2.route)) err(st.line, `route=${p2.route} is not a route; use ortho, straight or curve`);
13279
+ if (over3.rotate !== void 0) warn(st.line, "rotate= does nothing on a line; it follows the things it joins");
13207
13280
  const styleHead = style2.props.head && style2.props.head !== "none" ? style2.props.head : "arrow";
13208
13281
  const plain = style2.props.head === "none" && styleName2 !== "line";
13209
13282
  const headM = over3.head ?? (op === "--" || plain ? "none" : styleHead);
@@ -13286,17 +13359,32 @@ function buildScene(src, lookIn, file = "") {
13286
13359
  continue;
13287
13360
  }
13288
13361
  const fs = num(p.size, 12);
13289
- const lines = (text ?? "").split("\n");
13362
+ let lines = (text ?? "").split("\n");
13290
13363
  const t2 = p.caps === "1" ? (text ?? "").toUpperCase() : text ?? "";
13291
- const w = Math.max(...lines.map((l) => textWidth(l, fs, p.font ?? "sans", num(p.weight, 400), num(p.spacing, 0))));
13292
- const anchor = p.anchor ?? "start";
13364
+ const measure = (l) => textWidth(l, fs, p.font ?? "sans", num(p.weight, 400), num(p.spacing, 0));
13365
+ let w = Math.max(...lines.map(measure));
13366
+ const box = num(p.width, 0) > 0 ? num(p.width, 0) : 0;
13367
+ let wrapped;
13368
+ if (p.width !== void 0 && !box) err(st.line, `width=${p.width}: a text box's width is a number of pixels, e.g. width=240`);
13369
+ if (p.align !== void 0 && !["left", "center", "right"].includes(p.align)) err(st.line, `align=${p.align}: a text lines up left, center or right`);
13370
+ const drawn = (l) => measureText(look, l, fs, p.font ?? "sans", num(p.weight, 400), num(p.spacing, 0));
13371
+ if (box) {
13372
+ wrapped = wrapLines(t2, box, drawn);
13373
+ lines = wrapped;
13374
+ w = box;
13375
+ } else if (p.align !== void 0 && p.align !== "left") warn(st.line, `align= lines a text up inside its box; give it a width (width=240), or move its at point with anchor=${p.align === "center" ? "middle" : "end"}`);
13376
+ if (box && p.anchor !== void 0 && p.anchor !== "start") warn(st.line, `anchor= does nothing on a text box (width=): its at point is the left end; use align=${p.anchor === "middle" ? "center" : "right"}`);
13377
+ const anchor = box ? "start" : p.anchor ?? "start";
13293
13378
  const x = anchor === "middle" ? at.x - w / 2 : anchor === "end" ? at.x - w : at.x;
13294
13379
  const th = fs * 1.3 * lines.length;
13380
+ if (p.rotate !== void 0 && !isFinite(+p.rotate)) err(st.line, `rotate=${p.rotate}: an angle in degrees, turning clockwise (rotate=-90 reads upwards)`);
13295
13381
  const rot = num(p.rotate, 0);
13296
- if (p.rotate !== void 0 && ![0, 90, -90].includes(rot)) err(st.line, `rotate=${p.rotate}: text can be turned by 90 (reading down) or -90 (reading up)`);
13297
13382
  const dx = x - at.x;
13298
- const box = rot === -90 ? { x: at.x - fs, y: at.y - dx - w, w: th, h: w } : rot === 90 ? { x: at.x - th + fs, y: at.y + dx, w: th, h: w } : { x, y: at.y - fs, w, h: th };
13299
- texts.push({ id: register("text", "t"), line: st.line, style: styleName, p, text: t2, ax: at.x, ay: at.y, ...box });
13383
+ if (p.dy !== void 0 && !isFinite(+p.dy)) err(st.line, `dy=${p.dy}: how many pixels lower the text is drawn, e.g. dy=6`);
13384
+ const drop = num(p.dy, 0);
13385
+ const flat = { x, y: at.y - fs + drop, w, h: th };
13386
+ const bx = rot === -90 ? { x: at.x - fs + drop, y: at.y - dx - w, w: th, h: w } : rot === 90 ? { x: at.x - th + fs - drop, y: at.y + dx, w: th, h: w } : turnOf(p) ? turnedBox(flat, at, turnOf(p)) : flat;
13387
+ texts.push({ id: register("text", "t"), line: st.line, style: styleName, p, text: t2, ax: at.x, ay: at.y, ...bx, ...wrapped ? { lines: wrapped } : {}, ...turnOf(p) ? { frame: flat } : {} });
13300
13388
  continue;
13301
13389
  }
13302
13390
  if (!size && p.size) {
@@ -13318,8 +13406,12 @@ function buildScene(src, lookIn, file = "") {
13318
13406
  w: size.w,
13319
13407
  h: size.h
13320
13408
  };
13321
- if (p.icon && p.icon !== "none" && !look.icons.has(p.icon) && !look.images.has(p.icon)) {
13322
- const all = [...look.images.keys(), ...look.icons.keys()];
13409
+ const standIn = iconStandIn(look, p.icon);
13410
+ if (standIn) warn(st.line, `icon ${p.icon} is one of the look's icon files (${iconSources(look, p.icon)}), which could not be loaded here, so the built-in icon ${standIn} is drawn in its place`);
13411
+ else if (p.icon && p.icon !== "none" && !look.icons.has(p.icon) && !look.images.has(p.icon)) {
13412
+ const every = [...look.images.keys(), ...look.icons.keys()];
13413
+ const own = look.hideBuiltIns ? [...new Set(every.filter((n) => !isBuiltIn(look, n)))] : [];
13414
+ const all = own.length ? own : every;
13323
13415
  const near = all.filter((n) => iconMatches(n, p.icon) || n.length > 2 && p.icon.includes(n)), list2 = [.../* @__PURE__ */ new Set([...near, ...all])].slice(0, 40);
13324
13416
  const folder = look.iconDirs.length && !look.images.size ? ` (the look's icon folder ${look.iconDirs.join(", ")} could not be read here)` : "";
13325
13417
  err(st.line, `there is no icon called "${p.icon}"${folder}; the look has: ${list2.join(", ")}${all.length > list2.length ? `, and ${all.length - list2.length} more (run "fastdraw icons" to see them all)` : ""}`);
@@ -13327,7 +13419,8 @@ function buildScene(src, lookIn, file = "") {
13327
13419
  if (p["icon.width"] !== void 0 && !(Number(p["icon.width"]) > 0 && Number(p["icon.width"]) <= 8)) err(st.line, `icon.width=${p["icon.width"]}: the icon's line thickness in pixels, a number from 0.5 to 8 (e.g. icon.width=2)`);
13328
13420
  if (p["icon.style"] !== void 0 && !["outline", "solid", "duotone"].includes(p["icon.style"])) err(st.line, `icon.style=${p["icon.style"]}: an icon is drawn as an outline (the default), filled in one colour (icon.style=solid), or as an outline over a light tint (icon.style=duotone)`);
13329
13421
  else if ((p["icon.style"] === "solid" || p["icon.style"] === "duotone") && p.icon && p.icon !== "none" && (look.icons.has(p.icon) || look.images.has(p.icon)) && !isBuiltIn(look, p.icon)) warn(st.line, `icon ${p.icon} is the look's own, with no ${p["icon.style"]} version (only the built-in icons have one), so it is drawn as it is; drop icon.style=${p["icon.style"]}`);
13330
- if (p["icon.pos"] && !["left", "top"].includes(p["icon.pos"])) err(st.line, `icon.pos=${p["icon.pos"]}: an icon sits left of the text or on top of it (icon.pos=left or icon.pos=top)`);
13422
+ if (p["icon.pos"] && !["left", "top", "corner"].includes(p["icon.pos"])) err(st.line, `icon.pos=${p["icon.pos"]}: an icon sits left of the text, on top of it, or in the top-left corner as a tab (icon.pos=left, icon.pos=top or icon.pos=corner)`);
13423
+ if (p.rotate !== void 0 && !isFinite(+p.rotate)) err(st.line, `rotate=${p.rotate}: an angle in degrees; the shape turns clockwise about its middle (e.g. rotate=45)`);
13331
13424
  for (const k of ["color", "weight", "font", "italic"]) if (over2[k] !== void 0) warn(st.line, `${k}= does nothing on a shape; its text is set with title.${k}= (and sub.${k}= for the second line)`);
13332
13425
  if (sh.shape === "polygon") {
13333
13426
  const rel = (p.points ?? "").split(";").filter(Boolean).map((q) => {
@@ -13438,6 +13531,7 @@ function buildScene(src, lookIn, file = "") {
13438
13531
  }
13439
13532
  const shapeById = /* @__PURE__ */ new Map();
13440
13533
  for (const s of shapes) shapeById.set(s.id, s);
13534
+ const turnById = new Map(shapes.filter((s) => turnOf(s.p)).map((s) => [s.id, turnOf(s.p)]));
13441
13535
  for (const t of texts) shapeById.set(t.id, { x: t.x - 4, y: t.y - 2, w: t.w + 8, h: t.h + 4 });
13442
13536
  const connById = new Map(conns.map((c) => [c.id, c]));
13443
13537
  const rowsById = new Map(shapes.filter((s) => s.rows).map((s) => [s.id, s.rows]));
@@ -13447,6 +13541,20 @@ function buildScene(src, lookIn, file = "") {
13447
13541
  return r ? { x: S.x, y: r.y, w: S.w, h: r.h } : S;
13448
13542
  };
13449
13543
  const sideKey = (e) => `${e.id}${e.row ? "." + e.row : ""}|${e.side}`;
13544
+ const turnAt = (e) => {
13545
+ const deg = e.kind === "shape" ? turnById.get(e.id) : void 0;
13546
+ return deg ? { c: mid(shapeById.get(e.id)), deg } : null;
13547
+ };
13548
+ const turnBack = (e, r) => {
13549
+ const t = turnAt(e);
13550
+ return t ? turnPt(r, { x: 0, y: 0 }, -t.deg) : r;
13551
+ };
13552
+ const seenFrom = (e, b) => {
13553
+ const t = turnAt(e);
13554
+ if (!t || !b) return b;
13555
+ const m = turnPt(mid(b), t.c, -t.deg);
13556
+ return { x: m.x - b.w / 2, y: m.y - b.h / 2, w: b.w, h: b.h };
13557
+ };
13450
13558
  const done = /* @__PURE__ */ new Set();
13451
13559
  const bad = /* @__PURE__ */ new Set();
13452
13560
  for (const c of conns) for (const e of [c.a, c.b]) {
@@ -13491,12 +13599,13 @@ function buildScene(src, lookIn, file = "") {
13491
13599
  const relSide = (r) => Math.abs(r.y) >= Math.abs(r.x) ? r.y >= 0 ? "bottom" : "top" : r.x >= 0 ? "right" : "left";
13492
13600
  const rowSide = (me, other, rel) => (other ? cx(other) >= cx(me) : rel.x >= 0) ? "right" : "left";
13493
13601
  if (c.a.kind === "shape" && !c.a.side) {
13494
- c.a.side = c.a.row ? rowSide(ba, bb, c.b.rel ?? { x: 0, y: 0 }) : bb ? autoSides(ba, bb)[0] : relSide(c.b.rel);
13602
+ const ob = seenFrom(c.a, bb), rel = c.b.rel && turnBack(c.a, c.b.rel);
13603
+ c.a.side = c.a.row ? rowSide(ba, ob, rel ?? { x: 0, y: 0 }) : ob ? autoSides(ba, ob)[0] : relSide(rel);
13495
13604
  c.a.fanned = true;
13496
13605
  }
13497
13606
  if (c.b.kind === "shape" && !c.b.side) {
13498
- const back = c.a.rel ? { x: -c.a.rel.x, y: -c.a.rel.y } : { x: 0, y: 0 };
13499
- c.b.side = c.b.row ? rowSide(bb, ba, back) : ba ? autoSides(ba, bb)[1] : relSide(back);
13607
+ const back = turnBack(c.b, c.a.rel ? { x: -c.a.rel.x, y: -c.a.rel.y } : { x: 0, y: 0 }), ob = seenFrom(c.b, ba);
13608
+ c.b.side = c.b.row ? rowSide(bb, ob, back) : ob ? autoSides(ob, bb)[1] : relSide(back);
13500
13609
  c.b.fanned = true;
13501
13610
  }
13502
13611
  }
@@ -13511,8 +13620,8 @@ function buildScene(src, lookIn, file = "") {
13511
13620
  const single = /* @__PURE__ */ new Set();
13512
13621
  for (const [k, g] of groups) {
13513
13622
  const horiz = k.endsWith("top") || k.endsWith("bottom");
13514
- const ref = (o) => {
13515
- const b = boxOf(o);
13623
+ const ref = (e, o) => {
13624
+ const b = seenFrom(e, boxOf(o));
13516
13625
  return b ? horiz ? cx(b) : cy(b) : 0;
13517
13626
  };
13518
13627
  if (g.length === 1) {
@@ -13520,7 +13629,7 @@ function buildScene(src, lookIn, file = "") {
13520
13629
  single.add(g[0].e);
13521
13630
  continue;
13522
13631
  }
13523
- const order = g.map((m, idx) => ({ m, idx, r: ref(m.o) })).sort((p, q) => p.r - q.r || p.idx - q.idx);
13632
+ const order = g.map((m, idx) => ({ m, idx, r: ref(m.e, m.o) })).sort((p, q) => byNumber(p.r, q.r) || p.idx - q.idx);
13524
13633
  order.forEach((o, n) => frac.set(o.m.e, (n + 1) / (g.length + 1)));
13525
13634
  }
13526
13635
  for (const c of batch) {
@@ -13534,11 +13643,18 @@ function buildScene(src, lookIn, file = "") {
13534
13643
  const lo = horiz ? S.x : S.y, hi = horiz ? S.x + S.w : S.y + S.h;
13535
13644
  if (e.v < lo || e.v > hi) warn(c.line, `${e.raw}: ${e.v} is outside the ${e.side} side of ${e.id}, which runs from ${lo} to ${hi}; the end was moved to the nearest point`);
13536
13645
  }
13646
+ const t = turnAt(e);
13647
+ if (t) {
13648
+ const q = turnPt(e.pt, t.c, t.deg), d = turnPt(e.dir, { x: 0, y: 0 }, t.deg);
13649
+ e.pt = { x: Math.round(q.x), y: Math.round(q.y) };
13650
+ const ax = Math.abs(Math.round(d.x * 1e6)), ay = Math.abs(Math.round(d.y * 1e6));
13651
+ e.dir = !c.ortho ? d : ax >= ay ? { x: Math.sign(d.x), y: 0 } : { x: 0, y: Math.sign(d.y) };
13652
+ }
13537
13653
  }
13538
13654
  }
13539
13655
  const a = c.a, b = c.b;
13540
13656
  const opposing = a.dir && b.dir && a.dir.x === -b.dir.x && a.dir.y === -b.dir.y;
13541
- if (a.kind === "shape" && b.kind === "shape" && opposing) {
13657
+ if (a.kind === "shape" && b.kind === "shape" && opposing && !turnAt(a) && !turnAt(b)) {
13542
13658
  const A = tgt(a), B = tgt(b);
13543
13659
  const horiz = a.side === "top" || a.side === "bottom";
13544
13660
  const lo = horiz ? Math.max(A.x, B.x) : Math.max(A.y, B.y);
@@ -13562,7 +13678,7 @@ function buildScene(src, lookIn, file = "") {
13562
13678
  }
13563
13679
  }
13564
13680
  for (const [e, o] of [[a, b], [b, a]]) {
13565
- if (e.kind !== "shape" || !single.has(e) || o.kind !== "point" && o.kind !== "conn") continue;
13681
+ if (e.kind !== "shape" || !single.has(e) || o.kind !== "point" && o.kind !== "conn" || turnAt(e)) continue;
13566
13682
  const S = tgt(e);
13567
13683
  const horiz = e.side === "top" || e.side === "bottom";
13568
13684
  const pos = horiz ? o.pt.x : o.pt.y;
@@ -13585,9 +13701,9 @@ function buildScene(src, lookIn, file = "") {
13585
13701
  c.pts = c.curve ? curvePts(a.pt, a.dir, b.pt, b.dir, via, num(c.p.bend, NaN)) : route(c, via);
13586
13702
  if (c.ortho && !via.length && !c.ushape) {
13587
13703
  const strictlyIn = (o, p) => p.x > o.x + 1 && p.x < o.x + o.w - 1 && p.y > o.y + 1 && p.y < o.y + o.h - 1;
13588
- const obs = shapes.filter((o) => !o.back && o.shape !== "legend" && !(o.poly && o.p.open === "1") && Math.min(o.w, o.h) > 12 && !strictlyIn(o, a.pt) && !strictlyIn(o, b.pt));
13704
+ const obs = shapes.filter((o) => !o.back && o.shape !== "legend" && !(o.poly && o.p.open === "1") && Math.min(o.w, o.h) > 12 && !strictlyIn(footprint(o), a.pt) && !strictlyIn(footprint(o), b.pt)).map(footprint);
13589
13705
  for (const o of shapes) {
13590
- const cb = o.id !== c.a.id && o.id !== c.b.id ? captionBox(o) : null;
13706
+ const cb = o.id !== c.a.id && o.id !== c.b.id ? captionFootprint(o) : null;
13591
13707
  if (cb) obs.push({ x: cb.x - 4, y: cb.y - 2, w: cb.w + 8, h: cb.h + 4 });
13592
13708
  }
13593
13709
  if (crosses(c.pts, obs)) {
@@ -13596,7 +13712,7 @@ function buildScene(src, lookIn, file = "") {
13596
13712
  }
13597
13713
  }
13598
13714
  if (c.ortho) for (let i = 0; i < c.pts.length - 1; i++) taken.push([c.pts[i], c.pts[i + 1]]);
13599
- c.label = makeLabel(c, shapes.filter((o) => !o.back && o.shape !== "legend"));
13715
+ c.label = makeLabel(c, shapes.filter((o) => !o.back && o.shape !== "legend").map(footprint));
13600
13716
  done.add(c);
13601
13717
  }
13602
13718
  };
@@ -13612,7 +13728,7 @@ function buildScene(src, lookIn, file = "") {
13612
13728
  }
13613
13729
  resolvePass(second.filter((c) => !bad.has(c)));
13614
13730
  const finalConns = conns.filter((c) => done.has(c));
13615
- const ext = extent([...shapes, ...shapes.map(captionBox).filter((b) => !!b)], texts, finalConns);
13731
+ const ext = extent([...shapes.map(footprint), ...shapes.map(captionFootprint).filter((b) => !!b)], texts, finalConns);
13616
13732
  return { file, ...ext, look, canvasLine, canvasSize, baseCanvas, shapes, texts, conns: finalConns, issues };
13617
13733
  }
13618
13734
  var ICON_CAPTION_GAP = 6;
@@ -13624,6 +13740,10 @@ function captionBox(s) {
13624
13740
  const h = lines.length * Math.round(size * 1.17) + (subs.length ? 2 + subs.length * Math.round(sub * 1.3) : 0);
13625
13741
  return { x: s.x + s.w / 2 - w / 2, y: s.y + s.h + ICON_CAPTION_GAP, w, h };
13626
13742
  }
13743
+ function captionFootprint(s) {
13744
+ const b = captionBox(s), t = turnOf(s.p);
13745
+ return b && t ? turnedBox(b, mid(s), t) : b;
13746
+ }
13627
13747
  var MARGIN = 40;
13628
13748
  function extent(shapes, texts, conns) {
13629
13749
  const boxes = [...shapes, ...texts, ...conns.flatMap((c) => [...c.pts.map((p) => ({ x: p.x, y: p.y, w: 0, h: 0 })), ...c.label ? [c.label] : []])];
@@ -13634,41 +13754,174 @@ function extent(shapes, texts, conns) {
13634
13754
  return { x, y, w: Math.ceil((x1 + MARGIN) / 4) * 4 - x, h: Math.ceil((y1 + MARGIN) / 4) * 4 - y };
13635
13755
  }
13636
13756
 
13637
- // src/iconfiles.ts
13638
- var MAX_ICON_BYTES = 3e5;
13639
- var MAX_ICON_FILES = 3e3;
13640
- var URI = /^data:image\/svg\+xml;base64,[A-Za-z0-9+/]+=*$/;
13641
- var isIconUri = (v) => typeof v === "string" && v.length < MAX_ICON_BYTES * 1.4 && URI.test(v);
13642
- function iconName(file) {
13643
- return file.replace(/\.svg$/i, "").toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^\d+-icon-service-/, "").replace(/^-+|-+$/g, "");
13757
+ // src/webassets.ts
13758
+ var MAX_FONT_BYTES = 5e6;
13759
+ var MAX_WEB_ICONS = 300;
13760
+ var hasWebIcons = (look) => look.iconUrls.size > 0 || look.iconDirs.some(isWebUrl);
13761
+ var localIconDirs = (look) => look.iconDirs.filter((d) => !isWebUrl(d));
13762
+ function iconAddresses(look, name2) {
13763
+ const out = [];
13764
+ const own = look.iconUrls.get(name2);
13765
+ if (own) out.push(own);
13766
+ for (const d of look.iconDirs) {
13767
+ if (!isWebUrl(d)) continue;
13768
+ out.push(d.includes("{name}") ? d.replaceAll("{name}", name2) : `${d.replace(/\/+$/, "")}/${name2}.svg`);
13769
+ }
13770
+ return out;
13644
13771
  }
13645
- function svgDataUri(bytes) {
13646
- if (bytes.length === 0 || bytes.length > MAX_ICON_BYTES) return null;
13647
- const head = new TextDecoder().decode(bytes.subarray(0, 2e3));
13648
- if (!/<svg[\s>]/i.test(head)) return null;
13649
- let bin = "";
13650
- for (let i = 0; i < bytes.length; i += 32768) bin += String.fromCharCode(...bytes.subarray(i, i + 32768));
13651
- return "data:image/svg+xml;base64," + btoa(bin);
13772
+ function isPrivateHost(host) {
13773
+ const h = host.toLowerCase().replace(/^\[|\]$/g, "").replace(/\.+$/, "");
13774
+ if (h === "localhost" || h.endsWith(".localhost") || h.endsWith(".local") || h.endsWith(".internal") || !h.includes(".") && !h.includes(":")) return true;
13775
+ const v4 = /^(\d+)\.(\d+)\.(\d+)\.(\d+)$/.exec(h);
13776
+ if (v4) {
13777
+ const [a, b] = [Number(v4[1]), Number(v4[2])];
13778
+ return a === 0 || a === 10 || a === 127 || a === 169 && b === 254 || a === 172 && b >= 16 && b <= 31 || a === 192 && b === 168 || a === 100 && b >= 64 && b <= 127 || a >= 224;
13779
+ }
13780
+ return h.includes(":") && (h === "::" || h === "::1" || /^f[cd]/.test(h) || /^fe[89ab]/.test(h) || h.startsWith("::ffff:") || /^::[0-9a-f.:]*$/.test(h) || h.startsWith("64:ff9b:"));
13652
13781
  }
13653
- function withIconImages(look, files, uris = {}) {
13654
- const images = new Map(look.images);
13655
- for (const [k, v] of Object.entries(uris)) if (images.size < MAX_ICON_FILES && /^[a-z0-9-]{1,80}$/.test(k) && isIconUri(v)) images.set(k, v);
13656
- for (const f of [...files].sort((a, b) => a.name.localeCompare(b.name))) {
13657
- const name2 = iconName(f.name), uri = name2 && name2.length <= 80 ? svgDataUri(f.bytes) : null;
13658
- if (uri && images.size < MAX_ICON_FILES && !images.has(name2)) images.set(name2, uri);
13782
+ function isPublicWebUrl(url) {
13783
+ try {
13784
+ const u = new URL(url);
13785
+ return u.protocol === "https:" && !isPrivateHost(u.hostname);
13786
+ } catch {
13787
+ return false;
13659
13788
  }
13660
- return { ...look, images };
13661
13789
  }
13662
- function usedIconImages(look, names) {
13663
- const out = {};
13664
- for (const n of names) {
13665
- const u = look.images.get(n);
13666
- if (u) out[n] = u;
13790
+ var webFetch = async (url, maxBytes) => {
13791
+ if (!isPublicWebUrl(url)) throw new Error("not a public https address");
13792
+ const u = new URL(url);
13793
+ const r = await fetch(u, { credentials: "omit", referrerPolicy: "no-referrer", redirect: "error", signal: AbortSignal.timeout(15e3) });
13794
+ if (r.status === 404 || r.status === 410) return null;
13795
+ if (!r.ok) throw new Error(`${r.status} ${r.statusText}`.trim());
13796
+ if (Number(r.headers.get("content-length")) > maxBytes) throw new Error("file too large");
13797
+ const chunks = [];
13798
+ let total = 0;
13799
+ const reader = r.body.getReader();
13800
+ for (; ; ) {
13801
+ const { done, value } = await reader.read();
13802
+ if (done) break;
13803
+ total += value.length;
13804
+ if (total > maxBytes) {
13805
+ await reader.cancel();
13806
+ throw new Error("file too large");
13807
+ }
13808
+ chunks.push(value);
13809
+ }
13810
+ const bytes = new Uint8Array(total);
13811
+ let at = 0;
13812
+ for (const c of chunks) {
13813
+ bytes.set(c, at);
13814
+ at += c.length;
13815
+ }
13816
+ return bytes;
13817
+ };
13818
+ var caches = /* @__PURE__ */ new WeakMap();
13819
+ function cached(get, url, maxBytes) {
13820
+ let cache = caches.get(get);
13821
+ if (!cache) caches.set(get, cache = /* @__PURE__ */ new Map());
13822
+ let p = cache.get(url);
13823
+ if (!p) {
13824
+ p = get(url, maxBytes);
13825
+ cache.set(url, p);
13826
+ p.catch(() => cache.delete(url));
13827
+ }
13828
+ return p;
13829
+ }
13830
+ var MAX_LOOK_BYTES = 1e6;
13831
+ async function fetchWebLook(url, get = webFetch) {
13832
+ const bytes = await get(url, MAX_LOOK_BYTES);
13833
+ if (!bytes) return null;
13834
+ const text = new TextDecoder().decode(bytes);
13835
+ if (/^\s*</.test(text)) throw new Error('not a look file (it starts with "<")');
13836
+ return text;
13837
+ }
13838
+ var hostOf = (url) => {
13839
+ try {
13840
+ return new URL(url).host;
13841
+ } catch {
13842
+ return "an address in the look";
13843
+ }
13844
+ };
13845
+ function setListing(dir) {
13846
+ const tpl = dir.includes("{name}") ? dir : `${dir.replace(/\/+$/, "")}/{name}.svg`;
13847
+ const m = /^https:\/\/cdn\.jsdelivr\.net\/(npm\/(?:@[^/@{}]+\/)?[^/@{}]+|gh\/[^/@{}]+\/[^/@{}]+)@([^/{}]+)(\/.*)$/i.exec(tpl);
13848
+ if (!m) return null;
13849
+ const parts = m[3].split("{name}"), fixed = parts.join("").length, k = parts.length - 1;
13850
+ if (k > 3) return null;
13851
+ return {
13852
+ url: `https://data.jsdelivr.com/v1/packages/${m[1]}@${m[2]}?structure=flat`,
13853
+ nameOf: (path) => {
13854
+ const len = (path.length - fixed) / k;
13855
+ if (path.length > 1e3 || !Number.isInteger(len) || len < 1 || len > 80) return null;
13856
+ const name2 = path.slice(parts[0].length, parts[0].length + len);
13857
+ return /^[a-z0-9-]+$/.test(name2) && parts.join(name2) === path ? name2 : null;
13858
+ }
13859
+ };
13860
+ }
13861
+ var MAX_LISTING_BYTES = 2e7;
13862
+ async function listWebIcons(look, get = webFetch) {
13863
+ const out = /* @__PURE__ */ new Set();
13864
+ for (const d of look.iconDirs) {
13865
+ if (!isWebUrl(d)) continue;
13866
+ for (const n of look.iconSetNames.get(d) ?? []) out.add(n);
13867
+ const l = setListing(d);
13868
+ if (!l) continue;
13869
+ try {
13870
+ const bytes = await cached(get, l.url, MAX_LISTING_BYTES);
13871
+ const files = bytes ? JSON.parse(new TextDecoder().decode(bytes)).files : void 0;
13872
+ for (const f of Array.isArray(files) ? files : []) {
13873
+ const n = typeof f?.name === "string" ? l.nameOf(f.name) : null;
13874
+ if (n) out.add(n);
13875
+ }
13876
+ } catch {
13877
+ }
13878
+ }
13879
+ for (const n of look.iconUrls.keys()) out.delete(n);
13880
+ return [...out].sort();
13881
+ }
13882
+ async function fetchWebIcons(look, names, get = webFetch) {
13883
+ const want = [...new Set(names)].filter((n) => /^[a-z0-9-]{1,80}$/.test(n) && !look.images.has(n) && !(look.icons.has(n) && !isBuiltIn(look, n)));
13884
+ const uris = {};
13885
+ const unreachable = /* @__PURE__ */ new Set();
13886
+ await Promise.all(want.slice(0, MAX_WEB_ICONS).map(async (name2) => {
13887
+ for (const url of iconAddresses(look, name2)) {
13888
+ try {
13889
+ const bytes = await cached(get, url, MAX_ICON_BYTES);
13890
+ const uri = bytes && svgDataUri(bytes);
13891
+ if (uri) {
13892
+ uris[name2] = uri;
13893
+ return;
13894
+ }
13895
+ } catch {
13896
+ unreachable.add(hostOf(url));
13897
+ return;
13898
+ }
13899
+ }
13900
+ }));
13901
+ return { uris, done: unreachable.size === 0, unreachable: [...unreachable] };
13902
+ }
13903
+ var WEIGHTS = [400, 500, 600, 700];
13904
+ function webFaces(look) {
13905
+ const out = [];
13906
+ for (const [family, tpl] of look.fontUrls) {
13907
+ if (!/^[\w .-]{1,64}$/.test(family)) continue;
13908
+ const fill = (w, s) => tpl.replaceAll("{weight}", String(w)).replaceAll("{style}", s);
13909
+ const add = (weight, style) => {
13910
+ const url = fill(weight || 400, style);
13911
+ if (isPublicWebUrl(url)) out.push({ family, weight, style, url });
13912
+ };
13913
+ if (!tpl.includes("{weight}")) {
13914
+ add(0, "normal");
13915
+ continue;
13916
+ }
13917
+ for (const w of WEIGHTS) add(w, "normal");
13918
+ if (tpl.includes("{style}")) add(400, "italic");
13667
13919
  }
13668
13920
  return out;
13669
13921
  }
13670
13922
 
13671
13923
  // src/node.ts
13924
+ import { createHash } from "node:crypto";
13672
13925
  import { lstatSync, realpathSync } from "node:fs";
13673
13926
  import { isAbsolute, relative, sep } from "node:path";
13674
13927
  function lookFolder(lookFile, d) {
@@ -13696,7 +13949,7 @@ function plainFiles(dir, ext, maxBytes, maxFiles) {
13696
13949
  }
13697
13950
  function iconFiles(lookFile, look) {
13698
13951
  const out = [];
13699
- for (const d of look.iconDirs) {
13952
+ for (const d of localIconDirs(look)) {
13700
13953
  const dir = lookFolder(lookFile, d);
13701
13954
  if (!dir) {
13702
13955
  look.issues.push({ line: 0, level: "warn", msg: `icon folder not used: ${d} (icondir must be a folder inside the folder that holds the look file)` });
@@ -13706,7 +13959,116 @@ function iconFiles(lookFile, look) {
13706
13959
  }
13707
13960
  return out;
13708
13961
  }
13709
- var withIcons = (lookFile, look) => look.iconDirs.length ? withIconImages(look, iconFiles(lookFile, look)) : look;
13962
+ var webCache = /* @__PURE__ */ new Map();
13963
+ var webFonts = /* @__PURE__ */ new Map();
13964
+ var webLists = /* @__PURE__ */ new Map();
13965
+ var PREVIEW_ICONS = 200;
13966
+ function webCacheDir() {
13967
+ const base = process.env.XDG_CACHE_HOME || (process.platform === "win32" ? process.env.LOCALAPPDATA : void 0) || join(homedir(), ".cache");
13968
+ return join(base, "fastdraw", "web");
13969
+ }
13970
+ function diskFetch(offline) {
13971
+ return async (url, maxBytes) => {
13972
+ const path = cachePath(url);
13973
+ if (existsSync(path)) return new Uint8Array(readFileSync(path));
13974
+ if (offline) throw new Error("offline");
13975
+ const bytes = await webFetch(url, maxBytes);
13976
+ if (bytes) {
13977
+ mkdirSync(dirname(path), { recursive: true });
13978
+ writeFileSync(path, bytes);
13979
+ }
13980
+ return bytes;
13981
+ };
13982
+ }
13983
+ var cachePath = (url) => join(webCacheDir(), createHash("sha256").update(url).digest("hex").slice(0, 32) + (/\.(ttf|otf|svg|look)(?=\?|$)/i.exec(url)?.[0].toLowerCase() ?? ""));
13984
+ async function fetchLookToCache(url, offline) {
13985
+ const path = cachePath(url), had = existsSync(path);
13986
+ if (offline) return had ? void 0 : `${url}: not fetched (--offline) and not fetched before`;
13987
+ try {
13988
+ const text = await fetchWebLook(url);
13989
+ if (text === null) return `there is no look file at ${url}`;
13990
+ mkdirSync(dirname(path), { recursive: true });
13991
+ writeFileSync(path, text);
13992
+ return void 0;
13993
+ } catch (e) {
13994
+ return had ? `${hostOf(url)} could not be reached, so the copy of ${url} fetched before is used` : `the look at ${url} could not be fetched: ${e.message}`;
13995
+ }
13996
+ }
13997
+ var webLookFile = (url) => cachePath(url);
13998
+ var lookFileFor = (file, p) => isWebLook(p) ? cachePath(p) : resolve(dirname(file), p);
13999
+ async function fetchWebAssets(files, offline = false, looks = []) {
14000
+ const get = diskFetch(offline), notes = /* @__PURE__ */ new Set();
14001
+ const webLooks = new Set(looks.filter(isWebLook));
14002
+ const over2 = looks.find((l) => isWebLook(l) || /\.look$/i.test(l));
14003
+ const overPath = over2 && !isWebLook(over2) ? resolve(over2) : over2;
14004
+ for (const file of files) {
14005
+ if (/\.look$/i.test(file) || over2) continue;
14006
+ try {
14007
+ const p = lookPath(readFileSync(file, "utf8"));
14008
+ if (p && isWebLook(p)) webLooks.add(p);
14009
+ } catch {
14010
+ }
14011
+ }
14012
+ for (const url of webLooks) {
14013
+ const n = await fetchLookToCache(url, offline);
14014
+ if (n) notes.add(n);
14015
+ }
14016
+ const wanted = /* @__PURE__ */ new Map();
14017
+ for (const file of files) {
14018
+ if (/\.look$/i.test(file)) {
14019
+ let text;
14020
+ try {
14021
+ text = readFileSync(file, "utf8");
14022
+ } catch {
14023
+ continue;
14024
+ }
14025
+ const look2 = parseLook(text, file);
14026
+ if (!hasWebIcons(look2) && !look2.fontUrls.size) continue;
14027
+ const listed = await listWebIcons(look2, get);
14028
+ webLists.set(resolve(file), listed);
14029
+ wanted.set(resolve(file), { look: look2, names: new Set([...look2.iconUrls.keys(), ...listed].slice(0, PREVIEW_ICONS)) });
14030
+ continue;
14031
+ }
14032
+ let src;
14033
+ try {
14034
+ src = readFileSync(file, "utf8");
14035
+ } catch {
14036
+ continue;
14037
+ }
14038
+ const p = overPath ?? lookPath(src), r = readLook(file, p);
14039
+ if (r.text === null) continue;
14040
+ const lookFile = lookFileFor(file, p), look = parseLook(r.text, p);
14041
+ if (!hasWebIcons(look) && !look.fontUrls.size) continue;
14042
+ const w = wanted.get(lookFile) ?? { look, names: /* @__PURE__ */ new Set() };
14043
+ for (const m of src.matchAll(/\bicon="?([\w-]+)/g)) w.names.add(m[1]);
14044
+ for (const st of look.styles.values()) if (st.props.icon && st.props.icon !== "none") w.names.add(st.props.icon);
14045
+ wanted.set(lookFile, w);
14046
+ }
14047
+ for (const [lookFile, { look, names }] of wanted) {
14048
+ if (hasWebIcons(look)) {
14049
+ const got = await fetchWebIcons(look, names, get);
14050
+ webCache.set(lookFile, got);
14051
+ for (const h of got.unreachable) notes.add(offline ? `${h}: not fetched (--offline) and not fetched before, so the closest built-in icons are drawn instead` : `${h} could not be reached, so the closest built-in icons are drawn instead`);
14052
+ }
14053
+ const fonts = [];
14054
+ for (const f of webFaces(look)) {
14055
+ if (!/\.(ttf|otf)(\?|$)/i.test(f.url)) continue;
14056
+ try {
14057
+ if (await get(f.url, MAX_FONT_BYTES)) fonts.push(cachePath(f.url));
14058
+ } catch {
14059
+ notes.add(`${hostOf(f.url)}: the font ${f.family} could not be fetched, so text is drawn in a fallback font`);
14060
+ }
14061
+ }
14062
+ webFonts.set(lookFile, fonts);
14063
+ }
14064
+ return [...notes];
14065
+ }
14066
+ var withIcons = (lookFile, look) => {
14067
+ if (!look.iconDirs.length && !look.iconUrls.size) return look;
14068
+ const web = webCache.get(resolve(lookFile)), listed = webLists.get(resolve(lookFile));
14069
+ const out = withIconImages(look, iconFiles(lookFile, look), web?.uris ?? {}, web ? web.done : !hasWebIcons(look));
14070
+ return listed ? { ...out, listedIcons: listed } : out;
14071
+ };
13710
14072
  function loadLook(path) {
13711
14073
  try {
13712
14074
  return withIcons(path, parseLook(readFileSync(path, "utf8"), path));
@@ -13749,6 +14111,7 @@ function lookFonts(lookFile, look) {
13749
14111
  const dir = lookFolder(lookFile, d);
13750
14112
  return dir ? plainFiles(dir, /\.(ttf|otf)$/i, 2e7, 200) : [];
13751
14113
  }) : [];
14114
+ if (lookFile) files.push(...(webFonts.get(resolve(lookFile)) ?? []).filter((f) => existsSync(f)));
13752
14115
  const have = /* @__PURE__ */ new Set();
13753
14116
  for (const f of [...bundledFonts(), ...files]) {
13754
14117
  const m = fontMeta(new Uint8Array(readFileSync(f)));
@@ -13760,6 +14123,13 @@ function lookFonts(lookFile, look) {
13760
14123
  }
13761
14124
  function readLook(file, p) {
13762
14125
  if (!p) return { text: null, refused: false };
14126
+ if (isWebLook(p)) {
14127
+ try {
14128
+ return { text: readFileSync(cachePath(p), "utf8"), refused: false };
14129
+ } catch {
14130
+ return { text: null, refused: false };
14131
+ }
14132
+ }
13763
14133
  if (!p.toLowerCase().endsWith(".look")) return { text: null, refused: true };
13764
14134
  try {
13765
14135
  return { text: readFileSync(resolve(dirname(file), p), "utf8"), refused: false };
@@ -13778,11 +14148,12 @@ function loadScene(file, srcIn) {
13778
14148
  }
13779
14149
  const p = lookPath(src);
13780
14150
  const r = readLook(file, p);
13781
- const sc = buildScene(src, r.text === null ? null : withIcons(resolve(dirname(file), p), parseLook(r.text, p)), file);
13782
- const fonts = lookFonts(r.text === null ? void 0 : resolve(dirname(file), p), sc.look);
14151
+ const sc = buildScene(src, r.text === null ? null : withIcons(lookFileFor(file, p), parseLook(r.text, p)), file);
14152
+ const fonts = lookFonts(r.text === null ? void 0 : lookFileFor(file, p), sc.look);
13783
14153
  sc.fontFiles = fonts.files;
13784
14154
  for (const fam2 of fonts.missing) {
13785
- sc.issues.push({ line: 1, level: "warn", msg: `the look names the font "${fam2}", but no TTF or OTF file for it was found, so text will be drawn in a fallback font; put its files in a folder next to the look and add fontdir "./fonts" to the look` });
14155
+ const at = sc.look.fontUrls.get(fam2);
14156
+ sc.issues.push({ line: 1, level: "warn", msg: at ? `the look names the font "${fam2}" at ${at}, but no TTF or OTF file of it was fetched from there, so text will be drawn in a fallback font` : `the look names the font "${fam2}", but no TTF or OTF file for it was found, so text will be drawn in a fallback font; put its files in a folder next to the look and add fontdir "./fonts" to the look` });
13786
14157
  }
13787
14158
  if (r.refused) {
13788
14159
  for (const i of sc.issues) if (i.msg.startsWith("look file not found")) i.msg = `the look path must end in .look; "${p}" was not read`;
@@ -13800,23 +14171,25 @@ function readSources(file, sc, src) {
13800
14171
  function lookFileOf(diagramFile) {
13801
14172
  try {
13802
14173
  const p = lookPath(readFileSync(diagramFile, "utf8"));
13803
- return p && p.toLowerCase().endsWith(".look") ? resolve(dirname(diagramFile), p) : void 0;
14174
+ return p && isWebLook(p) ? cachePath(p) : p && p.toLowerCase().endsWith(".look") ? resolve(dirname(diagramFile), p) : void 0;
13804
14175
  } catch {
13805
14176
  return void 0;
13806
14177
  }
13807
14178
  }
13808
14179
  function lookArg(v) {
13809
14180
  if (isBundledLook(v)) return { name: v };
13810
- if (!/\.look$/i.test(v)) return `no look named ${v}; named looks: ${BUNDLED_LOOK_NAMES.join(", ")}, or give a path to a .look file`;
14181
+ if (isWebLook(v)) return { url: v, file: cachePath(v) };
14182
+ if (!/\.look$/i.test(v)) return `no look named ${v}; named looks: ${BUNDLED_LOOK_NAMES.join(", ")}, or give a path to a .look file or its https address`;
13811
14183
  return existsSync(v) ? { file: resolve(v) } : `look file not found: ${v}`;
13812
14184
  }
13813
14185
  function lookOfDiagram(file, src) {
13814
14186
  const p = lookPath(src);
13815
14187
  if (p === void 0) return void 0;
13816
- return isBundledLook(p) ? { name: p } : { file: resolve(dirname(file), p) };
14188
+ return isBundledLook(p) ? { name: p } : isWebLook(p) ? { url: p, file: cachePath(p) } : { file: resolve(dirname(file), p) };
13817
14189
  }
13818
14190
  function lookRefText(ref, file) {
13819
14191
  if ("name" in ref) return ref.name;
14192
+ if ("url" in ref) return ref.url;
13820
14193
  const rel = relative(dirname(resolve(file)), ref.file).split(sep).join("/");
13821
14194
  return rel.startsWith(".") || isAbsolute(rel) ? rel : "./" + rel;
13822
14195
  }
@@ -13828,35 +14201,19 @@ function darkLookOf(ref) {
13828
14201
  name2 = `the ${ref.name} look`;
13829
14202
  } else if (ref) {
13830
14203
  if (!/\.look$/i.test(ref.file)) return `the look path must end in .look; ${ref.file} was not read`;
13831
- if (!existsSync(ref.file)) return `look file not found: ${ref.file}`;
14204
+ if (!existsSync(ref.file)) return "url" in ref ? `the look at ${ref.url} could not be fetched` : `look file not found: ${ref.file}`;
13832
14205
  look = parseLook(readFileSync(ref.file, "utf8"), ref.file);
13833
- name2 = basename(ref.file);
13834
- from = ref.file;
14206
+ name2 = "url" in ref ? ref.url : basename(ref.file);
14207
+ from = "url" in ref ? void 0 : ref.file;
13835
14208
  }
13836
14209
  const d = look.dark;
13837
14210
  if (!d) return ref && "name" in ref ? `${name2} has no dark version; draw the dark image with --look and a dark look instead` : `${name2} has no dark version: ${how}`;
13838
14211
  if (isBundledLook(d)) return { name: d };
13839
- if (!from) return `${name2} names a dark look by path (${d}), which only a look file can do`;
14212
+ if (!from) return `${name2} names a dark look by path (${d}), which only a look file on this computer can do`;
13840
14213
  const file = resolve(dirname(from), d);
13841
14214
  return existsSync(file) ? { file } : `the dark look of ${name2} was not found: ${d}`;
13842
14215
  }
13843
14216
 
13844
- // src/extendedIcons.ts
13845
- var loading;
13846
- var loaded = false;
13847
- var listeners = /* @__PURE__ */ new Set();
13848
- function loadExtendedIcons() {
13849
- loading ??= Promise.resolve().then(() => (init_iconSetAll(), iconSetAll_exports)).then((m) => {
13850
- for (const w of Object.keys(m.EXTRA_WEIGHTS)) Object.assign(ICON_WEIGHTS[w], m.EXTRA_WEIGHTS[w]);
13851
- Object.assign(DUOTONE_TINT, m.EXTRA_TINT);
13852
- Object.assign(ICON_WORDS, m.EXTRA_WORDS);
13853
- loaded = true;
13854
- resetLookCaches();
13855
- listeners.forEach((fn) => fn());
13856
- });
13857
- return loading;
13858
- }
13859
-
13860
14217
  // src/embed.ts
13861
14218
  var b64 = (s) => {
13862
14219
  const b = new TextEncoder().encode(s);
@@ -13923,10 +14280,10 @@ var range = (v) => {
13923
14280
  const m = /^(-?[\d.]+)\.\.(-?[\d.]+)$/.exec(v ?? "");
13924
14281
  return m && Math.abs(+m[1]) < 1e15 && Math.abs(+m[2]) < 1e15 && +m[2] > +m[1] ? [+m[1], +m[2]] : null;
13925
14282
  };
13926
- function drawChart(look, s) {
13927
- const p = s.p, rows = (s.rows ?? []).filter((r) => r.id && r.vals.length), out = [];
14283
+ var pairs = (v) => v === "_" ? [] : v.split(",").map(Number);
14284
+ function plot(s) {
14285
+ const p = s.p, rows = (s.rows ?? []).filter((r) => r.id && r.vals.length);
13928
14286
  const { x, y, w, h } = s;
13929
- const pairs = (v) => v === "_" ? [] : v.split(",").map(Number);
13930
14287
  const xr = range(p.x), cats = !xr && p.x ? p.x.split(",").map((c) => c.trim()) : [];
13931
14288
  const n = xr ? 0 : Math.max(cats.length, ...rows.map((r) => r.vals.length), 1);
13932
14289
  const finite = (v) => Number.isFinite(v);
@@ -13948,6 +14305,43 @@ function drawChart(look, s) {
13948
14305
  const X = (i) => r2(x + bw * (i + 0.5));
13949
14306
  const XV = (v) => xr ? r2(x + (v - xr[0]) / (xr[1] - xr[0]) * w) : 0;
13950
14307
  const base = Y(Math.min(Math.max(0, y0), y1));
14308
+ const bars = rows.filter((r) => r.id === "bars");
14309
+ const group = bw * num2(p["bar.width"], 0.64), each = stacked || !bars.length ? group : group / bars.length;
14310
+ const tops = [];
14311
+ const barBoxes = bars.flatMap((r, k) => r.vals.flatMap((raw, i) => {
14312
+ const q = pairs(raw);
14313
+ if (!q.length) return [];
14314
+ let lo = q.length === 2 ? q[0] : 0, hi = q.length === 2 ? q[1] : q[0];
14315
+ if (stacked && q.length === 1) {
14316
+ lo = tops[i] ?? 0;
14317
+ hi = lo + q[0];
14318
+ tops[i] = hi;
14319
+ }
14320
+ const top = Math.min(Y(lo), Y(hi)), bh = Math.abs(Y(lo) - Y(hi));
14321
+ const bx = r2(X(i) - group / 2 + (stacked ? 0 : k * each) + (each > 6 ? 1 : 0)), ww = r2(each - (each > 6 ? 2 : 0));
14322
+ return [{ r, i, q, lo, hi, top, bh, bx, ww }];
14323
+ }));
14324
+ const points = rows.filter((r) => r.id !== "bars").map((r) => ({ r, pts: r.vals.map((raw, i) => ({ raw, i })).filter((e) => e.raw !== "_").map(({ raw, i }) => {
14325
+ const q = pairs(raw);
14326
+ return q.length >= 2 && xr ? { x: XV(q[0]), y: Y(q[1]), v: q[1], r: q[2] ?? 0, i } : { x: X(i), y: Y(q[0]), v: q[0], r: q[1] ?? 0, i };
14327
+ }) }));
14328
+ return { p, rows, x, y, w, h, xr, cats, n, y0, y1, step, Y, X, XV, bw, base, stacked, barBoxes, points };
14329
+ }
14330
+ function chartMarks(s) {
14331
+ const { barBoxes, points } = plot(s);
14332
+ const marks = barBoxes.map((b) => ({ x: b.bx, y: b.top, w: b.ww, h: Math.max(b.bh, 0.5) }));
14333
+ for (const { r, pts } of points) {
14334
+ if (r.id !== "dots" && r.p.dots !== "1") continue;
14335
+ for (const q of pts) {
14336
+ const rad = r.id === "dots" ? num2(r.p.r, q.r || 4) : 3;
14337
+ marks.push({ x: q.x - rad, y: q.y - rad, w: 2 * rad, h: 2 * rad });
14338
+ }
14339
+ }
14340
+ return marks;
14341
+ }
14342
+ function drawChart(look, s) {
14343
+ const { p, rows, x, y, w, h, xr, cats, n, y0, y1, step, Y, X, XV, bw, base, stacked, barBoxes, points } = plot(s);
14344
+ const out = [];
13951
14345
  const tick = textAttrs(look, p, "tick.", { font: "mono", size: 9, weight: 400, color: "muted" });
13952
14346
  const axis = col(look, p.stroke ?? "ink/0.5"), grid = col(look, p["grid.color"] ?? "ink/0.08"), sw = num2(p.sw, 1);
13953
14347
  const unit = p.unit ?? "", pre = p.prefix ?? "";
@@ -13970,35 +14364,15 @@ function drawChart(look, s) {
13970
14364
  const lab = textAttrs(look, p, "value.", { font: "mono", size: 9, weight: 400, color: "ink" });
13971
14365
  const labels = p.labels === "1";
13972
14366
  const value = (cx2, cy2, v, plus = false) => labels && out.push(`<text x="${cx2}" y="${r2(cy2)}" text-anchor="middle" ${lab.a}>${esc((plus ? "+" : "") + pre + fmt(v) + unit)}</text>`);
13973
- const bars = rows.filter((r) => r.id === "bars");
13974
14367
  const colour = (r, k) => r.p[k] ?? r.p.fill ?? r.p.stroke ?? PALETTE[rows.indexOf(r) % PALETTE.length];
13975
- const group = bw * num2(p["bar.width"], 0.64), each = stacked || !bars.length ? group : group / bars.length;
13976
- const tops = [];
13977
- bars.forEach((r, k) => {
13978
- const rad = num2(p["bar.radius"], 2);
14368
+ const rad = num2(p["bar.radius"], 2);
14369
+ for (const { r, i, q, lo, hi, top, bh, bx, ww } of barBoxes) {
13979
14370
  const outline2 = r.p.stroke && r.p.fill ? ` stroke="${col(look, r.p.stroke)}" stroke-width="${num2(r.p.sw, 1)}"` : "";
13980
- r.vals.forEach((raw, i) => {
13981
- const q = pairs(raw);
13982
- if (!q.length) return;
13983
- let lo = q.length === 2 ? q[0] : 0, hi = q.length === 2 ? q[1] : q[0];
13984
- if (stacked && q.length === 1) {
13985
- lo = tops[i] ?? 0;
13986
- hi = lo + q[0];
13987
- tops[i] = hi;
13988
- }
13989
- const top = Math.min(Y(lo), Y(hi)), bh = Math.abs(Y(lo) - Y(hi));
13990
- const bx = r2(X(i) - group / 2 + (stacked ? 0 : k * each) + (each > 6 ? 1 : 0)), ww = r2(each - (each > 6 ? 2 : 0));
13991
- out.push(`<rect x="${bx}" y="${top}" width="${ww}" height="${r2(Math.max(bh, 0.5))}"${rad && bh > rad * 2 && !stacked ? ` rx="${rad}"` : ""} fill="${col(look, r.p[`fill.${i + 1}`] ?? colour(r, "fill"))}"${outline2}/>`);
13992
- value(r2(bx + ww / 2), hi >= lo ? top - 4 : top + bh + lab.size + 2, q.length === 2 ? hi - lo : q[0], q.length === 2 && lo !== 0 && hi > lo);
13993
- });
13994
- });
13995
- for (const r of rows) {
13996
- if (r.id === "bars") continue;
14371
+ out.push(`<rect x="${bx}" y="${top}" width="${ww}" height="${r2(Math.max(bh, 0.5))}"${rad && bh > rad * 2 && !stacked ? ` rx="${rad}"` : ""} fill="${col(look, r.p[`fill.${i + 1}`] ?? colour(r, "fill"))}"${outline2}/>`);
14372
+ value(r2(bx + ww / 2), hi >= lo ? top - 4 : top + bh + lab.size + 2, q.length === 2 ? hi - lo : q[0], q.length === 2 && lo !== 0 && hi > lo);
14373
+ }
14374
+ for (const { r, pts } of points) {
13997
14375
  const stroke = col(look, colour(r, "stroke")), lw = num2(r.p.sw, 2);
13998
- const pts = r.vals.map((raw, i) => ({ raw, i })).filter((e) => e.raw !== "_").map(({ raw, i }) => {
13999
- const q = pairs(raw);
14000
- return q.length >= 2 && xr ? { x: XV(q[0]), y: Y(q[1]), v: q[1], r: q[2] ?? 0, i } : { x: X(i), y: Y(q[0]), v: q[0], r: q[1] ?? 0, i };
14001
- });
14002
14376
  if (!pts.length) continue;
14003
14377
  const d = pts.map((q) => `${q.x},${q.y}`).join(" ");
14004
14378
  if (r.id === "area") out.push(`<polygon points="${pts[0].x},${base} ${d} ${pts[pts.length - 1].x},${base}" fill="${col(look, r.p.fill ?? colour(r, "stroke") + (/\/[\d.]+$/.test(colour(r, "stroke")) ? "" : "/0.1"))}"/>`);
@@ -14144,10 +14518,27 @@ function hatchDefs() {
14144
14518
  }
14145
14519
  var BLEND = ' style="mix-blend-mode:multiply"';
14146
14520
  var blendOf = (p) => p.blend === "multiply" ? BLEND : "";
14521
+ function faded(p, svg) {
14522
+ const o = Math.min(1, Math.max(0, num2(p.opacity, 1)));
14523
+ return o < 1 ? `<g opacity="${r2(o)}">${svg}</g>` : svg;
14524
+ }
14525
+ function turned(s, svg) {
14526
+ const t = turnOf(s.p);
14527
+ return t ? `<g transform="rotate(${r2(t)} ${r2(s.x + s.w / 2)} ${r2(s.y + s.h / 2)})">${svg}</g>` : svg;
14528
+ }
14147
14529
  var shifted = (s, dx, dy) => ({ ...s, x: s.x + dx, y: s.y + dy, poly: s.poly?.map((q) => ({ x: q.x + dx, y: q.y + dy })) });
14148
14530
  var boxy = (s) => s.shape !== "polygon" && s.shape !== "arc";
14531
+ var SHADOW_STEPS = 6;
14149
14532
  function underlay(look, s) {
14150
14533
  const p = s.p, out = [];
14534
+ if (p.shadow && p.shadow !== "none" && boxy(s)) {
14535
+ const size = num2(p["shadow.size"], 12), dx = num2(p["shadow.dx"], 0), dy = num2(p["shadow.dy"], 4), c = col(look, p.shadow);
14536
+ for (let i = SHADOW_STEPS; i >= 1; i--) {
14537
+ const e = r2(size * i / SHADOW_STEPS);
14538
+ const grown = { ...s, x: s.x - e + dx, y: s.y - e + dy, w: s.w + e * 2, h: s.h + e * 2, p: { ...p, radius: String(num2(p.radius, 0) + e) } };
14539
+ out.push(outlinePlain(grown, `fill="${c}" fill-opacity="${r2(1 / SHADOW_STEPS)}" stroke="none"`));
14540
+ }
14541
+ }
14151
14542
  if (p.shade && p.shade !== "none") {
14152
14543
  const k = num2(p["shade.size"], 5);
14153
14544
  out.push(outlinePlain(shifted(s, k, k), `fill="${pattern("hatch", col(look, p.shade), num2(p["shade.gap"], 2.6), num2(p["shade.sw"], 0.6))}" stroke="none"`));
@@ -14170,6 +14561,8 @@ function overlay(look, s) {
14170
14561
  out.push(outlinePlain(inset2, `fill="none" stroke="${col(look, p.inner)}" stroke-width="${num2(p["inner.sw"], 0.6)}"`));
14171
14562
  }
14172
14563
  }
14564
+ const ib = iconBox(s), strips = [[p.side, num2(p["side.w"], 4)], [ib?.block ? p["icon.block"] : void 0, ib?.block ?? 0]];
14565
+ for (const [c, w] of strips) if (c && c !== "none" && w > 0 && s.shape === "rect") out.push(`<path d="${leftStrip(s, w)}" fill="${col(look, c)}"/>`);
14173
14566
  if (p.corners && p.corners !== "none" && (s.shape === "rect" || s.shape === "table")) {
14174
14567
  const c = col(look, p["corners.color"] ?? p.stroke ?? "ink"), k = num2(p["corners.size"], p.corners === "plus" ? 7 : 5) / 2;
14175
14568
  for (const [x, y] of [[s.x, s.y], [s.x + s.w, s.y], [s.x, s.y + s.h], [s.x + s.w, s.y + s.h]]) {
@@ -14178,6 +14571,10 @@ function overlay(look, s) {
14178
14571
  }
14179
14572
  return out;
14180
14573
  }
14574
+ function leftStrip(s, w) {
14575
+ const r = Math.min(num2(s.p.radius, 0), w, s.h / 2), x = s.x, y = s.y, b = s.y + s.h;
14576
+ return r > 0 ? `M ${r2(x + r)},${y} H ${r2(x + w)} V ${b} H ${r2(x + r)} Q ${x},${b} ${x},${r2(b - r)} V ${r2(y + r)} Q ${x},${y} ${r2(x + r)},${y} Z` : `M ${x},${y} H ${r2(x + w)} V ${b} H ${x} Z`;
14577
+ }
14181
14578
  var esc = (s) => s.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;");
14182
14579
  var num2 = (v, d) => v === void 0 || v === "" || isNaN(+v) ? d : +v;
14183
14580
  var r2 = (n) => Math.round(n * 100) / 100;
@@ -14275,8 +14672,8 @@ function outlinePlain(s, attrs) {
14275
14672
  const cx0 = x + w / 2, cy0 = y + h / 2;
14276
14673
  const pt = (deg, k) => `${r2(cx0 + w / 2 * k * Math.sin(deg * Math.PI / 180))},${r2(cy0 - h / 2 * k * Math.cos(deg * Math.PI / 180))}`;
14277
14674
  const sweep = (k, f, t) => {
14278
- const mid = (f + t) / 2, dir = t > f ? 1 : 0, r = `${r2(w / 2 * k)} ${r2(h / 2 * k)}`;
14279
- return `A ${r} 0 0 ${dir} ${pt(mid, k)} A ${r} 0 0 ${dir} ${pt(t, k)}`;
14675
+ const mid2 = (f + t) / 2, dir = t > f ? 1 : 0, r = `${r2(w / 2 * k)} ${r2(h / 2 * k)}`;
14676
+ return `A ${r} 0 0 ${dir} ${pt(mid2, k)} A ${r} 0 0 ${dir} ${pt(t, k)}`;
14280
14677
  };
14281
14678
  const full = Math.abs(a1 - a0) >= 360;
14282
14679
  let d = `M ${pt(a0, 1)} ${sweep(1, a0, a1)}`;
@@ -14361,8 +14758,8 @@ function drawTable(look, s) {
14361
14758
  if (cell === "") return;
14362
14759
  const base = row.kind === "head" ? strong : j === 0 ? first : rest;
14363
14760
  const a = cc ? { ...base, a: base.a.replace(/fill="[^"]*"/, () => `fill="${col(look, cc)}"`) } : base;
14364
- const mid = center && j > 0;
14365
- out.push(`<text x="${r2(s.x + c.x + (mid ? c.w / 2 : 0))}" y="${r2(row.y + row.h / 2 + a.size * 0.36)}"${mid ? ' text-anchor="middle"' : ""} ${a.a}>${esc(cell)}</text>`);
14761
+ const mid2 = center && j > 0;
14762
+ out.push(`<text x="${r2(s.x + c.x + (mid2 ? c.w / 2 : 0))}" y="${r2(row.y + row.h / 2 + a.size * 0.36)}"${mid2 ? ' text-anchor="middle"' : ""} ${a.a}>${esc(cell)}</text>`);
14366
14763
  });
14367
14764
  });
14368
14765
  if (p.grid === "1" && rows.length) for (const c of cols.slice(1)) {
@@ -14379,10 +14776,18 @@ function drawTable(look, s) {
14379
14776
  function iconBox(s) {
14380
14777
  const p = s.p;
14381
14778
  if (!p.icon || p.icon === "none") return null;
14779
+ if (p["icon.pos"] === "corner") return { x: s.x, y: s.y, size: num2(p["icon.size"], 24), dx: 0, dy: 0 };
14382
14780
  const hasText = !!(s.text || p.sub) && p["title.pos"] !== "top";
14383
14781
  const size = num2(p["icon.size"], hasText ? 20 : Math.max(8, Math.min(s.w, s.h, 96) - (s.style === "icon" ? 0 : 16)));
14384
14782
  if (!hasText) return { x: s.x + (s.w - size) / 2, y: s.y + (s.h - size) / 2, size, dx: 0, dy: 0 };
14385
- if (p["icon.pos"] === "top") return { x: s.x + (s.w - size) / 2, y: 0, size, dx: 0, dy: (size + 6) / 2 };
14783
+ if (p["icon.block"] && p["icon.block"] !== "none" && (p["icon.pos"] ?? "left") === "left" && s.shape === "rect") {
14784
+ const bw = num2(p["icon.block.w"], s.h);
14785
+ return { x: s.x + (bw - size) / 2, y: s.y + (s.h - size) / 2, size, dx: bw / 2, dy: 0, block: bw };
14786
+ }
14787
+ if (p["icon.pos"] === "top") {
14788
+ const room = iconBg(p) ? num2(p["icon.bg.size"], size + 24) : size;
14789
+ return { x: s.x + (s.w - size) / 2, y: 0, size, dx: 0, dy: (room + 6) / 2, room };
14790
+ }
14386
14791
  if (p["title.align"] === "left" || p["title.align"] === "right") return { x: s.x + 12, y: s.y + (s.h - size) / 2, size, dx: (size + 8) / 2, dy: 0 };
14387
14792
  const widths = [
14388
14793
  ...(s.text ? s.text.split("\n") : []).map((l) => textWidth(p["title.caps"] === "1" ? l.toUpperCase() : l, num2(p["title.size"], 12), p["title.font"] ?? "sans", num2(p["title.weight"], 600), num2(p["title.spacing"], 0))),
@@ -14391,8 +14796,20 @@ function iconBox(s) {
14391
14796
  const tw = Math.max(0, ...widths), x = Math.max(s.x + 8, s.x + (s.w - (size + 8 + tw)) / 2);
14392
14797
  return { x, y: s.y + (s.h - size) / 2, size, dx: (size + 8) / 2, dy: 0 };
14393
14798
  }
14799
+ var iconBg = (p) => !!p["icon.bg"] && p["icon.bg"] !== "none";
14394
14800
  function drawIcon(look, p, x, y, size) {
14395
- const name2 = p.icon, img = look.images.get(name2);
14801
+ if (!iconBg(p)) return drawIconOnly(look, p, x, y, size);
14802
+ const b = num2(p["icon.bg.size"], size + 24), cx2 = x + size / 2, cy2 = y + size / 2;
14803
+ const disc = (e, dx, dy, fill) => p["icon.bg.shape"] === "circle" ? `<circle cx="${r2(cx2 + dx)}" cy="${r2(cy2 + dy)}" r="${r2(b / 2 + e)}" ${fill}/>` : `<rect x="${r2(cx2 - b / 2 - e + dx)}" y="${r2(cy2 - b / 2 - e + dy)}" width="${r2(b + e * 2)}" height="${r2(b + e * 2)}" ${fill}/>`;
14804
+ let under = "";
14805
+ if (p["icon.bg.shadow"] && p["icon.bg.shadow"] !== "none") {
14806
+ const ss = num2(p["icon.bg.shadow.size"], 8), sdx = num2(p["icon.bg.shadow.dx"], 0), sdy = num2(p["icon.bg.shadow.dy"], 3), sc = col(look, p["icon.bg.shadow"]);
14807
+ for (let i = SHADOW_STEPS; i >= 1; i--) under += disc(r2(ss * i / SHADOW_STEPS), sdx, sdy, `fill="${sc}" fill-opacity="${r2(1 / SHADOW_STEPS)}"`);
14808
+ }
14809
+ return under + disc(0, 0, 0, `fill="${col(look, p["icon.bg"])}"`) + drawIconOnly(look, p, x, y, size);
14810
+ }
14811
+ function drawIconOnly(look, p, x, y, size) {
14812
+ const name2 = iconStandIn(look, p.icon) ?? p.icon, img = look.images.get(name2);
14396
14813
  if (img) return isIconUri(img) ? `<image x="${r2(x)}" y="${r2(y)}" width="${r2(size)}" height="${r2(size)}" href="${esc(img)}"/>` : "";
14397
14814
  const ink = col(look, p["icon.color"] ?? p["title.color"] ?? "ink");
14398
14815
  const ownFill = p["icon.fill"] && p["icon.fill"] !== "none" ? col(look, p["icon.fill"]) : null;
@@ -14465,9 +14882,9 @@ function drawShape(look, s) {
14465
14882
  }
14466
14883
  }
14467
14884
  if (s.shape === "arc" && Math.abs(num2(p.to, 360) - num2(p.from, 0)) < 360) {
14468
- const mid = (num2(p.from, 0) + num2(p.to, 360)) / 2 * (Math.PI / 180), inner = num2(p.inner, 0), k = inner > 0 ? (1 + inner) / 2 : 0.62;
14469
- cxm = r2(cxm + s.w / 2 * k * Math.sin(mid));
14470
- cym = r2(cym - s.h / 2 * k * Math.cos(mid));
14885
+ const mid2 = (num2(p.from, 0) + num2(p.to, 360)) / 2 * (Math.PI / 180), inner = num2(p.inner, 0), k = inner > 0 ? (1 + inner) / 2 : 0.62;
14886
+ cxm = r2(cxm + s.w / 2 * k * Math.sin(mid2));
14887
+ cym = r2(cym - s.h / 2 * k * Math.cos(mid2));
14471
14888
  }
14472
14889
  if (p.ghost) {
14473
14890
  const t = textAttrs(look, p, "ghost.", { font: "mono", size: 32, weight: 600, color: "ink/0.06" });
@@ -14479,7 +14896,8 @@ function drawShape(look, s) {
14479
14896
  const capOwn = p["title.dy"] !== void 0 || p["title.fill"] !== void 0;
14480
14897
  const capH = capOwn ? Math.max(12, Math.ceil(title.size + 4)) : 12, capY = num2(p["title.dy"], 0) + 4;
14481
14898
  if (tb && capTop) tb = { ...tb, x: 12, y: capY + Math.round((capH - tb.h) / 2) };
14482
- const tagRoom = tb && capTop ? tagWidth(look, p) + 4 : 0;
14899
+ const corner2 = capTop && p["icon.pos"] === "corner" && p.icon && p.icon !== "none" ? num2(p["icon.size"], 24) - 4 : 0;
14900
+ const tagRoom = (tb && capTop ? tagWidth(look, p) + 4 : 0) + corner2;
14483
14901
  if (tb) {
14484
14902
  const t = textAttrs(look, p, "tag.", { font: "mono", size: 7, weight: 400, color: "muted" });
14485
14903
  const tw = tagWidth(look, p);
@@ -14491,20 +14909,21 @@ function drawShape(look, s) {
14491
14909
  cxm += ib.dx;
14492
14910
  cym += ib.dy;
14493
14911
  }
14494
- if (ib && !(ib.dy > 0)) out.push(drawIcon(look, p, ib.x, ib.y, ib.size));
14912
+ const idx = num2(p["icon.dx"], 0), idy = num2(p["icon.dy"], 0);
14913
+ if (ib && !(ib.dy > 0)) out.push(drawIcon(look, p, ib.x + idx, ib.y + idy, ib.size));
14495
14914
  if (s.text && p["title.pos"] === "top") {
14496
14915
  const txt = p["title.caps"] === "1" ? s.text.toUpperCase() : s.text;
14497
14916
  const tw = Math.ceil(measureText(look, txt, title.size, title.font, title.weight, title.spacing) + 12);
14498
- const al = p["title.align"], mid = al === "left" ? s.x + 12 + tagRoom + tw / 2 : al === "right" ? s.x + s.w - 12 - tw / 2 : cxm;
14917
+ const al = p["title.align"], mid2 = al === "left" ? s.x + 12 + tagRoom + tw / 2 : al === "right" ? s.x + s.w - 12 - tw / 2 : cxm;
14499
14918
  const own = p["title.dy"] !== void 0 || p["title.fill"] !== void 0;
14500
14919
  const ty = s.y + num2(p["title.dy"], 0), th = own ? Math.max(12, Math.ceil(title.size + 4)) : 12;
14501
14920
  if (p["title.fill"] !== "none") {
14502
- const rect = (fill) => `<rect x="${r2(mid - tw / 2)}" y="${ty + 4}" width="${tw}" height="${th}" rx="2" fill="${fill}"/>`;
14921
+ const rect = (fill) => `<rect x="${r2(mid2 - tw / 2)}" y="${ty + 4}" width="${tw}" height="${th}" rx="2" fill="${fill}"/>`;
14503
14922
  out.push(rect(col(look, p["title.fill"] ?? look.canvas.paper ?? "paper")));
14504
14923
  const inside3 = p["title.fill"] === void 0 && ty + 4 >= s.y + num2(p.sw, 1) / 2 && !p.offset && !blendOf(p);
14505
14924
  if (inside3 && p.fill && p.fill !== "none") out.push(rect(col(look, p.fill)));
14506
14925
  }
14507
- out.push(`<text x="${mid}" y="${own ? r2(ty + 4 + th / 2 + title.size * 0.36) : s.y + 13}" text-anchor="middle" ${title.a}>${esc(txt)}</text>`);
14926
+ out.push(`<text x="${mid2}" y="${own ? r2(ty + 4 + th / 2 + title.size * 0.36) : s.y + 13}" text-anchor="middle" ${title.a}>${esc(txt)}</text>`);
14508
14927
  } else if (s.text || p.sub) {
14509
14928
  const lines = s.text ? (p["title.caps"] === "1" ? s.text.toUpperCase() : s.text).split("\n") : [];
14510
14929
  const lh = Math.round(title.size * 1.17);
@@ -14512,8 +14931,11 @@ function drawShape(look, s) {
14512
14931
  const subs = p.sub ? p.sub.split("\n") : [], slh = Math.round(sub.size * 1.3);
14513
14932
  const block = lines.length * lh + (subs.length ? sub.size + 7 + (subs.length - 1) * slh : 0);
14514
14933
  const top = tb ? tb.top : cym - block / 2;
14515
- if (ib && ib.dy > 0) out.push(drawIcon(look, p, ib.x, top - ib.size - 6, ib.size));
14516
- const al = p["title.align"], tx = al === "left" ? s.x + 12 + (ib && ib.dx ? ib.size + 8 : 0) : al === "right" ? s.x + s.w - 12 : cxm, anchor = al === "left" ? "start" : al === "right" ? "end" : "middle";
14934
+ if (ib && ib.dy > 0) {
14935
+ const room = ib.room ?? ib.size;
14936
+ out.push(drawIcon(look, p, ib.x + idx, top - room - 6 + (room - ib.size) / 2 + idy, ib.size));
14937
+ }
14938
+ const al = p["title.align"], tx = al === "left" ? ib?.block ? s.x + ib.block + 12 : s.x + 12 + (ib && ib.dx ? ib.size + 8 : 0) : al === "right" ? s.x + s.w - 12 : cxm, anchor = al === "left" ? "start" : al === "right" ? "end" : "middle";
14517
14939
  lines.forEach((l, i) => out.push(`<text x="${tx}" y="${r2(top + title.size * 0.86 + i * lh)}" text-anchor="${anchor}" ${title.a}>${esc(l)}</text>`));
14518
14940
  subs.forEach((l, i) => out.push(`<text x="${tx}" y="${r2(top + lines.length * lh + sub.size + 3 + i * slh)}" text-anchor="${anchor}" ${sub.a}>${esc(l)}</text>`));
14519
14941
  }
@@ -14677,6 +15099,25 @@ function marker(kind, tip, from, sw, stroke, paper, k = 1, ring2 = stroke) {
14677
15099
  return { svg: "", trim: 0 };
14678
15100
  case "open":
14679
15101
  return { svg: `<path d="M ${at(10 * k, 5 * k)} L ${at(0, 0)} L ${at(10 * k, -5 * k)}" ${line}/>`, trim: 0 };
15102
+ // swept back, with a notch where the line goes in
15103
+ case "stealth":
15104
+ return { svg: `<polygon points="${at(0, 0)} ${at(12 * k, 5 * k)} ${at(8 * k, 0)} ${at(12 * k, -5 * k)}" fill="${stroke}"/>`, trim: 8 * k };
15105
+ // two heads one behind the other
15106
+ case "double":
15107
+ return { svg: `<polygon points="${at(0, 0)} ${at(10 * k, 4 * k)} ${at(10 * k, -4 * k)}" fill="${stroke}"/><polygon points="${at(7 * k, 0)} ${at(17 * k, 4 * k)} ${at(17 * k, -4 * k)}" fill="${stroke}"/>`, trim: 14 * k };
15108
+ // a harpoon: one barb, on the left of the way the line runs
15109
+ case "half":
15110
+ return { svg: `<path d="M ${at(10 * k, -5 * k)} L ${at(0, 0)}" ${line}/>`, trim: 0 };
15111
+ case "square":
15112
+ return { svg: `<polygon points="${at(0, 4.5 * k)} ${at(9 * k, 4.5 * k)} ${at(9 * k, -4.5 * k)} ${at(0, -4.5 * k)}" ${hollow}/>`, trim: 9 * k };
15113
+ case "square-solid":
15114
+ return { svg: `<polygon points="${at(0, 4.5 * k)} ${at(9 * k, 4.5 * k)} ${at(9 * k, -4.5 * k)} ${at(0, -4.5 * k)}" fill="${stroke}" stroke="${stroke}" stroke-width="${sw}" stroke-linejoin="round"/>`, trim: 9 * k };
15115
+ // a bar across the very end: the line stops here (blocks, inhibits)
15116
+ case "bar":
15117
+ return { svg: `<path d="M ${at(0, 6 * k)} L ${at(0, -6 * k)}" ${line}/>`, trim: 0 };
15118
+ // an X over the end: cancelled, destroyed
15119
+ case "cross":
15120
+ return { svg: `<path d="M ${at(0, 4.5 * k)} L ${at(9 * k, -4.5 * k)} M ${at(0, -4.5 * k)} L ${at(9 * k, 4.5 * k)}" ${line}/>`, trim: 0 };
14680
15121
  case "triangle":
14681
15122
  return { svg: `<polygon points="${at(0, 0)} ${at(11 * k, 6 * k)} ${at(11 * k, -6 * k)}" ${hollow}/>`, trim: 11 * k };
14682
15123
  // a stop on a route: a ring the line runs into, in the colour of the boxes' outline
@@ -14727,22 +15168,32 @@ function cutEnd(pts, dist) {
14727
15168
  }
14728
15169
  return pts.slice(0, 2);
14729
15170
  }
15171
+ function seeThrough(c) {
15172
+ if (!c.startsWith("rgba(") || !c.endsWith(")")) return null;
15173
+ const v = c.slice(5, -1).split(",").map((x) => x.trim());
15174
+ if (v.length !== 4 || v.some((x) => x === "" || isNaN(+x))) return null;
15175
+ const a = +v[3];
15176
+ return a < 1 ? { solid: `rgb(${v[0]},${v[1]},${v[2]})`, a } : null;
15177
+ }
14730
15178
  function drawConn(look, c) {
15179
+ if (c.pts.length < 2) return "";
14731
15180
  const p = c.p, sw = num2(p.sw, 1.2), stroke = col(look, p.stroke ?? "muted");
14732
15181
  const n = c.pts.length, paper = col(look, look.canvas.paper ?? "paper");
14733
15182
  const hFrom = c.curve ? backAlong(c.pts, 10) : c.pts[n - 2], tFrom = c.curve ? backAlong([...c.pts].reverse(), 10) : c.pts[1];
14734
- const hk = Math.max(0.5, Math.min(num2(p["head.size"], 1), 4)), ringCol = col(look, p["stop.color"] ?? p.stroke ?? "muted");
14735
- const head = marker(c.headM, c.pts[n - 1], hFrom, sw, stroke, paper, hk, ringCol), tail = marker(c.tailM, c.pts[0], tFrom, sw, stroke, paper, hk, ringCol);
14736
- const d = c.curve ? pathD(cutEnd(cutEnd(c.pts, head.trim).reverse(), tail.trim).reverse(), 0, 0, 0) : pathD(c.pts, c.ortho ? num2(p.radius, 8) : 0, head.trim, tail.trim);
15183
+ const see = seeThrough(stroke), ink = see ? see.solid : stroke;
15184
+ const hk = Math.max(0.5, Math.min(num2(p["head.size"], 1), 4)), ringCol = p["stop.color"] ? col(look, p["stop.color"]) : ink;
15185
+ const head = marker(c.headM, c.pts[n - 1], hFrom, sw, ink, paper, hk, ringCol), tail = marker(c.tailM, c.pts[0], tFrom, sw, ink, paper, hk, ringCol);
15186
+ const d = c.curve ? pathD(cutEnd([...cutEnd(c.pts, head.trim)].reverse(), tail.trim).reverse(), 0, 0, 0) : pathD(c.pts, c.ortho ? num2(p.radius, 8) : 0, head.trim, tail.trim);
14737
15187
  const cap = p.cap === "round" ? ' stroke-linecap="round" stroke-linejoin="round"' : "";
14738
- const a = `fill="none" stroke="${stroke}" stroke-width="${sw}"${p.dash && p.dash !== "none" ? ` stroke-dasharray="${esc(p.dash)}"` : ""}${cap}${blendOf(p)}`;
15188
+ const a = `fill="none" stroke="${ink}" stroke-width="${sw}"${p.dash && p.dash !== "none" ? ` stroke-dasharray="${esc(p.dash)}"` : ""}${cap}${see ? "" : blendOf(p)}`;
14739
15189
  let s = roughOf(p) ? sketchSvg(d, a, roughOf(p)) : `<path d="${d}" ${a}/>`;
14740
- if (p.casing && p.casing !== "none") s = `<path d="${d}" fill="none" stroke="${col(look, p.casing)}" stroke-width="${r2(sw + 2 * num2(p["casing.width"], 2.5))}"${cap}/>
14741
- ` + s;
14742
15190
  if (p.double && p.double !== "none") s += `
14743
15191
  <path d="${d}" fill="none" stroke="${col(look, p.double)}" stroke-width="${num2(p["double.sw"], r2(sw * 0.42))}"${cap}/>`;
14744
15192
  if (head.svg) s += "\n" + head.svg;
14745
15193
  if (tail.svg) s += "\n" + tail.svg;
15194
+ if (see) s = `<g opacity="${see.a}"${blendOf(p)}>${s}</g>`;
15195
+ if (p.casing && p.casing !== "none") s = `<path d="${d}" fill="none" stroke="${col(look, p.casing)}" stroke-width="${r2(sw + 2 * num2(p["casing.width"], 2.5))}"${cap}/>
15196
+ ` + s;
14746
15197
  return s;
14747
15198
  }
14748
15199
  function drawLabel(look, c) {
@@ -14758,15 +15209,18 @@ function drawLabel(look, c) {
14758
15209
  }
14759
15210
  function drawText(look, t) {
14760
15211
  const a = textAttrs(look, t.p, "", { font: "sans", size: 12, weight: 400, color: "ink" });
14761
- const anchor = t.p.anchor && t.p.anchor !== "start" ? ` text-anchor="${esc(t.p.anchor)}"` : "";
14762
- const rot = num2(t.p.rotate, 0);
14763
- const lines = t.text.split("\n"), blend = blendOf(t.p);
14764
- let body = lines.map((l, i) => `<text x="${t.ax}" y="${r2(t.ay + i * a.size * 1.3)}"${anchor} ${a.a}${blend}>${esc(l)}</text>`).join("\n");
15212
+ const boxed = !!t.lines, al = t.p.align, bw = num2(t.p.width, 0);
15213
+ const ta = boxed ? al === "center" ? "middle" : al === "right" ? "end" : "start" : t.p.anchor;
15214
+ const anchor = ta && ta !== "start" ? ` text-anchor="${esc(ta)}"` : "";
15215
+ const x0 = boxed ? t.ax + (al === "center" ? bw / 2 : al === "right" ? bw : 0) : t.ax;
15216
+ const rot = turnOf(t.p);
15217
+ const lines = t.lines ?? t.text.split("\n"), blend = blendOf(t.p), y0 = t.ay + num2(t.p.dy, 0);
15218
+ let body = lines.map((l, i) => `<text x="${x0}" y="${r2(y0 + i * a.size * 1.3)}"${anchor} ${a.a}${blend}>${esc(l)}</text>`).join("\n");
14765
15219
  if (t.p.echo && t.p.echo !== "none") {
14766
15220
  const dx = num2(t.p["echo.dx"], 3), dy = num2(t.p["echo.dy"], 3), ea = a.a.replace(/fill="[^"]*"/, () => `fill="${col(look, t.p.echo)}"`);
14767
- body = lines.map((l, i) => `<text x="${t.ax + dx}" y="${r2(t.ay + dy + i * a.size * 1.3)}"${anchor} ${ea}>${esc(l)}</text>`).join("\n") + "\n" + body;
15221
+ body = lines.map((l, i) => `<text x="${x0 + dx}" y="${r2(y0 + dy + i * a.size * 1.3)}"${anchor} ${ea}>${esc(l)}</text>`).join("\n") + "\n" + body;
14768
15222
  }
14769
- return rot === 90 || rot === -90 ? `<g transform="rotate(${rot} ${t.ax} ${t.ay})">${body}</g>` : body;
15223
+ return rot ? `<g transform="rotate(${r2(rot)} ${t.ax} ${t.ay})">${body}</g>` : body;
14770
15224
  }
14771
15225
  function rgbOf(look, v, over2) {
14772
15226
  const c = color(look, v);
@@ -14841,7 +15295,7 @@ function footed(c, shapes) {
14841
15295
  if (Math.abs(q.x - n.x) > 0.5 || n.y < q.y) continue;
14842
15296
  for (const s of shapes) {
14843
15297
  const d = num2(s.p.depth, 0);
14844
- if (d > 0 && !s.back && Math.abs(q.y - (s.y + s.h)) < 1 && q.x > s.x && q.x < s.x + s.w && n.y - q.y > d + 6) {
15298
+ if (d > 0 && !s.back && !turnOf(s.p) && Math.abs(q.y - (s.y + s.h)) < 1 && q.x > s.x && q.x < s.x + s.w && n.y - q.y > d + 6) {
14845
15299
  q.y += d;
14846
15300
  moved = true;
14847
15301
  break;
@@ -14851,9 +15305,24 @@ function footed(c, shapes) {
14851
15305
  return moved ? { ...c, pts } : c;
14852
15306
  }
14853
15307
  var TEXT_STYLE = "font-variant-ligatures:none;text-rendering:geometricPrecision";
15308
+ var PAGE_MARKS = ["dots", "grid", "lines", "cross", "iso", "diag", "graph", "hex", "bars", "feed"];
15309
+ function pageMarks(look) {
15310
+ const cv = { ...look.canvas }, paper = rgbOf(look, cv.paper ?? "paper");
15311
+ if (!paper) return cv;
15312
+ for (const k of PAGE_MARKS) {
15313
+ const v = cv[k];
15314
+ if (!v || v === "none") continue;
15315
+ const i = v.lastIndexOf("/");
15316
+ if (i <= 0) continue;
15317
+ const rgb = rgbOf(look, v.slice(0, i));
15318
+ if (!rgb || contrast(rgb, paper) >= 3) continue;
15319
+ cv[k] = (contrast([255, 255, 255], paper) >= contrast([0, 0, 0], paper) ? "#ffffff" : "#000000") + v.slice(i);
15320
+ }
15321
+ return cv;
15322
+ }
14854
15323
  function renderBody(sc, background = true) {
14855
15324
  sc = legible(sc);
14856
- const look = sc.look, cv = look.canvas;
15325
+ const look = sc.look, cv = pageMarks(look);
14857
15326
  const out = [];
14858
15327
  R = { amt: Math.max(0, Math.min(num2(cv.sketch, 0), 4)), defs: /* @__PURE__ */ new Map() };
14859
15328
  if (background) out.push(`<rect class="fd-page" x="${sc.x}" y="${sc.y}" width="${sc.w}" height="${sc.h}" fill="${col(look, cv.paper ?? "paper")}"/>`);
@@ -14862,6 +15331,43 @@ function renderBody(sc, background = true) {
14862
15331
  out.push(`<defs><pattern id="fd-dots" width="${gap}" height="${gap}" patternUnits="userSpaceOnUse"><circle cx="1" cy="1" r="0.9" fill="${col(look, cv.dots)}"/></pattern></defs>`);
14863
15332
  out.push(`<rect class="fd-page" x="${sc.x}" y="${sc.y}" width="${sc.w}" height="${sc.h}" fill="url(#fd-dots)"/>`);
14864
15333
  }
15334
+ if (background && cv.grid && cv.grid !== "none") {
15335
+ const gap = Math.max(4, num2(cv.gridgap, 24));
15336
+ out.push(`<defs><pattern id="fd-grid" width="${gap}" height="${gap}" patternUnits="userSpaceOnUse"><path d="M ${gap},0 H 0 V ${gap}" fill="none" stroke="${col(look, cv.grid)}" stroke-width="1"/></pattern></defs>`);
15337
+ out.push(`<rect class="fd-page" x="${sc.x}" y="${sc.y}" width="${sc.w}" height="${sc.h}" fill="url(#fd-grid)"/>`);
15338
+ }
15339
+ if (background && cv.lines && cv.lines !== "none") {
15340
+ const gap = Math.max(4, num2(cv.linegap, 24));
15341
+ out.push(`<defs><pattern id="fd-lines" width="${gap}" height="${gap}" patternUnits="userSpaceOnUse"><rect y="${gap - 1}" width="${gap}" height="1" fill="${col(look, cv.lines)}"/></pattern></defs>`);
15342
+ out.push(`<rect class="fd-page" x="${sc.x}" y="${sc.y}" width="${sc.w}" height="${sc.h}" fill="url(#fd-lines)"/>`);
15343
+ }
15344
+ if (background && cv.cross && cv.cross !== "none") {
15345
+ const gap = Math.max(8, num2(cv.crossgap, 24)), c = gap / 2;
15346
+ out.push(`<defs><pattern id="fd-cross" x="${-c}" y="${-c}" width="${gap}" height="${gap}" patternUnits="userSpaceOnUse"><path d="M ${c - 3},${c} H ${c + 3} M ${c},${c - 3} V ${c + 3}" fill="none" stroke="${col(look, cv.cross)}" stroke-width="1"/></pattern></defs>`);
15347
+ out.push(`<rect class="fd-page" x="${sc.x}" y="${sc.y}" width="${sc.w}" height="${sc.h}" fill="url(#fd-cross)"/>`);
15348
+ }
15349
+ if (background && cv.iso && cv.iso !== "none") {
15350
+ const gap = Math.max(4, num2(cv.isogap, 24)), h = Math.round(gap * Math.sqrt(3) * 100) / 100;
15351
+ out.push(`<defs><pattern id="fd-iso" width="${gap}" height="${h}" patternUnits="userSpaceOnUse"><circle cx="${gap / 4}" cy="${h / 4}" r="0.9" fill="${col(look, cv.iso)}"/><circle cx="${gap * 3 / 4}" cy="${h * 3 / 4}" r="0.9" fill="${col(look, cv.iso)}"/></pattern></defs>`);
15352
+ out.push(`<rect class="fd-page" x="${sc.x}" y="${sc.y}" width="${sc.w}" height="${sc.h}" fill="url(#fd-iso)"/>`);
15353
+ }
15354
+ if (background && cv.diag && cv.diag !== "none") {
15355
+ const gap = Math.max(4, num2(cv.diaggap, 12));
15356
+ out.push(`<defs><pattern id="fd-diag" width="${gap}" height="${gap}" patternUnits="userSpaceOnUse" patternTransform="rotate(45)"><rect width="1" height="${gap}" fill="${col(look, cv.diag)}"/></pattern></defs>`);
15357
+ out.push(`<rect class="fd-page" x="${sc.x}" y="${sc.y}" width="${sc.w}" height="${sc.h}" fill="url(#fd-diag)"/>`);
15358
+ }
15359
+ if (background && cv.graph && cv.graph !== "none") {
15360
+ const gap = Math.max(4, num2(cv.graphgap, 10)), t = gap * 5, c = col(look, cv.graph);
15361
+ const minor = [1, 2, 3, 4].map((k) => `M ${k * gap},0 V ${t} M 0,${k * gap} H ${t}`).join(" ");
15362
+ out.push(`<defs><pattern id="fd-graph" width="${t}" height="${t}" patternUnits="userSpaceOnUse"><path d="${minor}" fill="none" stroke="${c}" stroke-width="0.5" stroke-opacity="0.6"/><path d="M 0,0.5 H ${t} M 0.5,0 V ${t}" fill="none" stroke="${c}" stroke-width="1"/></pattern></defs>`);
15363
+ out.push(`<rect class="fd-page" x="${sc.x}" y="${sc.y}" width="${sc.w}" height="${sc.h}" fill="url(#fd-graph)"/>`);
15364
+ }
15365
+ if (background && cv.hex && cv.hex !== "none") {
15366
+ const s = Math.max(4, num2(cv.hexgap, 14)), w = Math.round(s * Math.sqrt(3) * 100) / 100, m = w / 2;
15367
+ const d = `M ${m},0 V ${s / 2} L ${w},${s} V ${s * 2} L ${m},${s * 2.5} V ${s * 3} M ${m},${s * 2.5} L 0,${s * 2} V ${s} L ${m},${s / 2}`;
15368
+ out.push(`<defs><pattern id="fd-hex" width="${w}" height="${s * 3}" patternUnits="userSpaceOnUse"><path d="${d}" fill="none" stroke="${col(look, cv.hex)}" stroke-width="1"/></pattern></defs>`);
15369
+ out.push(`<rect class="fd-page" x="${sc.x}" y="${sc.y}" width="${sc.w}" height="${sc.h}" fill="url(#fd-hex)"/>`);
15370
+ }
14865
15371
  if (background && cv.bars && cv.bars !== "none") {
14866
15372
  const gap = Math.max(8, num2(cv.bargap, 32));
14867
15373
  out.push(`<defs><pattern id="fd-bars" width="${gap * 2}" height="${gap * 2}" patternUnits="userSpaceOnUse"><rect width="${gap * 2}" height="${gap}" fill="${col(look, cv.bars)}"/></pattern></defs>`);
@@ -14874,15 +15380,15 @@ function renderBody(sc, background = true) {
14874
15380
  out.push(`<rect class="fd-page" x="${sc.x}" y="${sc.y}" width="26" height="${sc.h}" fill="url(#fd-feed-l)"/><rect class="fd-page" x="${sc.x + sc.w - 26}" y="${sc.y}" width="26" height="${sc.h}" fill="url(#fd-feed-r)"/>`);
14875
15381
  out.push(`<path class="fd-page" d="M ${sc.x + 26},${sc.y} v ${sc.h} M ${sc.x + sc.w - 26},${sc.y} v ${sc.h}" stroke="${c}" stroke-width="1" stroke-dasharray="2 3" fill="none"/>`);
14876
15382
  }
14877
- for (const s of sc.shapes) if (s.back) out.push(drawShape(look, s));
15383
+ for (const s of sc.shapes) if (s.back) out.push(faded(s.p, turned(s, drawShape(look, s))));
14878
15384
  const conns = sc.shapes.some((s) => num2(s.p.depth, 0) > 0) ? sc.conns.map((c) => footed(c, sc.shapes)) : sc.conns;
14879
15385
  const under = conns.filter((c) => c.p.layer !== "front"), over2 = conns.filter((c) => c.p.layer === "front");
14880
- for (const c of under) out.push(drawConn(look, c));
14881
- for (const c of under) if (c.label) out.push(drawLabel(look, c));
14882
- for (const s of sc.shapes) if (!s.back) out.push(drawShape(look, s));
14883
- for (const c of over2) out.push(drawConn(look, c));
14884
- for (const c of over2) if (c.label) out.push(drawLabel(look, c));
14885
- for (const t of sc.texts) out.push(drawText(look, t));
15386
+ for (const c of under) out.push(faded(c.p, drawConn(look, c)));
15387
+ for (const c of under) if (c.label) out.push(faded(c.p, drawLabel(look, c)));
15388
+ for (const s of sc.shapes) if (!s.back) out.push(faded(s.p, turned(s, drawShape(look, s))));
15389
+ for (const c of over2) out.push(faded(c.p, drawConn(look, c)));
15390
+ for (const c of over2) if (c.label) out.push(faded(c.p, drawLabel(look, c)));
15391
+ for (const t of sc.texts) out.push(faded(t.p, drawText(look, t)));
14886
15392
  if (background && num2(cv.grain, 0) > 0) {
14887
15393
  out.push(`<defs><filter id="fd-grain" x="0" y="0" width="100%" height="100%"><feTurbulence type="fractalNoise" baseFrequency="1.1" numOctaves="2" seed="4"/><feColorMatrix values="0 0 0 0 .25 0 0 0 0 .22 0 0 0 0 .2 0 0 0 .5 -.2"/></filter></defs>`);
14888
15394
  out.push(`<rect class="fd-page" x="${sc.x}" y="${sc.y}" width="${sc.w}" height="${sc.h}" filter="url(#fd-grain)" opacity="${Math.min(1, num2(cv.grain, 0))}" pointer-events="none"/>`);
@@ -14905,6 +15411,29 @@ var hasPt = (b, p) => p.x >= b.x && p.x <= b.x + b.w && p.y >= b.y && p.y <= b.y
14905
15411
  var inset = (b, n) => ({ x: b.x + n, y: b.y + n, w: b.w - 2 * n, h: b.h - 2 * n });
14906
15412
  var name = (c) => c.id.startsWith("_") ? `${c.a.raw} ${c.head ? "->" : "--"} ${c.b.raw}` : c.id;
14907
15413
  var tiny = (s) => Math.min(s.w, s.h) <= 12;
15414
+ var turned2 = (s) => turnOf(s.p) !== 0;
15415
+ var local = (s, p) => turned2(s) ? turnPt(p, { x: s.x + s.w / 2, y: s.y + s.h / 2 }, -turnOf(s.p)) : p;
15416
+ var corners = (b, turn = 0) => {
15417
+ const q = [{ x: b.x, y: b.y }, { x: b.x + b.w, y: b.y }, { x: b.x + b.w, y: b.y + b.h }, { x: b.x, y: b.y + b.h }];
15418
+ return turn ? q.map((p) => turnPt(p, { x: b.x + b.w / 2, y: b.y + b.h / 2 }, turn)) : q;
15419
+ };
15420
+ function meets(b, bTurn, s, pad) {
15421
+ if (!bTurn && !turned2(s)) return inter(b, s, pad);
15422
+ const P = corners(inset(b, pad), bTurn), Q = corners(s, turnOf(s.p));
15423
+ for (const [A, B] of [[P[0], P[1]], [P[1], P[2]], [Q[0], Q[1]], [Q[1], Q[2]]]) {
15424
+ const ax = B.x - A.x, ay = B.y - A.y, along = (p2) => p2.x * ax + p2.y * ay;
15425
+ const p = P.map(along), q = Q.map(along);
15426
+ if (Math.max(...p) <= Math.min(...q) || Math.max(...q) <= Math.min(...p)) return false;
15427
+ }
15428
+ return true;
15429
+ }
15430
+ var hasPtIn = (s, p) => hasPt(s, local(s, p));
15431
+ function textFrame(t) {
15432
+ const f = t.frame, turn = turnOf(t.p);
15433
+ if (!f) return [t, 0];
15434
+ const m = turnPt({ x: f.x + f.w / 2, y: f.y + f.h / 2 }, { x: t.ax, y: t.ay }, turn);
15435
+ return [{ x: m.x - f.w / 2, y: m.y - f.h / 2, w: f.w, h: f.h }, turn];
15436
+ }
14908
15437
  var isLine = (s) => !!s.poly && s.p.open === "1";
14909
15438
  function rgba(look, v) {
14910
15439
  const c = color(look, v);
@@ -14937,7 +15466,12 @@ function check(sc) {
14937
15466
  const front = sc.shapes.filter((s) => !s.back);
14938
15467
  for (let i = 0; i < front.length; i++) for (let j = i + 1; j < front.length; j++) {
14939
15468
  const a = front[i], b = front[j];
14940
- if (!inter(a, b, 0.5) || contains(a, b) || contains(b, a) || a.p.overlap === "ok" || b.p.overlap === "ok") continue;
15469
+ if (a.p.overlap === "ok" || b.p.overlap === "ok") continue;
15470
+ if (turned2(a) || turned2(b)) {
15471
+ if (meets(a, turnOf(a.p), b, 0.5) && !corners(b, turnOf(b.p)).every((p) => hasPtIn(a, p)) && !corners(a, turnOf(a.p)).every((p) => hasPtIn(b, p))) warn(b.line, `${b.id} overlaps ${a.id}; move one of them`);
15472
+ continue;
15473
+ }
15474
+ if (!inter(a, b, 0.5) || contains(a, b) && a.shape !== "chart" || contains(b, a) && b.shape !== "chart") continue;
14941
15475
  const ox = Math.min(a.x + a.w, b.x + b.w) - Math.max(a.x, b.x), oy = Math.min(a.y + a.h, b.y + b.h) - Math.max(a.y, b.y);
14942
15476
  warn(b.line, `${b.id} overlaps ${a.id} by ${Math.round(Math.min(ox, oy))}px; move one of them`);
14943
15477
  }
@@ -14946,7 +15480,7 @@ function check(sc) {
14946
15480
  for (const s of front) {
14947
15481
  if (s.rows || s.shape === "legend" || s.shape === "chart" || s.p["title.pos"] === "top") continue;
14948
15482
  const cxs = s.x + s.w / 2, cys = s.y + s.h / 2, at = sc.shapes.indexOf(s);
14949
- const below = fillOf(s) ? void 0 : sc.shapes.slice(0, at).reverse().find((o) => !o.back && !o.rows && fillOf(o) && cxs >= o.x && cxs <= o.x + o.w && cys >= o.y && cys <= o.y + o.h);
15483
+ const below = fillOf(s) ? void 0 : sc.shapes.slice(0, at).reverse().find((o) => !o.back && !o.rows && fillOf(o) && hasPtIn(o, { x: cxs, y: cys }));
14950
15484
  const bg = fillOf(s) ?? (below ? fillOf(below) : paperRgb);
14951
15485
  for (const [what, has, key, dflt] of [["text", s.text, "title.color", "ink"], ["second line", s.p.sub, "sub.color", "muted"]]) {
14952
15486
  const fg = rgba(sc.look, s.p[key] ?? dflt);
@@ -14955,7 +15489,7 @@ function check(sc) {
14955
15489
  }
14956
15490
  for (const t of sc.texts) {
14957
15491
  const mx = t.x + t.w / 2, my = t.y + t.h / 2;
14958
- const under = [...sc.shapes].reverse().find((s) => !s.rows && s.shape !== "legend" && s.shape !== "chart" && fillOf(s) && mx >= s.x && mx <= s.x + s.w && my >= s.y && my <= s.y + s.h);
15492
+ const under = [...sc.shapes].reverse().find((s) => !s.rows && s.shape !== "legend" && s.shape !== "chart" && fillOf(s) && hasPtIn(s, { x: mx, y: my }));
14959
15493
  const fg = rgba(sc.look, t.p.color ?? "ink");
14960
15494
  if (!fg || fg[3] <= 0.3) continue;
14961
15495
  const bg = under ? fillOf(under) : paperRgb;
@@ -14968,7 +15502,7 @@ function check(sc) {
14968
15502
  if (s.shape === "icon") continue;
14969
15503
  const p = s.p;
14970
15504
  if (s.text && p["title.pos"] !== "top") {
14971
- const size = num3(p["title.size"], 12), ib = iconBox(s), room = (s.shape === "diamond" || s.shape === "ellipse" ? s.w * 0.72 : s.w - 16) - (ib && ib.dx ? ib.size + 8 + 8 : 0);
15505
+ const size = num3(p["title.size"], 12), ib = iconBox(s), room = (s.shape === "diamond" || s.shape === "ellipse" ? s.w * 0.72 : s.w - 16) - (ib?.block ? ib.block + 4 : ib && ib.dx ? ib.size + 8 + 8 : 0);
14972
15506
  for (const l of s.text.split("\n")) {
14973
15507
  const tw = textWidth(l, size, p["title.font"] ?? "sans", num3(p["title.weight"], 600), num3(p["title.spacing"], 0));
14974
15508
  if (tw > room) warn(s.line, `text "${l}" (~${Math.round(tw)}px) does not fit in ${s.id} (${Math.round(room)}px of room); widen it or break the line with \\n`);
@@ -14977,7 +15511,7 @@ function check(sc) {
14977
15511
  const ic = iconBox(s);
14978
15512
  if (ic && ic.dy > 0) {
14979
15513
  const lines = s.text ? s.text.split("\n").length : 0, subs = p.sub ? p.sub.split("\n").length : 0;
14980
- const need = Math.ceil((lines * Math.round(num3(p["title.size"], 12) * 1.17) + (subs ? num3(p["sub.size"], 9) + 7 + (subs - 1) * Math.round(num3(p["sub.size"], 9) * 1.3) : 0) + ic.size + 6 + 16) / 4) * 4;
15514
+ const need = Math.ceil((lines * Math.round(num3(p["title.size"], 12) * 1.17) + (subs ? num3(p["sub.size"], 9) + 7 + (subs - 1) * Math.round(num3(p["sub.size"], 9) * 1.3) : 0) + (ic.room ?? ic.size) + 6 + 16) / 4) * 4;
14981
15515
  if (s.h < need) warn(s.line, `the icon and text of ${s.id} need ${need}px of height; make it taller or use icon.pos=left`);
14982
15516
  } else if (ic && ic.size + 8 > Math.min(s.w, s.h) && s.style !== "icon") warn(s.line, `the ${ic.size}px icon does not fit in ${s.id}; make the box bigger or set icon.size=`);
14983
15517
  for (const l of p.sub ? p.sub.split("\n") : []) {
@@ -14995,14 +15529,14 @@ function check(sc) {
14995
15529
  const seen = /* @__PURE__ */ new Set();
14996
15530
  for (let i = 0; i < front.length; i++) for (let j = i + 1; j < front.length; j++) {
14997
15531
  const a = front[i], b = front[j];
14998
- if (tiny(a) || tiny(b) || contains(a, b) || contains(b, a) || a.p.overlap === "ok" || b.p.overlap === "ok") continue;
14999
- const pairs = [
15532
+ if (tiny(a) || tiny(b) || turned2(a) || turned2(b) || contains(a, b) || contains(b, a) || a.p.overlap === "ok" || b.p.overlap === "ok") continue;
15533
+ const pairs2 = [
15000
15534
  ["top edges", a.y, b.y],
15001
15535
  ["vertical centres", a.y + a.h / 2, b.y + b.h / 2],
15002
15536
  ["left edges", a.x, b.x],
15003
15537
  ["horizontal centres", a.x + a.w / 2, b.x + b.w / 2]
15004
15538
  ];
15005
- for (const [what, va, vb] of pairs) {
15539
+ for (const [what, va, vb] of pairs2) {
15006
15540
  const d = Math.abs(va - vb);
15007
15541
  if (d > 0 && d <= 3 && !seen.has(a.id + b.id)) {
15008
15542
  seen.add(a.id + b.id);
@@ -15018,8 +15552,8 @@ function check(sc) {
15018
15552
  for (const s of front) {
15019
15553
  if (c.p.layer === "back" || c.p.layer === "front") break;
15020
15554
  if (s.id === c.a.id || s.id === c.b.id || tiny(s) || hit.has(s.id) || isLine(s)) continue;
15021
- if (hasPt(s, c.pts[0]) || hasPt(s, c.pts[c.pts.length - 1])) continue;
15022
- if (segHits(A2, B, inset(s, 1))) {
15555
+ if (hasPtIn(s, c.pts[0]) || hasPtIn(s, c.pts[c.pts.length - 1])) continue;
15556
+ if (segHits(local(s, A2), local(s, B), inset(s, 1))) {
15023
15557
  hit.add(s.id);
15024
15558
  warn(c.line, `${name(c)} passes through ${s.id}; route around it with from=/to= sides or via=x,y`);
15025
15559
  }
@@ -15028,9 +15562,9 @@ function check(sc) {
15028
15562
  const first = c.pts[0], last = c.pts[c.pts.length - 1];
15029
15563
  const l = c.label;
15030
15564
  if (!l) continue;
15031
- for (const s of front) if (!tiny(s) && !isLine(s) && inter(l, s, 1)) warn(c.line, `label "${l.text}" of ${name(c)} collides with ${s.id}; shorten it, move things apart, or place it with lpos=x,y or lside=below|left`);
15565
+ for (const s of front) if (!tiny(s) && !isLine(s) && meets(l, 0, s, 1)) warn(c.line, `label "${l.text}" of ${name(c)} collides with ${s.id}; shorten it, move things apart, or place it with lpos=x,y or lside=below|left`);
15032
15566
  for (const z of sc.shapes) {
15033
- if (!z.back || !inter(l, z, 0) || contains(z, l)) continue;
15567
+ if (!z.back || !meets(l, 0, z, 0) || corners(l).every((p) => hasPtIn(z, p))) continue;
15034
15568
  warn(c.line, `label "${l.text}" of ${name(c)} sits on the border of ${z.id}; place it on a clear stretch of the line with lpos=x,y`);
15035
15569
  }
15036
15570
  for (let i = 0; i < c.pts.length - 1; i++) {
@@ -15080,7 +15614,9 @@ function check(sc) {
15080
15614
  }
15081
15615
  }
15082
15616
  for (const t of sc.texts) {
15083
- for (const s of front) if (!tiny(s) && s.shape !== "chart" && s.p.overlap !== "ok" && t.p.overlap !== "ok" && inter(t, s, 1) && !contains(s, t)) warn(t.line, `text ${t.id} overlaps ${s.id}`);
15617
+ const [tb, tt] = textFrame(t), tc = corners(tb, tt);
15618
+ for (const s of front) if (!tiny(s) && s.shape !== "chart" && s.p.overlap !== "ok" && t.p.overlap !== "ok" && meets(tb, tt, s, 1) && !tc.every((p) => hasPtIn(s, p))) warn(t.line, `text ${t.id} overlaps ${s.id}`);
15619
+ for (const s of front) if (s.shape === "chart" && !turned2(s) && s.p.overlap !== "ok" && t.p.overlap !== "ok" && chartMarks(s).some((m) => meets(tb, tt, { ...s, ...m, p: {} }, 1))) warn(t.line, `text ${t.id} sits on the bars or dots of chart ${s.id}; move it to a clear part of the chart or outside it`);
15084
15620
  for (const o of sc.texts) if (o.line > t.line && inter(t, o, 1) && t.p.overlap !== "ok" && o.p.overlap !== "ok") warn(o.line, `text ${o.id} overlaps text ${t.id}`);
15085
15621
  }
15086
15622
  if (sc.canvasSize && sc.canvasLine) hint(sc.canvasLine, "the canvas has no size any more: the picture is as big as what is drawn, plus a margin; remove WxH from this line");
@@ -15276,13 +15812,27 @@ ${kind} styles`);
15276
15812
  }
15277
15813
  out.push("\nfonts");
15278
15814
  for (const [role, fam2] of look.fonts) out.push(` ${role.padEnd(12)} ${fam2}${missingFonts.includes(fam2) ? " (no font file found: will fall back)" : ""}`);
15279
- const own = [...look.images.keys()];
15815
+ const own = [...look.images.keys()].filter((n) => !look.iconUrls.has(n));
15816
+ const sets = look.iconDirs.filter((d) => /^https:/i.test(d));
15817
+ if (sets.length || look.iconUrls.size) {
15818
+ out.push("\nicons from the web (icon=name)");
15819
+ if (look.iconUrls.size) out.push(` ${[...look.iconUrls.keys()].join(", ")}`);
15820
+ const listed = look.listedIcons ?? [];
15821
+ if (listed.length) out.push(` ${listed.slice(0, 60).join(", ")}${listed.length > 60 ? `, and ${listed.length - 60} more ("fastdraw icons <look> [word]" lists or searches them)` : ""}`);
15822
+ for (const d of sets) out.push(` from ${d.includes("{name}") ? d : d.replace(/\/+$/, "") + "/{name}.svg"}${listed.length ? "" : ", any file by its name"}`);
15823
+ }
15280
15824
  if (own.length) out.push(`
15281
15825
  icons from the look's folders (${own.length}; "fastdraw icons <look> [word]" lists or searches them)
15282
15826
  ${own.slice(0, 60).join(", ")}${own.length > 60 ? ", ..." : ""}`);
15283
- out.push(`
15827
+ const outlines = [...look.icons.keys()].filter((n) => !look.hideBuiltIns || !isBuiltIn(look, n) && !look.images.has(n));
15828
+ if (look.hideBuiltIns) {
15829
+ if (outlines.length) out.push(`
15830
+ the look's own outline icons
15831
+ ${outlines.join(", ")}`);
15832
+ out.push("\nbuilt-in icons: hidden by this look (icons builtin=hidden); use the icons above");
15833
+ } else out.push(`
15284
15834
  ${own.length ? "built-in icons" : "icons"} (icon=name on any box, or a box of style "icon")
15285
- ${[...look.icons.keys()].join(", ")}`);
15835
+ ${outlines.join(", ")}`);
15286
15836
  if (look.guidance.length) {
15287
15837
  out.push("\nguidance from this look");
15288
15838
  for (const g of look.guidance) out.push(` - ${g}`);
@@ -15299,9 +15849,9 @@ function about(md, name2) {
15299
15849
  }
15300
15850
 
15301
15851
  // src/setup.ts
15302
- import { readFileSync as readFileSync3, writeFileSync as writeFileSync3, existsSync as existsSync3, mkdirSync, realpathSync as realpathSync3, lstatSync as lstatSync3 } from "node:fs";
15852
+ import { readFileSync as readFileSync3, writeFileSync as writeFileSync3, existsSync as existsSync3, mkdirSync as mkdirSync2, realpathSync as realpathSync3, lstatSync as lstatSync3 } from "node:fs";
15303
15853
  import { dirname as dirname3, join as join3, relative as relative2, resolve as resolve3, sep as sep3 } from "node:path";
15304
- import { homedir } from "node:os";
15854
+ import { homedir as homedir2 } from "node:os";
15305
15855
  var TARGETS = ["claude", "agents", "copilot"];
15306
15856
  var START = "<!-- fastdraw:start -->";
15307
15857
  var END = "<!-- fastdraw:end -->";
@@ -15332,7 +15882,7 @@ function prepare(base, file) {
15332
15882
  const real = realpathSync3(at);
15333
15883
  if (!st.isDirectory() || real !== top && !real.startsWith(top + sep3)) refuse();
15334
15884
  }
15335
- if (!st && i < parts.length - 1) mkdirSync(at);
15885
+ if (!st && i < parts.length - 1) mkdirSync2(at);
15336
15886
  }
15337
15887
  }
15338
15888
  function upsert(base, file, body, version) {
@@ -15363,13 +15913,13 @@ function detect(dir) {
15363
15913
  }
15364
15914
  function setup(root2, dir, targets, global = false) {
15365
15915
  const lines = [], version = packageVersion(root2);
15366
- const show = (f) => f.startsWith(dir) ? relative2(dir, f) : f.replace(homedir(), "~");
15916
+ const show = (f) => f.startsWith(dir) ? relative2(dir, f) : f.replace(homedir2(), "~");
15367
15917
  for (const t of targets) {
15368
15918
  if (t === "claude") {
15369
- const base = global ? join3(homedir(), ".claude") : dir;
15919
+ const base = global ? join3(homedir2(), ".claude") : dir;
15370
15920
  const file = join3(global ? base : join3(dir, ".claude"), "skills", "fastdraw", "SKILL.md");
15371
15921
  const was = existsSync3(file);
15372
- if (global) mkdirSync(base, { recursive: true });
15922
+ if (global) mkdirSync2(base, { recursive: true });
15373
15923
  prepare(base, file);
15374
15924
  const skill = readFileSync3(join3(root2, "plugins", "fastdraw", "skills", "fastdraw", "SKILL.md"), "utf8");
15375
15925
  writeFileSync3(file, skill.replace(/^(---\r?\n[\s\S]*?\r?\n---\r?\n)/, `$1${stamp(version)}
@@ -15387,7 +15937,7 @@ function compareVersions(a, b) {
15387
15937
  for (let i = 0; i < Math.max(x.length, y.length); i++) if ((x[i] ?? 0) !== (y[i] ?? 0)) return (x[i] ?? 0) - (y[i] ?? 0);
15388
15938
  return 0;
15389
15939
  }
15390
- function installedSkills(dir, home = homedir()) {
15940
+ function installedSkills(dir, home = homedir2()) {
15391
15941
  const out = [];
15392
15942
  const look = (target, file, global = false, section = false) => {
15393
15943
  let text;
@@ -15408,14 +15958,14 @@ function installedSkills(dir, home = homedir()) {
15408
15958
  if (resolve3(home) !== resolve3(dir)) look("claude", join3(home, ".claude", "skills", "fastdraw", "SKILL.md"), true);
15409
15959
  return out;
15410
15960
  }
15411
- function skillNotes(root2, dir, home = homedir()) {
15961
+ function skillNotes(root2, dir, home = homedir2()) {
15412
15962
  const version = packageVersion(root2), found = installedSkills(dir, home), notes = [];
15413
15963
  const from = (fs) => [...new Set(fs.map((f) => f.version || "0.2.0 or earlier"))].join(", ");
15414
15964
  const old = found.filter((f) => !f.version || compareVersions(f.version, version) < 0);
15415
- const local = old.filter((f) => !f.global), global = old.filter((f) => f.global);
15416
- if (local.length) {
15417
- const files = local.map((f) => relative2(resolve3(dir), f.file) || f.file).join(", ");
15418
- notes.push(`Note: this repository's FastDraw instructions (${files}) are from version ${from(local)}; this fastdraw is ${version}. Tell the person, and to update them run in the repository: npx fastdraw@latest setup ${[...new Set(local.map((f) => f.target))].join(" ")}`);
15965
+ const local2 = old.filter((f) => !f.global), global = old.filter((f) => f.global);
15966
+ if (local2.length) {
15967
+ const files = local2.map((f) => relative2(resolve3(dir), f.file) || f.file).join(", ");
15968
+ notes.push(`Note: this repository's FastDraw instructions (${files}) are from version ${from(local2)}; this fastdraw is ${version}. Tell the person, and to update them run in the repository: npx fastdraw@latest setup ${[...new Set(local2.map((f) => f.target))].join(" ")}`);
15419
15969
  }
15420
15970
  if (global.length) {
15421
15971
  notes.push(`Note: the FastDraw skill in ${global[0].file.replace(home, "~")} is from version ${from(global)}; this fastdraw is ${version}. Tell the person, and to update it run: npx fastdraw@latest setup claude --global`);
@@ -15428,12 +15978,12 @@ function skillNotes(root2, dir, home = homedir()) {
15428
15978
  }
15429
15979
 
15430
15980
  // src/update.ts
15431
- import { mkdirSync as mkdirSync2, readFileSync as readFileSync4, writeFileSync as writeFileSync4 } from "node:fs";
15981
+ import { mkdirSync as mkdirSync3, readFileSync as readFileSync4, writeFileSync as writeFileSync4 } from "node:fs";
15432
15982
  import { dirname as dirname4, join as join4 } from "node:path";
15433
- import { homedir as homedir2 } from "node:os";
15983
+ import { homedir as homedir3 } from "node:os";
15434
15984
  var DAY = 24 * 60 * 60 * 1e3;
15435
15985
  var URL2 = "https://registry.npmjs.org/fastdraw/latest";
15436
- function cacheFile(env = process.env, home = homedir2(), platform = process.platform) {
15986
+ function cacheFile(env = process.env, home = homedir3(), platform = process.platform) {
15437
15987
  const base = platform === "win32" ? env.LOCALAPPDATA ?? join4(home, "AppData", "Local") : platform === "darwin" ? join4(home, "Library", "Caches") : env.XDG_CACHE_HOME ?? join4(home, ".cache");
15438
15988
  return join4(base, "fastdraw", "latest.json");
15439
15989
  }
@@ -15445,20 +15995,20 @@ async function fromRegistry() {
15445
15995
  async function newerVersion(current, o = {}) {
15446
15996
  const env = o.env ?? process.env, now = o.now ?? Date.now(), file = o.file ?? cacheFile(env);
15447
15997
  if (env.FASTDRAW_NO_UPDATE_CHECK || env.CI) return null;
15448
- let cached = null;
15998
+ let cached2 = null;
15449
15999
  try {
15450
- cached = JSON.parse(readFileSync4(file, "utf8"));
16000
+ cached2 = JSON.parse(readFileSync4(file, "utf8"));
15451
16001
  } catch {
15452
16002
  }
15453
- let latest = cached?.latest ?? null;
15454
- if (!cached || !(now - cached.checked < DAY)) {
16003
+ let latest = cached2?.latest ?? null;
16004
+ if (!cached2 || !(now - cached2.checked < DAY)) {
15455
16005
  try {
15456
16006
  latest = await (o.fetchLatest ?? fromRegistry)();
15457
16007
  } catch {
15458
16008
  latest = null;
15459
16009
  }
15460
16010
  try {
15461
- mkdirSync2(dirname4(file), { recursive: true });
16011
+ mkdirSync3(dirname4(file), { recursive: true });
15462
16012
  writeFileSync4(file, JSON.stringify({ checked: now, latest }));
15463
16013
  } catch {
15464
16014
  }
@@ -15498,13 +16048,16 @@ function usage() {
15498
16048
  check <file.fdraw | folder> ... report problems, with line numbers. A folder means every
15499
16049
  .fdraw file under it
15500
16050
  render <file.fdraw | folder> ... [-o out.png|.svg] [--scale 2] [--transparent] [--no-embed]
15501
- [--look name|file.look] [--dark]
16051
+ [--look name|file.look|https://...look] [--dark] [--offline]
15502
16052
  draw the diagram (PNG by default) next to it. With several
15503
16053
  files or a folder, checks them all first and draws nothing
15504
16054
  if any has an error. --look draws with another look instead
15505
16055
  of the file's own. --dark also writes x-dark.png with the
15506
16056
  look's dark version (the look's dark line; Night for the
15507
- built-in look)
16057
+ built-in look). A look named by https:// address (one on
16058
+ GitHub, say), and the icons and fonts a look names that way,
16059
+ are fetched and kept in a cache folder; --offline (also for
16060
+ check) uses only what is already there
15508
16061
  sizes [file.fdraw | file.look] list the look's styles and their sizes
15509
16062
  (the built-in look when no file is given)
15510
16063
  init-look [path] write the built-in look to a file to make your own
@@ -15555,9 +16108,23 @@ function diagramFiles(paths) {
15555
16108
  }
15556
16109
  var VALUE_FLAGS = ["-o", "--scale", "--look", "--editor"];
15557
16110
  var positional = (a) => a.filter((x, i) => !x.startsWith("-") && !VALUE_FLAGS.includes(a[i - 1]));
16111
+ var fetchWeb = async (files) => {
16112
+ const li = args.indexOf("--look"), over2 = li >= 0 && args[li + 1] ? [args[li + 1]] : [];
16113
+ for (const n of await fetchWebAssets(files, args.includes("--offline"), over2)) console.log(`note: ${n}`);
16114
+ };
16115
+ if (cmd === "sizes" || cmd === "icons" || cmd === "preview-look") {
16116
+ const i = args.findIndex((a, j) => isWebLook(a) && args[j - 1] !== "-o");
16117
+ if (i >= 0) {
16118
+ const url = args[i];
16119
+ for (const n of await fetchWebAssets([], args.includes("--offline"), [url])) console.log(`note: ${n}`);
16120
+ if (cmd === "preview-look" && !args.includes("-o")) args.push("-o", url.replace(/[?#].*$/, "").replace(/^.*\//, "").replace(/\.look$/i, "") + "-preview.png");
16121
+ args[i] = webLookFile(url);
16122
+ }
16123
+ }
15558
16124
  if (cmd === "check") {
15559
16125
  const { files, many } = diagramFiles(positional(args));
15560
16126
  if (!files.length) usage();
16127
+ await fetchWeb(files);
15561
16128
  if (!many) process.exit(report(files[0]).errors ? 1 : 0);
15562
16129
  let errors = 0, warns = 0, hints = 0;
15563
16130
  for (const f of files) {
@@ -15574,6 +16141,7 @@ ${files.length} files: ${errors} error(s), ${warns} warning(s), ${hints} hint(s)
15574
16141
  } else if (cmd === "render") {
15575
16142
  const { files, many } = diagramFiles(positional(args));
15576
16143
  if (!files.length) usage();
16144
+ await fetchWeb(files);
15577
16145
  const oi = args.indexOf("-o"), si = args.indexOf("--scale"), li = args.indexOf("--look");
15578
16146
  if (oi >= 0 && many) {
15579
16147
  console.log("-o names one output file, so it works with one diagram; leave it out to write each PNG next to its diagram");
@@ -15587,7 +16155,7 @@ ${files.length} files: ${errors} error(s), ${warns} warning(s), ${hints} hint(s)
15587
16155
  const transparent = args.includes("--transparent"), embed = !args.includes("--no-embed"), dark = args.includes("--dark");
15588
16156
  let lookOver;
15589
16157
  if (li >= 0) {
15590
- const r = args[li + 1] ? lookArg(args[li + 1]) : "give --look the name of a look that ships with FastDraw, or a path to a .look file";
16158
+ const r = args[li + 1] ? lookArg(args[li + 1]) : "give --look the name of a look that ships with FastDraw, a path to a .look file, or the https address of one";
15591
16159
  if (typeof r === "string") {
15592
16160
  console.log(r);
15593
16161
  process.exit(1);
@@ -15655,6 +16223,7 @@ ${files.length} files: ${errors} error(s), ${warns} warning(s), ${hints} hint(s)
15655
16223
  console.log(`wrote ${out} (${sc.w}x${sc.h}${notes.length ? ", " + notes.join(", ") : ""})`);
15656
16224
  }
15657
16225
  } else if (cmd === "sizes") {
16226
+ if (args[0]) await fetchWeb([args[0]]);
15658
16227
  const look = !args[0] ? defaultLook() : args[0].endsWith(".look") ? loadLook(args[0]) : loadScene(args[0]).look;
15659
16228
  const lf = lookFonts(!args[0] ? void 0 : args[0].endsWith(".look") ? args[0] : lookFileOf(args[0]), look);
15660
16229
  console.log(sizesReport(look, lf.missing));
@@ -15670,6 +16239,7 @@ ${files.length} files: ${errors} error(s), ${warns} warning(s), ${hints} hint(s)
15670
16239
  const file = args.find((a, i) => !a.startsWith("-") && args[i - 1] !== "-o");
15671
16240
  const oi = args.indexOf("-o");
15672
16241
  const out = oi >= 0 ? args[oi + 1] : (file ? file.replace(/\.look$/, "") : "default") + "-preview.png";
16242
+ if (file) await fetchWeb([file]);
15673
16243
  const look = file ? loadLook(file) : defaultLook();
15674
16244
  const errs = look.issues.filter((i) => i.level === "error");
15675
16245
  if (errs.length) {
@@ -15735,13 +16305,21 @@ ${files.length} files: ${errors} error(s), ${warns} warning(s), ${hints} hint(s)
15735
16305
  });
15736
16306
  y += 60;
15737
16307
  heading("Icons");
15738
- [...look.icons.keys()].filter((n) => NAMED_ICONS.has(n) || !isBuiltIn(look, n)).forEach((n, i) => {
16308
+ const ownIcons = [.../* @__PURE__ */ new Set([...look.iconUrls.keys(), ...[...look.images.keys()].sort(), ...look.listedIcons ?? [], ...[...look.icons.keys()].filter((n) => !isBuiltIn(look, n))])].filter((n) => look.images.has(n) || look.icons.has(n)).slice(0, PREVIEW_ICONS);
16309
+ const sheetIcons = ownIcons.length || look.hideBuiltIns ? ownIcons : [...look.icons.keys()].filter((n) => NAMED_ICONS.has(n));
16310
+ sheetIcons.forEach((n, i) => {
15739
16311
  const cx2 = 40 + i % 11 * 80;
15740
16312
  if (i && i % 11 === 0) y += 60;
15741
16313
  L.push(`icon at ${cx2 + 20},${y} icon=${n}`);
15742
- L.push(`text ${JSON.stringify(n)} at ${cx2 + 32},${y + 40} size=8 color=muted font=sans anchor=middle`);
16314
+ L.push(`text ${JSON.stringify(n.length > 17 ? n.slice(0, 16) + "\u2026" : n)} at ${cx2 + 32},${y + 40} size=8 color=muted font=sans anchor=middle`);
15743
16315
  });
15744
16316
  y += 76;
16317
+ if (ownIcons.length) {
16318
+ const total = (/* @__PURE__ */ new Set([...look.images.keys(), ...look.iconUrls.keys(), ...look.listedIcons ?? []])).size;
16319
+ y += 8;
16320
+ L.push(`text ${JSON.stringify(`${total > ownIcons.length ? `the first ${ownIcons.length} of the look's ${total} icons; ` : ""}${look.hideBuiltIns ? "the look hides the built-in icons (icons builtin=hidden); a diagram that uses one still draws" : `the built-in icons work too: fastdraw icons ${basename2(file ?? "")} <word> finds them all`}`)} at 40,${y - 20} size=10 color=muted font=sans`);
16321
+ y += 12;
16322
+ }
15745
16323
  heading("Text");
15746
16324
  for (const s of all.filter((t) => t.kind === "text")) {
15747
16325
  const size = +(s.props.size ?? 12);
@@ -15770,8 +16348,9 @@ ${files.length} files: ${errors} error(s), ${warns} warning(s), ${hints} hint(s)
15770
16348
  console.log(`wrote ${out}: ${all.length} styles`);
15771
16349
  } else if (cmd === "icons") {
15772
16350
  const file = args[0]?.endsWith(".look") ? args[0] : void 0, word = (file ? args[1] : args[0])?.toLowerCase();
16351
+ if (file) await fetchWeb([file]);
15773
16352
  const look = file ? loadLook(file) : defaultLook();
15774
- const names = [.../* @__PURE__ */ new Set([...look.images.keys(), ...look.icons.keys()])].filter((n) => !word || iconMatches(n, word));
16353
+ const names = [.../* @__PURE__ */ new Set([...look.images.keys(), ...look.iconUrls.keys(), ...look.listedIcons ?? [], ...[...look.icons.keys()].filter((n) => !(look.hideBuiltIns && isBuiltIn(look, n)))])].filter((n) => !word || iconMatches(n, word));
15775
16354
  console.log(names.length ? names.join("\n") : `no icon${word ? ` for "${word}"` : ""}`);
15776
16355
  } else if (cmd === "guide") {
15777
16356
  const topic = args[0];