@typespec/html-program-viewer 0.72.0-dev.0 → 0.72.0-dev.2

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.
@@ -948,7 +948,7 @@ const TextDirectionProvider = ({
948
948
  * The main difference between this function and `slot` is that this function does not return the metadata required for a slot to be considered a properly renderable slot, it only converts the value to a slot properties object
949
949
  * @param value - the value of the slot, it can be a slot shorthand or a slot properties object
950
950
  */ function resolveShorthand(value) {
951
- if (typeof value === 'string' || typeof value === 'number' || Array.isArray(value) || // eslint-disable-next-line @typescript-eslint/no-explicit-any
951
+ if (typeof value === 'string' || typeof value === 'number' || isIterable(value) || // eslint-disable-next-line @typescript-eslint/no-explicit-any
952
952
  React.isValidElement(value)) {
953
953
  return {
954
954
  children: value
@@ -964,6 +964,8 @@ Slot shorthands can be strings, numbers, arrays or JSX elements`);
964
964
  }
965
965
  return value;
966
966
  }
967
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
968
+ const isIterable = (value)=>typeof value === 'object' && value !== null && Symbol.iterator in value;
967
969
 
968
970
  /**
969
971
  * Guard method to ensure a given element is a slot.
@@ -996,6 +998,7 @@ Slot shorthands can be strings, numbers, arrays or JSX elements`);
996
998
  * as we're verifying static properties that will not change between environments
997
999
  */ if (process.env.NODE_ENV !== 'production') {
998
1000
  const typedState = state;
1001
+ // eslint-disable-next-line @typescript-eslint/no-deprecated
999
1002
  for (const slotName of Object.keys(typedState.components)){
1000
1003
  const slotElement = typedState[slotName];
1001
1004
  if (slotElement === undefined) {
@@ -1006,6 +1009,7 @@ Slot shorthands can be strings, numbers, arrays or JSX elements`);
1006
1009
  // FIXME: this slot will still fail to support child render function scenario
1007
1010
  if (!isSlot(slotElement)) {
1008
1011
  typedState[slotName] = always(slotElement, {
1012
+ // eslint-disable-next-line @typescript-eslint/no-deprecated
1009
1013
  elementType: typedState.components[slotName]
1010
1014
  });
1011
1015
  // eslint-disable-next-line no-console
@@ -1016,7 +1020,9 @@ Be sure to create slots properly by using "slot.always" or "slot.optional".`);
1016
1020
  // This means a slot is being declared by using resolveShorthand on the state hook,
1017
1021
  // but the render method is using the new `assertSlots` method. That scenario can be solved by simply updating the slot element with the proper element type
1018
1022
  const { [SLOT_ELEMENT_TYPE_SYMBOL]: elementType } = slotElement;
1023
+ // eslint-disable-next-line @typescript-eslint/no-deprecated
1019
1024
  if (elementType !== typedState.components[slotName]) {
1025
+ // eslint-disable-next-line @typescript-eslint/no-deprecated
1020
1026
  slotElement[SLOT_ELEMENT_TYPE_SYMBOL] = typedState.components[slotName];
1021
1027
  // eslint-disable-next-line no-console
1022
1028
  console.warn(`@fluentui/react-utilities [${assertSlots.name}]:
@@ -1484,7 +1490,12 @@ function getNativeElementProps(tagName, props, excludedPropNames) {
1484
1490
  * element type.
1485
1491
  *
1486
1492
  * Equivalent to {@link getNativeElementProps}, but more type-safe.
1487
- */ const getIntrinsicElementProps = (/** The slot's default element type (e.g. 'div') */ tagName, /** The component's props object */ props, /** List of native props to exclude from the returned value */ excludedPropNames)=>{
1493
+ *
1494
+ * @param tagName - The slot's default element type (e.g. 'div')
1495
+ * @param props - The component's props object
1496
+ * @param excludedPropNames - List of native props to exclude from the returned value
1497
+ */ const getIntrinsicElementProps = (tagName, // eslint-disable-next-line @typescript-eslint/no-restricted-types -- in order to not introduce Type Restriction CHANGe which is kinda "breaking change from Types POV", we don't enforce our custom `RefAttributes` in this API, to be compatible with scenarios where non v9 interfaces might be used. This may/will change with React 19
1498
+ props, excludedPropNames)=>{
1488
1499
  var _props_as;
1489
1500
  // eslint-disable-next-line @typescript-eslint/no-deprecated
1490
1501
  return getNativeElementProps((_props_as = props.as) !== null && _props_as !== void 0 ? _props_as : tagName, props);
@@ -1628,12 +1639,21 @@ function useIdPrefix() {
1628
1639
  * updates all provided refs
1629
1640
  * @param refs - Refs to collectively update with one ref value.
1630
1641
  * @returns A function with an attached "current" prop, so that it can be treated like a RefObject.
1631
- */ function useMergedRefs(...refs) {
1642
+ */ // LegacyRef is actually not supported, but in React v18 types this is leaking directly from forwardRef component declaration
1643
+ function useMergedRefs(...refs) {
1632
1644
  'use no memo';
1633
1645
  const mergedCallback = React.useCallback((value)=>{
1634
1646
  // Update the "current" prop hanging on the function.
1635
1647
  mergedCallback.current = value;
1636
1648
  for (const ref of refs){
1649
+ if (typeof ref === 'string' && process.env.NODE_ENV !== 'production') {
1650
+ // eslint-disable-next-line no-console
1651
+ console.error(`@fluentui/react-utilities [useMergedRefs]:
1652
+ This hook does not support the usage of string refs. Please use React.useRef instead.
1653
+
1654
+ For more info on 'React.useRef', see https://react.dev/reference/react/useRef.
1655
+ For more info on string refs, see https://react.dev/blog/2024/04/25/react-19-upgrade-guide#removed-string-refs.`);
1656
+ }
1637
1657
  if (typeof ref === 'function') {
1638
1658
  ref(value);
1639
1659
  } else if (ref) {
@@ -5407,39 +5427,62 @@ const JsValue = ({ value }) => {
5407
5427
  }
5408
5428
  };
5409
5429
 
5410
- const TypeConfig = {
5430
+ const CommonPropsConfig = {
5431
+ namespace: "parent",
5432
+ name: "value"
5433
+ };
5434
+ const HiddenProps = [
5435
+ "entityKind",
5436
+ "kind",
5437
+ "node",
5438
+ "symbol",
5439
+ "templateNode",
5440
+ "templateArguments",
5441
+ "templateMapper",
5442
+ "instantiationParameters",
5443
+ "decorators",
5444
+ "isFinished"
5445
+ ];
5446
+ const HiddenPropsConfig = Object.fromEntries(HiddenProps.map((prop) => [prop, "skip"]));
5447
+ const TypeConfig = buildConfig({
5411
5448
  Namespace: {
5412
5449
  namespaces: "skip",
5413
- models: "nested",
5414
- scalars: "nested",
5415
- interfaces: "nested",
5416
- operations: "nested",
5417
- unions: "nested",
5418
- enums: "nested",
5419
- decoratorDeclarations: "nested"
5450
+ models: "nested-items",
5451
+ scalars: "nested-items",
5452
+ interfaces: "nested-items",
5453
+ operations: "nested-items",
5454
+ unions: "nested-items",
5455
+ enums: "nested-items",
5456
+ decoratorDeclarations: "nested-items"
5420
5457
  },
5421
5458
  Interface: {
5422
- operations: "nested",
5459
+ operations: "nested-items",
5423
5460
  sourceInterfaces: "ref"
5424
5461
  },
5425
5462
  Operation: {
5426
5463
  interface: "parent",
5427
- parameters: "nested",
5464
+ parameters: "nested-items",
5428
5465
  returnType: "ref",
5429
5466
  sourceOperation: "ref"
5430
5467
  },
5431
5468
  Model: {
5432
- indexer: "skip",
5469
+ indexer: {
5470
+ kind: "nested",
5471
+ properties: {
5472
+ key: "ref",
5473
+ value: "ref"
5474
+ }
5475
+ },
5433
5476
  baseModel: "ref",
5434
5477
  derivedModels: "ref",
5435
- properties: "nested",
5478
+ properties: "nested-items",
5436
5479
  sourceModel: "ref",
5437
5480
  sourceModels: "value"
5438
5481
  },
5439
5482
  Scalar: {
5440
5483
  baseScalar: "ref",
5441
5484
  derivedScalars: "ref",
5442
- constructors: "nested"
5485
+ constructors: "nested-items"
5443
5486
  },
5444
5487
  ModelProperty: {
5445
5488
  model: "parent",
@@ -5449,7 +5492,7 @@ const TypeConfig = {
5449
5492
  defaultValue: "value"
5450
5493
  },
5451
5494
  Enum: {
5452
- members: "nested"
5495
+ members: "nested-items"
5453
5496
  },
5454
5497
  EnumMember: {
5455
5498
  enum: "parent",
@@ -5457,8 +5500,8 @@ const TypeConfig = {
5457
5500
  value: "value"
5458
5501
  },
5459
5502
  Union: {
5460
- expression: "skip",
5461
- variants: "nested"
5503
+ expression: "value",
5504
+ variants: "nested-items"
5462
5505
  },
5463
5506
  UnionVariant: {
5464
5507
  union: "parent",
@@ -5468,13 +5511,13 @@ const TypeConfig = {
5468
5511
  value: "value"
5469
5512
  },
5470
5513
  Decorator: {
5471
- parameters: "nested",
5514
+ parameters: "nested-items",
5472
5515
  implementation: "skip",
5473
5516
  target: "ref"
5474
5517
  },
5475
5518
  ScalarConstructor: {
5476
5519
  scalar: "parent",
5477
- parameters: "nested"
5520
+ parameters: "nested-items"
5478
5521
  },
5479
5522
  FunctionParameter: null,
5480
5523
  Number: {
@@ -5486,10 +5529,10 @@ const TypeConfig = {
5486
5529
  value: "value"
5487
5530
  },
5488
5531
  Tuple: {
5489
- values: "nested"
5532
+ values: "nested-items"
5490
5533
  },
5491
5534
  StringTemplate: {
5492
- spans: "nested",
5535
+ spans: "nested-items",
5493
5536
  stringValue: "value"
5494
5537
  },
5495
5538
  StringTemplateSpan: {
@@ -5502,29 +5545,38 @@ const TypeConfig = {
5502
5545
  },
5503
5546
  // Don't want to expose those for now
5504
5547
  Intrinsic: null
5505
- };
5506
- const CommonPropsConfig = {
5507
- namespace: "parent"
5508
- };
5509
- const HiddenProps = [
5510
- "entityKind",
5511
- "kind",
5512
- "name",
5513
- "node",
5514
- "symbol",
5515
- "templateNode",
5516
- "templateArguments",
5517
- "templateMapper",
5518
- "instantiationParameters",
5519
- "decorators",
5520
- "projector",
5521
- "isFinished"
5522
- ];
5548
+ });
5523
5549
  new Set(HiddenProps);
5524
- function getPropertyRendering(type, key) {
5525
- const properties = TypeConfig[type.kind];
5526
- const action = properties?.[key] ?? CommonPropsConfig[key];
5527
- return action;
5550
+ function getRenderingConfig(type) {
5551
+ return TypeConfig[type.kind];
5552
+ }
5553
+ function buildConfig(raw) {
5554
+ return Object.fromEntries(
5555
+ Object.entries(raw).map(([kind, config]) => {
5556
+ return [kind, buildConfigForKind(config)];
5557
+ })
5558
+ );
5559
+ }
5560
+ function buildConfigForKind(config) {
5561
+ if (config === null) {
5562
+ return null;
5563
+ }
5564
+ return Object.fromEntries(
5565
+ Object.entries({ ...CommonPropsConfig, ...HiddenPropsConfig, ...config }).map(
5566
+ ([key, value]) => {
5567
+ return [key, buildConfigForProperty(value)];
5568
+ }
5569
+ )
5570
+ );
5571
+ }
5572
+ function buildConfigForProperty(value) {
5573
+ if (typeof value === "string") {
5574
+ return { kind: value };
5575
+ }
5576
+ return {
5577
+ kind: "nested",
5578
+ properties: buildConfigForKind(value.properties)
5579
+ };
5528
5580
  }
5529
5581
 
5530
5582
  const TreeNavigatorContext = createContext(void 0);
@@ -5649,13 +5701,22 @@ const SimpleType = ({ type, children }) => {
5649
5701
  children
5650
5702
  ] });
5651
5703
  };
5652
- const EntityProperties = ({ entity: type }) => {
5653
- const props = Object.entries(type).map(([key, value]) => {
5654
- const action = getPropertyRendering(type, key);
5655
- if (action === void 0 || action === "skip") {
5704
+ const EntityProperties = ({ entity }) => {
5705
+ return /* @__PURE__ */ jsxRuntimeExports.jsx(InspectObject, { value: entity, config: getRenderingConfig(entity) });
5706
+ };
5707
+ const InspectObject = ({
5708
+ value,
5709
+ config
5710
+ }) => {
5711
+ if (value === void 0) {
5712
+ return null;
5713
+ }
5714
+ const props = Object.entries(value).map(([key, value2]) => {
5715
+ const action = config?.[key];
5716
+ if (action === void 0 || action === null || action.kind === "skip") {
5656
5717
  return void 0;
5657
5718
  }
5658
- return /* @__PURE__ */ jsxRuntimeExports.jsx(EntityProperty, { name: key, value, action }, key);
5719
+ return /* @__PURE__ */ jsxRuntimeExports.jsx(EntityProperty, { name: key, value: value2, action }, key);
5659
5720
  }).filter((x) => Boolean(x));
5660
5721
  return /* @__PURE__ */ jsxRuntimeExports.jsx("ul", { children: props });
5661
5722
  };
@@ -5669,12 +5730,15 @@ const EntityProperty = (props) => {
5669
5730
  };
5670
5731
  const EntityPropertyValue = ({ value, action }) => {
5671
5732
  const render = (x) => {
5672
- if (action === "parent") {
5733
+ if (action.kind === "parent") {
5673
5734
  return x.entityKind === "Type" ? /* @__PURE__ */ jsxRuntimeExports.jsx(ParentReference, { type: x }) : null;
5674
5735
  }
5675
- const renderRef = action === "ref";
5736
+ const renderRef = action.kind === "ref";
5676
5737
  return renderRef ? /* @__PURE__ */ jsxRuntimeExports.jsx(EntityReference, { entity: x }) : /* @__PURE__ */ jsxRuntimeExports.jsx(EntityUI, { entity: x });
5677
5738
  };
5739
+ if (action.kind === "nested") {
5740
+ return /* @__PURE__ */ jsxRuntimeExports.jsx(InspectObject, { value, config: action.properties });
5741
+ }
5678
5742
  if (value === void 0) {
5679
5743
  return null;
5680
5744
  } else if (value.entityKind) {
@@ -1,6 +1,6 @@
1
1
  const manifest = {
2
2
  "version": "1.1.0",
3
- "commit": "cc74c72d4dcfd78a6a6a84e5618a16a5bad462c1"
3
+ "commit": "51469629ea82616f76c81923d0e4943315925052"
4
4
  };
5
5
 
6
6
  export { manifest as default };
@@ -26247,23 +26247,36 @@ class Alias extends NodeBase {
26247
26247
  * Resolve the value of this alias within `doc`, finding the last
26248
26248
  * instance of the `source` anchor before this node.
26249
26249
  */
26250
- resolve(doc) {
26250
+ resolve(doc, ctx) {
26251
+ let nodes;
26252
+ if (ctx?.aliasResolveCache) {
26253
+ nodes = ctx.aliasResolveCache;
26254
+ }
26255
+ else {
26256
+ nodes = [];
26257
+ visit(doc, {
26258
+ Node: (_key, node) => {
26259
+ if (isAlias(node) || hasAnchor(node))
26260
+ nodes.push(node);
26261
+ }
26262
+ });
26263
+ if (ctx)
26264
+ ctx.aliasResolveCache = nodes;
26265
+ }
26251
26266
  let found = undefined;
26252
- visit(doc, {
26253
- Node: (_key, node) => {
26254
- if (node === this)
26255
- return visit.BREAK;
26256
- if (node.anchor === this.source)
26257
- found = node;
26258
- }
26259
- });
26267
+ for (const node of nodes) {
26268
+ if (node === this)
26269
+ break;
26270
+ if (node.anchor === this.source)
26271
+ found = node;
26272
+ }
26260
26273
  return found;
26261
26274
  }
26262
26275
  toJSON(_arg, ctx) {
26263
26276
  if (!ctx)
26264
26277
  return { source: this.source };
26265
26278
  const { anchors, doc, maxAliasCount } = ctx;
26266
- const source = this.resolve(doc);
26279
+ const source = this.resolve(doc, ctx);
26267
26280
  if (!source) {
26268
26281
  const msg = `Unresolved alias (the anchor must be set before the alias): ${this.source}`;
26269
26282
  throw new ReferenceError(msg);
@@ -26374,8 +26387,7 @@ function createNode(value, tagName, ctx) {
26374
26387
  if (aliasDuplicateObjects && value && typeof value === 'object') {
26375
26388
  ref = sourceObjects.get(value);
26376
26389
  if (ref) {
26377
- if (!ref.anchor)
26378
- ref.anchor = onAnchor(value);
26390
+ ref.anchor ?? (ref.anchor = onAnchor(value));
26379
26391
  return new Alias(ref.anchor);
26380
26392
  }
26381
26393
  else {
@@ -26976,10 +26988,9 @@ function plainString(item, ctx, onComment, onChompKeep) {
26976
26988
  (inFlow && /[[\]{},]/.test(value))) {
26977
26989
  return quotedString(value, ctx);
26978
26990
  }
26979
- if (!value ||
26980
- /^[\n\t ,[\]{}#&*!|>'"%@`]|^[?-]$|^[?-][ \t]|[\n:][ \t]|[ \t]\n|[\n\t ]#|[\n\t :]$/.test(value)) {
26991
+ if (/^[\n\t ,[\]{}#&*!|>'"%@`]|^[?-]$|^[?-][ \t]|[\n:][ \t]|[ \t]\n|[\n\t ]#|[\n\t :]$/.test(value)) {
26981
26992
  // not allowed:
26982
- // - empty string, '-' or '?'
26993
+ // - '-' or '?'
26983
26994
  // - start with an indicator character (except [?:-]) or /[?-] /
26984
26995
  // - '\n ', ': ' or ' \n' anywhere
26985
26996
  // - '#' not preceded by a non-space char
@@ -27122,7 +27133,7 @@ function getTagObject(tags, item) {
27122
27133
  tagObj = tags.find(t => t.nodeClass && obj instanceof t.nodeClass);
27123
27134
  }
27124
27135
  if (!tagObj) {
27125
- const name = obj?.constructor?.name ?? typeof obj;
27136
+ const name = obj?.constructor?.name ?? (obj === null ? 'null' : typeof obj);
27126
27137
  throw new Error(`Tag not resolved for ${name} value`);
27127
27138
  }
27128
27139
  return tagObj;
@@ -27137,7 +27148,7 @@ function stringifyProps(node, tagObj, { anchors, doc }) {
27137
27148
  anchors.add(anchor);
27138
27149
  props.push(`&${anchor}`);
27139
27150
  }
27140
- const tag = node.tag ? node.tag : tagObj.default ? null : tagObj.tag;
27151
+ const tag = node.tag ?? (tagObj.default ? null : tagObj.tag);
27141
27152
  if (tag)
27142
27153
  props.push(doc.directives.tagString(tag));
27143
27154
  return props.join(' ');
@@ -27163,8 +27174,7 @@ function stringify$1(item, ctx, onComment, onChompKeep) {
27163
27174
  const node = isNode(item)
27164
27175
  ? item
27165
27176
  : ctx.doc.createNode(item, { onTagObj: o => (tagObj = o) });
27166
- if (!tagObj)
27167
- tagObj = getTagObject(ctx.doc.schema.tags, node);
27177
+ tagObj ?? (tagObj = getTagObject(ctx.doc.schema.tags, node));
27168
27178
  const props = stringifyProps(node, tagObj, ctx);
27169
27179
  if (props.length > 0)
27170
27180
  ctx.indentAtStart = (ctx.indentAtStart ?? 0) + props.length + 1;
@@ -27423,6 +27433,7 @@ function addPairToJSMap(ctx, map, { key, value }) {
27423
27433
  function stringifyKey(key, jsKey, ctx) {
27424
27434
  if (jsKey === null)
27425
27435
  return '';
27436
+ // eslint-disable-next-line @typescript-eslint/no-base-to-string
27426
27437
  if (typeof jsKey !== 'object')
27427
27438
  return String(jsKey);
27428
27439
  if (isNode(key) && ctx?.doc) {
@@ -34314,7 +34325,7 @@ let manifest;
34314
34325
  try {
34315
34326
  // eslint-disable-next-line @typescript-eslint/ban-ts-comment
34316
34327
  // @ts-ignore
34317
- manifest = (await import('../manifest-BJp8WsoA.js')).default;
34328
+ manifest = (await import('../manifest-CVLhuDVf.js')).default;
34318
34329
  }
34319
34330
  catch {
34320
34331
  const name = "../dist/manifest.js";
@@ -45448,39 +45459,62 @@ function isMapLike(value) {
45448
45459
  return "entries" in value && typeof value.entries === "function";
45449
45460
  }
45450
45461
 
45451
- const TypeConfig = {
45462
+ const CommonPropsConfig = {
45463
+ namespace: "parent",
45464
+ name: "value"
45465
+ };
45466
+ const HiddenProps = [
45467
+ "entityKind",
45468
+ "kind",
45469
+ "node",
45470
+ "symbol",
45471
+ "templateNode",
45472
+ "templateArguments",
45473
+ "templateMapper",
45474
+ "instantiationParameters",
45475
+ "decorators",
45476
+ "isFinished"
45477
+ ];
45478
+ const HiddenPropsConfig = Object.fromEntries(HiddenProps.map((prop) => [prop, "skip"]));
45479
+ const TypeConfig = buildConfig({
45452
45480
  Namespace: {
45453
45481
  namespaces: "skip",
45454
- models: "nested",
45455
- scalars: "nested",
45456
- interfaces: "nested",
45457
- operations: "nested",
45458
- unions: "nested",
45459
- enums: "nested",
45460
- decoratorDeclarations: "nested"
45482
+ models: "nested-items",
45483
+ scalars: "nested-items",
45484
+ interfaces: "nested-items",
45485
+ operations: "nested-items",
45486
+ unions: "nested-items",
45487
+ enums: "nested-items",
45488
+ decoratorDeclarations: "nested-items"
45461
45489
  },
45462
45490
  Interface: {
45463
- operations: "nested",
45491
+ operations: "nested-items",
45464
45492
  sourceInterfaces: "ref"
45465
45493
  },
45466
45494
  Operation: {
45467
45495
  interface: "parent",
45468
- parameters: "nested",
45496
+ parameters: "nested-items",
45469
45497
  returnType: "ref",
45470
45498
  sourceOperation: "ref"
45471
45499
  },
45472
45500
  Model: {
45473
- indexer: "skip",
45501
+ indexer: {
45502
+ kind: "nested",
45503
+ properties: {
45504
+ key: "ref",
45505
+ value: "ref"
45506
+ }
45507
+ },
45474
45508
  baseModel: "ref",
45475
45509
  derivedModels: "ref",
45476
- properties: "nested",
45510
+ properties: "nested-items",
45477
45511
  sourceModel: "ref",
45478
45512
  sourceModels: "value"
45479
45513
  },
45480
45514
  Scalar: {
45481
45515
  baseScalar: "ref",
45482
45516
  derivedScalars: "ref",
45483
- constructors: "nested"
45517
+ constructors: "nested-items"
45484
45518
  },
45485
45519
  ModelProperty: {
45486
45520
  model: "parent",
@@ -45490,7 +45524,7 @@ const TypeConfig = {
45490
45524
  defaultValue: "value"
45491
45525
  },
45492
45526
  Enum: {
45493
- members: "nested"
45527
+ members: "nested-items"
45494
45528
  },
45495
45529
  EnumMember: {
45496
45530
  enum: "parent",
@@ -45498,8 +45532,8 @@ const TypeConfig = {
45498
45532
  value: "value"
45499
45533
  },
45500
45534
  Union: {
45501
- expression: "skip",
45502
- variants: "nested"
45535
+ expression: "value",
45536
+ variants: "nested-items"
45503
45537
  },
45504
45538
  UnionVariant: {
45505
45539
  union: "parent",
@@ -45509,13 +45543,13 @@ const TypeConfig = {
45509
45543
  value: "value"
45510
45544
  },
45511
45545
  Decorator: {
45512
- parameters: "nested",
45546
+ parameters: "nested-items",
45513
45547
  implementation: "skip",
45514
45548
  target: "ref"
45515
45549
  },
45516
45550
  ScalarConstructor: {
45517
45551
  scalar: "parent",
45518
- parameters: "nested"
45552
+ parameters: "nested-items"
45519
45553
  },
45520
45554
  FunctionParameter: null,
45521
45555
  Number: {
@@ -45527,10 +45561,10 @@ const TypeConfig = {
45527
45561
  value: "value"
45528
45562
  },
45529
45563
  Tuple: {
45530
- values: "nested"
45564
+ values: "nested-items"
45531
45565
  },
45532
45566
  StringTemplate: {
45533
- spans: "nested",
45567
+ spans: "nested-items",
45534
45568
  stringValue: "value"
45535
45569
  },
45536
45570
  StringTemplateSpan: {
@@ -45543,29 +45577,38 @@ const TypeConfig = {
45543
45577
  },
45544
45578
  // Don't want to expose those for now
45545
45579
  Intrinsic: null
45546
- };
45547
- const CommonPropsConfig = {
45548
- namespace: "parent"
45549
- };
45550
- const HiddenProps = [
45551
- "entityKind",
45552
- "kind",
45553
- "name",
45554
- "node",
45555
- "symbol",
45556
- "templateNode",
45557
- "templateArguments",
45558
- "templateMapper",
45559
- "instantiationParameters",
45560
- "decorators",
45561
- "projector",
45562
- "isFinished"
45563
- ];
45580
+ });
45564
45581
  new Set(HiddenProps);
45565
- function getPropertyRendering(type, key) {
45566
- const properties = TypeConfig[type.kind];
45567
- const action = properties?.[key] ?? CommonPropsConfig[key];
45568
- return action;
45582
+ function getRenderingConfig(type) {
45583
+ return TypeConfig[type.kind];
45584
+ }
45585
+ function buildConfig(raw) {
45586
+ return Object.fromEntries(
45587
+ Object.entries(raw).map(([kind, config]) => {
45588
+ return [kind, buildConfigForKind(config)];
45589
+ })
45590
+ );
45591
+ }
45592
+ function buildConfigForKind(config) {
45593
+ if (config === null) {
45594
+ return null;
45595
+ }
45596
+ return Object.fromEntries(
45597
+ Object.entries({ ...CommonPropsConfig, ...HiddenPropsConfig, ...config }).map(
45598
+ ([key, value]) => {
45599
+ return [key, buildConfigForProperty(value)];
45600
+ }
45601
+ )
45602
+ );
45603
+ }
45604
+ function buildConfigForProperty(value) {
45605
+ if (typeof value === "string") {
45606
+ return { kind: value };
45607
+ }
45608
+ return {
45609
+ kind: "nested",
45610
+ properties: buildConfigForKind(value.properties)
45611
+ };
45569
45612
  }
45570
45613
 
45571
45614
  function expandNamespaces(namespace) {
@@ -45635,7 +45678,7 @@ function computeTypeNode(parentPath, type, name) {
45635
45678
  }
45636
45679
  function computeTypeNodeProps(path, type, name) {
45637
45680
  const typeRendering = TypeConfig[type.kind];
45638
- const children = Object.entries(type).filter(([key]) => typeRendering?.[key] === "nested").map(([key, value]) => {
45681
+ const children = Object.entries(type).filter(([key]) => typeRendering?.[key]?.kind === "nested-items").map(([key, value]) => {
45639
45682
  const propPath = path + "." + key;
45640
45683
  if (isMapLike(value)) {
45641
45684
  return computeItemList(propPath, key, value);
@@ -46055,13 +46098,22 @@ const SimpleType = ({ type, children }) => {
46055
46098
  children
46056
46099
  ] });
46057
46100
  };
46058
- const EntityProperties = ({ entity: type }) => {
46059
- const props = Object.entries(type).map(([key, value]) => {
46060
- const action = getPropertyRendering(type, key);
46061
- if (action === void 0 || action === "skip") {
46101
+ const EntityProperties = ({ entity }) => {
46102
+ return /* @__PURE__ */ jsxRuntimeExports$1.jsx(InspectObject, { value: entity, config: getRenderingConfig(entity) });
46103
+ };
46104
+ const InspectObject = ({
46105
+ value,
46106
+ config
46107
+ }) => {
46108
+ if (value === void 0) {
46109
+ return null;
46110
+ }
46111
+ const props = Object.entries(value).map(([key, value2]) => {
46112
+ const action = config?.[key];
46113
+ if (action === void 0 || action === null || action.kind === "skip") {
46062
46114
  return void 0;
46063
46115
  }
46064
- return /* @__PURE__ */ jsxRuntimeExports$1.jsx(EntityProperty, { name: key, value, action }, key);
46116
+ return /* @__PURE__ */ jsxRuntimeExports$1.jsx(EntityProperty, { name: key, value: value2, action }, key);
46065
46117
  }).filter((x) => Boolean(x));
46066
46118
  return /* @__PURE__ */ jsxRuntimeExports$1.jsx("ul", { children: props });
46067
46119
  };
@@ -46075,12 +46127,15 @@ const EntityProperty = (props) => {
46075
46127
  };
46076
46128
  const EntityPropertyValue = ({ value, action }) => {
46077
46129
  const render = (x) => {
46078
- if (action === "parent") {
46130
+ if (action.kind === "parent") {
46079
46131
  return x.entityKind === "Type" ? /* @__PURE__ */ jsxRuntimeExports$1.jsx(ParentReference, { type: x }) : null;
46080
46132
  }
46081
- const renderRef = action === "ref";
46133
+ const renderRef = action.kind === "ref";
46082
46134
  return renderRef ? /* @__PURE__ */ jsxRuntimeExports$1.jsx(EntityReference, { entity: x }) : /* @__PURE__ */ jsxRuntimeExports$1.jsx(EntityUI, { entity: x });
46083
46135
  };
46136
+ if (action.kind === "nested") {
46137
+ return /* @__PURE__ */ jsxRuntimeExports$1.jsx(InspectObject, { value, config: action.properties });
46138
+ }
46084
46139
  if (value === void 0) {
46085
46140
  return null;
46086
46141
  } else if (value.entityKind) {
@@ -1 +1 @@
1
- {"version":3,"file":"inspect-type.d.ts","sourceRoot":"","sources":["../../../src/react/inspect-type/inspect-type.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAC;AAEvD,OAAO,EAAe,KAAK,iBAAiB,EAAqC,MAAM,OAAO,CAAC;AAU/F,UAAU,gBAAgB;IACxB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;CACzB;AAED,eAAO,MAAM,WAAW,EAAE,iBAAiB,CAAC,gBAAgB,CAM3D,CAAC;AAuEF,eAAO,MAAM,aAAa,EAAE,iBAAiB,CAAC;IAAE,IAAI,EAAE,IAAI,CAAA;CAAE,CAmD3D,CAAC"}
1
+ {"version":3,"file":"inspect-type.d.ts","sourceRoot":"","sources":["../../../src/react/inspect-type/inspect-type.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAC;AAEvD,OAAO,EAAe,KAAK,iBAAiB,EAAqC,MAAM,OAAO,CAAC;AAc/F,UAAU,gBAAgB;IACxB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;CACzB;AAED,eAAO,MAAM,WAAW,EAAE,iBAAiB,CAAC,gBAAgB,CAM3D,CAAC;AAuEF,eAAO,MAAM,aAAa,EAAE,iBAAiB,CAAC;IAAE,IAAI,EAAE,IAAI,CAAA;CAAE,CAmD3D,CAAC"}
@@ -1,19 +1,35 @@
1
- import { Type } from '@typespec/compiler';
2
- export type EntityPropertyConfig = "parent" | "nested" | "ref" | "value" | "skip";
1
+ import { Entity, Type } from '@typespec/compiler';
2
+ export type PropertyRendering<T> = {
3
+ kind: "parent" | "nested-items" | "ref" | "value" | "skip";
4
+ } | NestedPropertyRendering<T>;
5
+ export type PropertyRenderingRaw<T> = "parent" | "nested-items" | "ref" | "value" | "skip" | NestedPropertyRenderingRaw<T>;
6
+ export type PropertiesRenderingRaw<T> = {
7
+ [K in keyof T]: PropertyRenderingRaw<T[K]>;
8
+ };
9
+ export type PropertiesRendering<T> = {
10
+ [K in keyof T]: PropertyRendering<T[K]>;
11
+ };
12
+ export type NestedPropertyRendering<T> = {
13
+ kind: "nested";
14
+ properties: PropertiesRendering<T>;
15
+ };
16
+ export type NestedPropertyRenderingRaw<T> = {
17
+ kind: "nested";
18
+ properties: PropertiesRenderingRaw<T>;
19
+ };
20
+ export declare const CommonPropsConfig: {
21
+ namespace: string;
22
+ name: string;
23
+ };
3
24
  export declare const TypeConfig: TypeGraphConfig;
4
- type PropsToDefine<T extends Type> = Exclude<keyof T, HiddenPropsType | keyof typeof CommonPropsConfig>;
5
- type TypeConfig<T extends Type> = Record<PropsToDefine<T>, EntityPropertyConfig> | null;
25
+ type TypeConfig<T extends Type> = PropertiesRendering<T> | null;
6
26
  type TypeGraphConfig = {
7
27
  [K in Type["kind"]]: TypeConfig<Extract<Type, {
8
28
  kind: K;
9
29
  }>>;
10
30
  };
11
- export declare const CommonPropsConfig: {
12
- namespace: string;
13
- };
14
- declare const HiddenProps: readonly ["entityKind", "kind", "name", "node", "symbol", "templateNode", "templateArguments", "templateMapper", "instantiationParameters", "decorators", "projector", "isFinished"];
15
- type HiddenPropsType = (typeof HiddenProps)[number];
16
- export declare const HiddenPropsSet: Set<"symbol" | "kind" | "entityKind" | "name" | "node" | "templateNode" | "templateArguments" | "templateMapper" | "instantiationParameters" | "decorators" | "projector" | "isFinished">;
17
- export declare function getPropertyRendering<T extends Type, K extends keyof T>(type: T, key: K): EntityPropertyConfig;
31
+ export declare const HiddenPropsSet: Set<"symbol" | "entityKind" | "kind" | "node" | "templateNode" | "templateArguments" | "templateMapper" | "instantiationParameters" | "decorators" | "isFinished">;
32
+ export declare function getPropertyRendering<T extends Type, K extends keyof T>(type: T, key: K): PropertyRenderingRaw<T>;
33
+ export declare function getRenderingConfig<T extends Entity>(type: T): PropertiesRendering<T> | null;
18
34
  export {};
19
35
  //# sourceMappingURL=type-config.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"type-config.d.ts","sourceRoot":"","sources":["../../src/react/type-config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAC;AAE/C,MAAM,MAAM,oBAAoB,GAAG,QAAQ,GAAG,QAAQ,GAAG,KAAK,GAAG,OAAO,GAAG,MAAM,CAAC;AAElF,eAAO,MAAM,UAAU,EAAE,eAgGxB,CAAC;AAEF,KAAK,aAAa,CAAC,CAAC,SAAS,IAAI,IAAI,OAAO,CAC1C,MAAM,CAAC,EACP,eAAe,GAAG,MAAM,OAAO,iBAAiB,CACjD,CAAC;AACF,KAAK,UAAU,CAAC,CAAC,SAAS,IAAI,IAAI,MAAM,CAAC,aAAa,CAAC,CAAC,CAAC,EAAE,oBAAoB,CAAC,GAAG,IAAI,CAAC;AACxF,KAAK,eAAe,GAAG;KACpB,CAAC,IAAI,IAAI,CAAC,MAAM,CAAC,GAAG,UAAU,CAAC,OAAO,CAAC,IAAI,EAAE;QAAE,IAAI,EAAE,CAAC,CAAA;KAAE,CAAC,CAAC;CAC5D,CAAC;AAEF,eAAO,MAAM,iBAAiB;;CAE7B,CAAC;AAEF,QAAA,MAAM,WAAW,sLAaP,CAAC;AACX,KAAK,eAAe,GAAG,CAAC,OAAO,WAAW,CAAC,CAAC,MAAM,CAAC,CAAC;AAEpD,eAAO,MAAM,cAAc,2LAAuB,CAAC;AAEnD,wBAAgB,oBAAoB,CAAC,CAAC,SAAS,IAAI,EAAE,CAAC,SAAS,MAAM,CAAC,EACpE,IAAI,EAAE,CAAC,EACP,GAAG,EAAE,CAAC,GACL,oBAAoB,CAItB"}
1
+ {"version":3,"file":"type-config.d.ts","sourceRoot":"","sources":["../../src/react/type-config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAC;AAEvD,MAAM,MAAM,iBAAiB,CAAC,CAAC,IAC3B;IAAE,IAAI,EAAE,QAAQ,GAAG,cAAc,GAAG,KAAK,GAAG,OAAO,GAAG,MAAM,CAAA;CAAE,GAC9D,uBAAuB,CAAC,CAAC,CAAC,CAAC;AAC/B,MAAM,MAAM,oBAAoB,CAAC,CAAC,IAC9B,QAAQ,GACR,cAAc,GACd,KAAK,GACL,OAAO,GACP,MAAM,GACN,0BAA0B,CAAC,CAAC,CAAC,CAAC;AAElC,MAAM,MAAM,sBAAsB,CAAC,CAAC,IAAI;KAAG,CAAC,IAAI,MAAM,CAAC,GAAG,oBAAoB,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;CAAE,CAAC;AACvF,MAAM,MAAM,mBAAmB,CAAC,CAAC,IAAI;KAAG,CAAC,IAAI,MAAM,CAAC,GAAG,iBAAiB,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;CAAE,CAAC;AAEjF,MAAM,MAAM,uBAAuB,CAAC,CAAC,IAAI;IACvC,IAAI,EAAE,QAAQ,CAAC;IACf,UAAU,EAAE,mBAAmB,CAAC,CAAC,CAAC,CAAC;CACpC,CAAC;AACF,MAAM,MAAM,0BAA0B,CAAC,CAAC,IAAI;IAC1C,IAAI,EAAE,QAAQ,CAAC;IACf,UAAU,EAAE,sBAAsB,CAAC,CAAC,CAAC,CAAC;CACvC,CAAC;AAEF,eAAO,MAAM,iBAAiB;;;CAG7B,CAAC;AAoBF,eAAO,MAAM,UAAU,EAAE,eAsGvB,CAAC;AAOH,KAAK,UAAU,CAAC,CAAC,SAAS,IAAI,IAAI,mBAAmB,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC;AAChE,KAAK,eAAe,GAAG;KACpB,CAAC,IAAI,IAAI,CAAC,MAAM,CAAC,GAAG,UAAU,CAAC,OAAO,CAAC,IAAI,EAAE;QAAE,IAAI,EAAE,CAAC,CAAA;KAAE,CAAC,CAAC;CAC5D,CAAC;AAIF,eAAO,MAAM,cAAc,oKAAuB,CAAC;AAEnD,wBAAgB,oBAAoB,CAAC,CAAC,SAAS,IAAI,EAAE,CAAC,SAAS,MAAM,CAAC,EACpE,IAAI,EAAE,CAAC,EACP,GAAG,EAAE,CAAC,GACL,oBAAoB,CAAC,CAAC,CAAC,CAIzB;AACD,wBAAgB,kBAAkB,CAAC,CAAC,SAAS,MAAM,EAAE,IAAI,EAAE,CAAC,GAAG,mBAAmB,CAAC,CAAC,CAAC,GAAG,IAAI,CAE3F"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@typespec/html-program-viewer",
3
- "version": "0.72.0-dev.0",
3
+ "version": "0.72.0-dev.2",
4
4
  "author": "Microsoft Corporation",
5
5
  "description": "TypeSpec library for emitting an html view of the program.",
6
6
  "homepage": "https://typespec.io",
@@ -39,7 +39,7 @@
39
39
  "@typespec/compiler": "^1.1.0"
40
40
  },
41
41
  "dependencies": {
42
- "@fluentui/react-components": "~9.63.0",
42
+ "@fluentui/react-components": "~9.66.1",
43
43
  "@fluentui/react-icons": "^2.0.292",
44
44
  "@fluentui/react-list": "^9.1.2",
45
45
  "react": "~18.3.1",
@@ -51,7 +51,7 @@
51
51
  "@testing-library/dom": "^10.4.0",
52
52
  "@testing-library/jest-dom": "^6.6.3",
53
53
  "@testing-library/react": "^16.2.0",
54
- "@types/node": "~22.13.11",
54
+ "@types/node": "~24.0.3",
55
55
  "@types/react": "~18.3.11",
56
56
  "@types/react-dom": "~18.3.0",
57
57
  "@typespec/compiler": "^1.1.0",
@@ -63,7 +63,7 @@
63
63
  "typescript": "~5.8.2",
64
64
  "vite": "^6.2.7",
65
65
  "vite-plugin-checker": "^0.9.1",
66
- "vite-plugin-dts": "4.5.3",
66
+ "vite-plugin-dts": "4.5.4",
67
67
  "vite-plugin-node-polyfills": "^0.23.0",
68
68
  "vitest": "^3.1.2",
69
69
  "@typespec/react-components": "^0.57.0"