@huaweidevtools/aishell-dsh-deploy 0.0.18 → 0.0.19

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.
Binary file
package/lib/index.js CHANGED
@@ -1692,7 +1692,7 @@ function withAnchoredPaths(args, ctx) {
1692
1692
  * written by earlier releases carry it — so it is kept even though there is no
1693
1693
  * server.
1694
1694
  */
1695
- const SERVER_VERSION = "aishell-deploy 0.0.18";
1695
+ const SERVER_VERSION = "aishell-deploy 0.0.19";
1696
1696
 
1697
1697
  //#endregion
1698
1698
  //#region src/deployment-state.ts
@@ -6087,16 +6087,56 @@ async function renderD2(source$1) {
6087
6087
  const d2 = new D2();
6088
6088
  try {
6089
6089
  const compiled$1 = await d2.compile(source$1, { options: { layout: "elk" } });
6090
- return await d2.render(compiled$1.diagram, {
6090
+ const svg = await d2.render(compiled$1.diagram, {
6091
6091
  ...compiled$1.renderOptions,
6092
6092
  pad: 20,
6093
6093
  noXMLTag: true
6094
6094
  });
6095
+ return withIntrinsicSize(svg);
6095
6096
  } finally {
6096
6097
  await closeD2(d2);
6097
6098
  }
6098
6099
  }
6099
6100
  /**
6101
+ * Give the outer `<svg>` an intrinsic size.
6102
+ *
6103
+ * ## Why this is not cosmetic
6104
+ *
6105
+ * D2 emits the outer element with a `viewBox` and no `width`/`height`. In CSS,
6106
+ * an SVG with no intrinsic dimensions is a replaced element with no size, and
6107
+ * the browser falls back to 300×150 — then scales the whole `viewBox` into that
6108
+ * box. A picture of a real account is around 5000×1800, so the scale factor is
6109
+ * roughly 0.06 and a 16px label is drawn at about 1px: the diagram renders, and
6110
+ * is unreadable at any preview size.
6111
+ *
6112
+ * That is not a layout problem to tune — the file is correct, and it has no
6113
+ * size of its own. Declaring one gives the browser something to lay out at its
6114
+ * natural dimensions; whatever container shows it can then scale a legible
6115
+ * image down rather than a legible image already scaled to nothing.
6116
+ *
6117
+ * The values come from the viewBox, which is what D2 computed from the content,
6118
+ * so nothing is guessed. A viewBox D2 did not emit is left alone: a wrong size
6119
+ * would be worse than the default, and the caller's render would be reported
6120
+ * as broken for a reason that is not theirs.
6121
+ *
6122
+ * @param svg - the rendered SVG.
6123
+ * @returns the same SVG with `width` and `height` on the outer element.
6124
+ */
6125
+ function withIntrinsicSize(svg) {
6126
+ const outer = /<svg\b[^>]*>/.exec(svg);
6127
+ if (outer === null) return svg;
6128
+ const tag = outer[0];
6129
+ if (/\swidth="/.test(tag) || /\sheight="/.test(tag)) return svg;
6130
+ const viewBox = /\sviewBox="([^"]*)"/.exec(tag);
6131
+ const parts = viewBox?.[1]?.trim().split(/[\s,]+/) ?? [];
6132
+ if (parts.length !== 4) return svg;
6133
+ const width = Number(parts[2]);
6134
+ const height = Number(parts[3]);
6135
+ if (!Number.isFinite(width) || !Number.isFinite(height) || width <= 0 || height <= 0) return svg;
6136
+ const sized = tag.replace(/^<svg\b/, `<svg width="${width}" height="${height}"`);
6137
+ return sized + svg.slice(outer.index + tag.length);
6138
+ }
6139
+ /**
6100
6140
  * Terminate the renderer's worker.
6101
6141
  *
6102
6142
  * `D2` exposes no disposal API, so the thread is terminated directly. The
@@ -83,6 +83,32 @@ export declare function themePreamble(): string[];
83
83
  * so the caller names the generated fragment in its message.
84
84
  */
85
85
  export declare function renderD2(source: string): Promise<string>;
86
+ /**
87
+ * Give the outer `<svg>` an intrinsic size.
88
+ *
89
+ * ## Why this is not cosmetic
90
+ *
91
+ * D2 emits the outer element with a `viewBox` and no `width`/`height`. In CSS,
92
+ * an SVG with no intrinsic dimensions is a replaced element with no size, and
93
+ * the browser falls back to 300×150 — then scales the whole `viewBox` into that
94
+ * box. A picture of a real account is around 5000×1800, so the scale factor is
95
+ * roughly 0.06 and a 16px label is drawn at about 1px: the diagram renders, and
96
+ * is unreadable at any preview size.
97
+ *
98
+ * That is not a layout problem to tune — the file is correct, and it has no
99
+ * size of its own. Declaring one gives the browser something to lay out at its
100
+ * natural dimensions; whatever container shows it can then scale a legible
101
+ * image down rather than a legible image already scaled to nothing.
102
+ *
103
+ * The values come from the viewBox, which is what D2 computed from the content,
104
+ * so nothing is guessed. A viewBox D2 did not emit is left alone: a wrong size
105
+ * would be worse than the default, and the caller's render would be reported
106
+ * as broken for a reason that is not theirs.
107
+ *
108
+ * @param svg - the rendered SVG.
109
+ * @returns the same SVG with `width` and `height` on the outer element.
110
+ */
111
+ export declare function withIntrinsicSize(svg: string): string;
86
112
  /**
87
113
  * Quote a string for a D2 label.
88
114
  *
@@ -18,5 +18,5 @@
18
18
  * written by earlier releases carry it — so it is kept even though there is no
19
19
  * server.
20
20
  */
21
- export declare const SERVER_VERSION = "aishell-deploy 0.0.18";
21
+ export declare const SERVER_VERSION = "aishell-deploy 0.0.19";
22
22
  //# sourceMappingURL=version.d.ts.map
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@huaweidevtools/aishell-dsh-deploy",
3
3
  "description": "Huawei Cloud infrastructure tools for DSH — Terraform, OpenAPI, resource inventory, cost estimates",
4
- "version": "0.0.18",
4
+ "version": "0.0.19",
5
5
  "publishConfig": {
6
6
  "access": "public"
7
7
  },
@@ -32,22 +32,22 @@
32
32
  "hcl2-parser": "^1.0.3",
33
33
  "jsonpath-plus": "^10.4.0",
34
34
  "zod": "^4.2.0",
35
- "@huaweidevtools/aishell-dsh-credentials-store": "0.0.18"
35
+ "@huaweidevtools/aishell-dsh-credentials-store": "0.0.19"
36
36
  },
