jammincms 0.1.0 → 0.1.3

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.
@@ -0,0 +1,584 @@
1
+ var m=Object.defineProperty;var h=(l,t,e)=>t in l?m(l,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):l[t]=e;var o=(l,t,e)=>h(l,typeof t!="symbol"?t+"":t,e);function u(l){const t=[];let e=l;for(;e&&e!==document.body;){let i=e.tagName.toLowerCase();if(e.id){i=`#${e.id}`,t.unshift(i);break}if(e.className&&typeof e.className=="string"){const a=e.className.split(/\s+/).filter(s=>s&&!s.startsWith("jammin-")).slice(0,2);a.length>0&&(i+=`.${a.join(".")}`)}const n=e.parentElement;if(n){const a=Array.from(n.children).filter(s=>s.tagName===e.tagName);if(a.length>1){const s=a.indexOf(e)+1;i+=`:nth-child(${s})`}}t.unshift(i),e=e.parentElement}return t.join(" > ")}function p(l){const t=[];let e=l;for(;e&&e!==document.body;){let i=e.tagName.toLowerCase();if(e.id)i+=`#${e.id}`;else if(e.className&&typeof e.className=="string"){const n=e.className.split(/\s+/).filter(a=>a&&!a.startsWith("jammin-")).slice(0,2);n.length>0&&(i+=`.${n.join(".")}`)}if(t.unshift(i),e=e.parentElement,t.length>=4)break}return t.join(" > ")}class b{constructor(){o(this,"trackedElements",new Map);o(this,"config",null);o(this,"mutationObserver",null);o(this,"enabled",!1);o(this,"onDirtyChange",null);o(this,"selectionToolbar",null);this.handleInput=this.handleInput.bind(this),this.handleKeydown=this.handleKeydown.bind(this),this.handleSelectionChange=this.handleSelectionChange.bind(this),this.handleFormatCommand=this.handleFormatCommand.bind(this)}setConfig(t){this.config=t}setDirtyChangeHandler(t){this.onDirtyChange=t}enable(){this.enabled||!this.config||(this.enabled=!0,this.setupEditableElements(),this.createSelectionToolbar(),this.startObserving(),document.addEventListener("keydown",this.handleKeydown),document.addEventListener("selectionchange",this.handleSelectionChange))}disable(){this.enabled&&(this.enabled=!1,this.stopObserving(),this.removeAllEditable(),this.destroySelectionToolbar(),document.removeEventListener("keydown",this.handleKeydown),document.removeEventListener("selectionchange",this.handleSelectionChange))}isEnabled(){return this.enabled}setupEditableElements(){if(this.config)for(const t of this.config.editableSelectors)document.querySelectorAll(t).forEach(i=>this.makeEditable(i))}makeEditable(t){if(this.trackedElements.has(t))return;t.contentEditable="true",t.classList.add("jammin-editable");const e={element:t,originalContent:t.innerHTML,selector:u(t),elementPath:p(t),isDirty:!1};this.trackedElements.set(t,e),t.addEventListener("input",this.handleInput)}removeEditable(t){this.trackedElements.get(t)&&(t.contentEditable="false",t.classList.remove("jammin-editable","jammin-dirty"),t.removeEventListener("input",this.handleInput),this.trackedElements.delete(t))}removeAllEditable(){for(const[t]of this.trackedElements)this.removeEditable(t)}handleInput(t){const e=t.target,i=this.trackedElements.get(e);if(!i)return;const a=e.innerHTML!==i.originalContent;a!==i.isDirty&&(i.isDirty=a,e.classList.toggle("jammin-dirty",a),this.notifyDirtyChange())}handleKeydown(t){if((t.metaKey||t.ctrlKey)&&t.key==="s"&&this.hasDirtyElements()&&(t.preventDefault(),document.dispatchEvent(new CustomEvent("jammin:save"))),(t.metaKey||t.ctrlKey)&&this.isInEditableArea())switch(t.key.toLowerCase()){case"b":t.preventDefault(),this.execFormat("bold");break;case"i":t.preventDefault(),this.execFormat("italic");break;case"k":t.preventDefault(),this.promptAndCreateLink();break}if(t.key==="Escape"){const e=document.activeElement;e&&this.trackedElements.has(e)&&(this.revertElement(e),e.blur())}}isInEditableArea(){var n,a;const t=window.getSelection();if(!t||t.isCollapsed)return!1;const e=t.anchorNode;return e?!!((a=(n=e.parentElement||e)==null?void 0:n.closest)==null?void 0:a.call(n,'[contenteditable="true"]')):!1}createSelectionToolbar(){if(this.selectionToolbar)return;const t=document.createElement("div");t.className="jammin-selection-toolbar",t.innerHTML=`
2
+ <button data-cmd="bold" title="Bold (Cmd+B)"><strong>B</strong></button>
3
+ <button data-cmd="italic" title="Italic (Cmd+I)"><em>I</em></button>
4
+ <button data-cmd="createLink" title="Link (Cmd+K)">Link</button>
5
+ <span class="jammin-sel-divider"></span>
6
+ <button data-cmd="formatBlock" data-value="h2" title="Heading 2">H2</button>
7
+ <button data-cmd="formatBlock" data-value="h3" title="Heading 3">H3</button>
8
+ <button data-cmd="formatBlock" data-value="p" title="Paragraph">P</button>
9
+ `,t.querySelectorAll("button").forEach(e=>{e.addEventListener("mousedown",i=>{i.preventDefault()}),e.addEventListener("click",this.handleFormatCommand)}),document.body.appendChild(t),this.selectionToolbar=t}destroySelectionToolbar(){this.selectionToolbar&&(this.selectionToolbar.remove(),this.selectionToolbar=null)}handleSelectionChange(){var n,a;const t=window.getSelection();if(!t||t.isCollapsed||t.toString().trim()===""){this.hideSelectionToolbar();return}const e=t.anchorNode;if(!e)return;if(!((a=(n=e.parentElement||e)==null?void 0:n.closest)==null?void 0:a.call(n,'[contenteditable="true"]'))){this.hideSelectionToolbar();return}this.showSelectionToolbar(t)}showSelectionToolbar(t){if(!this.selectionToolbar)return;const i=t.getRangeAt(0).getBoundingClientRect();this.selectionToolbar.style.display="flex",this.selectionToolbar.style.top=i.top-40+window.scrollY+"px",this.selectionToolbar.style.left=i.left+i.width/2-this.selectionToolbar.offsetWidth/2+"px"}hideSelectionToolbar(){this.selectionToolbar&&(this.selectionToolbar.style.display="none")}handleFormatCommand(t){const e=t.target,i=e.dataset.cmd,n=e.dataset.value;i&&(i==="createLink"?this.promptAndCreateLink():i==="formatBlock"&&n?this.execFormat(i,"<"+n+">"):this.execFormat(i),this.hideSelectionToolbar())}execFormat(t,e=null){document.execCommand(t,!1,e),this.markAllEditedElementsDirty()}promptAndCreateLink(){const t=prompt("Enter URL:");t&&(document.execCommand("createLink",!1,t),this.markAllEditedElementsDirty()),this.hideSelectionToolbar()}markAllEditedElementsDirty(){for(const[t,e]of this.trackedElements){const n=t.innerHTML!==e.originalContent;n!==e.isDirty&&(e.isDirty=n,t.classList.toggle("jammin-dirty",n))}this.notifyDirtyChange()}startObserving(){this.mutationObserver||(this.mutationObserver=new MutationObserver(t=>{for(const e of t)for(const i of e.addedNodes)i instanceof HTMLElement&&this.checkNewElement(i)}),this.mutationObserver.observe(document.body,{childList:!0,subtree:!0}))}stopObserving(){this.mutationObserver&&(this.mutationObserver.disconnect(),this.mutationObserver=null)}checkNewElement(t){if(this.config)for(const e of this.config.editableSelectors)t.matches(e)&&this.makeEditable(t),t.querySelectorAll(e).forEach(i=>{this.makeEditable(i)})}notifyDirtyChange(){this.onDirtyChange&&this.onDirtyChange(this.hasDirtyElements())}hasDirtyElements(){for(const[,t]of this.trackedElements)if(t.isDirty)return!0;return!1}getDirtyChanges(){const t=[];for(const[e,i]of this.trackedElements)i.isDirty&&t.push({elementPath:i.elementPath,selector:i.selector,originalContent:i.originalContent,newContent:e.innerHTML});return t}revertElement(t){const e=this.trackedElements.get(t);e&&(t.innerHTML=e.originalContent,e.isDirty=!1,t.classList.remove("jammin-dirty"),this.notifyDirtyChange())}revertAll(){for(const[t,e]of this.trackedElements)e.isDirty&&(t.innerHTML=e.originalContent,e.isDirty=!1,t.classList.remove("jammin-dirty"));this.notifyDirtyChange()}markSaved(){for(const[t,e]of this.trackedElements)e.isDirty&&(e.originalContent=t.innerHTML,e.isDirty=!1,t.classList.remove("jammin-dirty"));this.notifyDirtyChange()}getDirtyCount(){let t=0;for(const[,e]of this.trackedElements)e.isDirty&&t++;return t}}function g(){return`
10
+ /* Reset */
11
+ *, *::before, *::after {
12
+ box-sizing: border-box;
13
+ margin: 0;
14
+ padding: 0;
15
+ }
16
+
17
+ /* Variables */
18
+ :host {
19
+ --jammin-primary: #6366f1;
20
+ --jammin-primary-hover: #4f46e5;
21
+ --jammin-bg: #1e1e2e;
22
+ --jammin-bg-light: #2a2a3e;
23
+ --jammin-text: #e0e0e0;
24
+ --jammin-text-muted: #a0a0a0;
25
+ --jammin-border: #3a3a4e;
26
+ --jammin-success: #22c55e;
27
+ --jammin-warning: #f59e0b;
28
+ --jammin-error: #ef4444;
29
+ --jammin-radius: 8px;
30
+ --jammin-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
31
+ font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
32
+ font-size: 14px;
33
+ line-height: 1.5;
34
+ }
35
+
36
+ /* Toggle Button */
37
+ .jammin-toggle {
38
+ position: fixed;
39
+ bottom: 20px;
40
+ right: 20px;
41
+ width: 48px;
42
+ height: 48px;
43
+ border-radius: 50%;
44
+ background: var(--jammin-primary);
45
+ border: none;
46
+ color: white;
47
+ cursor: pointer;
48
+ display: flex;
49
+ align-items: center;
50
+ justify-content: center;
51
+ box-shadow: var(--jammin-shadow);
52
+ transition: transform 0.2s, background-color 0.2s;
53
+ z-index: 2147483647;
54
+ }
55
+
56
+ .jammin-toggle:hover {
57
+ background: var(--jammin-primary-hover);
58
+ transform: scale(1.05);
59
+ }
60
+
61
+ .jammin-toggle.hidden {
62
+ transform: scale(0);
63
+ pointer-events: none;
64
+ }
65
+
66
+ .jammin-badge {
67
+ position: absolute;
68
+ top: -4px;
69
+ right: -4px;
70
+ min-width: 20px;
71
+ height: 20px;
72
+ background: var(--jammin-error);
73
+ border-radius: 10px;
74
+ font-size: 12px;
75
+ font-weight: 600;
76
+ display: flex;
77
+ align-items: center;
78
+ justify-content: center;
79
+ padding: 0 6px;
80
+ }
81
+
82
+ /* Toolbar Container */
83
+ .jammin-toolbar {
84
+ position: fixed;
85
+ bottom: 20px;
86
+ right: 20px;
87
+ z-index: 2147483647;
88
+ }
89
+
90
+ /* Panel Wrapper - contains both main panel and output drawer */
91
+ .jammin-panel-wrapper {
92
+ position: absolute;
93
+ bottom: 0;
94
+ right: 0;
95
+ display: flex;
96
+ align-items: flex-end;
97
+ gap: 8px;
98
+ transform: scale(0.9);
99
+ opacity: 0;
100
+ pointer-events: none;
101
+ transition: transform 0.2s, opacity 0.2s;
102
+ transform-origin: bottom right;
103
+ }
104
+
105
+ .jammin-panel-wrapper.expanded {
106
+ transform: scale(1);
107
+ opacity: 1;
108
+ pointer-events: auto;
109
+ }
110
+
111
+ /* Main Panel */
112
+ .jammin-panel {
113
+ width: 280px;
114
+ background: var(--jammin-bg);
115
+ border: 1px solid var(--jammin-border);
116
+ border-radius: var(--jammin-radius);
117
+ box-shadow: var(--jammin-shadow);
118
+ overflow: hidden;
119
+ }
120
+
121
+ .jammin-header {
122
+ display: flex;
123
+ align-items: center;
124
+ justify-content: space-between;
125
+ padding: 12px 16px;
126
+ background: var(--jammin-bg-light);
127
+ border-bottom: 1px solid var(--jammin-border);
128
+ }
129
+
130
+ .jammin-title {
131
+ font-weight: 600;
132
+ color: var(--jammin-text);
133
+ }
134
+
135
+ .jammin-close {
136
+ background: none;
137
+ border: none;
138
+ color: var(--jammin-text-muted);
139
+ cursor: pointer;
140
+ padding: 4px;
141
+ border-radius: 4px;
142
+ display: flex;
143
+ align-items: center;
144
+ justify-content: center;
145
+ }
146
+
147
+ .jammin-close:hover {
148
+ background: var(--jammin-border);
149
+ color: var(--jammin-text);
150
+ }
151
+
152
+ .jammin-content {
153
+ padding: 16px;
154
+ }
155
+
156
+ .jammin-row {
157
+ display: flex;
158
+ align-items: center;
159
+ gap: 12px;
160
+ margin-bottom: 16px;
161
+ color: var(--jammin-text);
162
+ }
163
+
164
+ /* Toggle Switch */
165
+ .jammin-switch {
166
+ position: relative;
167
+ width: 40px;
168
+ height: 22px;
169
+ flex-shrink: 0;
170
+ }
171
+
172
+ .jammin-switch input {
173
+ opacity: 0;
174
+ width: 0;
175
+ height: 0;
176
+ }
177
+
178
+ .jammin-slider {
179
+ position: absolute;
180
+ cursor: pointer;
181
+ top: 0;
182
+ left: 0;
183
+ right: 0;
184
+ bottom: 0;
185
+ background-color: var(--jammin-border);
186
+ transition: 0.2s;
187
+ border-radius: 22px;
188
+ }
189
+
190
+ .jammin-slider:before {
191
+ position: absolute;
192
+ content: "";
193
+ height: 16px;
194
+ width: 16px;
195
+ left: 3px;
196
+ bottom: 3px;
197
+ background-color: white;
198
+ transition: 0.2s;
199
+ border-radius: 50%;
200
+ }
201
+
202
+ .jammin-switch input:checked + .jammin-slider {
203
+ background-color: var(--jammin-primary);
204
+ }
205
+
206
+ .jammin-switch input:checked + .jammin-slider:before {
207
+ transform: translateX(18px);
208
+ }
209
+
210
+ /* Actions */
211
+ .jammin-actions {
212
+ display: flex;
213
+ gap: 8px;
214
+ margin-bottom: 12px;
215
+ }
216
+
217
+ .jammin-btn {
218
+ flex: 1;
219
+ display: flex;
220
+ align-items: center;
221
+ justify-content: center;
222
+ gap: 6px;
223
+ padding: 8px 12px;
224
+ border: 1px solid var(--jammin-border);
225
+ border-radius: 6px;
226
+ background: var(--jammin-bg-light);
227
+ color: var(--jammin-text);
228
+ font-size: 13px;
229
+ cursor: pointer;
230
+ transition: background-color 0.2s, border-color 0.2s;
231
+ }
232
+
233
+ .jammin-btn:hover:not(:disabled) {
234
+ background: var(--jammin-border);
235
+ }
236
+
237
+ .jammin-btn:disabled {
238
+ opacity: 0.5;
239
+ cursor: not-allowed;
240
+ }
241
+
242
+ .jammin-btn-primary {
243
+ background: var(--jammin-primary);
244
+ border-color: var(--jammin-primary);
245
+ }
246
+
247
+ .jammin-btn-primary:hover:not(:disabled) {
248
+ background: var(--jammin-primary-hover);
249
+ }
250
+
251
+ .jammin-divider {
252
+ height: 1px;
253
+ background: var(--jammin-border);
254
+ margin: 12px 0;
255
+ }
256
+
257
+ .jammin-status-text {
258
+ font-size: 12px;
259
+ color: var(--jammin-text-muted);
260
+ text-align: center;
261
+ }
262
+
263
+ /* Output Drawer - slides out to the left */
264
+ .jammin-output-drawer {
265
+ width: 350px;
266
+ max-height: 400px;
267
+ background: var(--jammin-bg);
268
+ border: 1px solid var(--jammin-border);
269
+ border-radius: var(--jammin-radius);
270
+ box-shadow: var(--jammin-shadow);
271
+ display: flex;
272
+ flex-direction: column;
273
+ transform: translateX(calc(100% + 16px));
274
+ opacity: 0;
275
+ pointer-events: none;
276
+ transition: transform 0.3s, opacity 0.3s;
277
+ position: absolute;
278
+ right: calc(100% + 8px);
279
+ bottom: 0;
280
+ }
281
+
282
+ .jammin-output-drawer.expanded {
283
+ transform: translateX(0);
284
+ opacity: 1;
285
+ pointer-events: auto;
286
+ }
287
+
288
+ .jammin-output-header {
289
+ display: flex;
290
+ align-items: center;
291
+ justify-content: space-between;
292
+ padding: 10px 14px;
293
+ background: var(--jammin-bg-light);
294
+ border-bottom: 1px solid var(--jammin-border);
295
+ border-radius: var(--jammin-radius) var(--jammin-radius) 0 0;
296
+ flex-shrink: 0;
297
+ }
298
+
299
+ .jammin-output-title {
300
+ display: flex;
301
+ align-items: center;
302
+ gap: 8px;
303
+ color: var(--jammin-text);
304
+ font-weight: 500;
305
+ }
306
+
307
+ .jammin-output-close {
308
+ background: none;
309
+ border: none;
310
+ color: var(--jammin-text-muted);
311
+ cursor: pointer;
312
+ padding: 4px;
313
+ border-radius: 4px;
314
+ display: flex;
315
+ align-items: center;
316
+ justify-content: center;
317
+ }
318
+
319
+ .jammin-output-close:hover {
320
+ background: var(--jammin-border);
321
+ color: var(--jammin-text);
322
+ }
323
+
324
+ .jammin-output-body {
325
+ flex: 1;
326
+ overflow: auto;
327
+ padding: 12px;
328
+ min-height: 100px;
329
+ max-height: 250px;
330
+ }
331
+
332
+ .jammin-output-content {
333
+ font-family: 'SF Mono', 'Menlo', 'Monaco', monospace;
334
+ font-size: 12px;
335
+ line-height: 1.6;
336
+ color: var(--jammin-text);
337
+ white-space: pre-wrap;
338
+ word-break: break-word;
339
+ margin: 0;
340
+ }
341
+
342
+ .jammin-output-footer {
343
+ padding: 10px 14px;
344
+ border-top: 1px solid var(--jammin-border);
345
+ background: var(--jammin-bg-light);
346
+ border-radius: 0 0 var(--jammin-radius) var(--jammin-radius);
347
+ flex-shrink: 0;
348
+ }
349
+
350
+ .jammin-output-footer:empty {
351
+ display: none;
352
+ }
353
+
354
+ /* Status Indicator */
355
+ .jammin-status-indicator {
356
+ width: 8px;
357
+ height: 8px;
358
+ border-radius: 50%;
359
+ background: var(--jammin-text-muted);
360
+ flex-shrink: 0;
361
+ }
362
+
363
+ .jammin-status-indicator.phase-thinking {
364
+ background: var(--jammin-warning);
365
+ animation: pulse 1.5s infinite;
366
+ }
367
+
368
+ .jammin-status-indicator.phase-editing {
369
+ background: var(--jammin-primary);
370
+ animation: pulse 1s infinite;
371
+ }
372
+
373
+ .jammin-status-indicator.phase-complete {
374
+ background: var(--jammin-success);
375
+ }
376
+
377
+ .jammin-status-indicator.phase-error {
378
+ background: var(--jammin-error);
379
+ }
380
+
381
+ @keyframes pulse {
382
+ 0%, 100% { opacity: 1; }
383
+ 50% { opacity: 0.5; }
384
+ }
385
+
386
+ /* Files list */
387
+ .jammin-files-header {
388
+ font-size: 12px;
389
+ font-weight: 500;
390
+ color: var(--jammin-text);
391
+ margin-bottom: 6px;
392
+ }
393
+
394
+ .jammin-files-list {
395
+ list-style: none;
396
+ font-size: 12px;
397
+ color: var(--jammin-success);
398
+ }
399
+
400
+ .jammin-files-list li {
401
+ padding: 2px 0;
402
+ }
403
+
404
+ .jammin-files-list li::before {
405
+ content: "\\2713 ";
406
+ }
407
+
408
+ .jammin-error {
409
+ font-size: 12px;
410
+ color: var(--jammin-error);
411
+ }
412
+ `}function f(){return`
413
+ .jammin-editable {
414
+ outline: 2px dashed transparent;
415
+ outline-offset: 2px;
416
+ transition: outline-color 0.2s;
417
+ }
418
+
419
+ /* Show dashed outline on all editable elements when editing is active */
420
+ body.jammin-editing-active .jammin-editable {
421
+ outline-color: rgba(99, 102, 241, 0.5);
422
+ }
423
+
424
+ .jammin-editable:focus {
425
+ outline-color: #6366f1;
426
+ outline-style: solid;
427
+ }
428
+
429
+ .jammin-editable.jammin-dirty {
430
+ outline-color: #f59e0b;
431
+ }
432
+
433
+ .jammin-editable.jammin-dirty:focus {
434
+ outline-color: #f59e0b;
435
+ outline-style: solid;
436
+ }
437
+
438
+ /* Selection Toolbar */
439
+ .jammin-selection-toolbar {
440
+ position: absolute;
441
+ display: none;
442
+ align-items: center;
443
+ gap: 2px;
444
+ padding: 4px 6px;
445
+ background: #1e1e2e;
446
+ border: 1px solid #3a3a4e;
447
+ border-radius: 6px;
448
+ box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
449
+ z-index: 2147483646;
450
+ font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
451
+ }
452
+
453
+ .jammin-selection-toolbar button {
454
+ display: flex;
455
+ align-items: center;
456
+ justify-content: center;
457
+ min-width: 28px;
458
+ height: 28px;
459
+ padding: 0 8px;
460
+ background: transparent;
461
+ border: none;
462
+ border-radius: 4px;
463
+ color: #e0e0e0;
464
+ font-size: 13px;
465
+ cursor: pointer;
466
+ transition: background-color 0.15s;
467
+ }
468
+
469
+ .jammin-selection-toolbar button:hover {
470
+ background: #3a3a4e;
471
+ }
472
+
473
+ .jammin-selection-toolbar button strong {
474
+ font-weight: 700;
475
+ }
476
+
477
+ .jammin-selection-toolbar button em {
478
+ font-style: italic;
479
+ }
480
+
481
+ .jammin-selection-toolbar .jammin-sel-divider {
482
+ width: 1px;
483
+ height: 20px;
484
+ background: #3a3a4e;
485
+ margin: 0 4px;
486
+ }
487
+ `}class y{constructor(){o(this,"container",null);o(this,"shadowRoot",null);o(this,"expanded",!1);o(this,"outputExpanded",!1);o(this,"editEnabled",!1);o(this,"dirtyCount",0);o(this,"saving",!1);o(this,"config",null);o(this,"callbacks",null);o(this,"output","");o(this,"phase","idle");o(this,"filesChanged",[]);o(this,"error",null)}create(t,e){if(this.container)return;this.config=t,this.callbacks=e,this.container=document.createElement("div"),this.container.id="jammin-toolbar-container",this.shadowRoot=this.container.attachShadow({mode:"closed"});const i=document.createElement("style");i.textContent=g(),this.shadowRoot.appendChild(i);const n=document.createElement("div");n.className="jammin-toolbar",n.innerHTML=this.getToolbarHTML(),this.shadowRoot.appendChild(n),document.body.appendChild(this.container),this.setupEventListeners(),this.setExpanded(!1)}destroy(){this.container&&(this.container.remove(),this.container=null,this.shadowRoot=null)}getToolbarHTML(){var t;return`
488
+ <button class="jammin-toggle" title="Jammin CMS">
489
+ <svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
490
+ <path d="M12 19l7-7 3 3-7 7-3-3z"></path>
491
+ <path d="M18 13l-1.5-7.5L2 2l3.5 14.5L13 18l5-5z"></path>
492
+ <path d="M2 2l7.586 7.586"></path>
493
+ <circle cx="11" cy="11" r="2"></circle>
494
+ </svg>
495
+ <span class="jammin-badge" style="display: none;">0</span>
496
+ </button>
497
+ <div class="jammin-panel-wrapper">
498
+ <div class="jammin-output-drawer">
499
+ <div class="jammin-output-header">
500
+ <div class="jammin-output-title">
501
+ <span class="jammin-status-indicator"></span>
502
+ <span class="jammin-status-phase">Ready</span>
503
+ </div>
504
+ <button class="jammin-output-close" title="Close">
505
+ <svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
506
+ <line x1="18" y1="6" x2="6" y2="18"></line>
507
+ <line x1="6" y1="6" x2="18" y2="18"></line>
508
+ </svg>
509
+ </button>
510
+ </div>
511
+ <div class="jammin-output-body">
512
+ <pre class="jammin-output-content"></pre>
513
+ </div>
514
+ <div class="jammin-output-footer"></div>
515
+ </div>
516
+ <div class="jammin-panel">
517
+ <div class="jammin-header">
518
+ <span class="jammin-title">${((t=this.config)==null?void 0:t.name)||"Jammin CMS"}</span>
519
+ <button class="jammin-close" title="Close">
520
+ <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
521
+ <line x1="18" y1="6" x2="6" y2="18"></line>
522
+ <line x1="6" y1="6" x2="18" y2="18"></line>
523
+ </svg>
524
+ </button>
525
+ </div>
526
+ <div class="jammin-content">
527
+ <div class="jammin-row">
528
+ <label class="jammin-switch">
529
+ <input type="checkbox" id="jammin-edit-toggle">
530
+ <span class="jammin-slider"></span>
531
+ </label>
532
+ <span>Enable editing</span>
533
+ </div>
534
+ <div class="jammin-actions">
535
+ <button class="jammin-btn jammin-btn-primary" id="jammin-save" disabled>
536
+ <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
537
+ <path d="M19 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h11l5 5v11a2 2 0 0 1-2 2z"></path>
538
+ <polyline points="17 21 17 13 7 13 7 21"></polyline>
539
+ <polyline points="7 3 7 8 15 8"></polyline>
540
+ </svg>
541
+ <span>Save</span>
542
+ </button>
543
+ <button class="jammin-btn" id="jammin-revert" disabled>
544
+ <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
545
+ <polyline points="1 4 1 10 7 10"></polyline>
546
+ <path d="M3.51 15a9 9 0 1 0 2.13-9.36L1 10"></path>
547
+ </svg>
548
+ <span>Revert</span>
549
+ </button>
550
+ </div>
551
+ <div class="jammin-divider"></div>
552
+ <div class="jammin-actions">
553
+ <button class="jammin-btn" id="jammin-editor">
554
+ <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
555
+ <polyline points="16 18 22 12 16 6"></polyline>
556
+ <polyline points="8 6 2 12 8 18"></polyline>
557
+ </svg>
558
+ <span>Open Editor</span>
559
+ </button>
560
+ <button class="jammin-btn" id="jammin-output-toggle">
561
+ <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
562
+ <rect x="3" y="3" width="18" height="18" rx="2" ry="2"></rect>
563
+ <line x1="3" y1="9" x2="21" y2="9"></line>
564
+ </svg>
565
+ <span>Output</span>
566
+ </button>
567
+ </div>
568
+ <div class="jammin-status-text">
569
+ <span id="jammin-status-message">Ready</span>
570
+ </div>
571
+ </div>
572
+ </div>
573
+ </div>
574
+ `}setupEventListeners(){if(!this.shadowRoot)return;const t=this.shadowRoot.querySelector(".jammin-toggle");t==null||t.addEventListener("click",()=>this.setExpanded(!this.expanded));const e=this.shadowRoot.querySelector(".jammin-close");e==null||e.addEventListener("click",()=>this.setExpanded(!1));const i=this.shadowRoot.querySelector("#jammin-edit-toggle");i==null||i.addEventListener("change",()=>{var r;this.editEnabled=i.checked,(r=this.callbacks)==null||r.onToggleEdit(this.editEnabled),this.updateUI()});const n=this.shadowRoot.querySelector("#jammin-save");n==null||n.addEventListener("click",()=>{var r;!this.saving&&this.dirtyCount>0&&((r=this.callbacks)==null||r.onSave())});const a=this.shadowRoot.querySelector("#jammin-revert");a==null||a.addEventListener("click",()=>{var r;this.dirtyCount>0&&((r=this.callbacks)==null||r.onRevert())});const s=this.shadowRoot.querySelector("#jammin-editor");s==null||s.addEventListener("click",()=>{var r;(r=this.callbacks)==null||r.onOpenEditor()});const d=this.shadowRoot.querySelector("#jammin-output-toggle");d==null||d.addEventListener("click",()=>{this.setOutputExpanded(!this.outputExpanded)});const c=this.shadowRoot.querySelector(".jammin-output-close");c==null||c.addEventListener("click",()=>{this.setOutputExpanded(!1)})}setExpanded(t){var n,a;this.expanded=t;const e=(n=this.shadowRoot)==null?void 0:n.querySelector(".jammin-panel-wrapper"),i=(a=this.shadowRoot)==null?void 0:a.querySelector(".jammin-toggle");t?(e==null||e.classList.add("expanded"),i==null||i.classList.add("hidden")):(e==null||e.classList.remove("expanded"),i==null||i.classList.remove("hidden"),this.setOutputExpanded(!1))}setOutputExpanded(t){var i;this.outputExpanded=t;const e=(i=this.shadowRoot)==null?void 0:i.querySelector(".jammin-output-drawer");t?e==null||e.classList.add("expanded"):e==null||e.classList.remove("expanded")}updateDirtyCount(t){this.dirtyCount=t,this.updateUI()}setSaving(t){this.saving=t,this.updateUI()}setStatus(t){var i;const e=(i=this.shadowRoot)==null?void 0:i.querySelector("#jammin-status-message");e&&(e.textContent=t)}updateUI(){if(!this.shadowRoot)return;const t=this.shadowRoot.querySelector(".jammin-badge");t&&(t.style.display=this.dirtyCount>0?"flex":"none",t.textContent=String(this.dirtyCount));const e=this.shadowRoot.querySelector("#jammin-save");if(e){e.disabled=this.dirtyCount===0||this.saving;const a=e.querySelector("span");a&&(a.textContent=this.saving?"Saving...":"Save")}const i=this.shadowRoot.querySelector("#jammin-revert");i&&(i.disabled=this.dirtyCount===0||this.saving);const n=this.shadowRoot.querySelector("#jammin-edit-toggle");n&&n.checked!==this.editEnabled&&(n.checked=this.editEnabled),this.updateOutputUI()}updateOutputUI(){if(!this.shadowRoot)return;const t=this.shadowRoot.querySelector(".jammin-status-indicator"),e=this.shadowRoot.querySelector(".jammin-status-phase");if(t&&(t.className="jammin-status-indicator",this.phase!=="idle"&&t.classList.add(`phase-${this.phase}`),this.error&&t.classList.add("phase-error")),e)if(this.error)e.textContent="Error";else switch(this.phase){case"idle":e.textContent="Ready";break;case"thinking":e.textContent="Thinking...";break;case"editing":e.textContent="Editing files...";break;case"complete":e.textContent="Complete";break}const i=this.shadowRoot.querySelector(".jammin-output-content");if(i){const s=this.output.replace(/\x1b\[[0-9;]*m/g,"").replace(/\r/g,"");i.textContent=s||"Waiting for output..."}const n=this.shadowRoot.querySelector(".jammin-output-footer");n&&(this.filesChanged.length>0?n.innerHTML=`
575
+ <div class="jammin-files-header">Files modified:</div>
576
+ <ul class="jammin-files-list">
577
+ ${this.filesChanged.map(s=>`<li>${this.escapeHtml(s)}</li>`).join("")}
578
+ </ul>
579
+ `:this.error?n.innerHTML=`<div class="jammin-error">${this.escapeHtml(this.error)}</div>`:n.innerHTML="");const a=this.shadowRoot.querySelector(".jammin-output-body");a&&(a.scrollTop=a.scrollHeight)}setEditEnabled(t){this.editEnabled=t,this.updateUI()}resetOutput(){this.output="",this.phase="thinking",this.filesChanged=[],this.error=null,this.updateOutputUI()}addProgress(t){this.output+=t.output,this.phase=t.phase,this.updateOutputUI()}setComplete(t){this.phase="complete",this.filesChanged=t.filesChanged||[],this.error=t.error||null,this.updateOutputUI()}showOutput(){this.setOutputExpanded(!0)}hideOutput(){this.setOutputExpanded(!1)}toggleOutput(){this.setOutputExpanded(!this.outputExpanded)}escapeHtml(t){const e=document.createElement("div");return e.textContent=t,e.innerHTML}}class v{constructor(){o(this,"config",null);o(this,"editor",null);o(this,"toolbar",null);o(this,"currentJobId",null);o(this,"styleElement",null);o(this,"activated",!1);o(this,"pendingChanges",null);chrome.runtime.onMessage.addListener((t,e,i)=>t.action==="activate_cms"?(this.activate().then(()=>{i({success:!0,activated:this.activated})}),!0):t.action==="cms_status"?(i({activated:this.activated}),!1):(this.activated&&this.handleBackgroundMessage(t),!1))}async activate(){if(this.activated)return;const t=await this.getConfigForCurrentPage();if(!t){console.log("[Jammin] No matching config for this page");return}this.config=t,this.activated=!0,console.log("[Jammin] Activated for:",t.name),this.editor=new b,this.toolbar=new y,this.injectPageStyles(),this.editor.setConfig(t),this.editor.setDirtyChangeHandler(()=>{var e,i;(i=this.toolbar)==null||i.updateDirtyCount(((e=this.editor)==null?void 0:e.getDirtyCount())||0)}),this.toolbar.create(t,{onSave:()=>this.handleSave(),onRevert:()=>this.handleRevert(),onToggleEdit:e=>this.handleToggleEdit(e),onOpenEditor:()=>this.handleOpenEditor()}),document.addEventListener("jammin:save",()=>this.handleSave())}async getConfigForCurrentPage(){return new Promise(t=>{chrome.runtime.sendMessage({action:"get_site_config",payload:{url:window.location.href}},e=>{t(e==null?void 0:e.payload)})})}injectPageStyles(){this.styleElement=document.createElement("style"),this.styleElement.id="jammin-page-styles",this.styleElement.textContent=f(),document.head.appendChild(this.styleElement)}handleToggleEdit(t){!this.editor||!this.toolbar||(t?(this.editor.enable(),document.body.classList.add("jammin-editing-active")):(this.editor.disable(),document.body.classList.remove("jammin-editing-active")),this.toolbar.setEditEnabled(t))}async handleSave(){if(!this.config||!this.editor||!this.toolbar||!this.editor.hasDirtyElements())return;const t=this.editor.getDirtyChanges();t.length!==0&&(this.toolbar.setSaving(!0),this.toolbar.setStatus("Checking project..."),this.toolbar.resetOutput(),this.toolbar.showOutput(),this.pendingChanges={projectPath:this.config.localPath,siteUrl:window.location.href,changes:t,customInstructions:this.config.customInstructions},chrome.runtime.sendMessage({action:"submit_changes",payload:this.pendingChanges},e=>{var i,n,a;(e==null?void 0:e.action)==="job_accepted"?(this.currentJobId=e.payload.jobId,(i=this.toolbar)==null||i.setStatus("Claude is working...")):(e==null?void 0:e.action)==="error"&&((n=this.toolbar)==null||n.setSaving(!1),(a=this.toolbar)==null||a.setStatus("Error: "+e.payload.message),this.pendingChanges=null)}))}handleRevert(){!this.editor||!this.toolbar||(this.editor.revertAll(),this.toolbar.setStatus("Changes reverted"))}handleOpenEditor(){this.config&&chrome.runtime.sendMessage({action:"open_editor",payload:{projectPath:this.config.localPath}})}handleBackgroundMessage(t){var e;if(!(!this.toolbar||!this.editor))switch(t.action){case"job_progress":{const i=t.payload;i.jobId===this.currentJobId&&(this.toolbar.addProgress(i),this.toolbar.setStatus(i.phase==="editing"?"Editing files...":"Claude is thinking..."));break}case"job_complete":{const i=t.payload;if(i.jobId===this.currentJobId){if(this.toolbar.setComplete(i),this.toolbar.setSaving(!1),i.success){this.editor.markSaved();const n=((e=i.filesChanged)==null?void 0:e.length)||0;this.toolbar.setStatus(`Done! ${n} file${n!==1?"s":""} modified`)}else this.toolbar.setStatus("Error: "+(i.error||"Unknown error"));this.currentJobId=null}break}case"job_cancelled":{t.payload.jobId===this.currentJobId&&(this.toolbar.setSaving(!1),this.toolbar.setStatus("Cancelled"),this.currentJobId=null);break}case"git_dirty":{const i=t.payload;i.jobId===this.currentJobId&&this.handleGitDirty(i);break}case"error":{this.toolbar.setSaving(!1),this.toolbar.setStatus("Error: "+t.payload.message);break}}}handleGitDirty(t){if(!this.toolbar)return;const e=t.changedFiles.length,i=t.changedFiles.slice(0,5).join(`
580
+ `),n=e>5?`
581
+ ... and ${e-5} more`:"";confirm(`This project has ${e} uncommitted change${e!==1?"s":""}:
582
+ ${i}${n}
583
+
584
+ Do you want to proceed anyway?`)&&this.pendingChanges?chrome.runtime.sendMessage({action:"submit_changes_force",payload:this.pendingChanges},s=>{var d,c,r;(s==null?void 0:s.action)==="job_accepted"?(this.currentJobId=s.payload.jobId,(d=this.toolbar)==null||d.setStatus("Claude is working...")):(s==null?void 0:s.action)==="error"&&((c=this.toolbar)==null||c.setSaving(!1),(r=this.toolbar)==null||r.setStatus("Error: "+s.payload.message))}):(this.toolbar.setSaving(!1),this.toolbar.setStatus("Cancelled - uncommitted changes"),this.currentJobId=null),this.pendingChanges=null}}new v;
@@ -0,0 +1,35 @@
1
+ {
2
+ "manifest_version": 3,
3
+ "name": "Jammin CMS",
4
+ "description": "Inline website editing with Claude Code",
5
+ "version": "0.1.3",
6
+ "permissions": [
7
+ "storage",
8
+ "activeTab",
9
+ "scripting"
10
+ ],
11
+ "host_permissions": [
12
+ "<all_urls>"
13
+ ],
14
+ "background": {
15
+ "service_worker": "background.js",
16
+ "type": "module"
17
+ },
18
+ "content_scripts": [
19
+ {
20
+ "matches": [
21
+ "<all_urls>"
22
+ ],
23
+ "js": [
24
+ "content.js"
25
+ ],
26
+ "css": [],
27
+ "run_at": "document_idle"
28
+ }
29
+ ],
30
+ "action": {
31
+ "default_popup": "popup.html",
32
+ "default_title": "Jammin CMS"
33
+ },
34
+ "options_page": "options.html"
35
+ }