@wasao/kagemusha 0.1.1 → 0.2.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 (104) hide show
  1. package/README.md +496 -57
  2. package/dist/commands/add.d.ts +6 -0
  3. package/dist/commands/add.d.ts.map +1 -0
  4. package/dist/commands/add.js +26 -0
  5. package/dist/commands/add.js.map +1 -0
  6. package/dist/commands/capture.d.ts +3 -2
  7. package/dist/commands/capture.d.ts.map +1 -1
  8. package/dist/commands/capture.js +234 -20
  9. package/dist/commands/capture.js.map +1 -1
  10. package/dist/commands/discover.d.ts +2 -0
  11. package/dist/commands/discover.d.ts.map +1 -0
  12. package/dist/commands/discover.js +62 -0
  13. package/dist/commands/discover.js.map +1 -0
  14. package/dist/commands/edit.d.ts.map +1 -1
  15. package/dist/commands/edit.js +40 -20
  16. package/dist/commands/edit.js.map +1 -1
  17. package/dist/commands/init.d.ts +1 -1
  18. package/dist/commands/init.d.ts.map +1 -1
  19. package/dist/commands/init.js +206 -102
  20. package/dist/commands/init.js.map +1 -1
  21. package/dist/commands/list.d.ts +2 -0
  22. package/dist/commands/list.d.ts.map +1 -0
  23. package/dist/commands/list.js +33 -0
  24. package/dist/commands/list.js.map +1 -0
  25. package/dist/commands/login.d.ts +6 -0
  26. package/dist/commands/login.d.ts.map +1 -0
  27. package/dist/commands/login.js +142 -0
  28. package/dist/commands/login.js.map +1 -0
  29. package/dist/commands/validate.js +1 -1
  30. package/dist/commands/validate.js.map +1 -1
  31. package/dist/editor/inject-script.js +407 -33
  32. package/dist/editor/inject-script.js.map +1 -1
  33. package/dist/index.js +27 -16
  34. package/dist/index.js.map +1 -1
  35. package/dist/lib/annotate.d.ts +2 -2
  36. package/dist/lib/annotate.d.ts.map +1 -1
  37. package/dist/lib/annotate.js +35 -43
  38. package/dist/lib/annotate.js.map +1 -1
  39. package/dist/lib/auth.d.ts +18 -0
  40. package/dist/lib/auth.d.ts.map +1 -0
  41. package/dist/lib/auth.js +45 -0
  42. package/dist/lib/auth.js.map +1 -0
  43. package/dist/lib/aws-error.d.ts +7 -0
  44. package/dist/lib/aws-error.d.ts.map +1 -0
  45. package/dist/lib/aws-error.js +74 -0
  46. package/dist/lib/aws-error.js.map +1 -0
  47. package/dist/lib/canonical.d.ts +22 -0
  48. package/dist/lib/canonical.d.ts.map +1 -0
  49. package/dist/lib/canonical.js +92 -0
  50. package/dist/lib/canonical.js.map +1 -0
  51. package/dist/lib/config.d.ts +2 -0
  52. package/dist/lib/config.d.ts.map +1 -1
  53. package/dist/lib/config.js +23 -13
  54. package/dist/lib/config.js.map +1 -1
  55. package/dist/lib/crawl.d.ts +1 -1
  56. package/dist/lib/crawl.d.ts.map +1 -1
  57. package/dist/lib/crawl.js +213 -20
  58. package/dist/lib/crawl.js.map +1 -1
  59. package/dist/lib/definition.d.ts +2 -0
  60. package/dist/lib/definition.d.ts.map +1 -0
  61. package/dist/lib/definition.js +6 -0
  62. package/dist/lib/definition.js.map +1 -0
  63. package/dist/lib/diff.d.ts +52 -0
  64. package/dist/lib/diff.d.ts.map +1 -0
  65. package/dist/lib/diff.js +41 -0
  66. package/dist/lib/diff.js.map +1 -0
  67. package/dist/lib/login-error.d.ts +10 -0
  68. package/dist/lib/login-error.d.ts.map +1 -0
  69. package/dist/lib/login-error.js +13 -0
  70. package/dist/lib/login-error.js.map +1 -0
  71. package/dist/lib/screenshot.d.ts +8 -2
  72. package/dist/lib/screenshot.d.ts.map +1 -1
  73. package/dist/lib/screenshot.js +44 -61
  74. package/dist/lib/screenshot.js.map +1 -1
  75. package/dist/lib/staging.d.ts +8 -0
  76. package/dist/lib/staging.d.ts.map +1 -0
  77. package/dist/lib/staging.js +24 -0
  78. package/dist/lib/staging.js.map +1 -0
  79. package/dist/types.d.ts +5 -23
  80. package/dist/types.d.ts.map +1 -1
  81. package/package.json +18 -11
  82. package/dist/commands/preview.d.ts +0 -6
  83. package/dist/commands/preview.d.ts.map +0 -1
  84. package/dist/commands/preview.js +0 -33
  85. package/dist/commands/preview.js.map +0 -1
  86. package/dist/commands/run.d.ts +0 -6
  87. package/dist/commands/run.d.ts.map +0 -1
  88. package/dist/commands/run.js +0 -39
  89. package/dist/commands/run.js.map +0 -1
  90. package/dist/editor/editor/editor.html +0 -313
  91. package/dist/editor/editor/inject.ts +0 -385
  92. package/dist/editor/editor.html +0 -338
  93. package/dist/editor/inject-script.cjs +0 -398
  94. package/dist/editor/inject-script.cjs.map +0 -1
  95. package/dist/editor/inject-script.d.cts +0 -2
  96. package/dist/editor/inject-script.d.cts.map +0 -1
  97. package/dist/editor/inject.d.ts +0 -2
  98. package/dist/editor/inject.d.ts.map +0 -1
  99. package/dist/editor/inject.js +0 -385
  100. package/dist/editor/inject.js.map +0 -1
  101. package/dist/lib/upload.d.ts +0 -9
  102. package/dist/lib/upload.d.ts.map +0 -1
  103. package/dist/lib/upload.js +0 -43
  104. package/dist/lib/upload.js.map +0 -1
