cyclecad 1.0.2 → 1.0.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.
Files changed (2) hide show
  1. package/app/index.html +33 -14
  2. package/package.json +1 -1
package/app/index.html CHANGED
@@ -1419,7 +1419,7 @@
1419
1419
  <span class="splash-logo-cycle">cycle</span><span class="splash-logo-cad">CAD</span>
1420
1420
  </div>
1421
1421
  <p class="splash-subtitle">Parametric 3D CAD Modeler for the Mechanical Designer</p>
1422
- <p style="display:inline-block; color:#0066cc; font-size:1rem; margin:12px 0 0 0; letter-spacing:2px; font-family:monospace; font-weight:700; background:rgba(0,102,204,0.08); border:1.5px solid rgba(0,102,204,0.25); border-radius:8px; padding:5px 20px;">v1.0.1</p>
1422
+ <p style="display:inline-block; color:#0066cc; font-size:1rem; margin:12px 0 0 0; letter-spacing:2px; font-family:monospace; font-weight:700; background:rgba(0,102,204,0.08); border:1.5px solid rgba(0,102,204,0.25); border-radius:8px; padding:5px 20px;">v1.0.3</p>
1423
1423
  </div>
1424
1424
  <div class="splash-options">
1425
1425
  <button class="splash-button splash-button-primary" id="btn-empty-project" style="grid-column: 1 / -1;">
@@ -4008,7 +4008,13 @@
4008
4008
  });
4009
4009
 
4010
4010
  // ========== New Module Toolbar Buttons ==========
