@pulse-js/tools 0.1.6 → 0.1.8

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/README.md CHANGED
@@ -59,7 +59,7 @@ document.body.appendChild(inspector);
59
59
 
60
60
  ## Tips
61
61
 
62
- - **Naming Matters**: Ensure you provide string names to your Sources and Guards (e.g., `source(val, { name: 'my-source' })`). The DevTools rely on these names to provide meaningful debugging information. Unnamed units will appear but are harder to trace.
62
+ - **Naming Matters**: Ensure you provide string names to your Sources and Guards (e.g., `source(val, { name: 'my-source' })`). The DevTools rely on these names to provide meaningful debugging information. Unnamed units will not appear.
63
63
  - **Status Indicators**:
64
64
  - 🟢 **Green**: OK / Active
65
65
  - 🔴 **Red**: Fails
package/dist/index.cjs CHANGED
@@ -45,7 +45,8 @@ var ICONS = {
45
45
  list: `<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><line x1="8" y1="6" x2="21" y2="6"/><line x1="8" y1="12" x2="21" y2="12"/><line x1="8" y1="18" x2="21" y2="18"/><line x1="3" y1="6" x2="3.01" y2="6"/><line x1="3" y1="12" x2="3.01" y2="12"/><line x1="3" y1="18" x2="3.01" y2="18"/></svg>`,
46
46
  chevronRight: `<svg width="10" height="10" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M9 18l6-6-6-6"/></svg>`,
47
47
  chevronDown: `<svg width="10" height="10" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M6 9l6 6 6-6"/></svg>`,
48
- edit: `<svg width="10" height="10" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7"/><path d="M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z"/></svg>`
48
+ edit: `<svg width="10" height="10" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7"/><path d="M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z"/></svg>`,
49
+ refresh: `<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M21.5 2v6h-6M2.5 22v-6h6M2 11.5a10 10 0 0 1 18.8-4.3M22 12.5a10 10 0 0 1-18.8 4.2"/></svg>`
49
50
  };
50
51
  var STORAGE_KEY = "pulse-devtools-state";
