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.
@@ -94,6 +94,7 @@ interface ReportRecord {
94
94
  interface Registry {
95
95
  add(entity: Entity): void;
96
96
  get<K extends EntityKind>(kind: K, id: string): EntityByKind<K> | undefined;
97
+ matchPattern<K extends EntityKind>(kind: K, id: string): EntityByKind<K> | undefined;
97
98
  list<K extends EntityKind>(kind: K): ReadonlyArray<EntityByKind<K>>;
98
99
  query(predicate: (entity: Entity) => boolean): Entity[];
99
100
  byScope(scope: Scope): Entity[];
@@ -362,6 +363,8 @@ interface DetailSurface {
362
363
  entityKind: EntityKind;
363
364
  /** Registry lookup failed — renders the "not found" placeholder. */
364
365
  notFound?: EntityRef;
366
+ /** Entity exists in the DOM but not in the registry (gen file). */
367
+ unregistered?: boolean;
365
368
  /** Entity display name, rendered as the heading. */
366
369
  title?: string;
367
370
  subtitle?: DetailSubtitle;
@@ -94,6 +94,7 @@ interface ReportRecord {
94
94
  interface Registry {
95
95
  add(entity: Entity): void;
96
96
  get<K extends EntityKind>(kind: K, id: string): EntityByKind<K> | undefined;
97
+ matchPattern<K extends EntityKind>(kind: K, id: string): EntityByKind<K> | undefined;
97
98
  list<K extends EntityKind>(kind: K): ReadonlyArray<EntityByKind<K>>;
98
99
  query(predicate: (entity: Entity) => boolean): Entity[];
99
100
  byScope(scope: Scope): Entity[];
@@ -362,6 +363,8 @@ interface DetailSurface {
362
363
  entityKind: EntityKind;
363
364
  /** Registry lookup failed — renders the "not found" placeholder. */
364
365
  notFound?: EntityRef;
366
+ /** Entity exists in the DOM but not in the registry (gen file). */
367
+ unregistered?: boolean;
365
368
  /** Entity display name, rendered as the heading. */
366
369
  title?: string;
367
370
  subtitle?: DetailSubtitle;
@@ -74,6 +74,7 @@ function freezeEntity(entity, flows) {
74
74
  function createRegistry() {
75
75
  const store = emptyStore();
76
76
  let flowsCache = null;
77
+ const patternCache = /* @__PURE__ */ new Map();
77
78
  const getFlows = () => {
78
79
  if (flowsCache === null) flowsCache = Array.from(store.flow.values());
79
80
  return flowsCache;
@@ -83,6 +84,7 @@ function createRegistry() {
83
84
  const key = entityKey(entity);
84
85
  store[entity.kind].set(key, entity);
85
86
  flowsCache = null;
87
+ patternCache.delete(entity.kind);
86
88
  };
87
89
  const get = (kind, id) => {
88
90
  assertEntityKind(kind);
@@ -90,6 +92,38 @@ function createRegistry() {
90
92
  if (raw === void 0) return void 0;
91
93
  return freezeEntity(raw, getFlows());
92
94
  };
95
+ const getPatternsForKind = (kind) => {
96
+ const cached = patternCache.get(kind);
97
+ if (cached !== void 0)
98
+ return cached;
99
+ const patterns = [];
100
+ for (const [key, entity] of store[kind]) {
101
+ if (key.endsWith("*")) {
102
+ patterns.push({
103
+ prefix: key.slice(0, -1),
104
+ entity
105
+ });
106
+ }
107
+ }
108
+ patternCache.set(
109
+ kind,
110
+ patterns
111
+ );
112
+ return patterns;
113
+ };
114
+ const matchPattern = (kind, id) => {
115
+ assertEntityKind(kind);
116
+ const patterns = getPatternsForKind(kind);
117
+ if (patterns.length === 0) return void 0;
118
+ let best;
119
+ for (const entry of patterns) {
120
+ if (id.startsWith(entry.prefix) && (best === void 0 || entry.prefix.length > best.prefix.length)) {
121
+ best = entry;
122
+ }
123
+ }
124
+ if (best === void 0) return void 0;
125
+ return freezeEntity(best.entity, getFlows());
126
+ };
93
127
  const list = (kind) => {
94
128
  assertEntityKind(kind);
95
129
  const flows = getFlows();
@@ -140,6 +174,7 @@ function createRegistry() {
140
174
  return {
141
175
  add,
142
176
  get,
177
+ matchPattern,
143
178
  list,
144
179
  query,
145
180
  byScope,
@@ -1098,6 +1133,9 @@ var tailwind_built_default = `/*! tailwindcss v4.2.2 | MIT License | https://tai
1098
1133
  .relative {
1099
1134
  position: relative;
1100
1135
  }
1136
+ .static {
1137
+ position: static;
1138
+ }
1101
1139
  .inset-0 {
1102
1140
  inset: calc(var(--spacing) * 0);
1103
1141
  }
@@ -3550,7 +3588,7 @@ function createCursorTooltip(deps) {
3550
3588
  // src/browser/surface/inspector.ts
3551
3589
  function entityForRef(ref2, registry) {
3552
3590
  if (registry) {
3553
- const found = registry.get(ref2.kind, ref2.id);
3591
+ const found = registry.get(ref2.kind, ref2.id) ?? registry.matchPattern?.(ref2.kind, ref2.id);
3554
3592
  if (found) return found;
3555
3593
  }
3556
3594
  if (ref2.kind === "route") return { kind: "route", path: ref2.id, page: ref2.id };
@@ -5521,6 +5559,14 @@ var badgeVariants = cva(badgeBase, {
5521
5559
  }
5522
5560
  }
5523
5561
  });
5562
+ function badgeTpl(content, options = {}) {
5563
+ const { variant, size, class: extra } = options;
5564
+ return html`
5565
+ <span class=${cn(badgeVariants({ variant, size }), extra)} data-slot="badge"
5566
+ >${content}</span
5567
+ >
5568
+ `;
5569
+ }
5524
5570
 
5525
5571
  // src/browser/views/primitives/chip.ts
5526
5572
  var CHIP_CLASS = "inline-flex items-center gap-1.5 text-xs font-medium text-muted-foreground";
@@ -6877,7 +6923,10 @@ function renderDetailSurface(surface, ctx, root) {
6877
6923
  >
6878
6924
  ${surface.title}
6879
6925
  </h2>` : nothing}
6880
- <span class="ml-auto">${kindBadgeTpl(surface.entityKind)}</span>
6926
+ <span class="ml-auto flex items-center gap-1">
6927
+ ${surface.unregistered ? badgeTpl("Unregistered", { variant: "warning", size: "sm" }) : nothing}
6928
+ ${kindBadgeTpl(surface.entityKind)}
6929
+ </span>
6881
6930
  </div>
6882
6931
  ${surface.subtitle ? subtitleTpl(surface.subtitle) : nothing}
6883
6932
  <div
@@ -9763,12 +9812,11 @@ function createEntityDetailView(config) {
9763
9812
  if (!ctx.ref || ctx.ref.kind !== kind) {
9764
9813
  return { kind: "detail", entityKind: kind };
9765
9814
  }
9766
- const entity = ctx.registry.get(kind, ctx.ref.id);
9767
- if (!entity) {
9768
- return { kind: "detail", entityKind: kind, notFound: ctx.ref };
9769
- }
9770
- const metaEntity = entity;
9771
- const meta = metaEntity.meta;
9815
+ const exactEntity = ctx.registry.get(kind, ctx.ref.id);
9816
+ const patternEntity = exactEntity ? void 0 : ctx.registry.matchPattern?.(kind, ctx.ref.id);
9817
+ const entity = exactEntity ?? patternEntity;
9818
+ const metaEntity = entity ? entity : null;
9819
+ const meta = metaEntity?.meta;
9772
9820
  const actions = [];
9773
9821
  const cloud = ctx.cloud;
9774
9822
  actions.push({ ...reportAction(ctx.ref), group: "Report" });
@@ -9786,14 +9834,16 @@ function createEntityDetailView(config) {
9786
9834
  actions.push({ ...highlightElementAction(ctx.ref), group: "Inspect" });
9787
9835
  actions.push({ ...copyScreenshotAction(ctx.ref), group: "Inspect" });
9788
9836
  }
9789
- actions.push({
9790
- ...copyPathAction(ctx.ref, metaEntity.loc),
9791
- group: "Inspect"
9792
- });
9793
- actions.push({
9794
- ...copySnapshotAction(ctx.ref, metaEntity.loc),
9795
- group: "Inspect"
9796
- });
9837
+ if (metaEntity?.loc) {
9838
+ actions.push({
9839
+ ...copyPathAction(ctx.ref, metaEntity.loc),
9840
+ group: "Inspect"
9841
+ });
9842
+ actions.push({
9843
+ ...copySnapshotAction(ctx.ref, metaEntity.loc),
9844
+ group: "Inspect"
9845
+ });
9846
+ }
9797
9847
  const sections = [];
9798
9848
  if (meta?.description) {
9799
9849
  sections.push({ id: "description", text: meta.description });
@@ -9801,8 +9851,10 @@ function createEntityDetailView(config) {
9801
9851
  if (offerAcceptance && meta?.acceptance?.length) {
9802
9852
  sections.push({ id: "acceptance", items: meta.acceptance });
9803
9853
  }
9804
- for (const s of config.extraSections?.(ctx, entity) ?? []) {
9805
- sections.push(s);
9854
+ if (entity) {
9855
+ for (const s of config.extraSections?.(ctx, entity) ?? []) {
9856
+ sections.push(s);
9857
+ }
9806
9858
  }
9807
9859
  if (!DOM_BACKED_KINDS2.has(kind)) {
9808
9860
  sections.push({
@@ -9831,8 +9883,9 @@ function createEntityDetailView(config) {
9831
9883
  return {
9832
9884
  kind: "detail",
9833
9885
  entityKind: kind,
9834
- title: displayName(metaEntity),
9835
- subtitle: config.subtitle?.(ctx, entity),
9886
+ title: patternEntity ? ctx.ref.id : metaEntity ? displayName(metaEntity) : ctx.ref.id,
9887
+ subtitle: exactEntity ? config.subtitle?.(ctx, exactEntity) : void 0,
9888
+ unregistered: !entity,
9836
9889
  actions,
9837
9890
  sections
9838
9891
  };