uidex 0.5.1 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -93,6 +93,7 @@ function freezeEntity(entity, flows) {
93
93
  function createRegistry() {
94
94
  const store = emptyStore();
95
95
  let flowsCache = null;
96
+ const patternCache = /* @__PURE__ */ new Map();
96
97
  const getFlows = () => {
97
98
  if (flowsCache === null) flowsCache = Array.from(store.flow.values());
98
99
  return flowsCache;
@@ -102,6 +103,7 @@ function createRegistry() {
102
103
  const key = entityKey(entity);
103
104
  store[entity.kind].set(key, entity);
104
105
  flowsCache = null;
106
+ patternCache.delete(entity.kind);
105
107
  };
106
108
  const get = (kind, id) => {
107
109
  assertEntityKind(kind);
@@ -109,6 +111,38 @@ function createRegistry() {
109
111
  if (raw === void 0) return void 0;
110
112
  return freezeEntity(raw, getFlows());
111
113
  };
114
+ const getPatternsForKind = (kind) => {
115
+ const cached = patternCache.get(kind);
116
+ if (cached !== void 0)
117
+ return cached;
118
+ const patterns = [];
119
+ for (const [key, entity] of store[kind]) {
120
+ if (key.endsWith("*")) {
121
+ patterns.push({
122
+ prefix: key.slice(0, -1),
123
+ entity
124
+ });
125
+ }
126
+ }
127
+ patternCache.set(
128
+ kind,
129
+ patterns
130
+ );
131
+ return patterns;
132
+ };
133
+ const matchPattern = (kind, id) => {
134
+ assertEntityKind(kind);
135
+ const patterns = getPatternsForKind(kind);
136
+ if (patterns.length === 0) return void 0;
137
+ let best;
138
+ for (const entry of patterns) {
139
+ if (id.startsWith(entry.prefix) && (best === void 0 || entry.prefix.length > best.prefix.length)) {
140
+ best = entry;
141
+ }
142
+ }
143
+ if (best === void 0) return void 0;
144
+ return freezeEntity(best.entity, getFlows());
145
+ };
112
146
  const list = (kind) => {
113
147
  assertEntityKind(kind);
114
148
  const flows = getFlows();
@@ -159,6 +193,7 @@ function createRegistry() {
159
193
  return {
160
194
  add,
161
195
  get,
196
+ matchPattern,
162
197
  list,
163
198
  query,
164
199
  byScope,
@@ -840,6 +875,9 @@ var tailwind_built_default = `/*! tailwindcss v4.2.2 | MIT License | https://tai
840
875
  .relative {
841
876
  position: relative;
842
877
  }
878
+ .static {
879
+ position: static;
880
+ }
843
881
  .inset-0 {
844
882
  inset: calc(var(--spacing) * 0);
845
883
  }
@@ -3229,16 +3267,18 @@ function createCursorTooltip(deps) {
3229
3267
  const renderBody = () => {
3230
3268
  body.replaceChildren();
3231
3269
  if (typeof currentContent === "string") {
3232
- applyColor(DEFAULT_TOOLTIP_COLOR);
3270
+ applyColor("#a1a1aa");
3271
+ el2.style.opacity = "0.6";
3233
3272
  body.append(document.createTextNode(currentContent));
3234
3273
  return;
3235
3274
  }
3236
3275
  if (!currentContent) return;
3276
+ el2.style.opacity = "1";
3237
3277
  const { entity, node } = currentContent;
3238
3278
  const style = KIND_STYLE[entity.kind];
3239
3279
  const demoted = entity.kind === "primitive";
3240
3280
  applyColor(style?.color ?? DEFAULT_TOOLTIP_COLOR);
3241
- el2.style.opacity = demoted ? "0.55" : "1";
3281
+ if (demoted) el2.style.opacity = "0.55";
3242
3282
  if (style) {
3243
3283
  const svg = (0, import_lucide2.createElement)(style.icon);
3244
3284
  svg.setAttribute("aria-hidden", "true");
@@ -3289,7 +3329,7 @@ function createCursorTooltip(deps) {
3289
3329
  // src/browser/surface/inspector.ts
3290
3330
  function entityForRef(ref, registry) {
3291
3331
  if (registry) {
3292
- const found = registry.get(ref.kind, ref.id);
3332
+ const found = registry.get(ref.kind, ref.id) ?? registry.matchPattern?.(ref.kind, ref.id);
3293
3333
  if (found) return found;
3294
3334
  }
3295
3335
  if (ref.kind === "route") return { kind: "route", path: ref.id, page: ref.id };
@@ -3346,7 +3386,8 @@ function createInspector(options) {
3346
3386
  resolveAll = (target) => defaultResolveAllMatches(target, registry),
3347
3387
  onHover,
3348
3388
  onSelect,
3349
- onCycle
3389
+ onCycle,
3390
+ onObscured
3350
3391
  } = options;
3351
3392
  let mounted = false;
3352
3393
  let currentEl = null;
@@ -3355,6 +3396,13 @@ function createInspector(options) {
3355
3396
  let layerIndex = 0;
3356
3397
  let lastCursor = { x: 0, y: 0 };
3357
3398
  const makeStack = () => stack.length > 0 ? { matches: stack, index: layerIndex, current: stack[layerIndex] } : null;
3399
+ const onDocumentLeave = () => {
3400
+ currentEl = null;
3401
+ stack = [];
3402
+ layerIndex = 0;
3403
+ session.highlight.unhover();
3404
+ onObscured?.(lastCursor);
3405
+ };
3358
3406
  const onMouseMove = (e) => {
3359
3407
  if (!(e.target instanceof Element)) return;
3360
3408
  const matches = resolveAll(e.target);
@@ -3407,6 +3455,7 @@ function createInspector(options) {
3407
3455
  document.head.appendChild(cursorStyleEl);
3408
3456
  }
3409
3457
  document.addEventListener("mousemove", onMouseMove);
3458
+ document.addEventListener("mouseleave", onDocumentLeave);
3410
3459
  document.addEventListener("click", onClick, true);
3411
3460
  document.addEventListener("contextmenu", onContextMenu, true);
3412
3461
  },
@@ -3421,6 +3470,7 @@ function createInspector(options) {
3421
3470
  cursorStyleEl = null;
3422
3471
  }
3423
3472
  document.removeEventListener("mousemove", onMouseMove);
3473
+ document.removeEventListener("mouseleave", onDocumentLeave);
3424
3474
  document.removeEventListener("click", onClick, true);
3425
3475
  document.removeEventListener("contextmenu", onContextMenu, true);
3426
3476
  session.highlight.unhover();
@@ -4197,6 +4247,10 @@ function createSurfaceShell(options) {
4197
4247
  },
4198
4248
  onCycle: (stack, cursor) => {
4199
4249
  showStack(stack, cursor);
4250
+ },
4251
+ onObscured: (cursor) => {
4252
+ overlay.hide();
4253
+ tooltip.update("iframe", cursor);
4200
4254
  }
4201
4255
  });
4202
4256
  cleanup.add(inspector);