@teurons/vds-diagrams 0.0.0-stage → 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.
Files changed (51) hide show
  1. package/README.md +170 -2
  2. package/dist/cli.js +2244 -0
  3. package/dist/diagrams.css +991 -0
  4. package/dist/grid.d.ts +1 -0
  5. package/dist/grid.js +283 -0
  6. package/dist/index.d.ts +1 -0
  7. package/dist/index.js +2044 -0
  8. package/dist/skills/vds-aggregates/SKILL.md +115 -0
  9. package/dist/skills/vds-ask-or-park/SKILL.md +101 -0
  10. package/dist/skills/vds-book-to-spec/SKILL.md +136 -0
  11. package/dist/skills/vds-build-from-published/SKILL.md +89 -0
  12. package/dist/skills/vds-change/SKILL.md +113 -0
  13. package/dist/skills/vds-context-map/SKILL.md +125 -0
  14. package/dist/skills/vds-contexts/SKILL.md +134 -0
  15. package/dist/skills/vds-diagrams/SKILL.md +88 -0
  16. package/dist/skills/vds-entities-and-values/SKILL.md +108 -0
  17. package/dist/skills/vds-language/SKILL.md +106 -0
  18. package/dist/skills/vds-model-review/SKILL.md +123 -0
  19. package/dist/skills/vds-ports-and-adapters/SKILL.md +119 -0
  20. package/dist/skills/vds-publish/SKILL.md +123 -0
  21. package/dist/skills/vds-reframe/SKILL.md +122 -0
  22. package/dist/skills/vds-requirements/SKILL.md +128 -0
  23. package/dist/skills/vds-requirements-review/SKILL.md +121 -0
  24. package/dist/skills/vds-scenarios/SKILL.md +142 -0
  25. package/dist/skills/vds-slice-blocks/SKILL.md +127 -0
  26. package/dist/skills/vds-story-walk/SKILL.md +128 -0
  27. package/dist/skills/vds-strip-invented/SKILL.md +130 -0
  28. package/dist/skills/vds-subdomains/SKILL.md +127 -0
  29. package/dist/skills/vds-which-skill/FILE-SHAPES.md +312 -0
  30. package/dist/skills/vds-which-skill/SKILL.md +125 -0
  31. package/dist/types/diagrams/src/grid/camera.d.ts +32 -0
  32. package/dist/types/diagrams/src/grid/capability.d.ts +11 -0
  33. package/dist/types/diagrams/src/grid/fold-uj.d.ts +2 -0
  34. package/dist/types/diagrams/src/grid/grid-canvas.d.ts +95 -0
  35. package/dist/types/diagrams/src/grid/index.d.ts +5 -0
  36. package/dist/types/diagrams/src/grid/input.d.ts +93 -0
  37. package/dist/types/diagrams/src/grid/route.d.ts +21 -0
  38. package/dist/types/engine/js/bridge.d.ts +12 -0
  39. package/dist/types/engine/js/index.d.ts +73 -0
  40. package/dist/types/vds-diagrams/src/canvas.d.ts +43 -0
  41. package/dist/types/vds-diagrams/src/from-scenarios.d.ts +4 -0
  42. package/dist/types/vds-diagrams/src/grid-folds.d.ts +1 -0
  43. package/dist/types/vds-diagrams/src/grid.d.ts +2 -0
  44. package/dist/types/vds-diagrams/src/index.d.ts +6 -0
  45. package/dist/types/vds-diagrams/src/types.d.ts +39 -0
  46. package/dist/types/vds-diagrams/src/user-journey.d.ts +54 -0
  47. package/dist/types/vds-diagrams/src/workspace.d.ts +25 -0
  48. package/dist/vds_engine.wasm +0 -0
  49. package/dist/workspace.d.ts +1 -0
  50. package/dist/workspace.js +113 -0
  51. package/package.json +68 -3
