teamshare-bridge 0.26.24 → 0.26.25

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 (75) hide show
  1. package/README.md +383 -383
  2. package/dist/bridge/install-verify.js +8 -8
  3. package/dist/bridge/wake-handler.js +5 -4
  4. package/dist/bridge/wake-handler.js.map +1 -1
  5. package/dist/lib/agent-scope.js +10 -10
  6. package/dist/lib/browser/browse-llm.js +44 -44
  7. package/dist/lib/browser/human-input-guard.js +106 -106
  8. package/dist/lib/browser/login.js +141 -141
  9. package/dist/lib/browser/otp.js +72 -72
  10. package/dist/lib/browser/page-context.js +592 -592
  11. package/dist/lib/browser/page-events.js +91 -91
  12. package/dist/lib/browser/refs.js +264 -264
  13. package/dist/lib/browser/screen-change.js +79 -79
  14. package/dist/lib/harness/harness-adapter.js +8 -0
  15. package/dist/lib/harness/harness-adapter.js.map +1 -1
  16. package/dist/lib/human-style.js +32 -32
  17. package/dist/lib/scope-guard.js +15 -5
  18. package/dist/lib/scope-guard.js.map +1 -1
  19. package/package.json +1 -1
  20. package/skills/THIRD_PARTY_NOTICES.md +26 -26
  21. package/skills/architect/LICENSE +21 -21
  22. package/skills/codebase-design/LICENSE +21 -21
  23. package/skills/diagnosing-bugs/LICENSE +21 -21
  24. package/skills/domain-modeling/LICENSE +21 -21
  25. package/skills/improve-codebase-architecture/LICENSE +21 -21
  26. package/skills/recover/LICENSE +21 -21
  27. package/skills/review/LICENSE +21 -21
  28. package/skills/tdd/LICENSE +21 -21
  29. package/skills/teamshare-auth-rbac/SKILL.md +78 -78
  30. package/skills/teamshare-cdd/SKILL.md +215 -215
  31. package/skills/teamshare-modularity/SKILL.md +146 -146
  32. package/skills/teamshare-orchestrator-ask/SKILL.md +77 -77
  33. package/skills/teamshare-scaffold/SKILL.md +116 -116
  34. package/templates/backend/.env.example.tpl +13 -13
  35. package/templates/backend/nest-cli.json.tpl +8 -8
  36. package/templates/backend/package.json.tpl +41 -41
  37. package/templates/backend/prisma/schema.prisma.tpl +39 -39
  38. package/templates/backend/src/app.module.ts.tpl +24 -24
  39. package/templates/backend/src/common/filters/all-exceptions.filter.ts.tpl +59 -59
  40. package/templates/backend/src/common/guards/jwt-auth.guard.ts.tpl +27 -27
  41. package/templates/backend/src/common/guards/rbac.guard.ts.tpl +48 -48
  42. package/templates/backend/src/common/interceptors/transform.interceptor.ts.tpl +44 -44
  43. package/templates/backend/src/common/pipes/zod-validation.pipe.ts.tpl +29 -29
  44. package/templates/backend/src/common/swagger/envelope.schemas.ts.tpl +53 -53
  45. package/templates/backend/src/common/swagger/error.schemas.ts.tpl +62 -62
  46. package/templates/backend/src/main.ts.tpl +27 -27
  47. package/templates/backend/src/modules/example/example.controller.ts.tpl +102 -102
  48. package/templates/backend/src/modules/example/example.dto.ts.tpl +14 -14
  49. package/templates/backend/src/modules/example/example.module.ts.tpl +10 -10
  50. package/templates/backend/src/modules/example/example.service.ts.tpl +45 -45
  51. package/templates/backend/tsconfig.json.tpl +26 -26
  52. package/templates/common/.gitignore.tpl +42 -42
  53. package/templates/common/AGENTS.md.tpl +58 -58
  54. package/templates/common/docs/adr/README.md +25 -25
  55. package/templates/common/docs/api-contract.md.tpl +72 -72
  56. package/templates/web/next.config.ts.tpl +7 -7
  57. package/templates/web/package.json.tpl +37 -37
  58. package/templates/web/src/app/globals.css.tpl +48 -48
  59. package/templates/web/src/app/layout.tsx.tpl +25 -25
  60. package/templates/web/src/components/shared/app-button.tsx.tpl +59 -59
  61. package/templates/web/src/components/shared/app-empty-state.tsx.tpl +39 -39
  62. package/templates/web/src/components/shared/app-list-toolbar.tsx.tpl +63 -63
  63. package/templates/web/src/components/shared/app-skeleton.tsx.tpl +14 -14
  64. package/templates/web/src/components/shared/app-table.tsx.tpl +128 -128
  65. package/templates/web/src/components/shared/index.ts.tpl +5 -5
  66. package/templates/web/src/hooks/use-list-state.ts.tpl +72 -72
  67. package/templates/web/src/hooks/use-url-tab.ts.tpl +25 -25
  68. package/templates/web/src/lib/api/client.ts.tpl +123 -123
  69. package/templates/web/src/lib/providers.tsx.tpl +35 -35
  70. package/templates/web/src/lib/query-keys.ts.tpl +21 -21
  71. package/templates/web/src/lib/utils.ts.tpl +7 -7
  72. package/templates/web/src/lib/validation/schemas.ts.tpl +15 -15
  73. package/templates/web/src/modules/example/views/example-list-view.tsx.tpl +97 -97
  74. package/templates/web/tsconfig.json.tpl +23 -23
  75. package/tools/workspace-arbitration-check.mjs +359 -359