@@ -1,385 +0,0 @@
1
- // This script is injected into the target page to provide annotation editing.
2
- // It adds a toolbar and SVG overlay layer on top of the actual page.
3
- export const EDITOR_SCRIPT = `
4
- (function() {
5
- const TOOLBAR_HEIGHT = 48;
6
- const svgNS = 'http://www.w3.org/2000/svg';
7
-
8
- let tool = 'rect';
9
- let annotations = [];
10
- let selectedId = null;
11
- let dragState = null;
12
- let nextId = 1;
13
-
14
- // --- GLOBAL STATE (single object to avoid namespace pollution) ---
15
- window.__kagemusha = window.__kagemusha || { dpr: 1, saved: null };
16
-
17
- // --- TOOLBAR ---
18
- const toolbar = document.createElement('div');
19
- toolbar.id = 'kagemusha-toolbar';
20
- toolbar.innerHTML = \`
21
- <style>
22
- #kagemusha-toolbar {
23
- position: fixed; top: 0; left: 0; right: 0; z-index: 999999;
24
- background: #16213e; padding: 8px 16px; display: flex; align-items: center; gap: 12px;
25
- box-shadow: 0 2px 8px rgba(0,0,0,0.3); font-family: -apple-system, sans-serif;
26
- }
27
- #kagemusha-toolbar button {
28
- padding: 6px 14px; border: 1px solid #444; border-radius: 6px;
29
- background: #1a1a2e; color: #fff; font-size: 13px; cursor: pointer;
30
- }
31
- #kagemusha-toolbar button:hover { background: #2a2a4e; }
32
- #kagemusha-toolbar button.active { background: #6366f1; border-color: #6366f1; }
33
- #kagemusha-toolbar .sep { width: 1px; height: 24px; background: #444; }
34
- #kagemusha-toolbar .title { color: #888; font-size: 13px; }
35
- #kagemusha-toolbar .save-btn { background: #22c55e; border-color: #22c55e; font-weight: 600; margin-left: auto; }
36
- #kagemusha-toolbar .save-btn:hover { background: #16a34a; }
37
- #kagemusha-svg-layer {
38
- position: absolute; top: 0; left: 0; width: 100%;
39
- z-index: 999998; pointer-events: none;
40
- }
41
- #kagemusha-svg-layer.drawing { pointer-events: auto; cursor: crosshair; }
42
- #kagemusha-svg-layer .annotation { pointer-events: auto; cursor: move; }
43
- #kagemusha-svg-layer .annotation.selected { filter: drop-shadow(0 0 3px #6366f1); }
44
- .kagemusha-hint {
45
- position: fixed; bottom: 16px; left: 50%; transform: translateX(-50%);
46
- color: #fff; background: rgba(0,0,0,0.7); padding: 6px 16px; border-radius: 8px;
47
- font-size: 12px; z-index: 999999; font-family: -apple-system, sans-serif;
48
- }
49
- </style>
50
- <span class="title">🥷 Annotation Editor</span>
51
- <button id="kg-tool-rect" class="active">▭ Rectangle</button>
52
- <button id="kg-tool-arrow">→ Arrow</button>
53
- <button id="kg-tool-label">T Label</button>
54
- <div class="sep"></div>
55
- <button id="kg-delete">🗑 Delete</button>
56
- <button class="save-btn" id="kg-save">💾 Save</button>
57
- \`;
58
- document.body.appendChild(toolbar);
59
- document.body.style.paddingTop = TOOLBAR_HEIGHT + 'px';
60
-
61
- // Hint
62
- const hint = document.createElement('div');
63
- hint.className = 'kagemusha-hint';
64
- hint.textContent = 'Click and drag to add annotations. Click to select. Press Delete to remove.';
65
- document.body.appendChild(hint);
66
-
67
- // --- SVG LAYER ---
68
- const svg = document.createElementNS(svgNS, 'svg');
69
- svg.id = 'kagemusha-svg-layer';
70
- svg.classList.add('drawing');
71
- document.body.appendChild(svg);
72
-
73
- function updateSvgSize() {
74
- svg.setAttribute('width', String(window.innerWidth));
75
- svg.setAttribute('height', String(document.documentElement.scrollHeight));
76
- }
77
- updateSvgSize();
78
- window.addEventListener('resize', updateSvgSize);
79
-
80
- const defs = document.createElementNS(svgNS, 'defs');
81
- defs.innerHTML = '<marker id="kg-arrowhead" markerWidth="10" markerHeight="7" refX="10" refY="3.5" orient="auto" fill="#FF0000"><polygon points="0 0, 10 3.5, 0 7"/></marker>';
82
- svg.appendChild(defs);
83
-
84
- // --- TOOLS ---
85
- function setTool(t) {
86
- tool = t;
87
- document.querySelectorAll('#kagemusha-toolbar button').forEach(b => b.classList.remove('active'));
88
- const btn = document.getElementById('kg-tool-' + t);
89
- if (btn) btn.classList.add('active');
90
- svg.classList.toggle('drawing', true);
91
- deselectAll();
92
- }
93
-
94
- document.getElementById('kg-tool-rect').addEventListener('click', () => setTool('rect'));
95
- document.getElementById('kg-tool-arrow').addEventListener('click', () => setTool('arrow'));
96
- document.getElementById('kg-tool-label').addEventListener('click', () => setTool('label'));
97
- document.getElementById('kg-delete').addEventListener('click', deleteSelected);
98
- document.getElementById('kg-save').addEventListener('click', save);
99
-
100
- function deselectAll() {
101
- selectedId = null;
102
- svg.querySelectorAll('.annotation').forEach(el => el.classList.remove('selected'));
103
- }
104
-
105
- function selectEl(el) {
106
- deselectAll();
107
- selectedId = el.dataset.id;
108
- el.classList.add('selected');
109
- }
110
-
111
- function deleteSelected() {
112
- if (!selectedId) return;
113
- const el = svg.querySelector('[data-id="' + selectedId + '"]');
114
- if (el) el.remove();
115
- annotations = annotations.filter(a => a.id !== selectedId);
116
- selectedId = null;
117
- }
118
-
119
- document.addEventListener('keydown', e => {
120
- if (e.key === 'Delete' || e.key === 'Backspace') {
121
- if (document.activeElement.tagName === 'INPUT') return;
122
- deleteSelected();
123
- }
124
- });
125
-
126
- // --- MOUSE HANDLING ---
127
- function getPos(e) {
128
- return { x: e.pageX, y: e.pageY };
129
- }
130
-
131
- function startMove(e, id) {
132
- e.stopPropagation();
133
- const el = svg.querySelector('[data-id="' + id + '"]');
134
- selectEl(el);
135
- const p = getPos(e);
136
- dragState = { type: 'move', id, el, lastX: p.x, lastY: p.y };
137
- }
138
-
139
- // --- LABEL: measure text width using SVG getBBox ---
140
- function measureTextWidth(text, fontSize) {
141
- const tmp = document.createElementNS(svgNS, 'text');
142
- tmp.setAttribute('font-size', String(fontSize));
143
- tmp.setAttribute('font-family', '-apple-system, sans-serif');
144
- tmp.textContent = text;
145
- svg.appendChild(tmp);
146
- const width = tmp.getBBox().width;
147
- tmp.remove();
148
- return width;
149
- }
150
-
151
- function createLabelGroup(id, x, y, text, fontSize) {
152
- fontSize = fontSize || 14;
153
- const g = document.createElementNS(svgNS, 'g');
154
- g.classList.add('annotation');
155
- g.dataset.id = id;
156
- const bg = document.createElementNS(svgNS, 'rect');
157
- const txt = document.createElementNS(svgNS, 'text');
158
- txt.textContent = text;
159
- txt.setAttribute('x', String(x + 6));
160
- txt.setAttribute('y', String(y + 16));
161
- txt.setAttribute('fill', '#FF0000');
162
- txt.setAttribute('font-size', String(fontSize));
163
- txt.setAttribute('font-family', '-apple-system, sans-serif');
164
- const tw = measureTextWidth(text, fontSize) + 12;
165
- bg.setAttribute('x', String(x));
166
- bg.setAttribute('y', String(y));
167
- bg.setAttribute('width', String(tw));
168
- bg.setAttribute('height', '24');
169
- bg.setAttribute('fill', '#FFFFFF');
170
- bg.setAttribute('rx', '4');
171
- g.appendChild(bg);
172
- g.appendChild(txt);
173
- return g;
174
- }
175
-
176
- svg.addEventListener('mousedown', e => {
177
- if (e.target.closest('.annotation')) return;
178
- const p = getPos(e);
179
- deselectAll();
180
-
181
- if (tool === 'rect') {
182
- const id = 'a' + nextId++;
183
- const rect = document.createElementNS(svgNS, 'rect');
184
- rect.setAttribute('x', p.x);
185
- rect.setAttribute('y', p.y);
186
- rect.setAttribute('width', '0');
187
- rect.setAttribute('height', '0');
188
- rect.setAttribute('fill', 'none');
189
- rect.setAttribute('stroke', '#FF0000');
190
- rect.setAttribute('stroke-width', '3');
191
- rect.setAttribute('rx', '4');
192
- rect.classList.add('annotation');
193
- rect.dataset.id = id;
194
- svg.appendChild(rect);
195
- dragState = { type: 'create-rect', id, el: rect, sx: p.x, sy: p.y };
196
- } else if (tool === 'arrow') {
197
- const id = 'a' + nextId++;
198
- const line = document.createElementNS(svgNS, 'line');
199
- line.setAttribute('x1', p.x);
200
- line.setAttribute('y1', p.y);
201
- line.setAttribute('x2', p.x);
202
- line.setAttribute('y2', p.y);
203
- line.setAttribute('stroke', '#FF0000');
204
- line.setAttribute('stroke-width', '3');
205
- line.setAttribute('marker-end', 'url(#kg-arrowhead)');
206
- line.classList.add('annotation');
207
- line.dataset.id = id;
208
- svg.appendChild(line);
209
- dragState = { type: 'create-arrow', id, el: line, sx: p.x, sy: p.y };
210
- } else if (tool === 'label') {
211
- const id = 'a' + nextId++;
212
- const input = document.createElement('input');
213
- input.type = 'text';
214
- input.value = '';
215
- input.placeholder = 'Type label...';
216
- input.style.cssText = 'position:fixed;z-index:9999999;padding:4px 8px;background:#fff;border:none;border-radius:4px;color:#FF0000;font-size:14px;font-family:-apple-system,sans-serif;outline:2px solid #6366f1;min-width:80px;box-shadow:0 2px 8px rgba(0,0,0,0.2);';
217
- input.style.left = (e.clientX) + 'px';
218
- input.style.top = (e.clientY) + 'px';
219
- document.body.appendChild(input);
220
- svg.classList.remove('drawing');
221
- setTimeout(() => input.focus(), 50);
222
-
223
- let labelFinished = false;
224
- function finishLabel() {
225
- if (labelFinished) return;
226
- labelFinished = true;
227
- const text = input.value.trim();
228
- input.remove();
229
- svg.classList.add('drawing');
230
- if (!text) return;
231
-
232
- const g = createLabelGroup(id, p.x, p.y, text);
233
- svg.appendChild(g);
234
- annotations.push({ id, type: 'label', x: p.x, y: p.y, text });
235
- selectEl(g);
236
- g.addEventListener('mousedown', e => startMove(e, id));
237
- }
238
-
239
- input.addEventListener('keydown', e => {
240
- if (e.key === 'Enter') finishLabel();
241
- if (e.key === 'Escape') { labelFinished = true; input.remove(); svg.classList.add('drawing'); }
242
- });
243
- input.addEventListener('blur', finishLabel);
244
- }
245
- });
246
-
247
- document.addEventListener('mousemove', e => {
248
- if (!dragState) return;
249
- const p = getPos(e);
250
-
251
- if (dragState.type === 'create-rect') {
252
- const el = dragState.el;
253
- el.setAttribute('x', Math.min(dragState.sx, p.x));
254
- el.setAttribute('y', Math.min(dragState.sy, p.y));
255
- el.setAttribute('width', Math.abs(p.x - dragState.sx));
256
- el.setAttribute('height', Math.abs(p.y - dragState.sy));
257
- } else if (dragState.type === 'create-arrow') {
258
- dragState.el.setAttribute('x2', p.x);
259
- dragState.el.setAttribute('y2', p.y);
260
- } else if (dragState.type === 'move') {
261
- const a = annotations.find(a => a.id === dragState.id);
262
- if (!a) return;
263
- const dx = p.x - dragState.lastX;
264
- const dy = p.y - dragState.lastY;
265
- dragState.lastX = p.x;
266
- dragState.lastY = p.y;
267
-
268
- if (a.type === 'rect') {
269
- a.x += dx; a.y += dy;
270
- dragState.el.setAttribute('x', a.x);
271
- dragState.el.setAttribute('y', a.y);
272
- } else if (a.type === 'arrow') {
273
- a.fromX += dx; a.fromY += dy; a.toX += dx; a.toY += dy;
274
- dragState.el.setAttribute('x1', a.fromX);
275
- dragState.el.setAttribute('y1', a.fromY);
276
- dragState.el.setAttribute('x2', a.toX);
277
- dragState.el.setAttribute('y2', a.toY);
278
- } else if (a.type === 'label') {
279
- a.x += dx; a.y += dy;
280
- const bg = dragState.el.querySelector('rect');
281
- const txt = dragState.el.querySelector('text');
282
- bg.setAttribute('x', a.x);
283
- bg.setAttribute('y', a.y);
284
- txt.setAttribute('x', a.x + 6);
285
- txt.setAttribute('y', a.y + 16);
286
- }
287
- }
288
- });
289
-
290
- document.addEventListener('mouseup', e => {
291
- if (!dragState) return;
292
- const p = getPos(e);
293
-
294
- if (dragState.type === 'create-rect') {
295
- const w = Math.abs(p.x - dragState.sx);
296
- const h = Math.abs(p.y - dragState.sy);
297
- if (w < 5 && h < 5) { dragState.el.remove(); }
298
- else {
299
- const a = { id: dragState.id, type: 'rect', x: Math.min(dragState.sx, p.x), y: Math.min(dragState.sy, p.y), width: w, height: h };
300
- annotations.push(a);
301
- selectEl(dragState.el);
302
- dragState.el.addEventListener('mousedown', e => startMove(e, dragState.id));
303
- }
304
- } else if (dragState.type === 'create-arrow') {
305
- const dist = Math.hypot(p.x - dragState.sx, p.y - dragState.sy);
306
- if (dist < 5) { dragState.el.remove(); }
307
- else {
308
- const a = { id: dragState.id, type: 'arrow', fromX: dragState.sx, fromY: dragState.sy, toX: p.x, toY: p.y };
309
- annotations.push(a);
310
- selectEl(dragState.el);
311
- dragState.el.addEventListener('mousedown', e => startMove(e, dragState.id));
312
- }
313
- }
314
- dragState = null;
315
- });
316
-
317
- // --- LOAD EXISTING ---
318
- window.__kagemusha.loadAnnotations = function(decorations) {
319
- const dpr = window.__kagemusha.dpr || 1;
320
- decorations.forEach(d => {
321
- const id = 'a' + nextId++;
322
- if (d.type === 'rect' && d.target && 'x' in d.target) {
323
- const rx = d.target.x / dpr, ry = d.target.y / dpr + TOOLBAR_HEIGHT;
324
- const rw = d.target.width / dpr, rh = d.target.height / dpr;
325
- const rect = document.createElementNS(svgNS, 'rect');
326
- rect.setAttribute('x', rx);
327
- rect.setAttribute('y', ry);
328
- rect.setAttribute('width', rw);
329
- rect.setAttribute('height', rh);
330
- rect.setAttribute('fill', 'none');
331
- rect.setAttribute('stroke', d.style?.color || '#FF0000');
332
- rect.setAttribute('stroke-width', '3');
333
- rect.setAttribute('rx', '4');
334
- rect.classList.add('annotation');
335
- rect.dataset.id = id;
336
- svg.appendChild(rect);
337
- annotations.push({ id, type: 'rect', x: rx, y: ry, width: rw, height: rh });
338
- rect.addEventListener('mousedown', e => startMove(e, id));
339
- } else if (d.type === 'arrow' && d.from && 'x' in d.from) {
340
- const ax1 = d.from.x / dpr, ay1 = d.from.y / dpr + TOOLBAR_HEIGHT;
341
- const ax2 = d.to.x / dpr, ay2 = d.to.y / dpr + TOOLBAR_HEIGHT;
342
- const line = document.createElementNS(svgNS, 'line');
343
- line.setAttribute('x1', ax1);
344
- line.setAttribute('y1', ay1);
345
- line.setAttribute('x2', ax2);
346
- line.setAttribute('y2', ay2);
347
- line.setAttribute('stroke', d.style?.color || '#FF0000');
348
- line.setAttribute('stroke-width', '3');
349
- line.setAttribute('marker-end', 'url(#kg-arrowhead)');
350
- line.classList.add('annotation');
351
- line.dataset.id = id;
352
- svg.appendChild(line);
353
- annotations.push({ id, type: 'arrow', fromX: ax1, fromY: ay1, toX: ax2, toY: ay2 });
354
- line.addEventListener('mousedown', e => startMove(e, id));
355
- } else if (d.type === 'label' && d.position && 'x' in d.position) {
356
- const lx = d.position.x / dpr, ly = d.position.y / dpr + TOOLBAR_HEIGHT;
357
- const fontSize = (d.style?.fontSize || 14) / dpr;
358
- const g = createLabelGroup(id, lx, ly, d.text, fontSize);
359
- svg.appendChild(g);
360
- annotations.push({ id, type: 'label', x: lx, y: ly, text: d.text });
361
- g.addEventListener('mousedown', e => startMove(e, id));
362
- }
363
- });
364
- };
365
-
366
- // --- SAVE ---
367
- function save() {
368
- const dpr = window.__kagemusha.dpr || 1;
369
- const s = Math.round;
370
- const decorations = annotations.map(a => {
371
- if (a.type === 'rect') {
372
- return { type: 'rect', target: { x: s(a.x * dpr), y: s((a.y - TOOLBAR_HEIGHT) * dpr), width: s(a.width * dpr), height: s(a.height * dpr) }, style: { color: '#FF0000', strokeWidth: s(3 * dpr) } };
373
- } else if (a.type === 'arrow') {
374
- return { type: 'arrow', from: { x: s(a.fromX * dpr), y: s((a.fromY - TOOLBAR_HEIGHT) * dpr) }, to: { x: s(a.toX * dpr), y: s((a.toY - TOOLBAR_HEIGHT) * dpr) }, style: { color: '#FF0000', strokeWidth: s(3 * dpr) } };
375
- } else if (a.type === 'label') {
376
- return { type: 'label', text: a.text, position: { x: s(a.x * dpr), y: s((a.y - TOOLBAR_HEIGHT) * dpr) }, style: { fontSize: s(14 * dpr), color: '#FF0000', background: '#FFFFFF' } };
377
- }
378
- }).filter(Boolean);
379
-
380
- window.__kagemusha.saved = decorations;
381
- document.title = 'KAGEMUSHA_SAVED';
382
- }
383
- })();
384
- `;
385
- //# sourceMappingURL=inject.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"inject.js","sourceRoot":"","sources":["../../src/editor/inject.ts"],"names":[],"mappings":"AAAA,8EAA8E;AAC9E,qEAAqE;AAErE,MAAM,CAAC,MAAM,aAAa,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA6X5B,CAAC"}
@@ -1,9 +0,0 @@
1
- import type { CaptureResult, KagemushaConfig } from "../types.js";
2
- export interface UploadResult {
3
- id: string;
4
- url: string;
5
- bucket: string;
6
- key: string;
7
- }
8
- export declare function uploadToS3(config: KagemushaConfig, results: CaptureResult[], _projectRoot: string): Promise<UploadResult[]>;
9
- //# sourceMappingURL=upload.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"upload.d.ts","sourceRoot":"","sources":["../../src/lib/upload.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAElE,MAAM,WAAW,YAAY;IAC5B,EAAE,EAAE,MAAM,CAAC;IACX,GAAG,EAAE,MAAM,CAAC;IACZ,MAAM,EAAE,MAAM,CAAC;IACf,GAAG,EAAE,MAAM,CAAC;CACZ;AAED,wBAAsB,UAAU,CAC/B,MAAM,EAAE,eAAe,EACvB,OAAO,EAAE,aAAa,EAAE,EACxB,YAAY,EAAE,MAAM,GAClB,OAAO,CAAC,YAAY,EAAE,CAAC,CAmDzB"}
@@ -1,43 +0,0 @@
1
- import fs from "node:fs";
2
- import { PutObjectCommand, S3Client } from "@aws-sdk/client-s3";
3
- export async function uploadToS3(config, results, _projectRoot) {
4
- if (!config.publish) {
5
- throw new Error("publish config is required for S3 upload");
6
- }
7
- const client = new S3Client({});
8
- const uploadResults = [];
9
- for (const result of results) {
10
- const imagePath = result.annotatedPath;
11
- if (!fs.existsSync(imagePath)) {
12
- console.warn(`Image not found, skipping: ${imagePath}`);
13
- continue;
14
- }
15
- const body = fs.readFileSync(imagePath);
16
- const key = `${result.id}/latest.png`;
17
- await client.send(new PutObjectCommand({
18
- Bucket: config.publish.cdnBucket,
19
- Key: key,
20
- Body: body,
21
- ContentType: "image/png",
22
- CacheControl: "no-cache",
23
- }));
24
- // Also upload with timestamp for history
25
- const historyKey = `${result.id}/${result.timestamp}.png`;
26
- await client.send(new PutObjectCommand({
27
- Bucket: config.publish.cdnBucket,
28
- Key: historyKey,
29
- Body: body,
30
- ContentType: "image/png",
31
- }));
32
- const url = `${config.publish.cdnBaseUrl}/${key}`;
33
- uploadResults.push({
34
- id: result.id,
35
- url,
36
- bucket: config.publish.cdnBucket ?? "",
37
- key,
38
- });
39
- console.log(` Uploaded: ${result.id} → ${url}`);
40
- }
41
- return uploadResults;
42
- }
43
- //# sourceMappingURL=upload.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"upload.js","sourceRoot":"","sources":["../../src/lib/upload.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,EAAE,gBAAgB,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAUhE,MAAM,CAAC,KAAK,UAAU,UAAU,CAC/B,MAAuB,EACvB,OAAwB,EACxB,YAAoB;IAEpB,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;QACrB,MAAM,IAAI,KAAK,CAAC,0CAA0C,CAAC,CAAC;IAC7D,CAAC;IAED,MAAM,MAAM,GAAG,IAAI,QAAQ,CAAC,EAAE,CAAC,CAAC;IAChC,MAAM,aAAa,GAAmB,EAAE,CAAC;IAEzC,KAAK,MAAM,MAAM,IAAI,OAAO,EAAE,CAAC;QAC9B,MAAM,SAAS,GAAG,MAAM,CAAC,aAAa,CAAC;QACvC,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,SAAS,CAAC,EAAE,CAAC;YAC/B,OAAO,CAAC,IAAI,CAAC,8BAA8B,SAAS,EAAE,CAAC,CAAC;YACxD,SAAS;QACV,CAAC;QAED,MAAM,IAAI,GAAG,EAAE,CAAC,YAAY,CAAC,SAAS,CAAC,CAAC;QACxC,MAAM,GAAG,GAAG,GAAG,MAAM,CAAC,EAAE,aAAa,CAAC;QAEtC,MAAM,MAAM,CAAC,IAAI,CAChB,IAAI,gBAAgB,CAAC;YACpB,MAAM,EAAE,MAAM,CAAC,OAAO,CAAC,SAAS;YAChC,GAAG,EAAE,GAAG;YACR,IAAI,EAAE,IAAI;YACV,WAAW,EAAE,WAAW;YACxB,YAAY,EAAE,UAAU;SACxB,CAAC,CACF,CAAC;QAEF,yCAAyC;QACzC,MAAM,UAAU,GAAG,GAAG,MAAM,CAAC,EAAE,IAAI,MAAM,CAAC,SAAS,MAAM,CAAC;QAC1D,MAAM,MAAM,CAAC,IAAI,CAChB,IAAI,gBAAgB,CAAC;YACpB,MAAM,EAAE,MAAM,CAAC,OAAO,CAAC,SAAS;YAChC,GAAG,EAAE,UAAU;YACf,IAAI,EAAE,IAAI;YACV,WAAW,EAAE,WAAW;SACxB,CAAC,CACF,CAAC;QAEF,MAAM,GAAG,GAAG,GAAG,MAAM,CAAC,OAAO,CAAC,UAAU,IAAI,GAAG,EAAE,CAAC;QAClD,aAAa,CAAC,IAAI,CAAC;YAClB,EAAE,EAAE,MAAM,CAAC,EAAE;YACb,GAAG;YACH,MAAM,EAAE,MAAM,CAAC,OAAO,CAAC,SAAS,IAAI,EAAE;YACtC,GAAG;SACH,CAAC,CAAC;QAEH,OAAO,CAAC,GAAG,CAAC,eAAe,MAAM,CAAC,EAAE,MAAM,GAAG,EAAE,CAAC,CAAC;IAClD,CAAC;IAED,OAAO,aAAa,CAAC;AACtB,CAAC"}