jammincms 0.1.0 → 0.1.1
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.
- package/dist/index.js +71 -1
- package/dist/index.js.map +1 -1
- package/extension/background.js +1 -0
- package/extension/content.js +526 -0
- package/extension/manifest.json +31 -0
- package/extension/options.html +425 -0
- package/extension/options.js +25 -0
- package/extension/popup.html +191 -0
- package/extension/popup.js +1 -0
- package/package.json +5 -3
package/dist/index.js
CHANGED
|
@@ -2,18 +2,59 @@
|
|
|
2
2
|
import { Command } from 'commander';
|
|
3
3
|
import { startServer } from './server.js';
|
|
4
4
|
import { checkClaudeAvailable } from './claude.js';
|
|
5
|
+
import { fileURLToPath } from 'url';
|
|
6
|
+
import { dirname, join } from 'path';
|
|
7
|
+
import { cpSync, existsSync, mkdirSync, rmSync } from 'fs';
|
|
5
8
|
const program = new Command();
|
|
9
|
+
const EXTENSION_FOLDER = 'jammin-cms-extension';
|
|
10
|
+
function getExtensionSource() {
|
|
11
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
12
|
+
const __dirname = dirname(__filename);
|
|
13
|
+
return join(__dirname, '..', 'extension');
|
|
14
|
+
}
|
|
15
|
+
function getExtensionDir() {
|
|
16
|
+
return join(process.cwd(), EXTENSION_FOLDER);
|
|
17
|
+
}
|
|
18
|
+
function ensureExtensionInstalled() {
|
|
19
|
+
const extensionSource = getExtensionSource();
|
|
20
|
+
const extensionDir = getExtensionDir();
|
|
21
|
+
if (!existsSync(extensionSource)) {
|
|
22
|
+
return { installed: false, path: extensionDir, fresh: false };
|
|
23
|
+
}
|
|
24
|
+
const alreadyExists = existsSync(extensionDir);
|
|
25
|
+
if (!alreadyExists) {
|
|
26
|
+
mkdirSync(extensionDir, { recursive: true });
|
|
27
|
+
cpSync(extensionSource, extensionDir, { recursive: true });
|
|
28
|
+
}
|
|
29
|
+
return { installed: true, path: extensionDir, fresh: !alreadyExists };
|
|
30
|
+
}
|
|
31
|
+
function printExtensionInstructions(path) {
|
|
32
|
+
console.log('\n┌─────────────────────────────────────────────────────────┐');
|
|
33
|
+
console.log('│ Chrome Extension Setup │');
|
|
34
|
+
console.log('├─────────────────────────────────────────────────────────┤');
|
|
35
|
+
console.log('│ 1. Open chrome://extensions │');
|
|
36
|
+
console.log('│ 2. Enable "Developer mode" (top right) │');
|
|
37
|
+
console.log('│ 3. Click "Load unpacked" and select: │');
|
|
38
|
+
console.log(`│ ${path}`);
|
|
39
|
+
console.log('└─────────────────────────────────────────────────────────┘\n');
|
|
40
|
+
}
|
|
6
41
|
async function start(port) {
|
|
7
42
|
if (isNaN(port) || port < 1 || port > 65535) {
|
|
8
43
|
console.error('Invalid port number');
|
|
9
44
|
process.exit(1);
|
|
10
45
|
}
|
|
46
|
+
// Ensure extension is available
|
|
47
|
+
const ext = ensureExtensionInstalled();
|
|
48
|
+
if (ext.fresh) {
|
|
49
|
+
console.log('Extension installed to:', ext.path);
|
|
50
|
+
printExtensionInstructions(ext.path);
|
|
51
|
+
}
|
|
11
52
|
// Check if Claude CLI is available
|
|
12
53
|
const claudeAvailable = await checkClaudeAvailable();
|
|
13
54
|
if (!claudeAvailable) {
|
|
14
55
|
console.warn('Warning: Claude CLI not found in PATH');
|
|
15
56
|
console.warn('Install it with: npm install -g @anthropic-ai/claude-code');
|
|
16
|
-
console.warn('The server will start but edit jobs will fail
|
|
57
|
+
console.warn('The server will start but edit jobs will fail.\n');
|
|
17
58
|
}
|
|
18
59
|
else {
|
|
19
60
|
console.log('Claude CLI: available');
|
|
@@ -82,5 +123,34 @@ program
|
|
|
82
123
|
process.exit(1);
|
|
83
124
|
});
|
|
84
125
|
});
|
|
126
|
+
program
|
|
127
|
+
.command('extension-path')
|
|
128
|
+
.description('Print the path to the Chrome extension')
|
|
129
|
+
.action(() => {
|
|
130
|
+
const ext = ensureExtensionInstalled();
|
|
131
|
+
if (!ext.installed) {
|
|
132
|
+
console.error('Extension files not found in package.');
|
|
133
|
+
process.exit(1);
|
|
134
|
+
}
|
|
135
|
+
console.log(ext.path);
|
|
136
|
+
});
|
|
137
|
+
program
|
|
138
|
+
.command('reinstall-extension')
|
|
139
|
+
.description('Reinstall the Chrome extension (replaces existing)')
|
|
140
|
+
.action(() => {
|
|
141
|
+
const extensionSource = getExtensionSource();
|
|
142
|
+
const extensionDir = getExtensionDir();
|
|
143
|
+
if (!existsSync(extensionSource)) {
|
|
144
|
+
console.error('Extension files not found in package.');
|
|
145
|
+
process.exit(1);
|
|
146
|
+
}
|
|
147
|
+
if (existsSync(extensionDir)) {
|
|
148
|
+
rmSync(extensionDir, { recursive: true });
|
|
149
|
+
}
|
|
150
|
+
mkdirSync(extensionDir, { recursive: true });
|
|
151
|
+
cpSync(extensionSource, extensionDir, { recursive: true });
|
|
152
|
+
console.log('Extension reinstalled to:', extensionDir);
|
|
153
|
+
printExtensionInstructions(extensionDir);
|
|
154
|
+
});
|
|
85
155
|
program.parse();
|
|
86
156
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AACnD,OAAO,EAAE,aAAa,EAAE,MAAM,KAAK,CAAC;AACpC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AACrC,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,S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EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;IAE3D,OAAO,CAAC,GAAG,CAAC,2BAA2B,EAAE,YAAY,CAAC,CAAC;IACvD,0BAA0B,CAAC,YAAY,CAAC,CAAC;AAC3C,CAAC,CAAC,CAAC;AAEL,OAAO,CAAC,KAAK,EAAE,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var g=Object.defineProperty;var p=(n,e,t)=>e in n?g(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t;var a=(n,e,t)=>p(n,typeof e!="symbol"?e+"":e,t);const f={bridgeUrl:"ws://localhost:9876",claudePath:"claude",defaultEditor:"auto",showStatusPanel:!0,autoSave:!1},d={SITES:"jammin_sites",SETTINGS:"jammin_settings"};async function S(){return(await chrome.storage.sync.get(d.SITES))[d.SITES]||[]}function j(n,e){for(const t of e)if(t.enabled&&_(n,t.urlPattern))return t}function _(n,e){const t=e.replace(/[.+^${}()|[\]\\]/g,"\\$&").replace(/\*\*/g,".*").replace(/\*/g,"[^/]*");return new RegExp(`^${t}$`).test(n)}async function u(){const n=await chrome.storage.sync.get(d.SETTINGS);return{...f,...n[d.SETTINGS]}}class m{constructor(){a(this,"ws",null);a(this,"reconnectTimer",null);a(this,"messageHandlers",new Set);a(this,"connectionStatus",{connected:!1});a(this,"pendingMessages",[]);a(this,"jobs",new Map);this.connect()}async connect(){var o;if(((o=this.ws)==null?void 0:o.readyState)===WebSocket.OPEN)return;const t=(await u()).bridgeUrl;try{this.ws=new WebSocket(t),this.ws.onopen=()=>{console.log("[Jammin] Connected to bridge"),this.connectionStatus={connected:!0},this.send({type:"ping"});for(const s of this.pendingMessages)this.send(s);this.pendingMessages=[]},this.ws.onmessage=s=>{try{const c=JSON.parse(s.data);this.handleMessage(c)}catch(c){console.error("[Jammin] Failed to parse message:",c)}},this.ws.onclose=()=>{console.log("[Jammin] Disconnected from bridge"),this.connectionStatus={connected:!1},this.ws=null,this.scheduleReconnect()},this.ws.onerror=s=>{console.error("[Jammin] WebSocket error:",s),this.connectionStatus={connected:!1,error:"Connection failed"}}}catch(s){console.error("[Jammin] Failed to connect:",s),this.connectionStatus={connected:!1,error:s instanceof Error?s.message:"Connection failed"},this.scheduleReconnect()}}scheduleReconnect(){this.reconnectTimer&&clearTimeout(this.reconnectTimer),this.reconnectTimer=setTimeout(()=>{this.connect()},5e3)}handleMessage(e){e.type==="pong"&&(this.connectionStatus={connected:!0,bridgeVersion:e.version,claudeAvailable:e.claudeAvailable}),"jobId"in e&&e.jobId&&this.updateJobStatus(e);for(const t of this.messageHandlers)try{t(e)}catch(o){console.error("[Jammin] Message handler error:",o)}}updateJobStatus(e){if(!("jobId"in e)||!e.jobId)return;const t=e.jobId;let o=this.jobs.get(t);switch(e.type){case"job_accepted":this.jobs.set(t,{id:t,status:"pending",output:"",phase:"thinking"});break;case"job_progress":o&&(o.output+=e.output,o.phase=e.phase,o.status="running");break;case"job_complete":o&&(o.status=e.success?"complete":"error",o.filesChanged=e.filesChanged,o.error=e.error);break;case"job_cancelled":o&&(o.status="cancelled");break}}send(e){var t;((t=this.ws)==null?void 0:t.readyState)===WebSocket.OPEN?this.ws.send(JSON.stringify(e)):(this.pendingMessages.push(e),this.connect())}getStatus(){return this.connectionStatus}getJobStatus(e){return this.jobs.get(e)}addMessageHandler(e){this.messageHandlers.add(e)}removeMessageHandler(e){this.messageHandlers.delete(e)}disconnect(){this.reconnectTimer&&clearTimeout(this.reconnectTimer),this.ws&&(this.ws.close(),this.ws=null)}}const r=new m,i=new Map;chrome.runtime.onMessage.addListener((n,e,t)=>{var s;const o=(s=e.tab)==null?void 0:s.id;return w(n,o).then(t).catch(c=>{console.error("[Jammin] Error handling message:",c),t({action:"error",payload:{message:c instanceof Error?c.message:"Unknown error"}})}),!0});async function w(n,e){switch(n.action){case"get_site_config":{const{url:t}=n.payload,o=await S();return{action:"site_config",payload:j(t,o)||null}}case"submit_changes":case"submit_changes_force":{const{projectPath:t,siteUrl:o,changes:s,customInstructions:c}=n.payload,l=crypto.randomUUID(),h=await u(),b=n.action==="submit_changes_force";return e&&(i.has(e)||i.set(e,new Set),i.get(e).add(l)),r.send({type:"submit_edit",jobId:l,projectPath:t,siteUrl:o,changes:s,customInstructions:c,claudePath:h.claudePath,skipGitCheck:b}),{action:"job_accepted",payload:{jobId:l}}}case"cancel_job":{const{jobId:t}=n.payload;return r.send({type:"cancel_job",jobId:t}),{action:"job_cancelled",payload:{jobId:t}}}case"open_editor":{const{projectPath:t,file:o}=n.payload;return r.send({type:"open_editor",projectPath:t,file:o}),{action:"job_accepted",payload:{}}}case"get_connection_status":return{action:"connection_status",payload:r.getStatus()};case"get_job_status":{const{jobId:t}=n.payload;return{action:"job_progress",payload:r.getJobStatus(t)}}default:throw new Error(`Unknown action: ${n.action}`)}}r.addMessageHandler(n=>{if(!("jobId"in n)||!n.jobId)return;const e=n.jobId;for(const[t,o]of i)if(o.has(e)){let s;switch(n.type){case"job_progress":s="job_progress";break;case"job_complete":s="job_complete",o.delete(e);break;case"job_cancelled":s="job_cancelled",o.delete(e);break;case"git_dirty":s="git_dirty";break;default:return}chrome.tabs.sendMessage(t,{action:s,payload:n})}});chrome.tabs.onRemoved.addListener(n=>{i.delete(n)});console.log("[Jammin] Background service worker initialized");
|
|
@@ -0,0 +1,526 @@
|
|
|
1
|
+
var c=Object.defineProperty;var h=(l,t,e)=>t in l?c(l,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):l[t]=e;var s=(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(o=>o&&!o.startsWith("jammin-")).slice(0,2);a.length>0&&(i+=`.${a.join(".")}`)}const n=e.parentElement;if(n){const a=Array.from(n.children).filter(o=>o.tagName===e.tagName);if(a.length>1){const o=a.indexOf(e)+1;i+=`:nth-child(${o})`}}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 g{constructor(){s(this,"trackedElements",new Map);s(this,"config",null);s(this,"mutationObserver",null);s(this,"enabled",!1);s(this,"onDirtyChange",null);this.handleInput=this.handleInput.bind(this),this.handleKeydown=this.handleKeydown.bind(this)}setConfig(t){this.config=t}setDirtyChangeHandler(t){this.onDirtyChange=t}enable(){this.enabled||!this.config||(this.enabled=!0,this.setupEditableElements(),this.startObserving(),document.addEventListener("keydown",this.handleKeydown))}disable(){this.enabled&&(this.enabled=!1,this.stopObserving(),this.removeAllEditable(),document.removeEventListener("keydown",this.handleKeydown))}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.key==="Escape"){const e=document.activeElement;e&&this.trackedElements.has(e)&&(this.revertElement(e),e.blur())}}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 b(){return`
|
|
2
|
+
/* Reset */
|
|
3
|
+
*, *::before, *::after {
|
|
4
|
+
box-sizing: border-box;
|
|
5
|
+
margin: 0;
|
|
6
|
+
padding: 0;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
/* Variables */
|
|
10
|
+
:host {
|
|
11
|
+
--jammin-primary: #6366f1;
|
|
12
|
+
--jammin-primary-hover: #4f46e5;
|
|
13
|
+
--jammin-bg: #1e1e2e;
|
|
14
|
+
--jammin-bg-light: #2a2a3e;
|
|
15
|
+
--jammin-text: #e0e0e0;
|
|
16
|
+
--jammin-text-muted: #a0a0a0;
|
|
17
|
+
--jammin-border: #3a3a4e;
|
|
18
|
+
--jammin-success: #22c55e;
|
|
19
|
+
--jammin-warning: #f59e0b;
|
|
20
|
+
--jammin-error: #ef4444;
|
|
21
|
+
--jammin-radius: 8px;
|
|
22
|
+
--jammin-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
|
|
23
|
+
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
|
|
24
|
+
font-size: 14px;
|
|
25
|
+
line-height: 1.5;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/* Toggle Button */
|
|
29
|
+
.jammin-toggle {
|
|
30
|
+
position: fixed;
|
|
31
|
+
bottom: 20px;
|
|
32
|
+
right: 20px;
|
|
33
|
+
width: 48px;
|
|
34
|
+
height: 48px;
|
|
35
|
+
border-radius: 50%;
|
|
36
|
+
background: var(--jammin-primary);
|
|
37
|
+
border: none;
|
|
38
|
+
color: white;
|
|
39
|
+
cursor: pointer;
|
|
40
|
+
display: flex;
|
|
41
|
+
align-items: center;
|
|
42
|
+
justify-content: center;
|
|
43
|
+
box-shadow: var(--jammin-shadow);
|
|
44
|
+
transition: transform 0.2s, background-color 0.2s;
|
|
45
|
+
z-index: 2147483647;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
.jammin-toggle:hover {
|
|
49
|
+
background: var(--jammin-primary-hover);
|
|
50
|
+
transform: scale(1.05);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
.jammin-toggle.hidden {
|
|
54
|
+
transform: scale(0);
|
|
55
|
+
pointer-events: none;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
.jammin-badge {
|
|
59
|
+
position: absolute;
|
|
60
|
+
top: -4px;
|
|
61
|
+
right: -4px;
|
|
62
|
+
min-width: 20px;
|
|
63
|
+
height: 20px;
|
|
64
|
+
background: var(--jammin-error);
|
|
65
|
+
border-radius: 10px;
|
|
66
|
+
font-size: 12px;
|
|
67
|
+
font-weight: 600;
|
|
68
|
+
display: flex;
|
|
69
|
+
align-items: center;
|
|
70
|
+
justify-content: center;
|
|
71
|
+
padding: 0 6px;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/* Toolbar Container */
|
|
75
|
+
.jammin-toolbar {
|
|
76
|
+
position: fixed;
|
|
77
|
+
bottom: 20px;
|
|
78
|
+
right: 20px;
|
|
79
|
+
z-index: 2147483647;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/* Panel Wrapper - contains both main panel and output drawer */
|
|
83
|
+
.jammin-panel-wrapper {
|
|
84
|
+
position: absolute;
|
|
85
|
+
bottom: 0;
|
|
86
|
+
right: 0;
|
|
87
|
+
display: flex;
|
|
88
|
+
align-items: flex-end;
|
|
89
|
+
gap: 8px;
|
|
90
|
+
transform: scale(0.9);
|
|
91
|
+
opacity: 0;
|
|
92
|
+
pointer-events: none;
|
|
93
|
+
transition: transform 0.2s, opacity 0.2s;
|
|
94
|
+
transform-origin: bottom right;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
.jammin-panel-wrapper.expanded {
|
|
98
|
+
transform: scale(1);
|
|
99
|
+
opacity: 1;
|
|
100
|
+
pointer-events: auto;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
/* Main Panel */
|
|
104
|
+
.jammin-panel {
|
|
105
|
+
width: 280px;
|
|
106
|
+
background: var(--jammin-bg);
|
|
107
|
+
border: 1px solid var(--jammin-border);
|
|
108
|
+
border-radius: var(--jammin-radius);
|
|
109
|
+
box-shadow: var(--jammin-shadow);
|
|
110
|
+
overflow: hidden;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
.jammin-header {
|
|
114
|
+
display: flex;
|
|
115
|
+
align-items: center;
|
|
116
|
+
justify-content: space-between;
|
|
117
|
+
padding: 12px 16px;
|
|
118
|
+
background: var(--jammin-bg-light);
|
|
119
|
+
border-bottom: 1px solid var(--jammin-border);
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
.jammin-title {
|
|
123
|
+
font-weight: 600;
|
|
124
|
+
color: var(--jammin-text);
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
.jammin-close {
|
|
128
|
+
background: none;
|
|
129
|
+
border: none;
|
|
130
|
+
color: var(--jammin-text-muted);
|
|
131
|
+
cursor: pointer;
|
|
132
|
+
padding: 4px;
|
|
133
|
+
border-radius: 4px;
|
|
134
|
+
display: flex;
|
|
135
|
+
align-items: center;
|
|
136
|
+
justify-content: center;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
.jammin-close:hover {
|
|
140
|
+
background: var(--jammin-border);
|
|
141
|
+
color: var(--jammin-text);
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
.jammin-content {
|
|
145
|
+
padding: 16px;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
.jammin-row {
|
|
149
|
+
display: flex;
|
|
150
|
+
align-items: center;
|
|
151
|
+
gap: 12px;
|
|
152
|
+
margin-bottom: 16px;
|
|
153
|
+
color: var(--jammin-text);
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
/* Toggle Switch */
|
|
157
|
+
.jammin-switch {
|
|
158
|
+
position: relative;
|
|
159
|
+
width: 40px;
|
|
160
|
+
height: 22px;
|
|
161
|
+
flex-shrink: 0;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
.jammin-switch input {
|
|
165
|
+
opacity: 0;
|
|
166
|
+
width: 0;
|
|
167
|
+
height: 0;
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
.jammin-slider {
|
|
171
|
+
position: absolute;
|
|
172
|
+
cursor: pointer;
|
|
173
|
+
top: 0;
|
|
174
|
+
left: 0;
|
|
175
|
+
right: 0;
|
|
176
|
+
bottom: 0;
|
|
177
|
+
background-color: var(--jammin-border);
|
|
178
|
+
transition: 0.2s;
|
|
179
|
+
border-radius: 22px;
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
.jammin-slider:before {
|
|
183
|
+
position: absolute;
|
|
184
|
+
content: "";
|
|
185
|
+
height: 16px;
|
|
186
|
+
width: 16px;
|
|
187
|
+
left: 3px;
|
|
188
|
+
bottom: 3px;
|
|
189
|
+
background-color: white;
|
|
190
|
+
transition: 0.2s;
|
|
191
|
+
border-radius: 50%;
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
.jammin-switch input:checked + .jammin-slider {
|
|
195
|
+
background-color: var(--jammin-primary);
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
.jammin-switch input:checked + .jammin-slider:before {
|
|
199
|
+
transform: translateX(18px);
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
/* Actions */
|
|
203
|
+
.jammin-actions {
|
|
204
|
+
display: flex;
|
|
205
|
+
gap: 8px;
|
|
206
|
+
margin-bottom: 12px;
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
.jammin-btn {
|
|
210
|
+
flex: 1;
|
|
211
|
+
display: flex;
|
|
212
|
+
align-items: center;
|
|
213
|
+
justify-content: center;
|
|
214
|
+
gap: 6px;
|
|
215
|
+
padding: 8px 12px;
|
|
216
|
+
border: 1px solid var(--jammin-border);
|
|
217
|
+
border-radius: 6px;
|
|
218
|
+
background: var(--jammin-bg-light);
|
|
219
|
+
color: var(--jammin-text);
|
|
220
|
+
font-size: 13px;
|
|
221
|
+
cursor: pointer;
|
|
222
|
+
transition: background-color 0.2s, border-color 0.2s;
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
.jammin-btn:hover:not(:disabled) {
|
|
226
|
+
background: var(--jammin-border);
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
.jammin-btn:disabled {
|
|
230
|
+
opacity: 0.5;
|
|
231
|
+
cursor: not-allowed;
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
.jammin-btn-primary {
|
|
235
|
+
background: var(--jammin-primary);
|
|
236
|
+
border-color: var(--jammin-primary);
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
.jammin-btn-primary:hover:not(:disabled) {
|
|
240
|
+
background: var(--jammin-primary-hover);
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
.jammin-divider {
|
|
244
|
+
height: 1px;
|
|
245
|
+
background: var(--jammin-border);
|
|
246
|
+
margin: 12px 0;
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
.jammin-status-text {
|
|
250
|
+
font-size: 12px;
|
|
251
|
+
color: var(--jammin-text-muted);
|
|
252
|
+
text-align: center;
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
/* Output Drawer - slides out to the left */
|
|
256
|
+
.jammin-output-drawer {
|
|
257
|
+
width: 350px;
|
|
258
|
+
max-height: 400px;
|
|
259
|
+
background: var(--jammin-bg);
|
|
260
|
+
border: 1px solid var(--jammin-border);
|
|
261
|
+
border-radius: var(--jammin-radius);
|
|
262
|
+
box-shadow: var(--jammin-shadow);
|
|
263
|
+
display: flex;
|
|
264
|
+
flex-direction: column;
|
|
265
|
+
transform: translateX(calc(100% + 16px));
|
|
266
|
+
opacity: 0;
|
|
267
|
+
pointer-events: none;
|
|
268
|
+
transition: transform 0.3s, opacity 0.3s;
|
|
269
|
+
position: absolute;
|
|
270
|
+
right: calc(100% + 8px);
|
|
271
|
+
bottom: 0;
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
.jammin-output-drawer.expanded {
|
|
275
|
+
transform: translateX(0);
|
|
276
|
+
opacity: 1;
|
|
277
|
+
pointer-events: auto;
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
.jammin-output-header {
|
|
281
|
+
display: flex;
|
|
282
|
+
align-items: center;
|
|
283
|
+
justify-content: space-between;
|
|
284
|
+
padding: 10px 14px;
|
|
285
|
+
background: var(--jammin-bg-light);
|
|
286
|
+
border-bottom: 1px solid var(--jammin-border);
|
|
287
|
+
border-radius: var(--jammin-radius) var(--jammin-radius) 0 0;
|
|
288
|
+
flex-shrink: 0;
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
.jammin-output-title {
|
|
292
|
+
display: flex;
|
|
293
|
+
align-items: center;
|
|
294
|
+
gap: 8px;
|
|
295
|
+
color: var(--jammin-text);
|
|
296
|
+
font-weight: 500;
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
.jammin-output-close {
|
|
300
|
+
background: none;
|
|
301
|
+
border: none;
|
|
302
|
+
color: var(--jammin-text-muted);
|
|
303
|
+
cursor: pointer;
|
|
304
|
+
padding: 4px;
|
|
305
|
+
border-radius: 4px;
|
|
306
|
+
display: flex;
|
|
307
|
+
align-items: center;
|
|
308
|
+
justify-content: center;
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
.jammin-output-close:hover {
|
|
312
|
+
background: var(--jammin-border);
|
|
313
|
+
color: var(--jammin-text);
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
.jammin-output-body {
|
|
317
|
+
flex: 1;
|
|
318
|
+
overflow: auto;
|
|
319
|
+
padding: 12px;
|
|
320
|
+
min-height: 100px;
|
|
321
|
+
max-height: 250px;
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
.jammin-output-content {
|
|
325
|
+
font-family: 'SF Mono', 'Menlo', 'Monaco', monospace;
|
|
326
|
+
font-size: 12px;
|
|
327
|
+
line-height: 1.6;
|
|
328
|
+
color: var(--jammin-text);
|
|
329
|
+
white-space: pre-wrap;
|
|
330
|
+
word-break: break-word;
|
|
331
|
+
margin: 0;
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
.jammin-output-footer {
|
|
335
|
+
padding: 10px 14px;
|
|
336
|
+
border-top: 1px solid var(--jammin-border);
|
|
337
|
+
background: var(--jammin-bg-light);
|
|
338
|
+
border-radius: 0 0 var(--jammin-radius) var(--jammin-radius);
|
|
339
|
+
flex-shrink: 0;
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
.jammin-output-footer:empty {
|
|
343
|
+
display: none;
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
/* Status Indicator */
|
|
347
|
+
.jammin-status-indicator {
|
|
348
|
+
width: 8px;
|
|
349
|
+
height: 8px;
|
|
350
|
+
border-radius: 50%;
|
|
351
|
+
background: var(--jammin-text-muted);
|
|
352
|
+
flex-shrink: 0;
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
.jammin-status-indicator.phase-thinking {
|
|
356
|
+
background: var(--jammin-warning);
|
|
357
|
+
animation: pulse 1.5s infinite;
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
.jammin-status-indicator.phase-editing {
|
|
361
|
+
background: var(--jammin-primary);
|
|
362
|
+
animation: pulse 1s infinite;
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
.jammin-status-indicator.phase-complete {
|
|
366
|
+
background: var(--jammin-success);
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
.jammin-status-indicator.phase-error {
|
|
370
|
+
background: var(--jammin-error);
|
|
371
|
+
}
|
|
372
|
+
|
|
373
|
+
@keyframes pulse {
|
|
374
|
+
0%, 100% { opacity: 1; }
|
|
375
|
+
50% { opacity: 0.5; }
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
/* Files list */
|
|
379
|
+
.jammin-files-header {
|
|
380
|
+
font-size: 12px;
|
|
381
|
+
font-weight: 500;
|
|
382
|
+
color: var(--jammin-text);
|
|
383
|
+
margin-bottom: 6px;
|
|
384
|
+
}
|
|
385
|
+
|
|
386
|
+
.jammin-files-list {
|
|
387
|
+
list-style: none;
|
|
388
|
+
font-size: 12px;
|
|
389
|
+
color: var(--jammin-success);
|
|
390
|
+
}
|
|
391
|
+
|
|
392
|
+
.jammin-files-list li {
|
|
393
|
+
padding: 2px 0;
|
|
394
|
+
}
|
|
395
|
+
|
|
396
|
+
.jammin-files-list li::before {
|
|
397
|
+
content: "\\2713 ";
|
|
398
|
+
}
|
|
399
|
+
|
|
400
|
+
.jammin-error {
|
|
401
|
+
font-size: 12px;
|
|
402
|
+
color: var(--jammin-error);
|
|
403
|
+
}
|
|
404
|
+
`}function f(){return`
|
|
405
|
+
.jammin-editable {
|
|
406
|
+
outline: 2px dashed transparent;
|
|
407
|
+
outline-offset: 2px;
|
|
408
|
+
transition: outline-color 0.2s;
|
|
409
|
+
}
|
|
410
|
+
|
|
411
|
+
/* Show dashed outline on all editable elements when editing is active */
|
|
412
|
+
body.jammin-editing-active .jammin-editable {
|
|
413
|
+
outline-color: rgba(99, 102, 241, 0.5);
|
|
414
|
+
}
|
|
415
|
+
|
|
416
|
+
.jammin-editable:focus {
|
|
417
|
+
outline-color: #6366f1;
|
|
418
|
+
outline-style: solid;
|
|
419
|
+
}
|
|
420
|
+
|
|
421
|
+
.jammin-editable.jammin-dirty {
|
|
422
|
+
outline-color: #f59e0b;
|
|
423
|
+
}
|
|
424
|
+
|
|
425
|
+
.jammin-editable.jammin-dirty:focus {
|
|
426
|
+
outline-color: #f59e0b;
|
|
427
|
+
outline-style: solid;
|
|
428
|
+
}
|
|
429
|
+
`}class v{constructor(){s(this,"container",null);s(this,"shadowRoot",null);s(this,"expanded",!1);s(this,"outputExpanded",!1);s(this,"editEnabled",!1);s(this,"dirtyCount",0);s(this,"saving",!1);s(this,"config",null);s(this,"callbacks",null);s(this,"output","");s(this,"phase","idle");s(this,"filesChanged",[]);s(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=b(),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`
|
|
430
|
+
<button class="jammin-toggle" title="Jammin CMS">
|
|
431
|
+
<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
|
|
432
|
+
<path d="M12 19l7-7 3 3-7 7-3-3z"></path>
|
|
433
|
+
<path d="M18 13l-1.5-7.5L2 2l3.5 14.5L13 18l5-5z"></path>
|
|
434
|
+
<path d="M2 2l7.586 7.586"></path>
|
|
435
|
+
<circle cx="11" cy="11" r="2"></circle>
|
|
436
|
+
</svg>
|
|
437
|
+
<span class="jammin-badge" style="display: none;">0</span>
|
|
438
|
+
</button>
|
|
439
|
+
<div class="jammin-panel-wrapper">
|
|
440
|
+
<div class="jammin-output-drawer">
|
|
441
|
+
<div class="jammin-output-header">
|
|
442
|
+
<div class="jammin-output-title">
|
|
443
|
+
<span class="jammin-status-indicator"></span>
|
|
444
|
+
<span class="jammin-status-phase">Ready</span>
|
|
445
|
+
</div>
|
|
446
|
+
<button class="jammin-output-close" title="Close">
|
|
447
|
+
<svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
|
|
448
|
+
<line x1="18" y1="6" x2="6" y2="18"></line>
|
|
449
|
+
<line x1="6" y1="6" x2="18" y2="18"></line>
|
|
450
|
+
</svg>
|
|
451
|
+
</button>
|
|
452
|
+
</div>
|
|
453
|
+
<div class="jammin-output-body">
|
|
454
|
+
<pre class="jammin-output-content"></pre>
|
|
455
|
+
</div>
|
|
456
|
+
<div class="jammin-output-footer"></div>
|
|
457
|
+
</div>
|
|
458
|
+
<div class="jammin-panel">
|
|
459
|
+
<div class="jammin-header">
|
|
460
|
+
<span class="jammin-title">${((t=this.config)==null?void 0:t.name)||"Jammin CMS"}</span>
|
|
461
|
+
<button class="jammin-close" title="Close">
|
|
462
|
+
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
|
|
463
|
+
<line x1="18" y1="6" x2="6" y2="18"></line>
|
|
464
|
+
<line x1="6" y1="6" x2="18" y2="18"></line>
|
|
465
|
+
</svg>
|
|
466
|
+
</button>
|
|
467
|
+
</div>
|
|
468
|
+
<div class="jammin-content">
|
|
469
|
+
<div class="jammin-row">
|
|
470
|
+
<label class="jammin-switch">
|
|
471
|
+
<input type="checkbox" id="jammin-edit-toggle">
|
|
472
|
+
<span class="jammin-slider"></span>
|
|
473
|
+
</label>
|
|
474
|
+
<span>Enable editing</span>
|
|
475
|
+
</div>
|
|
476
|
+
<div class="jammin-actions">
|
|
477
|
+
<button class="jammin-btn jammin-btn-primary" id="jammin-save" disabled>
|
|
478
|
+
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
|
|
479
|
+
<path d="M19 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h11l5 5v11a2 2 0 0 1-2 2z"></path>
|
|
480
|
+
<polyline points="17 21 17 13 7 13 7 21"></polyline>
|
|
481
|
+
<polyline points="7 3 7 8 15 8"></polyline>
|
|
482
|
+
</svg>
|
|
483
|
+
<span>Save</span>
|
|
484
|
+
</button>
|
|
485
|
+
<button class="jammin-btn" id="jammin-revert" disabled>
|
|
486
|
+
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
|
|
487
|
+
<polyline points="1 4 1 10 7 10"></polyline>
|
|
488
|
+
<path d="M3.51 15a9 9 0 1 0 2.13-9.36L1 10"></path>
|
|
489
|
+
</svg>
|
|
490
|
+
<span>Revert</span>
|
|
491
|
+
</button>
|
|
492
|
+
</div>
|
|
493
|
+
<div class="jammin-divider"></div>
|
|
494
|
+
<div class="jammin-actions">
|
|
495
|
+
<button class="jammin-btn" id="jammin-editor">
|
|
496
|
+
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
|
|
497
|
+
<polyline points="16 18 22 12 16 6"></polyline>
|
|
498
|
+
<polyline points="8 6 2 12 8 18"></polyline>
|
|
499
|
+
</svg>
|
|
500
|
+
<span>Open Editor</span>
|
|
501
|
+
</button>
|
|
502
|
+
<button class="jammin-btn" id="jammin-output-toggle">
|
|
503
|
+
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
|
|
504
|
+
<rect x="3" y="3" width="18" height="18" rx="2" ry="2"></rect>
|
|
505
|
+
<line x1="3" y1="9" x2="21" y2="9"></line>
|
|
506
|
+
</svg>
|
|
507
|
+
<span>Output</span>
|
|
508
|
+
</button>
|
|
509
|
+
</div>
|
|
510
|
+
<div class="jammin-status-text">
|
|
511
|
+
<span id="jammin-status-message">Ready</span>
|
|
512
|
+
</div>
|
|
513
|
+
</div>
|
|
514
|
+
</div>
|
|
515
|
+
</div>
|
|
516
|
+
`}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 o=this.shadowRoot.querySelector("#jammin-editor");o==null||o.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 m=this.shadowRoot.querySelector(".jammin-output-close");m==null||m.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 o=this.output.replace(/\x1b\[[0-9;]*m/g,"").replace(/\r/g,"");i.textContent=o||"Waiting for output..."}const n=this.shadowRoot.querySelector(".jammin-output-footer");n&&(this.filesChanged.length>0?n.innerHTML=`
|
|
517
|
+
<div class="jammin-files-header">Files modified:</div>
|
|
518
|
+
<ul class="jammin-files-list">
|
|
519
|
+
${this.filesChanged.map(o=>`<li>${this.escapeHtml(o)}</li>`).join("")}
|
|
520
|
+
</ul>
|
|
521
|
+
`: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 j{constructor(){s(this,"config",null);s(this,"editor",null);s(this,"toolbar",null);s(this,"currentJobId",null);s(this,"styleElement",null);s(this,"activated",!1);s(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 g,this.toolbar=new v,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(`
|
|
522
|
+
`),n=e>5?`
|
|
523
|
+
... and ${e-5} more`:"";confirm(`This project has ${e} uncommitted change${e!==1?"s":""}:
|
|
524
|
+
${i}${n}
|
|
525
|
+
|
|
526
|
+
Do you want to proceed anyway?`)&&this.pendingChanges?chrome.runtime.sendMessage({action:"submit_changes_force",payload:this.pendingChanges},o=>{var d,m,r;(o==null?void 0:o.action)==="job_accepted"?(this.currentJobId=o.payload.jobId,(d=this.toolbar)==null||d.setStatus("Claude is working...")):(o==null?void 0:o.action)==="error"&&((m=this.toolbar)==null||m.setSaving(!1),(r=this.toolbar)==null||r.setStatus("Error: "+o.payload.message))}):(this.toolbar.setSaving(!1),this.toolbar.setStatus("Cancelled - uncommitted changes"),this.currentJobId=null),this.pendingChanges=null}}new j;
|