@@ -75,122 +75,122 @@ const REF_SELECTOR = [
75
75
  * `window.__tsRefs.nodes` for later `isConnected` checks / focus calls.
76
76
  */
77
77
  function buildRefScanScript() {
78
- return `
79
- (() => {
80
- const MAX = ${exports.MAX_REFS};
81
- const SEL = ${JSON.stringify(REF_SELECTOR)};
82
- const PORTAL_SEL = '[data-radix-popper-content-wrapper],[data-radix-portal],[data-floating-ui-portal]';
83
- const DIALOG_SEL = 'dialog[open],[role="dialog"],[aria-modal="true"]';
84
- const vis = (el) => {
85
- if (!el || el.nodeType !== 1) return false;
86
- const r = el.getBoundingClientRect();
87
- if (r.width === 0 || r.height === 0) return false;
88
- const cs = getComputedStyle(el);
89
- if (cs.visibility === 'hidden' || cs.display === 'none' || cs.opacity === '0') return false;
90
- if (cs.pointerEvents === 'none') return false;
91
- return true;
92
- };
93
- const clean = (v, cap) => String(v == null ? '' : v)
94
- .replace(/\\s+/g, ' ')
95
- .trim()
96
- .slice(0, cap || 80);
97
- const nameOf = (el) => {
98
- const aria = el.getAttribute('aria-label');
99
- if (aria) return clean(aria, 80);
100
- const by = el.getAttribute('aria-labelledby');
101
- if (by) {
102
- const t = by.split(/\\s+/).map((id) => {
103
- const n = document.getElementById(id);
104
- return n ? (n.innerText || n.textContent || '') : '';
105
- }).join(' ');
106
- if (t.trim()) return clean(t, 80);
107
- }
108
- const tag = String(el.tagName || '').toLowerCase();
109
- if (tag === 'input' || tag === 'textarea' || tag === 'select') {
110
- const id = el.id;
111
- if (id) {
112
- try {
113
- const l = document.querySelector('label[for="' + CSS.escape(id) + '"]');
114
- if (l) return clean(l.innerText || l.textContent, 80);
115
- } catch (e) {}
116
- }
117
- const wrap = el.closest && el.closest('label');
118
- if (wrap) return clean(wrap.innerText || wrap.textContent, 80);
119
- const ph = el.getAttribute('placeholder');
120
- if (ph) return clean(ph, 80);
121
- const nm = el.getAttribute('name');
122
- if (nm) return clean(nm, 80);
123
- if (el.id) return clean(el.id, 80);
124
- }
125
- const txt = el.innerText || el.textContent || '';
126
- if (txt.trim()) return clean(txt, 80);
127
- return clean(
128
- el.getAttribute('title') ||
129
- el.getAttribute('alt') ||
130
- el.getAttribute('value') ||
131
- '',
132
- 80,
133
- );
134
- };
135
- const roleOf = (el) => {
136
- const explicit = el.getAttribute('role');
137
- if (explicit) return clean(explicit, 24);
138
- const tag = String(el.tagName || '').toLowerCase();
139
- const type = String(el.type || '').toLowerCase();
140
- if (tag === 'a') return 'link';
141
- if (tag === 'button' || tag === 'summary') return 'button';
142
- if (tag === 'select') return 'combobox';
143
- if (tag === 'textarea') return 'textbox';
144
- if (tag === 'input') {
145
- if (type === 'submit' || type === 'button' || type === 'reset') return 'button';
146
- if (type === 'checkbox') return 'checkbox';
147
- if (type === 'radio') return 'radio';
148
- if (type === 'search') return 'searchbox';
149
- return 'textbox';
150
- }
151
- if (el.isContentEditable === true) return 'textbox';
152
- return tag || 'element';
153
- };
154
- const seen = new Set();
155
- const nodes = {};
156
- const list = [];
157
- const all = [...document.querySelectorAll(SEL)];
158
- for (const el of all) {
159
- if (list.length >= MAX) break;
160
- if (seen.has(el)) continue;
161
- seen.add(el);
162
- // Skip an element wholly covered by another candidate we already took
163
- // only when it IS that element - nested buttons are real (icon spans
164
- // are not in the selector, so this is only a dedupe guard).
165
- if (!vis(el)) continue;
166
- const r = el.getBoundingClientRect();
167
- const ref = 'e' + (list.length + 1);
168
- const row = {
169
- ref,
170
- tag: clean(String(el.tagName || '').toLowerCase(), 20) || 'element',
171
- role: roleOf(el),
172
- name: nameOf(el),
173
- disabled:
174
- el.disabled === true || el.getAttribute('aria-disabled') === 'true',
175
- inDialog: !!(el.closest && el.closest(DIALOG_SEL)),
176
- inPortal: !!(el.closest && el.closest(PORTAL_SEL)),
177
- x: Math.round(r.x + r.width / 2),
178
- y: Math.round(r.y + r.height / 2),
179
- width: Math.round(r.width),
180
- height: Math.round(r.height),
181
- };
182
- if (
183
- (row.tag === 'input' || row.tag === 'textarea') &&
184
- typeof el.value === 'string'
185
- ) {
186
- row.valueLength = el.value.length;
187
- }
188
- nodes[ref] = el;
189
- list.push(row);
190
- }
191
- window.__tsRefs = { at: Date.now(), list, nodes };
192
- return { at: window.__tsRefs.at, list };
193
- })()
78
+ return `
79
+ (() => {
80
+ const MAX = ${exports.MAX_REFS};
81
+ const SEL = ${JSON.stringify(REF_SELECTOR)};
82
+ const PORTAL_SEL = '[data-radix-popper-content-wrapper],[data-radix-portal],[data-floating-ui-portal]';
83
+ const DIALOG_SEL = 'dialog[open],[role="dialog"],[aria-modal="true"]';
84
+ const vis = (el) => {
85
+ if (!el || el.nodeType !== 1) return false;
86
+ const r = el.getBoundingClientRect();
87
+ if (r.width === 0 || r.height === 0) return false;
88
+ const cs = getComputedStyle(el);
89
+ if (cs.visibility === 'hidden' || cs.display === 'none' || cs.opacity === '0') return false;
90
+ if (cs.pointerEvents === 'none') return false;
91
+ return true;
92
+ };
93
+ const clean = (v, cap) => String(v == null ? '' : v)
94
+ .replace(/\\s+/g, ' ')
95
+ .trim()
96
+ .slice(0, cap || 80);
97
+ const nameOf = (el) => {
98
+ const aria = el.getAttribute('aria-label');
99
+ if (aria) return clean(aria, 80);
100
+ const by = el.getAttribute('aria-labelledby');
101
+ if (by) {
102
+ const t = by.split(/\\s+/).map((id) => {
103
+ const n = document.getElementById(id);
104
+ return n ? (n.innerText || n.textContent || '') : '';
105
+ }).join(' ');
106
+ if (t.trim()) return clean(t, 80);
107
+ }
108
+ const tag = String(el.tagName || '').toLowerCase();
109
+ if (tag === 'input' || tag === 'textarea' || tag === 'select') {
110
+ const id = el.id;
111
+ if (id) {
112
+ try {
113
+ const l = document.querySelector('label[for="' + CSS.escape(id) + '"]');
114
+ if (l) return clean(l.innerText || l.textContent, 80);
115
+ } catch (e) {}
116
+ }
117
+ const wrap = el.closest && el.closest('label');
118
+ if (wrap) return clean(wrap.innerText || wrap.textContent, 80);
119
+ const ph = el.getAttribute('placeholder');
120
+ if (ph) return clean(ph, 80);
121
+ const nm = el.getAttribute('name');
122
+ if (nm) return clean(nm, 80);
123
+ if (el.id) return clean(el.id, 80);
124
+ }
125
+ const txt = el.innerText || el.textContent || '';
126
+ if (txt.trim()) return clean(txt, 80);
127
+ return clean(
128
+ el.getAttribute('title') ||
129
+ el.getAttribute('alt') ||
130
+ el.getAttribute('value') ||
131
+ '',
132
+ 80,
133
+ );
134
+ };
135
+ const roleOf = (el) => {
136
+ const explicit = el.getAttribute('role');
137
+ if (explicit) return clean(explicit, 24);
138
+ const tag = String(el.tagName || '').toLowerCase();
139
+ const type = String(el.type || '').toLowerCase();
140
+ if (tag === 'a') return 'link';
141
+ if (tag === 'button' || tag === 'summary') return 'button';
142
+ if (tag === 'select') return 'combobox';
143
+ if (tag === 'textarea') return 'textbox';
144
+ if (tag === 'input') {
145
+ if (type === 'submit' || type === 'button' || type === 'reset') return 'button';
146
+ if (type === 'checkbox') return 'checkbox';
147
+ if (type === 'radio') return 'radio';
148
+ if (type === 'search') return 'searchbox';
149
+ return 'textbox';
150
+ }
151
+ if (el.isContentEditable === true) return 'textbox';
152
+ return tag || 'element';
153
+ };
154
+ const seen = new Set();
155
+ const nodes = {};
156
+ const list = [];
157
+ const all = [...document.querySelectorAll(SEL)];
158
+ for (const el of all) {
159
+ if (list.length >= MAX) break;
160
+ if (seen.has(el)) continue;
161
+ seen.add(el);
162
+ // Skip an element wholly covered by another candidate we already took
163
+ // only when it IS that element - nested buttons are real (icon spans
164
+ // are not in the selector, so this is only a dedupe guard).
165
+ if (!vis(el)) continue;
166
+ const r = el.getBoundingClientRect();
167
+ const ref = 'e' + (list.length + 1);
168
+ const row = {
169
+ ref,
170
+ tag: clean(String(el.tagName || '').toLowerCase(), 20) || 'element',
171
+ role: roleOf(el),
172
+ name: nameOf(el),
173
+ disabled:
174
+ el.disabled === true || el.getAttribute('aria-disabled') === 'true',
175
+ inDialog: !!(el.closest && el.closest(DIALOG_SEL)),
176
+ inPortal: !!(el.closest && el.closest(PORTAL_SEL)),
177
+ x: Math.round(r.x + r.width / 2),
178
+ y: Math.round(r.y + r.height / 2),
179
+ width: Math.round(r.width),
180
+ height: Math.round(r.height),
181
+ };
182
+ if (
183
+ (row.tag === 'input' || row.tag === 'textarea') &&
184
+ typeof el.value === 'string'
185
+ ) {
186
+ row.valueLength = el.value.length;
187
+ }
188
+ nodes[ref] = el;
189
+ list.push(row);
190
+ }
191
+ window.__tsRefs = { at: Date.now(), list, nodes };
192
+ return { at: window.__tsRefs.at, list };
193
+ })()
194
194
  `;
195
195
  }
196
196
  /**
@@ -228,22 +228,22 @@ async function scanRefs(page) {
228
228
  /** Liveness + geometry of one ref, from the node the scan stored. */
229
229
  function buildRefInfoScript(ref) {
230
230
  const id = JSON.stringify(ref);
231
- return `(() => {
232
- const s = window.__tsRefs;
233
- const el = s && s.nodes ? s.nodes[${id}] : null;
234
- if (!el || el.isConnected !== true) return { ref: ${id}, alive: false };
235
- const r = el.getBoundingClientRect();
236
- return {
237
- ref: ${id},
238
- alive: true,
239
- x: Math.round(r.x + r.width / 2),
240
- y: Math.round(r.y + r.height / 2),
241
- width: Math.round(r.width),
242
- height: Math.round(r.height),
243
- inViewport:
244
- r.top >= 0 && r.left >= 0 &&
245
- r.bottom <= (window.innerHeight || 0) && r.right <= (window.innerWidth || 0),
246
- };
231
+ return `(() => {
232
+ const s = window.__tsRefs;
233
+ const el = s && s.nodes ? s.nodes[${id}] : null;
234
+ if (!el || el.isConnected !== true) return { ref: ${id}, alive: false };
235
+ const r = el.getBoundingClientRect();
236
+ return {
237
+ ref: ${id},
238
+ alive: true,
239
+ x: Math.round(r.x + r.width / 2),
240
+ y: Math.round(r.y + r.height / 2),
241
+ width: Math.round(r.width),
242
+ height: Math.round(r.height),
243
+ inViewport:
244
+ r.top >= 0 && r.left >= 0 &&
245
+ r.bottom <= (window.innerHeight || 0) && r.right <= (window.innerWidth || 0),
246
+ };
247
247
  })()`;
248
248
  }
249
249
  /**
@@ -253,22 +253,22 @@ function buildRefInfoScript(ref) {
253
253
  */
254
254
  function buildRefFocusScript(ref) {
255
255
  const id = JSON.stringify(ref);
256
- return `(() => {
257
- const s = window.__tsRefs;
258
- const el = s && s.nodes ? s.nodes[${id}] : null;
259
- if (!el || el.isConnected !== true) return { ref: ${id}, ok: false, alive: false };
260
- try { el.scrollIntoView({ block: 'center', inline: 'center' }); } catch (e) {}
261
- try { el.focus({ preventScroll: true }); } catch (e) {}
262
- const a = document.activeElement;
263
- return {
264
- ref: ${id},
265
- ok: a === el,
266
- alive: true,
267
- focused: a === el,
268
- tag: String((el.tagName || '')).toLowerCase(),
269
- contentEditable: el.isContentEditable === true,
270
- valueLength: typeof el.value === 'string' ? el.value.length : undefined,
271
- };
256
+ return `(() => {
257
+ const s = window.__tsRefs;
258
+ const el = s && s.nodes ? s.nodes[${id}] : null;
259
+ if (!el || el.isConnected !== true) return { ref: ${id}, ok: false, alive: false };
260
+ try { el.scrollIntoView({ block: 'center', inline: 'center' }); } catch (e) {}
261
+ try { el.focus({ preventScroll: true }); } catch (e) {}
262
+ const a = document.activeElement;
263
+ return {
264
+ ref: ${id},
265
+ ok: a === el,
266
+ alive: true,
267
+ focused: a === el,
268
+ tag: String((el.tagName || '')).toLowerCase(),
269
+ contentEditable: el.isContentEditable === true,
270
+ valueLength: typeof el.value === 'string' ? el.value.length : undefined,
271
+ };
272
272
  })()`;
273
273
  }
274
274
  /**
@@ -281,46 +281,46 @@ function buildRefFocusScript(ref) {
281
281
  */
282
282
  function buildRefPointerScript(ref) {
283
283
  const id = JSON.stringify(ref);
284
- return `(() => {
285
- const s = window.__tsRefs;
286
- const el = s && s.nodes ? s.nodes[${id}] : null;
287
- if (!el || el.isConnected !== true) return { ref: ${id}, ok: false, alive: false };
288
- try { el.scrollIntoView({ block: 'center', inline: 'center' }); } catch (e) {}
289
- const rect = el.getBoundingClientRect();
290
- const x = Math.round(rect.x + rect.width / 2);
291
- const y = Math.round(rect.y + rect.height / 2);
292
- const base = {
293
- bubbles: true,
294
- cancelable: true,
295
- composed: true,
296
- clientX: x,
297
- clientY: y,
298
- view: window,
299
- button: 0,
300
- buttons: 1,
301
- };
302
- const pointer = (type) => {
303
- try {
304
- return new PointerEvent(type, Object.assign({}, base, {
305
- pointerId: 1,
306
- pointerType: 'mouse',
307
- isPrimary: true,
308
- }));
309
- } catch (e) {
310
- return new MouseEvent(type, base);
311
- }
312
- };
313
- const mouse = (type) => new MouseEvent(type, base);
314
- el.dispatchEvent(pointer('pointerover'));
315
- el.dispatchEvent(pointer('pointerenter'));
316
- el.dispatchEvent(pointer('pointermove'));
317
- el.dispatchEvent(pointer('pointerdown'));
318
- el.dispatchEvent(mouse('mousedown'));
319
- try { el.focus({ preventScroll: true }); } catch (e) {}
320
- el.dispatchEvent(pointer('pointerup'));
321
- el.dispatchEvent(mouse('mouseup'));
322
- el.dispatchEvent(mouse('click'));
323
- return { ref: ${id}, ok: true, alive: true, clicked: true, x, y };
284
+ return `(() => {
285
+ const s = window.__tsRefs;
286
+ const el = s && s.nodes ? s.nodes[${id}] : null;
287
+ if (!el || el.isConnected !== true) return { ref: ${id}, ok: false, alive: false };
288
+ try { el.scrollIntoView({ block: 'center', inline: 'center' }); } catch (e) {}
289
+ const rect = el.getBoundingClientRect();
290
+ const x = Math.round(rect.x + rect.width / 2);
291
+ const y = Math.round(rect.y + rect.height / 2);
292
+ const base = {
293
+ bubbles: true,
294
+ cancelable: true,
295
+ composed: true,
296
+ clientX: x,
297
+ clientY: y,
298
+ view: window,
299
+ button: 0,
300
+ buttons: 1,
301
+ };
302
+ const pointer = (type) => {
303
+ try {
304
+ return new PointerEvent(type, Object.assign({}, base, {
305
+ pointerId: 1,
306
+ pointerType: 'mouse',
307
+ isPrimary: true,
308
+ }));
309
+ } catch (e) {
310
+ return new MouseEvent(type, base);
311
+ }
312
+ };
313
+ const mouse = (type) => new MouseEvent(type, base);
314
+ el.dispatchEvent(pointer('pointerover'));
315
+ el.dispatchEvent(pointer('pointerenter'));
316
+ el.dispatchEvent(pointer('pointermove'));
317
+ el.dispatchEvent(pointer('pointerdown'));
318
+ el.dispatchEvent(mouse('mousedown'));
319
+ try { el.focus({ preventScroll: true }); } catch (e) {}
320
+ el.dispatchEvent(pointer('pointerup'));
321
+ el.dispatchEvent(mouse('mouseup'));
322
+ el.dispatchEvent(mouse('click'));
323
+ return { ref: ${id}, ok: true, alive: true, clicked: true, x, y };
324
324
  })()`;
325
325
  }
326
326
  /**
@@ -332,60 +332,60 @@ function buildRefPointerScript(ref) {
332
332
  * immediately after the capture - the page is never left modified.
333
333
  */
334
334
  function buildAnnotateScript() {
335
- return `(() => {
336
- const s = window.__tsRefs;
337
- if (!s || !s.list) return 0;
338
- const ID = 'ts-ref-overlay';
339
- const old = document.getElementById(ID);
340
- if (old) old.remove();
341
- const root = document.createElement('div');
342
- root.id = ID;
343
- root.style.cssText = 'position:fixed;left:0;top:0;width:0;height:0;z-index:2147483647;pointer-events:none;';
344
- let n = 0;
345
- for (const item of s.list) {
346
- const el = s.nodes ? s.nodes[item.ref] : null;
347
- if (!el || el.isConnected !== true) continue;
348
- const r = el.getBoundingClientRect();
349
- if (r.width === 0 || r.height === 0) continue;
350
- const box = document.createElement('div');
351
- box.style.cssText =
352
- 'position:fixed;border:2px solid #e11d48;border-radius:3px;box-sizing:border-box;pointer-events:none;left:' +
353
- Math.round(r.left) + 'px;top:' + Math.round(r.top) + 'px;width:' + Math.round(r.width) +
354
- 'px;height:' + Math.round(r.height) + 'px;';
355
- const tag = document.createElement('div');
356
- tag.textContent = item.ref;
357
- tag.style.cssText =
358
- 'position:fixed;background:#e11d48;color:#ffffff;font:600 11px/1.2 sans-serif;padding:1px 3px;border-radius:2px;pointer-events:none;left:' +
359
- Math.round(r.left) + 'px;top:' + Math.max(0, Math.round(r.top) - 14) + 'px;';
360
- root.appendChild(box);
361
- root.appendChild(tag);
362
- if (++n >= 120) break;
363
- }
364
- document.documentElement.appendChild(root);
365
- return n;
335
+ return `(() => {
336
+ const s = window.__tsRefs;
337
+ if (!s || !s.list) return 0;
338
+ const ID = 'ts-ref-overlay';
339
+ const old = document.getElementById(ID);
340
+ if (old) old.remove();
341
+ const root = document.createElement('div');
342
+ root.id = ID;
343
+ root.style.cssText = 'position:fixed;left:0;top:0;width:0;height:0;z-index:2147483647;pointer-events:none;';
344
+ let n = 0;
345
+ for (const item of s.list) {
346
+ const el = s.nodes ? s.nodes[item.ref] : null;
347
+ if (!el || el.isConnected !== true) continue;
348
+ const r = el.getBoundingClientRect();
349
+ if (r.width === 0 || r.height === 0) continue;
350
+ const box = document.createElement('div');
351
+ box.style.cssText =
352
+ 'position:fixed;border:2px solid #e11d48;border-radius:3px;box-sizing:border-box;pointer-events:none;left:' +
353
+ Math.round(r.left) + 'px;top:' + Math.round(r.top) + 'px;width:' + Math.round(r.width) +
354
+ 'px;height:' + Math.round(r.height) + 'px;';
355
+ const tag = document.createElement('div');
356
+ tag.textContent = item.ref;
357
+ tag.style.cssText =
358
+ 'position:fixed;background:#e11d48;color:#ffffff;font:600 11px/1.2 sans-serif;padding:1px 3px;border-radius:2px;pointer-events:none;left:' +
359
+ Math.round(r.left) + 'px;top:' + Math.max(0, Math.round(r.top) - 14) + 'px;';
360
+ root.appendChild(box);
361
+ root.appendChild(tag);
362
+ if (++n >= 120) break;
363
+ }
364
+ document.documentElement.appendChild(root);
365
+ return n;
366
366
  })()`;
367
367
  }
368
368
  /** Remove the ref overlay (always called, even when the capture failed). */
369
369
  function buildClearAnnotationScript() {
370
- return `(() => {
371
- const el = document.getElementById('ts-ref-overlay');
372
- if (el) el.remove();
373
- return true;
370
+ return `(() => {
371
+ const el = document.getElementById('ts-ref-overlay');
372
+ if (el) el.remove();
373
+ return true;
374
374
  })()`;
375
375
  }
376
376
  /** How many popovers/menus are currently open (used by closePopup). */
377
377
  function buildPopoverCountScript() {
378
- return `(() => {
379
- const vis = (el) => {
380
- if (!el || el.nodeType !== 1) return false;
381
- const r = el.getBoundingClientRect();
382
- if (r.width === 0 || r.height === 0) return false;
383
- const cs = getComputedStyle(el);
384
- return cs.visibility !== 'hidden' && cs.display !== 'none' && cs.opacity !== '0';
385
- };
386
- const n = [...document.querySelectorAll('[data-radix-popper-content-wrapper],[role="menu"],[role="listbox"]')]
387
- .filter(vis).length;
388
- return n;
378
+ return `(() => {
379
+ const vis = (el) => {
380
+ if (!el || el.nodeType !== 1) return false;
381
+ const r = el.getBoundingClientRect();
382
+ if (r.width === 0 || r.height === 0) return false;
383
+ const cs = getComputedStyle(el);
384
+ return cs.visibility !== 'hidden' && cs.display !== 'none' && cs.opacity !== '0';
385
+ };
386
+ const n = [...document.querySelectorAll('[data-radix-popper-content-wrapper],[role="menu"],[role="listbox"]')]
387
+ .filter(vis).length;
388
+ return n;
389
389
  })()`;
390
390
  }
391
391
  /**
@@ -395,36 +395,36 @@ function buildPopoverCountScript() {
395
395
  * at the layer's own outside point instead.
396
396
  */
397
397
  function buildOutsidePointerScript() {
398
- return `(() => {
399
- const target = document.body;
400
- if (!target) return false;
401
- const base = {
402
- bubbles: true,
403
- cancelable: true,
404
- composed: true,
405
- clientX: 4,
406
- clientY: 4,
407
- view: window,
408
- button: 0,
409
- buttons: 1,
410
- };
411
- const pointer = (type) => {
412
- try {
413
- return new PointerEvent(type, Object.assign({}, base, {
414
- pointerId: 1,
415
- pointerType: 'mouse',
416
- isPrimary: true,
417
- }));
418
- } catch (e) {
419
- return new MouseEvent(type, base);
420
- }
421
- };
422
- target.dispatchEvent(pointer('pointerdown'));
423
- target.dispatchEvent(new MouseEvent('mousedown', base));
424
- target.dispatchEvent(pointer('pointerup'));
425
- target.dispatchEvent(new MouseEvent('mouseup', base));
426
- target.dispatchEvent(new MouseEvent('click', base));
427
- return true;
398
+ return `(() => {
399
+ const target = document.body;
400
+ if (!target) return false;
401
+ const base = {
402
+ bubbles: true,
403
+ cancelable: true,
404
+ composed: true,
405
+ clientX: 4,
406
+ clientY: 4,
407
+ view: window,
408
+ button: 0,
409
+ buttons: 1,
410
+ };
411
+ const pointer = (type) => {
412
+ try {
413
+ return new PointerEvent(type, Object.assign({}, base, {
414
+ pointerId: 1,
415
+ pointerType: 'mouse',
416
+ isPrimary: true,
417
+ }));
418
+ } catch (e) {
419
+ return new MouseEvent(type, base);
420
+ }
421
+ };
422
+ target.dispatchEvent(pointer('pointerdown'));
423
+ target.dispatchEvent(new MouseEvent('mousedown', base));
424
+ target.dispatchEvent(pointer('pointerup'));
425
+ target.dispatchEvent(new MouseEvent('mouseup', base));
426
+ target.dispatchEvent(new MouseEvent('click', base));
427
+ return true;
428
428
  })()`;
429
429
  }
430
430
  //# sourceMappingURL=refs.js.map