@lensmap/language-server 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.
- package/dist/preview/assets/playground-BkAkp5pk.js +215 -0
- package/dist/preview/assets/{preview-Bugh_5CI.js → preview-CYuPU91W.js} +1 -1
- package/dist/preview/assets/styles-Cl1eyMtV.js +200 -0
- package/dist/preview/index.html +2 -2
- package/dist/preview/preview.html +2 -2
- package/package.json +2 -2
- package/dist/preview/assets/playground-B1_UXc9t.js +0 -215
- package/dist/preview/assets/styles-BEj3ZVHM.js +0 -199
|
@@ -0,0 +1,215 @@
|
|
|
1
|
+
import{a as e,c as t,d as n,f as r,g as i,h as a,i as o,m as s,n as c,o as l,p as u,r as d,s as f,t as p,u as m}from"./styles-Cl1eyMtV.js";var h=i(),g=a();function _(e){try{let t=new r(`playground`,e).snapshot();return!t.valid||!t.graph?{ok:!1,error:t.diagnostics.map(e=>e.message).join(`
|
|
2
|
+
`)}:{ok:!0,graph:n(t.graph)}}catch(e){return{ok:!1,error:e instanceof Error?e.message:`The document could not be parsed.`}}}var v=l();function y({graph:t,thoughtHref:n,active:r,onFocus:i,onFragment:a,onActivatePortal:c,source:l,applied:d,error:f,status:p,onSourceChange:m,onApply:h,onLoadSample:g}){let _=t.edges.filter(e=>e.from===r?.key);return(0,v.jsxs)(`aside`,{className:`notes`,id:`lensmap-sidebar`,"aria-label":`Sidebar`,children:[(0,v.jsxs)(`div`,{className:`note-eyebrow`,children:[(0,v.jsx)(`span`,{children:`THOUGHTS & SOURCE`}),(0,v.jsx)(`span`,{children:`v1 / incomplete`})]}),(0,v.jsxs)(`details`,{className:`sidebar-section`,open:!0,children:[(0,v.jsx)(`summary`,{children:`Selected thought`}),(0,v.jsxs)(`div`,{className:`note-content`,children:[r?(0,v.jsx)(e,{components:{h1:({children:e})=>(0,v.jsx)(`h2`,{children:e}),a:({href:e,children:t})=>(0,v.jsx)(`a`,{href:e,onClick:t=>{e?.startsWith(`#`)&&(t.preventDefault(),a(e.slice(1)))},children:t})},children:r.markdown||(r.unresolved?`# Unresolved thought
|
|
3
|
+
|
|
4
|
+
This thought has not been named yet.`:r.title)}):(0,v.jsx)(`p`,{children:`No thought selected.`}),r&&(0,v.jsx)(`a`,{href:n??`#${encodeURIComponent(s(t.nodes).get(r.key)??r.key)}`,onClick:e=>{e.preventDefault(),a(encodeURIComponent(s(t.nodes).get(r.key)??r.key))},children:`Link to this thought`}),r?.destination&&(0,v.jsxs)(`div`,{className:`portal-actions`,children:[(0,v.jsx)(`p`,{children:r.destination.url}),(0,v.jsxs)(`button`,{type:`button`,onClick:()=>c?.(r),disabled:!c,children:[`Open`,` `,r.destination.kind===`map_link`?`destination map`:`external link`]})]})]})]}),(0,v.jsxs)(`details`,{className:`sidebar-section outgoing`,open:!0,children:[(0,v.jsx)(`summary`,{children:`Explicit connections`}),_.map(e=>{let n=t.nodes.find(t=>t.key===e.to);return n&&(0,v.jsxs)(`button`,{type:`button`,onClick:()=>i(e.to),children:[(0,v.jsxs)(`span`,{children:[u(e.type,`outgoing`,e.presentation),` `,`· `,o(n)]}),(0,v.jsx)(`span`,{"aria-hidden":`true`,children:`↗`})]},e.key)}),!_.length&&(0,v.jsx)(`p`,{children:`No outgoing connections yet.`})]}),(0,v.jsxs)(`details`,{className:`sidebar-section outgoing`,open:!0,children:[(0,v.jsx)(`summary`,{children:`Incoming connections`}),t.edges.filter(e=>e.to===r?.key).map(e=>{let n=t.nodes.find(t=>t.key===e.from);return n&&(0,v.jsxs)(`button`,{type:`button`,onClick:()=>i(n.key),children:[u(e.type,`incoming`,e.presentation),` `,`· `,o(n)]},e.key)})]}),(0,v.jsxs)(`details`,{className:`sidebar-section playground`,children:[(0,v.jsx)(`summary`,{children:`YAML playground`}),(0,v.jsxs)(`p`,{className:`editor-help`,id:`source-help`,children:[`Experimental `,(0,v.jsx)(`code`,{children:`version: v1`}),`. This is an incomplete schema, not a frozen format. Write thoughts first; positions and IDs are optional.`]}),(0,v.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),h()},children:[(0,v.jsx)(`label`,{className:`source-label`,htmlFor:`yaml-source`,children:`YAML source`}),(0,v.jsx)(`textarea`,{id:`yaml-source`,"aria-describedby":`source-help source-lifetime`,spellCheck:!1,value:l,onChange:e=>m(e.target.value)}),(0,v.jsxs)(`div`,{className:`editor-actions`,children:[(0,v.jsx)(`button`,{type:`submit`,children:`Apply YAML`}),(0,v.jsx)(`button`,{type:`button`,onClick:g,children:`Load sample`})]}),(0,v.jsx)(`p`,{className:`editor-state`,children:l===d?`Draft matches the map.`:`Unapplied changes — the map still shows the last valid document.`}),f&&(0,v.jsx)(`pre`,{className:`source-error`,role:`alert`,children:f}),(0,v.jsx)(`p`,{className:`editor-state`,role:`status`,children:p})]}),(0,v.jsx)(`p`,{className:`editor-help`,id:`source-lifetime`,children:`Drafts stay here while you navigate or collapse sections. Reloading the page discards them; saving and editor language tooling are not implemented yet.`})]})]})}var b=`# Lensmap v1 is incomplete and experimental. This sample is editable.
|
|
5
|
+
version: v1
|
|
6
|
+
nodes:
|
|
7
|
+
- id: ferry
|
|
8
|
+
full_text: |
|
|
9
|
+
# Night ferry
|
|
10
|
+
|
|
11
|
+
What would make a little night ferry worth taking? Start with the journey, not the timetable.
|
|
12
|
+
|
|
13
|
+
The [tide window](#tides) is a prose reference: following it does **not** add a line to the map.
|
|
14
|
+
|
|
15
|
+
- A dependable crossing
|
|
16
|
+
- A warm place to wait
|
|
17
|
+
- Room for unexpected stories
|
|
18
|
+
|
|
19
|
+
connections:
|
|
20
|
+
- full_text: |
|
|
21
|
+
# Weather
|
|
22
|
+
|
|
23
|
+
Rain changes the crossing, but it also changes how people wait. A roof can matter as much as a faster boat.
|
|
24
|
+
|
|
25
|
+
connections:
|
|
26
|
+
- id: tides
|
|
27
|
+
full_text: |
|
|
28
|
+
# Tide window
|
|
29
|
+
|
|
30
|
+
A timetable is a promise made to a moving shoreline.
|
|
31
|
+
|
|
32
|
+
**Question:** can the last departure move without leaving someone behind?
|
|
33
|
+
|
|
34
|
+
Return to the [night ferry](#ferry).
|
|
35
|
+
|
|
36
|
+
connections:
|
|
37
|
+
- full_text: |
|
|
38
|
+
# Tide tables
|
|
39
|
+
|
|
40
|
+
Compare the published prediction with the water at the actual landing.
|
|
41
|
+
|
|
42
|
+
- full_text: |
|
|
43
|
+
# Sandbar markers
|
|
44
|
+
|
|
45
|
+
A route that was clear last month may have moved after the storms.
|
|
46
|
+
|
|
47
|
+
- full_text: |
|
|
48
|
+
# Spring tides
|
|
49
|
+
|
|
50
|
+
The largest tidal range changes both the channel and the boarding ramp.
|
|
51
|
+
|
|
52
|
+
- full_text: |
|
|
53
|
+
# Distant tide gauge
|
|
54
|
+
|
|
55
|
+
An outer-harbor observation may explain a delay that is invisible at the pier.
|
|
56
|
+
|
|
57
|
+
- full_text: |
|
|
58
|
+
# A small forecast
|
|
59
|
+
|
|
60
|
+
A plain-language board at the pier. No need to make a traveller interpret a marine chart.
|
|
61
|
+
|
|
62
|
+
connections:
|
|
63
|
+
- node_id: harbor
|
|
64
|
+
- full_text: |
|
|
65
|
+
# Wind flags
|
|
66
|
+
|
|
67
|
+
A small visual signal can communicate more quickly than a paragraph of forecasts.
|
|
68
|
+
|
|
69
|
+
- full_text: |
|
|
70
|
+
# A squall line
|
|
71
|
+
|
|
72
|
+
The approaching weather matters more than the rain already overhead.
|
|
73
|
+
|
|
74
|
+
- full_text: |
|
|
75
|
+
# Offshore reports
|
|
76
|
+
|
|
77
|
+
Ask the boats beyond the headland what the sheltered pier cannot show.
|
|
78
|
+
|
|
79
|
+
- full_text: |
|
|
80
|
+
# Beyond the headland
|
|
81
|
+
|
|
82
|
+
The farthest observation belongs to the same crossing, even when it sits at the edge of attention.
|
|
83
|
+
|
|
84
|
+
- full_text: |
|
|
85
|
+
# Who crosses?
|
|
86
|
+
|
|
87
|
+
The cook going home. The early market seller. Someone who just wants to see the lights from the water.
|
|
88
|
+
|
|
89
|
+
connections:
|
|
90
|
+
- full_text: |
|
|
91
|
+
# A step-free pier
|
|
92
|
+
|
|
93
|
+
Access is part of the route, not something added after the boat is chosen.
|
|
94
|
+
|
|
95
|
+
connections:
|
|
96
|
+
- node_id: harbor
|
|
97
|
+
- full_text: |
|
|
98
|
+
# Ramp gradient
|
|
99
|
+
|
|
100
|
+
Check the boarding angle at low water, not only at a convenient midday tide.
|
|
101
|
+
|
|
102
|
+
- full_text: |
|
|
103
|
+
# Tactile wayfinding
|
|
104
|
+
|
|
105
|
+
The path should still make sense when a sign is difficult to see.
|
|
106
|
+
|
|
107
|
+
- full_text: |
|
|
108
|
+
# Late bus connection
|
|
109
|
+
|
|
110
|
+
A step-free boat is not enough if the last accessible bus leaves before it docks.
|
|
111
|
+
|
|
112
|
+
- full_text: |
|
|
113
|
+
# The last mile home
|
|
114
|
+
|
|
115
|
+
Follow the journey all the way from the landing to a traveller's own door.
|
|
116
|
+
|
|
117
|
+
- full_text: |
|
|
118
|
+
# Stories aboard
|
|
119
|
+
|
|
120
|
+
What do regular passengers notice that a route planner would miss?
|
|
121
|
+
|
|
122
|
+
> The crossing begins before you board.
|
|
123
|
+
|
|
124
|
+
connections:
|
|
125
|
+
- node_id: archive
|
|
126
|
+
- full_text: |
|
|
127
|
+
# Market mornings
|
|
128
|
+
|
|
129
|
+
The early crossing carries baskets, unfinished conversations, and a different rhythm.
|
|
130
|
+
|
|
131
|
+
- full_text: |
|
|
132
|
+
# Familiar faces
|
|
133
|
+
|
|
134
|
+
A regular passenger may notice an absence before anyone notices a missed ticket.
|
|
135
|
+
|
|
136
|
+
- full_text: |
|
|
137
|
+
# Songs at the pier
|
|
138
|
+
|
|
139
|
+
Keep a little room in the notes for things that are not operational requirements.
|
|
140
|
+
|
|
141
|
+
- full_text: |
|
|
142
|
+
# A crossing remembered
|
|
143
|
+
|
|
144
|
+
Someone who moved away still remembers which side of the boat caught the evening light.
|
|
145
|
+
|
|
146
|
+
- id: harbor
|
|
147
|
+
full_text: |
|
|
148
|
+
# Harbor lights
|
|
149
|
+
|
|
150
|
+
Wayfinding, shelter, and a recognisable place to arrive. This branch converges with accessibility and weather.
|
|
151
|
+
|
|
152
|
+
connections:
|
|
153
|
+
- full_text: |
|
|
154
|
+
# Keep it running
|
|
155
|
+
|
|
156
|
+
Maintenance is a recurring connection back to the crossing itself, not a dead-end checklist.
|
|
157
|
+
|
|
158
|
+
connections:
|
|
159
|
+
- node_id: ferry
|
|
160
|
+
- full_text: |
|
|
161
|
+
# Spare lamps
|
|
162
|
+
|
|
163
|
+
An ordinary replacement can keep a small failure from becoming a cancelled crossing.
|
|
164
|
+
|
|
165
|
+
- full_text: |
|
|
166
|
+
# Workshop rota
|
|
167
|
+
|
|
168
|
+
Leave enough time between shifts for repairs that need care rather than speed.
|
|
169
|
+
|
|
170
|
+
- full_text: |
|
|
171
|
+
# Winter overhaul
|
|
172
|
+
|
|
173
|
+
The work outside the busy season determines what can be promised during it.
|
|
174
|
+
|
|
175
|
+
- full_text: |
|
|
176
|
+
# A distant boatyard
|
|
177
|
+
|
|
178
|
+
Some repairs connect the little ferry to skills and suppliers far beyond its own harbor.
|
|
179
|
+
|
|
180
|
+
- id: archive
|
|
181
|
+
full_text: |
|
|
182
|
+
# Remember the route
|
|
183
|
+
|
|
184
|
+
Old tickets, passenger sketches, changing names for the same stretch of water.
|
|
185
|
+
|
|
186
|
+
connections:
|
|
187
|
+
- summary: null
|
|
188
|
+
|
|
189
|
+
connections:
|
|
190
|
+
- full_text: |
|
|
191
|
+
# A little ritual
|
|
192
|
+
|
|
193
|
+
Perhaps tea before departure. Perhaps something we have not thought of yet.
|
|
194
|
+
|
|
195
|
+
connections:
|
|
196
|
+
- full_text: |
|
|
197
|
+
# Tea before departure
|
|
198
|
+
|
|
199
|
+
A cup can mark the beginning of a journey without making a ceremony of it.
|
|
200
|
+
|
|
201
|
+
- full_text: |
|
|
202
|
+
# A passenger sketchbook
|
|
203
|
+
|
|
204
|
+
Let the route accumulate drawings as well as timetables.
|
|
205
|
+
|
|
206
|
+
- full_text: |
|
|
207
|
+
# Returning each year
|
|
208
|
+
|
|
209
|
+
The same crossing can become a quiet measure of what has changed.
|
|
210
|
+
|
|
211
|
+
- full_text: |
|
|
212
|
+
# A future tradition
|
|
213
|
+
|
|
214
|
+
Leave this idea far out on the map: it may only become clear after many crossings.
|
|
215
|
+
`,x=_(b);if(!x.ok)throw Error(x.error);var S=x.graph;function C(){let e=d({uri:``,graph:S,attachment:`draft:0`,source:b,draft:b}),[n,r]=(0,h.useState)(``),[i,a]=(0,h.useState)(``),o=e.current,[,l]=(0,h.useState)(0),u=(0,h.useRef)(new Map),g=(0,h.useRef)(new Map),x=(0,h.useRef)(new Map);u.current.set(o.uri,o);let C=async(e,n)=>{let r=g.current.get(e)??e,i=u.current.get(r);if(i)return i;if(!/^https?:/.test(r))throw Error(`Local maps are not attached in this standalone viewer.`);let a=await fetch(r,{signal:n});if(!a.ok)throw Error(`Map loading failed (${a.status}).`);let o=f(a.url).uri,s=u.current.get(o);if(s)return await a.body?.cancel(),n.throwIfAborted(),g.current.set(e,o),s;let c=await a.text(),l=_(c);if(!l.ok)throw Error(l.error);return n.throwIfAborted(),g.current.set(e,o),{uri:o,graph:l.graph,source:c,draft:c,attachment:t()}},w=()=>{let t=new URL(location.href);if(e.current.uri){let n=e.current,r=n.target?s(n.graph.nodes).get(n.target):void 0;t.searchParams.set(`map`,n.uri+(r?`#${encodeURIComponent(r)}`:``))}else t.searchParams.delete(`map`);return t.hash=``,t},T=(n=!1)=>{let r=n?history.state?.lensmapVisit:void 0,i=r&&x.current.has(r)?r:t();return x.current.set(i,{index:e.index,entry:e.current}),{lensmapVisit:i}},E=async(t,n,i=!1)=>{let o=e.index;if(await e.go(t,C,n,void 0)){r(``),a(``);let t=n!==void 0||e.index===o?`replaceState`:`pushState`;history[t](T(t===`replaceState`),``,i?location.href:w())}};return(0,h.useEffect)(()=>{history.replaceState(T(!0),``,location.href);let t=new URL(location.href).searchParams.get(`map`);if(t||location.hash){let e=location.hash?(t?t.split(`#`,1)[0]:``)+location.hash:t;e&&E(e,0)}let n=t=>{let n=t.state?.lensmapVisit,r=n?x.current.get(n):void 0;if(r){let t=e.entries[r.index]===r.entry?r.index:r.entry;E(r.entry.uri,t,!0)}};window.addEventListener(`popstate`,n);let r=()=>{E(location.hash||`#`)};return window.addEventListener(`hashchange`,r),()=>{e.cancel(),window.removeEventListener(`popstate`,n),window.removeEventListener(`hashchange`,r)}},[]),(0,v.jsxs)(v.Fragment,{children:[(0,v.jsx)(c,{navigation:e,openAnyway:()=>{e.fallback&&E(e.fallback)}}),(0,v.jsx)(p,{graph:o.graph,navigationControls:(0,v.jsxs)(`nav`,{className:`segmented`,"aria-label":`Map navigation`,children:[(0,v.jsx)(`button`,{type:`button`,disabled:e.index===0,onClick:()=>{let t=e.index-1;E(e.entries[t].uri,t)},children:`Back`}),(0,v.jsx)(`button`,{type:`button`,disabled:e.index>=e.entries.length-1,onClick:()=>{let t=e.index+1;E(e.entries[t].uri,t)},children:`Forward`})]}),thoughtLink:e=>m(location.href,o.uri,e),updateMode:`replace`,initialState:o.view,initialTarget:o.target,initialOverview:o.overview,onStateChange:e=>{o.view=e},onActivatePortal:e=>{if(e.destination){if(e.destination.kind===`map_link`)E(e.destination.url);else try{let t=f(e.destination.url,o.uri);if(!/^https?:/.test(t.uri))throw Error(`Standalone external opening supports HTTP(S) only.`);window.open(t.uri+(t.fragment?`#${encodeURIComponent(t.fragment)}`:``),`_blank`,`noopener`)}catch(e){r(e instanceof Error?e.message:`Opening failed.`)}}},renderSidebar:s=>(0,v.jsx)(y,{...s,source:o.draft??``,applied:o.source??``,error:n,status:i,onSourceChange:e=>{o.draft=e,l(e=>e+1)},onApply:()=>{e.cancel(),e.error=``;let n=_(o.draft??``);n.ok?(o.graph=n.graph,o.source=o.draft,o.attachment=t(),r(``),a(`Applied ${n.graph.nodes.length} thoughts and ${n.graph.edges.length} connections.`),l(e=>e+1)):(r(n.error),a(``))},onLoadSample:()=>{o.draft=b,l(e=>e+1),r(``),a(`Sample loaded into the draft. Apply YAML to change the map.`)}})},e.serial)]})}var w=document.getElementById(`root`);if(!w)throw Error(`Lensmap could not find its root element.`);(0,g.createRoot)(w).render((0,v.jsx)(h.StrictMode,{children:(0,v.jsx)(C,{})}));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{d as e,g as t,h as n,l as r,n as i,o as a,r as o,t as s,u as c}from"./styles-Cl1eyMtV.js";var l=t(),u=n();function d(e,t){let n=!1,r,i=new URLSearchParams(location.hash.slice(1)).get(`token`);i&&history.replaceState(null,``,location.pathname+location.search);let a=new AbortController;return(async()=>{if(i&&!(await fetch(`/api/auth`,{method:`POST`,credentials:`same-origin`,headers:{"Content-Type":`application/json`},body:JSON.stringify({token:i}),signal:a.signal})).ok)throw Error(`Preview authorization failed. Reopen the preview from Zed.`);n||(r=new EventSource(`/api/events`),r.onopen=()=>t(!0),r.onerror=()=>t(!1,`Disconnected or unauthorized. Reopen the preview from Zed after a server restart.`),r.onmessage=n=>{try{e(JSON.parse(n.data))}catch{t(!1,`The bridge sent an invalid update.`)}})})().catch(e=>{n||t(!1,e instanceof Error?e.message:`Preview connection failed.`)}),()=>{n=!0,a.abort(),r?.close()}}async function f(e,t){let n=await fetch(`/api/reveal`,{method:`POST`,credentials:`same-origin`,headers:{"Content-Type":`application/json`},body:JSON.stringify({uri:e,key:t})});if(!n.ok){let e=await n.json();throw Error(e.error??`Source reveal failed.`)}}async function p(e,t){let n=await fetch(`/api/open-destination`,{method:`POST`,credentials:`same-origin`,headers:{"Content-Type":`application/json`},body:JSON.stringify({uri:e.uri,key:t,baseRevision:e.revision,attachmentId:e.attachmentId})});if(!n.ok){let e=await n.json();throw Error(e.error??`Host destination opening failed.`)}}var m=a(),h=e=>{try{return decodeURIComponent(new URL(e).pathname.split(`/`).at(-1)??e)}catch{return e}};function g(){let[t,n]=(0,l.useState)([]),a=(0,l.useRef)(new Map),u=(0,l.useRef)(new Map),[g,_]=(0,l.useState)(null),v=o({uri:``,graph:{nodes:[],edges:[]},attachment:``},e=>{e.current.uri&&_(e.current.uri)}),[y,b]=(0,l.useState)(!1),[x,S]=(0,l.useState)(``),[C,w]=(0,l.useState)(``),[T,E]=(0,l.useState)(!1),[D,O]=(0,l.useState)(!1),k=(0,l.useRef)(void 0),[A,j]=(0,l.useState)(),M=(0,l.useRef)(0),N=(e,t)=>{_(e),j({key:t,sequence:++M.current})},P=(0,l.useEffectEvent)(e=>{if(e.type===`session`){let t=a.current;a.current=new Map(e.documents.map(e=>[e.uri,e]));for(let e of u.current.keys())a.current.has(e)||u.current.delete(e);k.current&&(!a.current.has(k.current.uri)||t.get(k.current.uri)?.attachmentId!==a.current.get(k.current.uri)?.attachmentId)&&(k.current=void 0),g&&(!a.current.has(g)||t.get(g)?.attachmentId!==a.current.get(g)?.attachmentId)&&j(void 0),n(e.documents),_(t=>t&&a.current.has(t)?t:e.activeUri??e.documents[0]?.uri??null)}else if(e.type===`snapshot`)a.current.get(e.snapshot.uri)?.attachmentId!==e.snapshot.attachmentId&&(k.current?.uri===e.snapshot.uri&&(k.current=void 0),g===e.snapshot.uri&&j(void 0)),a.current.set(e.snapshot.uri,e.snapshot),n([...a.current.values()]),_(t=>t??e.snapshot.uri);else if(e.type===`focus`)a.current.get(e.uri)?.graph?.nodes.some(t=>t.key===e.key)&&N(e.uri,e.key);else if(e.type===`caret`){let t=a.current.get(e.uri);if(!t||t.revision!==e.revision||!t.valid||t.pending){k.current=void 0;return}let n=k.current?.uri!==e.uri||k.current?.key!==e.key;k.current={uri:e.uri,key:e.key},T&&n&&e.key&&N(e.uri,e.key)}});(0,l.useEffect)(()=>d(P,(e,t)=>{b(e),S(t??``)}),[]);let F=t.find(e=>e.uri===g),I=(0,l.useMemo)(()=>{if(!F?.graph)return null;let t=u.current.get(F.uri);if(t?.attachmentId===F.attachmentId&&t?.revision===F.graphRevision&&t?.generation===F.graphGeneration&&JSON.stringify(t.semantic)===JSON.stringify(F.graph))return t.layout;let n=e(F.graph,t?.attachmentId===F.attachmentId?t:void 0);return u.current.set(F.uri,{attachmentId:F.attachmentId,revision:F.graphRevision,generation:F.graphGeneration,semantic:F.graph,layout:n}),n},[F]),L=async t=>{let n=a.current.get(t);if(!n)throw Error(`Destination map is not attached. Open it in the editor before navigating; the current map is retained.`);if(!n.valid||n.pending||!n.graph)throw Error(`Destination attached analysis is not currently valid.`);return{uri:t,graph:e(n.graph),attachment:n.attachmentId??``}};if(F&&I){if(v.current.uri!==F.uri)v.cancel(),v.entries=[...v.entries.slice(0,v.index+1),{uri:F.uri,graph:I,attachment:F.attachmentId??``}],v.index++;else{if(v.current.attachment!==(F.attachmentId??``)){let e=r(v.current,{uri:F.uri,graph:I,attachment:F.attachmentId??``},v.current.view);v.current.view&&!e&&(v.error=`Previous view target is removed or unavailable.`),v.current.view=e,v.current.target=void 0}v.current.graph=I,v.current.attachment=F.attachmentId??``}}let R=async(e,t)=>{await v.go(e,L,t)&&(_(v.current.uri),j(void 0))},z=(0,l.useRef)(!1);(0,l.useEffect)(()=>{if(z.current||!F?.valid||!I)return;z.current=!0;let e=new URL(location.href).searchParams.get(`map`),t=e?e.split(`#`,1)[0]+location.hash:location.hash;t&&R(t)},[F,I]);let B=y?F?F.pending?`Analyzing r${F.revision} · showing r${F.graphRevision??`—`}`:F.valid?`Live · r${F.revision}`:`Source r${F.revision} invalid · showing r${F.graphRevision??`—`} · stale`:`Waiting for a .lensmap document`:`Disconnected`;return(0,m.jsxs)(`div`,{className:`bridge-shell`,children:[(0,m.jsxs)(`header`,{className:`bridge-bar`,children:[(0,m.jsx)(`strong`,{children:`◎ Lensmap`}),(0,m.jsx)(`button`,{type:`button`,disabled:v.index<=1,onClick:()=>{let e=v.index-1;R(v.entries[e].uri,e)},children:`Back`}),(0,m.jsx)(`button`,{type:`button`,disabled:v.index>=v.entries.length-1,onClick:()=>{let e=v.index+1;R(v.entries[e].uri,e)},children:`Forward`}),(0,m.jsxs)(`select`,{"aria-label":`Document`,value:g??``,onChange:e=>{R(e.target.value),j(void 0),w(``)},children:[!t.length&&(0,m.jsx)(`option`,{value:``,children:`No attached document`}),t.map(e=>(0,m.jsx)(`option`,{value:e.uri,children:h(e.uri)},e.uri))]}),(0,m.jsxs)(`label`,{children:[(0,m.jsx)(`input`,{type:`checkbox`,checked:T,onChange:e=>{E(e.target.checked);let t=k.current;e.target.checked&&t?.key&&N(t.uri,t.key)}}),`Follow editor caret`]}),(0,m.jsx)(`button`,{type:`button`,"aria-pressed":D,onClick:()=>O(e=>!e),children:`Thought details`}),(0,m.jsx)(`span`,{role:`status`,"data-testid":`bridge-status`,children:B})]}),(0,m.jsx)(i,{navigation:v,openAnyway:()=>{v.fallback&&R(v.fallback)}}),(x||C)&&(0,m.jsxs)(`p`,{className:`bridge-notice`,children:[C||x,` The last map is retained.`]}),F&&!F.pending&&F.diagnostics.length>0&&(0,m.jsx)(`div`,{className:`bridge-errors`,role:`alert`,children:F.diagnostics.map(e=>(0,m.jsx)(`p`,{children:e.message},`${e.range.start.line}:${e.range.start.character}:${e.message}`))}),I&&g?(0,m.jsx)(s,{thoughtLink:e=>c(location.href,g,e),initialState:v.current.view,initialTarget:v.current.target,initialOverview:v.current.overview,onStateChange:e=>{v.current.view=e},onActivatePortal:e=>{if(!e.destination)return;if(e.destination.kind===`map_link`){R(e.destination.url);return}let t=a.current.get(g);t&&p(t,e.key).catch(e=>w(e instanceof Error?e.message:`Host opening failed.`))},graph:I,updateMode:`live`,focusRequest:A,showInspector:D,onRevealSource:e=>{w(``),f(g,e).catch(e=>w(e instanceof Error?e.message:`Source reveal failed.`))}},`${g}:${F?.attachmentId??``}:${v.serial}`):(0,m.jsxs)(`section`,{className:`bridge-empty`,children:[(0,m.jsx)(`h1`,{children:`Open a .lensmap document in Zed`}),(0,m.jsx)(`p`,{children:`Unsaved buffer contents drive this preview. Use the Lensmap code actions to open or centre it.`}),(0,m.jsx)(`p`,{children:`The format and integration are experimental. Source editing stays in your editor.`})]})]})}var _=document.getElementById(`root`);if(!_)throw Error(`Lensmap could not find its preview root.`);(0,u.createRoot)(_).render((0,m.jsx)(g,{}));
|