fastdraw 0.2.2 → 0.3.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
@@ -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,334 +11472,27 @@ 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
11496
  night: `// Night: the built-in look after dark. 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
11498
  // main path. Same styles as the built-in look, so a diagram moves between them without changes.
@@ -11897,82 +11590,6 @@ guidance "tag= is a 3 or 4 letter type marker in the corner of a box (EXT, EDGE,
11897
11590
  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
11591
  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
11592
  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
11593
  `,
11977
11594
  reference: `// Reference look for the quality comparison.
11978
11595
  // It mirrors the palette and type of diagram-design's default skin so the two can be
@@ -12236,82 +11853,6 @@ guidance "focal, terminal-focal and primary are the accent blue. Use the accent
12236
11853
  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."
12237
11854
  guidance "hatch=colour fills a shape with pencil hatching; hatch.gap spaces the lines."
12238
11855
  guidance "Finish with a legend: one statement, 'legend at x,y' followed by style=\\"what it means\\" for each style you used."
12239
- `,
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.
12242
-
12243
- canvas paper=paper
12244
-
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
12256
-
12257
- font sans "Geist"
12258
- font mono "Geist Mono"
12259
- font serif "Newsreader"
12260
-
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"
12272
-
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"
12278
-
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"
12288
-
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"
12298
-
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"
12308
-
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."
12314
- guidance "Finish with a legend: one statement, 'legend at x,y' followed by style=\\"what it means\\" for each style you used."
12315
11856
  `,
12316
11857
  whiteboard: `// Whiteboard: an online-whiteboard look. A white board with a light dot grid, white rounded
12317
11858
  // shapes with a dark outline, pastel sticky notes for the kinds of thing, curved dark connectors,
@@ -12487,20 +12028,27 @@ function emptyLook() {
12487
12028
  styles: /* @__PURE__ */ new Map(),
12488
12029
  icons: new Map(Object.entries(ICONS)),
12489
12030
  iconDirs: [],
12031
+ iconUrls: /* @__PURE__ */ new Map(),
12032
+ hideBuiltIns: false,
12033
+ iconSetNames: /* @__PURE__ */ new Map(),
12034
+ fontUrls: /* @__PURE__ */ new Map(),
12490
12035
  images: /* @__PURE__ */ new Map(),
12036
+ iconFolderRead: false,
12491
12037
  guidance: [],
12492
12038
  issues: []
12493
12039
  };
12494
12040
  for (const s of BUILTIN) look.styles.set(s.name, { ...s, props: { ...s.props } });
12495
12041
  return look;
12496
12042
  }