37
37
  "peerDependencies": {
38
38
  "@deepseek-ai/cordis": "^4.0.4",
39
- "@deepseek-ai/dsh-client-connection": "0.2.0-rc.1 || 0.2.1-rc.1 || 0.2.1-rc.2 || 0.2.1-rc.3 || 0.2.1-rc.4 || 0.2.1-rc.5",
40
- "@deepseek-ai/dsh-llm": "0.2.0-rc.1 || 0.2.1-rc.1 || 0.2.1-rc.2 || 0.2.1-rc.3 || 0.2.1-rc.4 || 0.2.1-rc.5",
41
- "@deepseek-ai/dsh-system-prompt": "0.2.0-rc.1 || 0.2.1-rc.1 || 0.2.1-rc.2 || 0.2.1-rc.3 || 0.2.1-rc.4 || 0.2.1-rc.5",
42
- "@deepseek-ai/dsh-tools": "0.2.0-rc.1 || 0.2.1-rc.1 || 0.2.1-rc.2 || 0.2.1-rc.3 || 0.2.1-rc.4 || 0.2.1-rc.5"
39
+ "@deepseek-ai/dsh-client-connection": "0.2.0-rc.1 || 0.2.1-rc.1 || 0.2.1-rc.2 || 0.2.1-rc.3 || 0.2.1-rc.4 || 0.2.1-rc.5 || 0.2.2-rc.1",
40
+ "@deepseek-ai/dsh-llm": "0.2.0-rc.1 || 0.2.1-rc.1 || 0.2.1-rc.2 || 0.2.1-rc.3 || 0.2.1-rc.4 || 0.2.1-rc.5 || 0.2.2-rc.1",
41
+ "@deepseek-ai/dsh-system-prompt": "0.2.0-rc.1 || 0.2.1-rc.1 || 0.2.1-rc.2 || 0.2.1-rc.3 || 0.2.1-rc.4 || 0.2.1-rc.5 || 0.2.2-rc.1",
42
+ "@deepseek-ai/dsh-tools": "0.2.0-rc.1 || 0.2.1-rc.1 || 0.2.1-rc.2 || 0.2.1-rc.3 || 0.2.1-rc.4 || 0.2.1-rc.5 || 0.2.2-rc.1"
43
43
  },
44
44
  "devDependencies": {
45
45
  "@deepseek-ai/cordis": "^4.0.4",
46
46
  "@deepseek-ai/cordis-plugin-loader": "^1.0.5",
47
- "@deepseek-ai/dsh-client-connection": "0.2.0-rc.1 || 0.2.1-rc.1 || 0.2.1-rc.2 || 0.2.1-rc.3 || 0.2.1-rc.4 || 0.2.1-rc.5",
48
- "@deepseek-ai/dsh-llm": "0.2.0-rc.1 || 0.2.1-rc.1 || 0.2.1-rc.2 || 0.2.1-rc.3 || 0.2.1-rc.4 || 0.2.1-rc.5",
49
- "@deepseek-ai/dsh-system-prompt": "0.2.0-rc.1 || 0.2.1-rc.1 || 0.2.1-rc.2 || 0.2.1-rc.3 || 0.2.1-rc.4 || 0.2.1-rc.5",
50
- "@deepseek-ai/dsh-tools": "0.2.0-rc.1 || 0.2.1-rc.1 || 0.2.1-rc.2 || 0.2.1-rc.3 || 0.2.1-rc.4 || 0.2.1-rc.5",
47
+ "@deepseek-ai/dsh-client-connection": "0.2.0-rc.1 || 0.2.1-rc.1 || 0.2.1-rc.2 || 0.2.1-rc.3 || 0.2.1-rc.4 || 0.2.1-rc.5 || 0.2.2-rc.1",
48
+ "@deepseek-ai/dsh-llm": "0.2.0-rc.1 || 0.2.1-rc.1 || 0.2.1-rc.2 || 0.2.1-rc.3 || 0.2.1-rc.4 || 0.2.1-rc.5 || 0.2.2-rc.1",
49
+ "@deepseek-ai/dsh-system-prompt": "0.2.0-rc.1 || 0.2.1-rc.1 || 0.2.1-rc.2 || 0.2.1-rc.3 || 0.2.1-rc.4 || 0.2.1-rc.5 || 0.2.2-rc.1",
50
+ "@deepseek-ai/dsh-tools": "0.2.0-rc.1 || 0.2.1-rc.1 || 0.2.1-rc.2 || 0.2.1-rc.3 || 0.2.1-rc.4 || 0.2.1-rc.5 || 0.2.2-rc.1",
51
51
  "@deepseek-ai/schemastery": "3.18.4",
52
52
  "tsdown": "^0.10.0",
53
53
  "typescript": "^5.7.0",