semantic-atlas 0.3.0 → 0.4.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 (49) hide show
  1. package/README.md +27 -1
  2. package/README.zh-CN.md +24 -1
  3. package/dist/cli/bin.js +12 -5
  4. package/dist/cli/standalone-cli.d.ts.map +1 -1
  5. package/dist/cli/standalone-cli.js +8 -0
  6. package/dist/cli/web-cli.d.ts +9 -0
  7. package/dist/cli/web-cli.d.ts.map +1 -0
  8. package/dist/cli/web-cli.js +134 -0
  9. package/dist/graph/graph-store.d.ts +2 -2
  10. package/dist/graph/graph-store.d.ts.map +1 -1
  11. package/dist/graph/graph-store.js +2 -2
  12. package/dist/repository/repository-inspector.d.ts +1 -0
  13. package/dist/repository/repository-inspector.d.ts.map +1 -1
  14. package/dist/repository/repository-inspector.js +13 -0
  15. package/dist/storage/atlas-database.d.ts +7 -1
  16. package/dist/storage/atlas-database.d.ts.map +1 -1
  17. package/dist/storage/atlas-database.js +60 -10
  18. package/dist/web/application/atlas-read-service.d.ts +27 -0
  19. package/dist/web/application/atlas-read-service.d.ts.map +1 -0
  20. package/dist/web/application/atlas-read-service.js +216 -0
  21. package/dist/web/application/primary-repository-catalog.d.ts +15 -0
  22. package/dist/web/application/primary-repository-catalog.d.ts.map +1 -0
  23. package/dist/web/application/primary-repository-catalog.js +202 -0
  24. package/dist/web/application/types.d.ts +41 -0
  25. package/dist/web/application/types.d.ts.map +1 -0
  26. package/dist/web/application/types.js +1 -0
  27. package/dist/web/server/api-router.d.ts +4 -0
  28. package/dist/web/server/api-router.d.ts.map +1 -0
  29. package/dist/web/server/api-router.js +151 -0
  30. package/dist/web/server/local-web-server.d.ts +12 -0
  31. package/dist/web/server/local-web-server.d.ts.map +1 -0
  32. package/dist/web/server/local-web-server.js +100 -0
  33. package/dist/web-client/assets/index-DneaErDj.css +1 -0
  34. package/dist/web-client/assets/index-cze_4vtt.js +2 -0
  35. package/dist/web-client/assets/index-cze_4vtt.js.map +1 -0
  36. package/dist/web-client/index.html +61 -0
  37. package/dist/world/world-graph-query.d.ts +5 -1
  38. package/dist/world/world-graph-query.d.ts.map +1 -1
  39. package/dist/world/world-graph-query.js +4 -2
  40. package/dist/world/world-snapshot-store.d.ts +2 -1
  41. package/dist/world/world-snapshot-store.d.ts.map +1 -1
  42. package/dist/world/world-snapshot-store.js +2 -2
  43. package/docs/architecture/web-viewer.md +225 -0
  44. package/docs/contracts/cli-v1.md +16 -1
  45. package/docs/contracts/http-api-v1.md +155 -0
  46. package/docs/index.md +5 -0
  47. package/docs/log.md +79 -0
  48. package/docs/product-contract.md +31 -3
  49. package/package.json +5 -4