12043
+ var isWebUrl = (s) => /^https:\/\/[^\s\x00-\x1f\x7f"'<>\\`]+$/i.test(s) && s.length <= 500;
12044
+ var hasScheme = (s) => /^[a-z][a-z0-9+.-]*:/i.test(s);
12497
12045
  function parseLook(src, path = "look") {
12498
12046
  const look = emptyLook();
12499
12047
  for (const st of parseStatements(src)) {
12500
12048
  const [head, ...rest] = st.toks;
12501
12049
  const err = (msg) => look.issues.push({ line: st.line, level: "error", msg, file: path });
12502
12050
  if (head.t !== "word") {
12503
- err("a look statement must start with canvas, color, font, fontdir, style, icon, icondir, guidance or dark");
12051
+ err("a look statement must start with canvas, color, font, fontdir, style, icon, icons, icondir, guidance or dark");
12504
12052
  continue;
12505
12053
  }
12506
12054
  if (head.v === "dark") {
@@ -12511,16 +12059,35 @@ function parseLook(src, path = "look") {
12511
12059
  }
12512
12060
  if (head.v === "icondir") {
12513
12061
  if (!rest[0]) err('icondir needs a folder of SVG files, e.g. icondir "./icons"');
12514
- else look.iconDirs.push(rest[0].v);
12062
+ 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`);
12063
+ else {
12064
+ look.iconDirs.push(rest[0].v);
12065
+ const names = rest.slice(1).find((t) => t.t === "prop" && t.k === "names")?.v;
12066
+ if (names !== void 0) {
12067
+ const list2 = names.split(/\s+/).filter(Boolean);
12068
+ if (!isWebUrl(rest[0].v)) err(`names= lists the icons of an icondir address; a folder's icons are its files ("${rest[0].v}")`);
12069
+ 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"');
12070
+ else look.iconSetNames.set(rest[0].v, list2);
12071
+ }
12072
+ }
12515
12073
  continue;
12516
12074
  }
12517
12075
  if (head.v === "icon") {
12518
12076
  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
12077
  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"`);
12078
+ else if (paths.length === 1 && hasScheme(paths[0])) {
12079
+ if (isWebUrl(paths[0])) look.iconUrls.set(name2, paths[0]);
12080
+ 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"`);
12081
+ } 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
12082
  else look.icons.set(name2, paths);
12522
12083
  continue;
12523
12084
  }
12085
+ if (head.v === "icons") {
12086
+ const v = rest.length === 1 && rest[0].t === "prop" && rest[0].k === "builtin" ? rest[0].v : void 0;
12087
+ if (v === "hidden" || v === "shown") look.hideBuiltIns = v === "hidden";
12088
+ 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");
12089
+ continue;
12090
+ }
12524
12091
  if (head.v === "fontdir") {
12525
12092
  if (!rest[0]) err('fontdir needs a folder, e.g. fontdir "./fonts"');
12526
12093
  else look.fontDirs.push(rest[0].v);
@@ -12534,6 +12101,11 @@ function parseLook(src, path = "look") {
12534
12101
  continue;
12535
12102
  }
12536
12103
  (head.v === "color" ? look.colors : look.fonts).set(rest[0].v, rest[1].v);
12104
+ const at = head.v === "font" ? rest[2]?.v : void 0;
12105
+ if (at !== void 0) {
12106
+ if (isWebUrl(at)) look.fontUrls.set(rest[1].v, at);
12107
+ 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"`);
12108
+ }
12537
12109
  } else if (head.v === "guidance") {
12538
12110
  for (const t of rest) if (t.t === "str") look.guidance.push(t.v);
12539
12111
  } else if (head.v === "style") {
@@ -12654,15 +12226,23 @@ function backdrop(look, v) {
12654
12226
  if (!top || !page) return top;
12655
12227
  return [0, 1, 2].map((i) => top[i] * a + page[i] * (1 - a));
12656
12228
  }
12229
+ var SHIPPED_FAMILIES = ["Geist", "Geist Mono", "Newsreader", "Libre Franklin", "Instrument Serif", "Sketch Hand"];
12230
+ var SYSTEM_FAMILIES = ["sans-serif", "serif", "monospace", "helvetica"];
12231
+ var isShippedFamily = (fam2) => [...SHIPPED_FAMILIES, ...SYSTEM_FAMILIES].some((f) => f.toLowerCase() === fam2.toLowerCase());
12232
+ var fallbackFamily = (role, fam2) => role === "mono" || /mono/i.test(fam2) ? "Geist Mono" : role === "serif" ? "Newsreader" : "Geist";
12657
12233
  function fontFamily(look, v) {
12658
12234
  const name2 = v ?? "sans";
12659
12235
  const fam2 = look.fonts.get(name2) ?? name2;
12660
12236
  const generic = name2 === "mono" ? "monospace" : name2 === "serif" ? "serif" : "sans-serif";
12661
- return `'${fam2}', ${generic}`;
12237
+ return isShippedFamily(fam2) ? `'${fam2}', ${generic}` : `'${fam2}', '${fallbackFamily(name2, fam2)}', ${generic}`;
12662
12238
  }
12663
12239
  var cachedDefault;
12664
12240
  var BUNDLED_LOOK_NAMES = Object.keys(BUNDLED_LOOKS);
12665
12241
  var isBundledLook = (p) => !!p && Object.hasOwn(BUNDLED_LOOKS, p);
12242
+ var LOOKS_REPO = "coccor/fastdraw-looks";
12243
+ var MOVED_LOOKS = ["engraved", "headline", "keys", "listing", "offset", "transit"];
12244
+ var movedLookUrl = (name2) => MOVED_LOOKS.includes(name2) ? `https://raw.githubusercontent.com/${LOOKS_REPO}/main/${name2}.look` : void 0;
12245
+ var isWebLook = (p) => !!p && isWebUrl(p) && /^[^?#]*\.look(?:[?#]|$)/i.test(p);
12666
12246
  var bundledCache = /* @__PURE__ */ new Map();
12667
12247
  function bundledLook(name2) {
12668
12248
  if (!isBundledLook(name2)) return null;
@@ -12679,6 +12259,65 @@ function resetLookCaches() {
12679
12259
  bundledCache.clear();
12680
12260
  }
12681
12261
 
12262
+ // src/order.ts
12263
+ var byNumber = (a, b) => Number.isNaN(a) ? Number.isNaN(b) ? 0 : 1 : Number.isNaN(b) ? -1 : a < b ? -1 : a > b ? 1 : 0;
12264
+
12265
+ // src/extendedIcons.ts
12266
+ var loading;
12267
+ var loaded = false;
12268
+ var listeners = /* @__PURE__ */ new Set();
12269
+ var extendedIconsLoaded = () => loaded;
12270
+ function loadExtendedIcons() {
12271
+ loading ??= Promise.resolve().then(() => (init_iconSetAll(), iconSetAll_exports)).then((m) => {
12272
+ for (const w of Object.keys(m.EXTRA_WEIGHTS)) Object.assign(ICON_WEIGHTS[w], m.EXTRA_WEIGHTS[w]);
12273
+ Object.assign(DUOTONE_TINT, m.EXTRA_TINT);
12274
+ Object.assign(ICON_WORDS, m.EXTRA_WORDS);
12275
+ loaded = true;
12276
+ resetLookCaches();
12277
+ listeners.forEach((fn) => fn());
12278
+ });
12279
+ return loading;
12280
+ }
12281
+
12282
+ // src/iconfiles.ts
12283
+ var MAX_ICON_BYTES = 3e5;
12284
+ var MAX_ICON_FILES = 3e3;
12285
+ var URI = /^data:image\/svg\+xml;base64,[A-Za-z0-9+/]+=*$/;
12286
+ var isIconUri = (v) => typeof v === "string" && v.length < MAX_ICON_BYTES * 1.4 && URI.test(v);
12287
+ function iconName(file) {
12288
+ return file.replace(/\.svg$/i, "").toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^\d+-icon-service-/, "").replace(/^-+|-+$/g, "");
12289
+ }
12290
+ function svgDataUri(bytes) {
12291
+ if (bytes.length === 0 || bytes.length > MAX_ICON_BYTES) return null;
12292
+ const head = new TextDecoder().decode(bytes.subarray(0, 2e3));
12293
+ if (!/<svg[\s>]/i.test(head)) return null;
12294
+ let bin = "";
12295
+ for (let i = 0; i < bytes.length; i += 32768) bin += String.fromCharCode(...bytes.subarray(i, i + 32768));
12296
+ return "data:image/svg+xml;base64," + btoa(bin);
12297
+ }
12298
+ function withIconImages(look, files, uris = {}, folderRead = files.length > 0) {
12299
+ const images = new Map(look.images);
12300
+ 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);
12301
+ for (const f of [...files].sort((a, b) => a.name.localeCompare(b.name))) {
12302
+ const name2 = iconName(f.name), uri = name2 && name2.length <= 80 ? svgDataUri(f.bytes) : null;
12303
+ if (uri && images.size < MAX_ICON_FILES && !images.has(name2)) images.set(name2, uri);
12304
+ }
12305
+ return { ...look, images, iconFolderRead: look.iconFolderRead || folderRead };
12306
+ }
12307
+ function usedIconImages(look, names) {
12308
+ const out = {};
12309
+ for (const n of names) {
12310
+ const u = look.images.get(n);
12311
+ if (u) out[n] = u;
12312
+ }
12313
+ return out;
12314
+ }
12315
+ function iconStandIn(look, name2) {
12316
+ if (!name2 || name2 === "none" || look.images.has(name2) || look.icons.has(name2)) return null;
12317
+ return (look.iconDirs.length || look.iconUrls.size) && !look.iconFolderRead && extendedIconsLoaded() ? standInIcon(name2) : null;
12318
+ }
12319
+ var iconSources = (look, name2) => look.iconUrls.get(name2) ?? look.iconDirs.join(", ");
12320
+
12682
12321
  // src/iconStyle.ts
12683
12322
  var isBuiltIn = (look, name2) => !look.images.has(name2) && !!ICONS[name2] && look.icons.get(name2) === ICONS[name2];
12684
12323
  function weightFor(width) {
@@ -12735,7 +12374,7 @@ var LANES = [CLEAR, CLEAR + 12, CLEAR + 24];
12735
12374
  function routeAround(P0, d0, P1, d1, obstacles, taken = []) {
12736
12375
  const S = d0 ? { x: P0.x + d0.x * STUB, y: P0.y + d0.y * STUB } : P0;
12737
12376
  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);
12377
+ const uniq = (v) => [...new Set(v.map((n) => Math.round(n)))].sort(byNumber);
12739
12378
  const xs = uniq([S.x, E.x, ...obstacles.flatMap((o) => LANES.flatMap((l) => [o.x - l, o.x + o.w + l]))]);
12740
12379
  const ys = uniq([S.y, E.y, ...obstacles.flatMap((o) => LANES.flatMap((l) => [o.y - l, o.y + o.h + l]))]);
12741
12380
  const W = xs.length, H = ys.length;
@@ -12848,7 +12487,7 @@ var FONT_WIDTHS = {
12848
12487
 
12849
12488
  // src/scene.ts
12850
12489
  var SERIES = ["bars", "line", "area", "dots"];
12851
- var CANVAS_KEYS = ["paper", "dots", "dotgap"];
12490
+ var CANVAS_KEYS = ["paper", "dots", "dotgap", "grid", "gridgap", "lines", "linegap", "cross", "crossgap", "iso", "isogap", "bars", "bargap", "diag", "diaggap", "graph", "graphgap", "hex", "hexgap"];
12852
12491
  var MARKERS = ["none", "arrow", "open", "triangle", "diamond", "diamond-solid", "dot", "circle", "stop", "one", "only-one", "many", "one-many", "zero-one", "zero-many"];
12853
12492
  var DIRS = { top: { x: 0, y: -1 }, bottom: { x: 0, y: 1 }, left: { x: -1, y: 0 }, right: { x: 1, y: 0 } };
12854
12493
  var num = (v, d) => v === void 0 || v === "" || isNaN(+v) ? d : +v;
@@ -13140,7 +12779,7 @@ function buildScene(src, lookIn, file = "") {
13140
12779
  if (lookStmt) {
13141
12780
  const p = lookStmt.toks[1]?.v;
13142
12781
  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`);
12782
+ 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
12783
  else for (const i of look.issues) issues.push({ ...i, line: lookStmt.line, msg: `${i.msg} (in look, line ${i.line})` });
13145
12784
  }
13146
12785
  const shapes = [], texts = [], conns = [];
@@ -13318,8 +12957,12 @@ function buildScene(src, lookIn, file = "") {
13318
12957
  w: size.w,
13319
12958
  h: size.h
13320
12959
  };
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()];
12960
+ const standIn = iconStandIn(look, p.icon);
12961
+ 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`);
12962
+ else if (p.icon && p.icon !== "none" && !look.icons.has(p.icon) && !look.images.has(p.icon)) {
12963
+ const every = [...look.images.keys(), ...look.icons.keys()];
12964
+ const own = look.hideBuiltIns ? [...new Set(every.filter((n) => !isBuiltIn(look, n)))] : [];
12965
+ const all = own.length ? own : every;
13323
12966
  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
12967
  const folder = look.iconDirs.length && !look.images.size ? ` (the look's icon folder ${look.iconDirs.join(", ")} could not be read here)` : "";
13325
12968
  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 +12970,7 @@ function buildScene(src, lookIn, file = "") {
13327
12970
  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
12971
  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
12972
  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)`);
12973
+ 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)`);
13331
12974
  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
12975
  if (sh.shape === "polygon") {
13333
12976
  const rel = (p.points ?? "").split(";").filter(Boolean).map((q) => {
@@ -13520,7 +13163,7 @@ function buildScene(src, lookIn, file = "") {
13520
13163
  single.add(g[0].e);
13521
13164
  continue;
13522
13165
  }
13523
- const order = g.map((m, idx) => ({ m, idx, r: ref(m.o) })).sort((p, q) => p.r - q.r || p.idx - q.idx);
13166
+ const order = g.map((m, idx) => ({ m, idx, r: ref(m.o) })).sort((p, q) => byNumber(p.r, q.r) || p.idx - q.idx);
13524
13167
  order.forEach((o, n) => frac.set(o.m.e, (n + 1) / (g.length + 1)));
13525
13168
  }
13526
13169
  for (const c of batch) {
@@ -13634,41 +13277,174 @@ function extent(shapes, texts, conns) {
13634
13277
  return { x, y, w: Math.ceil((x1 + MARGIN) / 4) * 4 - x, h: Math.ceil((y1 + MARGIN) / 4) * 4 - y };
13635
13278
  }
13636
13279
 
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, "");
13280
+ // src/webassets.ts
13281
+ var MAX_FONT_BYTES = 5e6;
13282
+ var MAX_WEB_ICONS = 300;
13283
+ var hasWebIcons = (look) => look.iconUrls.size > 0 || look.iconDirs.some(isWebUrl);
13284
+ var localIconDirs = (look) => look.iconDirs.filter((d) => !isWebUrl(d));
13285
+ function iconAddresses(look, name2) {
13286
+ const out = [];
13287
+ const own = look.iconUrls.get(name2);
13288
+ if (own) out.push(own);
13289
+ for (const d of look.iconDirs) {
13290
+ if (!isWebUrl(d)) continue;
13291
+ out.push(d.includes("{name}") ? d.replaceAll("{name}", name2) : `${d.replace(/\/+$/, "")}/${name2}.svg`);
13292
+ }
13293
+ return out;
13644
13294
  }
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);
13295
+ function isPrivateHost(host) {
13296
+ const h = host.toLowerCase().replace(/^\[|\]$/g, "").replace(/\.+$/, "");
13297
+ if (h === "localhost" || h.endsWith(".localhost") || h.endsWith(".local") || h.endsWith(".internal") || !h.includes(".") && !h.includes(":")) return true;
13298
+ const v4 = /^(\d+)\.(\d+)\.(\d+)\.(\d+)$/.exec(h);
13299
+ if (v4) {
13300
+ const [a, b] = [Number(v4[1]), Number(v4[2])];
13301
+ 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;
13302
+ }
13303
+ 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
13304
  }
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);
13305
+ function isPublicWebUrl(url) {
13306
+ try {
13307
+ const u = new URL(url);
13308
+ return u.protocol === "https:" && !isPrivateHost(u.hostname);
13309
+ } catch {
13310
+ return false;
13659
13311
  }
13660
- return { ...look, images };
13661
13312
  }
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;
13313
+ var webFetch = async (url, maxBytes) => {
13314
+ if (!isPublicWebUrl(url)) throw new Error("not a public https address");
13315
+ const u = new URL(url);
13316
+ const r = await fetch(u, { credentials: "omit", referrerPolicy: "no-referrer", redirect: "error", signal: AbortSignal.timeout(15e3) });
13317
+ if (r.status === 404 || r.status === 410) return null;
13318
+ if (!r.ok) throw new Error(`${r.status} ${r.statusText}`.trim());
13319
+ if (Number(r.headers.get("content-length")) > maxBytes) throw new Error("file too large");
13320
+ const chunks = [];
13321
+ let total = 0;
13322
+ const reader = r.body.getReader();
13323
+ for (; ; ) {
13324
+ const { done, value } = await reader.read();
13325
+ if (done) break;
13326
+ total += value.length;
13327
+ if (total > maxBytes) {
13328
+ await reader.cancel();
13329
+ throw new Error("file too large");
13330
+ }
13331
+ chunks.push(value);
13332
+ }
13333
+ const bytes = new Uint8Array(total);
13334
+ let at = 0;
13335
+ for (const c of chunks) {
13336
+ bytes.set(c, at);
13337
+ at += c.length;
13338
+ }
13339
+ return bytes;
13340
+ };
13341
+ var caches = /* @__PURE__ */ new WeakMap();
13342
+ function cached(get, url, maxBytes) {
13343
+ let cache = caches.get(get);
13344
+ if (!cache) caches.set(get, cache = /* @__PURE__ */ new Map());
13345
+ let p = cache.get(url);
13346
+ if (!p) {
13347
+ p = get(url, maxBytes);
13348
+ cache.set(url, p);
13349
+ p.catch(() => cache.delete(url));
13350
+ }
13351
+ return p;
13352
+ }
13353
+ var MAX_LOOK_BYTES = 1e6;
13354
+ async function fetchWebLook(url, get = webFetch) {
13355
+ const bytes = await get(url, MAX_LOOK_BYTES);
13356
+ if (!bytes) return null;
13357
+ const text = new TextDecoder().decode(bytes);
13358
+ if (/^\s*</.test(text)) throw new Error('not a look file (it starts with "<")');
13359
+ return text;
13360
+ }
13361
+ var hostOf = (url) => {
13362
+ try {
13363
+ return new URL(url).host;
13364
+ } catch {
13365
+ return "an address in the look";
13366
+ }
13367
+ };
13368
+ function setListing(dir) {
13369
+ const tpl = dir.includes("{name}") ? dir : `${dir.replace(/\/+$/, "")}/{name}.svg`;
13370
+ const m = /^https:\/\/cdn\.jsdelivr\.net\/(npm\/(?:@[^/@{}]+\/)?[^/@{}]+|gh\/[^/@{}]+\/[^/@{}]+)@([^/{}]+)(\/.*)$/i.exec(tpl);
13371
+ if (!m) return null;
13372
+ const parts = m[3].split("{name}"), fixed = parts.join("").length, k = parts.length - 1;
13373
+ if (k > 3) return null;
13374
+ return {
13375
+ url: `https://data.jsdelivr.com/v1/packages/${m[1]}@${m[2]}?structure=flat`,
13376
+ nameOf: (path) => {
13377
+ const len = (path.length - fixed) / k;
13378
+ if (path.length > 1e3 || !Number.isInteger(len) || len < 1 || len > 80) return null;
13379
+ const name2 = path.slice(parts[0].length, parts[0].length + len);
13380
+ return /^[a-z0-9-]+$/.test(name2) && parts.join(name2) === path ? name2 : null;
13381
+ }
13382
+ };
13383
+ }
13384
+ var MAX_LISTING_BYTES = 2e7;
13385
+ async function listWebIcons(look, get = webFetch) {
13386
+ const out = /* @__PURE__ */ new Set();
13387
+ for (const d of look.iconDirs) {
13388
+ if (!isWebUrl(d)) continue;
13389
+ for (const n of look.iconSetNames.get(d) ?? []) out.add(n);
13390
+ const l = setListing(d);
13391
+ if (!l) continue;
13392
+ try {
13393
+ const bytes = await cached(get, l.url, MAX_LISTING_BYTES);
13394
+ const files = bytes ? JSON.parse(new TextDecoder().decode(bytes)).files : void 0;
13395
+ for (const f of Array.isArray(files) ? files : []) {
13396
+ const n = typeof f?.name === "string" ? l.nameOf(f.name) : null;
13397
+ if (n) out.add(n);
13398
+ }
13399
+ } catch {
13400
+ }
13401
+ }
13402
+ for (const n of look.iconUrls.keys()) out.delete(n);
13403
+ return [...out].sort();
13404
+ }
13405
+ async function fetchWebIcons(look, names, get = webFetch) {
13406
+ 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)));
13407
+ const uris = {};
13408
+ const unreachable = /* @__PURE__ */ new Set();
13409
+ await Promise.all(want.slice(0, MAX_WEB_ICONS).map(async (name2) => {
13410
+ for (const url of iconAddresses(look, name2)) {
13411
+ try {
13412
+ const bytes = await cached(get, url, MAX_ICON_BYTES);
13413
+ const uri = bytes && svgDataUri(bytes);
13414
+ if (uri) {
13415
+ uris[name2] = uri;
13416
+ return;
13417
+ }
13418
+ } catch {
13419
+ unreachable.add(hostOf(url));
13420
+ return;
13421
+ }
13422
+ }
13423
+ }));
13424
+ return { uris, done: unreachable.size === 0, unreachable: [...unreachable] };
13425
+ }
13426
+ var WEIGHTS = [400, 500, 600, 700];
13427
+ function webFaces(look) {
13428
+ const out = [];
13429
+ for (const [family, tpl] of look.fontUrls) {
13430
+ if (!/^[\w .-]{1,64}$/.test(family)) continue;
13431
+ const fill = (w, s) => tpl.replaceAll("{weight}", String(w)).replaceAll("{style}", s);
13432
+ const add = (weight, style) => {
13433
+ const url = fill(weight || 400, style);
13434
+ if (isPublicWebUrl(url)) out.push({ family, weight, style, url });
13435
+ };
13436
+ if (!tpl.includes("{weight}")) {
13437
+ add(0, "normal");
13438
+ continue;
13439
+ }
13440
+ for (const w of WEIGHTS) add(w, "normal");
13441
+ if (tpl.includes("{style}")) add(400, "italic");
13667
13442
  }
13668
13443
  return out;
13669
13444
  }
13670
13445
 
13671
13446
  // src/node.ts
13447
+ import { createHash } from "node:crypto";
13672
13448
  import { lstatSync, realpathSync } from "node:fs";
13673
13449
  import { isAbsolute, relative, sep } from "node:path";
13674
13450
  function lookFolder(lookFile, d) {
@@ -13696,7 +13472,7 @@ function plainFiles(dir, ext, maxBytes, maxFiles) {
13696
13472
  }
13697
13473
  function iconFiles(lookFile, look) {
13698
13474
  const out = [];
13699
- for (const d of look.iconDirs) {
13475
+ for (const d of localIconDirs(look)) {
13700
13476
  const dir = lookFolder(lookFile, d);
13701
13477
  if (!dir) {
13702
13478
  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 +13482,116 @@ function iconFiles(lookFile, look) {
13706
13482
  }
13707
13483
  return out;
13708
13484
  }
13709
- var withIcons = (lookFile, look) => look.iconDirs.length ? withIconImages(look, iconFiles(lookFile, look)) : look;
13485
+ var webCache = /* @__PURE__ */ new Map();
13486
+ var webFonts = /* @__PURE__ */ new Map();
13487
+ var webLists = /* @__PURE__ */ new Map();
13488
+ var PREVIEW_ICONS = 200;
13489
+ function webCacheDir() {
13490
+ const base = process.env.XDG_CACHE_HOME || (process.platform === "win32" ? process.env.LOCALAPPDATA : void 0) || join(homedir(), ".cache");
13491
+ return join(base, "fastdraw", "web");
13492
+ }
13493
+ function diskFetch(offline) {
13494
+ return async (url, maxBytes) => {
13495
+ const path = cachePath(url);
13496
+ if (existsSync(path)) return new Uint8Array(readFileSync(path));
13497
+ if (offline) throw new Error("offline");
13498
+ const bytes = await webFetch(url, maxBytes);
13499
+ if (bytes) {
13500
+ mkdirSync(dirname(path), { recursive: true });
13501
+ writeFileSync(path, bytes);
13502
+ }
13503
+ return bytes;
13504
+ };
13505
+ }
13506
+ var cachePath = (url) => join(webCacheDir(), createHash("sha256").update(url).digest("hex").slice(0, 32) + (/\.(ttf|otf|svg|look)(?=\?|$)/i.exec(url)?.[0].toLowerCase() ?? ""));
13507
+ async function fetchLookToCache(url, offline) {
13508
+ const path = cachePath(url), had = existsSync(path);
13509
+ if (offline) return had ? void 0 : `${url}: not fetched (--offline) and not fetched before`;
13510
+ try {
13511
+ const text = await fetchWebLook(url);
13512
+ if (text === null) return `there is no look file at ${url}`;
13513
+ mkdirSync(dirname(path), { recursive: true });
13514
+ writeFileSync(path, text);
13515
+ return void 0;
13516
+ } catch (e) {
13517
+ 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}`;
13518
+ }
13519
+ }
13520
+ var webLookFile = (url) => cachePath(url);
13521
+ var lookFileFor = (file, p) => isWebLook(p) ? cachePath(p) : resolve(dirname(file), p);
13522
+ async function fetchWebAssets(files, offline = false, looks = []) {
13523
+ const get = diskFetch(offline), notes = /* @__PURE__ */ new Set();
13524
+ const webLooks = new Set(looks.filter(isWebLook));
13525
+ const over2 = looks.find((l) => isWebLook(l) || /\.look$/i.test(l));
13526
+ const overPath = over2 && !isWebLook(over2) ? resolve(over2) : over2;
13527
+ for (const file of files) {
13528
+ if (/\.look$/i.test(file) || over2) continue;
13529
+ try {
13530
+ const p = lookPath(readFileSync(file, "utf8"));
13531
+ if (p && isWebLook(p)) webLooks.add(p);
13532
+ } catch {
13533
+ }
13534
+ }
13535
+ for (const url of webLooks) {
13536
+ const n = await fetchLookToCache(url, offline);
13537
+ if (n) notes.add(n);
13538
+ }
13539
+ const wanted = /* @__PURE__ */ new Map();
13540
+ for (const file of files) {
13541
+ if (/\.look$/i.test(file)) {
13542
+ let text;
13543
+ try {
13544
+ text = readFileSync(file, "utf8");
13545
+ } catch {
13546
+ continue;
13547
+ }
13548
+ const look2 = parseLook(text, file);
13549
+ if (!hasWebIcons(look2) && !look2.fontUrls.size) continue;
13550
+ const listed = await listWebIcons(look2, get);
13551
+ webLists.set(resolve(file), listed);
13552
+ wanted.set(resolve(file), { look: look2, names: new Set([...look2.iconUrls.keys(), ...listed].slice(0, PREVIEW_ICONS)) });
13553
+ continue;
13554
+ }
13555
+ let src;
13556
+ try {
13557
+ src = readFileSync(file, "utf8");
13558
+ } catch {
13559
+ continue;
13560
+ }
13561
+ const p = overPath ?? lookPath(src), r = readLook(file, p);
13562
+ if (r.text === null) continue;
13563
+ const lookFile = lookFileFor(file, p), look = parseLook(r.text, p);
13564
+ if (!hasWebIcons(look) && !look.fontUrls.size) continue;
13565
+ const w = wanted.get(lookFile) ?? { look, names: /* @__PURE__ */ new Set() };
13566
+ for (const m of src.matchAll(/\bicon="?([\w-]+)/g)) w.names.add(m[1]);
13567
+ for (const st of look.styles.values()) if (st.props.icon && st.props.icon !== "none") w.names.add(st.props.icon);
13568
+ wanted.set(lookFile, w);
13569
+ }
13570
+ for (const [lookFile, { look, names }] of wanted) {
13571
+ if (hasWebIcons(look)) {
13572
+ const got = await fetchWebIcons(look, names, get);
13573
+ webCache.set(lookFile, got);
13574
+ 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`);
13575
+ }
13576
+ const fonts = [];
13577
+ for (const f of webFaces(look)) {
13578
+ if (!/\.(ttf|otf)(\?|$)/i.test(f.url)) continue;
13579
+ try {
13580
+ if (await get(f.url, MAX_FONT_BYTES)) fonts.push(cachePath(f.url));
13581
+ } catch {
13582
+ notes.add(`${hostOf(f.url)}: the font ${f.family} could not be fetched, so text is drawn in a fallback font`);
13583
+ }
13584
+ }
13585
+ webFonts.set(lookFile, fonts);
13586
+ }
13587
+ return [...notes];
13588
+ }
13589
+ var withIcons = (lookFile, look) => {
13590
+ if (!look.iconDirs.length && !look.iconUrls.size) return look;
13591
+ const web = webCache.get(resolve(lookFile)), listed = webLists.get(resolve(lookFile));
13592
+ const out = withIconImages(look, iconFiles(lookFile, look), web?.uris ?? {}, web ? web.done : !hasWebIcons(look));
13593
+ return listed ? { ...out, listedIcons: listed } : out;
13594
+ };
13710
13595
  function loadLook(path) {
13711
13596
  try {
13712
13597
  return withIcons(path, parseLook(readFileSync(path, "utf8"), path));
@@ -13749,6 +13634,7 @@ function lookFonts(lookFile, look) {
13749
13634
  const dir = lookFolder(lookFile, d);
13750
13635
  return dir ? plainFiles(dir, /\.(ttf|otf)$/i, 2e7, 200) : [];
13751
13636
  }) : [];
13637
+ if (lookFile) files.push(...(webFonts.get(resolve(lookFile)) ?? []).filter((f) => existsSync(f)));
13752
13638
  const have = /* @__PURE__ */ new Set();
13753
13639
  for (const f of [...bundledFonts(), ...files]) {
13754
13640
  const m = fontMeta(new Uint8Array(readFileSync(f)));
@@ -13760,6 +13646,13 @@ function lookFonts(lookFile, look) {
13760
13646
  }
13761
13647
  function readLook(file, p) {
13762
13648
  if (!p) return { text: null, refused: false };
13649
+ if (isWebLook(p)) {
13650
+ try {
13651
+ return { text: readFileSync(cachePath(p), "utf8"), refused: false };
13652
+ } catch {
13653
+ return { text: null, refused: false };
13654
+ }
13655
+ }
13763
13656
  if (!p.toLowerCase().endsWith(".look")) return { text: null, refused: true };
13764
13657
  try {
13765
13658
  return { text: readFileSync(resolve(dirname(file), p), "utf8"), refused: false };
@@ -13778,11 +13671,12 @@ function loadScene(file, srcIn) {
13778
13671
  }
13779
13672
  const p = lookPath(src);
13780
13673
  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);
13674
+ const sc = buildScene(src, r.text === null ? null : withIcons(lookFileFor(file, p), parseLook(r.text, p)), file);
13675
+ const fonts = lookFonts(r.text === null ? void 0 : lookFileFor(file, p), sc.look);
13783
13676
  sc.fontFiles = fonts.files;
13784
13677
  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` });
13678
+ const at = sc.look.fontUrls.get(fam2);
13679
+ 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
13680
  }
13787
13681
  if (r.refused) {
13788
13682
  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 +13694,25 @@ function readSources(file, sc, src) {
13800
13694
  function lookFileOf(diagramFile) {
13801
13695
  try {
13802
13696
  const p = lookPath(readFileSync(diagramFile, "utf8"));
13803
- return p && p.toLowerCase().endsWith(".look") ? resolve(dirname(diagramFile), p) : void 0;
13697
+ return p && isWebLook(p) ? cachePath(p) : p && p.toLowerCase().endsWith(".look") ? resolve(dirname(diagramFile), p) : void 0;
13804
13698
  } catch {
13805
13699
  return void 0;
13806
13700
  }
13807
13701
  }
13808
13702
  function lookArg(v) {
13809
13703
  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`;
13704
+ if (isWebLook(v)) return { url: v, file: cachePath(v) };
13705
+ 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
13706
  return existsSync(v) ? { file: resolve(v) } : `look file not found: ${v}`;
13812
13707
  }
13813
13708
  function lookOfDiagram(file, src) {
13814
13709
  const p = lookPath(src);
13815
13710
  if (p === void 0) return void 0;
13816
- return isBundledLook(p) ? { name: p } : { file: resolve(dirname(file), p) };
13711
+ return isBundledLook(p) ? { name: p } : isWebLook(p) ? { url: p, file: cachePath(p) } : { file: resolve(dirname(file), p) };
13817
13712
  }
13818
13713
  function lookRefText(ref, file) {
13819
13714
  if ("name" in ref) return ref.name;
13715
+ if ("url" in ref) return ref.url;
13820
13716
  const rel = relative(dirname(resolve(file)), ref.file).split(sep).join("/");
13821
13717
  return rel.startsWith(".") || isAbsolute(rel) ? rel : "./" + rel;
13822
13718
  }
@@ -13828,35 +13724,19 @@ function darkLookOf(ref) {
13828
13724
  name2 = `the ${ref.name} look`;
13829
13725
  } else if (ref) {
13830
13726
  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}`;
13727
+ if (!existsSync(ref.file)) return "url" in ref ? `the look at ${ref.url} could not be fetched` : `look file not found: ${ref.file}`;
13832
13728
  look = parseLook(readFileSync(ref.file, "utf8"), ref.file);
13833
- name2 = basename(ref.file);
13834
- from = ref.file;
13729
+ name2 = "url" in ref ? ref.url : basename(ref.file);
13730
+ from = "url" in ref ? void 0 : ref.file;
13835
13731
  }
13836
13732
  const d = look.dark;
13837
13733
  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
13734
  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`;
13735
+ if (!from) return `${name2} names a dark look by path (${d}), which only a look file on this computer can do`;
13840
13736
  const file = resolve(dirname(from), d);
13841
13737
  return existsSync(file) ? { file } : `the dark look of ${name2} was not found: ${d}`;
13842
13738
  }
13843
13739
 
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
13740
  // src/embed.ts
13861
13741
  var b64 = (s) => {
13862
13742
  const b = new TextEncoder().encode(s);
@@ -14146,8 +14026,17 @@ var BLEND = ' style="mix-blend-mode:multiply"';
14146
14026
  var blendOf = (p) => p.blend === "multiply" ? BLEND : "";
14147
14027
  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
14028
  var boxy = (s) => s.shape !== "polygon" && s.shape !== "arc";
14029
+ var SHADOW_STEPS = 6;
14149
14030
  function underlay(look, s) {
14150
14031
  const p = s.p, out = [];
14032
+ if (p.shadow && p.shadow !== "none" && boxy(s)) {
14033
+ const size = num2(p["shadow.size"], 12), dx = num2(p["shadow.dx"], 0), dy = num2(p["shadow.dy"], 4), c = col(look, p.shadow);
14034
+ for (let i = SHADOW_STEPS; i >= 1; i--) {
14035
+ const e = r2(size * i / SHADOW_STEPS);
14036
+ 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) } };
14037
+ out.push(outlinePlain(grown, `fill="${c}" fill-opacity="${r2(1 / SHADOW_STEPS)}" stroke="none"`));
14038
+ }
14039
+ }
14151
14040
  if (p.shade && p.shade !== "none") {
14152
14041
  const k = num2(p["shade.size"], 5);
14153
14042
  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 +14059,8 @@ function overlay(look, s) {
14170
14059
  out.push(outlinePlain(inset2, `fill="none" stroke="${col(look, p.inner)}" stroke-width="${num2(p["inner.sw"], 0.6)}"`));
14171
14060
  }
14172
14061
  }
14062
+ const ib = iconBox(s), strips = [[p.side, num2(p["side.w"], 4)], [ib?.block ? p["icon.block"] : void 0, ib?.block ?? 0]];
14063
+ 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
14064
  if (p.corners && p.corners !== "none" && (s.shape === "rect" || s.shape === "table")) {
14174
14065
  const c = col(look, p["corners.color"] ?? p.stroke ?? "ink"), k = num2(p["corners.size"], p.corners === "plus" ? 7 : 5) / 2;
14175
14066
  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 +14069,10 @@ function overlay(look, s) {
14178
14069
  }
14179
14070
  return out;
14180
14071
  }
14072
+ function leftStrip(s, w) {
14073
+ const r = Math.min(num2(s.p.radius, 0), w, s.h / 2), x = s.x, y = s.y, b = s.y + s.h;
14074
+ 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`;
14075
+ }
14181
14076
  var esc = (s) => s.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;");
14182
14077
  var num2 = (v, d) => v === void 0 || v === "" || isNaN(+v) ? d : +v;
14183
14078
  var r2 = (n) => Math.round(n * 100) / 100;
@@ -14379,10 +14274,18 @@ function drawTable(look, s) {
14379
14274
  function iconBox(s) {
14380
14275
  const p = s.p;
14381
14276
  if (!p.icon || p.icon === "none") return null;
14277
+ if (p["icon.pos"] === "corner") return { x: s.x, y: s.y, size: num2(p["icon.size"], 24), dx: 0, dy: 0 };
14382
14278
  const hasText = !!(s.text || p.sub) && p["title.pos"] !== "top";
14383
14279
  const size = num2(p["icon.size"], hasText ? 20 : Math.max(8, Math.min(s.w, s.h, 96) - (s.style === "icon" ? 0 : 16)));
14384
14280
  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 };
14281
+ if (p["icon.block"] && p["icon.block"] !== "none" && (p["icon.pos"] ?? "left") === "left" && s.shape === "rect") {
14282
+ const bw = num2(p["icon.block.w"], s.h);
14283
+ return { x: s.x + (bw - size) / 2, y: s.y + (s.h - size) / 2, size, dx: bw / 2, dy: 0, block: bw };
14284
+ }
14285
+ if (p["icon.pos"] === "top") {
14286
+ const room = iconBg(p) ? num2(p["icon.bg.size"], size + 24) : size;
14287
+ return { x: s.x + (s.w - size) / 2, y: 0, size, dx: 0, dy: (room + 6) / 2, room };
14288
+ }
14386
14289
  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
14290
  const widths = [
14388
14291
  ...(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 +14294,20 @@ function iconBox(s) {
14391
14294
  const tw = Math.max(0, ...widths), x = Math.max(s.x + 8, s.x + (s.w - (size + 8 + tw)) / 2);
14392
14295
  return { x, y: s.y + (s.h - size) / 2, size, dx: (size + 8) / 2, dy: 0 };
14393
14296
  }
14297
+ var iconBg = (p) => !!p["icon.bg"] && p["icon.bg"] !== "none";
14394
14298
  function drawIcon(look, p, x, y, size) {
14395
- const name2 = p.icon, img = look.images.get(name2);
14299
+ if (!iconBg(p)) return drawIconOnly(look, p, x, y, size);
14300
+ const b = num2(p["icon.bg.size"], size + 24), cx2 = x + size / 2, cy2 = y + size / 2;
14301
+ 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}/>`;
14302
+ let under = "";
14303
+ if (p["icon.bg.shadow"] && p["icon.bg.shadow"] !== "none") {
14304
+ 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"]);
14305
+ 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)}"`);
14306
+ }
14307
+ return under + disc(0, 0, 0, `fill="${col(look, p["icon.bg"])}"`) + drawIconOnly(look, p, x, y, size);
14308
+ }
14309
+ function drawIconOnly(look, p, x, y, size) {
14310
+ const name2 = iconStandIn(look, p.icon) ?? p.icon, img = look.images.get(name2);
14396
14311
  if (img) return isIconUri(img) ? `<image x="${r2(x)}" y="${r2(y)}" width="${r2(size)}" height="${r2(size)}" href="${esc(img)}"/>` : "";
14397
14312
  const ink = col(look, p["icon.color"] ?? p["title.color"] ?? "ink");
14398
14313
  const ownFill = p["icon.fill"] && p["icon.fill"] !== "none" ? col(look, p["icon.fill"]) : null;
@@ -14479,7 +14394,8 @@ function drawShape(look, s) {
14479
14394
  const capOwn = p["title.dy"] !== void 0 || p["title.fill"] !== void 0;
14480
14395
  const capH = capOwn ? Math.max(12, Math.ceil(title.size + 4)) : 12, capY = num2(p["title.dy"], 0) + 4;
14481
14396
  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;
14397
+ const corner2 = capTop && p["icon.pos"] === "corner" && p.icon && p.icon !== "none" ? num2(p["icon.size"], 24) - 4 : 0;
14398
+ const tagRoom = (tb && capTop ? tagWidth(look, p) + 4 : 0) + corner2;
14483
14399
  if (tb) {
14484
14400
  const t = textAttrs(look, p, "tag.", { font: "mono", size: 7, weight: 400, color: "muted" });
14485
14401
  const tw = tagWidth(look, p);
@@ -14491,7 +14407,8 @@ function drawShape(look, s) {
14491
14407
  cxm += ib.dx;
14492
14408
  cym += ib.dy;
14493
14409
  }
14494
- if (ib && !(ib.dy > 0)) out.push(drawIcon(look, p, ib.x, ib.y, ib.size));
14410
+ const idx = num2(p["icon.dx"], 0), idy = num2(p["icon.dy"], 0);
14411
+ if (ib && !(ib.dy > 0)) out.push(drawIcon(look, p, ib.x + idx, ib.y + idy, ib.size));
14495
14412
  if (s.text && p["title.pos"] === "top") {
14496
14413
  const txt = p["title.caps"] === "1" ? s.text.toUpperCase() : s.text;
14497
14414
  const tw = Math.ceil(measureText(look, txt, title.size, title.font, title.weight, title.spacing) + 12);
@@ -14512,8 +14429,11 @@ function drawShape(look, s) {
14512
14429
  const subs = p.sub ? p.sub.split("\n") : [], slh = Math.round(sub.size * 1.3);
14513
14430
  const block = lines.length * lh + (subs.length ? sub.size + 7 + (subs.length - 1) * slh : 0);
14514
14431
  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";
14432
+ if (ib && ib.dy > 0) {
14433
+ const room = ib.room ?? ib.size;
14434
+ out.push(drawIcon(look, p, ib.x + idx, top - room - 6 + (room - ib.size) / 2 + idy, ib.size));
14435
+ }
14436
+ 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
14437
  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
14438
  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
14439
  }
@@ -14728,12 +14648,13 @@ function cutEnd(pts, dist) {
14728
14648
  return pts.slice(0, 2);
14729
14649
  }
14730
14650
  function drawConn(look, c) {
14651
+ if (c.pts.length < 2) return "";
14731
14652
  const p = c.p, sw = num2(p.sw, 1.2), stroke = col(look, p.stroke ?? "muted");
14732
14653
  const n = c.pts.length, paper = col(look, look.canvas.paper ?? "paper");
14733
14654
  const hFrom = c.curve ? backAlong(c.pts, 10) : c.pts[n - 2], tFrom = c.curve ? backAlong([...c.pts].reverse(), 10) : c.pts[1];
14734
14655
  const hk = Math.max(0.5, Math.min(num2(p["head.size"], 1), 4)), ringCol = col(look, p["stop.color"] ?? p.stroke ?? "muted");
14735
14656
  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);
14657
+ 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
14658
  const cap = p.cap === "round" ? ' stroke-linecap="round" stroke-linejoin="round"' : "";
14738
14659
  const a = `fill="none" stroke="${stroke}" stroke-width="${sw}"${p.dash && p.dash !== "none" ? ` stroke-dasharray="${esc(p.dash)}"` : ""}${cap}${blendOf(p)}`;
14739
14660
  let s = roughOf(p) ? sketchSvg(d, a, roughOf(p)) : `<path d="${d}" ${a}/>`;
@@ -14862,6 +14783,43 @@ function renderBody(sc, background = true) {
14862
14783
  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
14784
  out.push(`<rect class="fd-page" x="${sc.x}" y="${sc.y}" width="${sc.w}" height="${sc.h}" fill="url(#fd-dots)"/>`);
14864
14785
  }
14786
+ if (background && cv.grid && cv.grid !== "none") {
14787
+ const gap = Math.max(4, num2(cv.gridgap, 24));
14788
+ 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>`);
14789
+ out.push(`<rect class="fd-page" x="${sc.x}" y="${sc.y}" width="${sc.w}" height="${sc.h}" fill="url(#fd-grid)"/>`);
14790
+ }
14791
+ if (background && cv.lines && cv.lines !== "none") {
14792
+ const gap = Math.max(4, num2(cv.linegap, 24));
14793
+ 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>`);
14794
+ out.push(`<rect class="fd-page" x="${sc.x}" y="${sc.y}" width="${sc.w}" height="${sc.h}" fill="url(#fd-lines)"/>`);
14795
+ }
14796
+ if (background && cv.cross && cv.cross !== "none") {
14797
+ const gap = Math.max(8, num2(cv.crossgap, 24)), c = gap / 2;
14798
+ 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>`);
14799
+ out.push(`<rect class="fd-page" x="${sc.x}" y="${sc.y}" width="${sc.w}" height="${sc.h}" fill="url(#fd-cross)"/>`);
14800
+ }
14801
+ if (background && cv.iso && cv.iso !== "none") {
14802
+ const gap = Math.max(4, num2(cv.isogap, 24)), h = Math.round(gap * Math.sqrt(3) * 100) / 100;
14803
+ 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>`);
14804
+ out.push(`<rect class="fd-page" x="${sc.x}" y="${sc.y}" width="${sc.w}" height="${sc.h}" fill="url(#fd-iso)"/>`);
14805
+ }
14806
+ if (background && cv.diag && cv.diag !== "none") {
14807
+ const gap = Math.max(4, num2(cv.diaggap, 12));
14808
+ 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>`);
14809
+ out.push(`<rect class="fd-page" x="${sc.x}" y="${sc.y}" width="${sc.w}" height="${sc.h}" fill="url(#fd-diag)"/>`);
14810
+ }
14811
+ if (background && cv.graph && cv.graph !== "none") {
14812
+ const gap = Math.max(4, num2(cv.graphgap, 10)), t = gap * 5, c = col(look, cv.graph);
14813
+ const minor = [1, 2, 3, 4].map((k) => `M ${k * gap},0 V ${t} M 0,${k * gap} H ${t}`).join(" ");
14814
+ 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>`);
14815
+ out.push(`<rect class="fd-page" x="${sc.x}" y="${sc.y}" width="${sc.w}" height="${sc.h}" fill="url(#fd-graph)"/>`);
14816
+ }
14817
+ if (background && cv.hex && cv.hex !== "none") {
14818
+ const s = Math.max(4, num2(cv.hexgap, 14)), w = Math.round(s * Math.sqrt(3) * 100) / 100, m = w / 2;
14819
+ 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}`;
14820
+ 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>`);
14821
+ out.push(`<rect class="fd-page" x="${sc.x}" y="${sc.y}" width="${sc.w}" height="${sc.h}" fill="url(#fd-hex)"/>`);
14822
+ }
14865
14823
  if (background && cv.bars && cv.bars !== "none") {
14866
14824
  const gap = Math.max(8, num2(cv.bargap, 32));
14867
14825
  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>`);
@@ -14968,7 +14926,7 @@ function check(sc) {
14968
14926
  if (s.shape === "icon") continue;
14969
14927
  const p = s.p;
14970
14928
  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);
14929
+ 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
14930
  for (const l of s.text.split("\n")) {
14973
14931
  const tw = textWidth(l, size, p["title.font"] ?? "sans", num3(p["title.weight"], 600), num3(p["title.spacing"], 0));
14974
14932
  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 +14935,7 @@ function check(sc) {
14977
14935
  const ic = iconBox(s);
14978
14936
  if (ic && ic.dy > 0) {
14979
14937
  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;
14938
+ 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
14939
  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
14940
  } 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
14941
  for (const l of p.sub ? p.sub.split("\n") : []) {
@@ -15276,13 +15234,27 @@ ${kind} styles`);
15276
15234
  }