4011
- function toggleModulePanel(moduleKey, panelId) {
4011
+ // Map of ES modules that need dynamic import to initialize
4012
+ const _moduleImportMap = {
4013
+ copilot: { path: './js/ai-copilot.js', initFn: 'initCopilot' },
4014
+ materials: { path: './js/material-library.js', initFn: 'initMaterialLibrary' },
4015
+ };
4016
+
4017
+ async function toggleModulePanel(moduleKey, panelId) {
4012
4018
  let panel = document.getElementById(panelId);
4013
4019
  if (panel) {
4014
4020
  panel.style.display = panel.style.display === 'none' ? 'flex' : 'none';
@@ -4017,7 +4023,7 @@
4017
4023
  // Create floating panel
4018
4024
  panel = document.createElement('div');
4019
4025
  panel.id = panelId;
4020
- panel.style.cssText = 'position:fixed;top:60px;right:320px;width:400px;max-height:80vh;overflow-y:auto;background:var(--bg-secondary);border:1px solid var(--border-color);border-radius:8px;z-index:500;display:flex;flex-direction:column;box-shadow:var(--shadow-lg);';
4026
+ panel.style.cssText = 'position:fixed;top:60px;right:320px;width:420px;max-height:80vh;overflow-y:auto;background:var(--bg-secondary);border:1px solid var(--border-color);border-radius:8px;z-index:500;display:flex;flex-direction:column;box-shadow:var(--shadow-lg);';
4021
4027
 
4022
4028
  const header = document.createElement('div');
4023
4029
  header.style.cssText = 'display:flex;justify-content:space-between;align-items:center;padding:10px 14px;border-bottom:1px solid var(--border-color);background:var(--bg-tertiary);border-radius:8px 8px 0 0;cursor:move;';
@@ -4049,12 +4055,24 @@
4049
4055
  const body = document.createElement('div');
4050
4056
  body.style.cssText = 'padding:14px;flex:1;min-height:0;overflow-y:auto;font-size:12px;';
4051
4057
 
4052
- const mod = window.cycleCAD?.[moduleKey];
4058
+ // Try dynamic import for ES modules that export init functions
4059
+ let mod = window.cycleCAD?.[moduleKey];
4060
+ if (!mod && _moduleImportMap[moduleKey]) {
4061
+ try {
4062
+ const m = await import(_moduleImportMap[moduleKey].path);
4063
+ if (m[_moduleImportMap[moduleKey].initFn]) {
4064
+ m[_moduleImportMap[moduleKey].initFn](body);
4065
+ panel.appendChild(body);
4066
+ document.body.appendChild(panel);
4067
+ return;
4068
+ }
4069
+ } catch(e) { console.warn('[Module Import]', moduleKey, e); }
4070
+ mod = window.cycleCAD?.[moduleKey]; // re-check after import
4071
+ }
4072
+
4053
4073
  if (mod?.init) {
4054
- // Use init() which sets innerHTML AND attaches event listeners
4055
4074
  mod.init(body);
4056
4075
  } else if (mod?.getUI) {
4057
- // Strip position:fixed and z-index from module HTML — our wrapper handles positioning
4058
4076
  let html = mod.getUI();
4059
4077
  html = html.replace(/position:\s*fixed;?/gi, 'position:relative;')
4060
4078
  .replace(/z-index:\s*\d+;?/gi, '')
@@ -4063,18 +4081,13 @@
4063
4081
  .replace(/height:\s*calc\([^)]+\);?/gi, 'height:auto;')
4064
4082
  .replace(/width:\s*400px;?/gi, 'width:100%;');
4065
4083
  body.innerHTML = html;
4066
- // Wire up tab switching for modules that use .tab-btn
4067
4084
  body.querySelectorAll('.tab-btn').forEach(btn => {
4068
4085
  btn.addEventListener('click', () => {
4069
4086
  const tab = btn.dataset.tab;
4070
4087
  body.querySelectorAll('.tab-btn').forEach(b => {
4071
- b.style.color = '#888';
4072
- b.style.borderBottom = 'none';
4073
- b.classList.remove('active');
4088
+ b.style.color = '#888'; b.style.borderBottom = 'none'; b.classList.remove('active');
4074
4089
  });
4075
- btn.style.color = '#58a6ff';
4076
- btn.style.borderBottom = '2px solid #58a6ff';
4077
- btn.classList.add('active');
4090
+ btn.style.color = '#58a6ff'; btn.style.borderBottom = '2px solid #58a6ff'; btn.classList.add('active');
4078
4091
  body.querySelectorAll('.tab-content').forEach(c => c.style.display = 'none');
4079
4092
  const target = body.querySelector(`.tab-content.${tab}`);
4080
4093
  if (target) target.style.display = 'block';
@@ -4083,6 +4096,12 @@
4083
4096
  } else if (mod?.getStatus) {
4084
4097
  const status = mod.getStatus();
4085
4098
  body.innerHTML = `<div style="color:var(--text-secondary);line-height:1.8;">${JSON.stringify(status, null, 2).replace(/\n/g, '<br>')}</div>`;
4099
+ } else if (mod?.analyze || mod?.generate || mod?.search || mod?.execute) {
4100
+ // Module has methods but no UI — build a quick command panel
4101
+ const methods = Object.keys(mod).filter(k => typeof mod[k] === 'function');
4102
+ body.innerHTML = `<div style="margin-bottom:12px;"><input id="_mod_input_${moduleKey}" placeholder="Enter command or query..." style="width:100%;padding:8px 10px;border:1px solid var(--border-color);border-radius:5px;background:var(--bg-primary);color:var(--text-primary);font-size:12px;box-sizing:border-box;"></div>
4103
+ <div style="display:flex;flex-wrap:wrap;gap:6px;margin-bottom:12px;">${methods.slice(0,8).map(m => `<button onclick="(async()=>{const r=await window.cycleCAD.${moduleKey}.${m}(document.getElementById('_mod_input_${moduleKey}').value);document.getElementById('_mod_out_${moduleKey}').textContent=JSON.stringify(r,null,2)})()" style="padding:4px 10px;border-radius:4px;border:1px solid var(--border-color);background:var(--bg-tertiary);color:var(--text-primary);cursor:pointer;font-size:11px;">${m}()</button>`).join('')}</div>
4104
+ <pre id="_mod_out_${moduleKey}" style="background:var(--bg-primary);border:1px solid var(--border-color);border-radius:5px;padding:10px;font-size:11px;color:var(--text-secondary);white-space:pre-wrap;max-height:300px;overflow-y:auto;margin:0;">Ready. Click a function above.</pre>`;
4086
4105
  } else {
4087
4106
  body.innerHTML = `<div style="color:var(--accent-green);padding:12px;text-align:center;"><p style="font-weight:600;margin-bottom:8px;">Module Loaded</p><p style="color:var(--text-secondary);">Access via console:<br><code style="background:var(--bg-tertiary);padding:2px 6px;border-radius:3px;">window.cycleCAD.${moduleKey}</code></p></div>`;
4088
4107
  }
@@ -5221,6 +5240,6 @@
5221
5240
  </div>
5222
5241
  </div>
5223
5242
 
5224
- <span id="version-badge" style="position:fixed;bottom:42px;left:50%;transform:translateX(-50%);z-index:999;font-size:0.9rem;color:rgba(255,255,255,0.9);letter-spacing:0.1em;white-space:nowrap;padding:6px 16px;user-select:all;pointer-events:auto;font-family:monospace;font-weight:700;background:rgba(0,0,0,0.7);border:1px solid rgba(88,166,255,0.4);border-radius:6px;text-shadow:0 1px 3px rgba(0,0,0,0.5);" title="cycleCAD version">cycleCAD v1.0.1</span>
5243
+ <span id="version-badge" style="position:fixed;bottom:42px;left:50%;transform:translateX(-50%);z-index:999;font-size:0.9rem;color:rgba(255,255,255,0.9);letter-spacing:0.1em;white-space:nowrap;padding:6px 16px;user-select:all;pointer-events:auto;font-family:monospace;font-weight:700;background:rgba(0,0,0,0.7);border:1px solid rgba(88,166,255,0.4);border-radius:6px;text-shadow:0 1px 3px rgba(0,0,0,0.5);" title="cycleCAD version">cycleCAD v1.0.3</span>
5225
5244
  </body>
5226
5245
  </html>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cyclecad",
3
- "version": "1.0.2",
3
+ "version": "1.0.3",
4
4
  "description": "Browser-based parametric 3D CAD modeler with AI-powered tools, native Inventor file parsing, and smart assembly management. No install required.",
5
5
  "main": "index.html",
6
6
  "bin": {