@@ -0,0 +1,100 @@
1
+ import { createReadStream } from "node:fs";
2
+ import { stat } from "node:fs/promises";
3
+ import { createServer } from "node:http";
4
+ import { extname, join, normalize, relative } from "node:path";
5
+ import { fileURLToPath } from "node:url";
6
+ import { createApiRequestHandler } from "./api-router.js";
7
+ export async function startLocalWebServer(options) {
8
+ const apiHandler = createApiRequestHandler(options.readService);
9
+ const assetsDirectory = options.assetsDirectory ?? bundledAssetsDirectory();
10
+ const server = createServer((request, response) => {
11
+ if ((request.url ?? "").startsWith("/api/")) {
12
+ apiHandler(request, response);
13
+ return;
14
+ }
15
+ void serveStaticAsset(assetsDirectory, request, response);
16
+ });
17
+ await new Promise((resolve, reject) => {
18
+ server.once("error", reject);
19
+ server.listen(options.port, "127.0.0.1", resolve);
20
+ });
21
+ const address = server.address();
22
+ if (address === null || typeof address === "string") {
23
+ server.close();
24
+ throw new Error("Semantic Atlas Web did not receive a TCP address");
25
+ }
26
+ return {
27
+ url: `http://127.0.0.1:${address.port}`,
28
+ close: () => new Promise((resolve, reject) => {
29
+ server.close((error) => error === undefined ? resolve() : reject(error));
30
+ }),
31
+ };
32
+ }
33
+ async function serveStaticAsset(assetsDirectory, request, response) {
34
+ if (request.method !== "GET" && request.method !== "HEAD") {
35
+ response.statusCode = 405;
36
+ response.setHeader("Allow", "GET, HEAD");
37
+ response.end();
38
+ return;
39
+ }
40
+ let requestedPath;
41
+ try {
42
+ const url = new URL(request.url ?? "/", "http://127.0.0.1");
43
+ requestedPath = url.pathname === "/" ? "index.html" : decodeURIComponent(url.pathname.slice(1));
44
+ }
45
+ catch {
46
+ response.statusCode = 400;
47
+ response.end("Invalid request");
48
+ return;
49
+ }
50
+ const normalizedPath = normalize(requestedPath);
51
+ const assetPath = join(assetsDirectory, normalizedPath);
52
+ const pathFromAssets = relative(assetsDirectory, assetPath);
53
+ if (pathFromAssets.startsWith("..") || pathFromAssets === "" || pathFromAssets.includes("\0")) {
54
+ respondNotFound(response);
55
+ return;
56
+ }
57
+ try {
58
+ const metadata = await stat(assetPath);
59
+ if (!metadata.isFile()) {
60
+ respondNotFound(response);
61
+ return;
62
+ }
63
+ response.statusCode = 200;
64
+ response.setHeader("Content-Type", contentType(assetPath));
65
+ response.setHeader("Cache-Control", requestedPath === "index.html"
66
+ ? "no-cache"
67
+ : "public, max-age=31536000, immutable");
68
+ if (request.method === "HEAD") {
69
+ response.end();
70
+ return;
71
+ }
72
+ createReadStream(assetPath).pipe(response);
73
+ }
74
+ catch (error) {
75
+ if (error.code === "ENOENT") {
76
+ respondNotFound(response);
77
+ return;
78
+ }
79
+ response.statusCode = 500;
80
+ response.end("Semantic Atlas Web could not load this asset.");
81
+ }
82
+ }
83
+ function bundledAssetsDirectory() {
84
+ return fileURLToPath(new URL("../../web-client/", import.meta.url));
85
+ }
86
+ function respondNotFound(response) {
87
+ response.statusCode = 404;
88
+ response.setHeader("Content-Type", "text/plain; charset=utf-8");
89
+ response.end("Not found");
90
+ }
91
+ function contentType(path) {
92
+ switch (extname(path)) {
93
+ case ".html": return "text/html; charset=utf-8";
94
+ case ".css": return "text/css; charset=utf-8";
95
+ case ".js": return "text/javascript; charset=utf-8";
96
+ case ".svg": return "image/svg+xml";
97
+ case ".png": return "image/png";
98
+ default: return "application/octet-stream";
99
+ }
100
+ }
@@ -0,0 +1 @@
1
+ :root{--ink: #17231d;--ink-muted: #526158;--paper: #f3f0e8;--panel: #fffdf8;--rail: #e7e9df;--line: #d7d9cf;--line-strong: #bfc6ba;--accent: #c75d35;--accent-soft: #f3ded3;--sage: #647d6c;--sage-soft: #dfe8df;--warning: #a67420;--danger: #a64f42;--shadow: 0 18px 45px rgba(31, 45, 37, .08);font-family:Avenir Next,Gill Sans,Trebuchet MS,sans-serif;color:var(--ink);background:var(--paper);font-synthesis:none;text-rendering:optimizeLegibility}*{box-sizing:border-box}html,body{min-width:1120px;min-height:100%;margin:0}body{background:radial-gradient(circle at 72% 8%,rgba(199,93,53,.08),transparent 28rem),linear-gradient(135deg,#f5f2eb,#efeee7)}button,input{font:inherit}button{color:inherit}code,kbd{font-family:SFMono-Regular,Cascadia Code,monospace}.app-shell{display:grid;grid-template-columns:208px minmax(850px,1fr);min-height:100vh}.project-rail{position:sticky;top:0;display:flex;flex-direction:column;height:100vh;padding:22px 14px;overflow:hidden;background:var(--rail);border-right:1px solid var(--line-strong)}.rail-header{padding:0 9px 16px;border-bottom:1px solid var(--line-strong)}.rail-header h1{margin:0;font-family:Iowan Old Style,Baskerville,Georgia,serif;font-size:22px;font-weight:600;letter-spacing:-.02em}.project-list{flex:1;min-height:0;padding-top:10px;overflow-y:auto}.project-button{display:block;width:100%;padding:11px 10px;text-align:left;background:transparent;border:0;border-radius:10px;cursor:pointer;transition:background .15s ease,transform .15s ease}.project-button:hover{background:#ffffff8c}.project-button[aria-current=true]{background:var(--panel);box-shadow:0 5px 14px #23302812}.project-name{display:block;overflow:hidden;font-size:14px;font-weight:650;text-overflow:ellipsis;white-space:nowrap}.rail-empty{padding:18px 10px;color:var(--ink-muted);font-size:13px;line-height:1.55}.workspace{min-width:0}.workspace-header{position:sticky;z-index:20;top:0;display:flex;align-items:center;justify-content:space-between;min-height:58px;padding:9px 24px;background:#f3f0e8e0;border-bottom:1px solid rgba(191,198,186,.75);-webkit-backdrop-filter:blur(16px);backdrop-filter:blur(16px)}.breadcrumbs{display:flex;align-items:center;min-width:0;color:var(--ink-muted);font-size:13px}.breadcrumb-button{max-width:180px;padding:5px 7px;overflow:hidden;color:inherit;text-overflow:ellipsis;white-space:nowrap;background:transparent;border:0;border-radius:5px;cursor:pointer}.breadcrumb-button:hover{color:var(--ink);background:#ffffffb3}.breadcrumb-separator{color:#98a197}.search{position:relative;display:flex;align-items:center;width:280px;height:38px;padding:0 11px;background:var(--panel);border:1px solid var(--line);border-radius:9px;box-shadow:0 5px 16px #2330280a}.search:focus-within{border-color:var(--sage);box-shadow:0 0 0 3px #647d6c1f}.search>svg{flex:0 0 auto;width:17px;fill:none;stroke:var(--ink-muted);stroke-width:1.7}.search input{min-width:0;flex:1;height:100%;padding:0 9px;color:var(--ink);background:transparent;border:0;outline:0}.search input::placeholder{color:#879087}.search input:disabled{cursor:not-allowed}.search-results{position:absolute;top:48px;right:0;width:390px;max-height:430px;padding:7px;overflow-y:auto;background:var(--panel);border:1px solid var(--line);border-radius:11px;box-shadow:var(--shadow)}.search-result{display:block;width:100%;padding:11px 12px;text-align:left;background:transparent;border:0;border-radius:7px;cursor:pointer}.search-result:hover{background:#f1f2ec}.search-result strong{display:block;font-size:13px}.search-result span{display:block;margin-top:3px;overflow:hidden;color:var(--ink-muted);font-size:11px;text-overflow:ellipsis;white-space:nowrap}.search-message{padding:17px 13px;color:var(--ink-muted);font-size:12px}.content-layout{display:grid;grid-template-columns:minmax(660px,1fr) 310px;gap:14px;padding:16px 24px 24px}body.is-immersive-map,body.is-immersive-map .app-shell,body.is-immersive-map .workspace{height:100vh;overflow:hidden}body.is-immersive-map .project-rail,body.is-immersive-map .workspace-header,body.is-immersive-map .detail-panel{display:none}body.is-immersive-map .app-shell,body.is-immersive-map .content-layout{display:block}body.is-immersive-map .content-layout{height:100vh;padding:0}body.is-immersive-map .map-surface{height:100vh;min-height:0;border:0;border-radius:0;box-shadow:none}body.is-immersive-map .map-viewport{height:100vh}.map-surface,.detail-panel{min-height:calc(100vh - 98px);background:#fffdf8e0;border:1px solid var(--line);border-radius:14px;box-shadow:var(--shadow)}.map-surface{position:relative;min-width:0;overflow:hidden}.map-viewport{position:relative;height:clamp(560px,calc(100vh - 98px),900px);overflow:hidden;background:radial-gradient(circle at 50% 48%,rgba(199,93,53,.08),transparent 24rem),radial-gradient(circle at 20% 82%,rgba(100,125,108,.08),transparent 22rem),linear-gradient(rgba(93,110,98,.07) 1px,transparent 1px),linear-gradient(90deg,rgba(93,110,98,.07) 1px,transparent 1px),#fbfaf4;background-size:auto,auto,42px 42px,42px 42px,auto;cursor:grab;touch-action:none}.map-viewport.is-panning{cursor:grabbing}.map-world{position:absolute;top:0;left:0;transform-origin:0 0;will-change:transform}.map-world.is-animating{transition:transform .52s cubic-bezier(.2,.78,.25,1)}.map-connections{position:absolute;inset:0;width:100%;height:100%;overflow:visible;pointer-events:none}.map-connections path{fill:none;vector-effect:non-scaling-stroke}.map-connections path[hidden]{display:none}.map-hierarchy-edge{stroke:#b6c0b4;stroke-width:1.4}.map-business-edge{stroke:var(--accent);stroke-width:1.5;stroke-dasharray:6 6;opacity:.78}.map-hub{position:absolute;display:grid;width:150px;height:150px;padding:24px 18px;place-content:center;text-align:center;background:var(--ink);border:8px solid rgba(255,253,248,.94);border-radius:50%;box-shadow:0 18px 36px #17231d33;transform:translate(-50%,-50%)}.map-hub-label{color:#fffdf8;font-size:14px;font-weight:750;line-height:1.15}.map-node{position:absolute;z-index:2;width:154px;transform:translate(-50%,-50%);transition:opacity .18s ease,transform .18s ease}.map-node[hidden]{display:none}.map-node-core{display:grid;width:134px;height:134px;margin:auto;padding:17px 12px 15px;place-content:center;text-align:center;background:#fffdf8f5;border:2px solid var(--node-color, var(--sage));border-radius:50%;box-shadow:0 10px 26px #1f2d2521;cursor:pointer;transition:transform .16s ease,box-shadow .16s ease,background .16s ease}.map-node-core:hover,.map-node.is-selected .map-node-core{background:#fff;box-shadow:0 16px 32px #1f2d2533;transform:scale(1.06)}.map-node.is-selected .map-node-core{outline:5px solid color-mix(in srgb,var(--node-color, var(--accent)) 18%,transparent)}.map-node[data-role=context] .map-node-core{border-style:dashed;opacity:.86}.map-node[data-validity=stale] .map-node-core{border-color:var(--warning)}.map-node[data-kind=capability]{--node-color: #c75d35}.map-node[data-kind=operation]{--node-color: #647d6c}.map-node[data-kind=interface]{--node-color: #456a82}.map-node[data-kind=scenario]{--node-color: #a67420}.map-node[data-kind=invariant]{--node-color: #a64f42}.map-node[data-kind=data]{--node-color: #4a817e}.map-node-count{display:block;margin-top:7px;color:var(--ink-muted);font-size:8px;font-weight:750;letter-spacing:.1em;text-transform:uppercase}.map-node-label{display:-webkit-box;max-height:42px;margin:0;overflow:hidden;font-size:12px;font-weight:750;line-height:1.15;-webkit-box-orient:vertical;-webkit-line-clamp:3}.map-viewport[data-zoom=overview] .map-node-count{display:none}.map-viewport[data-zoom=overview] .map-node-core{width:112px;height:112px}.map-controls{position:absolute;z-index:5;top:14px;right:14px;display:flex;overflow:hidden;background:#fffdf8ed;border:1px solid var(--line);border-radius:9px;box-shadow:0 8px 22px #1f2d251a}.map-control{min-width:39px;height:36px;padding:0 11px;background:transparent;border:0;border-right:1px solid var(--line);cursor:pointer;font-size:12px;font-weight:700}.map-control[data-action=immersive]{min-width:58px}.map-control:last-child{border-right:0}.map-control:hover{color:var(--accent);background:var(--accent-soft)}.detail-panel{align-self:start;min-width:0;max-height:calc(100vh - 98px);padding:22px;overflow-y:auto}.detail-placeholder,.welcome-state,.empty-state,.error-state{display:flex;flex-direction:column;justify-content:center;min-height:330px;padding:34px}.detail-placeholder{min-height:300px;padding:8px}.detail-placeholder h3,.welcome-state h3,.empty-state h3,.error-state h3{margin:13px 0 8px;font-family:Iowan Old Style,Baskerville,Georgia,serif;font-size:23px;font-weight:500}.detail-placeholder p:last-child,.welcome-state p:last-child,.empty-state p:last-child,.error-state p:last-child{max-width:430px;margin:0;color:var(--ink-muted);font-size:13px;line-height:1.6}.detail-heading{padding-bottom:20px;border-bottom:1px solid var(--line)}.detail-heading h3{margin:12px 0 9px;font-family:Iowan Old Style,Baskerville,Georgia,serif;font-size:25px;font-weight:500;line-height:1.12}.detail-heading>p{margin:0;color:var(--ink-muted);font-size:13px;line-height:1.6;overflow-wrap:anywhere}.detail-kind{margin:0 0 10px;color:var(--ink-muted);font-size:12px}.detail-section{padding:20px 0;border-bottom:1px solid var(--line)}.detail-section:last-child{border-bottom:0}.detail-section h4{margin:0 0 11px;color:var(--ink-muted);font-size:12px}.relation-item{position:relative;padding:7px 0 7px 13px;color:var(--ink);font-size:13px;line-height:1.45;overflow-wrap:anywhere}.relation-item:before{position:absolute;top:15px;left:1px;width:4px;height:4px;content:"";background:var(--accent);border-radius:50%}.loading-state{display:grid;min-height:420px;place-items:center;color:var(--ink-muted);font-size:12px}.loading-state:before{width:23px;height:23px;margin-right:9px;content:"";border:2px solid var(--line);border-top-color:var(--accent);border-radius:50%;animation:spin .7s linear infinite}.notice{position:fixed;z-index:50;right:28px;bottom:25px;max-width:430px;padding:12px 15px;color:#fff;background:var(--ink);border-radius:8px;box-shadow:var(--shadow);font-size:12px}.sr-only{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0}@keyframes region-in{0%{opacity:0;transform:translateY(7px)}to{opacity:1;transform:translateY(0)}}@keyframes spin{to{transform:rotate(360deg)}}@media(prefers-reduced-motion:reduce){*,*:before,*:after{scroll-behavior:auto!important;animation-duration:.01ms!important;animation-iteration-count:1!important;transition-duration:.01ms!important}}
@@ -0,0 +1,2 @@
1
+ (function(){const e=document.createElement("link").relList;if(e&&e.supports&&e.supports("modulepreload"))return;for(const i of document.querySelectorAll('link[rel="modulepreload"]'))o(i);new MutationObserver(i=>{for(const s of i)if(s.type==="childList")for(const a of s.addedNodes)a.tagName==="LINK"&&a.rel==="modulepreload"&&o(a)}).observe(document,{childList:!0,subtree:!0});function n(i){const s={};return i.integrity&&(s.integrity=i.integrity),i.referrerPolicy&&(s.referrerPolicy=i.referrerPolicy),i.crossOrigin==="use-credentials"?s.credentials="include":i.crossOrigin==="anonymous"?s.credentials="omit":s.credentials="same-origin",s}function o(i){if(i.ep)return;i.ep=!0;const s=n(i);fetch(i.href,s)}})();function ne(t,e,n,o){const i=t.get(n);if(i!==void 0)return Promise.resolve(i);const s=e.get(n);if(s!==void 0)return s;const a=o().then(d=>(t.set(n,d),d)).finally(()=>e.delete(n));return e.set(n,a),a}const p={width:3e3,height:2200};function oe(t,e=[]){const n={x:p.width/2,y:p.height/2},o=new Map(e.map(s=>[s.key,s])),i=t.filter(({key:s})=>!o.has(s));for(;i.length>0;){const s=i.filter(({parentKey:d})=>d===void 0||o.has(d)),a=s.length>0?s:i;for(const[d,l]of re(a))ie(l,d,o,n);for(const{key:d}of a)ce(i,d)}return{center:n,nodes:t.map(({key:s})=>o.get(s))}}function ie(t,e,n,o){const i=e===void 0?void 0:n.get(e),a=[...[...n.values()].filter(c=>c.parentKey===e).sort(de),...t].sort((c,u)=>c.key.localeCompare(u.key)),d=i===void 0,l=i??{x:o.x,y:o.y,depth:0},h=d?-Math.PI/2:Math.atan2(l.y-o.y,l.x-o.x);for(const c of t){const u=a.findIndex(({key:te})=>te===c.key),y=se(h,u,a.length,d),b=l.depth+1,K=ae(b,c.role,d);n.set(c.key,{key:c.key,x:Math.round(l.x+Math.cos(y)*K.x),y:Math.round(l.y+Math.sin(y)*K.y),ring:b+(c.role==="context"?1:0),depth:b,role:c.role,parentKey:e})}}function se(t,e,n,o){if(n<=1)return t;if(o)return t+Math.PI*2*e/n;const i=Math.min(1.7,Math.max(.85,(n-1)*.46));return t-i/2+i*e/(n-1)}function ae(t,e,n){const o=n?430:320+Math.min(t,4)*28,i=e==="context"?155:0;return{x:o+i,y:Math.round((o+i)*.72)}}function re(t){const e=new Map;for(const n of t){const o=e.get(n.parentKey)??[];o.push(n),e.set(n.parentKey,o)}return e}function ce(t,e){const n=t.findIndex(o=>o.key===e);n>=0&&t.splice(n,1)}function de(t,e){return t.key.localeCompare(e.key)}const k={minScale:.2,maxScale:4.8};function le(t,e,n){const o=z(t.scale*e,k.minScale,k.maxScale),i=(n.x-t.x)/t.scale,s=(n.y-t.y)/t.scale;return{scale:o,x:n.x-i*o,y:n.y-s*o}}function pe(t,e){return{...t,x:t.x+e.x,y:t.y+e.y}}function ue(t,e,n=80){const o=Math.max(1,e.right-e.left),i=Math.max(1,e.bottom-e.top),s=z(Math.min((t.width-n*2)/o,(t.height-n*2)/i),k.minScale,k.maxScale);return{scale:s,x:(t.width-o*s)/2-e.left*s,y:(t.height-i*s)/2-e.top*s}}function P(t){return t<=1?k.minScale:z(.55*1.6**(t-1),k.minScale,k.maxScale)}function T(t,e){return t<=1||e>=P(t)}function fe(t,e,n){return T(t,n)&&T(e,n)}function z(t,e,n){return Math.min(n,Math.max(e,t))}class X extends Error{constructor(e,n){super(n),this.code=e,this.name="ApiRequestError"}code}const q=M("project-list"),S=M("breadcrumbs"),C=M("map-surface"),L=M("detail-panel"),U=M("search-form"),m=M("business-search"),g=M("search-results"),B=M("notice");let w=[],f,x,E,v,I=0,V;he();async function he(){me();try{w=(await N("/api/v1/projects")).projects,Q();const t=new URLSearchParams(location.search).get("project"),e=w.find(({id:n})=>n===t)??w.find(({freshness:n})=>n==="current")??w[0];e!==void 0?await _(e.id):je()}catch(t){Ne("项目列表暂时无法显示",R(t))}}function me(){U.addEventListener("submit",e=>e.preventDefault());let t;m.addEventListener("input",()=>{window.clearTimeout(t);const e=m.value.trim();if(e.length===0){A();return}t=window.setTimeout(()=>{Ie(e)},170)}),m.addEventListener("keydown",e=>{e.key==="Escape"&&(A(),m.blur())}),document.addEventListener("keydown",e=>{const n=e.target;if(e.key==="Escape"&&document.body.classList.contains("is-immersive-map")){e.preventDefault(),W(!1);return}e.key==="/"&&n?.tagName!=="INPUT"&&f!==void 0&&(e.preventDefault(),m.focus())}),document.addEventListener("click",e=>{U.contains(e.target)||A()}),window.addEventListener("resize",()=>x?.fit())}async function _(t){const e=w.find(({id:n})=>n===t);if(e!==void 0){f=e,x=void 0,E=void 0,v={projectId:e.id,maps:new Map,mapRequests:new Map,nodes:new Map,connections:new Map,positions:new Map,camera:void 0},m.disabled=!1,m.value="",A(),Q(),J(C,"正在加载业务地图"),G(),qe(e.id);try{const n=await O();F(n)}catch(n){Z(n)}}}async function O(t){const e=f,n=v;if(e===void 0||n===void 0)throw new Error("请先选择一个项目。");const o=t??"";return ne(n.maps,n.mapRequests,o,async()=>{const i=t===void 0?"":`?focus=${encodeURIComponent(t)}`,s=await N(`/api/v1/projects/${e.id}/map${i}`);return H(n,s),s})}function H(t,e){let n;for(const s of e.breadcrumbs)D(t,s,n===void 0?"root":"child",n,0,!0),n=s.key;const o=e.breadcrumbs.at(-1);e.focus!==null&&o?.key!==e.focus.key&&D(t,e.focus,"child",n,0,!0);for(const s of e.regions)D(t,s.node,s.role,e.focus?.key,s.childCount,s.expandable);for(const s of e.connections)t.connections.set(`${s.from.key}\0${s.to.key}`,s);const i=oe([...t.nodes.values()].map(({node:s,role:a,parentKey:d})=>({key:s.key,role:a,parentKey:d})),[...t.positions.values()]);t.positions=new Map(i.nodes.map(s=>[s.key,s]))}function D(t,e,n,o,i,s){const a=t.nodes.get(e.key),d=a!==void 0&&n==="context";t.nodes.set(e.key,{node:e,role:d?a.role:n,parentKey:d?a.parentKey:o,childCount:Math.max(a?.childCount??0,i),expandable:(a?.expandable??!1)||s})}function Q(){if(q.replaceChildren(),w.length===0){const t=r("p","rail-empty");t.textContent="暂无可查看的项目。",q.append(t);return}for(const t of w){const e=r("button","project-button");e.type="button",e.setAttribute("aria-current",String(t.id===f?.id)),e.setAttribute("aria-label",`${t.name},${t.branch} 分支`),e.addEventListener("click",()=>{_(t.id)});const n=r("span","project-name");n.textContent=t.name,e.append(n),q.append(e)}}function F(t){if(v!==void 0&&H(v,t),$e(t),C.replaceChildren(),t.regions.length===0&&t.focus===null){const e=r("div","empty-state"),n=r("h3");n.textContent=t.focus===null?"还没有可展示的业务知识":"这里没有更多业务区域";const o=r("p");o.textContent=t.focus===null?"业务知识会在日常研发过程中逐步整理。":"这个区域仍可能包含简介和相关业务。",e.append(n,o),C.append(e);return}v!==void 0&&C.append(ye(v))}function ye(t){const e=r("section","map-viewport");e.tabIndex=0,e.setAttribute("aria-label","交互式业务地图。拖拽移动,滚轮缩放。");const n=r("div","map-world");n.style.width=`${p.width}px`,n.style.height=`${p.height}px`;const o=document.createElementNS("http://www.w3.org/2000/svg","svg");o.classList.add("map-connections"),o.setAttribute("viewBox",`0 0 ${p.width} ${p.height}`),o.setAttribute("aria-hidden","true"),be(o,t),n.append(o,ge());for(const s of t.nodes.values()){const a=t.positions.get(s.node.key);a!==void 0&&n.append(xe(s,a))}e.append(n,ve());const i=t.camera===void 0;return x=Ce(e,n,t),requestAnimationFrame(()=>{i?x?.fit():x?.refresh()}),e}function ge(){const t=r("div","map-hub");t.style.left=`${p.width/2}px`,t.style.top=`${p.height/2}px`;const e=r("span","map-hub-label");return e.textContent=f?.name??"项目",t.append(e),t}function xe(t,e){const n=r("article","map-node");n.dataset.key=t.node.key,n.dataset.depth=String(e.depth),n.dataset.role=t.role,n.dataset.kind=t.node.kind.toLowerCase().replaceAll(" ","-"),n.dataset.validity=t.node.validity,n.classList.toggle("is-selected",t.node.key===E),n.style.left=`${e.x}px`,n.style.top=`${e.y}px`;const o=r("button","map-node-core");o.type="button",o.title=t.expandable?"进入这个业务区域":"查看这个业务区域",o.setAttribute("aria-label",t.node.label),o.addEventListener("click",()=>{j(t.node.key)});const i=r("span","map-node-label");if(i.textContent=t.node.label,o.append(i),t.childCount>0){const s=r("span","map-node-count");s.textContent=`${t.childCount} 项`,o.append(s)}return n.append(o),n}function be(t,e){const n={x:p.width/2,y:p.height/2};for(const o of e.nodes.values()){if(o.role==="context")continue;const i=e.positions.get(o.node.key);if(i===void 0)continue;const s=o.parentKey===void 0?void 0:e.positions.get(o.parentKey),a=s??n;a!==void 0&&Y(t,a,i,"map-hierarchy-edge",s?.depth??1,i.depth)}for(const o of e.connections.values()){const i=e.positions.get(o.from.key),s=e.positions.get(o.to.key);i===void 0||s===void 0||Y(t,i,s,"map-business-edge",i.depth,s.depth)}}function Y(t,e,n,o,i,s){const a=document.createElementNS("http://www.w3.org/2000/svg","path");a.classList.add(o),a.dataset.fromDepth=String(i),a.dataset.toDepth=String(s);const d={x:(e.x+n.x)/2,y:(e.y+n.y)/2},l={x:-(n.y-e.y)*.08,y:(n.x-e.x)*.08};a.setAttribute("d",`M ${e.x} ${e.y} Q ${d.x+l.x} ${d.y+l.y} ${n.x} ${n.y}`),t.append(a)}function ve(){const t=r("div","map-controls"),e=document.body.classList.contains("is-immersive-map");for(const[n,o,i]of[["zoom-out","−","缩小"],["fit","适应","适应当前地图"],["zoom-in","+","放大"],["immersive",e?"退出":"沉浸",e?"退出沉浸查看":"进入沉浸查看"]]){const s=r("button","map-control");s.type="button",s.dataset.action=n,s.textContent=o,s.title=i,n==="immersive"&&s.setAttribute("aria-pressed",String(e)),t.append(s)}return t}function Ce(t,e,n){let o=n.camera??{scale:1,x:0,y:0},i;const s=new Map([...t.querySelectorAll("[data-action]")].map(c=>[c.dataset.action,c])),a=(c=!1)=>{e.classList.toggle("is-animating",c),e.style.transform=`translate3d(${o.x}px, ${o.y}px, 0) scale(${o.scale})`,n.camera=o,t.dataset.zoom=o.scale<.75?"overview":o.scale<1.4?"region":"detail",ke(t,n,o.scale)},d=()=>{o=ue(t.getBoundingClientRect(),Ee(n)),a(!0)},l=(c,u=o.scale)=>{const y=n.positions.get(c);if(y===void 0)return;const b=t.getBoundingClientRect();o={scale:u,x:b.width/2-y.x*u,y:b.height/2-y.y*u},a(!0)},h=(c,u)=>{o=le(o,c,u),a()};return s.get("zoom-in")?.addEventListener("click",()=>{h(1.25,$(t))}),s.get("zoom-out")?.addEventListener("click",()=>{h(.8,$(t))}),s.get("fit")?.addEventListener("click",d),s.get("immersive")?.addEventListener("click",()=>{W(!document.body.classList.contains("is-immersive-map"))}),t.addEventListener("wheel",c=>{c.preventDefault();const u=t.getBoundingClientRect(),y={x:c.clientX-u.left,y:c.clientY-u.top},b=o.scale;h(Math.exp(-c.deltaY*.0015),y),o.scale>b&&Me(c.target,n,o,y)},{passive:!1}),t.addEventListener("pointerdown",c=>{c.button!==0||c.target.closest("button")||(i={pointerId:c.pointerId,x:c.clientX,y:c.clientY},t.setPointerCapture(c.pointerId),t.classList.add("is-panning"))}),t.addEventListener("pointermove",c=>{i?.pointerId===c.pointerId&&(o=pe(o,{x:c.clientX-i.x,y:c.clientY-i.y}),i={...i,x:c.clientX,y:c.clientY},a())}),t.addEventListener("pointerup",()=>{i=void 0,t.classList.remove("is-panning")}),t.addEventListener("keydown",c=>{(c.key==="+"||c.key==="=")&&(c.preventDefault(),h(1.25,$(t))),c.key==="-"&&(c.preventDefault(),h(.8,$(t))),c.key==="0"&&(c.preventDefault(),d())}),a(),{fit:d,focus:l,refresh:()=>a()}}function W(t){document.body.classList.toggle("is-immersive-map",t);const e=document.querySelector("[data-action=immersive]");e!==null&&(e.textContent=t?"退出":"沉浸",e.title=t?"退出沉浸查看":"进入沉浸查看",e.setAttribute("aria-pressed",String(t))),requestAnimationFrame(()=>{const n=v?.camera;E!==void 0&&n!==void 0?x?.focus(E,n.scale):x?.fit()})}function Me(t,e,n,o){const s=(t instanceof Element?t.closest(".map-node"):null)?.dataset.key??we(e,n,o)??E;if(s===void 0||e.maps.has(s)||e.mapRequests.has(s))return;const a=e.nodes.get(s),d=e.positions.get(s);a?.expandable===!0&&d!==void 0&&n.scale>=P(d.depth+1)&&j(s)}function we(t,e,n){let o;for(const i of t.nodes.values()){if(!i.expandable)continue;const s=t.positions.get(i.node.key);if(s===void 0)continue;const a=s.x*e.scale+e.x,d=s.y*e.scale+e.y,l=Math.hypot(n.x-a,n.y-d);l<=130&&(o===void 0||l<o.distance)&&(o={key:i.node.key,distance:l})}return o?.key}function ke(t,e,n){const o=new Map([...t.querySelectorAll(".map-node")].map(i=>[i.dataset.key,i]));for(const i of e.nodes.values()){const s=e.positions.get(i.node.key),a=o.get(i.node.key);s===void 0||a===void 0||(a.hidden=!T(s.depth,n))}t.querySelectorAll("[data-from-depth][data-to-depth]").forEach(i=>{const s=fe(Number(i.dataset.fromDepth),Number(i.dataset.toDepth),n);i.toggleAttribute("hidden",!s),i.style.display=s?"":"none"})}function Ee(t){const e=[...t.positions.values()];if(e.length===0){const n=p.width/2,o=p.height/2;return{left:n-240,top:o-160,right:n+240,bottom:o+160}}return{left:Math.min(p.width/2,...e.map(({x:n})=>n))-150,top:Math.min(p.height/2,...e.map(({y:n})=>n))-150,right:Math.max(p.width/2,...e.map(({x:n})=>n))+150,bottom:Math.max(p.height/2,...e.map(({y:n})=>n))+150}}function $(t){const e=t.getBoundingClientRect();return{x:e.width/2,y:e.height/2}}async function j(t){const e=v;if(e===void 0)return;E=t;const n=e.nodes.get(t),o=n?.expandable===!0||n===void 0?O(t):Promise.resolve(void 0),i=Se(t),s=await o;s!==void 0&&F(s),await i;const a=e.nodes.get(t),d=e.positions.get(t),l=d===void 0?e.camera?.scale:a?.expandable===!0?P(d.depth+1):Math.max(e.camera?.scale??1,P(d.depth));x?.focus(t,l)}async function Le(){try{const t=await O();F(t),x?.fit()}catch(t){Z(t)}}async function Se(t){if(f!==void 0){E=t,C.querySelectorAll(".map-node").forEach(e=>{e.classList.toggle("is-selected",e.dataset.key===t)}),J(L,"正在加载详情");try{const e=await N(`/api/v1/projects/${f.id}/node?key=${encodeURIComponent(t)}`);Ae(e)}catch(e){const n=r("div","error-state"),o=r("h3");o.textContent="详情暂时无法显示";const i=r("p");i.textContent=R(e),n.append(o,i),L.replaceChildren(n)}}}function Ae(t){const e=t.node;L.replaceChildren();const n=r("header","detail-heading"),o=r("p","detail-kind");o.textContent=`类型:${ee(e.kind)}`;const i=r("h3");i.textContent=e.label;const s=r("p");if(s.textContent=e.summary,n.append(o,i,s),L.append(n),t.relations.length===0)return;const a=Re("相关业务");t.relations.forEach(d=>{const l=r("div","relation-item"),h=r("span");h.textContent=d.node.label,l.append(h),a.append(l)}),L.append(a)}function $e(t){S.replaceChildren();const e=r("button","breadcrumb-button");e.type="button",e.textContent=f?.name??"业务地图",e.addEventListener("click",()=>{Le(),G()}),S.append(e);for(const n of t.breadcrumbs){const o=r("span","breadcrumb-separator");o.textContent="/";const i=r("button","breadcrumb-button");i.type="button",i.textContent=n.label,i.addEventListener("click",()=>{j(n.key)}),S.append(o,i)}}async function Ie(t){if(f===void 0)return;const e=++I;g.hidden=!1;const n=r("div","search-message");n.textContent="正在搜索业务知识…",g.replaceChildren(n);try{const o=await N(`/api/v1/projects/${f.id}/search?q=${encodeURIComponent(t)}&limit=12`);if(e!==I||m.value.trim()!==t)return;Pe(o.results)}catch(o){if(e!==I)return;const i=r("div","search-message");i.textContent=R(o),g.replaceChildren(i)}}function Pe(t){if(g.replaceChildren(),g.hidden=!1,t.length===0){const e=r("div","search-message");e.textContent="没有找到匹配的业务知识。",g.append(e);return}for(const e of t){const n=r("button","search-result");n.type="button";const o=r("strong");o.textContent=e.node.label;const i=r("span");i.textContent=`类型:${ee(e.node.kind)}`,n.append(o,i),n.addEventListener("click",()=>{m.value="",A(),j(e.node.key)}),g.append(n)}}function A(){I+=1,g.hidden=!0,g.replaceChildren()}function je(){m.disabled=!0;const t=r("div","empty-state"),e=r("h3");e.textContent="没有可查看的项目";const n=r("p");n.textContent="请先为主分支项目准备业务知识。",t.append(e,n),C.replaceChildren(t)}function Z(t){S.replaceChildren();const e=r("span","breadcrumb-button");e.textContent=f?.name??"业务地图",S.append(e);const n=r("div","error-state"),o=r("h3");o.textContent=t instanceof X&&t.code==="ATLAS_STATE_UNAVAILABLE"?"地图尚未准备好":"业务地图暂时无法显示";const i=r("p");i.textContent=R(t),n.append(o,i),C.replaceChildren(n)}function Ne(t,e){const n=r("div","error-state"),o=r("h3");o.textContent=t;const i=r("p");i.textContent=e,n.append(o,i),C.replaceChildren(n),Be(e)}function G(){const t=r("div","detail-placeholder"),e=r("h3");e.textContent="选择一个业务区域";const n=r("p");n.textContent="在地图上点击节点查看简介和相关业务。",t.append(e,n),L.replaceChildren(t)}function J(t,e){const n=r("div","loading-state");n.textContent=e,t.replaceChildren(n)}function Re(t){const e=r("section","detail-section"),n=r("h4");return n.textContent=t,e.append(n),e}async function N(t){const e=await fetch(t,{headers:{Accept:"application/json"}}),n=await e.json();if(!e.ok||"error"in n){const o="error"in n?n.error:{code:"INVALID_RESPONSE",message:"The local API returned an invalid response."};throw new X(o.code,o.message)}return n.data}function qe(t){const e=new URL(location.href);e.searchParams.set("project",t),history.replaceState(null,"",e)}function Be(t){window.clearTimeout(V),B.textContent=t,B.hidden=!1,V=window.setTimeout(()=>{B.hidden=!0},4500)}function ee(t){return{Capability:"能力",Scenario:"场景",Operation:"操作",Invariant:"规则",Interface:"接口",Data:"数据"}[t]??t}function R(t){return t instanceof Error?t.message:String(t)}function M(t){const e=document.getElementById(t);if(e===null)throw new Error(`Missing required interface element ${t}`);return e}function r(t,e){const n=document.createElement(t);return e!==void 0&&(n.className=e),n}
2
+ //# sourceMappingURL=index-cze_4vtt.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index-cze_4vtt.js","sources":["../../../src/web/client/map-cache.ts","../../../src/web/client/map-layout.ts","../../../src/web/client/map-camera.ts","../../../src/web/client/main.ts"],"sourcesContent":["export function loadCachedValue<Key, Value>(\n values: Map<Key, Value>,\n pending: Map<Key, Promise<Value>>,\n key: Key,\n load: () => Promise<Value>,\n): Promise<Value> {\n const cached = values.get(key);\n if (cached !== undefined) return Promise.resolve(cached);\n\n const inFlight = pending.get(key);\n if (inFlight !== undefined) return inFlight;\n\n const request = load()\n .then((value) => {\n values.set(key, value);\n return value;\n })\n .finally(() => pending.delete(key));\n pending.set(key, request);\n return request;\n}\n","export const BUSINESS_MAP_WORLD = {\n width: 3_000,\n height: 2_200,\n} as const;\n\nexport interface BusinessMapLayoutInput {\n readonly key: string;\n readonly role: \"root\" | \"child\" | \"context\";\n readonly parentKey?: string | undefined;\n}\n\nexport interface BusinessMapLayoutNode {\n readonly key: string;\n readonly x: number;\n readonly y: number;\n readonly ring: number;\n readonly depth: number;\n readonly role: BusinessMapLayoutInput[\"role\"];\n readonly parentKey: string | undefined;\n}\n\nexport interface BusinessMapLayout {\n readonly center: { readonly x: number; readonly y: number };\n readonly nodes: readonly BusinessMapLayoutNode[];\n}\n\nexport function layoutBusinessMap(\n regions: readonly BusinessMapLayoutInput[],\n existingNodes: readonly BusinessMapLayoutNode[] = [],\n): BusinessMapLayout {\n const center = {\n x: BUSINESS_MAP_WORLD.width / 2,\n y: BUSINESS_MAP_WORLD.height / 2,\n };\n const positions = new Map(existingNodes.map((node) => [node.key, node]));\n const pending = regions.filter(({ key }) => !positions.has(key));\n\n while (pending.length > 0) {\n const ready = pending.filter(({ parentKey }) => parentKey === undefined || positions.has(parentKey));\n const next = ready.length > 0 ? ready : pending;\n for (const [parentKey, siblings] of groupByParent(next)) {\n placeSiblings(siblings, parentKey, positions, center);\n }\n for (const { key } of next) removeRegion(pending, key);\n }\n\n return {\n center,\n nodes: regions.map(({ key }) => positions.get(key)!),\n };\n}\n\nfunction placeSiblings(\n siblings: readonly BusinessMapLayoutInput[],\n parentKey: string | undefined,\n positions: Map<string, BusinessMapLayoutNode>,\n center: BusinessMapLayout[\"center\"],\n): void {\n const parent = parentKey === undefined ? undefined : positions.get(parentKey);\n const existingSiblings = [...positions.values()]\n .filter((node) => node.parentKey === parentKey)\n .sort(compareNodes);\n const allSiblings = [...existingSiblings, ...siblings]\n .sort((left, right) => left.key.localeCompare(right.key));\n const root = parent === undefined;\n const parentPosition = parent ?? { x: center.x, y: center.y, depth: 0 };\n const outwardAngle = root\n ? -Math.PI / 2\n : Math.atan2(parentPosition.y - center.y, parentPosition.x - center.x);\n\n for (const region of siblings) {\n const index = allSiblings.findIndex(({ key }) => key === region.key);\n const angle = siblingAngle(outwardAngle, index, allSiblings.length, root);\n const depth = parentPosition.depth + 1;\n const radius = siblingRadius(depth, region.role, root);\n positions.set(region.key, {\n key: region.key,\n x: Math.round(parentPosition.x + Math.cos(angle) * radius.x),\n y: Math.round(parentPosition.y + Math.sin(angle) * radius.y),\n ring: depth + (region.role === \"context\" ? 1 : 0),\n depth,\n role: region.role,\n parentKey,\n });\n }\n}\n\nfunction siblingAngle(\n outwardAngle: number,\n index: number,\n count: number,\n root: boolean,\n): number {\n if (count <= 1) return outwardAngle;\n if (root) return outwardAngle + (Math.PI * 2 * index) / count;\n const span = Math.min(1.7, Math.max(0.85, (count - 1) * 0.46));\n return outwardAngle - span / 2 + (span * index) / (count - 1);\n}\n\nfunction siblingRadius(\n depth: number,\n role: BusinessMapLayoutInput[\"role\"],\n root: boolean,\n): { readonly x: number; readonly y: number } {\n const base = root ? 430 : 320 + Math.min(depth, 4) * 28;\n const contextOffset = role === \"context\" ? 155 : 0;\n return {\n x: base + contextOffset,\n y: Math.round((base + contextOffset) * 0.72),\n };\n}\n\nfunction groupByParent(\n nodes: readonly BusinessMapLayoutInput[],\n): ReadonlyMap<string | undefined, readonly BusinessMapLayoutInput[]> {\n const groups = new Map<string | undefined, BusinessMapLayoutInput[]>();\n for (const node of nodes) {\n const group = groups.get(node.parentKey) ?? [];\n group.push(node);\n groups.set(node.parentKey, group);\n }\n return groups;\n}\n\nfunction removeRegion(regions: BusinessMapLayoutInput[], key: string): void {\n const index = regions.findIndex((region) => region.key === key);\n if (index >= 0) regions.splice(index, 1);\n}\n\nfunction compareNodes(left: BusinessMapLayoutNode, right: BusinessMapLayoutNode): number {\n return left.key.localeCompare(right.key);\n}\n","export const MAP_CAMERA_LIMITS = {\n minScale: 0.2,\n maxScale: 4.8,\n} as const;\n\nexport interface MapCamera {\n readonly scale: number;\n readonly x: number;\n readonly y: number;\n}\n\nexport interface MapPoint {\n readonly x: number;\n readonly y: number;\n}\n\nexport interface MapViewport {\n readonly width: number;\n readonly height: number;\n}\n\nexport interface MapBounds {\n readonly left: number;\n readonly top: number;\n readonly right: number;\n readonly bottom: number;\n}\n\nexport function zoomMapCameraAt(\n camera: MapCamera,\n factor: number,\n pointer: MapPoint,\n): MapCamera {\n const scale = clamp(camera.scale * factor, MAP_CAMERA_LIMITS.minScale, MAP_CAMERA_LIMITS.maxScale);\n const worldX = (pointer.x - camera.x) / camera.scale;\n const worldY = (pointer.y - camera.y) / camera.scale;\n return {\n scale,\n x: pointer.x - worldX * scale,\n y: pointer.y - worldY * scale,\n };\n}\n\nexport function panMapCamera(camera: MapCamera, delta: MapPoint): MapCamera {\n return {\n ...camera,\n x: camera.x + delta.x,\n y: camera.y + delta.y,\n };\n}\n\nexport function fitMapCamera(\n viewport: MapViewport,\n bounds: MapBounds,\n padding = 80,\n): MapCamera {\n const width = Math.max(1, bounds.right - bounds.left);\n const height = Math.max(1, bounds.bottom - bounds.top);\n const scale = clamp(\n Math.min((viewport.width - padding * 2) / width, (viewport.height - padding * 2) / height),\n MAP_CAMERA_LIMITS.minScale,\n MAP_CAMERA_LIMITS.maxScale,\n );\n return {\n scale,\n x: (viewport.width - width * scale) / 2 - bounds.left * scale,\n y: (viewport.height - height * scale) / 2 - bounds.top * scale,\n };\n}\n\nexport function semanticRevealScale(depth: number): number {\n if (depth <= 1) return MAP_CAMERA_LIMITS.minScale;\n return clamp(0.55 * 1.6 ** (depth - 1), MAP_CAMERA_LIMITS.minScale, MAP_CAMERA_LIMITS.maxScale);\n}\n\nexport function isMapNodeVisible(depth: number, scale: number): boolean {\n return depth <= 1 || scale >= semanticRevealScale(depth);\n}\n\nexport function isMapConnectionVisible(\n fromDepth: number,\n toDepth: number,\n scale: number,\n): boolean {\n return isMapNodeVisible(fromDepth, scale) && isMapNodeVisible(toDepth, scale);\n}\n\nfunction clamp(value: number, minimum: number, maximum: number): number {\n return Math.min(maximum, Math.max(minimum, value));\n}\n","import \"./styles.css\";\nimport { loadCachedValue } from \"./map-cache.js\";\nimport { BUSINESS_MAP_WORLD, layoutBusinessMap, type BusinessMapLayoutNode } from \"./map-layout.js\";\nimport {\n fitMapCamera,\n isMapConnectionVisible,\n isMapNodeVisible,\n panMapCamera,\n semanticRevealScale,\n zoomMapCameraAt,\n type MapCamera,\n} from \"./map-camera.js\";\n\ntype Freshness = \"current\" | \"stale\" | \"missing\";\ntype PublicationStatus = \"missing\" | \"building\" | \"current\" | \"failed\";\n\ninterface ProjectSummary {\n readonly id: string;\n readonly name: string;\n readonly root: string;\n readonly branch: \"main\" | \"master\";\n readonly headCommit: string;\n readonly snapshotId: string | null;\n readonly freshness: Freshness;\n readonly status: PublicationStatus;\n}\n\ninterface BusinessNode {\n readonly domain: \"business\";\n readonly key: string;\n readonly kind: string;\n readonly label: string;\n readonly summary: string;\n readonly aliases: readonly string[];\n readonly certainty: \"exact\" | \"inferred\" | \"hypothesis\";\n readonly validity: \"valid\" | \"stale\";\n readonly evidence: readonly Evidence[];\n}\n\ninterface Evidence {\n readonly symbolId: string;\n readonly file: string;\n readonly range: {\n readonly start: { readonly line: number; readonly column: number };\n readonly end: { readonly line: number; readonly column: number };\n };\n}\n\ninterface MapRegion {\n readonly node: BusinessNode;\n readonly role: \"root\" | \"child\" | \"context\";\n readonly childCount: number;\n readonly expandable: boolean;\n}\n\ninterface MapConnection {\n readonly from: { readonly key: string };\n readonly to: { readonly key: string };\n readonly relations: readonly {\n readonly type: string;\n readonly directCount: number;\n readonly aggregatedCount: number;\n }[];\n}\n\ninterface BusinessMap {\n readonly focus: BusinessNode | null;\n readonly breadcrumbs: readonly BusinessNode[];\n readonly regions: readonly MapRegion[];\n readonly connections: readonly MapConnection[];\n}\n\ninterface SearchResult {\n readonly score: number;\n readonly node: BusinessNode;\n}\n\ninterface BusinessSearch {\n readonly query: string;\n readonly limit: number;\n readonly results: readonly SearchResult[];\n}\n\ninterface GraphNeighbor {\n readonly direction: \"incoming\" | \"outgoing\";\n readonly relation: { readonly type: string; readonly certainty: string; readonly validity: string };\n readonly node: { readonly label: string; readonly kind: string };\n}\n\ninterface BusinessNodeView {\n readonly node: BusinessNode;\n readonly relations: readonly GraphNeighbor[];\n}\n\ninterface ApiEnvelope<Data> {\n readonly schemaVersion: 1;\n readonly data: Data;\n}\n\ninterface ApiErrorEnvelope {\n readonly schemaVersion: 1;\n readonly error: { readonly code: string; readonly message: string };\n}\n\nclass ApiRequestError extends Error {\n constructor(readonly code: string, message: string) {\n super(message);\n this.name = \"ApiRequestError\";\n }\n}\n\ninterface MapViewportController {\n fit(): void;\n focus(key: string, scale?: number): void;\n refresh(): void;\n}\n\ninterface CachedMapNode extends MapRegion {\n readonly parentKey: string | undefined;\n}\n\ninterface InteractiveMapState {\n readonly projectId: string;\n readonly maps: Map<string, BusinessMap>;\n readonly mapRequests: Map<string, Promise<BusinessMap>>;\n readonly nodes: Map<string, CachedMapNode>;\n readonly connections: Map<string, MapConnection>;\n positions: Map<string, BusinessMapLayoutNode>;\n camera: MapCamera | undefined;\n}\n\nconst projectList = requireElement<HTMLElement>(\"project-list\");\nconst breadcrumbs = requireElement<HTMLElement>(\"breadcrumbs\");\nconst mapSurface = requireElement<HTMLElement>(\"map-surface\");\nconst detailPanel = requireElement<HTMLElement>(\"detail-panel\");\nconst searchForm = requireElement<HTMLFormElement>(\"search-form\");\nconst searchInput = requireElement<HTMLInputElement>(\"business-search\");\nconst searchResults = requireElement<HTMLElement>(\"search-results\");\nconst notice = requireElement<HTMLElement>(\"notice\");\n\nlet projects: readonly ProjectSummary[] = [];\nlet activeProject: ProjectSummary | undefined;\nlet activeMapViewport: MapViewportController | undefined;\nlet selectedBusinessKey: string | undefined;\nlet interactiveMap: InteractiveMapState | undefined;\nlet searchSequence = 0;\nlet noticeTimer: number | undefined;\n\nvoid initialize();\n\nasync function initialize(): Promise<void> {\n installInteractions();\n try {\n projects = (await api<{ readonly projects: readonly ProjectSummary[] }>(\"/api/v1/projects\"))\n .projects;\n renderProjects();\n const requestedProject = new URLSearchParams(location.search).get(\"project\");\n const initialProject = projects.find(({ id }) => id === requestedProject)\n ?? projects.find(({ freshness }) => freshness === \"current\")\n ?? projects[0];\n if (initialProject !== undefined) {\n await selectProject(initialProject.id);\n } else {\n renderNoProjects();\n }\n } catch (error) {\n renderFatalError(\"项目列表暂时无法显示\", errorMessage(error));\n }\n}\n\nfunction installInteractions(): void {\n searchForm.addEventListener(\"submit\", (event) => event.preventDefault());\n let debounceTimer: number | undefined;\n searchInput.addEventListener(\"input\", () => {\n window.clearTimeout(debounceTimer);\n const query = searchInput.value.trim();\n if (query.length === 0) {\n hideSearchResults();\n return;\n }\n debounceTimer = window.setTimeout(() => void runSearch(query), 170);\n });\n searchInput.addEventListener(\"keydown\", (event) => {\n if (event.key === \"Escape\") {\n hideSearchResults();\n searchInput.blur();\n }\n });\n document.addEventListener(\"keydown\", (event) => {\n const target = event.target as HTMLElement | null;\n if (event.key === \"Escape\" && document.body.classList.contains(\"is-immersive-map\")) {\n event.preventDefault();\n setImmersiveMap(false);\n return;\n }\n if (event.key === \"/\" && target?.tagName !== \"INPUT\" && activeProject !== undefined) {\n event.preventDefault();\n searchInput.focus();\n }\n });\n document.addEventListener(\"click\", (event) => {\n if (!searchForm.contains(event.target as Node)) hideSearchResults();\n });\n window.addEventListener(\"resize\", () => activeMapViewport?.fit());\n}\n\nasync function selectProject(projectId: string): Promise<void> {\n const project = projects.find(({ id }) => id === projectId);\n if (project === undefined) return;\n activeProject = project;\n activeMapViewport = undefined;\n selectedBusinessKey = undefined;\n interactiveMap = {\n projectId: project.id,\n maps: new Map(),\n mapRequests: new Map(),\n nodes: new Map(),\n connections: new Map(),\n positions: new Map(),\n camera: undefined,\n };\n searchInput.disabled = false;\n searchInput.value = \"\";\n hideSearchResults();\n renderProjects();\n renderLoading(mapSurface, \"正在加载业务地图\");\n renderDetailPlaceholder();\n replaceLocationProject(project.id);\n\n try {\n const map = await readMap();\n renderMap(map);\n } catch (error) {\n renderMapError(error);\n }\n}\n\nasync function loadMap(focusKey?: string): Promise<void> {\n if (activeProject === undefined) return;\n try {\n const map = await readMap(focusKey);\n renderMap(map);\n } catch (error) {\n renderMapError(error);\n }\n}\n\nasync function readMap(focusKey?: string): Promise<BusinessMap> {\n const project = activeProject;\n const state = interactiveMap;\n if (project === undefined || state === undefined) {\n throw new Error(\"请先选择一个项目。\");\n }\n const cacheKey = focusKey ?? \"\";\n return loadCachedValue(\n state.maps,\n state.mapRequests,\n cacheKey,\n async () => {\n const query = focusKey === undefined ? \"\" : `?focus=${encodeURIComponent(focusKey)}`;\n const map = await api<BusinessMap>(`/api/v1/projects/${project.id}/map${query}`);\n mergeMap(state, map);\n return map;\n },\n );\n}\n\nfunction mergeMap(state: InteractiveMapState, map: BusinessMap): void {\n let parentKey: string | undefined;\n for (const node of map.breadcrumbs) {\n cacheMapNode(state, node, parentKey === undefined ? \"root\" : \"child\", parentKey, 0, true);\n parentKey = node.key;\n }\n const breadcrumbFocus = map.breadcrumbs.at(-1);\n if (map.focus !== null && breadcrumbFocus?.key !== map.focus.key) {\n cacheMapNode(state, map.focus, \"child\", parentKey, 0, true);\n }\n for (const region of map.regions) {\n cacheMapNode(\n state,\n region.node,\n region.role,\n map.focus?.key,\n region.childCount,\n region.expandable,\n );\n }\n for (const connection of map.connections) {\n state.connections.set(`${connection.from.key}\\0${connection.to.key}`, connection);\n }\n const layout = layoutBusinessMap(\n [...state.nodes.values()].map(({ node, role, parentKey: nodeParentKey }) => ({\n key: node.key,\n role,\n parentKey: nodeParentKey,\n })),\n [...state.positions.values()],\n );\n state.positions = new Map(layout.nodes.map((position) => [position.key, position]));\n}\n\nfunction cacheMapNode(\n state: InteractiveMapState,\n node: BusinessNode,\n role: MapRegion[\"role\"],\n parentKey: string | undefined,\n childCount: number,\n expandable: boolean,\n): void {\n const existing = state.nodes.get(node.key);\n const keepHierarchy = existing !== undefined && role === \"context\";\n state.nodes.set(node.key, {\n node,\n role: keepHierarchy ? existing.role : role,\n parentKey: keepHierarchy ? existing.parentKey : parentKey,\n childCount: Math.max(existing?.childCount ?? 0, childCount),\n expandable: (existing?.expandable ?? false) || expandable,\n });\n}\n\nfunction renderProjects(): void {\n projectList.replaceChildren();\n if (projects.length === 0) {\n const empty = element(\"p\", \"rail-empty\");\n empty.textContent = \"暂无可查看的项目。\";\n projectList.append(empty);\n return;\n }\n for (const project of projects) {\n const button = element(\"button\", \"project-button\");\n button.type = \"button\";\n button.setAttribute(\"aria-current\", String(project.id === activeProject?.id));\n button.setAttribute(\"aria-label\", `${project.name},${project.branch} 分支`);\n button.addEventListener(\"click\", () => void selectProject(project.id));\n const name = element(\"span\", \"project-name\");\n name.textContent = project.name;\n button.append(name);\n projectList.append(button);\n }\n}\n\nfunction renderMap(map: BusinessMap): void {\n if (interactiveMap !== undefined) mergeMap(interactiveMap, map);\n renderBreadcrumbs(map);\n mapSurface.replaceChildren();\n\n if (map.regions.length === 0 && map.focus === null) {\n const empty = element(\"div\", \"empty-state\");\n const emptyTitle = element(\"h3\");\n emptyTitle.textContent = map.focus === null\n ? \"还没有可展示的业务知识\"\n : \"这里没有更多业务区域\";\n const emptyCopy = element(\"p\");\n emptyCopy.textContent = map.focus === null\n ? \"业务知识会在日常研发过程中逐步整理。\"\n : \"这个区域仍可能包含简介和相关业务。\";\n empty.append(emptyTitle, emptyCopy);\n mapSurface.append(empty);\n return;\n }\n if (interactiveMap !== undefined) {\n mapSurface.append(renderSpatialMap(interactiveMap));\n }\n}\n\nfunction renderSpatialMap(state: InteractiveMapState): HTMLElement {\n const viewport = element(\"section\", \"map-viewport\");\n viewport.tabIndex = 0;\n viewport.setAttribute(\"aria-label\", \"交互式业务地图。拖拽移动,滚轮缩放。\");\n const world = element(\"div\", \"map-world\");\n world.style.width = `${BUSINESS_MAP_WORLD.width}px`;\n world.style.height = `${BUSINESS_MAP_WORLD.height}px`;\n\n const connectionLayer = document.createElementNS(\"http://www.w3.org/2000/svg\", \"svg\");\n connectionLayer.classList.add(\"map-connections\");\n connectionLayer.setAttribute(\"viewBox\", `0 0 ${BUSINESS_MAP_WORLD.width} ${BUSINESS_MAP_WORLD.height}`);\n connectionLayer.setAttribute(\"aria-hidden\", \"true\");\n renderMapEdges(connectionLayer, state);\n world.append(connectionLayer, renderMapHub());\n for (const cached of state.nodes.values()) {\n const position = state.positions.get(cached.node.key);\n if (position !== undefined) world.append(renderMapNode(cached, position));\n }\n\n viewport.append(world, renderMapControls());\n const shouldFitLoadedMap = state.camera === undefined;\n activeMapViewport = installMapViewport(viewport, world, state);\n requestAnimationFrame(() => {\n if (shouldFitLoadedMap) activeMapViewport?.fit();\n else activeMapViewport?.refresh();\n });\n return viewport;\n}\n\nfunction renderMapHub(): HTMLElement {\n const hub = element(\"div\", \"map-hub\");\n hub.style.left = `${BUSINESS_MAP_WORLD.width / 2}px`;\n hub.style.top = `${BUSINESS_MAP_WORLD.height / 2}px`;\n const label = element(\"span\", \"map-hub-label\");\n label.textContent = activeProject?.name ?? \"项目\";\n hub.append(label);\n return hub;\n}\n\nfunction renderMapNode(cached: CachedMapNode, position: BusinessMapLayoutNode): HTMLElement {\n const node = element(\"article\", \"map-node\");\n node.dataset.key = cached.node.key;\n node.dataset.depth = String(position.depth);\n node.dataset.role = cached.role;\n node.dataset.kind = cached.node.kind.toLowerCase().replaceAll(\" \", \"-\");\n node.dataset.validity = cached.node.validity;\n node.classList.toggle(\"is-selected\", cached.node.key === selectedBusinessKey);\n node.style.left = `${position.x}px`;\n node.style.top = `${position.y}px`;\n\n const select = element(\"button\", \"map-node-core\");\n select.type = \"button\";\n select.title = cached.expandable ? \"进入这个业务区域\" : \"查看这个业务区域\";\n select.setAttribute(\"aria-label\", cached.node.label);\n select.addEventListener(\"click\", () => void selectMapNode(cached.node.key));\n const name = element(\"span\", \"map-node-label\");\n name.textContent = cached.node.label;\n select.append(name);\n if (cached.childCount > 0) {\n const count = element(\"span\", \"map-node-count\");\n count.textContent = `${cached.childCount} 项`;\n select.append(count);\n }\n node.append(select);\n return node;\n}\n\nfunction renderMapEdges(layer: SVGSVGElement, state: InteractiveMapState): void {\n const center = { x: BUSINESS_MAP_WORLD.width / 2, y: BUSINESS_MAP_WORLD.height / 2 };\n for (const cached of state.nodes.values()) {\n if (cached.role === \"context\") continue;\n const to = state.positions.get(cached.node.key);\n if (to === undefined) continue;\n const parent = cached.parentKey === undefined\n ? undefined\n : state.positions.get(cached.parentKey);\n const from = parent ?? center;\n if (from !== undefined) {\n appendMapEdge(layer, from, to, \"map-hierarchy-edge\", parent?.depth ?? 1, to.depth);\n }\n }\n for (const connection of state.connections.values()) {\n const from = state.positions.get(connection.from.key);\n const to = state.positions.get(connection.to.key);\n if (from === undefined || to === undefined) continue;\n appendMapEdge(\n layer,\n from,\n to,\n \"map-business-edge\",\n from.depth,\n to.depth,\n );\n }\n}\n\nfunction appendMapEdge(\n layer: SVGSVGElement,\n from: { readonly x: number; readonly y: number },\n to: { readonly x: number; readonly y: number },\n className: string,\n fromDepth: number,\n toDepth: number,\n): void {\n const path = document.createElementNS(\"http://www.w3.org/2000/svg\", \"path\");\n path.classList.add(className);\n path.dataset.fromDepth = String(fromDepth);\n path.dataset.toDepth = String(toDepth);\n const midpoint = { x: (from.x + to.x) / 2, y: (from.y + to.y) / 2 };\n const normal = { x: -(to.y - from.y) * 0.08, y: (to.x - from.x) * 0.08 };\n path.setAttribute(\"d\", `M ${from.x} ${from.y} Q ${midpoint.x + normal.x} ${midpoint.y + normal.y} ${to.x} ${to.y}`);\n layer.append(path);\n}\n\nfunction renderMapControls(): HTMLElement {\n const controls = element(\"div\", \"map-controls\");\n const immersive = document.body.classList.contains(\"is-immersive-map\");\n for (const [action, label, title] of [\n [\"zoom-out\", \"−\", \"缩小\"],\n [\"fit\", \"适应\", \"适应当前地图\"],\n [\"zoom-in\", \"+\", \"放大\"],\n [\"immersive\", immersive ? \"退出\" : \"沉浸\", immersive ? \"退出沉浸查看\" : \"进入沉浸查看\"],\n ] as const) {\n const button = element(\"button\", \"map-control\");\n button.type = \"button\";\n button.dataset.action = action;\n button.textContent = label;\n button.title = title;\n if (action === \"immersive\") button.setAttribute(\"aria-pressed\", String(immersive));\n controls.append(button);\n }\n return controls;\n}\n\nfunction installMapViewport(\n viewport: HTMLElement,\n world: HTMLElement,\n state: InteractiveMapState,\n): MapViewportController {\n let camera = state.camera ?? { scale: 1, x: 0, y: 0 };\n let drag: { readonly pointerId: number; readonly x: number; readonly y: number } | undefined;\n const controls = new Map(\n [...viewport.querySelectorAll<HTMLButtonElement>(\"[data-action]\")]\n .map((button) => [button.dataset.action!, button]),\n );\n\n const apply = (animated = false): void => {\n world.classList.toggle(\"is-animating\", animated);\n world.style.transform = `translate3d(${camera.x}px, ${camera.y}px, 0) scale(${camera.scale})`;\n state.camera = camera;\n viewport.dataset.zoom = camera.scale < 0.75 ? \"overview\" : camera.scale < 1.4 ? \"region\" : \"detail\";\n updateMapVisibility(viewport, state, camera.scale);\n };\n const fit = (): void => {\n camera = fitMapCamera(viewport.getBoundingClientRect(), mapBounds(state));\n apply(true);\n };\n const focus = (key: string, scale = camera.scale): void => {\n const position = state.positions.get(key);\n if (position === undefined) return;\n const rect = viewport.getBoundingClientRect();\n camera = {\n scale,\n x: rect.width / 2 - position.x * scale,\n y: rect.height / 2 - position.y * scale,\n };\n apply(true);\n };\n const zoom = (factor: number, point: { readonly x: number; readonly y: number }): void => {\n camera = zoomMapCameraAt(camera, factor, point);\n apply();\n };\n\n controls.get(\"zoom-in\")?.addEventListener(\"click\", () => {\n zoom(1.25, viewportCenter(viewport));\n });\n controls.get(\"zoom-out\")?.addEventListener(\"click\", () => {\n zoom(0.8, viewportCenter(viewport));\n });\n controls.get(\"fit\")?.addEventListener(\"click\", fit);\n controls.get(\"immersive\")?.addEventListener(\"click\", () => {\n setImmersiveMap(!document.body.classList.contains(\"is-immersive-map\"));\n });\n viewport.addEventListener(\"wheel\", (event) => {\n event.preventDefault();\n const rect = viewport.getBoundingClientRect();\n const point = { x: event.clientX - rect.left, y: event.clientY - rect.top };\n const before = camera.scale;\n zoom(Math.exp(-event.deltaY * 0.0015), point);\n if (camera.scale > before) maybeExpandFromZoom(event.target, state, camera, point);\n }, { passive: false });\n viewport.addEventListener(\"pointerdown\", (event) => {\n if (event.button !== 0 || (event.target as Element).closest(\"button\")) return;\n drag = { pointerId: event.pointerId, x: event.clientX, y: event.clientY };\n viewport.setPointerCapture(event.pointerId);\n viewport.classList.add(\"is-panning\");\n });\n viewport.addEventListener(\"pointermove\", (event) => {\n if (drag?.pointerId !== event.pointerId) return;\n camera = panMapCamera(camera, {\n x: event.clientX - drag.x,\n y: event.clientY - drag.y,\n });\n drag = { ...drag, x: event.clientX, y: event.clientY };\n apply();\n });\n viewport.addEventListener(\"pointerup\", () => {\n drag = undefined;\n viewport.classList.remove(\"is-panning\");\n });\n viewport.addEventListener(\"keydown\", (event) => {\n if (event.key === \"+\" || event.key === \"=\") {\n event.preventDefault();\n zoom(1.25, viewportCenter(viewport));\n }\n if (event.key === \"-\") {\n event.preventDefault();\n zoom(0.8, viewportCenter(viewport));\n }\n if (event.key === \"0\") {\n event.preventDefault();\n fit();\n }\n });\n apply();\n return { fit, focus, refresh: () => apply() };\n}\n\nfunction setImmersiveMap(immersive: boolean): void {\n document.body.classList.toggle(\"is-immersive-map\", immersive);\n const control = document.querySelector<HTMLButtonElement>(\"[data-action=immersive]\");\n if (control !== null) {\n control.textContent = immersive ? \"退出\" : \"沉浸\";\n control.title = immersive ? \"退出沉浸查看\" : \"进入沉浸查看\";\n control.setAttribute(\"aria-pressed\", String(immersive));\n }\n requestAnimationFrame(() => {\n const camera = interactiveMap?.camera;\n if (selectedBusinessKey !== undefined && camera !== undefined) {\n activeMapViewport?.focus(selectedBusinessKey, camera.scale);\n } else {\n activeMapViewport?.fit();\n }\n });\n}\n\nfunction maybeExpandFromZoom(\n target: EventTarget | null,\n state: InteractiveMapState,\n camera: MapCamera,\n pointer: { readonly x: number; readonly y: number },\n): void {\n const nodeElement = target instanceof Element ? target.closest<HTMLElement>(\".map-node\") : null;\n const key = nodeElement?.dataset.key\n ?? nearestExpandableMapNode(state, camera, pointer)\n ?? selectedBusinessKey;\n if (key === undefined || state.maps.has(key) || state.mapRequests.has(key)) return;\n const node = state.nodes.get(key);\n const position = state.positions.get(key);\n if (node?.expandable === true && position !== undefined && camera.scale >= semanticRevealScale(position.depth + 1)) {\n void selectMapNode(key);\n }\n}\n\nfunction nearestExpandableMapNode(\n state: InteractiveMapState,\n camera: MapCamera,\n pointer: { readonly x: number; readonly y: number },\n): string | undefined {\n let closest: { readonly key: string; readonly distance: number } | undefined;\n for (const cached of state.nodes.values()) {\n if (!cached.expandable) continue;\n const position = state.positions.get(cached.node.key);\n if (position === undefined) continue;\n const x = position.x * camera.scale + camera.x;\n const y = position.y * camera.scale + camera.y;\n const distance = Math.hypot(pointer.x - x, pointer.y - y);\n if (distance <= 130 && (closest === undefined || distance < closest.distance)) {\n closest = { key: cached.node.key, distance };\n }\n }\n return closest?.key;\n}\n\nfunction updateMapVisibility(viewport: HTMLElement, state: InteractiveMapState, scale: number): void {\n const nodesByKey = new Map(\n [...viewport.querySelectorAll<HTMLElement>(\".map-node\")]\n .map((element_) => [element_.dataset.key, element_]),\n );\n for (const node of state.nodes.values()) {\n const position = state.positions.get(node.node.key);\n const element_ = nodesByKey.get(node.node.key);\n if (position === undefined || element_ === undefined) continue;\n element_.hidden = !isMapNodeVisible(position.depth, scale);\n }\n viewport.querySelectorAll<SVGElement>(\"[data-from-depth][data-to-depth]\").forEach((element_) => {\n const visible = isMapConnectionVisible(\n Number(element_.dataset.fromDepth),\n Number(element_.dataset.toDepth),\n scale,\n );\n element_.toggleAttribute(\"hidden\", !visible);\n element_.style.display = visible ? \"\" : \"none\";\n });\n}\n\nfunction mapBounds(state: InteractiveMapState): { left: number; top: number; right: number; bottom: number } {\n const positions = [...state.positions.values()];\n if (positions.length === 0) {\n const x = BUSINESS_MAP_WORLD.width / 2;\n const y = BUSINESS_MAP_WORLD.height / 2;\n return { left: x - 240, top: y - 160, right: x + 240, bottom: y + 160 };\n }\n return {\n left: Math.min(BUSINESS_MAP_WORLD.width / 2, ...positions.map(({ x }) => x)) - 150,\n top: Math.min(BUSINESS_MAP_WORLD.height / 2, ...positions.map(({ y }) => y)) - 150,\n right: Math.max(BUSINESS_MAP_WORLD.width / 2, ...positions.map(({ x }) => x)) + 150,\n bottom: Math.max(BUSINESS_MAP_WORLD.height / 2, ...positions.map(({ y }) => y)) + 150,\n };\n}\n\nfunction viewportCenter(viewport: HTMLElement): { x: number; y: number } {\n const rect = viewport.getBoundingClientRect();\n return { x: rect.width / 2, y: rect.height / 2 };\n}\n\nasync function selectMapNode(key: string): Promise<void> {\n const state = interactiveMap;\n if (state === undefined) return;\n selectedBusinessKey = key;\n const cached = state.nodes.get(key);\n const mapPromise = cached?.expandable === true || cached === undefined\n ? readMap(key)\n : Promise.resolve(undefined);\n const nodePromise = loadNode(key);\n const map = await mapPromise;\n if (map !== undefined) renderMap(map);\n await nodePromise;\n const loadedNode = state.nodes.get(key);\n const position = state.positions.get(key);\n const targetScale = position === undefined\n ? state.camera?.scale\n : loadedNode?.expandable === true\n ? semanticRevealScale(position.depth + 1)\n : Math.max(state.camera?.scale ?? 1, semanticRevealScale(position.depth));\n activeMapViewport?.focus(key, targetScale);\n}\n\nasync function focusMapRoot(): Promise<void> {\n try {\n const map = await readMap();\n renderMap(map);\n activeMapViewport?.fit();\n } catch (error) {\n renderMapError(error);\n }\n}\n\nasync function loadNode(businessKey: string): Promise<void> {\n if (activeProject === undefined) return;\n selectedBusinessKey = businessKey;\n mapSurface.querySelectorAll<HTMLElement>(\".map-node\").forEach((node) => {\n node.classList.toggle(\"is-selected\", node.dataset.key === businessKey);\n });\n renderLoading(detailPanel, \"正在加载详情\");\n try {\n const view = await api<BusinessNodeView>(\n `/api/v1/projects/${activeProject.id}/node?key=${encodeURIComponent(businessKey)}`,\n );\n renderNode(view);\n } catch (error) {\n const state = element(\"div\", \"error-state\");\n const title = element(\"h3\");\n title.textContent = \"详情暂时无法显示\";\n const copy = element(\"p\");\n copy.textContent = errorMessage(error);\n state.append(title, copy);\n detailPanel.replaceChildren(state);\n }\n}\n\nfunction renderNode(view: BusinessNodeView): void {\n const node = view.node;\n detailPanel.replaceChildren();\n const heading = element(\"header\", \"detail-heading\");\n const kind = element(\"p\", \"detail-kind\");\n kind.textContent = `类型:${localizeBusinessKind(node.kind)}`;\n const title = element(\"h3\");\n title.textContent = node.label;\n const summary = element(\"p\");\n summary.textContent = node.summary;\n heading.append(kind, title, summary);\n detailPanel.append(heading);\n\n if (view.relations.length === 0) return;\n const relations = detailSection(\"相关业务\");\n view.relations.forEach((neighbor) => {\n const row = element(\"div\", \"relation-item\");\n const label = element(\"span\");\n label.textContent = neighbor.node.label;\n row.append(label);\n relations.append(row);\n });\n detailPanel.append(relations);\n}\n\nfunction renderBreadcrumbs(map: BusinessMap): void {\n breadcrumbs.replaceChildren();\n const root = element(\"button\", \"breadcrumb-button\");\n root.type = \"button\";\n root.textContent = activeProject?.name ?? \"业务地图\";\n root.addEventListener(\"click\", () => {\n void focusMapRoot();\n renderDetailPlaceholder();\n });\n breadcrumbs.append(root);\n for (const node of map.breadcrumbs) {\n const separator = element(\"span\", \"breadcrumb-separator\");\n separator.textContent = \"/\";\n const button = element(\"button\", \"breadcrumb-button\");\n button.type = \"button\";\n button.textContent = node.label;\n button.addEventListener(\"click\", () => {\n void selectMapNode(node.key);\n });\n breadcrumbs.append(separator, button);\n }\n}\n\nasync function runSearch(query: string): Promise<void> {\n if (activeProject === undefined) return;\n const sequence = ++searchSequence;\n searchResults.hidden = false;\n const loading = element(\"div\", \"search-message\");\n loading.textContent = \"正在搜索业务知识…\";\n searchResults.replaceChildren(loading);\n try {\n const result = await api<BusinessSearch>(\n `/api/v1/projects/${activeProject.id}/search?q=${encodeURIComponent(query)}&limit=12`,\n );\n if (sequence !== searchSequence || searchInput.value.trim() !== query) return;\n renderSearchResults(result.results);\n } catch (error) {\n if (sequence !== searchSequence) return;\n const message = element(\"div\", \"search-message\");\n message.textContent = errorMessage(error);\n searchResults.replaceChildren(message);\n }\n}\n\nfunction renderSearchResults(results: readonly SearchResult[]): void {\n searchResults.replaceChildren();\n searchResults.hidden = false;\n if (results.length === 0) {\n const message = element(\"div\", \"search-message\");\n message.textContent = \"没有找到匹配的业务知识。\";\n searchResults.append(message);\n return;\n }\n for (const result of results) {\n const button = element(\"button\", \"search-result\");\n button.type = \"button\";\n const label = element(\"strong\");\n label.textContent = result.node.label;\n const meta = element(\"span\");\n meta.textContent = `类型:${localizeBusinessKind(result.node.kind)}`;\n button.append(label, meta);\n button.addEventListener(\"click\", () => {\n searchInput.value = \"\";\n hideSearchResults();\n void selectMapNode(result.node.key);\n });\n searchResults.append(button);\n }\n}\n\nfunction hideSearchResults(): void {\n searchSequence += 1;\n searchResults.hidden = true;\n searchResults.replaceChildren();\n}\n\nfunction renderNoProjects(): void {\n searchInput.disabled = true;\n const state = element(\"div\", \"empty-state\");\n const title = element(\"h3\");\n title.textContent = \"没有可查看的项目\";\n const copy = element(\"p\");\n copy.textContent = \"请先为主分支项目准备业务知识。\";\n state.append(title, copy);\n mapSurface.replaceChildren(state);\n}\n\nfunction renderMapError(error: unknown): void {\n breadcrumbs.replaceChildren();\n const root = element(\"span\", \"breadcrumb-button\");\n root.textContent = activeProject?.name ?? \"业务地图\";\n breadcrumbs.append(root);\n const state = element(\"div\", \"error-state\");\n const title = element(\"h3\");\n title.textContent = error instanceof ApiRequestError && error.code === \"ATLAS_STATE_UNAVAILABLE\"\n ? \"地图尚未准备好\"\n : \"业务地图暂时无法显示\";\n const copy = element(\"p\");\n copy.textContent = errorMessage(error);\n state.append(title, copy);\n mapSurface.replaceChildren(state);\n}\n\nfunction renderFatalError(titleText: string, message: string): void {\n const state = element(\"div\", \"error-state\");\n const title = element(\"h3\");\n title.textContent = titleText;\n const copy = element(\"p\");\n copy.textContent = message;\n state.append(title, copy);\n mapSurface.replaceChildren(state);\n showNotice(message);\n}\n\nfunction renderDetailPlaceholder(): void {\n const placeholder = element(\"div\", \"detail-placeholder\");\n const title = element(\"h3\");\n title.textContent = \"选择一个业务区域\";\n const copy = element(\"p\");\n copy.textContent = \"在地图上点击节点查看简介和相关业务。\";\n placeholder.append(title, copy);\n detailPanel.replaceChildren(placeholder);\n}\n\nfunction renderLoading(target: HTMLElement, label: string): void {\n const state = element(\"div\", \"loading-state\");\n state.textContent = label;\n target.replaceChildren(state);\n}\n\nfunction detailSection(titleText: string): HTMLElement {\n const section = element(\"section\", \"detail-section\");\n const title = element(\"h4\");\n title.textContent = titleText;\n section.append(title);\n return section;\n}\n\nasync function api<Data>(path: string): Promise<Data> {\n const response = await fetch(path, { headers: { Accept: \"application/json\" } });\n const envelope = await response.json() as ApiEnvelope<Data> | ApiErrorEnvelope;\n if (!response.ok || \"error\" in envelope) {\n const error = \"error\" in envelope\n ? envelope.error\n : { code: \"INVALID_RESPONSE\", message: \"The local API returned an invalid response.\" };\n throw new ApiRequestError(error.code, error.message);\n }\n return envelope.data;\n}\n\nfunction replaceLocationProject(projectId: string): void {\n const url = new URL(location.href);\n url.searchParams.set(\"project\", projectId);\n history.replaceState(null, \"\", url);\n}\n\nfunction showNotice(message: string): void {\n window.clearTimeout(noticeTimer);\n notice.textContent = message;\n notice.hidden = false;\n noticeTimer = window.setTimeout(() => { notice.hidden = true; }, 4500);\n}\n\nfunction localizeBusinessKind(kind: string): string {\n const labels: Readonly<Record<string, string>> = {\n Capability: \"能力\",\n Scenario: \"场景\",\n Operation: \"操作\",\n Invariant: \"规则\",\n Interface: \"接口\",\n Data: \"数据\",\n };\n return labels[kind] ?? kind;\n}\n\nfunction errorMessage(error: unknown): string {\n return error instanceof Error ? error.message : String(error);\n}\n\nfunction requireElement<ElementType extends HTMLElement>(id: string): ElementType {\n const found = document.getElementById(id);\n if (found === null) throw new Error(`Missing required interface element ${id}`);\n return found as ElementType;\n}\n\nfunction element<Tag extends keyof HTMLElementTagNameMap>(\n tag: Tag,\n className?: string,\n): HTMLElementTagNameMap[Tag] {\n const created = document.createElement(tag);\n if (className !== undefined) created.className = className;\n return created;\n}\n"],"names":["loadCachedValue","values","pending","key","load","cached","inFlight","request","value","BUSINESS_MAP_WORLD","layoutBusinessMap","regions","existingNodes","center","positions","node","ready","parentKey","next","siblings","groupByParent","placeSiblings","removeRegion","parent","allSiblings","compareNodes","left","right","root","parentPosition","outwardAngle","region","index","angle","siblingAngle","depth","radius","siblingRadius","count","span","role","base","contextOffset","nodes","groups","group","MAP_CAMERA_LIMITS","zoomMapCameraAt","camera","factor","pointer","scale","clamp","worldX","worldY","panMapCamera","delta","fitMapCamera","viewport","bounds","padding","width","height","semanticRevealScale","isMapNodeVisible","isMapConnectionVisible","fromDepth","toDepth","minimum","maximum","ApiRequestError","code","message","projectList","requireElement","breadcrumbs","mapSurface","detailPanel","searchForm","searchInput","searchResults","notice","projects","activeProject","activeMapViewport","selectedBusinessKey","interactiveMap","searchSequence","noticeTimer","initialize","installInteractions","api","renderProjects","requestedProject","initialProject","id","freshness","selectProject","renderNoProjects","error","renderFatalError","errorMessage","event","debounceTimer","query","hideSearchResults","runSearch","target","setImmersiveMap","projectId","project","renderLoading","renderDetailPlaceholder","replaceLocationProject","map","readMap","renderMap","renderMapError","focusKey","state","cacheKey","mergeMap","cacheMapNode","breadcrumbFocus","connection","layout","nodeParentKey","position","childCount","expandable","existing","keepHierarchy","empty","element","button","name","renderBreadcrumbs","emptyTitle","emptyCopy","renderSpatialMap","world","connectionLayer","renderMapEdges","renderMapHub","renderMapNode","renderMapControls","shouldFitLoadedMap","installMapViewport","hub","label","select","selectMapNode","layer","to","from","appendMapEdge","className","path","midpoint","normal","controls","immersive","action","title","drag","apply","animated","updateMapVisibility","fit","mapBounds","focus","rect","zoom","point","viewportCenter","before","maybeExpandFromZoom","control","nearestExpandableMapNode","closest","x","y","distance","nodesByKey","element_","visible","mapPromise","nodePromise","loadNode","loadedNode","targetScale","focusMapRoot","businessKey","view","renderNode","copy","heading","kind","localizeBusinessKind","summary","relations","detailSection","neighbor","row","separator","sequence","loading","result","renderSearchResults","results","meta","titleText","showNotice","placeholder","section","response","envelope","url","found","tag","created"],"mappings":"ssBAAO,SAASA,GACdC,EACAC,EACAC,EACAC,EACgB,CAChB,MAAMC,EAASJ,EAAO,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I,EACjCA,EAAI,aAAa,IAAI,UAAW5G,CAAS,EACzC,QAAQ,aAAa,KAAM,GAAI4G,CAAG,CACpC,CAEA,SAASL,GAAW5I,EAAuB,CACzC,OAAO,aAAagB,CAAW,EAC/BP,EAAO,YAAcT,EACrBS,EAAO,OAAS,GAChBO,EAAc,OAAO,WAAW,IAAM,CAAEP,EAAO,OAAS,EAAM,EAAG,IAAI,CACvE,CAEA,SAASqH,GAAqBD,EAAsB,CASlD,MARiD,CAC/C,WAAY,KACZ,SAAU,KACV,UAAW,KACX,UAAW,KACX,UAAW,KACX,KAAM,IAAA,EAEMA,CAAI,GAAKA,CACzB,CAEA,SAAShG,EAAaF,EAAwB,CAC5C,OAAOA,aAAiB,MAAQA,EAAM,QAAU,OAAOA,CAAK,CAC9D,CAEA,SAASzB,EAAgDqB,EAAyB,CAChF,MAAM2H,EAAQ,SAAS,eAAe3H,CAAE,EACxC,GAAI2H,IAAU,KAAM,MAAM,IAAI,MAAM,sCAAsC3H,CAAE,EAAE,EAC9E,OAAO2H,CACT,CAEA,SAASrF,EACPsF,EACA/D,EAC4B,CAC5B,MAAMgE,EAAU,SAAS,cAAcD,CAAG,EAC1C,OAAI/D,IAAc,SAAWgE,EAAQ,UAAYhE,GAC1CgE,CACT"}
@@ -0,0 +1,61 @@
1
+ <!doctype html>
2
+ <html lang="zh-CN">
3
+ <head>
4
+ <meta charset="UTF-8" />
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />
6
+ <meta name="color-scheme" content="light" />
7
+ <meta name="theme-color" content="#f3f0e8" />
8
+ <title>Semantic Atlas</title>
9
+ <script type="module" crossorigin src="/assets/index-cze_4vtt.js"></script>
10
+ <link rel="stylesheet" crossorigin href="/assets/index-DneaErDj.css">
11
+ </head>
12
+ <body>
13
+ <div class="app-shell">
14
+ <aside class="project-rail" aria-label="项目">
15
+ <header class="rail-header">
16
+ <h1>项目</h1>
17
+ </header>
18
+ <nav id="project-list" class="project-list" aria-live="polite"></nav>
19
+ </aside>
20
+
21
+ <main class="workspace">
22
+ <header class="workspace-header">
23
+ <nav id="breadcrumbs" class="breadcrumbs" aria-label="业务路径"></nav>
24
+ <form id="search-form" class="search" role="search">
25
+ <label class="sr-only" for="business-search">搜索当前项目的业务知识</label>
26
+ <svg viewBox="0 0 24 24" aria-hidden="true">
27
+ <circle cx="11" cy="11" r="6.5"></circle>
28
+ <path d="m16 16 4 4"></path>
29
+ </svg>
30
+ <input
31
+ id="business-search"
32
+ name="q"
33
+ type="search"
34
+ autocomplete="off"
35
+ placeholder="搜索业务"
36
+ disabled
37
+ />
38
+ <div id="search-results" class="search-results" hidden></div>
39
+ </form>
40
+ </header>
41
+
42
+ <div class="content-layout">
43
+ <section id="map-surface" class="map-surface" aria-live="polite">
44
+ <div class="welcome-state">
45
+ <h3>选择一个项目</h3>
46
+ <p>地图会展示已整理的业务知识。</p>
47
+ </div>
48
+ </section>
49
+
50
+ <aside id="detail-panel" class="detail-panel" aria-label="业务详情" aria-live="polite">
51
+ <div class="detail-placeholder">
52
+ <h3>选择一个业务区域</h3>
53
+ <p>在地图上点击节点查看简介和相关业务。</p>
54
+ </div>
55
+ </aside>
56
+ </div>
57
+ </main>
58
+ </div>
59
+ <div id="notice" class="notice" role="status" hidden></div>
60
+ </body>
61
+ </html>
@@ -2,10 +2,14 @@ import type { GitRepository } from "../repository/types.js";
2
2
  import { GraphStore } from "../graph/graph-store.js";
3
3
  import type { BusinessGraphView, BusinessGraphNode, BusinessMapView, GraphSearchResult, StructuralGraphNode } from "../graph/types.js";
4
4
  import type { StructuralIndexBackend } from "../structural-backend/types.js";
5
+ import type { AtlasDatabaseAccess } from "../storage/atlas-database.js";
5
6
  import type { SemanticGraphChangeOptions, SemanticGraphChanges } from "./types.js";
7
+ export interface WorldGraphQueryOptions {
8
+ readonly atlasAccess?: AtlasDatabaseAccess;
9
+ }
6
10
  export declare class WorldGraphQuery implements Disposable {
7
11
  #private;
8
- constructor(repository: GitRepository, graph?: GraphStore, structural?: StructuralIndexBackend);
12
+ constructor(repository: GitRepository, graph?: GraphStore, structural?: StructuralIndexBackend, options?: WorldGraphQueryOptions);
9
13
  view(focusKey?: string): Promise<BusinessMapView | undefined>;
10
14
  searchBusiness(query: string, options?: {
11
15
  readonly limit?: number;
@@ -1 +1 @@
1
- {"version":3,"file":"world-graph-query.d.ts","sourceRoot":"","sources":["../../src/world/world-graph-query.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAC5D,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AACrD,OAAO,KAAK,EACV,iBAAiB,EACjB,iBAAiB,EAEjB,eAAe,EAIf,iBAAiB,EACjB,mBAAmB,EACpB,MAAM,mBAAmB,CAAC;AAE3B,OAAO,KAAK,EACV,sBAAsB,EAEvB,MAAM,gCAAgC,CAAC;AAIxC,OAAO,KAAK,EACV,0BAA0B,EAC1B,oBAAoB,EACrB,MAAM,YAAY,CAAC;AAQpB,qBAAa,eAAgB,YAAW,UAAU;;gBAO9C,UAAU,EAAE,aAAa,EACzB,KAAK,CAAC,EAAE,UAAU,EAClB,UAAU,GAAE,sBAAmE;IAS3E,IAAI,CAAC,QAAQ,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,eAAe,GAAG,SAAS,CAAC;IAQ7D,cAAc,CAClB,KAAK,EAAE,MAAM,EACb,OAAO,GAAE;QAAE,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAA;KAAO,GACxC,OAAO,CAAC,SAAS,iBAAiB,CAAC,iBAAiB,CAAC,EAAE,CAAC;IAcrD,UAAU,CACd,KAAK,EAAE,MAAM,EACb,OAAO,GAAE;QAAE,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAA;KAAO,GACxC,OAAO,CAAC,SAAS,iBAAiB,CAAC,mBAAmB,CAAC,EAAE,CAAC;IAevD,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,iBAAiB,GAAG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AC;IAcrD,UAAU,CACd,KAAK,EAAE,MAAM,EACb,OAAO,GAAE;QAAE,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAA;KAAO,GACxC,OAAO,CAAC,SAAS,iBAAiB,CAAC,mBAAmB,CAAC,EAAE,CAAC;IAevD,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,iBAAiB,GAAG,SAAS,CAAC;IAgBvE,OAAO,CAAC,OAAO,GAAE,0BAA+B,GAAG,oBAAoB,GAAG,SAAS;IAKnF,KAAK,IAAI,IAAI;IAMb,CAAC,MAAM,CAAC,OAAO,CAAC,IAAI,IAAI;IAIxB,OAAO,CAAC,YAAY;YAKN,gBAAgB;YAgBhB,OAAO;YAWP,iBAAiB;YAmBjB,cAAc;CAgB7B"}
@@ -59,12 +59,14 @@ export class WorldGraphQuery {
59
59
  #graph;
60
60
  #structural;
61
61
  #ownsGraph;
62
- constructor(repository, graph, structural = new CodeGraphStructuralBackend(repository)) {
62
+ #atlasAccess;
63
+ constructor(repository, graph, structural = new CodeGraphStructuralBackend(repository), options = {}) {
63
64
  const dependencies = createDependencies(repository, graph, structural);
64
65
  this.#repository = repository;
65
66
  this.#graph = dependencies.graph;
66
67
  this.#structural = dependencies.structural;
67
68
  this.#ownsGraph = dependencies.ownsGraph;
69
+ this.#atlasAccess = options.atlasAccess ?? "read-write";
68
70
  }
69
71
  async view(focusKey) {
70
72
  return this.withCurrentWorld(async (snapshot) => {
@@ -135,7 +137,7 @@ export class WorldGraphQuery {
135
137
  currentWorld() {
136
138
  const env_2 = { stack: [], error: void 0, hasError: false };
137
139
  try {
138
- const store = __addDisposableResource(env_2, new WorldSnapshotStore(this.#repository), false);
140
+ const store = __addDisposableResource(env_2, new WorldSnapshotStore(this.#repository, { access: this.#atlasAccess }), false);
139
141
  return store.requireCurrentWorld();
140
142
  }
141
143
  catch (e_2) {
@@ -1,12 +1,13 @@
1
1
  import type { GitRepository } from "../repository/types.js";
2
2
  import type { RepositorySnapshot } from "../snapshots/types.js";
3
+ import { type AtlasDatabaseOptions } from "../storage/atlas-database.js";
3
4
  import type { CurrentWorldSnapshot, SemanticGraphChangeOptions, SemanticGraphChanges, StructuralEvidenceResolver, WorldPublicationMetadata, WorldSnapshotState } from "./types.js";
4
5
  interface ReconciliationResult {
5
6
  readonly staleAssertions: readonly string[];
6
7
  }
7
8
  export declare class WorldSnapshotStore implements Disposable {
8
9
  #private;
9
- constructor(repository: GitRepository);
10
+ constructor(repository: GitRepository, options?: AtlasDatabaseOptions);
10
11
  readState(): WorldSnapshotState;
11
12
  begin(targetSnapshotId: string): void;
12
13
  publish(snapshot: RepositorySnapshot, backendVersion: string, extractionVersion: number | null, resolver: StructuralEvidenceResolver, changes: Omit<WorldPublicationMetadata, "staleAssertions">): ReconciliationResult;
@@ -1 +1 @@
1
- {"version":3,"file":"world-snapshot-store.d.ts","sourceRoot":"","sources":["../../src/world/world-snapshot-store.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAC5D,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAEhE,OAAO,KAAK,EACV,oBAAoB,EAEpB,0BAA0B,EAC1B,oBAAoB,EACpB,0BAA0B,EAE1B,wBAAwB,EACxB,kBAAkB,EACnB,MAAM,YAAY,CAAC;AAmBpB,UAAU,oBAAoB;IAC5B,QAAQ,CAAC,eAAe,EAAE,SAAS,MAAM,EAAE,CAAC;CAC7C;AAwBD,qBAAa,kBAAmB,YAAW,UAAU;;gBAKvC,UAAU,EAAE,aAAa;IAMrC,SAAS,IAAI,kBAAkB;IAsC/B,KAAK,CAAC,gBAAgB,EAAE,MAAM,GAAG,IAAI;IAmBrC,OAAO,CACL,QAAQ,EAAE,kBAAkB,EAC5B,cAAc,EAAE,MAAM,EACtB,iBAAiB,EAAE,MAAM,GAAG,IAAI,EAChC,QAAQ,EAAE,0BAA0B,EACpC,OAAO,EAAE,IAAI,C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AAO,CAAC,oBAAoB;IAuD5B,OAAO,CAAC,oBAAoB;CA8B7B"}
@@ -5,8 +5,8 @@ export class WorldSnapshotStore {
5
5
  #database;
6
6
  #repositoryId;
7
7
  #gitDirectory;
8
- constructor(repository) {
9
- this.#database = new AtlasDatabase(repository);
8
+ constructor(repository, options = {}) {
9
+ this.#database = new AtlasDatabase(repository, options);
10
10
  this.#repositoryId = repository.repositoryId;
11
11
  this.#gitDirectory = repository.gitDirectory;
12
12
  }