ontrackd 0.11.1 → 0.13.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 (160) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +9 -7
  3. package/dist/cli/build.js +9 -8
  4. package/dist/cli/build.js.map +1 -1
  5. package/dist/cli/cloud.js +4 -3
  6. package/dist/cli/cloud.js.map +1 -1
  7. package/dist/cli/feedback.js +4 -4
  8. package/dist/cli/hugo.js +4 -3
  9. package/dist/cli/hugo.js.map +1 -1
  10. package/dist/cli/init.d.ts +1 -1
  11. package/dist/cli/init.js +32 -11
  12. package/dist/cli/init.js.map +1 -1
  13. package/dist/cli/link.d.ts +2 -2
  14. package/dist/cli/link.js +20 -86
  15. package/dist/cli/link.js.map +1 -1
  16. package/dist/cli/pull.d.ts +1 -1
  17. package/dist/cli/pull.js +2 -2
  18. package/dist/cli/pull.js.map +1 -1
  19. package/dist/cli/push.d.ts +1 -1
  20. package/dist/cli/push.js +2 -2
  21. package/dist/cli/push.js.map +1 -1
  22. package/dist/cli/remote.js +6 -1
  23. package/dist/cli/remote.js.map +1 -1
  24. package/dist/core/envNames.d.ts +17 -0
  25. package/dist/core/envNames.js +28 -0
  26. package/dist/core/envNames.js.map +1 -0
  27. package/dist/core/exportTaskDoc.js.map +1 -1
  28. package/dist/core/feedbackTypes.d.ts +6 -0
  29. package/dist/core/oxcAst.js.map +1 -1
  30. package/dist/core/projectSecret.js +1 -1
  31. package/dist/core/staleness.js +1 -0
  32. package/dist/core/staleness.js.map +1 -1
  33. package/dist/core/styleOrigin.js.map +1 -1
  34. package/dist/core/untrusted.js +3 -0
  35. package/dist/core/untrusted.js.map +1 -1
  36. package/dist/expo/app/ConnectSheet.d.ts +13 -0
  37. package/dist/expo/app/ConnectSheet.js +121 -0
  38. package/dist/expo/app/ConnectSheet.js.map +1 -0
  39. package/dist/expo/app/Provider.js +6 -0
  40. package/dist/expo/app/Provider.js.map +1 -1
  41. package/dist/expo/app/adapter.d.ts +5 -0
  42. package/dist/expo/app/adapter.js.map +1 -1
  43. package/dist/expo/app/runtimeConfig.d.ts +4 -0
  44. package/dist/expo/app/runtimeConfig.js +7 -0
  45. package/dist/expo/app/runtimeConfig.js.map +1 -1
  46. package/dist/expo/app/useCloudReviewer.d.ts +6 -0
  47. package/dist/expo/app/useCloudReviewer.js +9 -0
  48. package/dist/expo/app/useCloudReviewer.js.map +1 -1
  49. package/dist/expo/metro.cjs +1 -1
  50. package/dist/expo/metroBuild.js +31 -5
  51. package/dist/expo/metroBuild.js.map +1 -1
  52. package/dist/expo/mode.js +2 -2
  53. package/dist/expo/publicConfig.d.ts +6 -0
  54. package/dist/expo/publicConfig.js.map +1 -1
  55. package/dist/expo/transformer.cjs +7 -2
  56. package/dist/integration/buildCredentials.d.ts +1 -1
  57. package/dist/integration/buildCredentials.js +5 -4
  58. package/dist/integration/buildCredentials.js.map +1 -1
  59. package/dist/integration/buildSession.js +6 -5
  60. package/dist/integration/buildSession.js.map +1 -1
  61. package/dist/integration/configuredApi.d.ts +1 -1
  62. package/dist/integration/configuredApi.js +5 -4
  63. package/dist/integration/configuredApi.js.map +1 -1
  64. package/dist/integration/devCloud.d.ts +13 -7
  65. package/dist/integration/devCloud.js +48 -24
  66. package/dist/integration/devCloud.js.map +1 -1
  67. package/dist/integration/importClient.d.ts +53 -0
  68. package/dist/integration/importClient.js +76 -0
  69. package/dist/integration/importClient.js.map +1 -0
  70. package/dist/integration/importPlan.d.ts +3 -2
  71. package/dist/integration/importPlan.js +10 -3
  72. package/dist/integration/importPlan.js.map +1 -1
  73. package/dist/integration/localImport.d.ts +30 -0
  74. package/dist/integration/localImport.js +139 -0
  75. package/dist/integration/localImport.js.map +1 -0
  76. package/dist/integration/localModeSwitch.d.ts +4 -0
  77. package/dist/integration/localModeSwitch.js +51 -0
  78. package/dist/integration/localModeSwitch.js.map +1 -0
  79. package/dist/integration/manifestSink.d.ts +1 -1
  80. package/dist/integration/manifestSink.js +2 -2
  81. package/dist/integration/manifestSink.js.map +1 -1
  82. package/dist/integration/manifestUpload.js +2 -2
  83. package/dist/integration/manifestUpload.js.map +1 -1
  84. package/dist/integration/middleware.d.ts +8 -0
  85. package/dist/integration/middleware.js +57 -10
  86. package/dist/integration/middleware.js.map +1 -1
  87. package/dist/integration/requestGuards.d.ts +2 -0
  88. package/dist/integration/requestGuards.js +4 -0
  89. package/dist/integration/requestGuards.js.map +1 -1
  90. package/dist/integration/sharedBuild.d.ts +6 -3
  91. package/dist/integration/sharedBuild.js +6 -2
  92. package/dist/integration/sharedBuild.js.map +1 -1
  93. package/dist/integration/sharedInject.js +5 -4
  94. package/dist/integration/sharedInject.js.map +1 -1
  95. package/dist/mcp/cloudRefresh.d.ts +1 -1
  96. package/dist/mcp/cloudRefresh.js +2 -2
  97. package/dist/mcp/cloudRefresh.js.map +1 -1
  98. package/dist/mcp/server.js +5 -2
  99. package/dist/mcp/server.js.map +1 -1
  100. package/dist/overlay/anchors.d.ts +2 -0
  101. package/dist/overlay/anchors.js +1 -1
  102. package/dist/overlay/anchors.js.map +1 -1
  103. package/dist/overlay/api.d.ts +1 -0
  104. package/dist/overlay/api.js.map +1 -1
  105. package/dist/overlay/browser.js +15 -0
  106. package/dist/overlay/browser.js.map +1 -1
  107. package/dist/overlay/connectDialog.d.ts +14 -0
  108. package/dist/overlay/connectDialog.js +297 -0
  109. package/dist/overlay/connectDialog.js.map +1 -0
  110. package/dist/overlay/dialogOpener.d.ts +30 -0
  111. package/dist/overlay/dialogOpener.js +82 -0
  112. package/dist/overlay/dialogOpener.js.map +1 -0
  113. package/dist/overlay/localMachine.js +1 -1
  114. package/dist/overlay/runtime.js +37 -6
  115. package/dist/overlay/runtime.js.map +1 -1
  116. package/dist/plugin/astro.d.ts +1 -0
  117. package/dist/plugin/astro.js +1 -0
  118. package/dist/plugin/astro.js.map +1 -1
  119. package/dist/plugin/eleventy.d.ts +2 -1
  120. package/dist/plugin/eleventy.js +4 -2
  121. package/dist/plugin/eleventy.js.map +1 -1
  122. package/dist/plugin/next.js +3 -2
  123. package/dist/plugin/next.js.map +1 -1
  124. package/dist/plugin/vite.d.ts +2 -0
  125. package/dist/plugin/vite.js +10 -7
  126. package/dist/plugin/vite.js.map +1 -1
  127. package/dist/plugin/webpack.js +3 -2
  128. package/dist/plugin/webpack.js.map +1 -1
  129. package/dist/remote/config.js +3 -2
  130. package/dist/remote/config.js.map +1 -1
  131. package/dist/remote/content-schema.d.ts +49 -10
  132. package/dist/remote/content-schema.js +1 -0
  133. package/dist/remote/content-schema.js.map +1 -1
  134. package/dist/setup/connect.d.ts +50 -5
  135. package/dist/setup/connect.js +151 -83
  136. package/dist/setup/connect.js.map +1 -1
  137. package/dist/setup/frameworks.d.ts +2 -2
  138. package/dist/setup/frameworks.js +5 -5
  139. package/dist/setup/frameworks.js.map +1 -1
  140. package/dist/sidecar/cloudSync.js +1 -1
  141. package/dist/sidecar/cloudSync.js.map +1 -1
  142. package/dist/sidecar/connectRoutes.d.ts +28 -0
  143. package/dist/sidecar/connectRoutes.js +154 -0
  144. package/dist/sidecar/connectRoutes.js.map +1 -0
  145. package/dist/sidecar/http.d.ts +4 -1
  146. package/dist/sidecar/http.js +61 -9
  147. package/dist/sidecar/http.js.map +1 -1
  148. package/dist/storage/cliSession.d.ts +1 -1
  149. package/dist/storage/cliSession.js +1 -1
  150. package/dist/storage/cliSession.js.map +1 -1
  151. package/dist/storage/localCredentials.d.ts +3 -3
  152. package/dist/storage/localCredentials.js +14 -6
  153. package/dist/storage/localCredentials.js.map +1 -1
  154. package/dist/storage/localRecipe.js +3 -2
  155. package/dist/storage/localRecipe.js.map +1 -1
  156. package/dist/storage/pulledComments.d.ts +1 -1
  157. package/dist/storage/sidecarAccess.d.ts +23 -0
  158. package/dist/storage/sidecarAccess.js +68 -1
  159. package/dist/storage/sidecarAccess.js.map +1 -1
  160. package/package.json +3 -3
