@staix/vault-mem-ui 0.0.0-stage → 0.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.
Files changed (64) hide show
  1. package/CHANGELOG.md +15 -0
  2. package/LICENSE +21 -0
  3. package/README.md +96 -2
  4. package/THIRD_PARTY_NOTICES.md +164 -0
  5. package/bin/vmem-ui.ts +26 -0
  6. package/dist/panel.css +666 -0
  7. package/dist/panel.js +355 -0
  8. package/package.json +53 -4
  9. package/src/client/App.tsx +167 -0
  10. package/src/client/a11y.ts +54 -0
  11. package/src/client/acon.ts +46 -0
  12. package/src/client/components.tsx +243 -0
  13. package/src/client/data.ts +66 -0
  14. package/src/client/fake.ts +48 -0
  15. package/src/client/graph-export.tsx +21 -0
  16. package/src/client/host.ts +80 -0
  17. package/src/client/markdown/parse.ts +620 -0
  18. package/src/client/markdown/render.tsx +270 -0
  19. package/src/client/panel.css +666 -0
  20. package/src/client/panel.tsx +66 -0
  21. package/src/client/prefs.ts +76 -0
  22. package/src/client/standalone.ts +44 -0
  23. package/src/client/store.ts +201 -0
  24. package/src/client/views/assertions.tsx +109 -0
  25. package/src/client/views/common.ts +15 -0
  26. package/src/client/views/history.tsx +205 -0
  27. package/src/client/views/lint.tsx +27 -0
  28. package/src/client/views/log.tsx +64 -0
  29. package/src/client/views/note.tsx +128 -0
  30. package/src/client/views/notes.tsx +34 -0
  31. package/src/client/views/overview.tsx +74 -0
  32. package/src/client/views/promote.tsx +112 -0
  33. package/src/client/views/proposals.tsx +55 -0
  34. package/src/client/views/settings.tsx +57 -0
  35. package/src/client/write.ts +144 -0
  36. package/src/graph/decisionChains.ts +122 -0
  37. package/src/graph/derive.ts +338 -0
  38. package/src/graph/export.ts +44 -0
  39. package/src/graph/insights.ts +254 -0
  40. package/src/graph/labels.ts +67 -0
  41. package/src/graph/layout/client.ts +139 -0
  42. package/src/graph/layout/engine.ts +107 -0
  43. package/src/graph/layout/fa2.d.ts +8 -0
  44. package/src/graph/layout/protocol.ts +70 -0
  45. package/src/graph/layout/worker.ts +132 -0
  46. package/src/graph/model.ts +230 -0
  47. package/src/graph/positions.ts +41 -0
  48. package/src/graph/search.ts +54 -0
  49. package/src/graph/style.ts +301 -0
  50. package/src/graph/target.ts +38 -0
  51. package/src/graph/types.ts +64 -0
  52. package/src/graph/view/GraphView.tsx +279 -0
  53. package/src/graph/view/SidePanels.tsx +141 -0
  54. package/src/graph/view/cache.ts +42 -0
  55. package/src/graph/view/canvas.ts +309 -0
  56. package/src/graph/view/graph-snapshot.ts +75 -0
  57. package/src/graph/view/lod.ts +30 -0
  58. package/src/graph/view/motion.ts +4 -0
  59. package/src/graph/view/state.ts +240 -0
  60. package/src/plugin/assets.ts +33 -0
  61. package/src/plugin/graph.ts +71 -0
  62. package/src/plugin/index.ts +23 -0
  63. package/src/server/cli.ts +99 -0
  64. package/src/server/host.ts +287 -0
