schematex 0.9.13 → 0.9.15

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.
@@ -8053,8 +8053,8 @@ function parseNote(ln, state2) {
8053
8053
  throw new UsecaseParseError(`unterminated note block`, ln.line);
8054
8054
  }
8055
8055
  function defaultIdFor(name) {
8056
- const safe = name.replace(/[^A-Za-z0-9_]/g, "_");
8057
- return /^[A-Za-z_]/.test(safe) ? safe : "_" + safe;
8056
+ const safe = name.replace(/[^\p{L}\p{N}_]/gu, "_");
8057
+ return /^[\p{L}_]/u.test(safe) ? safe : "_" + safe;
8058
8058
  }
8059
8059
  function parseRelation(ln, state2) {
8060
8060
  const op = findRelOp(ln.text);
@@ -13444,7 +13444,33 @@ var KIND_ALIASES = {
13444
13444
  ips: "ids",
13445
13445
  decoder: "encoder",
13446
13446
  videowall: "monitor",
13447
- segment: "lan"
13447
+ segment: "lan",
13448
+ // Common everyday synonyms a model reaches for. A specific server role still
13449
+ // renders as a generic `server` (with its label) instead of hard-failing.
13450
+ webserver: "server",
13451
+ mailserver: "server",
13452
+ dns: "server",
13453
+ dhcp: "server",
13454
+ ntp: "server",
13455
+ database: "server",
13456
+ dbserver: "server",
13457
+ db: "server",
13458
+ vm: "server",
13459
+ host: "server",
13460
+ hypervisor: "server",
13461
+ activedirectory: "server",
13462
+ domaincontroller: "server",
13463
+ desktop: "pc",
13464
+ smartphone: "mobile",
13465
+ tablet: "mobile",
13466
+ accesspoint: "ap",
13467
+ wap: "ap",
13468
+ hub: "switch",
13469
+ bridge: "switch",
13470
+ l2switch: "switch",
13471
+ ngfw: "firewall",
13472
+ utm: "firewall",
13473
+ mfp: "printer"
13448
13474
  };
13449
13475
  var GROUP_KINDS = /* @__PURE__ */ new Set(["site", "building", "campus", "rack", "subnet", "vlan", "zone", "dmz"]);
13450
13476
  var GROUP_KIND_ALIAS = { building: "site", campus: "site" };
@@ -29965,7 +29991,23 @@ var FURNITURE_ALIASES = {
29965
29991
  panel: "electrical-panel",
29966
29992
  "breaker-panel": "electrical-panel",
29967
29993
  db: "distribution-board",
29968
- "consumer-unit": "distribution-board"
29994
+ "consumer-unit": "distribution-board",
29995
+ // Common everyday synonyms an LLM reaches for that map cleanly onto an
29996
+ // existing type. Keeps a valid layout from failing on a vocabulary gap.
29997
+ "console-table": "side-table",
29998
+ console: "side-table",
29999
+ "end-table": "side-table",
30000
+ couch: "sofa",
30001
+ settee: "loveseat",
30002
+ "tv-console": "tv-stand",
30003
+ "media-console": "tv-stand",
30004
+ "entertainment-center": "tv-stand",
30005
+ refrigerator: "fridge",
30006
+ cooktop: "stove",
30007
+ stovetop: "stove",
30008
+ armoire: "wardrobe",
30009
+ wc: "toilet",
30010
+ "water-closet": "toilet"
29969
30011
  };
29970
30012
  function parseFurnitureType(t, ln) {
29971
30013
  const word = isWord(t) ? t.word : "";
@@ -36687,6 +36729,9 @@ function parseMermaidErd(lines) {
36687
36729
  const entityMap = /* @__PURE__ */ new Map();
36688
36730
  const order = [];
36689
36731
  const refs = [];
36732
+ let title2;
36733
+ let direction = "LR";
36734
+ let notation = "crowsfoot";
36690
36735
  const ensure = (id) => {
36691
36736
  let e = entityMap.get(id);
36692
36737
  if (!e) {
@@ -36700,6 +36745,33 @@ function parseMermaidErd(lines) {
36700
36745
  while (i < lines.length) {
36701
36746
  const t = lines[i].text;
36702
36747
  const ln = lines[i].lineNumber;
36748
+ const lower = t.toLowerCase();
36749
+ if (lower.startsWith("title:")) {
36750
+ title2 = unquote7(t.slice("title:".length).trim());
36751
+ i++;
36752
+ continue;
36753
+ }
36754
+ if (lower.startsWith("direction:")) {
36755
+ const v = t.slice("direction:".length).trim().toUpperCase();
36756
+ if (v !== "LR" && v !== "TB") {
36757
+ throw new ErdParseError(`Unknown direction '${v}'. Use LR or TB.`, ln);
36758
+ }
36759
+ direction = v;
36760
+ i++;
36761
+ continue;
36762
+ }
36763
+ if (lower.startsWith("notation:")) {
36764
+ const v = t.slice("notation:".length).trim().toLowerCase();
36765
+ if (v !== "crowsfoot") {
36766
+ throw new ErdParseError(
36767
+ `notation '${v}' is documented but not yet implemented in v0.1; use 'crowsfoot'.`,
36768
+ ln
36769
+ );
36770
+ }
36771
+ notation = v;
36772
+ i++;
36773
+ continue;
36774
+ }
36703
36775
  const inlineBlock = new RegExp(`^(${MERMAID_NAME.source})\\s*\\{\\s*(.*?)\\s*\\}$`).exec(t);
36704
36776
  const openBlock = new RegExp(`^(${MERMAID_NAME.source})\\s*\\{$`).exec(t);
36705
36777
  if (inlineBlock) {
@@ -36746,8 +36818,9 @@ function parseMermaidErd(lines) {
36746
36818
  }
36747
36819
  return {
36748
36820
  type: "erd",
36749
- notation: "crowsfoot",
36750
- direction: "LR",
36821
+ notation,
36822
+ direction,
36823
+ title: title2,
36751
36824
  entities: order.map((id) => entityMap.get(id)),
36752
36825
  refs
36753
36826
  };
@@ -42749,6 +42822,24 @@ function normalizeHeader(text2, type) {
42749
42822
  }
42750
42823
  return text2;
42751
42824
  }
42825
+ function headerCandidates(type) {
42826
+ if (type === "erd") return ["erDiagram", "erd"];
42827
+ return [type];
42828
+ }
42829
+ function recoverHeader(plugin, prepared, forced) {
42830
+ if (!forced || !plugin.parse || plugin.detect(prepared)) return prepared;
42831
+ for (const hdr of headerCandidates(plugin.type)) {
42832
+ const candidate = `${hdr}
42833
+ ${prepared}`;
42834
+ if (!plugin.detect(candidate)) continue;
42835
+ try {
42836
+ plugin.parse(candidate);
42837
+ return candidate;
42838
+ } catch {
42839
+ }
42840
+ }
42841
+ return prepared;
42842
+ }
42752
42843
  function preprocess9(text2) {
42753
42844
  const { data, body: rawBody } = parseFrontmatter(stripCodeFences(text2));
42754
42845
  const body = stripComments(rawBody, UNIVERSAL_COMMENT_MARKERS);
@@ -42767,11 +42858,14 @@ function preprocess9(text2) {
42767
42858
  function parse(text2, config) {
42768
42859
  const prepared0 = preprocess9(text2);
42769
42860
  const plugin = detectPlugin(prepared0, config);
42770
- const prepared = normalizeHeader(prepared0, plugin.type);
42771
- if (plugin.parse) return plugin.parse(prepared);
42772
- throw new Error(
42773
- `Diagram type '${plugin.type}' does not yet expose a parse() method.`
42774
- );
42861
+ if (!plugin.parse) {
42862
+ throw new Error(
42863
+ `Diagram type '${plugin.type}' does not yet expose a parse() method.`
42864
+ );
42865
+ }
42866
+ const forced = config?.type != null && plugin.type === config.type;
42867
+ const prepared = recoverHeader(plugin, normalizeHeader(prepared0, plugin.type), forced);
42868
+ return plugin.parse(prepared);
42775
42869
  }
42776
42870
  function parseResult(text2, config) {
42777
42871
  let plugin;
@@ -42783,7 +42877,8 @@ function parseResult(text2, config) {
42783
42877
  `Diagram type '${plugin.type}' does not yet expose a parse() method.`
42784
42878
  );
42785
42879
  }
42786
- const prepared = normalizeHeader(prepared0, plugin.type);
42880
+ const forced = config?.type != null && plugin.type === config.type;
42881
+ const prepared = recoverHeader(plugin, normalizeHeader(prepared0, plugin.type), forced);
42787
42882
  const ast = plugin.parse(prepared);
42788
42883
  const diagnostics = runLint(plugin, prepared);
42789
42884
  return {
@@ -42814,7 +42909,8 @@ function render(text2, config) {
42814
42909
  if (config?.mode === "preview") return renderResult(text2, config).svg;
42815
42910
  const prepared0 = preprocess9(text2);
42816
42911
  const plugin = detectPlugin(prepared0, config);
42817
- const prepared = normalizeHeader(prepared0, plugin.type);
42912
+ const forced = config?.type != null && plugin.type === config.type;
42913
+ const prepared = recoverHeader(plugin, normalizeHeader(prepared0, plugin.type), forced);
42818
42914
  return renderWithPlugin(prepared, plugin, config);
42819
42915
  }
42820
42916
  function renderResult(text2, config) {
@@ -42822,7 +42918,8 @@ function renderResult(text2, config) {
42822
42918
  try {
42823
42919
  const prepared0 = preprocess9(text2);
42824
42920
  plugin = detectPlugin(prepared0, config);
42825
- const prepared = normalizeHeader(prepared0, plugin.type);
42921
+ const forced = config?.type != null && plugin.type === config.type;
42922
+ const prepared = recoverHeader(plugin, normalizeHeader(prepared0, plugin.type), forced);
42826
42923
  const svg = renderWithPlugin(prepared, plugin, config);
42827
42924
  const diagnostics = runLint(plugin, prepared);
42828
42925
  return {
@@ -42860,5 +42957,5 @@ function renderWithPlugin(prepared, plugin, config) {
42860
42957
  }
42861
42958
 
42862
42959
  export { FLOORPLAN_SYMBOLS, GEOMETRY, bowtie2 as bowtie, causalloop, comparison, decisiontree, drawDeviceIcon, epc, eventtree, faulttree, floorplan, fmea, gitgraph, iconSize, idef0, markov, network, parse, parseResult, pert, petri, pid, playbook, prisma, rbd, render, renderEquip, renderPreview, renderResult, sequence, state, threatmodel, timeline, umlclass, usecase, welding };
42863
- //# sourceMappingURL=chunk-WPNMVV3U.js.map
42864
- //# sourceMappingURL=chunk-WPNMVV3U.js.map
42960
+ //# sourceMappingURL=chunk-F72IQZ6O.js.map
42961
+ //# sourceMappingURL=chunk-F72IQZ6O.js.map