@@ -0,0 +1,25 @@
1
+ import { type Files, type Finding } from '../../engine/js/index.js';
2
+ import type { DiagramGrid } from './types.js';
3
+ /** Every file under a workspace's domain/, as {path under domain/: text}. */
4
+ export type WorkspaceFiles = Files;
5
+ export type { Finding };
6
+ /** Where to load the engine from, when it is not beside this file (a CDN, or the repo's tests). */
7
+ export declare function useEngineWasm(url: URL): void;
8
+ /** What a check found: problems block, steps not modelled yet do not, open questions are asked. */
9
+ export interface WorkspaceReport {
10
+ problems: Finding[];
11
+ incomplete: Finding[];
12
+ open: string[];
13
+ }
14
+ /** Checks a workspace: every problem, every step not modelled yet, every open question. */
15
+ export declare function checkWorkspace(files: WorkspaceFiles): Promise<WorkspaceReport>;
16
+ /**
17
+ * Each scenario grid, keyed by its id (DGSF-<code>-<hash>); empty while the workspace has
18
+ * problems.
19
+ */
20
+ export declare function compileScenarioGrids(files: WorkspaceFiles): Promise<Record<string, DiagramGrid>>;
21
+ /**
22
+ * Every file of a workspace folder as {path under domain/: text}, the shape checkWorkspace takes. Give the
23
+ * workspace (it holds domain/) or the domain folder itself. Node only.
24
+ */
25
+ export declare function readWorkspaceFolder(dir: string): Promise<WorkspaceFiles>;
Binary file
@@ -0,0 +1 @@
1
+ export * from './types/vds-diagrams/src/workspace.js';
@@ -0,0 +1,113 @@
1
+ // ../engine/js/bridge.ts
2
+ var enc = new TextEncoder();
3
+ var dec = new TextDecoder();
4
+ function instanceOf(module) {
5
+ return new WebAssembly.Instance(module, {});
6
+ }
7
+ function bridge(instance) {
8
+ const x = instance.exports;
9
+ const read = (packed) => {
10
+ const ptr = Number(packed >> 32n);
11
+ const len = Number(packed & 0xffffffffn);
12
+ const text = dec.decode(new Uint8Array(x.memory.buffer, ptr, len));
13
+ x.dealloc(ptr, len);
14
+ return text;
15
+ };
16
+ const call = (fn, input) => {
17
+ const bytes = enc.encode(input);
18
+ const ptr = x.alloc(bytes.length);
19
+ new Uint8Array(x.memory.buffer, ptr, bytes.length).set(bytes);
20
+ return read(x[fn](ptr, bytes.length));
21
+ };
22
+ return {
23
+ call,
24
+ json: (fn, input) => JSON.parse(call(fn, JSON.stringify(input))),
25
+ none: (fn) => JSON.parse(read(x[fn]()))
26
+ };
27
+ }
28
+
29
+ // ../engine/js/index.ts
30
+ function ok(answer) {
31
+ if (answer && typeof answer === "object" && "error" in answer)
32
+ throw new Error(String(answer.error));
33
+ return answer;
34
+ }
35
+ function bind(instance) {
36
+ const { call, json, none } = bridge(instance);
37
+ return {
38
+ check: (files) => json("check", files),
39
+ flows: (files) => json("flows", files),
40
+ grids: (files) => json("grids", files),
41
+ hexagons: (files) => json("hexagons", files),
42
+ contextMap: (files) => json("context_map", files),
43
+ open: (files) => json("open", files),
44
+ generated: (files) => call("generated", JSON.stringify(files)),
45
+ index: (files) => call("index", JSON.stringify(files)),
46
+ snapshot: (files) => ok(json("snapshot", { spec: "0.1", files })),
47
+ toYaml: (value) => call("to_yaml", JSON.stringify(value)),
48
+ parseInput: (text) => ok(JSON.parse(call("parse_input", text))),
49
+ owned: () => ok(none("owned")),
50
+ closure: (files, caps) => ok(json("closure", { caps, files }))
51
+ };
52
+ }
53
+ function instantiate(module) {
54
+ return bind(instanceOf(module));
55
+ }
56
+
57
+ // src/workspace.ts
58
+ var engine;
59
+ var where;
60
+ function useEngineWasm(url) {
61
+ where = url;
62
+ engine = void 0;
63
+ }
64
+ async function wasmBytes() {
65
+ const url = where ?? new URL("./vds_engine.wasm", import.meta.url);
66
+ if (typeof window === "undefined") {
67
+ const { readFile } = await import("node:fs/promises");
68
+ const { fileURLToPath } = await import("node:url");
69
+ const b = await readFile(fileURLToPath(String(url)));
70
+ return b.buffer.slice(b.byteOffset, b.byteOffset + b.byteLength);
71
+ }
72
+ return (await fetch(url)).arrayBuffer();
73
+ }
74
+ function load() {
75
+ engine ??= wasmBytes().then(async (b) => instantiate(await WebAssembly.compile(b)));
76
+ return engine;
77
+ }
78
+ async function checkWorkspace(files) {
79
+ const s = (await load()).snapshot(files);
80
+ return { problems: s.problems, incomplete: s.incomplete, open: s.open };
81
+ }
82
+ async function compileScenarioGrids(files) {
83
+ const m = await load();
84
+ const grids = m.grids(files);
85
+ if ("error" in grids) throw new Error(String(grids.error));
86
+ const out = {};
87
+ for (const [path, text] of Object.entries(grids)) {
88
+ const id = /([^/]+)\.grid$/.exec(path)?.[1];
89
+ if (id) out[id] = m.parseInput(text);
90
+ }
91
+ return out;
92
+ }
93
+ async function readWorkspaceFolder(dir) {
94
+ const { readdir, readFile, stat } = await import("node:fs/promises");
95
+ const { join, relative } = await import("node:path");
96
+ const root = await stat(join(dir, "domain")).catch(() => null) ? join(dir, "domain") : dir;
97
+ const out = {};
98
+ const walk = async (d) => {
99
+ for (const e of await readdir(d, { withFileTypes: true })) {
100
+ const p = join(d, e.name);
101
+ if (e.isDirectory()) await walk(p);
102
+ else out[relative(root, p)] = await readFile(p, "utf8");
103
+ }
104
+ };
105
+ await walk(root);
106
+ return out;
107
+ }
108
+ export {
109
+ checkWorkspace,
110
+ compileScenarioGrids,
111
+ readWorkspaceFolder,
112
+ useEngineWasm
113
+ };
package/package.json CHANGED
@@ -1,6 +1,71 @@
1
1
  {
2
2
  "name": "@teurons/vds-diagrams",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
3
+ "version": "0.3.0",
4
+ "description": "Validate a VDS workspace or a user journey, compile its scenario grids, and draw scenario diagrams and capability diagrams in React, in Full and user journey views.",
5
+ "type": "module",
6
+ "bin": {
7
+ "vds-diagrams": "dist/cli.js"
8
+ },
9
+ "exports": {
10
+ ".": {
11
+ "types": "./dist/index.d.ts",
12
+ "default": "./dist/index.js"
13
+ },
14
+ "./grid": {
15
+ "types": "./dist/grid.d.ts",
16
+ "default": "./dist/grid.js"
17
+ },
18
+ "./workspace": {
19
+ "types": "./dist/workspace.d.ts",
20
+ "default": "./dist/workspace.js"
21
+ },
22
+ "./diagrams.css": "./dist/diagrams.css",
23
+ "./package.json": "./package.json"
24
+ },
25
+ "files": [
26
+ "dist",
27
+ "README.md"
28
+ ],
29
+ "sideEffects": [
30
+ "*.css"
31
+ ],
32
+ "engines": {
33
+ "node": ">=20"
34
+ },
35
+ "publishConfig": {
36
+ "registry": "https://registry.npmjs.org/",
37
+ "access": "public"
38
+ },
39
+ "repository": {
40
+ "type": "git",
41
+ "url": "git+https://github.com/teurons/vds.git",
42
+ "directory": "packages/vds-diagrams"
43
+ },
44
+ "dependencies": {
45
+ "@xyflow/react": "^12.12.1"
46
+ },
47
+ "peerDependencies": {
48
+ "@teurons/ui": ">=0.8.1",
49
+ "react": "^19",
50
+ "react-dom": "^19"
51
+ },
52
+ "devDependencies": {
53
+ "@teurons/ui": "^0.8.1",
54
+ "@types/react": "19.2.18",
55
+ "@types/react-dom": "19.2.7",
56
+ "@vds/diagrams": "0.1.0",
57
+ "@vds/engine": "0.1.0",
58
+ "@vds/tsconfig": "0.1.0",
59
+ "esbuild": "0.28.1",
60
+ "react": "^19.3.1",
61
+ "react-dom": "^19.3.1",
62
+ "@types/node": "25.9.1",
63
+ "vitest": "5.0.1",
64
+ "happy-dom": "20.14.5"
65
+ },
66
+ "scripts": {
67
+ "build": "node build.ts",
68
+ "type-check": "tsc --noEmit -p .",
69
+ "test": "vitest run"
70
+ }
6
71
  }