@@ -0,0 +1,21 @@
1
+ import type { GraphModel } from "../graph/model";
2
+ import { exportGraphHtml, type GraphPositions } from "../graph/export";
3
+ import { useId } from "react";
4
+
5
+ /** Start a local download without changing the panel's script or worker policy. */
6
+ export function downloadGraphHtml(model: GraphModel, positions: GraphPositions): void {
7
+ const url = URL.createObjectURL(new Blob([exportGraphHtml(model, positions)], { type: "text/html;charset=utf-8" }));
8
+ const link = document.createElement("a");
9
+ link.href = url;
10
+ link.download = "vault-graph.html";
11
+ document.body.append(link);
12
+ link.click();
13
+ link.remove();
14
+ setTimeout(() => URL.revokeObjectURL(url), 1000);
15
+ }
16
+
17
+ /** Read positions at the click, so a running layout exports its current canvas coordinates. */
18
+ export function GraphExportButton({ model, positions, disabledReason }: { model: GraphModel; positions: GraphPositions | (() => GraphPositions); disabledReason?: string }) {
19
+ const hintId = useId();
20
+ return <><button type="button" className="vmem-button" disabled={Boolean(disabledReason)} aria-describedby={disabledReason ? hintId : undefined} onClick={() => downloadGraphHtml(model, typeof positions === "function" ? positions() : positions)}>Export filtered graph HTML</button>{disabledReason && <span id={hintId} className="vmem-sub">{disabledReason}</span>}</>;
21
+ }
@@ -0,0 +1,80 @@
1
+ /**
2
+ * The small host interface the client is written against (spec: issue #1, milestone 1).
3
+ *
4
+ * `acon` supplies its `ConsoleHost` through `createAconHost`; the standalone shell supplies the same four
5
+ * members over its HTTP endpoints. Nothing here knows about either transport, so a fake host runs the views
6
+ * in tests.
7
+ */
8
+
9
+ /** Query parameters carried by a panel navigation; the shell also keeps them in the URL. */
10
+ export type Params = Record<string, unknown>;
11
+
12
+ export interface SnapshotInput extends Params {
13
+ panel: string;
14
+ }
15
+
16
+ export interface SnapshotReply extends Record<string, unknown> {}
17
+
18
+ export interface Theme {
19
+ mode: "light" | "dark";
20
+ tokens?: Record<string, string>;
21
+ }
22
+
23
+ /** A planned file change of a previewed write, as the provider reports it. */
24
+ export interface Change {
25
+ op: string;
26
+ target: string;
27
+ note?: string;
28
+ }
29
+
30
+ /**
31
+ * The provider's answer to one `action` call. A write first answers `needsConfirm` with a fingerprint and the
32
+ * preview the person decides on; the same call with `confirmed: true` and that fingerprint performs it.
33
+ */
34
+ export interface ActionResult {
35
+ ok?: boolean;
36
+ error?: string;
37
+ message?: string;
38
+ needsConfirm?: boolean;
39
+ fingerprint?: string;
40
+ confirmToken?: string;
41
+ verb?: string;
42
+ preview?: string[];
43
+ changes?: Change[];
44
+ warnings?: string[];
45
+ applied?: boolean;
46
+ /** A host that owns the confirmation (`confirm: "host"`) reports the person's cancellation this way. */
47
+ cancelled?: boolean;
48
+ }
49
+
50
+ export interface ActionInput extends Params {
51
+ action: string;
52
+ confirmed?: boolean;
53
+ fingerprint?: string;
54
+ confirmToken?: string;
55
+ }
56
+
57
+ export interface Host {
58
+ /** Element the client renders into. The client owns its contents and removes them on `destroy`. */
59
+ mount: HTMLElement;
60
+ /** Ask for the current panel's data. `panel` is used by hosts that route it themselves (standalone, fake). */
61
+ snapshot(input: SnapshotInput): Promise<SnapshotReply>;
62
+ /** One provider call, including the confirm round trip of a write. */
63
+ action(input: ActionInput): Promise<ActionResult>;
64
+ /** The host's current theme; the person's own preference may override it for this panel. */
65
+ theme(): Theme;
66
+ /**
67
+ * Who shows the preview and sends the confirmation. `"client"` (the default) means `action` answers the
68
+ * provider's `needsConfirm` to this panel, which renders the preview and re-sends the fingerprint — what the
69
+ * fake host and a host that answers the provider directly do. `"host"` means the host runs that round trip
70
+ * itself and only resolves `action` with the outcome, as `acon` does: its console mints the confirm token,
71
+ * renders the preview in its own dialog and refuses a page that sets `confirmed` or `fingerprint`.
72
+ */
73
+ confirm?: "client" | "host";
74
+ /** Push from the host. When absent the client polls `snapshot` instead. */
75
+ subscribe?(listener: (reply: SnapshotReply) => void): () => void;
76
+ /** Switch to a panel. When absent the client switches in place. */
77
+ navigate?(panel: string, params?: Record<string, string>): void;
78
+ /** Theme changes from the host, so the panel follows a console theme switch without a reload. */
79
+ onTheme?(listener: (theme: Theme) => void): () => void;
80
+ }