@typespec/html-program-viewer 0.70.0-dev.3 → 0.70.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.
@@ -0,0 +1,6 @@
1
+ const manifest = {
2
+ "version": "1.0.0",
3
+ "commit": "b7a5b19167edd6e1d5fc9b1b031a408f52cefd35"
4
+ };
5
+
6
+ export { manifest as default };
@@ -28907,6 +28907,22 @@ function singleton(key, init) {
28907
28907
  function createStateSymbol(name) {
28908
28908
  return Symbol.for(`TypeSpec.${name}`);
28909
28909
  }
28910
+ /**
28911
+ * Instantiate a NameTemplate string with the properties of a source object.
28912
+ *
28913
+ * @param formatString - The template string to format. It should contain placeholders in the form of {propertyName}.
28914
+ * @param sourceObject - The object containing the properties to replace in the template string.
28915
+ * @returns The formatted string with the placeholders replaced by the corresponding property values from the source object.
28916
+ */
28917
+ function replaceTemplatedStringFromProperties(formatString, sourceObject) {
28918
+ // Template parameters are not valid source objects, just skip them
28919
+ if (sourceObject.kind === "TemplateParameter") {
28920
+ return formatString;
28921
+ }
28922
+ return formatString.replace(/{(\w+)}/g, (_, propName) => {
28923
+ return sourceObject[propName];
28924
+ });
28925
+ }
28910
28926
 
28911
28927
  function useStateMap(key) {
28912
28928
  const getter = (program, target) => program.stateMap(key).get(target);
@@ -29090,7 +29106,10 @@ function isTemplateDeclarationOrInstance(type) {
29090
29106
  defineKit({
29091
29107
  array: {
29092
29108
  is(type) {
29093
- return (type.kind === "Model" && isArrayModelType(this.program, type) && type.properties.size === 0);
29109
+ return (type.entityKind === "Type" &&
29110
+ type.kind === "Model" &&
29111
+ isArrayModelType(this.program, type) &&
29112
+ type.properties.size === 0);
29094
29113
  },
29095
29114
  getElementType(type) {
29096
29115
  if (!this.array.is(type)) {
@@ -29196,6 +29215,9 @@ defineKit({
29196
29215
  isAssignableTo: createDiagnosable(function (source, target, diagnosticTarget) {
29197
29216
  return this.program.checker.isTypeAssignableTo(source, target, diagnosticTarget ?? source);
29198
29217
  }),
29218
+ resolve: createDiagnosable(function (reference) {
29219
+ return this.program.resolveTypeOrValueReference(reference);
29220
+ }),
29199
29221
  },
29200
29222
  });
29201
29223
 
@@ -29251,7 +29273,7 @@ defineKit({
29251
29273
  return member;
29252
29274
  },
29253
29275
  is(type) {
29254
- return type.kind === "EnumMember";
29276
+ return type.entityKind === "Type" && type.kind === "EnumMember";
29255
29277
  },
29256
29278
  },
29257
29279
  });
@@ -31322,15 +31344,6 @@ var MutatorFlow;
31322
31344
  })(MutatorFlow || (MutatorFlow = {}));
31323
31345
  // #endregion
31324
31346
 
31325
- function replaceTemplatedStringFromProperties(formatString, sourceObject) {
31326
- // Template parameters are not valid source objects, just skip them
31327
- if (sourceObject.kind === "TemplateParameter") {
31328
- return formatString;
31329
- }
31330
- return formatString.replace(/{(\w+)}/g, (_, propName) => {
31331
- return sourceObject[propName];
31332
- });
31333
- }
31334
31347
  const [getSummary, setSummary] = useStateMap(createStateSymbol("summary"));
31335
31348
  /**
31336
31349
  * @doc attaches a documentation string. Works great with multi-line string literals.
@@ -31410,7 +31423,7 @@ defineKit({
31410
31423
  return en;
31411
31424
  },
31412
31425
  is(type) {
31413
- return type.kind === "Enum";
31426
+ return type.entityKind === "Type" && type.kind === "Enum";
31414
31427
  },
31415
31428
  createFromUnion(type) {
31416
31429
  if (!type.name) {
@@ -31456,6 +31469,9 @@ defineKit({
31456
31469
  get void() {
31457
31470
  return this.program.checker.voidType;
31458
31471
  },
31472
+ is(entity) {
31473
+ return entity.entityKind === "Type" && entity.kind === "Intrinsic";
31474
+ },
31459
31475
  },
31460
31476
  });
31461
31477
 
@@ -31674,13 +31690,13 @@ defineKit({
31674
31690
  });
31675
31691
  },
31676
31692
  isBoolean(type) {
31677
- return type.kind === "Boolean";
31693
+ return type.entityKind === "Type" && type.kind === "Boolean";
31678
31694
  },
31679
31695
  isString(type) {
31680
- return type.kind === "String";
31696
+ return type.entityKind === "Type" && type.kind === "String";
31681
31697
  },
31682
31698
  isNumeric(type) {
31683
- return type.kind === "Number";
31699
+ return type.entityKind === "Type" && type.kind === "Number";
31684
31700
  },
31685
31701
  is(type) {
31686
31702
  return (this.literal.isBoolean(type) || this.literal.isNumeric(type) || this.literal.isString(type));
@@ -31691,7 +31707,7 @@ defineKit({
31691
31707
  defineKit({
31692
31708
  modelProperty: {
31693
31709
  is(type) {
31694
- return type.kind === "ModelProperty";
31710
+ return type.entityKind === "Type" && type.kind === "ModelProperty";
31695
31711
  },
31696
31712
  getEncoding(type) {
31697
31713
  return getEncode(this.program, type) ?? getEncode(this.program, type.type);
@@ -31733,7 +31749,7 @@ defineKit({
31733
31749
  return model;
31734
31750
  },
31735
31751
  is(type) {
31736
- return type.kind === "Model";
31752
+ return type.entityKind === "Type" && type.kind === "Model";
31737
31753
  },
31738
31754
  isExpresion(type) {
31739
31755
  return type.name === "";
@@ -31815,7 +31831,7 @@ defineKit({
31815
31831
  defineKit({
31816
31832
  operation: {
31817
31833
  is(type) {
31818
- return type.kind === "Operation";
31834
+ return type.entityKind === "Type" && type.kind === "Operation";
31819
31835
  },
31820
31836
  getPagingMetadata: createDiagnosable(function (operation) {
31821
31837
  return getPagingOperation(this.program, operation);
@@ -31844,7 +31860,10 @@ defineKit({
31844
31860
  defineKit({
31845
31861
  record: {
31846
31862
  is(type) {
31847
- return (type.kind === "Model" && isRecordModelType(this.program, type) && type.properties.size === 0);
31863
+ return (type.entityKind === "Type" &&
31864
+ type.kind === "Model" &&
31865
+ isRecordModelType(this.program, type) &&
31866
+ type.properties.size === 0);
31848
31867
  },
31849
31868
  getElementType(type) {
31850
31869
  if (!this.record.is(type)) {
@@ -31865,16 +31884,10 @@ defineKit({
31865
31884
  },
31866
31885
  });
31867
31886
 
31868
- defineKit({
31869
- resolve: createDiagnosable(function (reference) {
31870
- return this.program.resolveTypeOrValueReference(reference);
31871
- }),
31872
- });
31873
-
31874
31887
  defineKit({
31875
31888
  scalar: {
31876
31889
  is(type) {
31877
- return type.kind === "Scalar";
31890
+ return type.entityKind === "Type" && type.kind === "Scalar";
31878
31891
  },
31879
31892
  extendsBoolean: extendsStdType("boolean"),
31880
31893
  extendsBytes: extendsStdType("bytes"),
@@ -31962,7 +31975,7 @@ function extendsStdType(typeName) {
31962
31975
  defineKit({
31963
31976
  tuple: {
31964
31977
  is(type) {
31965
- return type.kind === "Tuple";
31978
+ return type.entityKind === "Type" && type.kind === "Tuple";
31966
31979
  },
31967
31980
  create(values = []) {
31968
31981
  const tuple = this.program.checker.createType({
@@ -31976,6 +31989,13 @@ defineKit({
31976
31989
  },
31977
31990
  });
31978
31991
 
31992
+ /**
31993
+ * Simple utility function to capitalize a string.
31994
+ */
31995
+ function capitalize(s) {
31996
+ return (s.charAt(0).toUpperCase() + s.slice(1));
31997
+ }
31998
+
31979
31999
  /**
31980
32000
  * Get a plausible name for the given type.
31981
32001
  * @experimental
@@ -31988,9 +32008,9 @@ function getPlausibleName(type) {
31988
32008
  if (a.entityKind === "Type") {
31989
32009
  switch (a.kind) {
31990
32010
  case "Scalar":
31991
- // Box<scalar> is not a scalar so capital case naming convention applies
31992
32011
  const name = getPlausibleName(a);
31993
- return name.charAt(0).toUpperCase() + name.slice(1);
32012
+ // Box<scalar> is not a scalar so capital case naming convention applies
32013
+ return capitalize(name);
31994
32014
  case "Model":
31995
32015
  case "Interface":
31996
32016
  case "Enum":
@@ -32008,6 +32028,9 @@ function getPlausibleName(type) {
32008
32028
 
32009
32029
  defineKit({
32010
32030
  type: {
32031
+ is(entity) {
32032
+ return entity.entityKind === "Type";
32033
+ },
32011
32034
  finishType(type) {
32012
32035
  this.program.checker.finishType(type);
32013
32036
  },
@@ -32185,7 +32208,7 @@ defineKit({
32185
32208
  return variant;
32186
32209
  },
32187
32210
  is(type) {
32188
- return type.kind === "UnionVariant";
32211
+ return type.entityKind === "Type" && type.kind === "UnionVariant";
32189
32212
  },
32190
32213
  },
32191
32214
  });
@@ -32256,7 +32279,7 @@ defineKit({
32256
32279
  });
32257
32280
  },
32258
32281
  is(type) {
32259
- return type.kind === "Union";
32282
+ return type.entityKind === "Type" && type.kind === "Union";
32260
32283
  },
32261
32284
  isValidEnum(type) {
32262
32285
  for (const variant of type.variants.values()) {
@@ -32301,15 +32324,7 @@ defineKit({
32301
32324
  defineKit({
32302
32325
  value: {
32303
32326
  is(value) {
32304
- const type = value;
32305
- return (this.value.isString(type) ||
32306
- this.value.isNumeric(type) ||
32307
- this.value.isBoolean(type) ||
32308
- this.value.isArray(type) ||
32309
- this.value.isObject(type) ||
32310
- this.value.isEnum(type) ||
32311
- this.value.isNull(type) ||
32312
- this.value.isScalar(type));
32327
+ return value.entityKind === "Value";
32313
32328
  },
32314
32329
  create(value) {
32315
32330
  if (typeof value === "string") {
@@ -32351,28 +32366,28 @@ defineKit({
32351
32366
  };
32352
32367
  },
32353
32368
  isBoolean(type) {
32354
- return type.valueKind === "BooleanValue";
32369
+ return this.value.is(type) && type.valueKind === "BooleanValue";
32355
32370
  },
32356
32371
  isString(type) {
32357
- return type.valueKind === "StringValue";
32372
+ return this.value.is(type) && type.valueKind === "StringValue";
32358
32373
  },
32359
32374
  isNumeric(type) {
32360
- return type.valueKind === "NumericValue";
32375
+ return this.value.is(type) && type.valueKind === "NumericValue";
32361
32376
  },
32362
32377
  isArray(type) {
32363
- return type.valueKind === "ArrayValue";
32378
+ return this.value.is(type) && type.valueKind === "ArrayValue";
32364
32379
  },
32365
32380
  isObject(type) {
32366
- return type.valueKind === "ObjectValue";
32381
+ return this.value.is(type) && type.valueKind === "ObjectValue";
32367
32382
  },
32368
32383
  isEnum(type) {
32369
- return type.valueKind === "EnumValue";
32384
+ return this.value.is(type) && type.valueKind === "EnumValue";
32370
32385
  },
32371
32386
  isNull(type) {
32372
- return type.valueKind === "NullValue";
32387
+ return this.value.is(type) && type.valueKind === "NullValue";
32373
32388
  },
32374
32389
  isScalar(type) {
32375
- return type.valueKind === "ScalarValue";
32390
+ return this.value.is(type) && type.valueKind === "ScalarValue";
32376
32391
  },
32377
32392
  isAssignableTo: createDiagnosable(function (source, target, diagnosticTarget) {
32378
32393
  return this.program.checker.isTypeAssignableTo(source, target, diagnosticTarget ?? source);
@@ -34285,7 +34300,7 @@ let manifest;
34285
34300
  try {
34286
34301
  // eslint-disable-next-line @typescript-eslint/ban-ts-comment
34287
34302
  // @ts-ignore
34288
- manifest = (await import('../manifest-6CNI0MQF.js')).default;
34303
+ manifest = (await import('../manifest-0K2D8hcR.js')).default;
34289
34304
  }
34290
34305
  catch {
34291
34306
  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.70.0-dev.3",
3
+ "version": "0.70.0",
4
4
  "author": "Microsoft Corporation",
5
5
  "description": "TypeSpec library for emitting an html view of the program.",
6
6
  "homepage": "https://typespec.io",
@@ -36,7 +36,7 @@
36
36
  "!dist/test/**"
37
37
  ],
38
38
  "peerDependencies": {
39
- "@typespec/compiler": "^1.0.0-rc.1"
39
+ "@typespec/compiler": "^1.0.0"
40
40
  },
41
41
  "dependencies": {
42
42
  "@fluentui/react-components": "~9.61.2",
@@ -54,7 +54,6 @@
54
54
  "@types/node": "~22.13.11",
55
55
  "@types/react": "~18.3.11",
56
56
  "@types/react-dom": "~18.3.0",
57
- "@typespec/compiler": "^1.0.0-rc.1",
58
57
  "@vitejs/plugin-react": "~4.3.4",
59
58
  "@vitest/coverage-v8": "^3.1.2",
60
59
  "@vitest/ui": "^3.1.2",
@@ -66,6 +65,7 @@
66
65
  "vite-plugin-dts": "4.5.3",
67
66
  "vite-plugin-node-polyfills": "^0.23.0",
68
67
  "vitest": "^3.1.2",
68
+ "@typespec/compiler": "^1.0.0",
69
69
  "@typespec/react-components": "^0.57.0"
70
70
  },
71
71
  "scripts": {
@@ -1,6 +0,0 @@
1
- const manifest = {
2
- "version": "1.0.0-rc.1",
3
- "commit": "7148ab781a5f0736122dbc2dab937e828f9e3272"
4
- };
5
-
6
- export { manifest as default };