@@ -0,0 +1,297 @@
1
+ /**
2
+ * What a dev server without a project shows instead of the comment tool (spec 2026-11-26 section 3):
3
+ * a card in a corner, never over the page. Plain DOM in a shadow root, loaded only when needed, in
4
+ * the same dark look as the rest of the overlay (styles.ts).
5
+ */
6
+ const reasons = {
7
+ 'no-secret': null,
8
+ malformed: 'The project secret in this app is not valid. Connect a project to get a new one.',
9
+ mismatch: "The project secret in this app doesn't match its project. Connect a project to get a new one.",
10
+ refused: 'ontrackd refused this app’s project secret. It may have been rotated. Connect a project to get a new one.',
11
+ legacy: 'This app uses an older project setting. Connect a project to get a secret.',
12
+ 'kept-local': 'FEEDBACK_CLOUD_SYNC=0 keeps this dev server off ontrackd. Remove it, then restart the dev server.',
13
+ };
14
+ const css = `:host{all:initial;--fb-bg:#2b2b2b;--fb-bg-raised:#363636;--fb-line:rgba(255,255,255,.11);--fb-text:#f2f2f2;--fb-muted:rgba(242,242,242,.52);--fb-accent:#3b82f6;--fb-primary:#2563eb;--fb-danger:#ef4444;color-scheme:dark;
15
+ font-family:ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,"Segoe UI",sans-serif}
16
+ *{box-sizing:border-box}
17
+ .card{position:fixed;right:16px;bottom:16px;z-index:2147483646;width:min(360px,calc(100vw - 32px));font-size:13px;line-height:1.45;color:var(--fb-text);background:var(--fb-bg);
18
+ border:1px solid var(--fb-line);border-radius:12px;box-shadow:0 12px 36px rgba(0,0,0,.4);padding:16px;cursor:default}
19
+ h2{font-size:14px;font-weight:600;margin:0 24px 8px 0}p{margin:0 0 10px}.muted{color:var(--fb-muted);font-size:12px}
20
+ button{font:inherit;color:var(--fb-text);background:var(--fb-bg-raised);border:1px solid var(--fb-line);border-radius:8px;padding:6px 12px;cursor:pointer;margin:0 6px 6px 0}
21
+ button:hover{background:#404040}button.primary{background:var(--fb-primary);border-color:var(--fb-primary);color:#fff}
22
+ button:focus-visible,a:focus-visible{outline:2px solid var(--fb-accent);outline-offset:2px}
23
+ .close{position:absolute;top:8px;right:8px;margin:0;padding:2px 8px;border:0;background:none;font-size:16px;line-height:1.2;color:var(--fb-muted)}
24
+ code{display:block;font:12px ui-monospace,SFMono-Regular,Menlo,monospace;word-break:break-all;background:#1f1f1f;border:1px solid var(--fb-line);padding:8px;border-radius:6px;margin:0 0 10px}
25
+ .status{margin:0}.status:empty{display:none}.code{font:600 16px ui-monospace,SFMono-Regular,Menlo,monospace;letter-spacing:.08em}a{color:var(--fb-accent)}`;
26
+ let dismiss = null;
27
+ let current = null;
28
+ function mount() {
29
+ dismiss?.();
30
+ const host = document.createElement('div');
31
+ host.id = 'feedback-connect-root';
32
+ const root = host.attachShadow({ mode: 'open' });
33
+ const style = document.createElement('style');
34
+ style.textContent = css;
35
+ const card = document.createElement('section');
36
+ card.className = 'card';
37
+ card.setAttribute('role', 'dialog');
38
+ card.setAttribute('aria-label', 'ontrackd');
39
+ card.setAttribute('data-fb-connect', '');
40
+ card.tabIndex = -1;
41
+ const before = document.activeElement instanceof HTMLElement ? document.activeElement : null;
42
+ const close = el('button', '×', { class: 'close', type: 'button', 'aria-label': 'Close' });
43
+ card.append(close, el('p', undefined, { class: 'status muted', 'aria-live': 'polite', 'data-fb-status': '' }));
44
+ root.append(style, card);
45
+ document.body.append(host);
46
+ let done = false;
47
+ const onKey = (event) => { if (event.key === 'Escape') {
48
+ event.stopPropagation();
49
+ finish();
50
+ } };
51
+ const finish = () => { if (done)
52
+ return; done = true; document.removeEventListener('keydown', onKey, true); host.remove(); if (dismiss === finish)
53
+ dismiss = null; if (before?.isConnected)
54
+ before.focus(); };
55
+ dismiss = finish;
56
+ close.onclick = finish;
57
+ document.addEventListener('keydown', onKey, true);
58
+ card.focus();
59
+ current = { card, closed: () => done };
60
+ return current;
61
+ }
62
+ function el(tag, text, attrs = {}) {
63
+ const node = document.createElement(tag);
64
+ if (text !== undefined)
65
+ node.textContent = text;
66
+ for (const [key, value] of Object.entries(attrs))
67
+ node.setAttribute(key, value);
68
+ if (tag === 'button' && !node.hasAttribute('type'))
69
+ node.setAttribute('type', 'button');
70
+ return node;
71
+ }
72
+ async function post(route, body = {}) {
73
+ try {
74
+ const response = await fetch(route, { method: 'POST', credentials: 'same-origin', headers: { 'content-type': 'application/json' }, body: JSON.stringify(body) });
75
+ const value = await response.json().catch(() => ({}));
76
+ return { ok: response.ok, status: response.status, value: (value && typeof value === 'object' ? value : {}) };
77
+ }
78
+ catch {
79
+ return { ok: false, status: 0, value: {} };
80
+ }
81
+ }
82
+ /** Replaces everything but the close button, and moves focus to the first control (or the card). */
83
+ function render(card, ...nodes) {
84
+ const keep = [card.querySelector('.close'), card.querySelector('.status')].filter((node) => node !== null);
85
+ const status = keep[1];
86
+ if (status) {
87
+ status.textContent = '';
88
+ status.removeAttribute('data-fb-connect-written');
89
+ }
90
+ card.replaceChildren(keep[0], ...nodes, ...(status ? [status] : []));
91
+ (card.querySelector('button:not(.close), a') ?? card).focus();
92
+ }
93
+ /** A short line in the polite live region, so a screen reader hears it without the focus moving. */
94
+ function say(card, text, attrs = {}) {
95
+ const status = card.querySelector('.status');
96
+ if (!status)
97
+ return;
98
+ status.textContent = text;
99
+ for (const [key, value] of Object.entries(attrs))
100
+ status.setAttribute(key, value);
101
+ }
102
+ /** Only an absolute http(s) address is ever opened or linked. */
103
+ function safeAddress(value) {
104
+ if (typeof value !== 'string')
105
+ return null;
106
+ try {
107
+ const url = new URL(value);
108
+ return url.protocol === 'http:' || url.protocol === 'https:' ? url.href : null;
109
+ }
110
+ catch {
111
+ return null;
112
+ }
113
+ }
114
+ /** Any 403 from a connect route: the dev server refused this browser (not loopback, a relay, another name). */
115
+ const blocked = 'Connect from the app on this computer at http://localhost, or add ONTRACKD_SECRET to your env file by hand.';
116
+ export function showConnectDialog(options = {}) {
117
+ const mounted = mount();
118
+ const why = options.reason ? reasons[options.reason] : null;
119
+ const start = el('button', 'Connect a project', { class: 'primary', 'data-fb-connect-start': '' });
120
+ render(mounted.card, el('h2', 'ontrackd needs a free account to work on your dev server.'), ...(why ? [el('p', why)] : []), el('p', 'Sign in or sign up, then pick or create a project. It takes a minute.', { class: 'muted' }), start);
121
+ start.onclick = () => void connect(mounted);
122
+ }
123
+ async function connect(mounted) {
124
+ const { card } = mounted;
125
+ // Opened in the click, before any await, so the browser lets it open.
126
+ const tab = window.open('about:blank', '_blank');
127
+ if (tab)
128
+ tab.opener = null;
129
+ const started = await post('/__fb/connect/start');
130
+ if (started.status === 403) {
131
+ tab?.close();
132
+ render(card, el('h2', 'Could not start the connection'));
133
+ say(card, blocked);
134
+ return;
135
+ }
136
+ if (!started.ok) {
137
+ tab?.close();
138
+ const message = typeof started.value.error === 'string' ? started.value.error : 'ontrackd cannot be reached right now. Try again in a minute.';
139
+ const again = el('button', 'Try again', { class: 'primary' });
140
+ again.onclick = () => void connect(mounted);
141
+ render(card, el('h2', 'Could not start the connection'), again);
142
+ say(card, message);
143
+ return;
144
+ }
145
+ const { connectionId, userCode, interval, expiresAt } = started.value;
146
+ const address = safeAddress(started.value.verificationUrl);
147
+ if (tab && address)
148
+ tab.location.href = address;
149
+ else
150
+ tab?.close();
151
+ render(card, el('h2', 'Approve this app in your browser'), el('p', address ? 'Check that the page shows this code:' : 'Open the Connect page in your ontrackd dashboard and check that it shows this code:', { class: 'muted' }), el('p', String(userCode), { class: 'code', 'data-fb-connect-code': '' }), el('p', 'Approving needs the owner or admin role on the project. Ask an admin of that project, or create your own project.', { class: 'muted' }), ...(address ? [el('a', 'Open the page again', { href: address, target: '_blank', rel: 'noopener noreferrer' })] : []));
152
+ const deadline = Date.parse(String(expiresAt));
153
+ const failure = (title, message, label = 'Start again') => {
154
+ const again = el('button', label, { class: 'primary' });
155
+ again.onclick = () => void connect(mounted);
156
+ render(card, el('h2', title), again);
157
+ say(card, message);
158
+ };
159
+ const expired = 'The code expired before it was approved. Start again for a new one.';
160
+ let wait = Math.max(1, Number(interval) || 2) * 1000;
161
+ while (!mounted.closed()) {
162
+ await new Promise((resolve) => setTimeout(resolve, wait));
163
+ if (mounted.closed())
164
+ return;
165
+ const polled = await post('/__fb/connect/poll', { connectionId });
166
+ if (polled.status === 403) {
167
+ render(card, el('h2', 'Not connected'));
168
+ say(card, blocked);
169
+ return;
170
+ }
171
+ const status = polled.value.status;
172
+ // A dev server that stops answering is retried until the code itself runs out.
173
+ if (polled.status === 0) {
174
+ if (Date.now() >= deadline) {
175
+ failure('Not connected', expired);
176
+ return;
177
+ }
178
+ continue;
179
+ }
180
+ if (status === 'pending')
181
+ continue;
182
+ if (status === 'slow-down') {
183
+ wait = Math.max(wait + 1000, Number(polled.value.retryAfter) * 1000 || 0);
184
+ continue;
185
+ }
186
+ if (status === 'approved' && typeof polled.value.secret === 'string' && polled.value.secret !== '') {
187
+ approved(mounted, connectionId, String(polled.value.projectName ?? ''), polled.value.secret, typeof polled.value.projectId === 'string' ? polled.value.projectId : undefined);
188
+ return;
189
+ }
190
+ failure('Not connected', status === 'denied' ? 'The connection was denied. Start again to pick another project.'
191
+ : status === 'expired' ? expired
192
+ : typeof polled.value.message === 'string' ? polled.value.message : 'The connection failed. Start again.');
193
+ return;
194
+ }
195
+ }
196
+ function approved(mounted, connectionId, projectName, secret, projectId) {
197
+ const { card } = mounted;
198
+ // Masked: the real value is held in this closure and enters the DOM only on Show.
199
+ const masked = `ONTRACKD_SECRET=${secret.slice(0, 7)}${'•'.repeat(12)}`;
200
+ const line = `ONTRACKD_SECRET=${secret}`;
201
+ const value = el('code', masked, { 'data-fb-secret': '' });
202
+ const show = el('button', 'Show', { 'aria-pressed': 'false', 'data-fb-secret-show': '' });
203
+ const copy = el('button', 'Copy', { 'data-fb-secret-copy': '' });
204
+ const write = el('button', 'Add it for me', { class: 'primary', 'data-fb-secret-write': '' });
205
+ let shown = false;
206
+ show.onclick = () => {
207
+ shown = !shown;
208
+ value.textContent = shown ? line : masked;
209
+ show.textContent = shown ? 'Hide' : 'Show';
210
+ show.setAttribute('aria-pressed', String(shown));
211
+ };
212
+ copy.onclick = () => { void navigator.clipboard?.writeText(line).then(() => say(card, 'Copied.'), () => say(card, 'Could not copy. Select the line and copy it by hand.')); };
213
+ write.onclick = async () => {
214
+ const result = await post('/__fb/connect/write', { connectionId });
215
+ if (!result.ok) {
216
+ say(card, result.status === 403 ? blocked : 'Could not add it. Copy the line and add it yourself.');
217
+ return;
218
+ }
219
+ render(card, el('h2', `Connected to ${projectName}`));
220
+ say(card, `Added to ${String(result.value.file)}. Restart your dev server to start commenting.`, { 'data-fb-connect-written': '' });
221
+ await offerImport({ connectionId, projectName, projectId });
222
+ };
223
+ render(card, el('h2', `Connected to ${projectName}`), el('p', 'Add this line to your app’s environment file, or let ontrackd add it.'), value, show, copy, write);
224
+ }
225
+ export function showOfflineNotice() {
226
+ const { card } = mount();
227
+ render(card, el('h2', "ontrackd can't be reached"), el('p', 'Comments are off on this page until it can. Check your connection, then reload.', { 'data-fb-offline': '' }));
228
+ }
229
+ const refusalReasons = { invalid: 'something in them is not valid', invalid_key: 'their id is not valid' };
230
+ /** One answer per browser session and project: "Not now", or an import that left only refused comments, is not asked again. */
231
+ const askedKey = (project) => `ontrackd:import-offer:${project ?? 'project'}`;
232
+ const wasAsked = (project) => { try {
233
+ return sessionStorage.getItem(askedKey(project)) === '1';
234
+ }
235
+ catch {
236
+ return false;
237
+ } };
238
+ const rememberAsked = (project) => { try {
239
+ sessionStorage.setItem(askedKey(project), '1');
240
+ }
241
+ catch { /* private mode: asked again next load */ } };
242
+ /**
243
+ * "Move N comments into <project>?" Nothing moves without the click, and nothing is sent before it: the offer
244
+ * rests on the count the dev server gives. The originals are kept, never deleted.
245
+ */
246
+ export async function offerImport(options) {
247
+ if (wasAsked(options.projectId))
248
+ return;
249
+ const pending = await fetch('/__fb/connect/pending', { credentials: 'same-origin', cache: 'no-store' }).then((r) => (r.ok ? r.json() : null)).catch(() => null);
250
+ const count = Number(pending?.count) || 0;
251
+ if (!count)
252
+ return;
253
+ const project = options.projectName || (typeof pending?.projectName === 'string' ? pending.projectName : '') || 'your project';
254
+ const many = `${count} comment${count === 1 ? '' : 's'}`;
255
+ const card = (current && !current.closed() ? current : mount()).card;
256
+ card.querySelector('[data-fb-import]')?.remove();
257
+ const section = el('div', undefined, { 'data-fb-import': '' });
258
+ const run = el('button', 'Move them', { class: 'primary', 'data-fb-import-run': '' });
259
+ const keep = el('button', 'Not now', { 'data-fb-import-skip': '' });
260
+ section.append(el('p', `Move ${many} into ${project}?`), run, keep);
261
+ keep.onclick = () => { rememberAsked(options.projectId); section.remove(); };
262
+ run.onclick = async () => {
263
+ run.setAttribute('disabled', '');
264
+ keep.setAttribute('disabled', '');
265
+ say(card, 'Moving comments...');
266
+ // The import checks the whole batch first and writes nothing if the project cannot take it.
267
+ const done = await post('/__fb/connect/import', { connectionId: options.connectionId, dryRun: false });
268
+ const report = done.value.report;
269
+ if (!done.value.ok || !report) {
270
+ say(card, `Nothing was moved: ${typeof done.value.error === 'string' ? done.value.error : 'try again in a minute'}.`);
271
+ run.removeAttribute('disabled');
272
+ keep.removeAttribute('disabled');
273
+ return;
274
+ }
275
+ const lines = [`Moved ${report.comments.created + report.comments.alreadyThere} of ${many} into ${project}.`];
276
+ const reasons = new Map();
277
+ for (const refused of report.refused)
278
+ reasons.set(refused.reason, (reasons.get(refused.reason) ?? 0) + 1);
279
+ if (report.refused.length)
280
+ lines.push(`${report.refused.length} could not be moved and stay on this computer: ${[...reasons].map(([reason, n]) => `${n} because ${refusalReasons[reason] ?? 'they were refused'}`).join(', ')}.`);
281
+ if (report.files.failed)
282
+ lines.push(`${report.files.failed} file${report.files.failed === 1 ? '' : 's'} did not upload, so everything stays on this computer. Move them again to finish.`);
283
+ else if (typeof done.value.moved === 'string')
284
+ lines.push(`The originals are kept in ${done.value.moved}.`);
285
+ section.replaceChildren(...lines.map((line) => el('p', line)));
286
+ say(card, lines[0]);
287
+ if (report.files.failed) {
288
+ const again = el('button', 'Move them', { class: 'primary', 'data-fb-import-run': '' });
289
+ again.onclick = () => { section.remove(); void offerImport(options); };
290
+ section.append(again);
291
+ }
292
+ else if (report.refused.length)
293
+ rememberAsked(options.projectId);
294
+ };
295
+ card.insertBefore(section, card.querySelector('.status'));
296
+ }
297
+ //# sourceMappingURL=connectDialog.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"connectDialog.js","sourceRoot":"","sources":["../../src/overlay/connectDialog.ts"],"names":[],"mappings":"AAEA;;;;GAIG;AACH,MAAM,OAAO,GAAyC;IACpD,WAAW,EAAE,IAAI;IACjB,SAAS,EAAE,kFAAkF;IAC7F,QAAQ,EAAE,+FAA+F;IACzG,OAAO,EAAE,2GAA2G;IACpH,MAAM,EAAE,4EAA4E;IACpF,YAAY,EAAE,mGAAmG;CAClH,CAAC;AAEF,MAAM,GAAG,GAAG;;;;;;;;;;;2JAW+I,CAAC;AAK5J,IAAI,OAAO,GAAwB,IAAI,CAAC;AACxC,IAAI,OAAO,GAAmB,IAAI,CAAC;AAEnC,SAAS,KAAK;IACZ,OAAO,EAAE,EAAE,CAAC;IACZ,MAAM,IAAI,GAAG,QAAQ,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;IAC3C,IAAI,CAAC,EAAE,GAAG,uBAAuB,CAAC;IAClC,MAAM,IAAI,GAAG,IAAI,CAAC,YAAY,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC,CAAC;IACjD,MAAM,KAAK,GAAG,QAAQ,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC;IAC9C,KAAK,CAAC,WAAW,GAAG,GAAG,CAAC;IACxB,MAAM,IAAI,GAAG,QAAQ,CAAC,aAAa,CAAC,SAAS,CAAC,CAAC;IAC/C,IAAI,CAAC,SAAS,GAAG,MAAM,CAAC;IACxB,IAAI,CAAC,YAAY,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;IACpC,IAAI,CAAC,YAAY,CAAC,YAAY,EAAE,UAAU,CAAC,CAAC;IAC5C,IAAI,CAAC,YAAY,CAAC,iBAAiB,EAAE,EAAE,CAAC,CAAC;IACzC,IAAI,CAAC,QAAQ,GAAG,CAAC,CAAC,CAAC;IACnB,MAAM,MAAM,GAAG,QAAQ,CAAC,aAAa,Y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AAa,CAAC,SAAS,CAAC,CAAC,CAAC;AAC5D,CAAC"}
@@ -0,0 +1,30 @@
1
+ /**
2
+ * The way back into a dialog or drawer a comment was left in.
3
+ *
4
+ * A comment left inside a dialog is drawn only while that dialog is open. Opened from the list
5
+ * while it is closed, the comment would have nowhere to sit but a corner, so the overlay records
6
+ * what opened the dialog when the comment is made, and clicks it again to show the comment where
7
+ * it was written. Nothing is recorded outside a dialog, and a comment with no opener (or whose
8
+ * opener is not on this page) falls back to the corner pin, as before.
9
+ */
10
+ import type { Anchor, Comment } from '../core/feedbackTypes.js';
11
+ /** Notes a click the page received, so the dialog it opened can name it later. */
12
+ export declare function rememberClick(target: EventTarget | null): void;
13
+ /** True while the overlay is clicking an opener itself: that click is the page's, not a dismissal. */
14
+ export declare function openingDialog(): boolean;
15
+ /**
16
+ * What opened the dialog `element` sits in, described so it can be found again after a reload.
17
+ *
18
+ * The trigger that names the dialog (`aria-controls`, as Radix and most libraries set it) when
19
+ * there is one; otherwise the last thing clicked outside the dialog, which is what opened it in
20
+ * every case the overlay can see. Null outside a dialog, or when neither is on the page.
21
+ */
22
+ export declare function openerFor(element: HTMLElement): Anchor | null;
23
+ /**
24
+ * Opens the dialog a comment was left in, when its element is not on screen and its opener is.
25
+ *
26
+ * Resolves once the element shows, or after `waitMs` if it never does (the opener did something
27
+ * else, or the dialog loads slowly): the thread opens either way, in the corner if need be.
28
+ * An opener that says it is already expanded is not clicked, since a second click would close it.
29
+ */
30
+ export declare function openDialogFor(comment: Comment, locate: (comment: Comment) => HTMLElement | null, waitMs?: number): Promise<void>;
@@ -0,0 +1,82 @@
1
+ import { anchorForElement, locateAnchor, opensOverAnyPage, plainAnchorFor } from './anchors.js';
2
+ import { describeElement } from './elementDescription.js';
3
+ /** What a person clicks to open something: the element a click inside it stands for. */
4
+ const trigger = 'button, a[href], summary, [role="button"], [role="menuitem"], [role="tab"], [aria-haspopup], [aria-expanded], [aria-controls]';
5
+ /** The page's own recent clicks on something that could open a dialog, newest last. */
6
+ const recent = [];
7
+ const kept = 8;
8
+ let opening = false;
9
+ /** Notes a click the page received, so the dialog it opened can name it later. */
10
+ export function rememberClick(target) {
11
+ if (!(target instanceof Element))
12
+ return;
13
+ const element = target.closest(trigger);
14
+ if (!(element instanceof HTMLElement))
15
+ return;
16
+ const at = recent.indexOf(element);
17
+ if (at !== -1)
18
+ recent.splice(at, 1);
19
+ recent.push(element);
20
+ if (recent.length > kept)
21
+ recent.shift();
22
+ }
23
+ /** True while the overlay is clicking an opener itself: that click is the page's, not a dismissal. */
24
+ export function openingDialog() {
25
+ return opening;
26
+ }
27
+ /**
28
+ * What opened the dialog `element` sits in, described so it can be found again after a reload.
29
+ *
30
+ * The trigger that names the dialog (`aria-controls`, as Radix and most libraries set it) when
31
+ * there is one; otherwise the last thing clicked outside the dialog, which is what opened it in
32
+ * every case the overlay can see. Null outside a dialog, or when neither is on the page.
33
+ */
34
+ export function openerFor(element) {
35
+ const dialog = element.closest(opensOverAnyPage);
36
+ if (!dialog)
37
+ return null;
38
+ const outside = (candidate) => candidate instanceof HTMLElement && candidate.isConnected && !dialog.contains(candidate) && !candidate.closest(opensOverAnyPage);
39
+ let found = null;
40
+ if (dialog.id) {
41
+ const named = document.querySelector(`[aria-controls~="${CSS.escape(dialog.id)}"]`);
42
+ if (outside(named))
43
+ found = named;
44
+ }
45
+ for (let index = recent.length - 1; !found && index >= 0; index--) {
46
+ if (outside(recent[index]))
47
+ found = recent[index];
48
+ }
49
+ if (!found)
50
+ return null;
51
+ return { ...(anchorForElement(found) ?? plainAnchorFor(found)), element: describeElement(found) };
52
+ }
53
+ const shown = (element) => {
54
+ const rect = element?.getBoundingClientRect();
55
+ return Boolean(rect && (rect.width > 0 || rect.height > 0));
56
+ };
57
+ /**
58
+ * Opens the dialog a comment was left in, when its element is not on screen and its opener is.
59
+ *
60
+ * Resolves once the element shows, or after `waitMs` if it never does (the opener did something
61
+ * else, or the dialog loads slowly): the thread opens either way, in the corner if need be.
62
+ * An opener that says it is already expanded is not clicked, since a second click would close it.
63
+ */
64
+ export async function openDialogFor(comment, locate, waitMs = 2000) {
65
+ if (!comment.opener || shown(locate(comment)))
66
+ return;
67
+ const opener = locateAnchor(comment.opener);
68
+ if (!opener || !shown(opener) || opener.getAttribute('aria-expanded') === 'true')
69
+ return;
70
+ opening = true;
71
+ try {
72
+ opener.click();
73
+ }
74
+ finally {
75
+ opening = false;
76
+ }
77
+ const until = Date.now() + waitMs;
78
+ while (Date.now() < until && !shown(locate(comment))) {
79
+ await new Promise((resolve) => setTimeout(resolve, 50));
80
+ }
81
+ }
82
+ //# sourceMappingURL=dialogOpener.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dialogOpener.js","sourceRoot":"","sources":["../../src/overlay/dialogOpener.ts"],"names":[],"mappings":"AAUA,OAAO,EAAE,gBAAgB,EAAE,YAAY,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAChG,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAE1D,wFAAwF;AACxF,MAAM,OAAO,GAAG,+HAA+H,CAAC;AAEhJ,uFAAuF;AACvF,MAAM,MAAM,GAAkB,EAAE,CAAC;AACjC,MAAM,IAAI,GAAG,CAAC,CAAC;AAEf,IAAI,OAAO,GAAG,KAAK,CAAC;AAEpB,kFAAkF;AAClF,MAAM,UAAU,aAAa,CAAC,MAA0B;IACtD,IAAI,CAAC,CAAC,MAAM,YAAY,OAAO,CAAC;QAAE,OAAO;IACzC,MAAM,OAAO,GAAG,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;IACxC,IAAI,CAAC,CAAC,OAAO,YAAY,WAAW,CAAC;QAAE,OAAO;IAC9C,MAAM,EAAE,GAAG,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;IACnC,IAAI,EAAE,KAAK,CAAC,CAAC;QAAE,MAAM,CAAC,MAAM,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC;IACpC,MAAM,CAAC,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
36
  }