15277
15235
  out.push("\nfonts");
15278
15236
  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()];
15237
+ const own = [...look.images.keys()].filter((n) => !look.iconUrls.has(n));
15238
+ const sets = look.iconDirs.filter((d) => /^https:/i.test(d));
15239
+ if (sets.length || look.iconUrls.size) {
15240
+ out.push("\nicons from the web (icon=name)");
15241
+ if (look.iconUrls.size) out.push(` ${[...look.iconUrls.keys()].join(", ")}`);
15242
+ const listed = look.listedIcons ?? [];
15243
+ 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)` : ""}`);
15244
+ for (const d of sets) out.push(` from ${d.includes("{name}") ? d : d.replace(/\/+$/, "") + "/{name}.svg"}${listed.length ? "" : ", any file by its name"}`);
15245
+ }
15280
15246
  if (own.length) out.push(`
15281
15247
  icons from the look's folders (${own.length}; "fastdraw icons <look> [word]" lists or searches them)
15282
15248
  ${own.slice(0, 60).join(", ")}${own.length > 60 ? ", ..." : ""}`);
15283
- out.push(`
15249
+ const outlines = [...look.icons.keys()].filter((n) => !look.hideBuiltIns || !isBuiltIn(look, n) && !look.images.has(n));
15250
+ if (look.hideBuiltIns) {
15251
+ if (outlines.length) out.push(`
15252
+ the look's own outline icons
15253
+ ${outlines.join(", ")}`);
15254
+ out.push("\nbuilt-in icons: hidden by this look (icons builtin=hidden); use the icons above");
15255
+ } else out.push(`
15284
15256
  ${own.length ? "built-in icons" : "icons"} (icon=name on any box, or a box of style "icon")
15285
- ${[...look.icons.keys()].join(", ")}`);
15257
+ ${outlines.join(", ")}`);
15286
15258
  if (look.guidance.length) {
15287
15259
  out.push("\nguidance from this look");
15288
15260
  for (const g of look.guidance) out.push(` - ${g}`);
@@ -15299,9 +15271,9 @@ function about(md, name2) {
15299
15271
  }
15300
15272
 
15301
15273
  // src/setup.ts
15302
- import { readFileSync as readFileSync3, writeFileSync as writeFileSync3, existsSync as existsSync3, mkdirSync, realpathSync as realpathSync3, lstatSync as lstatSync3 } from "node:fs";
15274
+ import { readFileSync as readFileSync3, writeFileSync as writeFileSync3, existsSync as existsSync3, mkdirSync as mkdirSync2, realpathSync as realpathSync3, lstatSync as lstatSync3 } from "node:fs";
15303
15275
  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";
15276
+ import { homedir as homedir2 } from "node:os";
15305
15277
  var TARGETS = ["claude", "agents", "copilot"];
15306
15278
  var START = "<!-- fastdraw:start -->";
15307
15279
  var END = "<!-- fastdraw:end -->";
@@ -15332,7 +15304,7 @@ function prepare(base, file) {
15332
15304
  const real = realpathSync3(at);
15333
15305
  if (!st.isDirectory() || real !== top && !real.startsWith(top + sep3)) refuse();
15334
15306
  }
15335
- if (!st && i < parts.length - 1) mkdirSync(at);
15307
+ if (!st && i < parts.length - 1) mkdirSync2(at);
15336
15308
  }
