uidex 0.5.2 → 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.
@@ -115,6 +115,7 @@ function freezeEntity(entity, flows) {
115
115
  function createRegistry() {
116
116
  const store = emptyStore();
117
117
  let flowsCache = null;
118
+ const patternCache = /* @__PURE__ */ new Map();
118
119
  const getFlows = () => {
119
120
  if (flowsCache === null) flowsCache = Array.from(store.flow.values());
120
121
  return flowsCache;
@@ -124,6 +125,7 @@ function createRegistry() {
124
125
  const key = entityKey(entity);
125
126
  store[entity.kind].set(key, entity);
126
127
  flowsCache = null;
128
+ patternCache.delete(entity.kind);
127
129
  };
128
130
  const get = (kind, id) => {
129
131
  assertEntityKind(kind);
@@ -131,6 +133,38 @@ function createRegistry() {
131
133
  if (raw === void 0) return void 0;
132
134
  return freezeEntity(raw, getFlows());
133
135
  };
136
+ const getPatternsForKind = (kind) => {
137
+ const cached = patternCache.get(kind);
138
+ if (cached !== void 0)
139
+ return cached;
140
+ const patterns = [];
141
+ for (const [key, entity] of store[kind]) {
142
+ if (key.endsWith("*")) {
143
+ patterns.push({
144
+ prefix: key.slice(0, -1),
145
+ entity
146
+ });
147
+ }
148
+ }
149
+ patternCache.set(
150
+ kind,
151
+ patterns
152
+ );
153
+ return patterns;
154
+ };
155
+ const matchPattern = (kind, id) => {
156
+ assertEntityKind(kind);
157
+ const patterns = getPatternsForKind(kind);
158
+ if (patterns.length === 0) return void 0;
159
+ let best;
160
+ for (const entry of patterns) {
161
+ if (id.startsWith(entry.prefix) && (best === void 0 || entry.prefix.length > best.prefix.length)) {
162
+ best = entry;
163
+ }
164
+ }
165
+ if (best === void 0) return void 0;
166
+ return freezeEntity(best.entity, getFlows());
167
+ };
134
168
  const list = (kind) => {
135
169
  assertEntityKind(kind);
136
170
  const flows = getFlows();
@@ -181,6 +215,7 @@ function createRegistry() {
181
215
  return {
182
216
  add,
183
217
  get,
218
+ matchPattern,
184
219
  list,
185
220
  query,
186
221
  byScope,
@@ -1130,6 +1165,9 @@ var tailwind_built_default = `/*! tailwindcss v4.2.2 | MIT License | https://tai
1130
1165
  .relative {
1131
1166
  position: relative;
1132
1167
  }
1168
+ .static {
1169
+ position: static;
1170
+ }
1133
1171
  .inset-0 {
1134
1172
  inset: calc(var(--spacing) * 0);
1135
1173
  }
@@ -3582,7 +3620,7 @@ function createCursorTooltip(deps) {
3582
3620
  // src/browser/surface/inspector.ts
3583
3621
  function entityForRef(ref2, registry) {
3584
3622
  if (registry) {
3585
- const found = registry.get(ref2.kind, ref2.id);
3623
+ const found = registry.get(ref2.kind, ref2.id) ?? registry.matchPattern?.(ref2.kind, ref2.id);
3586
3624
  if (found) return found;
3587
3625
  }
3588
3626
  if (ref2.kind === "route") return { kind: "route", path: ref2.id, page: ref2.id };
@@ -5532,6 +5570,14 @@ var badgeVariants = cva(badgeBase, {
5532
5570
  }
5533
5571
  }
5534
5572
  });
5573
+ function badgeTpl(content, options = {}) {
5574
+ const { variant, size, class: extra } = options;
5575
+ return import_lit_html2.html`
5576
+ <span class=${cn(badgeVariants({ variant, size }), extra)} data-slot="badge"
5577
+ >${content}</span
5578
+ >
5579
+ `;
5580
+ }
5535
5581
 
5536
5582
  // src/browser/views/primitives/chip.ts
5537
5583
  var CHIP_CLASS = "inline-flex items-center gap-1.5 text-xs font-medium text-muted-foreground";
@@ -6860,7 +6906,10 @@ function renderDetailSurface(surface, ctx, root) {
6860
6906
  >
6861
6907
  ${surface.title}
6862
6908
  </h2>` : import_lit_html2.nothing}
6863
- <span class="ml-auto">${kindBadgeTpl(surface.entityKind)}</span>
6909
+ <span class="ml-auto flex items-center gap-1">
6910
+ ${surface.unregistered ? badgeTpl("Unregistered", { variant: "warning", size: "sm" }) : import_lit_html2.nothing}
6911
+ ${kindBadgeTpl(surface.entityKind)}
6912
+ </span>
6864
6913
  </div>
6865
6914
  ${surface.subtitle ? subtitleTpl(surface.subtitle) : import_lit_html2.nothing}
6866
6915
  <div
@@ -9730,12 +9779,11 @@ function createEntityDetailView(config) {
9730
9779
  if (!ctx.ref || ctx.ref.kind !== kind) {
9731
9780
  return { kind: "detail", entityKind: kind };
9732
9781
  }
9733
- const entity = ctx.registry.get(kind, ctx.ref.id);
9734
- if (!entity) {
9735
- return { kind: "detail", entityKind: kind, notFound: ctx.ref };
9736
- }
9737
- const metaEntity = entity;
9738
- const meta = metaEntity.meta;
9782
+ const exactEntity = ctx.registry.get(kind, ctx.ref.id);
9783
+ const patternEntity = exactEntity ? void 0 : ctx.registry.matchPattern?.(kind, ctx.ref.id);
9784
+ const entity = exactEntity ?? patternEntity;
9785
+ const metaEntity = entity ? entity : null;
9786
+ const meta = metaEntity?.meta;
9739
9787
  const actions = [];
9740
9788
  const cloud = ctx.cloud;
9741
9789
  actions.push({ ...reportAction(ctx.ref), group: "Report" });
@@ -9753,14 +9801,16 @@ function createEntityDetailView(config) {
9753
9801
  actions.push({ ...highlightElementAction(ctx.ref), group: "Inspect" });
9754
9802
  actions.push({ ...copyScreenshotAction(ctx.ref), group: "Inspect" });
9755
9803
  }
9756
- actions.push({
9757
- ...copyPathAction(ctx.ref, metaEntity.loc),
9758
- group: "Inspect"
9759
- });
9760
- actions.push({
9761
- ...copySnapshotAction(ctx.ref, metaEntity.loc),
9762
- group: "Inspect"
9763
- });
9804
+ if (metaEntity?.loc) {
9805
+ actions.push({
9806
+ ...copyPathAction(ctx.ref, metaEntity.loc),
9807
+ group: "Inspect"
9808
+ });
9809
+ actions.push({
9810
+ ...copySnapshotAction(ctx.ref, metaEntity.loc),
9811
+ group: "Inspect"
9812
+ });
9813
+ }
9764
9814
  const sections = [];
9765
9815
  if (meta?.description) {
9766
9816
  sections.push({ id: "description", text: meta.description });
@@ -9768,8 +9818,10 @@ function createEntityDetailView(config) {
9768
9818
  if (offerAcceptance && meta?.acceptance?.length) {
9769
9819
  sections.push({ id: "acceptance", items: meta.acceptance });
9770
9820
  }
9771
- for (const s of config.extraSections?.(ctx, entity) ?? []) {
9772
- sections.push(s);
9821
+ if (entity) {
9822
+ for (const s of config.extraSections?.(ctx, entity) ?? []) {
9823
+ sections.push(s);
9824
+ }
9773
9825
  }
9774
9826
  if (!DOM_BACKED_KINDS2.has(kind)) {
9775
9827
  sections.push({
@@ -9798,8 +9850,9 @@ function createEntityDetailView(config) {
9798
9850
  return {
9799
9851
  kind: "detail",
9800
9852
  entityKind: kind,
9801
- title: displayName(metaEntity),
9802
- subtitle: config.subtitle?.(ctx, entity),
9853
+ title: patternEntity ? ctx.ref.id : metaEntity ? displayName(metaEntity) : ctx.ref.id,
9854
+ subtitle: exactEntity ? config.subtitle?.(ctx, exactEntity) : void 0,
9855
+ unregistered: !entity,
9803
9856
  actions,
9804
9857
  sections
9805
9858
  };