37
37
  export const notLocalMessage = '[Ontrackd feedback] The review widget is not shown: it has no shared configuration, '
38
38
  + 'and local mode only runs on a local machine (localhost or a private network address). '
39
- + 'On a deployed preview, build with shared mode and FEEDBACK_SECRET.';
39
+ + 'On a deployed preview, build with shared mode and ONTRACKD_SECRET.';
40
40
  //# sourceMappingURL=localMachine.js.map
@@ -3,6 +3,7 @@ import { joinReviewer, forgetReviewer, hasMagicLink } from './magicLink.js';
3
3
  import { configureDirectApi } from './api.js';
4
4
  import { anchorCandidatesFor, filesInsideSelection, instancesOf, locateAnchor, scopeFor, siblingInstances, belongsOnThisPage, } from './anchors.js';
5
5
  import { describeElement, summarizeDescription } from './elementDescription.js';
6
+ import { openDialogFor, openerFor, openingDialog, rememberClick } from './dialogOpener.js';
6
7
  import { anchorsToTranslate, locateComment, rememberTranslations, setCurrentBuild, stopAsking } from './movedAnchors.js';
7
8
  import { leaveReviewMode } from './reviewMode.js';
8
9
  import { api, attachmentsAvailable, recordingSupported, remoteFeedbackStatus, renderable } from './api.js';
