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

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) {
@@ -1,6 +1,6 @@
1
1
  const manifest = {
2
2
  "version": "1.1.0",
3
- "commit": "cc74c72d4dcfd78a6a6a84e5618a16a5bad462c1"
3
+ "commit": "96088468048e5bc5eb450816a8f047ec68be9646"
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-DvYpHITg.js')).default;
34318
34329
  }
34319
34330
  catch {
34320
34331
  const name = "../dist/manifest.js";
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.1",
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"