annotask 0.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (60) hide show
  1. package/README.md +191 -0
  2. package/dist/chunk-2TUWBFQG.js +882 -0
  3. package/dist/chunk-2TUWBFQG.js.map +1 -0
  4. package/dist/chunk-3VLTLTEO.js +53 -0
  5. package/dist/chunk-3VLTLTEO.js.map +1 -0
  6. package/dist/chunk-53D2PE43.js +105 -0
  7. package/dist/chunk-53D2PE43.js.map +1 -0
  8. package/dist/chunk-6UQW2W7S.js +358 -0
  9. package/dist/chunk-6UQW2W7S.js.map +1 -0
  10. package/dist/chunk-6VYCY34B.js +848 -0
  11. package/dist/chunk-6VYCY34B.js.map +1 -0
  12. package/dist/chunk-B7IKW7UB.js +792 -0
  13. package/dist/chunk-B7IKW7UB.js.map +1 -0
  14. package/dist/chunk-BDMOC2BG.js +794 -0
  15. package/dist/chunk-BDMOC2BG.js.map +1 -0
  16. package/dist/chunk-CFBRU3DQ.js +332 -0
  17. package/dist/chunk-CFBRU3DQ.js.map +1 -0
  18. package/dist/chunk-CWA33RDQ.js +21 -0
  19. package/dist/chunk-CWA33RDQ.js.map +1 -0
  20. package/dist/chunk-DGUM43GV.js +11 -0
  21. package/dist/chunk-DGUM43GV.js.map +1 -0
  22. package/dist/chunk-EAT6V4LF.js +358 -0
  23. package/dist/chunk-EAT6V4LF.js.map +1 -0
  24. package/dist/chunk-FBXNRXMY.js +849 -0
  25. package/dist/chunk-FBXNRXMY.js.map +1 -0
  26. package/dist/chunk-LKRKKLOT.js +61 -0
  27. package/dist/chunk-LKRKKLOT.js.map +1 -0
  28. package/dist/chunk-STOP7QF3.js +61 -0
  29. package/dist/chunk-STOP7QF3.js.map +1 -0
  30. package/dist/chunk-T6TKVAAA.js +332 -0
  31. package/dist/chunk-T6TKVAAA.js.map +1 -0
  32. package/dist/chunk-VCC7UV6G.js +291 -0
  33. package/dist/chunk-VCC7UV6G.js.map +1 -0
  34. package/dist/chunk-XR26XVHT.js +21 -0
  35. package/dist/chunk-XR26XVHT.js.map +1 -0
  36. package/dist/chunk-XZNNRBUW.js +311 -0
  37. package/dist/chunk-XZNNRBUW.js.map +1 -0
  38. package/dist/cli.js +248 -0
  39. package/dist/index.d.ts +9 -0
  40. package/dist/index.js +171 -0
  41. package/dist/index.js.map +1 -0
  42. package/dist/server.d.ts +50 -0
  43. package/dist/server.js +15 -0
  44. package/dist/server.js.map +1 -0
  45. package/dist/shell/assets/index-BD3nZNWX.js +59 -0
  46. package/dist/shell/assets/index-DwbhEo-C.css +1 -0
  47. package/dist/shell/index.html +13 -0
  48. package/dist/standalone.d.ts +10 -0
  49. package/dist/standalone.js +9 -0
  50. package/dist/standalone.js.map +1 -0
  51. package/dist/webpack-loader.d.ts +3 -0
  52. package/dist/webpack-loader.js +59 -0
  53. package/dist/webpack-loader.js.map +1 -0
  54. package/dist/webpack.d.ts +11 -0
  55. package/dist/webpack.js +63 -0
  56. package/dist/webpack.js.map +1 -0
  57. package/package.json +78 -0
  58. package/skills/annotask-apply/SKILL.md +133 -0
  59. package/skills/annotask-init/SKILL.md +230 -0
  60. package/skills/annotask-watch/SKILL.md +45 -0
