@typespec/html-program-viewer 0.80.0-dev.0 → 0.80.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.
@@ -4514,7 +4514,8 @@ const TypeConfig = buildConfig({
4514
4514
  operations: "nested-items",
4515
4515
  unions: "nested-items",
4516
4516
  enums: "nested-items",
4517
- decoratorDeclarations: "nested-items"
4517
+ decoratorDeclarations: "nested-items",
4518
+ functionDeclarations: "nested-items"
4518
4519
  },
4519
4520
  Interface: {
4520
4521
  operations: "nested-items",
@@ -4605,6 +4606,7 @@ const TypeConfig = buildConfig({
4605
4606
  default: "value"
4606
4607
  },
4607
4608
  // Don't want to expose those for now
4609
+ FunctionType: null,
4608
4610
  Intrinsic: null
4609
4611
  });
4610
4612
  new Set(HiddenProps);
@@ -1,6 +1,6 @@
1
1
  const manifest = {
2
2
  "version": "1.9.0",
3
- "commit": "942d808c614bdf23c3b865a196c0c51181bebb1a"
3
+ "commit": "14287e848123aab23ebcaefd2ee02f5bea9317dd"
4
4
  };
5
5
 
6
6
  export { manifest as default };
@@ -36296,6 +36296,13 @@ class RekeyableMapImpl {
36296
36296
  return true;
36297
36297
  }
36298
36298
  }
36299
+ function getEnvironmentVariable(envVarName, defaultWhenNotAvailable) {
36300
+ // make sure we are fine in both node and browser environments
36301
+ if (typeof process !== "undefined") {
36302
+ return process?.env?.[envVarName] ?? defaultWhenNotAvailable;
36303
+ }
36304
+ return defaultWhenNotAvailable;
36305
+ }
36299
36306
 
36300
36307
  /**
36301
36308
  * Create a new diagnostics creator.
@@ -36598,6 +36605,13 @@ const diagnostics = {
36598
36605
  /**
36599
36606
  * Checker
36600
36607
  */
