@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.
- package/assets/studio/assets/index-Caq_0xOc.js +109 -0
- package/assets/studio/index.html +1 -1
- package/assets/viewer/index.html +4 -4
- package/dist/api/dispatch.js +9 -3
- package/dist/api/handlers.d.ts +1 -1
- package/dist/api/handlers.js +26 -8
- package/dist/api/routes.js +51 -11
- package/dist/cli.d.ts +6 -0
- package/dist/cli.js +38 -17
- package/dist/compile.d.ts +1 -1
- package/dist/compile.js +1 -1
- package/dist/diff.d.ts +1 -1
- package/dist/diff.js +27 -6
- package/dist/eject.d.ts +1 -1
- package/dist/eject.js +1 -1
- package/dist/git-ref.js +4 -1
- package/dist/guide.js +1 -1
- package/dist/includes.d.ts +1 -1
- package/dist/init.d.ts +1 -1
- package/dist/init.js +10 -5
- package/dist/lint.js +4 -2
- package/dist/publish/assets.d.ts +1 -1
- package/dist/publish/assets.js +6 -1
- package/dist/publish/discover.js +5 -1
- package/dist/publish/gallery.js +1 -3
- package/dist/publish/html.d.ts +1 -1
- package/dist/publish/html.js +1 -1
- package/dist/publish/publish.d.ts +1 -1
- package/dist/publish/publish.js +6 -6
- package/dist/publish/snapshot.js +16 -5
- package/dist/serve.js +5 -2
- package/dist/snapshots.d.ts +1 -1
- package/dist/snapshots.js +1 -1
- package/dist/watch.d.ts +1 -1
- package/dist/watch.js +1 -1
- package/package.json +2 -2
- package/assets/studio/assets/index-BTb7M_Is.js +0 -109
package/dist/publish/publish.js
CHANGED
|
@@ -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'
|
|
33
|
-
|
|
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
|
package/dist/publish/snapshot.js
CHANGED
|
@@ -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',
|
|
13
|
-
'/usr/bin/
|
|
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({
|
|
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, {
|
|
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,
|
|
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
|
|
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))
|
package/dist/snapshots.d.ts
CHANGED
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
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.
|
|
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.
|
|
47
|
+
"@diagc/core": "1.0.0"
|
|
48
48
|
},
|
|
49
49
|
"publishConfig": {
|
|
50
50
|
"access": "public"
|