@diagc/cli 0.14.1 → 1.0.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.
@@ -1,6 +1,6 @@
1
1
  import { mkdir, readFile, writeFile } from 'node:fs/promises';
2
2
  import path from 'node:path';
3
- import { errMessage, isDrawings } from '@diagc/core';
3
+ import { errMessage, isDrawings } from '@diagc/core/internal';
4
4
  import { classifyAssetRef, rewriteAssetRefs, safeAssetPath } from './assets.js';
5
5
  import { buildGallery } from './gallery.js';
6
6
  import { discoverDiagrams } from './discover.js';
@@ -29,8 +29,10 @@ export async function inlineAssets(model, dirs, cache, label) {
29
29
  if (kind === 'skip')
30
30
  continue;
31
31
  const base = kind === 'library' ? dirs.libraryDir : dirs.assetsDir;
32
- const rel = kind === 'library' ? ref.slice('/library/'.length)
33
- : kind === 'api-assets' ? ref.slice('/api/assets/'.length)
32
+ const rel = kind === 'library'
33
+ ? ref.slice('/library/'.length)
34
+ : kind === 'api-assets'
35
+ ? ref.slice('/api/assets/'.length)
34
36
  : ref;
35
37
  const filePath = safeAssetPath(base, rel);
36
38
  if (filePath === undefined) {
@@ -65,9 +67,7 @@ export async function publishDiagrams(opts) {
65
67
  try {
66
68
  const modelRaw = JSON.parse(await readFile(d.modelPath, 'utf8'));
67
69
  titles.set(d.name, modelRaw.name);
68
- const layout = d.layoutPath !== undefined
69
- ? JSON.parse(await readFile(d.layoutPath, 'utf8'))
70
- : undefined;
70
+ const layout = d.layoutPath !== undefined ? JSON.parse(await readFile(d.layoutPath, 'utf8')) : undefined;
71
71
  // A hand-edited sidecar can be valid JSON and still not be a drawings
72
72
  // overlay. Publishing it would stamp shapeless data into a page that has
73
73
  // no validator of its own, so it is warned about and dropped — the page
@@ -9,8 +9,11 @@ export function findChrome() {
9
9
  if (env !== undefined && existsSync(env))
10
10
  return env;
11
11
  const candidates = [
12
- '/usr/bin/google-chrome', '/usr/bin/google-chrome-stable', '/usr/bin/chromium',
13
- '/usr/bin/chromium-browser', '/snap/bin/chromium',
12
+ '/usr/bin/google-chrome',
13
+ '/usr/bin/google-chrome-stable',
14
+ '/usr/bin/chromium',
15
+ '/usr/bin/chromium-browser',
16
+ '/snap/bin/chromium',
14
17
  '/Applications/Google Chrome.app/Contents/MacOS/Google Chrome',
15
18
  ];
16
19
  return candidates.find((p) => existsSync(p));
@@ -26,10 +29,16 @@ export async function renderPng(htmlPath, pngPath) {
26
29
  try {
27
30
  // Light, by name: `?export=1` already makes the viewer light whatever the browser
28
31
  // prefers, and this says so where the picture is taken.
29
- const page = await browser.newPage({ viewport: { width: 1600, height: 1000 }, deviceScaleFactor: 2, colorScheme: 'light' });
32
+ const page = await browser.newPage({
33
+ viewport: { width: 1600, height: 1000 },
34
+ deviceScaleFactor: 2,
35
+ colorScheme: 'light',
36
+ });
30
37
  // `?export=1` tells the viewer to unfold every group for a full overview.
31
38
  await page.goto(`${pathToFileURL(path.resolve(htmlPath)).href}?export=1`);
32
- await page.waitForFunction(() => window.__DG_READY__ === true, null, { timeout: 15_000 });
39
+ await page.waitForFunction(() => window.__DG_READY__ === true, null, {
40
+ timeout: 15_000,
41
+ });
33
42
  // __DG_BOUNDS__ is the TRUE node bounding box in flow coordinates, so the
34
43
  // frame gets the real content aspect; then re-fit into it (React Flow's
35
44
  // `fitView` prop only fits on init, not after this resize) so nothing clips.
@@ -38,7 +47,9 @@ export async function renderPng(htmlPath, pngPath) {
38
47
  const bounds = await page.evaluate(() => window.__DG_BOUNDS__ ?? { width: 1200, height: 800 });
39
48
  const reserve = await page.evaluate(() => window.__DG_RESERVE__ ?? null);
40
49
  const size = pageSize(bounds, {
41
- maxWidth: 2000, maxHeight: 1400, padding: FRAME_PADDING,
50
+ maxWidth: 2000,
51
+ maxHeight: 1400,
52
+ padding: FRAME_PADDING,
42
53
  // Only a top/bottom legend costs height, which is all `legendReserve`
43
54
  // ever reports today; a side legend would need pageSize to widen instead.
44
55
  reserve: reserve === null || reserve.side === 'left' || reserve.side === 'right' ? 0 : reserve.px,
package/dist/serve.js CHANGED
@@ -2,7 +2,7 @@ import { createReadStream } from 'node:fs';
2
2
  import { stat } from 'node:fs/promises';
3
3
  import { createServer } from 'node:http';
4
4
  import path from 'node:path';
5
- import { errMessage } from '@diagc/core';
5
+ import { errMessage } from '@diagc/core/internal';
6
6
  import { handleApiRequest } from './api/dispatch.js';
7
7
  import * as handlers from './api/handlers.js';
8
8
  /** Content types for what a Vite build actually emits, plus the image formats a
@@ -47,7 +47,10 @@ export function resolveStatic(root, urlPath) {
47
47
  }
48
48
  // Normalizing against '/' first collapses '..' segments before they are ever
49
49
  // joined to a real directory, so the resolve below cannot climb out.
50
- const rel = path.posix.normalize(decoded).replace(/^(\.\.(\/|$))+/, '').replace(/^\/+/, '');
50
+ const rel = path.posix
51
+ .normalize(decoded)
52
+ .replace(/^(\.\.(\/|$))+/, '')
53
+ .replace(/^\/+/, '');
51
54
  const full = path.resolve(root, rel);
52
55
  const rootResolved = path.resolve(root);
53
56
  if (full !== rootResolved && !full.startsWith(rootResolved + path.sep))
@@ -1,4 +1,4 @@
1
- import { type IncludeResolver } from '@diagc/core';
1
+ import { type IncludeResolver } from '@diagc/core/internal';
2
2
  export type SnapshotMode = 'locked' | 'update';
3
3
  export interface SnapshotSession {
4
4
  resolver: IncludeResolver;
package/dist/snapshots.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import { createHash } from 'node:crypto';
2
2
  import { mkdir, readFile, readdir, rm, writeFile } from 'node:fs/promises';
3
3
  import path from 'node:path';
4
- import { IncludeError } from '@diagc/core';
4
+ import { IncludeError } from '@diagc/core/internal';
5
5
  const LOCK_NAME = 'includes.lock.json';
6
6
  const VENDOR_DIR = 'includes';
7
7
  const isHttp = (s) => /^https?:\/\//.test(s);
package/dist/watch.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { type IncludeResolver } from '@diagc/core';
1
+ import { type IncludeResolver } from '@diagc/core/internal';
2
2
  export type WatchEvent = {
3
3
  file: string;
4
4
  ok: true;
package/dist/watch.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { watch as chokidarWatch } from 'chokidar';
2
- import { errMessage } from '@diagc/core';
2
+ import { errMessage } from '@diagc/core/internal';
3
3
  import { compileFile } from './compile.js';
4
4
  /** Human-readable rendering of a compile event, shared by the one-shot
5
5
  * `compile` command, the `watch` command's live log, and the `studio` watcher
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@diagc/cli",
3
- "version": "0.14.1",
3
+ "version": "1.0.0",
4
4
  "description": "Author software-architecture diagrams as code, compile them to a validated model, edit them in a local studio, and publish pages and images.",
5
5
  "license": "AGPL-3.0-only",
6
6
  "author": "Bogdan Frankovskyi",
@@ -44,7 +44,7 @@
44
44
  "fast-glob": "^3.3.0",
45
45
  "jiti": "^2.0.0",
46
46
  "playwright-core": "^1.62.0",
47
- "@diagc/core": "0.14.1"
47
+ "@diagc/core": "1.0.0"
48
48
  },
49
49
  "publishConfig": {
50
50
  "access": "public"