@@ -243,6 +244,9 @@ class FeedbackOverlay {
243
244
  constructor() {
244
245
  this.host.id = rootId;
245
246
  this.host.setAttribute('data-feedback-overlay', '');
247
+ // React Aria listens for outside presses in the capture phase, where nothing of ours can stop it;
248
+ // this marker is the opt-out it documents for floating UI that does not belong to a dialog.
249
+ this.host.setAttribute('data-react-aria-top-layer', 'true');
246
250
  this.root = this.host.attachShadow({ mode: 'open' });
247
251
  }
248
252
  async mount() {
@@ -313,6 +317,22 @@ class FeedbackOverlay {
313
317
  for (const type of ['keydown', 'keypress', 'keyup']) {
314
318
  this.root.addEventListener(type, (event) => event.stopPropagation());
315
319
  }
320
+ // The same for the start of a press and for focus. A modal dialog of the page (Radix, Headless UI)
321
+ // listens on the document for a pointerdown or focus landing "outside" it, and past our shadow
322
+ // root the target reads as our host, which is outside: the toolbar closed the dialog. Only the
323
+ // bubble phase is stopped, so our own capture handlers below and every listener inside the
324
+ // overlay (the sheet's swipe, the picker) run first and are unaffected.
325
+ for (const type of ['pointerdown', 'mousedown', 'touchstart', 'focusin', 'focusout']) {
326
+ this.root.addEventListener(type, (event) => event.stopPropagation());
327
+ }
328
+ // The other half of focus: a dialog's own element loses focus to us, and its focus trap (Radix
329
+ // FocusScope) reads relatedTarget - our host - as "left the dialog" and pulls focus back, so no
330
+ // comment could be typed. A null relatedTarget is what a click on the browser chrome looks like,
331
+ // and every trap lets that one go. The event still reaches the page's own blur handlers.
332
+ document.addEventListener('focusout', (event) => {
333
+ if (event.relatedTarget === this.host)
334
+ Object.defineProperty(event, 'relatedTarget', { value: null });
335
+ }, true);
316
336
  document.addEventListener('pointermove', (event) => this.handlePointerMove(event), true);
317
337
  document.addEventListener('click', (event) => this.handleHostClick(event), true);
318
338
  // The rest of a tap, which the click handler alone would let through to the page's own handlers.
@@ -510,10 +530,13 @@ class FeedbackOverlay {
510
530
  this.state.setMode('visible');
511
531
  if (!this.state.chipsVisible)
512
532
  this.state.setChipsVisible(true);
513
- this.openThread(id);
514
- this.stickyId = id;
515
- this.render();
516
- this.scrollToComment(id);
533
+ const comment = this.state.comments.find((entry) => entry.id === id);
534
+ void openDialogFor(comment, locateComment).then(() => {
535
+ this.openThread(id);
536
+ this.stickyId = id;
537
+ this.render();
538
+ this.scrollToComment(id);
539
+ });
517
540
  }
518
541
  /**
519
542
  * Who the reviewer is, in shared mode.
@@ -926,11 +949,14 @@ class FeedbackOverlay {
926
949
  this.renderHighlight();
927
950
  }
928
951
  handleHostClick(event) {
929
- if (this.isOverlayEvent(event)) {
952
+ // The overlay's own click on a dialog's opener (openDialogFor) belongs to the page.
953
+ if (this.isOverlayEvent(event) || openingDialog()) {
930
954
  return;
931
955
  }
932
956
  // SPEC 7.1: outside Comment mode the host app behaves as if the tool were absent.
933
957
  if (this.state.mode !== 'commenting') {
958
+ // What opens a dialog, so a comment left in it can open it again.
959
+ rememberClick(event.target);
934
960
  // On a phone a tap that gets past the sheet's backdrop keeps a typed reply, as the backdrop does.
935
961
  if (this.compact && this.state.openThreadId && !this.threadDismissable())
936
962
  return;
@@ -998,7 +1024,7 @@ class FeedbackOverlay {
998
1024
  this.lastPointerType = event.pointerType;
999
1025
  this.tapSelected = false;
1000
1026
  }
1001
- if (this.state.mode !== 'commenting' || this.isOverlayEvent(event))
1027
+ if (this.state.mode !== 'commenting' || this.isOverlayEvent(event) || openingDialog())
1002
1028
  return;
1003
1029
  // A compat mouse event carries no pointer type: it is the pointerdown's.
1004
1030
  const pointer = event instanceof PointerEvent ? event.pointerType : this.lastPointerType;
@@ -2493,6 +2519,8 @@ class FeedbackOverlay {
2493
2519
  ...(instances > 1 ? { choice: draft.scopeChoice } : {}),
2494
2520
  },
2495
2521
  pinOffset: draft.offset,
2522
+ // Inside a dialog or drawer: what opened it, so the comment can open it again from the list.
2523
+ opener: openerFor(chosen.element),
2496
2524
  context: {
2497
2525
  route: window.location.pathname,
2498
2526
  viewport: { w: window.innerWidth, h: window.innerHeight },
@@ -2612,6 +2640,9 @@ class FeedbackOverlay {
2612
2640
  this.openThread(id, from);
2613
2641
  return;
2614
2642
  }
2643
+ // Left in a dialog that is closed now: open it first, so the comment shows where it was made.
2644
+ this.render();
2645
+ await openDialogFor(comment, locateComment);
2615
2646
  this.openThread(id);
2616
2647
  this.scrollToComment(id);
2617
2648
  }