36608
+ "experimental-feature": {
36609
+ severity: "warning",
36610
+ messages: {
36611
+ default: paramMessage `${"feature"} is an experimental feature. It may change in the future or be removed. Use with caution and consider providing feedback on this feature.`,
36612
+ functionDeclarations: "Function declarations are an experimental feature that may change in the future. Use with caution and consider providing feedback to the TypeSpec team.",
36613
+ },
36614
+ },
36601
36615
  "using-invalid-ref": {
36602
36616
  severity: "error",
36603
36617
  messages: {
@@ -36742,12 +36756,14 @@ const diagnostics = {
36742
36756
  modelExpression: `Is a model expression type, but is being used as a value here. Use #{} to create an object value.`,
36743
36757
  tuple: `Is a tuple type, but is being used as a value here. Use #[] to create an array value.`,
36744
36758
  templateConstraint: paramMessage `${"name"} template parameter can be a type but is being used as a value here.`,
36759
+ functionReturn: paramMessage `Function returned a type, but a value was expected.`,
36745
36760
  },
36746
36761
  },
36747
36762
  "non-callable": {
36748
36763
  severity: "error",
36749
36764
  messages: {
36750
36765
  default: paramMessage `Type ${"type"} is not is not callable.`,
36766
+ templateParameter: paramMessage `Template parameter '${"name"} extends ${"constraint"}' is not callable. Ensure it is constrained to a function value or callable type (scalar or scalar constructor).`,
36751
36767
  },
36752
36768
  },
36753
36769
  "named-init-required": {
@@ -36787,6 +36803,14 @@ const diagnostics = {
36787
36803
  default: paramMessage `Property '${"propName"}' is required in type '${"targetType"}' but here is optional.`,
36788
36804
  },
36789
36805
  },
36806
+ "parameter-required": {
36807
+ severity: "error",
36808
+ messages: {
36809
+ default: paramMessage `Parameter '${"paramName"}' is required, but optional in the target function.`,
36810
+ missing: paramMessage `Parameter '${"paramName"}' is required, but missing in the target function.`,
36811
+ "rest-to-required": paramMessage `Parameter '${"paramName"}' is required and not satisfied by a rest parameter, as rest parameters are effectively optional.`,
36812
+ },
36813
+ },
36790
36814
  "value-in-type": {
36791
36815
  severity: "error",
36792
36816
  messages: {
@@ -36885,10 +36909,18 @@ const diagnostics = {
36885
36909
  default: "A function declaration must be prefixed with the 'extern' modifier.",
36886
36910
  },
36887
36911
  },
36888
- "function-unsupported": {
36912
+ "function-return": {
36913
+ severity: "error",
36914
+ messages: {
36915
+ default: "Function implementation returned an invalid result.",
36916
+ "invalid-value": paramMessage `Function implementation returned invalid JS value '${"value"}'.`,
36917
+ unassignable: paramMessage `Implementation of '${"name"}' returned ${"entityKind"} '${"return"}', which is not assignable to the declared return type '${"type"}'.`,
36918
+ },
36919
+ },
36920
+ "fn-in-union-expression": {
36889
36921
  severity: "error",
36890
36922
  messages: {
36891
- default: "Function are currently not supported.",
36923
+ default: "Function types in anonymous union expressions must be parenthesized.",
36892
36924
  },
36893
36925
  },
36894
36926
  "missing-implementation": {
@@ -46696,6 +46728,7 @@ var SyntaxKind;
46696
46728
  SyntaxKind[SyntaxKind["ConstStatement"] = 67] = "ConstStatement";
46697
46729
  SyntaxKind[SyntaxKind["CallExpression"] = 68] = "CallExpression";
46698
46730
  SyntaxKind[SyntaxKind["ScalarConstructor"] = 69] = "ScalarConstructor";
46731
+ SyntaxKind[SyntaxKind["FunctionTypeExpression"] = 70] = "FunctionTypeExpression";
46699
46732
  })(SyntaxKind || (SyntaxKind = {}));
46700
46733
  var IdentifierKind;
46701
46734
  (function (IdentifierKind) {
@@ -49065,20 +49098,20 @@ var Token;
49065
49098
  Token[Token["ElseKeyword"] = 64] = "ElseKeyword";
49066
49099
  Token[Token["IfKeyword"] = 65] = "IfKeyword";
49067
49100
  Token[Token["DecKeyword"] = 66] = "DecKeyword";
49068
- Token[Token["FnKeyword"] = 67] = "FnKeyword";
49069
- Token[Token["ConstKeyword"] = 68] = "ConstKeyword";
49070
- Token[Token["InitKeyword"] = 69] = "InitKeyword";
49101
+ Token[Token["ConstKeyword"] = 67] = "ConstKeyword";
49102
+ Token[Token["InitKeyword"] = 68] = "InitKeyword";
49071
49103
  // Add new statement keyword above
49072
- /** @internal */ Token[Token["__EndStatementKeyword"] = 70] = "__EndStatementKeyword";
49104
+ /** @internal */ Token[Token["__EndStatementKeyword"] = 69] = "__EndStatementKeyword";
49073
49105
  ///////////////////////////////////////////////////////////////
49074
49106
  ///////////////////////////////////////////////////////////////
49075
- /** @internal */ Token[Token["__StartModifierKeyword"] = 70] = "__StartModifierKeyword";
49076
- Token[Token["ExternKeyword"] = 70] = "ExternKeyword";
49077
- /** @internal */ Token[Token["__EndModifierKeyword"] = 71] = "__EndModifierKeyword";
49107
+ /** @internal */ Token[Token["__StartModifierKeyword"] = 69] = "__StartModifierKeyword";
49108
+ Token[Token["ExternKeyword"] = 69] = "ExternKeyword";
49109
+ /** @internal */ Token[Token["__EndModifierKeyword"] = 70] = "__EndModifierKeyword";
49078
49110
  ///////////////////////////////////////////////////////////////
49079
49111
  ///////////////////////////////////////////////////////////////
49080
49112
  // Other keywords
49081
- Token[Token["ExtendsKeyword"] = 71] = "ExtendsKeyword";
49113
+ Token[Token["ExtendsKeyword"] = 70] = "ExtendsKeyword";
49114
+ Token[Token["FnKeyword"] = 71] = "FnKeyword";
49082
49115
  Token[Token["TrueKeyword"] = 72] = "TrueKeyword";
49083
49116
  Token[Token["FalseKeyword"] = 73] = "FalseKeyword";
49084
49117
  Token[Token["ReturnKeyword"] = 74] = "ReturnKeyword";
@@ -49476,10 +49509,20 @@ function getTypeName(type, options) {
49476
49509
  return type.value.toString();
49477
49510
  case "Intrinsic":
49478
49511
  return type.name;
49512
+ case "FunctionType":
49513
+ return getFunctionSignature(type);
49479
49514
  default:
49480
49515
  return `(unnamed type)`;
49481
49516
  }
49482
49517
  }
49518
+ function getFunctionSignature(type) {
49519
+ const parameters = [...type.parameters].map((x) => {
49520
+ const rest = x.rest ? "..." : "";
49521
+ const optional = x.optional ? "?" : "";
49522
+ return `${rest}${x.name}${optional}: ${getEntityName(x.type)}`;
49523
+ });
49524
+ return `fn (${parameters.join(", ")}) => ${getEntityName(type.returnType)}`;
49525
+ }
49483
49526
  function getValuePreview(value, options) {
49484
49527
  switch (value.valueKind) {
49485
49528
  case "ObjectValue":
@@ -49498,6 +49541,9 @@ function getValuePreview(value, options) {
49498
49541
  return "null";
49499
49542
  case "ScalarValue":
49500
49543
  return `${getTypeName(value.type, options)}.${value.value.name}(${value.value.args.map((x) => getValuePreview(x, options)).join(", ")}})`;
49544
+ case "Function": {
49545
+ return `fn ${value.name ?? "<anonymous>"}`;
49546
+ }
49501
49547
  }
49502
49548
  }
49503
49549
  function getEntityName(entity, options) {
@@ -51440,7 +51486,7 @@ let manifest;
51440
51486
  try {
51441
51487
  // eslint-disable-next-line @typescript-eslint/ban-ts-comment
51442
51488
  // @ts-ignore
51443
- manifest = (await import('../manifest-CKOZ7gJ9.js')).default;
51489
+ manifest = (await import('../manifest-BDDhiZn2.js')).default;
51444
51490
  }
51445
51491
  catch {
51446
51492
  const name = "../dist/manifest.js";
@@ -62553,6 +62599,54 @@ var SemanticTokenKind;
62553
62599
 
62554
62600
  requireMain();
62555
62601
 
62602
+ /**
62603
+ * Debug areas that can be enabled via TYPESPEC_DEBUG environment variable.
62604
+ *
62605
+ * Note: We use TYPESPEC_DEBUG instead of DEBUG because the DEBUG environment variable
62606
+ * is not supported in VSCode extensions. See: https://github.com/microsoft/vscode/issues/290140
62607
+ *
62608
+ * Usage: TYPESPEC_DEBUG=server.compile,compile.config
62609
+ *
62610
+ * Examples:
62611
+ * TYPESPEC_DEBUG=server.compile - Enable server compilation debug logs
62612
+ * TYPESPEC_DEBUG=* - Enable all debug logs
62613
+ * TYPESPEC_DEBUG=server.compile,compile.config - Enable multiple areas
62614
+ */
62615
+ const debugAreas = {
62616
+ serverCompile: "server.compile",
62617
+ updateManager: "update.manager",
62618
+ compileConfig: "compile.config",
62619
+ };
62620
+ /**
62621
+ * Check if a debug area is enabled via the TYPESPEC_DEBUG environment variable.
62622
+ * Supports comma-separated values and wildcards.
62623
+ */
62624
+ function isDebugEnabled(area) {
62625
+ const debug = getEnvironmentVariable("TYPESPEC_DEBUG");
62626
+ if (!debug) {
62627
+ return false;
62628
+ }
62629
+ const areas = debug.split(",").map((a) => a.trim());
62630
+ return areas.some((pattern) => {
62631
+ // Exact match
62632
+ if (pattern === area) {
62633
+ return true;
62634
+ }
62635
+ // Wildcard pattern matching
62636
+ if (pattern.includes("*")) {
62637
+ const regexPattern = pattern.replace(/\*/g, ".*");
62638
+ const regex = new RegExp(`^${regexPattern}$`);
62639
+ return regex.test(area);
62640
+ }
62641
+ return false;
62642
+ });
62643
+ }
62644
+ ({
62645
+ serverCompile: { enabled: isDebugEnabled(debugAreas.serverCompile) },
62646
+ updateManager: { enabled: isDebugEnabled(debugAreas.updateManager) },
62647
+ compileConfig: { enabled: isDebugEnabled(debugAreas.compileConfig) },
62648
+ });
62649
+
62556
62650
  const ProgramContext = createContext(void 0);
62557
62651
  const ProgramProvider = ProgramContext.Provider;
62558
62652
  function useProgram() {
@@ -62601,7 +62695,8 @@ const TypeConfig = buildConfig({
62601
62695
  operations: "nested-items",
62602
62696
  unions: "nested-items",
62603
62697
  enums: "nested-items",
62604
- decoratorDeclarations: "nested-items"
62698
+ decoratorDeclarations: "nested-items",
62699
+ functionDeclarations: "nested-items"
62605
62700
  },
62606
62701
  Interface: {
62607
62702
  operations: "nested-items",
@@ -62692,6 +62787,7 @@ const TypeConfig = buildConfig({
62692
62787
  default: "value"
62693
62788
  },
62694
62789
  // Don't want to expose those for now
62790
+ FunctionType: null,
62695
62791
  Intrinsic: null
62696
62792
  });
62697
62793
  new Set(HiddenProps);
@@ -1 +1 @@
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,C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c,iLAAuB,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.80.0-dev.0",
3
+ "version": "0.80.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",