15337
15309
  }
15338
15310
  function upsert(base, file, body, version) {
@@ -15363,13 +15335,13 @@ function detect(dir) {
15363
15335
  }
15364
15336
  function setup(root2, dir, targets, global = false) {
15365
15337
  const lines = [], version = packageVersion(root2);
15366
- const show = (f) => f.startsWith(dir) ? relative2(dir, f) : f.replace(homedir(), "~");
15338
+ const show = (f) => f.startsWith(dir) ? relative2(dir, f) : f.replace(homedir2(), "~");
15367
15339
  for (const t of targets) {
15368
15340
  if (t === "claude") {
15369
- const base = global ? join3(homedir(), ".claude") : dir;
15341
+ const base = global ? join3(homedir2(), ".claude") : dir;
15370
15342
  const file = join3(global ? base : join3(dir, ".claude"), "skills", "fastdraw", "SKILL.md");
15371
15343
  const was = existsSync3(file);
15372
- if (global) mkdirSync(base, { recursive: true });
15344
+ if (global) mkdirSync2(base, { recursive: true });
15373
15345
  prepare(base, file);
15374
15346
  const skill = readFileSync3(join3(root2, "plugins", "fastdraw", "skills", "fastdraw", "SKILL.md"), "utf8");
15375
15347
  writeFileSync3(file, skill.replace(/^(---\r?\n[\s\S]*?\r?\n---\r?\n)/, `$1${stamp(version)}
@@ -15387,7 +15359,7 @@ function compareVersions(a, b) {
15387
15359
  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
15360
  return 0;
15389
15361
  }
15390
- function installedSkills(dir, home = homedir()) {
15362
+ function installedSkills(dir, home = homedir2()) {
15391
15363
  const out = [];
15392
15364
  const look = (target, file, global = false, section = false) => {
15393
15365
  let text;
@@ -15408,7 +15380,7 @@ function installedSkills(dir, home = homedir()) {
15408
15380
  if (resolve3(home) !== resolve3(dir)) look("claude", join3(home, ".claude", "skills", "fastdraw", "SKILL.md"), true);
15409
15381
  return out;
15410
15382
  }
15411
- function skillNotes(root2, dir, home = homedir()) {
15383
+ function skillNotes(root2, dir, home = homedir2()) {
15412
15384
  const version = packageVersion(root2), found = installedSkills(dir, home), notes = [];
15413
15385
  const from = (fs) => [...new Set(fs.map((f) => f.version || "0.2.0 or earlier"))].join(", ");
15414
15386
  const old = found.filter((f) => !f.version || compareVersions(f.version, version) < 0);
@@ -15428,12 +15400,12 @@ function skillNotes(root2, dir, home = homedir()) {
15428
15400
  }
15429
15401
 
15430
15402
  // src/update.ts
15431
- import { mkdirSync as mkdirSync2, readFileSync as readFileSync4, writeFileSync as writeFileSync4 } from "node:fs";
15403
+ import { mkdirSync as mkdirSync3, readFileSync as readFileSync4, writeFileSync as writeFileSync4 } from "node:fs";
15432
15404
  import { dirname as dirname4, join as join4 } from "node:path";
15433
- import { homedir as homedir2 } from "node:os";
15405
+ import { homedir as homedir3 } from "node:os";
15434
15406
  var DAY = 24 * 60 * 60 * 1e3;
15435
15407
  var URL2 = "https://registry.npmjs.org/fastdraw/latest";
15436
- function cacheFile(env = process.env, home = homedir2(), platform = process.platform) {
15408
+ function cacheFile(env = process.env, home = homedir3(), platform = process.platform) {
15437
15409
  const base = platform === "win32" ? env.LOCALAPPDATA ?? join4(home, "AppData", "Local") : platform === "darwin" ? join4(home, "Library", "Caches") : env.XDG_CACHE_HOME ?? join4(home, ".cache");
15438
15410
  return join4(base, "fastdraw", "latest.json");
15439
15411
  }
@@ -15445,20 +15417,20 @@ async function fromRegistry() {
15445
15417
  async function newerVersion(current, o = {}) {
15446
15418
  const env = o.env ?? process.env, now = o.now ?? Date.now(), file = o.file ?? cacheFile(env);
15447
15419
  if (env.FASTDRAW_NO_UPDATE_CHECK || env.CI) return null;
15448
- let cached = null;
15420
+ let cached2 = null;
15449
15421
  try {
15450
- cached = JSON.parse(readFileSync4(file, "utf8"));
15422
+ cached2 = JSON.parse(readFileSync4(file, "utf8"));
15451
15423
  } catch {
15452
15424
  }
15453
- let latest = cached?.latest ?? null;
15454
- if (!cached || !(now - cached.checked < DAY)) {
15425
+ let latest = cached2?.latest ?? null;
15426
+ if (!cached2 || !(now - cached2.checked < DAY)) {
15455
15427
  try {
15456
15428
  latest = await (o.fetchLatest ?? fromRegistry)();
15457
15429
  } catch {
15458
15430
  latest = null;
15459
15431
  }
15460
15432
  try {
15461
- mkdirSync2(dirname4(file), { recursive: true });
15433
+ mkdirSync3(dirname4(file), { recursive: true });
15462
15434
  writeFileSync4(file, JSON.stringify({ checked: now, latest }));
15463
15435
  } catch {
15464
15436
  }
@@ -15498,13 +15470,16 @@ function usage() {
15498
15470
  check <file.fdraw | folder> ... report problems, with line numbers. A folder means every
15499
15471
  .fdraw file under it
15500
15472
  render <file.fdraw | folder> ... [-o out.png|.svg] [--scale 2] [--transparent] [--no-embed]
15501
- [--look name|file.look] [--dark]
15473
+ [--look name|file.look|https://...look] [--dark] [--offline]
15502
15474
  draw the diagram (PNG by default) next to it. With several
15503
15475
  files or a folder, checks them all first and draws nothing
15504
15476
  if any has an error. --look draws with another look instead
15505
15477
  of the file's own. --dark also writes x-dark.png with the
15506
15478
  look's dark version (the look's dark line; Night for the
15507
- built-in look)
15479
+ built-in look). A look named by https:// address (one on
15480
+ GitHub, say), and the icons and fonts a look names that way,
15481
+ are fetched and kept in a cache folder; --offline (also for
15482
+ check) uses only what is already there
15508
15483
  sizes [file.fdraw | file.look] list the look's styles and their sizes
15509
15484
  (the built-in look when no file is given)
15510
15485
  init-look [path] write the built-in look to a file to make your own
@@ -15555,9 +15530,23 @@ function diagramFiles(paths) {
15555
15530
  }
15556
15531
  var VALUE_FLAGS = ["-o", "--scale", "--look", "--editor"];
15557
15532
  var positional = (a) => a.filter((x, i) => !x.startsWith("-") && !VALUE_FLAGS.includes(a[i - 1]));
15533
+ var fetchWeb = async (files) => {
15534
+ const li = args.indexOf("--look"), over2 = li >= 0 && args[li + 1] ? [args[li + 1]] : [];
15535
+ for (const n of await fetchWebAssets(files, args.includes("--offline"), over2)) console.log(`note: ${n}`);
15536
+ };
15537
+ if (cmd === "sizes" || cmd === "icons" || cmd === "preview-look") {
15538
+ const i = args.findIndex((a, j) => isWebLook(a) && args[j - 1] !== "-o");
15539
+ if (i >= 0) {
15540
+ const url = args[i];
15541
+ for (const n of await fetchWebAssets([], args.includes("--offline"), [url])) console.log(`note: ${n}`);
15542
+ if (cmd === "preview-look" && !args.includes("-o")) args.push("-o", url.replace(/[?#].*$/, "").replace(/^.*\//, "").replace(/\.look$/i, "") + "-preview.png");
15543
+ args[i] = webLookFile(url);
15544
+ }
15545
+ }
15558
15546
  if (cmd === "check") {
15559
15547
  const { files, many } = diagramFiles(positional(args));
15560
15548
  if (!files.length) usage();
15549
+ await fetchWeb(files);
15561
15550
  if (!many) process.exit(report(files[0]).errors ? 1 : 0);
15562
15551
  let errors = 0, warns = 0, hints = 0;
15563
15552
  for (const f of files) {
@@ -15574,6 +15563,7 @@ ${files.length} files: ${errors} error(s), ${warns} warning(s), ${hints} hint(s)
15574
15563
  } else if (cmd === "render") {
15575
15564
  const { files, many } = diagramFiles(positional(args));
15576
15565
  if (!files.length) usage();
15566
+ await fetchWeb(files);
15577
15567
  const oi = args.indexOf("-o"), si = args.indexOf("--scale"), li = args.indexOf("--look");
15578
15568
  if (oi >= 0 && many) {
15579
15569
  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 +15577,7 @@ ${files.length} files: ${errors} error(s), ${warns} warning(s), ${hints} hint(s)
15587
15577
  const transparent = args.includes("--transparent"), embed = !args.includes("--no-embed"), dark = args.includes("--dark");
15588
15578
  let lookOver;
15589
15579
  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";
15580
+ 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
15581
  if (typeof r === "string") {
15592
15582
  console.log(r);
15593
15583
  process.exit(1);
@@ -15655,6 +15645,7 @@ ${files.length} files: ${errors} error(s), ${warns} warning(s), ${hints} hint(s)
15655
15645
  console.log(`wrote ${out} (${sc.w}x${sc.h}${notes.length ? ", " + notes.join(", ") : ""})`);
15656
15646
  }
15657
15647
  } else if (cmd === "sizes") {
15648
+ if (args[0]) await fetchWeb([args[0]]);
15658
15649
  const look = !args[0] ? defaultLook() : args[0].endsWith(".look") ? loadLook(args[0]) : loadScene(args[0]).look;
15659
15650
  const lf = lookFonts(!args[0] ? void 0 : args[0].endsWith(".look") ? args[0] : lookFileOf(args[0]), look);
15660
15651
  console.log(sizesReport(look, lf.missing));
@@ -15670,6 +15661,7 @@ ${files.length} files: ${errors} error(s), ${warns} warning(s), ${hints} hint(s)
15670
15661
  const file = args.find((a, i) => !a.startsWith("-") && args[i - 1] !== "-o");
15671
15662
  const oi = args.indexOf("-o");
15672
15663
  const out = oi >= 0 ? args[oi + 1] : (file ? file.replace(/\.look$/, "") : "default") + "-preview.png";
15664
+ if (file) await fetchWeb([file]);
15673
15665
  const look = file ? loadLook(file) : defaultLook();
15674
15666
  const errs = look.issues.filter((i) => i.level === "error");
15675
15667
  if (errs.length) {
@@ -15735,13 +15727,21 @@ ${files.length} files: ${errors} error(s), ${warns} warning(s), ${hints} hint(s)
15735
15727
  });
15736
15728
  y += 60;
15737
15729
  heading("Icons");
15738
- [...look.icons.keys()].filter((n) => NAMED_ICONS.has(n) || !isBuiltIn(look, n)).forEach((n, i) => {
15730
+ 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);
15731
+ const sheetIcons = ownIcons.length || look.hideBuiltIns ? ownIcons : [...look.icons.keys()].filter((n) => NAMED_ICONS.has(n));
15732
+ sheetIcons.forEach((n, i) => {
15739
15733
  const cx2 = 40 + i % 11 * 80;
15740
15734
  if (i && i % 11 === 0) y += 60;
15741
15735
  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`);
15736
+ 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
15737
  });
15744
15738
  y += 76;
15739
+ if (ownIcons.length) {
15740
+ const total = (/* @__PURE__ */ new Set([...look.images.keys(), ...look.iconUrls.keys(), ...look.listedIcons ?? []])).size;
15741
+ y += 8;
15742
+ 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`);
15743
+ y += 12;
15744
+ }
15745
15745
  heading("Text");
15746
15746
  for (const s of all.filter((t) => t.kind === "text")) {
15747
15747
  const size = +(s.props.size ?? 12);
@@ -15770,8 +15770,9 @@ ${files.length} files: ${errors} error(s), ${warns} warning(s), ${hints} hint(s)
15770
15770
  console.log(`wrote ${out}: ${all.length} styles`);
15771
15771
  } else if (cmd === "icons") {
15772
15772
  const file = args[0]?.endsWith(".look") ? args[0] : void 0, word = (file ? args[1] : args[0])?.toLowerCase();
15773
+ if (file) await fetchWeb([file]);
15773
15774
  const look = file ? loadLook(file) : defaultLook();
15774
- const names = [.../* @__PURE__ */ new Set([...look.images.keys(), ...look.icons.keys()])].filter((n) => !word || iconMatches(n, word));
15775
+ 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
15776
  console.log(names.length ? names.join("\n") : `no icon${word ? ` for "${word}"` : ""}`);
15776
15777
  } else if (cmd === "guide") {
15777
15778
  const topic = args[0];