@@ -0,0 +1,849 @@
1
+ // src/plugin/toggle-button.ts
2
+ function toggleButtonScript(serverUrl) {
3
+ const annotaskUrl = serverUrl ? `${serverUrl}/__annotask/` : "/__annotask/";
4
+ return `
5
+ (function() {
6
+ // Don't inject inside the Annotask shell itself
7
+ if (window.location.pathname.startsWith('/__annotask')) return;
8
+
9
+ const btn = document.createElement('button');
10
+ btn.innerHTML = \`<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="3" width="18" height="18" rx="2"/><path d="M3 9h18"/><path d="M9 21V9"/></svg>\`;
11
+ btn.title = 'Open Annotask';
12
+ btn.setAttribute('aria-label', 'Open Annotask design tool');
13
+
14
+ Object.assign(btn.style, {
15
+ position: 'fixed',
16
+ bottom: '16px',
17
+ right: '16px',
18
+ zIndex: '2147483647',
19
+ width: '40px',
20
+ height: '40px',
21
+ borderRadius: '10px',
22
+ border: 'none',
23
+ background: '#18181b',
24
+ color: '#fafafa',
25
+ cursor: 'pointer',
26
+ display: 'flex',
27
+ alignItems: 'center',
28
+ justifyContent: 'center',
29
+ boxShadow: '0 2px 8px rgba(0,0,0,0.3)',
30
+ transition: 'transform 0.15s, box-shadow 0.15s',
31
+ opacity: '0.8',
32
+ });
33
+
34
+ btn.addEventListener('mouseenter', () => {
35
+ btn.style.transform = 'scale(1.1)';
36
+ btn.style.opacity = '1';
37
+ btn.style.boxShadow = '0 4px 16px rgba(0,0,0,0.4)';
38
+ });
39
+ btn.addEventListener('mouseleave', () => {
40
+ btn.style.transform = 'scale(1)';
41
+ btn.style.opacity = '0.8';
42
+ btn.style.boxShadow = '0 2px 8px rgba(0,0,0,0.3)';
43
+ });
44
+
45
+ btn.addEventListener('click', () => {
46
+ var appOrigin = window.location.origin;
47
+ var url = '${annotaskUrl}' + '?appUrl=' + encodeURIComponent(appOrigin + '/');
48
+ window.open(url, '_blank');
49
+ });
50
+
51
+ document.body.appendChild(btn);
52
+ })();
53
+ `.trim();
54
+ }
55
+
56
+ // src/plugin/bridge-client.ts
57
+ function bridgeClientScript() {
58
+ return `
59
+ (function() {
60
+ // Don't run inside the Annotask shell
61
+ if (window.location.pathname.startsWith('/__annotask')) return;
62
+ // Don't run if already initialized
63
+ if (window.__ANNOTASK_BRIDGE__) return;
64
+ window.__ANNOTASK_BRIDGE__ = true;
65
+
66
+ // \u2500\u2500 Element Registry \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500
67
+ var eidCounter = 0;
68
+ var eidMap = new Map(); // eid string \u2192 WeakRef<Element>
69
+ var elToEid = new WeakMap(); // Element \u2192 eid string
70
+
71
+ function getEid(el) {
72
+ if (!el) return null;
73
+ var existing = elToEid.get(el);
74
+ if (existing) return existing;
75
+ eidCounter++;
76
+ var eid = 'e-' + eidCounter;
77
+ eidMap.set(eid, new WeakRef(el));
78
+ elToEid.set(el, eid);
79
+ return eid;
80
+ }
81
+
82
+ function getEl(eid) {
83
+ var ref = eidMap.get(eid);
84
+ return ref ? ref.deref() || null : null;
85
+ }
86
+
87
+ // \u2500\u2500 PostMessage Helpers \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500
88
+ var shellOrigin = '*'; // Will be tightened on first shell message
89
+
90
+ function sendToShell(type, payload, id) {
91
+ var msg = { type: type, payload: payload || {}, source: 'annotask-client' };
92
+ if (id) msg.id = id;
93
+ window.parent.postMessage(msg, shellOrigin);
94
+ }
95
+
96
+ function respond(id, payload) {
97
+ sendToShell(null, payload, id);
98
+ // type is not needed for responses \u2014 shell matches by id
99
+ }
100
+
101
+ // \u2500\u2500 Source Element Resolution \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500
102
+ function findSourceElement(el) {
103
+ var c = el;
104
+ while (c) {
105
+ if (c.hasAttribute && c.hasAttribute('data-annotask-file')) return { sourceEl: c, targetEl: el };
106
+ c = c.parentElement;
107
+ }
108
+ return { sourceEl: el, targetEl: el };
109
+ }
110
+
111
+ function getSourceData(el) {
112
+ return {
113
+ file: el.getAttribute('data-annotask-file') || '',
114
+ line: el.getAttribute('data-annotask-line') || '',
115
+ component: el.getAttribute('data-annotask-component') || ''
116
+ };
117
+ }
118
+
119
+ function getRect(el) {
120
+ var r = el.getBoundingClientRect();
121
+ return { x: r.x, y: r.y, width: r.width, height: r.height };
122
+ }
123
+
124
+ // \u2500\u2500 Interaction Mode \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500
125
+ var currentMode = 'select';
126
+ var inspectModes = { select: true, pin: true };
127
+
128
+ // \u2500\u2500 Event Handlers \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500
129
+ var lastHoverEid = null;
130
+ var rafPending = false;
131
+ var pendingHoverData = null;
132
+
133
+ function onMouseOver(e) {
134
+ if (!inspectModes[currentMode]) return;
135
+ var el = e.target;
136
+ if (!el || el === document.documentElement || el === document.body) return;
137
+ var eid = getEid(el);
138
+ if (eid === lastHoverEid) return;
139
+ lastHoverEid = eid;
140
+
141
+ var source = findSourceElement(el);
142
+ var data = getSourceData(source.sourceEl);
143
+
144
+ pendingHoverData = {
145
+ eid: eid,
146
+ tag: el.tagName.toLowerCase(),
147
+ file: data.file,
148
+ component: data.component,
149
+ rect: getRect(el)
150
+ };
151
+
152
+ if (!rafPending) {
153
+ rafPending = true;
154
+ requestAnimationFrame(function() {
155
+ rafPending = false;
156
+ if (pendingHoverData) sendToShell('hover:enter', pendingHoverData);
157
+ });
158
+ }
159
+ }
160
+
161
+ function onMouseOut(e) {
162
+ if (!inspectModes[currentMode]) return;
163
+ // Only fire leave when truly leaving all elements
164
+ if (e.relatedTarget && e.relatedTarget !== document.documentElement) return;
165
+ lastHoverEid = null;
166
+ pendingHoverData = null;
167
+ sendToShell('hover:leave', {});
168
+ }
169
+
170
+ function onClick(e) {
171
+ if (!inspectModes[currentMode]) return;
172
+ e.preventDefault();
173
+ e.stopPropagation();
174
+
175
+ var el = e.target;
176
+ if (!el) return;
177
+
178
+ var source = findSourceElement(el);
179
+ var data = getSourceData(source.sourceEl);
180
+ var targetEl = source.targetEl;
181
+ var classes = typeof targetEl.className === 'string' ? targetEl.className : '';
182
+
183
+ sendToShell('click:element', {
184
+ eid: getEid(targetEl),
185
+ sourceEid: getEid(source.sourceEl),
186
+ file: data.file,
187
+ line: data.line,
188
+ component: data.component,
189
+ tag: targetEl.tagName.toLowerCase(),
190
+ classes: classes,
191
+ rect: getRect(targetEl),
192
+ shiftKey: e.shiftKey,
193
+ clientX: e.clientX,
194
+ clientY: e.clientY
195
+ });
196
+ }
197
+
198
+ function onMouseDown(e) {
199
+ if (!inspectModes[currentMode]) return;
200
+ e.stopPropagation();
201
+ }
202
+
203
+ function onMouseUp(e) {
204
+ if (currentMode !== 'highlight') return;
205
+ var sel = document.getSelection();
206
+ var text = sel ? sel.toString().trim() : '';
207
+ if (!text || text.length < 2) return;
208
+ var anchorEl = sel.anchorNode ? sel.anchorNode.parentElement : null;
209
+ if (!anchorEl) return;
210
+ var source = findSourceElement(anchorEl);
211
+ var data = getSourceData(source.sourceEl);
212
+
213
+ sendToShell('selection:text', {
214
+ text: text,
215
+ eid: getEid(anchorEl),
216
+ file: data.file,
217
+ line: parseInt(data.line) || 0,
218
+ component: data.component,
219
+ tag: anchorEl.tagName.toLowerCase()
220
+ });
221
+ }
222
+
223
+ function onContextMenu(e) {
224
+ if (currentMode === 'interact') return;
225
+ e.preventDefault();
226
+ var el = e.target;
227
+ if (!el) return;
228
+ var source = findSourceElement(el);
229
+ var data = getSourceData(source.sourceEl);
230
+ var targetEl = source.targetEl;
231
+ var classes = typeof targetEl.className === 'string' ? targetEl.className : '';
232
+
233
+ sendToShell('contextmenu:element', {
234
+ eid: getEid(targetEl),
235
+ sourceEid: getEid(source.sourceEl),
236
+ file: data.file,
237
+ line: data.line,
238
+ component: data.component,
239
+ tag: targetEl.tagName.toLowerCase(),
240
+ classes: classes,
241
+ rect: getRect(targetEl),
242
+ shiftKey: false,
243
+ clientX: e.clientX,
244
+ clientY: e.clientY
245
+ });
246
+ }
247
+
248
+ function onKeyDown(e) {
249
+ if ((e.ctrlKey || e.metaKey) && e.key === 'z' && !e.shiftKey) {
250
+ e.preventDefault();
251
+ sendToShell('keydown', { key: e.key, ctrlKey: e.ctrlKey, metaKey: e.metaKey, shiftKey: e.shiftKey });
252
+ }
253
+ }
254
+
255
+ // Install event listeners
256
+ document.addEventListener('mouseover', onMouseOver, { capture: true });
257
+ document.addEventListener('mouseout', onMouseOut, { capture: true });
258
+ document.addEventListener('mousedown', onMouseDown, { capture: true });
259
+ document.addEventListener('click', onClick, { capture: true });
260
+ document.addEventListener('mouseup', onMouseUp, { capture: true });
261
+ document.addEventListener('keydown', onKeyDown, { capture: true });
262
+ document.addEventListener('contextmenu', onContextMenu, { capture: true });
263
+
264
+ // \u2500\u2500 Route Tracking \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500
265
+ var lastRoute = window.location.pathname;
266
+
267
+ function checkRoute() {
268
+ var path = window.location.pathname;
269
+ if (path !== lastRoute) {
270
+ lastRoute = path;
271
+ sendToShell('route:changed', { path: path });
272
+ }
273
+ }
274
+
275
+ window.addEventListener('popstate', checkRoute);
276
+ window.addEventListener('hashchange', checkRoute);
277
+ setInterval(checkRoute, 2000); // safety net for pushState
278
+
279
+ // \u2500\u2500 Message Handler \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500
280
+ window.addEventListener('message', function(event) {
281
+ var msg = event.data;
282
+ if (!msg || msg.source !== 'annotask-shell') return;
283
+ // Tighten origin on first shell message
284
+ if (shellOrigin === '*' && event.origin) shellOrigin = event.origin;
285
+
286
+ var type = msg.type;
287
+ var payload = msg.payload || {};
288
+ var id = msg.id;
289
+
290
+ // \u2500\u2500 Mode \u2500\u2500
291
+ if (type === 'mode:set') {
292
+ currentMode = payload.mode || 'select';
293
+ return;
294
+ }
295
+
296
+ // \u2500\u2500 Ping \u2500\u2500
297
+ if (type === 'bridge:ping') {
298
+ respond(id, {});
299
+ return;
300
+ }
301
+
302
+ // \u2500\u2500 Element Resolution \u2500\u2500
303
+ if (type === 'resolve:at-point') {
304
+ var el = document.elementFromPoint(payload.x, payload.y);
305
+ if (!el || el === document.documentElement || el === document.body) {
306
+ respond(id, null);
307
+ return;
308
+ }
309
+ var src = findSourceElement(el);
310
+ var srcData = getSourceData(src.sourceEl);
311
+ respond(id, {
312
+ eid: getEid(src.targetEl),
313
+ file: srcData.file,
314
+ line: srcData.line,
315
+ component: srcData.component,
316
+ tag: src.sourceEl.tagName.toLowerCase(),
317
+ rect: getRect(src.sourceEl),
318
+ classes: typeof src.targetEl.className === 'string' ? src.targetEl.className : ''
319
+ });
320
+ return;
321
+ }
322
+
323
+ if (type === 'resolve:template-group') {
324
+ var all = document.querySelectorAll(
325
+ '[data-annotask-file="' + payload.file + '"][data-annotask-line="' + payload.line + '"]'
326
+ );
327
+ var eids = [];
328
+ var rects = [];
329
+ for (var i = 0; i < all.length; i++) {
330
+ if (all[i].tagName.toLowerCase() === payload.tagName) {
331
+ eids.push(getEid(all[i]));
332
+ rects.push(getRect(all[i]));
333
+ }
334
+ }
335
+ respond(id, { eids: eids, rects: rects });
336
+ return;
337
+ }
338
+
339
+ if (type === 'resolve:rect') {
340
+ var rEl = getEl(payload.eid);
341
+ respond(id, rEl ? { rect: getRect(rEl) } : null);
342
+ return;
343
+ }
344
+
345
+ if (type === 'resolve:rects') {
346
+ var results = [];
347
+ for (var j = 0; j < payload.eids.length; j++) {
348
+ var re = getEl(payload.eids[j]);
349
+ if (!re) console.warn('[annotask-bridge] resolve:rects: eid not found:', payload.eids[j], 'mapHas:', eidMap.has(payload.eids[j]), 'mapSize:', eidMap.size);
350
+ results.push(re ? getRect(re) : null);
351
+ }
352
+ respond(id, { rects: results });
353
+ return;
354
+ }
355
+
356
+ // \u2500\u2500 Style Operations \u2500\u2500
357
+ if (type === 'style:get-computed') {
358
+ var sEl = getEl(payload.eid);
359
+ if (!sEl) { respond(id, { styles: {} }); return; }
360
+ var cs = window.getComputedStyle(sEl);
361
+ var styles = {};
362
+ for (var k = 0; k < payload.properties.length; k++) {
363
+ styles[payload.properties[k]] = cs.getPropertyValue(payload.properties[k]);
364
+ }
365
+ respond(id, { styles: styles });
366
+ return;
367
+ }
368
+
369
+ if (type === 'style:apply') {
370
+ var aEl = getEl(payload.eid);
371
+ if (!aEl) { respond(id, { before: '' }); return; }
372
+ var before = window.getComputedStyle(aEl).getPropertyValue(payload.property);
373
+ aEl.style.setProperty(payload.property, payload.value);
374
+ respond(id, { before: before });
375
+ return;
376
+ }
377
+
378
+ if (type === 'style:apply-batch') {
379
+ var befores = [];
380
+ for (var m = 0; m < payload.eids.length; m++) {
381
+ var bEl = getEl(payload.eids[m]);
382
+ if (bEl) {
383
+ befores.push(window.getComputedStyle(bEl).getPropertyValue(payload.property));
384
+ bEl.style.setProperty(payload.property, payload.value);
385
+ } else {
386
+ befores.push('');
387
+ }
388
+ }
389
+ respond(id, { befores: befores });
390
+ return;
391
+ }
392
+
393
+ if (type === 'style:undo') {
394
+ var uEl = getEl(payload.eid);
395
+ if (uEl) {
396
+ if (payload.value) uEl.style.setProperty(payload.property, payload.value);
397
+ else uEl.style.removeProperty(payload.property);
398
+ }
399
+ respond(id, {});
400
+ return;
401
+ }
402
+
403
+ if (type === 'class:get') {
404
+ var cEl = getEl(payload.eid);
405
+ respond(id, { classes: cEl ? (typeof cEl.className === 'string' ? cEl.className : '') : '' });
406
+ return;
407
+ }
408
+
409
+ if (type === 'class:set') {
410
+ var csEl = getEl(payload.eid);
411
+ if (!csEl) { respond(id, { before: '' }); return; }
412
+ var classBefore = typeof csEl.className === 'string' ? csEl.className : '';
413
+ csEl.className = payload.classes;
414
+ respond(id, { before: classBefore });
415
+ return;
416
+ }
417
+
418
+ if (type === 'class:set-batch') {
419
+ var classBefores = [];
420
+ for (var n = 0; n < payload.eids.length; n++) {
421
+ var cbEl = getEl(payload.eids[n]);
422
+ if (cbEl) {
423
+ classBefores.push(typeof cbEl.className === 'string' ? cbEl.className : '');
424
+ cbEl.className = payload.classes;
425
+ } else {
426
+ classBefores.push('');
427
+ }
428
+ }
429
+ respond(id, { befores: classBefores });
430
+ return;
431
+ }
432
+
433
+ if (type === 'class:undo') {
434
+ var cuEl = getEl(payload.eid);
435
+ if (cuEl) cuEl.className = payload.classes;
436
+ respond(id, {});
437
+ return;
438
+ }
439
+
440
+ // \u2500\u2500 Classification \u2500\u2500
441
+ if (type === 'classify:element') {
442
+ var clEl = getEl(payload.eid);
443
+ if (!clEl) { respond(id, null); return; }
444
+ var tag = clEl.tagName.toLowerCase();
445
+ var clCs = window.getComputedStyle(clEl);
446
+ var display = clCs.display;
447
+ var childCount = clEl.children.length;
448
+ var isFlex = display.includes('flex');
449
+ var isGrid = display.includes('grid');
450
+ var semanticContainers = ['section','main','aside','nav','header','footer','article'];
451
+ var role = 'content';
452
+ if (clEl.hasAttribute('data-annotask-component')) {
453
+ var comp = clEl.getAttribute('data-annotask-component') || '';
454
+ if (comp && comp[0] === comp[0].toUpperCase() && comp[0] !== comp[0].toLowerCase()) {
455
+ role = 'component';
456
+ }
457
+ }
458
+ if (role !== 'component' && (isFlex || isGrid) && childCount > 0) role = 'container';
459
+ if (role !== 'component' && role !== 'container' && semanticContainers.indexOf(tag) >= 0 && childCount > 0) role = 'container';
460
+
461
+ respond(id, {
462
+ role: role,
463
+ display: display,
464
+ isFlexContainer: isFlex,
465
+ isGridContainer: isGrid,
466
+ flexDirection: isFlex ? clCs.flexDirection : undefined,
467
+ childCount: childCount,
468
+ isComponentUnit: role === 'component'
469
+ });
470
+ return;
471
+ }
472
+
473
+ // \u2500\u2500 Layout Scan \u2500\u2500
474
+ if (type === 'layout:scan') {
475
+ var layoutResults = [];
476
+ var allEls = document.querySelectorAll('*');
477
+ for (var li = 0; li < allEls.length; li++) {
478
+ var lEl = allEls[li];
479
+ if (lEl.nodeType !== 1) continue;
480
+ var lCs = window.getComputedStyle(lEl);
481
+ var lDisplay = lCs.display;
482
+ if (!lDisplay.includes('flex') && !lDisplay.includes('grid')) continue;
483
+ var lRect = lEl.getBoundingClientRect();
484
+ if (lRect.width < 20 || lRect.height < 20) continue;
485
+ var lIsGrid = lDisplay.includes('grid');
486
+ var entry = {
487
+ eid: getEid(lEl),
488
+ display: lIsGrid ? 'grid' : 'flex',
489
+ direction: lIsGrid ? 'grid' : lCs.flexDirection,
490
+ rect: { x: lRect.x, y: lRect.y, width: lRect.width, height: lRect.height },
491
+ columnGap: parseFloat(lCs.columnGap) || 0,
492
+ rowGap: parseFloat(lCs.rowGap) || 0
493
+ };
494
+ if (lIsGrid) {
495
+ var cols = lCs.gridTemplateColumns;
496
+ var rows = lCs.gridTemplateRows;
497
+ entry.templateColumns = cols;
498
+ entry.templateRows = rows;
499
+ if (cols && cols !== 'none') {
500
+ entry.columns = cols.split(/\\s+/).map(function(s) { return parseFloat(s) || 0; }).filter(function(v) { return v > 0; });
501
+ }
502
+ if (rows && rows !== 'none') {
503
+ entry.rows = rows.split(/\\s+/).map(function(s) { return parseFloat(s) || 0; }).filter(function(v) { return v > 0; });
504
+ }
505
+ }
506
+ layoutResults.push(entry);
507
+ }
508
+ respond(id, { containers: layoutResults });
509
+ return;
510
+ }
511
+
512
+ if (type === 'layout:add-track') {
513
+ var ltEl = getEl(payload.eid);
514
+ if (!ltEl) { respond(id, { property: '', before: '', after: '' }); return; }
515
+ var ltCs = window.getComputedStyle(ltEl);
516
+ var cssProp = payload.axis === 'col' ? 'grid-template-columns' : 'grid-template-rows';
517
+ var ltBefore = ltCs.getPropertyValue(cssProp) || '';
518
+ var ltAfter = ltBefore && ltBefore !== 'none' ? ltBefore + ' 1fr' : '1fr';
519
+ ltEl.style.setProperty(cssProp, ltAfter);
520
+ respond(id, { property: cssProp, before: ltBefore, after: ltAfter });
521
+ return;
522
+ }
523
+
524
+ if (type === 'layout:add-child') {
525
+ var lcEl = getEl(payload.eid);
526
+ if (!lcEl) { respond(id, { childEid: '' }); return; }
527
+ var child = document.createElement('div');
528
+ child.style.minWidth = '60px';
529
+ child.style.minHeight = '40px';
530
+ child.style.border = '2px dashed #a855f7';
531
+ child.style.borderRadius = '4px';
532
+ child.style.background = 'rgba(168,85,247,0.05)';
533
+ child.setAttribute('data-annotask-placeholder', 'true');
534
+ lcEl.appendChild(child);
535
+ respond(id, { childEid: getEid(child) });
536
+ return;
537
+ }
538
+
539
+ // \u2500\u2500 Theme \u2500\u2500
540
+ if (type === 'theme:inject-css') {
541
+ var existing = document.getElementById(payload.styleId);
542
+ if (existing) {
543
+ existing.textContent = payload.css;
544
+ } else {
545
+ var style = document.createElement('style');
546
+ style.id = payload.styleId;
547
+ style.textContent = payload.css;
548
+ document.head.appendChild(style);
549
+ }
550
+ respond(id, {});
551
+ return;
552
+ }
553
+
554
+ if (type === 'theme:remove-css') {
555
+ var toRemove = document.getElementById(payload.styleId);
556
+ if (toRemove) toRemove.remove();
557
+ respond(id, {});
558
+ return;
559
+ }
560
+
561
+ // \u2500\u2500 Color Palette \u2500\u2500
562
+ if (type === 'palette:scan-vars') {
563
+ var swatches = [];
564
+ try {
565
+ var rootStyles = window.getComputedStyle(document.documentElement);
566
+ var sheets = document.styleSheets;
567
+ for (var si = 0; si < sheets.length; si++) {
568
+ try {
569
+ var rules = sheets[si].cssRules;
570
+ for (var ri = 0; ri < rules.length; ri++) {
571
+ var rule = rules[ri];
572
+ if (rule.selectorText === ':root' || rule.selectorText === ':root, :host') {
573
+ for (var pi = 0; pi < rule.style.length; pi++) {
574
+ var prop = rule.style[pi];
575
+ if (prop.startsWith('--')) {
576
+ var val = rootStyles.getPropertyValue(prop).trim();
577
+ if (val && isColor(val)) {
578
+ swatches.push({ name: prop, value: val });
579
+ }
580
+ }
581
+ }
582
+ }
583
+ }
584
+ } catch(e) { /* cross-origin stylesheet */ }
585
+ }
586
+ } catch(e) {}
587
+ respond(id, { swatches: swatches });
588
+ return;
589
+ }
590
+
591
+ // \u2500\u2500 Source Mapping Check \u2500\u2500
592
+ if (type === 'check:source-mapping') {
593
+ respond(id, { hasMapping: !!document.querySelector('[data-annotask-file]') });
594
+ return;
595
+ }
596
+
597
+ // \u2500\u2500 Insert Placeholder \u2500\u2500
598
+ if (type === 'insert:placeholder') {
599
+ var ipTarget = getEl(payload.targetEid);
600
+ if (!ipTarget) { respond(id, { placeholderEid: '' }); return; }
601
+ var ipEl = createPlaceholder(payload);
602
+ var ipRef = ipTarget;
603
+ switch (payload.position) {
604
+ case 'before': ipRef.parentElement && ipRef.parentElement.insertBefore(ipEl, ipRef); break;
605
+ case 'after': ipRef.parentElement && ipRef.parentElement.insertBefore(ipEl, ipRef.nextSibling); break;
606
+ case 'append': ipRef.appendChild(ipEl); break;
607
+ case 'prepend': ipRef.insertBefore(ipEl, ipRef.firstChild); break;
608
+ }
609
+ // Match sibling sizes in flex/grid
610
+ var insertParent = (payload.position === 'append' || payload.position === 'prepend') ? ipRef : ipRef.parentElement;
611
+ if (insertParent) {
612
+ var pCs = window.getComputedStyle(insertParent);
613
+ if (pCs.display.includes('flex') || pCs.display.includes('grid')) {
614
+ if (!ipEl.style.width) {
615
+ var isRow = pCs.flexDirection === 'row' || pCs.flexDirection === 'row-reverse' || pCs.display.includes('grid');
616
+ if (isRow) ipEl.style.flex = '1';
617
+ }
618
+ }
619
+ }
620
+ respond(id, { placeholderEid: getEid(ipEl) });
621
+ return;
622
+ }
623
+
624
+ if (type === 'insert:remove') {
625
+ var irEl = getEl(payload.eid);
626
+ if (irEl) {
627
+ var unmount = irEl.__annotask_unmount;
628
+ if (unmount) unmount();
629
+ irEl.remove();
630
+ }
631
+ respond(id, {});
632
+ return;
633
+ }
634
+
635
+ if (type === 'move:element') {
636
+ var meEl = getEl(payload.eid);
637
+ var meTarget = getEl(payload.targetEid);
638
+ if (meEl && meTarget) {
639
+ switch (payload.position) {
640
+ case 'before': meTarget.parentElement && meTarget.parentElement.insertBefore(meEl, meTarget); break;
641
+ case 'after': meTarget.parentElement && meTarget.parentElement.insertBefore(meEl, meTarget.nextSibling); break;
642
+ case 'append': meTarget.appendChild(meEl); break;
643
+ case 'prepend': meTarget.insertBefore(meEl, meTarget.firstChild); break;
644
+ }
645
+ }
646
+ respond(id, {});
647
+ return;
648
+ }
649
+
650
+ if (type === 'insert:vue-component' || type === 'insert:component') {
651
+ var vcTarget = getEl(payload.targetEid);
652
+ if (!vcTarget) { respond(id, { eid: '', mounted: false }); return; }
653
+ var vcContainer = document.createElement('div');
654
+ vcContainer.setAttribute('data-annotask-placeholder', 'true');
655
+ switch (payload.position) {
656
+ case 'before': vcTarget.parentElement && vcTarget.parentElement.insertBefore(vcContainer, vcTarget); break;
657
+ case 'after': vcTarget.parentElement && vcTarget.parentElement.insertBefore(vcContainer, vcTarget.nextSibling); break;
658
+ case 'append': vcTarget.appendChild(vcContainer); break;
659
+ case 'prepend': vcTarget.insertBefore(vcContainer, vcTarget.firstChild); break;
660
+ }
661
+ var mounted = tryMountComponent(vcContainer, payload.componentName, payload.props);
662
+ respond(id, { eid: getEid(vcContainer), mounted: mounted });
663
+ return;
664
+ }
665
+
666
+ // \u2500\u2500 Get source data for an eid \u2500\u2500
667
+ if (type === 'resolve:source') {
668
+ var rsEl = getEl(payload.eid);
669
+ if (!rsEl) { respond(id, null); return; }
670
+ var rsSrc = findSourceElement(rsEl);
671
+ var rsData = getSourceData(rsSrc.sourceEl);
672
+ respond(id, {
673
+ sourceEid: getEid(rsSrc.sourceEl),
674
+ file: rsData.file,
675
+ line: rsData.line,
676
+ component: rsData.component,
677
+ tag: rsSrc.sourceEl.tagName.toLowerCase()
678
+ });
679
+ return;
680
+ }
681
+
682
+ // \u2500\u2500 Route \u2500\u2500
683
+ if (type === 'route:current') {
684
+ respond(id, { path: window.location.pathname });
685
+ return;
686
+ }
687
+ });
688
+
689
+ // \u2500\u2500 Helpers \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500
690
+ function isColor(val) {
691
+ if (val.startsWith('#') || val.startsWith('rgb') || val.startsWith('hsl')) return true;
692
+ // Named colors \u2014 quick check with canvas
693
+ try {
694
+ var ctx = document.createElement('canvas').getContext('2d');
695
+ ctx.fillStyle = '#000000';
696
+ ctx.fillStyle = val;
697
+ return ctx.fillStyle !== '#000000' || val === 'black' || val === '#000000';
698
+ } catch(e) { return false; }
699
+ }
700
+
701
+ function createPlaceholder(payload) {
702
+ var el = document.createElement(payload.tag);
703
+ el.setAttribute('data-annotask-placeholder', 'true');
704
+ if (payload.classes) el.className = payload.classes;
705
+ var tag = payload.tag.toLowerCase();
706
+ var isComponent = payload.tag.includes('-') || (payload.tag[0] === payload.tag[0].toUpperCase() && payload.tag[0] !== payload.tag[0].toLowerCase());
707
+
708
+ if (tag === 'button') {
709
+ el.textContent = payload.textContent || 'Button';
710
+ el.style.cssText = 'padding:8px 16px;border-radius:6px;font-size:14px;font-weight:500;cursor:pointer;border:1px solid currentColor;background:var(--accent,#3b82f6);color:white;';
711
+ } else if (tag === 'input') {
712
+ el.type = 'text'; el.placeholder = 'Input field...';
713
+ el.style.cssText = 'padding:8px 12px;border:1px solid #ccc;border-radius:6px;font-size:14px;width:100%;max-width:300px;background:white;color:#333;';
714
+ } else if (tag === 'textarea') {
715
+ el.placeholder = 'Text area...';
716
+ el.style.cssText = 'padding:8px 12px;border:1px solid #ccc;border-radius:6px;font-size:14px;width:100%;min-height:60px;background:white;color:#333;resize:vertical;';
717
+ } else if (tag === 'img') {
718
+ el.style.cssText = 'width:200px;height:120px;background:#e5e7eb;border-radius:8px;display:flex;align-items:center;justify-content:center;';
719
+ } else if (['h1','h2','h3','h4','h5','h6'].indexOf(tag) >= 0) {
720
+ el.textContent = payload.textContent || 'Heading';
721
+ var sizes = { h1:'2em', h2:'1.5em', h3:'1.25em', h4:'1.1em', h5:'1em', h6:'0.9em' };
722
+ el.style.cssText = 'font-size:' + (sizes[tag]||'1em') + ';font-weight:700;margin:0.5em 0;';
723
+ } else if (tag === 'p') {
724
+ el.textContent = payload.textContent || 'Paragraph text goes here.';
725
+ el.style.cssText = 'margin:0.5em 0;line-height:1.5;';
726
+ } else if (tag === 'a') {
727
+ el.textContent = payload.textContent || 'Link';
728
+ el.style.cssText = 'color:var(--accent,#3b82f6);text-decoration:underline;cursor:pointer;';
729
+ } else if (tag === 'section' || tag === 'div' || tag === 'nav' || tag === 'header' || tag === 'footer' || tag === 'aside' || tag === 'main') {
730
+ if (!payload.classes && !payload.textContent) {
731
+ el.style.cssText = 'min-height:40px;padding:12px;border:1.5px dashed rgba(59,130,246,0.3);border-radius:6px;background:rgba(59,130,246,0.03);';
732
+ } else if (payload.textContent) {
733
+ el.textContent = payload.textContent;
734
+ }
735
+ if (payload.category === 'layout-preset') {
736
+ el.style.minHeight = '60px';
737
+ el.style.padding = el.style.padding || '12px';
738
+ el.style.border = '1.5px dashed rgba(34,197,94,0.3)';
739
+ el.style.borderRadius = '6px';
740
+ el.style.background = 'rgba(34,197,94,0.03)';
741
+ }
742
+ } else if (isComponent) {
743
+ var vcMounted = tryMountComponent(el, payload.tag, payload.defaultProps);
744
+ if (!vcMounted) {
745
+ el.style.cssText = 'min-height:80px;padding:16px;border:1px solid rgba(168,85,247,0.2);border-radius:8px;background:rgba(168,85,247,0.03);display:flex;flex-direction:column;gap:8px;overflow:hidden;';
746
+ var hdr = document.createElement('div');
747
+ hdr.style.cssText = 'display:flex;align-items:center;gap:6px;margin-bottom:4px;';
748
+ var dot = document.createElement('span');
749
+ dot.style.cssText = 'width:6px;height:6px;border-radius:50%;background:#a855f7;';
750
+ hdr.appendChild(dot);
751
+ var tagLabel = document.createElement('span');
752
+ tagLabel.style.cssText = 'font-size:11px;font-weight:600;color:#a855f7;';
753
+ tagLabel.textContent = payload.tag;
754
+ hdr.appendChild(tagLabel);
755
+ el.appendChild(hdr);
756
+ }
757
+ } else {
758
+ el.textContent = payload.textContent || '';
759
+ }
760
+ return el;
761
+ }
762
+
763
+ function tryMountComponent(container, componentName, props) {
764
+ // Try Vue
765
+ if (window.__ANNOTASK_VUE__) {
766
+ var mounted = tryMountVueComponent(container, componentName, props);
767
+ if (mounted) return true;
768
+ }
769
+ // Try React
770
+ if (window.__ANNOTASK_REACT__) {
771
+ var mounted = tryMountReactComponent(container, componentName, props);
772
+ if (mounted) return true;
773
+ }
774
+ // Try Svelte
775
+ if (window.__ANNOTASK_SVELTE__) {
776
+ var mounted = tryMountSvelteComponent(container, componentName, props);
777
+ if (mounted) return true;
778
+ }
779
+ return false;
780
+ }
781
+
782
+ function tryMountVueComponent(container, componentName, props) {
783
+ try {
784
+ var appEl = document.querySelector('#app');
785
+ var vueApp = appEl && appEl.__vue_app__;
786
+ if (!vueApp) return false;
787
+ var annotaskVue = window.__ANNOTASK_VUE__;
788
+ if (!annotaskVue || !annotaskVue.createApp || !annotaskVue.h) return false;
789
+ var component = vueApp._context.components[componentName] || (window.__ANNOTASK_COMPONENTS__ && window.__ANNOTASK_COMPONENTS__[componentName]);
790
+ if (!component) return false;
791
+ var mountPoint = document.createElement('div');
792
+ container.appendChild(mountPoint);
793
+ var miniApp = annotaskVue.createApp({
794
+ render: function() { return annotaskVue.h(component, props || {}); }
795
+ });
796
+ miniApp._context = vueApp._context;
797
+ miniApp.mount(mountPoint);
798
+ container.setAttribute('data-annotask-mounted', 'true');
799
+ container.__annotask_unmount = function() { try { miniApp.unmount(); } catch(e) {} };
800
+ return true;
801
+ } catch(e) { return false; }
802
+ }
803
+
804
+ function tryMountReactComponent(container, componentName, props) {
805
+ try {
806
+ var annotaskReact = window.__ANNOTASK_REACT__;
807
+ if (!annotaskReact || !annotaskReact.createElement || !annotaskReact.createRoot) return false;
808
+ var component = window.__ANNOTASK_COMPONENTS__ && window.__ANNOTASK_COMPONENTS__[componentName];
809
+ if (!component) return false;
810
+ var mountPoint = document.createElement('div');
811
+ container.appendChild(mountPoint);
812
+ var root = annotaskReact.createRoot(mountPoint);
813
+ root.render(annotaskReact.createElement(component, props || {}));
814
+ container.setAttribute('data-annotask-mounted', 'true');
815
+ container.__annotask_unmount = function() { try { root.unmount(); } catch(e) {} };
816
+ return true;
817
+ } catch(e) { return false; }
818
+ }
819
+
820
+ function tryMountSvelteComponent(container, componentName, props) {
821
+ try {
822
+ var annotaskSvelte = window.__ANNOTASK_SVELTE__;
823
+ if (!annotaskSvelte || !annotaskSvelte.mount) return false;
824
+ var component = window.__ANNOTASK_COMPONENTS__ && window.__ANNOTASK_COMPONENTS__[componentName];
825
+ if (!component) return false;
826
+ var mountPoint = document.createElement('div');
827
+ container.appendChild(mountPoint);
828
+ var instance = annotaskSvelte.mount(component, { target: mountPoint, props: props || {} });
829
+ container.setAttribute('data-annotask-mounted', 'true');
830
+ container.__annotask_unmount = function() {
831
+ try {
832
+ if (annotaskSvelte.unmount) annotaskSvelte.unmount(instance);
833
+ } catch(e) {}
834
+ };
835
+ return true;
836
+ } catch(e) { return false; }
837
+ }
838
+
839
+ // \u2500\u2500 Ready \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500
840
+ sendToShell('bridge:ready', { version: '1.0' });
841
+ })();
842
+ `.trim();
843
+ }
844
+
845
+ export {
846
+ toggleButtonScript,
847
+ bridgeClientScript
848
+ };
849
+ //# sourceMappingURL=chunk-FBXNRXMY.js.map