51
52
  var PulseInspector = class extends HTMLElement {
@@ -64,10 +65,16 @@ var PulseInspector = class extends HTMLElement {
64
65
  editValue = "";
65
66
  unsubscribeRegistry;
66
67
  unitSubscriptions = /* @__PURE__ */ new Map();
68
+ shortcut = "Ctrl+M";
69
+ // Default shortcut
67
70
  constructor() {
68
71
  super();
69
72
  this.shadow = this.attachShadow({ mode: "open" });
70
73
  this.loadState();
74
+ const shortcutAttr = this.getAttribute("shortcut");
75
+ if (shortcutAttr) {
76
+ this.shortcut = shortcutAttr;
77
+ }
71
78
  }
72
79
  connectedCallback() {
73
80
  this.render();
@@ -123,7 +130,14 @@ var PulseInspector = class extends HTMLElement {
123
130
  this.shadow.addEventListener("keydown", this.handleEditKeydown);
124
131
  }
125
132
  handleKeyDown = (e) => {
126
- if (e.ctrlKey && e.key.toLowerCase() === "m") {
133
+ const parts = this.shortcut.split("+").map((p) => p.trim().toLowerCase());
134
+ const needsCtrl = parts.includes("ctrl");
135
+ const needsShift = parts.includes("shift");
136
+ const needsAlt = parts.includes("alt");
137
+ const key = parts.find((p) => !["ctrl", "shift", "alt"].includes(p));
138
+ if (!key) return;
139
+ const matches = e.ctrlKey === needsCtrl && e.shiftKey === needsShift && e.altKey === needsAlt && e.key.toLowerCase() === key;
140
+ if (matches) {
127
141
  e.preventDefault();
128
142
  this.toggle();
129
143
  }
@@ -190,6 +204,10 @@ var PulseInspector = class extends HTMLElement {
190
204
  this.toggle();
191
205
  return;
192
206
  }
207
+ if (target.id === "refresh" || target.closest("#refresh")) {
208
+ this.refreshUnits();
209
+ return;
210
+ }
193
211
  const tabEl = target.closest(".tab-btn");
194
212
  if (tabEl) {
195
213
  const tab = tabEl.getAttribute("data-tab");
@@ -202,10 +220,10 @@ var PulseInspector = class extends HTMLElement {
202
220
  }
203
221
  const valueEl = target.closest(".editable-value");
204
222
  if (valueEl) {
223
+ const id = valueEl.getAttribute("data-id");
205
224
  const name = valueEl.getAttribute("data-name");
206
- const unit = this.units.find((u) => u._name === name);
207
- const hasName = unit._name && unit._name !== "unnamed";
208
- if (unit && !("state" in unit) && hasName) {
225
+ const unit = this.units.find((u) => u._id === id || u._name === name);
226
+ if (unit && !("state" in unit)) {
209
227
  this.editingUnit = unit;
210
228
  this.editValue = JSON.stringify(unit());
211
229
  this.render();
@@ -292,7 +310,10 @@ var PulseInspector = class extends HTMLElement {
292
310
  <strong style="font-size:14px;letter-spacing:0.5px">PULSE</strong>
293
311
  <span style="font-size:10px;opacity:0.5;margin-top:2px">v0.2.0</span>
294
312
  </div>
295
- <div id="close" class="icon-btn">\xD7</div>
313
+ <div style="display:flex;gap:8px;align-items:center">
314
+ <div id="refresh" class="icon-btn" title="Refresh" style="font-size:16px">${ICONS.refresh}</div>
315
+ <div id="close" class="icon-btn" title="Close (${this.shortcut})">\xD7</div>
316
+ </div>
296
317
  </div>
297
318
 
298
319
  <div class="tabs">
@@ -325,6 +346,7 @@ var PulseInspector = class extends HTMLElement {
325
346
  renderUnitCard(unit) {
326
347
  const isGuard = "state" in unit;
327
348
  const name = unit._name || "unnamed";
349
+ const id = unit._id;
328
350
  const explanation = isGuard ? unit.explain() : null;
329
351
  const value = isGuard ? explanation.value : unit();
330
352
  let status = "ok";
@@ -346,13 +368,13 @@ var PulseInspector = class extends HTMLElement {
346
368
  <input class="edit-input" value='${this.safeStringify(value)}' />
347
369
  </form>
348
370
  ` : `
349
- <div class="value-row ${!isGuard && name !== "unnamed" ? "editable-value" : ""}"
371
+ <div class="value-row ${!isGuard ? "editable-value" : ""}"
372
+ data-id="${id}"
350
373
  data-name="${name}"
351
- title="${!isGuard ? name === "unnamed" ? "Unnamed sources cannot be edited (not trackable)" : "Click to edit" : ""}">
374
+ title="${!isGuard ? "Click to edit" : ""}">
352
375
  <span style="opacity:0.5;margin-right:6px">Value:</span>
353
376
  <span class="value-text">${this.formatValue(value)}</span>
354
- ${!isGuard && name !== "unnamed" ? `<span class="edit-icon">${ICONS.edit}</span>` : ""}
355
- ${!isGuard && name === "unnamed" ? `<span style="opacity:0.3;font-size:10px;margin-left:auto">\u{1F512} Locked</span>` : ""}
377
+ ${!isGuard ? `<span class="edit-icon">${ICONS.edit}</span>` : ""}
356
378
  </div>
357
379
  `}
358
380
 
package/dist/index.d.cts CHANGED
@@ -8,6 +8,7 @@ declare class PulseInspector extends HTMLElement {
8
8
  private editValue;
9
9
  private unsubscribeRegistry?;
10
10
  private unitSubscriptions;
11
+ private shortcut;
11
12
  constructor();
12
13
  connectedCallback(): void;
13
14
  disconnectedCallback(): void;
package/dist/index.d.ts CHANGED
@@ -8,6 +8,7 @@ declare class PulseInspector extends HTMLElement {
8
8
  private editValue;
9
9
  private unsubscribeRegistry?;
10
10
  private unitSubscriptions;
11
+ private shortcut;
11
12
  constructor();
12
13
  connectedCallback(): void;
13
14
  disconnectedCallback(): void;
package/dist/index.js CHANGED
@@ -19,7 +19,8 @@ var ICONS = {
19
19
  list: `<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><line x1="8" y1="6" x2="21" y2="6"/><line x1="8" y1="12" x2="21" y2="12"/><line x1="8" y1="18" x2="21" y2="18"/><line x1="3" y1="6" x2="3.01" y2="6"/><line x1="3" y1="12" x2="3.01" y2="12"/><line x1="3" y1="18" x2="3.01" y2="18"/></svg>`,
20
20
  chevronRight: `<svg width="10" height="10" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M9 18l6-6-6-6"/></svg>`,
21
21
  chevronDown: `<svg width="10" height="10" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M6 9l6 6 6-6"/></svg>`,
22
- edit: `<svg width="10" height="10" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7"/><path d="M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z"/></svg>`
22
+ edit: `<svg width="10" height="10" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7"/><path d="M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z"/></svg>`,
23
+ refresh: `<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M21.5 2v6h-6M2.5 22v-6h6M2 11.5a10 10 0 0 1 18.8-4.3M22 12.5a10 10 0 0 1-18.8 4.2"/></svg>`
23
24
  };
24
25
  var STORAGE_KEY = "pulse-devtools-state";
25
26
  var PulseInspector = class extends HTMLElement {
@@ -38,10 +39,16 @@ var PulseInspector = class extends HTMLElement {
38
39
  editValue = "";
39
40
  unsubscribeRegistry;
40
41
  unitSubscriptions = /* @__PURE__ */ new Map();
42
+ shortcut = "Ctrl+M";
43
+ // Default shortcut
41
44
  constructor() {
42
45
  super();
43
46
  this.shadow = this.attachShadow({ mode: "open" });
44
47
  this.loadState();
48
+ const shortcutAttr = this.getAttribute("shortcut");
49
+ if (shortcutAttr) {
50
+ this.shortcut = shortcutAttr;
51
+ }
45
52
  }
46
53
  connectedCallback() {
47
54
  this.render();
@@ -97,7 +104,14 @@ var PulseInspector = class extends HTMLElement {
97
104
  this.shadow.addEventListener("keydown", this.handleEditKeydown);
98
105
  }
99
106
  handleKeyDown = (e) => {
100
- if (e.ctrlKey && e.key.toLowerCase() === "m") {
107
+ const parts = this.shortcut.split("+").map((p) => p.trim().toLowerCase());
108
+ const needsCtrl = parts.includes("ctrl");
109
+ const needsShift = parts.includes("shift");
110
+ const needsAlt = parts.includes("alt");
111
+ const key = parts.find((p) => !["ctrl", "shift", "alt"].includes(p));
112
+ if (!key) return;
113
+ const matches = e.ctrlKey === needsCtrl && e.shiftKey === needsShift && e.altKey === needsAlt && e.key.toLowerCase() === key;
114
+ if (matches) {
101
115
  e.preventDefault();
102
116
  this.toggle();
103
117
  }
@@ -164,6 +178,10 @@ var PulseInspector = class extends HTMLElement {
164
178
  this.toggle();
165
179
  return;
166
180
  }
181
+ if (target.id === "refresh" || target.closest("#refresh")) {
182
+ this.refreshUnits();
183
+ return;
184
+ }
167
185
  const tabEl = target.closest(".tab-btn");
168
186
  if (tabEl) {
169
187
  const tab = tabEl.getAttribute("data-tab");
@@ -176,10 +194,10 @@ var PulseInspector = class extends HTMLElement {
176
194
  }
177
195
  const valueEl = target.closest(".editable-value");
178
196
  if (valueEl) {
197
+ const id = valueEl.getAttribute("data-id");
179
198
  const name = valueEl.getAttribute("data-name");
180
- const unit = this.units.find((u) => u._name === name);
181
- const hasName = unit._name && unit._name !== "unnamed";
182
- if (unit && !("state" in unit) && hasName) {
199
+ const unit = this.units.find((u) => u._id === id || u._name === name);
200
+ if (unit && !("state" in unit)) {
183
201
  this.editingUnit = unit;
184
202
  this.editValue = JSON.stringify(unit());
185
203
  this.render();
@@ -266,7 +284,10 @@ var PulseInspector = class extends HTMLElement {
266
284
  <strong style="font-size:14px;letter-spacing:0.5px">PULSE</strong>
267
285
  <span style="font-size:10px;opacity:0.5;margin-top:2px">v0.2.0</span>
268
286
  </div>
269
- <div id="close" class="icon-btn">\xD7</div>
287
+ <div style="display:flex;gap:8px;align-items:center">
288
+ <div id="refresh" class="icon-btn" title="Refresh" style="font-size:16px">${ICONS.refresh}</div>
289
+ <div id="close" class="icon-btn" title="Close (${this.shortcut})">\xD7</div>
290
+ </div>
270
291
  </div>
271
292
 
272
293
  <div class="tabs">
@@ -299,6 +320,7 @@ var PulseInspector = class extends HTMLElement {
299
320
  renderUnitCard(unit) {
300
321
  const isGuard = "state" in unit;
301
322
  const name = unit._name || "unnamed";
323
+ const id = unit._id;
302
324
  const explanation = isGuard ? unit.explain() : null;
303
325
  const value = isGuard ? explanation.value : unit();
304
326
  let status = "ok";
@@ -320,13 +342,13 @@ var PulseInspector = class extends HTMLElement {
320
342
  <input class="edit-input" value='${this.safeStringify(value)}' />
321
343
  </form>
322
344
  ` : `
323
- <div class="value-row ${!isGuard && name !== "unnamed" ? "editable-value" : ""}"
345
+ <div class="value-row ${!isGuard ? "editable-value" : ""}"
346
+ data-id="${id}"
324
347
  data-name="${name}"
325
- title="${!isGuard ? name === "unnamed" ? "Unnamed sources cannot be edited (not trackable)" : "Click to edit" : ""}">
348
+ title="${!isGuard ? "Click to edit" : ""}">
326
349
  <span style="opacity:0.5;margin-right:6px">Value:</span>
327
350
  <span class="value-text">${this.formatValue(value)}</span>
328
- ${!isGuard && name !== "unnamed" ? `<span class="edit-icon">${ICONS.edit}</span>` : ""}
329
- ${!isGuard && name === "unnamed" ? `<span style="opacity:0.3;font-size:10px;margin-left:auto">\u{1F512} Locked</span>` : ""}
351
+ ${!isGuard ? `<span class="edit-icon">${ICONS.edit}</span>` : ""}
330
352
  </div>
331
353
  `}
332
354
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pulse-js/tools",
3
- "version": "0.1.6",
3
+ "version": "0.1.8",
4
4
  "type": "module",
5
5
  "main": "dist/index.cjs",
6
6
  "module": "dist/index.js",
@@ -13,6 +13,6 @@
13
13
  "lint": "bun x tsc --noEmit"
14
14
  },
15
15
  "dependencies": {
16
- "@pulse-js/core": "^0.1.8"
16
+ "@pulse-js/core": "^0.2.0"
17
17
  }
18
18
  }